Write a policy
policy(id, cedar…) holds exactly one permit or forbid. Interpolate handlers, views, objects, and properties, and Tilde writes the Cedar names for you.
ontology/policies.ts
ontology({ policies }).
Principals
Each call carries a subject, and the actors acting for it. The subject and every actor must each be allowed. An agent never exceeds the person it acts for, and the person never exceeds the agent.
Use these in conditions:
Resources and actions
context.input is the handler’s input, typed from its zod schema.
Field masking
A caller sees a property only withreadField on it. Otherwise the value is null wherever a handler loads it, in output fields tagged with prop(), and inside handler SQL. Grant readField broadly, and forbid the sensitive properties.
Edits
Each edit an action makes is checked on its own. Edits are permitted by default, so only aforbid refuses one. The notes-for-people policy above stops agents changing internal notes through any action.
Approvals
An action can require a person’s approval. Permit it only whencontext.approved is true. A caller who is otherwise allowed then gets pending approval, and the input waits for a decision.