Documentation

Docs

Syntax

Step 8 of the research plan. Draft of 18 November 2026, revised 22 November 2026 (strict read, lattice scale, duty). Designed only after the meaning (Semantics) was fixed and tested. Nothing here adds meaning: every construct translates into the core's rules, facts and readings. Working name only; the name is decision 5.

1. Three Forms of One Rule

A rule exists in three forms. The graph form is the source of truth; the other two are views of it.

Form Who uses it Where it lives
Graph the graph store: a hyperedge node with typed role edges to its anchors, plus its guard, effect and meta the graph store, indexed by anchor (T1)
Text people who review, version and diff rules; tests; the paper .rules files, one module per domain or owner
Sentence owners who approve generated from the graph; never parsed as the source

An owner never edits text. An owner reads a sentence and answers yes, change or no (see The Life of a Rule).

2. The Text Form

2.1 Grammar (EBNF)

module     = "module" NAME "owner" REF { decl } ;
decl       = scale | entity | usecase | rule | default | test ;

scale      = "scale" NAME ":" chain { ";" chain } ;   (* the chains together must form a lattice *)
chain      = NAME "<" NAME { "<" NAME } ;
entity     = "entity" NAME ":" TYPE [ "in" REF { "," REF } ] [ "label" LEVEL ] [ "owner" REF ] ;

usecase    = "usecase" NAME
               "owner" REF
               "positions" REF { "," REF }
               { "needs" REF "max" FORM [ "min_group" INT ] }
               [ "recipients" REF { "," REF } ]
               "valid" ( "until" DATE | "while" STATE_COND | "once" ) ;

rule       = "rule" NAME effect anchors [ guard ] meta { test } ;
effect     = "permit" "up to" FORM
           | "forbid"
           | "cap" "at" FORM
           | "ask" WHOM
           | "boundary" "lifted by" NAME { "," NAME }
           | "duty" DUTY ;                    (* DUTY: min_cell(INT) | cite | draft_only *)
anchors    = "on" anchor { "," anchor } ;
anchor     = ROLE REF ;                      (* ROLE: subject | position | agent | action | asset | recipient *)
guard      = "when" cond { "and" cond } ;
cond       = [ "not" ] FACT_ATOM | "declared" USECASE_ATOM | "read" READING_ATOM | "during" TIME_RANGE ;
meta       = "owner" REF "source" STRING [ "approved" "by" REF DATE ] "valid" ( "until" DATE | "with" NAME ) ;

default    = "default" LEVEL "->" ( "allow" "up to" FORM | "deny" | "ask" WHOM ) ;
test       = "test" ( "allow" FORM | "deny" | "ask" WHOM ) request ;
request    = REF "does" ACTION "on" REF [ "as" FORM ] [ "for" NAME ] [ "to" REF ] [ "via" REF ] [ "at" DATE ] ;

The only place a reading can be written is read …, and the parser accepts read only in rules whose effect is ask or duty, and never after not. This is Restriction N in its strict form (decision 1, 22 November 2026), in the grammar, matching the types of the Lean model (Core.lean): a permit, forbid, cap or boundary with a read condition is a syntax error, not a warning. A permit names a use case with declared usecase(u), which the requester makes. When the model only reads a use case that would allow the request, the system asks the requester to confirm it (SEMANTICS §2.6).

The scale must form a lattice (any two forms have a greatest lower bound); the parser checks it and names the pair that has none.

2.2 Example: the Salary Module

module payroll owner position:cfo

scale form: metadata < count < aggregated < anonymised < pseudonymised < raw;
            aggregated < summarised < raw

entity payroll        : DataProduct label strictly_confidential owner position:cfo
entity payroll.salary : Column in payroll

usecase exec_salary_report
  owner      position:cfo
  positions  position:ceo
  needs      payroll.salary max aggregated min_group 10
  recipients group:executives
  valid      until 2027-06-30

rule pay_boundary
  boundary lifted by exec_salary_report
  on asset payroll
  owner position:cfo  source "Payroll policy §2"  valid until never

rule ceo_report
  permit up to aggregated
  on position position:ceo, asset payroll.salary, action read
  when declared usecase(exec_salary_report) and grant(subject, exec_salary_report)
  owner position:cfo  source "approved use case exec_salary_report"  valid with exec_salary_report
  test allow aggregated  ana does read on payroll.salary for exec_salary_report
  test deny              eva does read on payroll.salary

rule deputy_asks
  ask above(position)
  on position position:deputy_ceo, asset payroll
  owner position:cfo  source "16:32 conversation, 0:05:30"  valid until 2027-06-30
  test ask position:ceo  ben does read on payroll.salary

default public       -> allow up to raw
default internal     -> allow up to raw
default confidential -> deny

3. The Sentence Form

Generated from the graph, one sentence per rule, in the owner's language. Patterns:

Effect Sentence
permit "{position} may {action} {asset}, at most as {form}, for {use case}, until {date}."
forbid "Nobody in {position} may {action} {asset}."
cap "Whatever else is allowed, {asset} leaves no more detailed than {form}."
ask "When {position} asks for {asset}, ask {whom} first."
boundary "{asset} is closed. Only {use case}, approved by {owner}, opens it."
duty "Whenever {asset} is released, {duty in words} (for example: no group smaller than 5 people is shown)."

Every sentence is followed by the cases it decides (its own tests, plus the requests in the record whose answer it changed), so an owner approves examples, not wording.

4. Errors

An error names the axiom the rule breaks, in words, and the smallest change that would fix it.

Rule written Error
forbid on asset payroll when not read usecase(audit) "A model's reading cannot decide a prohibition (axiom A10). Write the prohibition on facts, and put the use case in a permit."
permit up to raw on asset x when read usecase(audit) "A model's reading never opens access (axiom A10, strict mode). Write declared usecase(audit); when the model only reads it, the requester is asked to confirm."
scale form: a < b; a < c "The forms b and c have no common upper bound, so the scale is not a lattice. Add a top form, for example b < raw; c < raw."
permit up to raw on asset x with no owner "Every rule needs an owner who answers for it (A17)."
rule r permit up to raw when grant(subject, u) with no on "A rule must name at least one thing it is about (T1); otherwise it would apply to every request. Write a default instead."
a clause that derives p from p through other rules "Rules may not depend on themselves, except through in (axiom A4)."
valid missing "Every rule ends (A15). Give a date, or tie it to a use case."

5. Compilation

Target What is compiled Used for
The core interpreter (the reference implementation) everything reference meaning and the case suite
Cedar facts-only rules, hierarchies, defaults; readings become context fields analysis: equivalence, implication, what a change adds (T7)
ProbLog rules with readings, readings with their confidence the probability of a use case and the choice between allow and ask
The checker inside each MCP server the published version of the rules a server's assets touch the call-time decision

6. Still Open

  • Whether text files are kept at all, or rules exist only in the graph with the text form generated for review.

Last built 2026-11-25