§4 Policy
Normative schema for policy.json (operation, land, confirm), with coverage rules and the semantics runtimes must enforce.
The Policy file is policy.json at the pack root. It MUST be a JSON object and
is validated strictly: unknown fields at any level MUST fail parse.
4.1 Schema#
type Operation = 'read' | 'write'
type Land = 'personal' | 'brain' | 'local'
type PolicyEntry = {
operation: Operation
privacy: { land: Land }
confirm?: boolean // writes only
}
type PolicyFile = {
surface_id: string // = pack_id
version: 1
verbs: Record<string, PolicyEntry>
stimuli: Record<string, PolicyEntry> // default {}
}4.2 Operation#
readdenotes a command with no side effect an Invoker would need to undo.writedenotes a command that changes state.- Validating a prospective write MUST be
read. - A dry-run or preview mode of a write MUST remain
writeand MUST NOT persist side effects. If persistence cannot be guaranteed the pack MUST NOT offer the flag. - A command that establishes or refreshes Binding MUST be
writeand is additionally gated bypack.connect(§9.4). - A trigger's
operationMUST beread. Sense cannot write.
4.3 Land#
| Token | Meaning | Runtime obligation |
|---|---|---|
personal | Actor-private data or effect | Restrict to the Principal's own scope |
brain | Shared project context | Require project membership; project_id MUST be present |
local | A local workspace directory | Bind to the sandbox working directory. Not a tenant |
- Runtimes MUST reject a land token other than these three.
- Runtimes MUST NOT let a command argument select the tenant. Tenant comes from the Principal's session (§9.2).
- Products MAY map
brainto their own shared-context object. They MUST NOT introduce additional land tokens without an RFC.
4.4 Coverage#
- Every
verb_keyin the manifest MUST appear inverbs. - Every key in
verbsMUST be averb_keyin the manifest. - Every
refin manifeststimulusTriggersMUST appear instimuli. - Every key in
stimuliMUST be a declaredref. surface_idMUST equal the manifestid.
Violations are lint issues of kind missing_verb, extra_verb,
missing_stimulus, extra_stimulus, and write_stimulus (a trigger whose
entry is not read, §4.2.6). Runtimes MUST reject a pack with any of them.
4.5 Confirm#
confirmMAY be set only on entries withoperation: write.- When
confirmistrue, a runtime MUST refuse the command unless the exec envelope'sargscontainsconfirm: trueorapply: true(string"true"is accepted on the CLI face). - The refusal MUST occur before Binding mint and before any Adapter runs, and
MUST return
error: "confirm required". - A pack SHOULD mirror
confirmon the CLI face with a--confirmor--applyflag in the command'scli[]. - No Invoker MAY bypass the gate. Host approval UIs present the gate and do not replace it.
4.6 Grants (informative cross-reference)#
Policy states effect class; runtime capabilities state who. The mapping is normative in §9.4:
operation read → verb.exec.read
operation write → verb.exec.write
connect command → pack.connect
trigger delivery → sense.enable4.7 Example (informative)#
{
"surface_id": "mail",
"version": 1,
"verbs": {
"mail.list": { "operation": "read", "privacy": { "land": "personal" } },
"mail.send": { "operation": "write", "privacy": { "land": "personal" }, "confirm": true },
"mail.connect": { "operation": "write", "privacy": { "land": "personal" } },
"notes.create": { "operation": "write", "privacy": { "land": "brain" } }
},
"stimuli": {
"new_item": { "operation": "read", "privacy": { "land": "personal" } },
"binding.degraded": { "operation": "read", "privacy": { "land": "personal" } }
}
}