Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

requirements.authoring.redaction

Requirements index · View definition

evidence Valid

Requirement

Every source text the harness supplies to a model, including mandatory inputs, habeas reads, and ripgrep results, and every source text Habeas displays in the book or habeas info, MUST be redacted:

  1. In a workspace habeas.toml or user configuration file, the value of every explicit credential field defined by cite requirements.authoring.credentials MUST be replaced. Such a file that is not valid TOML MUST be replaced whole, with configuration as the kind, because its fields cannot be located.
  2. In every source, each match of a built-in rule of the secretshape crate MUST be replaced. The replaced region MUST be extended through each adjacent region that the crate’s entropy heuristic flags and that only whitespace separates from the region, repeating until no flagged region is adjacent. The heuristic MUST NOT cause redaction on its own.

A replacement MUST read [REDACTED:<kind>], where <kind> is the credential field or the rule’s name, and MUST keep every line break within the replaced text, so line numbers are unchanged. Outlines MUST be built from the original source, and the structural hash MUST hash each text piece that overlaps a redacted region in its redacted form, so evidence never depends on a credential’s value and redaction never changes or breaks a file’s outline. The secretshape version MUST be pinned exactly; upgrading it MAY change redaction and hashes and MUST be treated as a deliberate change.

Rationale

The reviewed tests cover each obligation of requirements.authoring.redaction.

Clause 1: credential fields in configuration files

  • src/redaction/tests.rs#fn[configuration_credential_fields_are_redacted_by_name_whatever_their_values] checks all four explicit credential fields: access_key_id, secret_access_key, session_token (including a multi-line value) and api_key.
  • It asserts the exact [REDACTED:<field>] output and an unchanged line count.
  • It also covers inline tables and a nested sub/habeas.toml, and shows that a non-configuration notes.toml is left unchanged.
  • src/redaction/tests.rs#fn[the_user_configuration_file_and_its_aliases_are_configuration_files] covers the user configuration file and its symlink alias.
  • src/redaction/tests.rs#fn[invalid_configuration_files_are_redacted_whole_keeping_lines] checks that invalid TOML is replaced whole as [REDACTED:configuration] with its line breaks kept.

Clause 2: secretshape rule matches and heuristic extension

  • src/redaction/tests.rs#fn[tokens_in_code_are_redacted_without_adjacent_code] checks that a token is replaced and its neighbouring code is untouched.
  • src/redaction/tests.rs#fn[private_keys_are_redacted_from_header_through_body_keeping_lines] checks private key blocks, including line preservation.
  • src/redaction/tests.rs#fn[regions_extend_both_ways_keep_crlf_and_scan_past_a_mebibyte] covers four extension cases:
    • extension backward and forward;
    • chained extension through several adjacent flagged regions;
    • separators other than whitespace (, and ;), which do not extend the region;
    • mixed whitespace including \t and CRLF.
  • It also checks CRLF line breaks and a scan past the default input cap.
  • src/redaction/tests.rs#fn[heuristic_findings_alone_are_not_redacted] shows the heuristic does not cause redaction on its own.

Replacement format and line numbers

  • Every test above asserts the [REDACTED:<kind>] format and an unchanged line count.

Outlines and structural hashes

  • src/redaction/tests.rs#fn[redaction_never_changes_an_outline] builds the outline from the original source. It covers YAML, Rust, TOML, Markdown and plain text, and shows that outlines built from redacted YAML text would differ.
  • src/redaction/tests.rs#fn[hashes_do_not_depend_on_credential_values] shows hashes are independent of the credential value.
  • The same test shows that a change outside a redacted region still changes the hash, and that a non-configuration file’s hash does depend on the value.
  • src/redaction/tests.rs#fn[slices_concatenate_to_the_redacted_whole] shows that redacted slices join to the redacted whole at every split point.

Every source shown or supplied

  • src/authoring/tools.rs#fn[model_inputs_reads_searches_and_citation_prompts_are_redacted] covers mandatory inputs, habeas reads of a configuration file and of line ranges, ripgrep results (including a pattern that matches the credential itself), citation-review inputs, prompts, and commentary.
  • src/authoring/tools.rs#fn[declaration_text_reaches_the_model_redacted] covers requirement and definition text.
  • src/authoring/tools.rs#fn[search_excerpts_stop_at_byte_boundaries_including_attached_comments_and_attributes] and src/authoring/tools.rs#fn[ast_grep_returns_innermost_nodes_of_the_language_and_reports_failures] cover search excerpts.
  • src/authoring/mod.rs#fn[site_prompts_exclude_credentials_from_source_and_configuration] and src/sites.rs#fn[violation_text_reaches_the_model_redacted] cover site prompts and violation text.
  • src/github.rs#fn[the_tool_reads_issues_with_the_token_and_redacts_bodies] covers GitHub issue bodies and the cache.
  • src/index.rs#fn[detail_pages_and_info_display_redacted_source] covers book detail pages, habeas info, validation errors, unresolved inputs, and unreadable records.

Exact version pin

  • Cargo.toml declares secretshape = "=0.1.0" and carries the {impl} reference. This is a declarative pin with no conditional or transformation of its own, so it needs no test.

I found no untested obligation and no wrong expectation.

Inputs

Implementation

Input 21: outline Cargo.toml table[dependencies]/pair[secretshape]
  • File: Cargo.toml
  • Selector: table[dependencies]/pair[secretshape]
  • Kind: pair
  • Cargo.toml:83–85
# Pinned exactly: a new version may change redaction and structural hashes.
# {impl}`requirements.authoring.redaction`
secretshape = "=0.1.0"

Tests

Input 3: outline src/authoring/mod.rs mod[tests]/fn[site_prompts_exclude_credentials_from_source_and_configuration]
    // {test}`requirements.authoring.credentials`
    // {test}`requirements.authoring.redaction`
    #[test]
    fn site_prompts_exclude_credentials_from_source_and_configuration() {
        let token = crate::redaction::tests::github_token();
        let source = crate::sites::tests::SOURCE.replace(
            "fn check_two() {}",
            &format!("fn check_two() {{ let credential = \"{token}\"; }}"),
        );
        let project = crate::sites::tests::project(crate::sites::tests::RULE, &source);
        fs::write(project.path().join("habeas.toml"), "version = 1\n[authoring.configs.local]\nbackend = 'openai'\napi_key = 'SITE_CONFIG_SECRET'\n").unwrap();
        let subject = AuthoringSubject::parse("sites:requirements.rule/src/lib.rs#fn[check_two]");
        let sources = subject.sources(project.path()).unwrap();
        let prompt = initial_prompt(&sources).unwrap().joined();
        assert!(prompt.contains("[REDACTED:GitHub Token]"));
        assert!(!prompt.contains(&token));
        assert!(!prompt.contains("SITE_CONFIG_SECRET"));
    }
Input 4: outline src/authoring/tools.rs mod[tests]/fn[model_inputs_reads_searches_and_citation_prompts_are_redacted]
    // {test}`requirements.authoring.redaction`
    // {test}`requirements.authoring.credentials`
    // {test}`requirements.authoring.source_tools`
    // {test}`requirements.authoring.text_search`
    // {test}`requirements.authoring.mandatory_inputs`
    // {test}`requirements.authoring.citation_prompt`
    // {test}`requirements.authoring.fixme_inputs`
    #[test]
    fn model_inputs_reads_searches_and_citation_prompts_are_redacted() {
        let root = project();
        let token = crate::redaction::tests::github_token();
        fs::write(
            root.path().join("habeas.toml"),
            "version = 1\n[authoring.configs.local]\nbackend = 'ollama'\nmodel = 'm'\napi_key = 'plain ollama key'\n",
        )
        .unwrap();
        fs::write(
            root.path().join("src/lib.rs"),
            format!(
                "// {}\nfn client() -> &'static str {{\n    \"{token}\"\n}}\n\n// :::{} requirements.ready\n// Defaults to {token}.\n// :::\nfn helper() {{}}\n\n// :::{{fixme}} requirements.ready\n// Missing check for {token}.\n// :::\nfn gap() {{}}\n",
                role("test", "requirements.ready"),
                "{cite}"
            ),
        )
        .unwrap();
        git(root.path(), &["init", "--quiet"]);
        git(root.path(), &["add", "."]);
        let leaks = |value: &Value| {
            let text = value.to_string();
            text.contains(&token) || text.contains("plain ollama key")
        };
        // Mandatory inputs, and so the initial and verification prompts.
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        let mandatory = Value::Array(sources.mandatory_inputs().to_vec());
        assert!(!leaks(&mandatory), "{mandatory:#}");
        assert!(mandatory.to_string().contains("[REDACTED:GitHub Token]"));
        let prompt = super::super::initial_prompt(&sources).unwrap().joined();
        assert!(!prompt.contains(&token), "{prompt}");
        assert!(
            prompt.contains("Missing check for [REDACTED:GitHub Token]."),
            "{prompt}"
        );
        assert!(!prompt.contains("fn gap()"), "{prompt}");
        // A habeas read of the configuration file and a line range.
        let read = dispatch(&sources, "habeas", &json!({"file":"habeas.toml","item":""})).unwrap();
        assert!(!leaks(&read.result), "{:#}", read.result);
        assert!(
            read.result["input"]["text"]
                .as_array()
                .unwrap()
                .contains(&json!("api_key = '[REDACTED:api_key]'"))
        );
        let lines = dispatch(
            &sources,
            "habeas",
            &json!({"file":"src/lib.rs","line_start":1}),
        )
        .unwrap();
        assert!(!leaks(&lines.result), "{:#}", lines.result);
        // Search results, even for a pattern matching the credential itself.
        for pattern in ["ollama", "gh[p]_", "Defaults"] {
            let search = dispatch(&sources, "ripgrep", &json!({"pattern": pattern})).unwrap();
            assert!(
                !search.result["matches"].as_array().unwrap().is_empty(),
                "{pattern}"
            );
            assert!(!leaks(&search.result), "{pattern}: {:#}", search.result);
        }
        // A citation review's inputs and its commentary in the prompt.
        let citation =
            AssessmentSources::prepare_citation(root.path(), "src/lib.rs", "fn[helper]").unwrap();
        assert!(!leaks(&Value::Array(citation.mandatory_inputs().to_vec())));
        let prompt = super::super::initial_prompt(&citation).unwrap().joined();
        assert!(!prompt.contains(&token), "{prompt}");
        assert!(
            prompt.contains("Defaults to [REDACTED:GitHub Token]."),
            "{prompt}"
        );
    }
Input 5: outline src/authoring/tools.rs mod[tests]/fn[declaration_text_reaches_the_model_redacted]
    // {test}`requirements.authoring.redaction`
    // {test}`requirements.authoring.source_tools`
    // {test}`requirements.authoring.delivered_inputs`
    // {test}`requirements.definitions.authoring_inputs`
    #[test]
    fn declaration_text_reaches_the_model_redacted() {
        let root = project();
        let token = crate::redaction::tests::github_token();
        fs::write(
            root.path().join("md/terms.md"),
            format!(":::{{definition}} value\n:phrase: value\nA value such as {token}, with a {}.\n:::\n\n:::{{definition}} base\n:phrase: base\nA foundation.\n:::\n", role("term", "terms.base")),
        )
        .unwrap();
        fs::write(
            root.path().join("md/requirements.md"),
            format!(
                ":::{{req}} ready\nThe project MUST accept {token} as a {}.\n{}\n:::\n\n:::{{req}} other\nOther MUST reject\n{token}\non its own line.\n:::\n",
                role("term", "terms.value"),
                role("cite", "requirements.other"),
            ),
        )
        .unwrap();
        git(root.path(), &["init", "--quiet"]);
        git(root.path(), &["add", "."]);
        // The subject, a cited requirement, and a term in the mandatory
        // inputs and so the prompt, with their line structure kept.
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        let mandatory = Value::Array(sources.mandatory_inputs().to_vec());
        let text = mandatory.to_string();
        assert!(!text.contains(&token), "{mandatory:#}");
        for expected in [
            "The project MUST accept [REDACTED:GitHub Token] as a",
            "A value such as [REDACTED:GitHub Token], with a",
            "\"Other MUST reject\",\"[REDACTED:GitHub Token]\",\"on its own line.\"",
        ] {
            assert!(
                text.contains(expected),
                "missing {expected:?}: {mandatory:#}"
            );
        }
        let prompt = super::super::initial_prompt(&sources).unwrap().joined();
        assert!(!prompt.contains(&token), "{prompt}");
        // Requirements and definition reads.
        for arguments in [
            json!({"requirements":"requirements.*"}),
            json!({"definition":"terms.value"}),
        ] {
            let read = dispatch(&sources, "habeas", &arguments).unwrap();
            let text = read.result.to_string();
            assert!(!text.contains(&token), "{arguments}: {:#}", read.result);
            assert!(
                text.contains("[REDACTED:GitHub Token]"),
                "{arguments}: {:#}",
                read.result
            );
            let definition = arguments.get("definition").is_some();
            assert_eq!(read.result["input"].get("definition").is_some(), definition);
            assert_eq!(
                read.result["input"].get("requirements").is_some(),
                !definition
            );
            assert!(read.result.get("inputs").is_none());
            let expected_terms = if definition {
                vec!["terms.base"]
            } else {
                vec!["terms.base", "terms.value"]
            };
            let terms: Vec<_> = read.result["definitions"]
                .as_array()
                .unwrap()
                .iter()
                .map(|input| input["definition"].as_str().unwrap())
                .collect();
            assert_eq!(terms, expected_terms);
            if definition {
                assert_eq!(read.result["input"]["definition"], "terms.value");
                assert_eq!(
                    read.result["input"]["text"],
                    json!([
                        ":::{definition} value",
                        ":phrase: value",
                        "A value such as [REDACTED:GitHub Token], with a {term}`terms.base`.",
                        ":::"
                    ])
                );
            } else {
                assert_eq!(read.result["input"]["requirements"], "requirements.*");
                assert_eq!(
                    read.result["input"]["matches"],
                    json!(["requirements.other", "requirements.ready"])
                );
                assert_eq!(
                    read.result["input"]["text"],
                    json!([
                        ":::{req} other",
                        "Other MUST reject",
                        "[REDACTED:GitHub Token]",
                        "on its own line.",
                        ":::",
                        "",
                        ":::{req} ready",
                        "The project MUST accept [REDACTED:GitHub Token] as a {term}`terms.value`.",
                        "{cite}`requirements.other`",
                        ":::"
                    ])
                );
            }
            let mut fresh = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
            assert!(fresh.recorded_inputs().is_empty());
            fresh.record_inputs(&read.inputs);
            fresh.record_inputs(&read.inputs);
            let mut expected = vec![read.result["input"].clone()];
            expected.extend(
                read.result["definitions"]
                    .as_array()
                    .unwrap()
                    .iter()
                    .cloned(),
            );
            assert_eq!(fresh.recorded_inputs(), expected);
            assert_eq!(read.inputs, expected);
        }
    }
Input 6: outline src/authoring/tools.rs mod[tests]/fn[search_excerpts_stop_at_byte_boundaries_including_attached_comments_and_attributes]
  • File: src/authoring/tools.rs
  • Selector: mod[tests]/fn[search_excerpts_stop_at_byte_boundaries_including_attached_comments_and_attributes]
  • Kind: fn
  • src/authoring/tools.rs:3587–3668
    // {test}`requirements.authoring.search_accounting.excerpts`
    // {test}`requirements.authoring.text_search`
    // {test}`requirements.authoring.structural_search`
    // {test}`requirements.authoring.redaction`
    #[test]
    fn search_excerpts_stop_at_byte_boundaries_including_attached_comments_and_attributes() {
        let root = project();
        let token = format!("ghp_{}", "S".repeat(36));
        fs::write(root.path().join("src/lib.rs"), format!(
            "fn before() {{ unwanted_before(); }}\n\
             /// needle docs\n\
             #[inline]\n\
             fn target() {{\n    let café = \"{token}\";\n    needle();\n}}\n\
             fn after() {{ unwanted_after(); }}\n\
             fn left() {{ unwanted_left(); }} /* needle attached */ #[inline] fn right() {{ needle(); }} fn last() {{ unwanted_last(); }}\n"
        )).unwrap();
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        for (tool, args) in [
            (
                "ripgrep",
                json!({"pattern":"needle","path":"src/lib.rs","context":99}),
            ),
            (
                "ast_grep",
                json!({"language":"rust","path":"src/lib.rs",
                "rule":{"rule":{"any":[{"pattern":"needle()"},{"kind":"block_comment","regex":"needle"}]}}}),
            ),
        ] {
            let result = dispatch(&sources, tool, &args).unwrap().result;
            let matches = result["matches"].as_array().unwrap();
            assert_eq!(matches.len(), 3, "{tool}: {matches:?}");
            assert_eq!(matches[0]["item"], "fn[target]");
            assert_eq!(matches[1]["item"], "fn[left]");
            assert_eq!(matches[2]["item"], "fn[right]");
            assert!(!matches[1]["lines"].to_string().contains("fn right"));
            assert!(!matches[2]["lines"].to_string().contains("fn left"));
            assert!(!matches[2]["lines"].to_string().contains("needle attached"));
            let text = result.to_string();
            for unwanted in [
                "unwanted_before",
                "unwanted_after",
                "unwanted_last",
                "fn last",
            ] {
                assert!(!text.contains(unwanted), "{tool}: {text}");
            }
            assert!(!text.contains(&token), "{text}");
            if tool == "ripgrep" {
                let lines = &matches[0]["lines"];
                assert!(lines.to_string().contains("needle docs"));
                assert!(lines.to_string().contains("#[inline]"));
                assert!(lines.to_string().contains("café"));
                assert!(lines.to_string().contains("[REDACTED:"));
            }
            assert!(matches[1]["lines"].to_string().contains("needle attached"));
            assert!(
                matches[2]["lines"]
                    .to_string()
                    .contains("#[inline] fn right")
            );
        }
        let only = dispatch(
            &sources,
            "ripgrep",
            &json!({"pattern":"café","path":"src/lib.rs","context":0}),
        )
        .unwrap();
        assert_eq!(only.result["matches"].as_array().unwrap().len(), 1);
        assert_eq!(only.result["matches"][0]["item"], "fn[target]");
        let attributes = dispatch(
            &sources,
            "ripgrep",
            &json!({
                "pattern":"inline","path":"src/lib.rs","context":0
            }),
        )
        .unwrap();
        assert_eq!(
            found(&attributes),
            ["src/lib.rs#fn[target]", "src/lib.rs#fn[right]"]
        );
    }
Input 7: outline src/authoring/tools.rs mod[tests]/fn[ast_grep_returns_innermost_nodes_of_the_language_and_reports_failures]
    // {test}`requirements.authoring.structural_search`
    // {test}`requirements.references.outline_comments`
    // {test}`requirements.authoring.redaction`
    // {test}`requirements.authoring.read_denial`
    #[test]
    fn ast_grep_returns_innermost_nodes_of_the_language_and_reports_failures() {
        let root = project();
        fs::write(
            root.path().join("md/terms.md"),
            ":::{definition} value\n:phrase: value\nA useful value.\n:::\n",
        )
        .unwrap();
        let token = ["gh", "p_", "abcdefghijklmnopqrstuvwxyz0123456789"].concat();
        fs::write(
            root.path().join("src/lib.rs"),
            format!(
                "// {}\nfn first() {{\n    let x = value.unwrap();\n}}\n\n/// Calls unwrap in docs.\nfn second() {{\n    other(\"{token}\").unwrap();\n}}\n\nmod inner {{\n    fn third() {{\n        a.unwrap();\n        b.unwrap();\n    }}\n}}\n",
                role("term", "terms.value")
            ),
        )
        .unwrap();
        fs::write(
            root.path().join("src/a.rs"),
            "fn a() {\n    z.unwrap();\n}\n",
        )
        .unwrap();
        fs::write(root.path().join("src/tool.py"), "value.unwrap()\n").unwrap();
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        let rust = |rule: Value, path: &str| {
            dispatch(
                &sources,
                "ast_grep",
                &json!({"language":"rust","rule":rule,"path":path}),
            )
        };
        let search = rust(json!({"rule":{"pattern":"$X.unwrap()"}}), ".").unwrap();
        // Only Rust files are searched, ordered by path and then line, and
        // each node once.
        assert_eq!(
            found(&search),
            [
                "src/a.rs#fn[a]",
                "src/lib.rs#fn[first]",
                "src/lib.rs#fn[second]",
                "src/lib.rs#mod[inner]/fn[third]"
            ]
        );
        // Each entry shows the matched lines, redacted; no terminology is
        // supplied.
        let second = &matched(&search)[2]["lines"];
        assert_eq!(second[0]["matched"], true);
        assert!(second.to_string().contains("[REDACTED:"), "{second}");
        assert!(!second.to_string().contains(&token), "{second}");
        assert_eq!(
            matched(&search)[3]["lines"],
            json!([
                {"text": "        a.unwrap();", "matched": true},
                {"text": "        b.unwrap();", "matched": true},
            ])
        );
        assert!(search.result.get("definitions").is_none());
        // A match in a comment belongs to the comment's owner; utils and
        // constraints are accepted.
        let comment = rust(
            json!({
                "rule": {"matches": "doc"},
                "utils": {"doc": {"kind": "line_comment", "regex": "unwrap"}}
            }),
            "src/lib.rs",
        )
        .unwrap();
        assert_eq!(found(&comment), ["src/lib.rs#fn[second]"]);
        let constrained = rust(
            json!({
                "rule": {"pattern": "$X.unwrap()"},
                "constraints": {"X": {"regex": "^[ab]$"}}
            }),
            "src",
        )
        .unwrap();
        assert_eq!(found(&constrained), ["src/lib.rs#mod[inner]/fn[third]"]);
        let python = dispatch(
            &sources,
            "ast_grep",
            &json!({"language":"python","rule":{"rule":{"pattern":"$X.unwrap()"}}}),
        )
        .unwrap();
        assert_eq!(found(&python), ["src/tool.py#"]);
        let none = rust(json!({"rule":{"pattern":"missing()"}}), ".").unwrap();
        assert_eq!(none.result["matches"], json!([]));
        assert!(none.inputs.is_empty());
        for (arguments, message) in [
            (
                json!({"language":"cobol","rule":{"rule":{"kind":"x"}}}),
                "unknown structural search language",
            ),
            (
                json!({"rule":{"rule":{"kind":"x"}}}),
                "language must be a string",
            ),
            (
                json!({"language":"rust","rule":"x"}),
                "rule must be an object",
            ),
            (
                json!({"language":"rust","rule":{"rule":{"kind":"no_such_kind"}}}),
                "invalid ast-grep rule",
            ),
            (
                json!({"language":"rust","rule":{"pattern":"x"}}),
                "unexpected key \"pattern\"",
            ),
            (
                json!({"language":"rust","rule":{"rule":{"kind":"x"}},"extra":1}),
                "unexpected tool argument \"extra\"",
            ),
            (
                json!({"query":"x","language":"rust"}),
                "unexpected tool argument \"language\"",
            ),
            (
                json!({"query":"x"}),
                "must have the form <full-name>/<query-name>",
            ),
            (
                json!({"query":"requirements.none/sites"}),
                "names no declared requirement",
            ),
            (
                json!({"query":"requirements.ready/sites"}),
                "declares no query named \"sites\"",
            ),
        ] {
            let error = dispatch(&sources, "ast_grep", &arguments).err().unwrap();
            assert!(error.to_string().contains(message), "{arguments}: {error}");
        }
        // A matched file that cannot be parsed fails the search.
        fs::write(
            root.path().join("src/broken.rs"),
            "fn broken() {\n    q.unwrap();\n}\n}\n",
        )
        .unwrap();
        let error = rust(json!({"rule":{"pattern":"$X.unwrap()"}}), "src")
            .err()
            .unwrap();
        assert!(error.to_string().contains("syntax error"), "{error}");
        assert!(sources.recorded_inputs().is_empty());
    }
Input 8: outline src/github.rs mod[tests]/fn[the_tool_reads_issues_with_the_token_and_redacts_bodies]
  • File: src/github.rs
  • Selector: mod[tests]/fn[the_tool_reads_issues_with_the_token_and_redacts_bodies]
  • Kind: fn
  • src/github.rs:823–880
    // {test}`requirements.authoring.github_reads`
    // {test}`requirements.authoring.redaction`
    #[test]
    fn the_tool_reads_issues_with_the_token_and_redacts_bodies() {
        let token = ["ghp_", "abcdefghijklmnopqrstuvwxyz0123456789"].concat();
        let github = FakeGithub::start(&[
            (
                "/repos/example/queue/issues/125",
                200,
                issue("closed", &format!("Leaked {token} here.")),
            ),
            ("/repos/example/queue/issues/7", 200, issue("open", "")),
            ("/repos/example/queue/issues/500", 500, json!({})),
        ]);
        let cache = tempfile::tempdir().unwrap();
        let issues = GithubIssues::with_api(
            github.endpoint.clone(),
            Some(cache.path().to_owned()),
            Some("TEST_TOKEN".to_owned()),
        );
        let read = tool(&issues, &json!({"issue": "example/queue#125"})).unwrap();
        assert_eq!(read["reference"], "example/queue#125");
        assert_eq!(read["state"], "closed");
        assert_eq!(read["title"], "Queue capacity");
        let body = read["body"].as_str().unwrap();
        assert!(
            !body.contains(&token) && body.contains("[REDACTED"),
            "{body}"
        );
        let head = github.requests.lock().unwrap()[0].clone();
        assert!(
            head.starts_with("GET /repos/example/queue/issues/125 "),
            "{head}"
        );
        assert!(head.contains("Bearer TEST_TOKEN"), "{head}");
        // The cache keeps only redacted text.
        let cached = fs::read_to_string(cache.path().join("example+queue+125.json")).unwrap();
        assert!(!cached.contains(&token), "{cached}");
        assert_eq!(
            tool(&issues, &json!({"issue": "example/queue#7"})).unwrap()["state"],
            "open"
        );

        for (arguments, message) in [
            (json!({"issue": "example/queue"}), "not an issue reference"),
            (json!({"issue": "#7"}), "not an issue reference"),
            (json!({"issue": "o/r#1", "extra": 1}), "exactly an issue"),
            (json!({"issue": "example/queue#404"}), "does not exist"),
            (json!({"issue": "example/queue#500"}), "HTTP 500"),
        ] {
            let error = tool(&issues, &arguments).unwrap_err();
            assert!(error.contains(message), "{arguments}: {error}");
        }
        let unreachable = GithubIssues::with_api("http://127.0.0.1:9".to_owned(), None, None);
        let error = tool(&unreachable, &json!({"issue": "example/queue#1"})).unwrap_err();
        assert!(error.contains("cannot read GitHub issue"), "{error}");
        assert_eq!(unreachable.read("example/queue#1").state(), "open");
    }
Input 9: outline src/index.rs mod[tests]/fn[detail_pages_and_info_display_redacted_source]
  • File: src/index.rs
  • Selector: mod[tests]/fn[detail_pages_and_info_display_redacted_source]
  • Kind: fn
  • src/index.rs:1341–1461
    // {test}`requirements.authoring.redaction`
    // {test}`requirements.index.detail_format`
    // {test}`requirements.cli.info`
    #[test]
    fn detail_pages_and_info_display_redacted_source() {
        let token = crate::redaction::tests::github_token();
        let temp = tempfile::tempdir().unwrap();
        let root = temp.path();
        fs::create_dir_all(root.join("src")).unwrap();
        fs::create_dir_all(root.join("md")).unwrap();
        fs::create_dir_all(root.join("evidence")).unwrap();
        fs::write(root.join("book.toml"), "[book]\nsrc = 'md'\n").unwrap();
        fs::write(
            root.join("md/requirements.md"),
            format!(":::{{req}} ready\nTokens such as {token} MUST be hidden.\n:::\n"),
        )
        .unwrap();
        fs::write(
            root.join("src/main.rs"),
            format!("fn main() {{\n    println!(\"{token}\");\n}}\n"),
        )
        .unwrap();
        fs::write(
            root.join("habeas.toml"),
            "version = 1\n[authoring.configs.local]\nbackend = 'ollama'\nmodel = 'm'\napi_key = 'plain ollama key'\n",
        )
        .unwrap();
        let record = json!({
            "requirement": format!("Tokens such as {token} MUST be hidden."),
            "determination": true,
            "rationale": "Checked.",
            "inputs": [
                crate::inputs::outline_input(root, "src/main.rs", "fn[main]").unwrap(),
                crate::inputs::outline_input(root, "habeas.toml", "").unwrap(),
                {"requirements": "requirements.ready", "matches": ["requirements.ready"], "text": [format!("Tokens such as {token} MUST be hidden.")]},
            ]
        });
        fs::write(
            root.join("evidence/requirements.ready.json"),
            record.to_string(),
        )
        .unwrap();
        let definition = Definition {
            path: Path::new("requirements.md").to_path_buf(),
            text: format!("Tokens such as {token} MUST be hidden."),
            kind: DefinitionKind::Requirement,
        };
        let record = record.to_string();
        let page = render_detail_page(
            "requirements.ready",
            Path::new("appendix/requirements-index/requirements.ready.md"),
            None,
            &definition,
            DetailEvidence {
                state: EvidenceState::Valid,
                record: Some(&record),
                errors: &[],
                fixme_entries: &[],
            },
            &RenderSources {
                root,
                definitions: &BTreeMap::new(),
                references: &[],
                source_links: None,
                outlines: &crate::inputs::OutlineCache::default(),
            },
        );
        let info = crate::commands::info_markdown(root, "requirements.ready").unwrap();
        for page in [page, info] {
            assert!(!page.contains(&token), "{page}");
            assert!(!page.contains("plain ollama key"), "{page}");
            assert!(
                page.contains("Tokens such as [REDACTED:GitHub Token] MUST be hidden."),
                "{page}"
            );
            assert!(
                page.contains("    println!(\"[REDACTED:GitHub Token]\");"),
                "{page}"
            );
            assert!(page.contains("api_key = '[REDACTED:api_key]'"), "{page}");
        }

        // Validation findings, an unresolved input shown as raw JSON, and an
        // unreadable record are redacted too.
        let unresolved = json!({
            "requirement": "Ready.",
            "determination": true,
            "rationale": "Checked.",
            "inputs": [{"file": "src/gone.rs", "item": "fn[gone]", "hash": token}],
        })
        .to_string();
        let unreadable = format!("{{broken {token}");
        let errors = [format!("evidence/requirements.ready.json: saw {token}")];
        for (record, shown) in [
            (&unresolved, "\"hash\": \"[REDACTED:GitHub Token]\""),
            (&unreadable, "{broken [REDACTED:GitHub Token]"),
        ] {
            let page = render_detail_page(
                "requirements.ready",
                Path::new("appendix/requirements-index/requirements.ready.md"),
                None,
                &definition,
                DetailEvidence {
                    state: EvidenceState::Invalid,
                    record: Some(record),
                    errors: &errors,
                    fixme_entries: &[],
                },
                &RenderSources {
                    root,
                    definitions: &BTreeMap::new(),
                    references: &[],
                    source_links: None,
                    outlines: &crate::inputs::OutlineCache::default(),
                },
            );
            assert!(!page.contains(&token), "{page}");
            assert!(page.contains("saw [REDACTED:GitHub Token]"), "{page}");
            assert!(page.contains(shown), "{page}");
        }
    }
Input 10: outline src/redaction/tests.rs fn[configuration_credential_fields_are_redacted_by_name_whatever_their_values]
  • File: src/redaction/tests.rs
  • Selector: fn[configuration_credential_fields_are_redacted_by_name_whatever_their_values]
  • Kind: fn
  • src/redaction/tests.rs:53–113
// {test}`requirements.authoring.redaction`
// {test}`requirements.authoring.credentials`
#[test]
fn configuration_credential_fields_are_redacted_by_name_whatever_their_values() {
    let source = "version = 1\n\
        [authoring.configs.cloud]\n\
        backend = 'bedrock'\n\
        model = 'm'\n\
        [authoring.configs.cloud.credentials]\n\
        access_key_id = 'plainaccesskey'\n\
        secret_access_key = \"no prefix secret\"\n\
        session_token = '''\nsession\ntoken'''\n\
        [authoring.configs.local]\n\
        backend = 'ollama'\n\
        model = 'm'\n\
        api_key = 'ollama key'\n";
    let redacted = Redaction::of_file(Path::new("sub/habeas.toml"), source)
        .apply(source)
        .into_owned();
    assert_eq!(
        redacted,
        "version = 1\n\
        [authoring.configs.cloud]\n\
        backend = 'bedrock'\n\
        model = 'm'\n\
        [authoring.configs.cloud.credentials]\n\
        access_key_id = '[REDACTED:access_key_id]'\n\
        secret_access_key = \"[REDACTED:secret_access_key]\"\n\
        session_token = '''[REDACTED:session_token]\n\n'''\n\
        [authoring.configs.local]\n\
        backend = 'ollama'\n\
        model = 'm'\n\
        api_key = '[REDACTED:api_key]'\n"
    );
    assert_eq!(redacted.lines().count(), source.lines().count());
    let fields = credential_fields(source).unwrap();
    assert_eq!(
        fields
            .iter()
            .map(|field| field.setting.as_str())
            .collect::<Vec<_>>(),
        [
            "authoring.configs.cloud.credentials.access_key_id",
            "authoring.configs.cloud.credentials.secret_access_key",
            "authoring.configs.cloud.credentials.session_token",
            "authoring.configs.local.api_key",
        ]
    );
    // Inline tables are found by name too.
    let inline = "version = 1\n[authoring.configs.c]\ncredentials = { access_key_id = 'a1', secret_access_key = 's1' }\n";
    assert_eq!(
        Redaction::of_file(Path::new("habeas.toml"), inline).apply(inline),
        "version = 1\n[authoring.configs.c]\ncredentials = { access_key_id = '[REDACTED:access_key_id]', secret_access_key = '[REDACTED:secret_access_key]' }\n"
    );
    // The same text in a file that is not a configuration file has no
    // credential-shaped value, so it is unchanged.
    assert_eq!(
        Redaction::of_file(Path::new("notes.toml"), source).apply(source),
        source
    );
}
Input 11: outline src/redaction/tests.rs fn[private_keys_are_redacted_from_header_through_body_keeping_lines]
// {test}`requirements.authoring.redaction`
#[test]
fn private_keys_are_redacted_from_header_through_body_keeping_lines() {
    let key = private_key();
    let plain = format!("before\n{key}\nafter\n");
    let redacted = redact_text(&plain).into_owned();
    assert_eq!(
        redacted,
        format!(
            "before\n[REDACTED:Private Key Block]\n\n\n\n-----END {}-----\nafter\n",
            "RSA PRIVATE KEY"
        )
    );
    assert_eq!(redacted.lines().count(), plain.lines().count());

    let rust =
        format!("const KEY: &str = r\"{key}\";\n\nfn after() -> usize {{\n    KEY.len()\n}}\n");
    let redacted = Redaction::of_file(Path::new("src/key.rs"), &rust)
        .apply(&rust)
        .into_owned();
    assert!(!redacted.contains("MIIEow"), "{redacted}");
    assert!(!redacted.contains("VTLw7o"), "{redacted}");
    assert!(!redacted.contains("LxoS2t"), "{redacted}");
    assert!(
        redacted.starts_with("const KEY: &str = r\"[REDACTED:Private Key Block]\n\n\n\n-----END"),
        "{redacted}"
    );
    assert!(redacted.ends_with("\";\n\nfn after() -> usize {\n    KEY.len()\n}\n"));
    assert_eq!(redacted.lines().count(), rust.lines().count());
}
Input 12: outline src/redaction/tests.rs fn[tokens_in_code_are_redacted_without_adjacent_code]
// {test}`requirements.authoring.redaction`
#[test]
fn tokens_in_code_are_redacted_without_adjacent_code() {
    let token = github_token();
    let source = format!(
        "fn client() -> Client {{\n    let token = \"{token}\";\n    Client::builder().token(token).retries(3).build()\n}}\n"
    );
    assert_eq!(
        redact_text(&source),
        "fn client() -> Client {\n    let token = \"[REDACTED:GitHub Token]\";\n    Client::builder().token(token).retries(3).build()\n}\n"
    );
}
Input 13: outline src/redaction/tests.rs fn[heuristic_findings_alone_are_not_redacted]
// {test}`requirements.authoring.redaction`
#[test]
fn heuristic_findings_alone_are_not_redacted() {
    let source = "const DIGEST: &str = \"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\";\n\
        let value = Builder::new(Config42).with_parts(PartsV2::Default).finish_all(true)?;\n\
        let id = \"Xk7pQm2Rv9Ls4Tz8Wn3Yb6Hd\";\n";
    assert!(Redaction::of_text(source).is_empty());
    assert_eq!(redact_text(source), source);
}
Input 14: outline src/redaction/tests.rs fn[hashes_do_not_depend_on_credential_values]
// {test}`requirements.authoring.redaction`
// {test}`requirements.references.structural_hash`
#[test]
fn hashes_do_not_depend_on_credential_values() {
    let config = |key: &str| {
        format!(
            "version = 1\n[authoring.configs.cloud]\nbackend = 'bedrock'\nmodel = 'm'\n[authoring.configs.cloud.credentials]\naccess_key_id = '{key}'\nsecret_access_key = 'secret'\n"
        )
    };
    let hashes = |path: &str, source: &str| {
        let redaction = Redaction::of_file(Path::new(path), source);
        outline(path, source, &redaction)
            .nodes
            .iter()
            .map(|node| (node.selector.clone(), node.structural_hash.clone()))
            .collect::<Vec<_>>()
    };
    assert_eq!(
        hashes("habeas.toml", &config("first")),
        hashes("habeas.toml", &config("second-value"))
    );
    assert_ne!(
        hashes("notes.toml", &config("first")),
        hashes("notes.toml", &config("second-value"))
    );

    let token = github_token();
    let other = format!("gh{}_{}", "p", "aB3dE5fG7hJ9kL1mN3pQ5rS7tV9wX1yZ3aB5");
    let rust = |token: &str| {
        format!(
            "/// Uses `{token}` by default.\nfn token() -> &'static str {{\n    \"{token}\"\n}}\n"
        )
    };
    assert_eq!(
        hashes("src/lib.rs", &rust(&token)),
        hashes("src/lib.rs", &rust(&other))
    );
    let text = |token: &str| format!("token {token}\nother line\n");
    assert_eq!(
        hashes("notes.txt", &text(&token)),
        hashes("notes.txt", &text(&other))
    );
    // Changing code outside a redacted region still changes the hash.
    assert_ne!(
        hashes("src/lib.rs", &rust(&token)),
        hashes("src/lib.rs", &rust(&token).replace("default", "design"))
    );
}
Input 15: outline src/redaction/tests.rs fn[redaction_never_changes_an_outline]
// {test}`requirements.authoring.redaction`
// {test}`requirements.references.outlines`
#[test]
fn redaction_never_changes_an_outline() {
    let token = github_token();
    let cases = [
        // A YAML plain scalar: its redacted text would parse as a flow sequence.
        ("config.yaml", format!("service:\n  token: {token}\n  retries: 3\n")),
        ("src/lib.rs", format!("const KEY: &str = r\"{}\";\nfn after() {{}}\n", private_key())),
        (
            "habeas.toml",
            "version = 1\n[authoring.configs.local]\nbackend = 'ollama'\nmodel = 'm'\napi_key = '''\nkey\n'''\n".to_owned(),
        ),
        ("notes.md", format!("# Notes\n\nUse `{token}`.\n\n## Next\n\nText.\n")),
        ("notes.txt", format!("{}\nafter\n", private_key())),
    ];
    for (path, source) in cases {
        let redaction = Redaction::of_file(Path::new(path), &source);
        assert!(!redaction.is_empty(), "{path}");
        let original = outline(path, &source, &Redaction::default());
        let redacted = outline(path, &source, &redaction);
        assert_eq!(structure(&original), structure(&redacted), "{path}");
        assert_eq!(
            redaction.apply(&source).lines().count(),
            source.lines().count(),
            "{path}"
        );
    }
    // Parsing the redacted YAML text itself would change the outline.
    let yaml = format!("service:\n  token: {token}\n  retries: 3\n");
    let redacted = Redaction::of_text(&yaml).apply(&yaml).into_owned();
    assert_eq!(
        redacted,
        "service:\n  token: [REDACTED:GitHub Token]\n  retries: 3\n"
    );
    assert_ne!(
        structure(&outline("config.yaml", &yaml, &Redaction::default())),
        structure(&outline("config.yaml", &redacted, &Redaction::default()))
    );
}
Input 16: outline src/redaction/tests.rs fn[slices_concatenate_to_the_redacted_whole]
// {test}`requirements.authoring.redaction`
#[test]
fn slices_concatenate_to_the_redacted_whole() {
    let source = format!("a {}\nb\n", private_key());
    let redaction = Redaction::of_text(&source);
    let whole = redaction.apply(&source).into_owned();
    for split in (0..=source.len()).filter(|index| source.is_char_boundary(*index)) {
        let joined = format!(
            "{}{}",
            redaction.slice(&source, 0..split),
            redaction.slice(&source, split..source.len())
        );
        assert_eq!(joined, whole, "split at {split}");
    }
}
Input 17: outline src/redaction/tests.rs fn[invalid_configuration_files_are_redacted_whole_keeping_lines]
// {test}`requirements.authoring.redaction`
#[test]
fn invalid_configuration_files_are_redacted_whole_keeping_lines() {
    let source = "version = 1\n[authoring.configs.local]\napi_key = 'unterminated\n";
    assert_eq!(
        Redaction::of_file(Path::new("habeas.toml"), source).apply(source),
        "[REDACTED:configuration]\n\n\n"
    );
}
Input 18: outline src/redaction/tests.rs fn[the_user_configuration_file_and_its_aliases_are_configuration_files]
// {test}`requirements.authoring.redaction`
#[test]
fn the_user_configuration_file_and_its_aliases_are_configuration_files() {
    let directory = tempfile::tempdir().unwrap();
    let user = directory.path().join("config.toml");
    std::fs::write(&user, "version = 1\n").unwrap();
    assert!(is_configuration_file_for(&user, Some(&user)));
    assert!(is_configuration_file_for(Path::new("a/habeas.toml"), None));
    assert!(!is_configuration_file_for(
        &directory.path().join("other.toml"),
        Some(&user)
    ));
    assert!(!is_configuration_file_for(&user, None));
    #[cfg(unix)]
    {
        let alias = directory.path().join("alias.toml");
        std::os::unix::fs::symlink(&user, &alias).unwrap();
        assert!(is_configuration_file_for(&alias, Some(&user)));
    }
    // The real user configuration path is recognized by `of_file`.
    if let Ok(user) = crate::config::user_config_path() {
        let source = "version = 1\n[authoring.configs.local]\napi_key = 'k'\n";
        assert_eq!(
            Redaction::of_file(&user, source).apply(source),
            "version = 1\n[authoring.configs.local]\napi_key = '[REDACTED:api_key]'\n"
        );
    }
}
Input 19: outline src/redaction/tests.rs fn[regions_extend_both_ways_keep_crlf_and_scan_past_a_mebibyte]
// {test}`requirements.authoring.redaction`
#[test]
fn regions_extend_both_ways_keep_crlf_and_scan_past_a_mebibyte() {
    let token = github_token();
    let source = format!("let pair = \"Xk7pQm2Rv9Ls4Tz8Wn3Yb6Hd {token}\";\n");
    assert_eq!(
        redact_text(&source),
        "let pair = [REDACTED:GitHub Token]\";\n"
    );
    let crlf = format!("a\r\n{}\r\nb\r\n", private_key().replace('\n', "\r\n"));
    let redacted = redact_text(&crlf).into_owned();
    assert!(
        redacted.starts_with("a\r\n[REDACTED:Private Key Block]\r\n\r\n\r\n\r\n-----END"),
        "{redacted:?}"
    );
    assert_eq!(
        redacted.matches("\r\n").count(),
        crlf.matches("\r\n").count()
    );
    // Extension runs forward too, and repeats through each adjacent region.
    let chained =
        format!("let pair = \"{token} Xk7pQm2Rv9Ls4Tz8Wn3Yb6Hd Gq4Vx8Nc2Jw6Pf9Ry3Kt7Mb5\";\n");
    assert_eq!(
        redact_text(&chained),
        "let pair = \"[REDACTED:GitHub Token]\n"
    );
    let entropy = "Xk7pQm2Rv9Ls4Tz8Wn3Yb6Hd";
    for separator in [",", ";"] {
        for source in [
            format!("{entropy}{separator}{token}"),
            format!("{token}{separator}{entropy}"),
        ] {
            let redacted = redact_text(&source);
            assert!(redacted.contains(entropy), "{source}: {redacted}");
            assert!(redacted.contains(separator), "{source}: {redacted}");
            assert!(!redacted.contains(&token), "{source}: {redacted}");
        }
    }
    let spaced = format!("{entropy}\t\r\n{token}\n\t{entropy}");
    let redacted = redact_text(&spaced);
    assert!(!redacted.contains(entropy), "{redacted}");
    assert!(!redacted.contains(&token), "{redacted}");
    assert_eq!(redacted.matches('\n').count(), spaced.matches('\n').count());
    assert!(redacted.contains("\r\n"), "{redacted:?}");
    let large = format!("{}\n{token}\n", "x ".repeat(1 << 20));
    assert!(redact_text(&large).ends_with("\n[REDACTED:GitHub Token]\n"));
}
Input 20: outline src/sites.rs mod[tests]/fn[violation_text_reaches_the_model_redacted]
  • File: src/sites.rs
  • Selector: mod[tests]/fn[violation_text_reaches_the_model_redacted]
  • Kind: fn
  • src/sites.rs:846–884
    // {test}`requirements.authoring.redaction`
    // {test}`requirements.authoring.site_prompt`
    #[test]
    fn violation_text_reaches_the_model_redacted() {
        let token = ["ghp_", "abcdefghijklmnopqrstuvwxyz0123456789"].concat();
        let found = |kind, text: &str| SiteMatch {
            kind,
            query: "q".to_owned(),
            line_start: 1,
            line_end: 1,
            item: "fn[check]".to_owned(),
            text: text.to_owned(),
        };
        let site = SiteItem {
            requirement: "requirements.rule".to_owned(),
            file: "src/lib.rs".to_owned(),
            item: "fn[check]".to_owned(),
            line_start: 1,
            line_end: 1,
            matches: vec![
                found(QueryKind::Sites, "fn check() {}"),
                found(QueryKind::Violations, &format!("connect(\"{token}\")")),
            ],
        };
        let value = site.matches_value();
        assert_eq!(
            value[0],
            json!({"kind": "sites", "query": "q", "item": "fn[check]"})
        );
        assert_eq!(value[1]["kind"], "violations");
        assert_eq!(site.selector_label(), "fn[check]");
        let root_site = SiteItem {
            item: String::new(),
            ..site.clone()
        };
        assert_eq!(root_site.selector_label(), "<root>");
        assert_eq!(value[1]["text"], "connect(\"[REDACTED:GitHub Token]\")");
        assert!(!value.to_string().contains(&token), "{value}");
    }

Referenced definitions

Input 2: requirements selection requirements.authoring.credentials
:::{req} credentials
Bedrock configurations MAY supply `credentials` containing nonempty
`access_key_id`, `secret_access_key`, and optional nonempty `session_token`.
Ollama and OpenAI configurations MAY supply a nonempty `api_key`. Habeas MUST reject a
Bedrock record combining explicit credentials with `aws_profile`, and an Ollama or OpenAI
record combining `api_key` with `api_key_env`.

Explicit credentials MUST be passed directly to the selected provider without
changing process environment variables or writing credential files. Saved
explicit values MUST round-trip; credentials resolved from profiles or the
environment MUST NOT be serialized back. Debug output, configuration diagnostics,
usage records, and initial prompts MUST NOT include credential values. TOML
diagnostics MUST NOT echo credential-containing source lines. A configuration
file containing explicit credentials MAY be read as source; its credential
values MUST be redacted under {cite}`requirements.authoring.redaction`.
Validation MUST report a workspace `habeas.toml` present in the Git index that
contains explicit credentials, naming the file and the credential fields and
recommending credential-source references, because committed credentials leak.

Documentation MUST discourage literal credentials in workspace files and
recommend AWS profiles or environment-variable references. Examples MUST use
placeholders and explain that workspace files may be committed or read as source
when explicitly allowed.
:::

Other sources

Input 1: requirements selection requirements.authoring.redaction
:::{req} redaction
Every source text the harness supplies to a model, including mandatory inputs,
`habeas` reads, and `ripgrep` results, and every source text Habeas displays in
the book or `habeas info`, MUST be redacted:

1. In a workspace `habeas.toml` or user configuration file, the value of every
   explicit credential field defined by {cite}`requirements.authoring.credentials`
   MUST be replaced. Such a file that is not valid TOML MUST be replaced whole,
   with `configuration` as the kind, because its fields cannot be located.
2. In every source, each match of a built-in rule of the `secretshape` crate MUST
   be replaced. The replaced region MUST be extended through each adjacent region
   that the crate's entropy heuristic flags and that only whitespace separates
   from the region, repeating until no flagged region is adjacent. The heuristic
   MUST NOT cause redaction on its own.

A replacement MUST read `[REDACTED:<kind>]`, where `<kind>` is the credential
field or the rule's name, and MUST keep every line break within the replaced
text, so line numbers are unchanged. Outlines MUST be built from the original
source, and the structural hash MUST hash each text piece that overlaps a
redacted region in its redacted form, so evidence never depends on a credential's
value and redaction never changes or breaks a file's outline. The `secretshape` version MUST be pinned exactly; upgrading
it MAY change redaction and hashes and MUST be treated as a deliberate change.
:::