One non-UTF-8 .env.swp blocked everything a checkout sent across a link, and would withhold every tool output under deny. A discovered *.swp, *.swo, *.swn, *.swx or *~ that cannot be read or parsed is now passed over under every setting. One that can be parsed stays known to the redactor. .bak, .env.gpg and [[file]] overrides keep the rule.
5.4 KiB
5.4 KiB
Package: dirigent_fermata
Harness-agnostic secret redaction engine and policy gate for AI coding agents.
Quick Facts
- Type: Library + binary (
fermata) - Main Entry:
src/lib.rs,src/bin/fermata.rs - Dependencies:
ignore,toml,regex,globset,serde,clap(cli feature),aho-corasick,serde_yaml - Status: v0.2 — secret redaction + policy gate (
.botsecretsnow includes[policy]section)
Layering
Three concentric layers; nothing inner imports from anything outer.
core/— harness-unaware, transport-unaware, sync. Types (Op,Decision),.botignorewalker,Policy::check/check_command, path extraction..botsecretscontains a[policy]section for access control rules (fermata.tomlis accepted as an alias for.botsecrets). Sync, no tokio.core/secrets/— the secret filtering engine:config.rs—.botsecretsTOML parser (SecretsConfig,PolicyConfig) and hierarchical resolution (user, project, local override).manifest.rs— discovers secret-containing files from.botsecretspatterns and loads their content for redaction.parser.rs— multi-format secret file parser (.env, TOML, YAML, JSON). Extracts key-value pairs where the value is a secret.patterns.rs— built-in key name patterns (~30 universal patterns like*_KEY,*_SECRET,*_PASSWORD) and gitleaks-derived regex patterns for heuristic scanning.redactor.rs—Redactorbuilds an Aho-Corasick automaton from known secret values and replaces them in arbitrary text. Sub-millisecond performance.scanner.rs—Scannerapplies heuristic regex patterns to detect secrets not covered by the known-value manifest (entropy-based and format-based detection).
harness/—HarnessAdaptertrait over a normalizedToolCall(PreToolUse) andPostToolUsePayload(PostToolUse). Each adapter (Claude, future Codex, etc.) lives in its own submodule, feature-gated. PostToolUse enables output redaction viaupdatedToolOutputbefore content enters the LLM context.bin/fermata.rs— only place whereclap, stdio, and exit codes appear.
Release Model
Developed in this monorepo; planned to be exported as a standalone repo in the future for advertising / external distribution. Development stays here. See docs/tools/fermata.md.
Dependency Direction
dirigent_tools depends on dirigent_fermata, never the reverse. Fermata must remain usable as a standalone hook/MCP without dragging in the in-process ACP tool runtime.
Failure behaviour and known limits
- Hooks fail open, except under
on_parse_error = "deny". Withdenyin effect, PostToolUse replaces the tool output with a refusal naming the file when the config or a secret file cannot be loaded, and PreToolUse answersdenywhen the config or the rules cannot be loaded or applied. A malformed hook payload and a missing working directory stay open: no payload means nothing to render, no directory means no setting to read.fermata checkdoes not refuse on a broken config. - A config that cannot be read: the setting is unknown.
SecretsConfig::denies_on_failurereads the raw bytes of every layer: an uncommented line settingdenycounts, broken layer or not; without one the hook stays open as for any default root; a layer whose bytes cannot be read counts asdeny. - Withholding depends on the harness. Claude Code ignores an
updatedToolOutputthat does not match a built-in tool's output schema and then uses the original, soharness/claude.rskeeps the object's shape (strings replaced, arrays cut to one item,type/modetags kept). A tool whose schema has another enum field can still reject that. PreToolUse does not look at secret files, so the tool has already run. - Redaction sees only a string
tool_response. Claude Code's built-in tools send objects. Those count as empty and pass unredacted under every setting; only thedenyfailure path above handles them. - Errors never quote a file.
ParseError::FormatandSecretsConfigError::Parsekeep the format and line number and drop the parser's text, because it can quote the failing line. Patterns (.botignore,[policy],[files]) can appear in messages: they are not values, and a deny reason names them too. - Editor files never refuse. A discovered file named
*.swp,*.swo,*.swn,*.swxor*~that cannot be read or parsed is passed over silently under everyon_parse_error, in the hooks and in Dirigent's channel filter (which forcesdeny). If it can be parsed its values stay known and are redacted, as before..bak,.origand.env.gpgkeep today's rule, since a hand-made copy can hold live values. A[[file]]override is meant, whatever its name, and keeps the rule too. Files with no parser format (secrets.toml~,#secrets.toml#,secrets.toml.bak) were and are opaque: not read, no refusal, not redacted.
Out of scope (v0.2)
Codex / Gemini hook adapters, MCP server mode, readonly_only Bash mode, audit log, filesystem watcher, context taint tracking. Each is a future task with its own plan.
See also
docs/tools/fermata.md— Dirigent integration plandocs/workpad/brainstorm/fermata.md— canonical product specdocs/architecture/fermata-security-philosophy.md— security philosophy and the reveal triangle.botsecretsformat:core/secrets/config.rs— unified config for secret redaction and policy (fermata.tomlaccepted as alias)