fix(fermata): the hooks refuse under on_parse_error = "deny", and no error quotes a file

PostToolUse replaced nothing when a secret file or the config failed. Under deny
it now puts a refusal naming the file in place of the output, in the tool's own
shape: Claude Code ignores a replacement that does not match a built-in tool's
schema. PreToolUse answers deny for a config or rules it cannot load or apply.

A config that cannot be loaded leaves the setting unknown: a layer with a line
setting deny counts, a layer whose bytes cannot be read counts as deny, and
anything else stays open as today.

Parse errors keep the format and line number and drop the parser's text.
This commit is contained in:
2026-11-06 23:36:57 +01:00
parent 0dc0b87b9d
commit 969cff212f
13 changed files with 599 additions and 133 deletions
+3 -1
View File
@@ -75,7 +75,9 @@ The hook payload is always read from **stdin** as JSON. The response is written
| 0 | Success. The JSON response on stdout tells the harness what to do. |
| 2 | Internal error (unknown harness, unknown event type, stdin read failure) |
Fermata follows a **fail-open** policy for hooks: if the payload cannot be parsed or the policy cannot be loaded, it writes `{}` to stdout and exits 0 so the agent can continue. Errors are reported on stderr.
Fermata follows a **fail-open** policy for hooks: if the payload cannot be parsed or the policy cannot be loaded, it writes `{}` to stdout (PreToolUse: an allow) and exits 0 so the agent can continue. Errors are reported on stderr and never quote a file.
The exception is a project that sets `on_parse_error = "deny"`. If the config or a secret file cannot be loaded, `post-tool-use` replaces the tool output with a refusal naming the file; if the config or the rules cannot be loaded or applied, `pre-tool-use` answers deny. See [`on_parse_error`](configuration.md) for what happens when the config itself is the broken file.
**Event types**
+6 -2
View File
@@ -173,9 +173,13 @@ Parse error actions:
| Action | Behavior |
|--------|----------|
| `mask-entire-file` | Treat the entire file content as a secret. Default and safest. |
| `mask-entire-file` | Default. Warn on stderr and go on without that file's values: they are not redacted. Masking the whole file is not implemented. |
| `allow` | Skip the unparseable file (secrets may leak). |
| `deny` | Block all access to the file. |
| `deny` | The hooks refuse. PostToolUse replaces each tool output with a refusal naming the file, until it parses. |
Messages name the file and the line, never the line's text.
If the config itself cannot be read, the setting is unknown. Any layer with an uncommented line setting `deny` counts, even in a file that does not parse, and PreToolUse then refuses too. A layer whose bytes cannot be read counts as `deny`. Otherwise the hooks stay open.
```toml
[enforcement]
+1 -1
View File
@@ -58,7 +58,7 @@ fermata does not own this layer. It is provided by your container runtime, VM, o
## Design Principles
**Fail-open for availability.** A parse error in `.botsecrets`, an unrecognized file format, or a scanner timeout does not block the agent from working. Redaction failures are logged, not fatal. The agent's productivity is not sacrificed for edge-case security failures.
**Fail-open for availability.** A parse error in `.botsecrets`, an unrecognized file format, or a scanner timeout does not block the agent from working. Redaction failures are logged, not fatal. The agent's productivity is not sacrificed for edge-case security failures. The exception is a project that sets `on_parse_error = "deny"`: there the hooks refuse instead.
**Zero false negatives for declared secrets.** If a value appears in the secret manifest (loaded from files matched by `.botsecrets`), it will be redacted from every tool output, every time. The Aho-Corasick automaton guarantees this -- it finds all occurrences in a single pass at memory-bandwidth speed.