Explainer

Agent Authorization Is a Composition, Not a Module

An agent’s user-facing approval depends on four separate pieces: a written rule, a read-only gate, a durable grant record, and a wrapper that bounds an action.

On this page

Deck: I stopped looking for a single “permission check” in my agent tooling and started reading four pieces that only work together: a written rule, a read-only gate, a durable record of what was granted, and a push wrapper that limits how far a mistake can spread. The gate’s exit codes are where the design’s beliefs become visible.

The user-facing ask is never one component

When an agent is about to take a repository-changing action, what the user sees is one event: the agent asks, waits, then acts. It is tempting to conclude that one module is responsible for that ask. There is no such module, and looking for one leads to bad designs, because the work is divided among pieces with different jobs and different failure modes.

Here is the composition I landed on. I describe it generically rather than by script name, because the shape — not my particular filenames — is the part worth transferring.

A written rule tells the agent when an action counts as risky enough to require a check. It is prose in a place the agent reads, not code in the action’s path. Its job is to turn “should I check first?” into a step the agent takes, rather than a judgment call it infers in the moment.

A read-only gate answers that question. It consults the durable grants and returns a status. It does not perform the risky action, does not modify grants, and does not decide policy from context. It is deliberately boring: a lookup with a verdict.

A grant record is the durable store. Each entry states what is granted, when it expires, who granted it, how risky the action is, and a scope description. The record is where authorization survives after the conversation ends.

A push wrapper narrows the normal push path to session branches. It limits how far a mistaken action can spread when the action goes through it — but it does not make the gate optional, and it cannot stop a caller from bypassing the wrapper.

Read in order, they form a pipeline: the rule decides whether to ask, the gate consults the record to answer, and the wrapper bounds what an approved action can touch. Each piece acts at a different moment, and each has its own characteristic failure — which is why the set is not secure merely because most of it is in place:

PieceWhen it actsHow it fails
Written ruleBefore the action is attemptedGets ignored or misread
Read-only gateAt the moment of decisionGets queried wrongly
Grant recordBetween sessionsGoes missing or stale
Push wrapperOn the path the action takesGets bypassed

Composing them is what makes the ask visible to the user and the consequence bounded.

Exit codes are the design’s opinion about ambiguity

The gate is a script, so its verdict arrives as an exit code: a small integer the caller branches on. Four codes cover the four outcomes I wanted to keep distinguishable:

Exit codeMeaning
0Granted and unexpired
1Not granted
2Expired
3Unknown scope or missing file

Two decisions are visible in that table, and I think they matter more than the mechanism that produces it.

First, expired is not the same as denied. A grant that ran out is a different fact from a grant that never existed, and collapsing them into one status would push whoever reads the result toward the wrong response. “Renew it” and “never ask for that” are different next actions.

Second, and more important: “unknown scope or missing file” is its own status, and the default is to fail closed. A lookup that finds no record and a lookup that cannot tell what it is looking at are not the same, and neither is treated as approval. Treating an unreadable grant file as “no objection” would make the system quietly permissive in exactly the situations where it is least legible. Fail-closed on ambiguity is a cheap rule, and it is only cheap if the status codes make ambiguity expressible in the first place.

One asymmetry in that table deserves to be named rather than smoothed over: code 3 merges two lookup failures — a scope the gate does not recognize, and a grant file it cannot find. Both fail closed, so the merge is deliberate, but it costs the caller a distinction between “I do not know what you are asking about” and “there is no record to read.” If those two facts ever start driving different responses, the remedy is to split the code.

Chat approval is not durable authorization

This is the seam I had to think hardest about. During a session, a user can say yes. That yes is real, and it is also ephemeral: it lives in the conversation, and the conversation ends.

My design keeps those separate. A chat approval is not a grant until it is bridged into the durable record. Until that bridge happens, the gate reports what the record says, not what the transcript says. The alternative — treating conversational consent as authorization — produces a system whose permissions depend on context length, summarization, and whether the right message survived compaction. That is not an authorization system; it is a memory system pretending to be one.

The cost of this choice is real and worth naming: a user can approve something in chat and then be refused, because the approval was never written down. I accept that trade deliberately, which makes it a feature with a support burden rather than a bug. The refusal is legible — the gate answers 1 or 3 — and the remedy is to record the grant, not to re-argue the case.

A script convention is not a sandbox

I want to be plain about the limits, because composition diagrams invite overconfidence.

These pieces are conventions enforced by scripts and by the agent following instructions. If an action can be taken without going through the wrapper, the wrapper does not constrain it. A gate that can be skipped is advisory. A grant record writable by the same processes it is meant to constrain needs its own protection. Written rules shape agent behavior only to the extent the agent consults them.

So no, this design is not universally secure, and it does not make risky operations safe in general. What it does is make the decision explicit, inspectable, and consistent across sessions in a way that “I asked and the user said yes” is not. If I needed true confinement, I would need enforcement below the level of my scripts — a sandbox, a restricted account, or a permission system the agent cannot write to. I have not built that, and I would rather state the gap than imply a property the design does not have.

The point I would carry to another system

The transferable part is not the four components specifically. It is the observation that authorization has three separable responsibilities — four components carry them, with the gate and the record sharing one — and conflating them is where designs go wrong:

  1. Knowing when to ask — the rule.
  2. Knowing what has already been agreed — the gate plus the record.
  3. Limiting what the action can do even when the answer is yes — the wrapper.

A system that collapses 1 and 2 makes the agent the arbiter of its own risk classification. A system that collapses 2 and 3 makes a single stale grant into a standing capability. Keeping them separate is what made the composition legible to me, and it is what makes the ask feel like one thing to the user while remaining four auditable things underneath.