One list, merged from both READMEs and security-model.md "Known limits", each entry with its test. Entries fixed on this branch are gone. Both READMEs keep the warning and point at the page. tests/docs_known_failures.rs keeps the page and known_limits.rs in step, and test_crate_export.py checks that the public README's links resolve in the exported tree.
9.2 KiB
9.2 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/check_command_paths,paths.rs(command segments, verb classes, the named files)..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). Every config struct hasdeny_unknown_fields;[enforcement]holdson_parse_error(defaultallow),on_unparsed_readandon_mask_write(defaultdeny), and nothing else.manifest.rs— discovers secret-containing files from.botsecretspatterns and loads their content for redaction. One entry per spelling of a value: file text, decoded, escaped forms, each line of a multi-line value from 8 characters (MIN_LINE_LEN).parser.rs— multi-format secret file parser (.env, TOML, YAML per document, JSON, Python, properties, opaque key files). Extracts key-value pairs where the value is a secret, numbers from 6 characters, and a value's text as the file spells it as a second entry of the key.value_class.rs—is_plain_setting: booleans, short numbers, durations and setting-word keys make no entry.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; overlapping matches become one mask under the longest. 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". A broken config layer (a parse error or an unknown field) switches only that layer's rules off, with a note beside text output. Withdenyin effect, PostToolUse answers 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. A glob in[files]or[policy]that does not compile costs only that pattern while open (SecretsConfig::bad_patterns, a note naming pattern, section and layer bybad_pattern_sources); a[files]list with none left leaves the built-in list; underdenythe manifest and PreToolUse refuse, sodirigent_server's filter, which forcesdeny, stays strict.fermata checkexits 2 on a broken config or a bad glob. - 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 says nothing and does not count, so an unreadable global config cannot stop every project on the machine. - Replacing output depends on the harness. Claude Code ignores an
updatedToolOutputthat does not match a built-in tool's output schema and then uses the original.harness/claude.rstherefore walkstool_responsein any shape and masks strings in place.SCHEMA_VALUESlists the enum and literal values of the 87outputSchemagetters in Claude Code v2.1.314, as far as they have values to list (re-read it when a release adds tools): those exact values stay. Not resolved, because they exist only at run time: Workflow'sRUN_OP_STATUSandrunOpOutputFieldsand Artifact'shandlersarms, all flag-gated, and Artifact'sreason. Artifact's pattern fields and thatreasonareARTIFACT_PATTERN_FIELDS: a secret there refuses. A secret elsewhere under those names or in a built-in's object key cannot take a mask, soOutputEdit::Unmaskablerefuses the output under every setting. Refusals: Bash, Read and Artifact answer a minimal schema-valid output, other built-ins keep their shape, MCP gets the plain text.tests/cli_hook_redaction.rschecks shapes against a copy of those schemas, andTOOL_ENUMSthere lists each tool's enums so that dropping a value fails a test; nothing here runs Claude Code. - Read gate and write guard.
SecretFileSetandunmaskable_reasondecide which listed files cannot be masked (no parser, a secret as a whole, unparseable, no value to read, tfstate by position); a Read, a Grep with apathand a printing command naming one is stopped under everyon_parse_errorunlesson_unparsed_read = "allow".count_masksbacks the write guard: a Write, Edit or MultiEdit that adds a mask is stopped unlesson_mask_write = "allow". Commands meet only the session's own project rules, by verb class (docs/security-model.md, Layer 3). What a command writes (Verb::Writes) meets.botignore,[policy.write]and[policy.read], also for a file not there yet, and not the read gate. - The gate approves nothing.
render_decisionanswers{}forDecision::Allow, neverpermissionDecision: "allow", which would skip Claude Code's permission prompt.allow_prefixesonly skips fermata's ownaskrules.[policy.bash]reaches Bash, PowerShell and Monitor. - Redaction limits. The largest: a failed tool (
PostToolUseFailure, including a Bash non-zero exit) cannot be rewritten by any hook and is not hooked, socat .env; falsereaches the model. Only a[policy.bash] denypattern stops that, and only for the spelling it names. Also out of reach: Monitor's output and changed-file attachments. Values split across strings, encoded values, JSON numbers in a response and binary fields are not masked.tests/known_limits.rspins each limit that the binary can show: when one starts to fail, a limit was fixed anddocs/known-failures.mdmust change with it (tests/docs_known_failures.rskeeps the two in step and keeps the failure list out of the README).tests/docs_toml_examples.rsloads every TOML example ofdocs/configuration.mdunderdeny_unknown_fields. Heuristics warn inadditionalContextand do not mask. Full list:docs/known-failures.md. - 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 vim swap file (
*.sw[a-p],*.swx), Kate's*.kate-swpor a*~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: no refusal, not redacted (they are not on the secret list, so the read gate does not meet them either).
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)