Expand description
Per-verb glob-pattern tool permissions — allow / ask / deny (#7948).
Why: tcode_tools: is an exact-match allowlist and cannot express “run
git status freely, never rm, ask about the rest”; the TUI permission
prompt (#3422) also needs a decision object to prompt from.
What: parse_permissions, PermissionMap, PermissionGate, the
PermissionBroker, and session.permission.respond.
Test: permissions::tests::*.
Per-verb glob-pattern tool permissions for tcode agents (#7948).
Why: before this, an agent’s only tool control was tcode_tools: — a flat
exact-match allowlist that can say “this agent may run bash” and nothing
finer. Real coding work needs “git status without asking, never rm, ask
about everything else”, which is what opencode’s permission config
expresses and what the TUI permission prompt (#3422) has to prompt FROM.
What: config (the permissions: frontmatter schema, parser, and
fail-closed validation), matcher (glob matching, subject extraction, and
the precedence order), gate (the runtime decision and the ask/await
round trip), session (per-session pending requests and remembered
grants, plus the daemon-wide broker), redact (credential scrubbing for
the published subject), and protocol (the session.permission.respond
JSON-RPC method).
The legacy tcode_tools allowlist is enforced FIRST: a tool absent from it
is denied before the permission map is consulted, so a map can only narrow
an agent’s reach. #7948: the exception is gate::HARNESS_REGISTERED_TOOLS —
tools the harness wires up for the agent rather than the agent asking for
them — which the allowlist branch skips; a written deny still refuses one.
Stock bundled agents declare no permissions: block, so their behaviour
does not change.
Test: permissions::tests — one test module per submodule.
Re-exports§
pub use config::PermissionConfigError;pub use config::PermissionMap;pub use config::RuleDecision;pub use config::parse_permissions;pub use gate::DEFAULT_ASK_TIMEOUT_SECS;pub use gate::Decision;pub use gate::DenySource;pub use gate::HARNESS_REGISTERED_TOOLS;pub use gate::Outcome;pub use gate::PERMISSION_MODE_ENV;pub use gate::PermissionContext;pub use gate::PermissionEvents;pub use gate::PermissionGate;pub use gate::PermissionMode;pub use matcher::RuleMatch;pub use matcher::subjects_for;pub use matcher::subjects_for_in_root;pub use protocol::PERMISSION_RESPOND_METHOD;pub use protocol::PermissionDecision;pub use redact::redact_subject;pub use session::PermissionBroker;pub use session::SessionPermissions;
Modules§
- config
- Schema, parser, and validation for an agent’s
permissions:frontmatter block (#7948). - gate
- The runtime permission gate: evaluate, ask, await, time out (#7948).
- matcher
- Glob matching, subject extraction, and precedence for a compiled
PermissionMap(#7948). - protocol
- The
session.permission.respondJSON-RPC method and its wire types (#7948). - redact
- Credential scrubbing for a published permission subject (#7948).
- session
- Per-session permission state and the daemon-wide broker (#7948).