Expand description
Policy capabilities: rules that narrow what an agent may do.
A policy is a list of rules, each with an effect, deny or ask, and
exactly one subject: a command prefix, file paths an agent may not read,
file paths it may not edit, or an MCP tool. There is no allow effect. A
policy can come from anyone’s repository or pack, and one that could grant
permissions could quietly widen what an agent may do in every project that
installs it; a policy that can only take permissions away can at worst be
too strict, and too strict is visible.
The subjects are deliberately the intersection of what harnesses can match: commands by prefix and paths by glob. A richer rule would compile into something that means less than it says.
Every harness declares, per effect and subject, how it enforces such a
rule, in the same full / partial / unsupported terms the hooks
specification uses. Until a harness compiles policies, every row is
unsupported, and installing a policy for it is refused rather than
reported as installed.
Structs§
- Policy
Config - The
[policy]section of atype = "policy"manifest. - Policy
Coverage Entry - How one harness enforces one kind of rule.
- Policy
Rule - One
[[policy.rules]]entry, as written. - Rule
Verdict - One rule’s verdict on one harness.
Enums§
- Policy
Effect - What a matching rule does to the call.
- Policy
Subject - A rule’s subject, once validated.
- Policy
Subject Kind - The kind of thing a rule matches.
Constants§
- RULES_
FILE_ HEADER - The first line of a rules file Tuff writes.
Functions§
- enforcement
- Split a policy’s rules by whether a harness enforces them: the zero-based
positions of the rules its matrix covers
fullorpartial, and a record of each rule it coversunsupported, for the lockfile when the policy is installed with--accept-unenforced(RFC-107 D6). - is_
codex_ config - Whether a native permissions file is a Codex
config.toml, where an MCP tool rule sits on the server’s[mcp_servers.<id>]table. - is_
opencode_ config - Whether a native permissions file is an OpenCode config file, whose
permissionobject maps permission names to actions, or to patterns and actions, and whose order OpenCode reads as precedence. - is_
rules_ file - Whether a native permissions file is a rules file, one compiled rule per
line, such as Codex’s
.codex/rules/tuff.rules, rather than a JSON settings file. - managed_
permission_ status - Whether a recorded rule is still in its list:
cleanwhen it is,missingwhen the rule or the file is gone,modifiedwhen the file is no longer valid JSON. - merge_
permissions - Add and remove native permission rules in a harness settings file, given the bytes it holds now, and return the bytes it should hold next.
- no_gaps
- A
RuleGapfor a harness whose matrix rows apply to every rule. - not_
implemented_ matrix - The matrix of a harness Tuff does not compile policies for: every effect
and subject
unsupported, said plainly. - permission_
location - Where
tuff checkreports a compiled rule that is missing: the file for a rules file, the permission for an OpenCode config, the server setting for a Codex config, and the list for a JSON settings file. - remove_
permissions - Take recorded permission rules back out of their settings files.
- validate_
policy - Refuse a policy that could not be enforced as written anywhere: no
rules, or a rule with no subject, two subjects, an
alloweffect, or a malformed pattern. - verdicts
- Look up every rule in a harness’s matrix. A matrix missing a row for a
rule’s effect and subject is treated as
unsupported, never as enforced, and so is a rulegapnames a reason for.
Type Aliases§
- RuleGap
- Why a harness cannot enforce one rule even though its matrix row for the
rule’s effect and subject says it can, such as a pattern its native
setting has no form for;
Nonewhen the row applies.