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.ci.outline_inputs

Requirements index · View definition

evidence Valid

Requirement

For an outline input, Habeas MUST parse file with its language’s grammar under cite requirements.references.outlines and resolve item to exactly one outline node under cite requirements.references.outline_selectors. It MUST compare hash with the node’s current structural hash under cite requirements.references.structural_hash. It MUST derive the node’s inclusive line range, including attached comments and attributes, during validation for display and reference coverage. Moving the node, editing other nodes, or editing comments its profile does not hash MUST NOT invalidate the input. Habeas MUST report a missing file, unsupported language, parse failure, invalid or ambiguous selector, or changed hash.

Rationale

The reviewed tests cover every obligation in requirements.ci.outline_inputs.

Resolve item to exactly one node, and compare hash

  • tests/evidence_boundaries.rs#fn[outline_inputs_survive_moves_and_unhashed_comments_but_not_edits] records valid inputs for fn[alpha], fn[beta] and a plain-text line@ node. It asserts they validate with no errors.
  • The same test edits alpha’s code and beta’s doc comment. It asserts an “outline input changed … no longer has the recorded hash” error for each, naming the file, the selector and the current range.
  • tests/evidence_boundaries.rs#fn[configured_external_inputs_validate_and_remain_subject_to_freshness_and_disallow] and #fn[discovered_external_cargo_outputs_validate_freshness_and_obey_disallow] also assert “outline input changed” after a source edit.
  • tests/outcomes.rs#fn[fixme_does_not_hide_stale_inputs_or_uncovered_references] asserts “outline input changed” for the root node.
  • src/evidence.rs#mod[tests]/fn[collects_missing_orphan_format_false_and_changed_line_errors] asserts the root-node hash mismatch message.

Derive the inclusive line range, including attached comments and attributes

  • The stale-input diagnostics assert the current range for beta. That range spans its doc comment, plain comment, attribute and fn line.
  • src/evidence.rs#mod[tests]/fn[selector_anchors_are_covered_by_inputs_selecting_the_node_or_an_ancestor] asserts the range shown in the coverage diagnostic. It also checks that an input selecting the node, an ancestor or the root covers the anchor.
  • src/authoring/tools.rs#mod[tests]/fn[line_range_reads_record_the_innermost_covering_nodes] checks the line-range-to-node mapping and that the recorded input carries no line numbers.

Moving a node, editing other nodes, or editing unhashed comments must not invalidate the input

  • The survive test prepends a comment and a blank line, so both functions shift. It reformats alpha’s body and shifts plain-text lines, then asserts there are no errors.
  • It then edits work(1) to work(2) in alpha and asserts beta’s input still validates.
  • Whitespace-only reformatting is tolerated, which matches the word-based hash.
  • One thing the test does not do is edit a non-doc comment that sits inside or directly before a node’s body. The test does add a comment line, and it asserts the other inputs stay valid. The comment-exclusion rule itself belongs to requirements.references.structural_hash, which this test is also marked for. I do not count this as a gap for the subject.

Errors the text requires Habeas to report

  • Missing selector: “no outline node matches”.
  • Ambiguous selector: fn[dup] is reported as “is ambiguous”.
  • Invalid selector: fn[unclosed is reported as “invalid outline selector”.
  • Malformed hash: an input with ABC as its hash is rejected.
  • Missing file: “cannot open missing.txt”.
  • Parse failure: src/broken.rs is reported as “cannot parse rust source”.
  • Changed hash: covered above.

Unsupported language The src search found no unsupported-language error. requirements.references.outlines gives every non-supported text file a plain-text profile, so no separate error case exists to test.

The remaining marked tests (the symlink, disallow and external-output tests) check outline inputs through containment paths and also exercise freshness. I found no gap.

Inputs

Tests

Input 5: outline src/authoring/tools.rs mod[tests]/fn[line_range_reads_record_the_innermost_covering_nodes]
    // {test}`requirements.authoring.source_tools`
    // {test}`requirements.authoring.delivered_inputs`
    // {test}`requirements.ci.outline_inputs`
    // {test}`requirements.authoring.no_line_numbers`
    #[test]
    fn line_range_reads_record_the_innermost_covering_nodes() {
        let root = project();
        let source = "use std::fmt;\n\nfn first() {}\n\nmod inner {\n    fn second() {\n        let x = 1;\n    }\n}\n";
        fs::write(root.path().join("src/lib.rs"), source).unwrap();
        let mut sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        // Blank lines between nodes do not select their common ancestor.
        let read = dispatch(
            &sources,
            "habeas",
            &json!({"file":"src/lib.rs","line_start":3,"line_end":7}),
        )
        .unwrap();
        let items = read.result["inputs"]
            .as_array()
            .unwrap()
            .iter()
            .map(|input| {
                assert!(input.get("line_start").is_none());
                input["item"].as_str().unwrap()
            })
            .collect::<Vec<_>>();
        assert_eq!(
            items,
            ["fn[first]", "mod[inner]"],
            "line 5 is mod inner's own line, so the module is selected"
        );
        let nested = dispatch(
            &sources,
            "habeas",
            &json!({"file":"src/lib.rs","line_start":7,"line_end":7}),
        )
        .unwrap();
        assert_eq!(nested.result["inputs"][0]["item"], "mod[inner]/fn[second]");
        assert_eq!(
            nested.result["inputs"][0]["text"],
            json!(["    fn second() {", "        let x = 1;", "    }"])
        );
        sources.record_inputs(&nested.inputs);
        assert_eq!(
            sources.recorded_inputs(),
            [
                crate::inputs::outline_input(root.path(), "src/lib.rs", "mod[inner]/fn[second]")
                    .unwrap()
            ]
        );
        assert!(sources.recorded_inputs()[0].get("line_start").is_none());
        assert!(sources.recorded_inputs()[0].get("text").is_none());
        let whole = dispatch(
            &sources,
            "habeas",
            &json!({"file":"src/lib.rs","line_start":1}),
        )
        .unwrap();
        assert!(
            whole.result["inputs"][0]["item"]
                .as_str()
                .unwrap()
                .starts_with("use@")
        );
        assert_eq!(whole.result["inputs"].as_array().unwrap().len(), 3);
        fs::write(root.path().join("notes.txt"), "alpha\nbeta\ngamma\ndelta\n").unwrap();
        let plain = dispatch(
            &sources,
            "habeas",
            &json!({"file":"notes.txt","line_start":2,"line_end":3}),
        )
        .unwrap();
        let inputs = plain.result["inputs"].as_array().unwrap();
        assert_eq!(inputs.len(), 2);
        assert_eq!(inputs[0]["text"], json!(["beta"]));
        assert_eq!(inputs[1]["text"], json!(["gamma"]));
        assert_ne!(inputs[0]["item"], inputs[1]["item"]);
        for input in inputs {
            assert!(input["item"].as_str().unwrap().starts_with("line@"));
            assert!(input.get("line_start").is_none());
            assert!(input.get("line_end").is_none());
        }
    }
Input 6: outline src/evidence.rs mod[tests]/fn[validates_full_names_requirement_text_and_input_lines]
  • File: src/evidence.rs
  • Selector: mod[tests]/fn[validates_full_names_requirement_text_and_input_lines]
  • Kind: fn
  • src/evidence.rs:2533–2564
    // {test}`requirements.integration.report_api`
    // {test}`requirements.ci.book_source`
    // {test}`requirements.ci.coverage`
    // {test}`requirements.ci.requirement_text`
    // {test}`requirements.ci.outline_inputs`
    // {test}`requirements.ci.identifiers`
    // {test}`requirements.ci.span`
    #[test]
    fn validates_full_names_requirement_text_and_input_lines() {
        let temp = fixture();
        fs::write(
            temp.path().join("md/reqs/foo/bar.md"),
            "# Requirements\n\n:::{req} ready\n\n  The check MUST pass.\n\n```text\n{req}`example`\n```\n:::\n",
        )
        .unwrap();
        fs::write(
            temp.path().join("evidence/foo.bar.ready.json"),
            json!({
                "requirement": "The check MUST pass.\n\n```text\n{req}`example`\n```",
                "determination": true,
                "rationale": "The inspected file has the expected lines.",
                "inputs": [outline(temp.path(), "src/main.rs", "")]
            })
            .to_string(),
        )
        .unwrap();

        let report = validate_repository(temp.path()).unwrap();
        assert_eq!(report.requirements, 1);
        assert_eq!(report.evidence_files, 1);
        assert!(report.errors.is_empty(), "{:?}", report.errors);
    }
Input 7: outline src/evidence.rs mod[tests]/fn[collects_missing_orphan_format_false_and_changed_line_errors]
  • File: src/evidence.rs
  • Selector: mod[tests]/fn[collects_missing_orphan_format_false_and_changed_line_errors]
  • Kind: fn
  • src/evidence.rs:2566–2667
    // {test}`requirements.integration.report_api`
    // {test}`requirements.ci.errors`
    // {test}`requirements.ci.diagnostics`
    // {test}`requirements.ci.input_containment`
    // {test}`requirements.ci.definition_errors`
    // {test}`requirements.ci.orphans`
    // {test}`requirements.ci.coverage`
    // {test}`requirements.ci.determination`
    // {test}`requirements.ci.outline_inputs`
    // {test}`requirements.ci.requirement_text`
    // {test}`requirements.ci.schema`
    #[test]
    fn collects_missing_orphan_format_false_and_changed_line_errors() {
        let temp = fixture();
        fs::write(
            temp.path().join("md/requirements.md"),
            "# Requirements\n\n:::{req} one\nFirst.\n:::\n\n:::{req} two\nSecond.\n:::\n\n:::{req} three\nThird.\n:::\n\n:::{req} one\nDuplicate.\n:::\n\n:::{req} empty\n  \n:::\n",
        )
        .unwrap();
        fs::write(
            temp.path().join("evidence/requirements.one.json"),
            json!({
                "requirement": "Old text.",
                "determination": false,
                "rationale": "Work remains.",
                "inputs": [
                    {
                        "file": "src/main.rs",
                        "item": "",
                        "hash": "0".repeat(64)
                    },
                    {
                        "file": "",
                        "item": 0,
                        "hash": "ABC"
                    },
                    {
                        "file": "src/main.rs",
                        "item": "fn[missing]",
                        "hash": "0".repeat(64)
                    },
                    {
                        "file": "src/main.rs",
                        "line_start": 1,
                        "line_end": 1,
                        "text": ["// first line"]
                    },
                    {
                        "requirements": "requirements.two",
                        "matches": ["requirements.two"],
                        "text": [1]
                    }
                ]
            })
            .to_string(),
        )
        .unwrap();
        fs::write(
            temp.path().join("evidence/requirements.three.json"),
            json!({"requirement": 3, "inputs": {}}).to_string(),
        )
        .unwrap();
        fs::write(
            temp.path().join("evidence/ghost.json"),
            json!({
                "requirement": "Ghost.",
                "determination": true,
                "rationale": "A valid but orphaned file.",
                "inputs": []
            })
            .to_string(),
        )
        .unwrap();
        fs::write(temp.path().join("evidence/broken.json"), "{").unwrap();

        let report = validate_repository(temp.path()).unwrap();
        let errors = report.errors.join("\n");
        for detail in [
            "no matching requirement",
            "invalid JSON",
            "missing for requirement",
            "requirement text changed",
            "- Old text.",
            "+ First.",
            "determination is false",
            "inputs[0]: outline input changed: src/main.rs <root> (now lines 1-2) no longer has the recorded hash",
            "inputs[1]: file must be a nonempty path",
            "inputs[1]: item must be a string",
            "inputs[1]: hash must be a lowercase hexadecimal SHA-256 digest",
            "inputs[2]: src/main.rs: no outline node matches \"fn[missing]\"",
            "inputs[3]: unexpected field \"line_start\"",
            "inputs[3]: missing field \"item\"",
            "inputs[4]: text[0] must be a string",
            "requirement must be a string",
            "missing field \"determination\"",
            "inputs must be an array",
            "duplicate requirement requirements.one; first declared at md/requirements.md:3",
            "requirement requirements.empty has no text",
        ] {
            assert!(errors.contains(detail), "missing {detail:?} in:\n{errors}");
        }
    }
Input 8: outline src/evidence.rs mod[tests]/fn[selector_anchors_are_covered_by_inputs_selecting_the_node_or_an_ancestor]
  • File: src/evidence.rs
  • Selector: mod[tests]/fn[selector_anchors_are_covered_by_inputs_selecting_the_node_or_an_ancestor]
  • Kind: fn
  • src/evidence.rs:3853–3920
    // {test}`requirements.references.anchors`
    // {test}`requirements.ci.outline_inputs`
    // {test}`requirements.references.evidence_coverage`
    #[test]
    fn selector_anchors_are_covered_by_inputs_selecting_the_node_or_an_ancestor() {
        let temp = fixture();
        let root = temp.path();
        fs::write(
            root.join("src/lib.rs"),
            "mod inner {\n    fn run() {}\n    fn other() {}\n}\n",
        )
        .unwrap();
        fs::write(
            root.join("md/requirements.md"),
            ":::{req} ready\n:test: src/lib.rs#mod[inner]/fn[run]\nReady MUST hold.\n:::\n",
        )
        .unwrap();
        let write = |inputs: Value| {
            fs::write(
                root.join("evidence/requirements.ready.json"),
                json!({
                    "requirement": "Ready MUST hold.",
                    "determination": true,
                    "rationale": "Checked.",
                    "inputs": inputs,
                })
                .to_string(),
            )
            .unwrap();
        };
        let anchor_errors = || {
            validate_repository(root)
                .unwrap()
                .errors
                .into_iter()
                .filter(|error| error.contains("anchor"))
                .collect::<Vec<_>>()
        };
        write(json!([outline(root, "src/lib.rs", "mod[inner]/fn[other]")]));
        let errors = anchor_errors();
        assert_eq!(
            errors,
            [
                "evidence/requirements.ready.json: no input selects src/lib.rs#mod[inner]/fn[run] (lines 2-2) anchored by :test: on requirement requirements.ready"
            ],
        );
        for item in ["mod[inner]/fn[run]", "mod[inner]", ""] {
            write(json!([outline(root, "src/lib.rs", item)]));
            assert!(anchor_errors().is_empty(), "{item}: {:?}", anchor_errors());
        }
        fs::write(
            root.join("md/requirements.md"),
            ":::{req} ready\n:impl: src/lib.rs#mod[inner]/fn[run]\nReady MUST hold.\n:::\n",
        )
        .unwrap();
        write(json!([]));
        assert!(anchor_errors().is_empty(), "{:?}", anchor_errors());
        fs::write(
            root.join("md/requirements.md"),
            ":::{req} ready\n:impl: src/lib.rs#fn[missing]\nReady MUST hold.\n:::\n",
        )
        .unwrap();
        let errors = anchor_errors().join("\n");
        assert!(
            errors.contains(":impl: anchor src/lib.rs#fn[missing] on requirement requirements.ready at md/requirements.md:1 does not resolve to a readable, permitted file or node: src/lib.rs: no outline node matches \"fn[missing]\""),
            "{errors}"
        );
    }
Input 9: outline tests/evidence_boundaries.rs fn[outline_inputs_survive_moves_and_unhashed_comments_but_not_edits]
// {test}`requirements.ci.outline_inputs`
// {test}`requirements.ci.input_containment`
// {test}`requirements.ci.diagnostics`
// {test}`requirements.ci.schema`
// {test}`requirements.ci.fixme_stale_input`
// {test}`requirements.references.selector_raw_lines`
// {test}`requirements.references.structural_hash`
#[test]
fn outline_inputs_survive_moves_and_unhashed_comments_but_not_edits() {
    let temp = fixture();
    let root = temp.path().join("project");
    // Citation reviews of the cited functions are checked elsewhere.
    let errors = |inputs: Vec<Value>| {
        write_inputs(&root, inputs);
        without_citation_reviews(validate_repository(&root).unwrap().errors).join("\n")
    };
    let rust = "// {cite}`rules.ready`\nfn alpha() { work(1); }\n\n/// Docs.\n// {cite}`rules.ready`\n#[allow(dead_code)]\nfn beta() {}\n";
    fs::write(root.join("src/lib.rs"), rust).unwrap();
    let inputs = vec![
        outline(&root, "src/lib.rs", "fn[alpha]"),
        outline(&root, "src/lib.rs", "fn[beta]"),
        habeas::outline_inputs_for_lines(&root, "data.txt", 2, 2)
            .unwrap()
            .remove(0),
    ];
    assert_eq!(errors(inputs.clone()), "");

    // Moving nodes and lines, and editing unhashed comments, keeps inputs valid.
    fs::write(
        root.join("src/lib.rs"),
        format!("// {{cite}}`rules.ready` moved below a new line\n\n{rust}")
            .replace("fn alpha() { work(1); }", "fn alpha() {\n    work(1);\n}"),
    )
    .unwrap();
    fs::write(root.join("data.txt"), "zero\nfirst\nsecond\n").unwrap();
    assert_eq!(errors(inputs.clone()), "");

    // Editing another node must not invalidate beta's recorded input.
    fs::write(root.join("src/lib.rs"), rust.replace("work(1)", "work(2)")).unwrap();
    assert_eq!(errors(vec![inputs[1].clone()]), "");

    // Editing a node's code or its doc comment makes the input stale, naming the
    // file, selector, and current line range.
    fs::write(
        root.join("src/lib.rs"),
        rust.replace("work(1)", "work(2)")
            .replace("/// Docs.", "/// Changed docs."),
    )
    .unwrap();
    let found = errors(inputs.clone());
    for expected in [
        "inputs[0]: outline input changed: src/lib.rs fn[alpha] (now lines 1-2) no longer has the recorded hash",
        "inputs[1]: outline input changed: src/lib.rs fn[beta] (now lines 4-7) no longer has the recorded hash",
    ] {
        assert!(found.contains(expected), "missing {expected:?}: {found}");
    }
    assert!(!found.contains("inputs[2]"), "{found}");
    assert!(!found.contains("work(2)"), "no diff: {found}");

    // An edited plain-text line is a different node.
    fs::write(root.join("data.txt"), "first\nchanged\n").unwrap();
    let found = errors(inputs[2..].to_vec());
    assert!(
        found.contains("data.txt: no outline node matches \"line@"),
        "{found}"
    );

    fs::write(
        root.join("src/lib.rs"),
        "// {cite}`rules.ready`\n#[cfg(a)]\nfn dup() {}\n// {cite}`rules.ready`\n#[cfg(b)]\nfn dup() {}\n",
    )
    .unwrap();
    let hash = "0".repeat(64);
    for (input, expected) in [
        (
            json!({"file":"src/lib.rs", "item":"fn[missing]", "hash":hash}),
            "src/lib.rs: no outline node matches \"fn[missing]\"",
        ),
        (
            json!({"file":"src/lib.rs", "item":"fn[dup]", "hash":hash}),
            "src/lib.rs: outline selector \"fn[dup]\" is ambiguous",
        ),
        (
            json!({"file":"src/lib.rs", "item":"fn[unclosed", "hash":hash}),
            "src/lib.rs: invalid outline selector \"fn[unclosed\"",
        ),
        (
            json!({"file":"src/lib.rs", "item":"fn[dup]#2", "hash":"ABC"}),
            "hash must be a lowercase hexadecimal SHA-256 digest",
        ),
        (
            json!({"file":"missing.txt", "item":"", "hash":hash}),
            "cannot open missing.txt",
        ),
        (
            json!({"file":"data.txt", "line_start":1, "line_end":1, "text":["first"]}),
            "unexpected field \"line_start\"",
        ),
        (
            json!({"rust_file":"src/lib.rs", "rust_item":"fn[dup]#1", "text":["fn dup() {}"]}),
            "unexpected field \"rust_file\"",
        ),
        (
            json!({"file":"src/lib.rs", "item":"fn[dup]#1", "hash":hash, "text":["fn dup() {}"]}),
            "unexpected field \"text\"",
        ),
    ] {
        let found = errors(vec![input]);
        assert!(found.contains(expected), "missing {expected:?}: {found}");
    }
    fs::write(root.join("src/broken.rs"), "fn {").unwrap();
    let found = errors(vec![
        json!({"file":"src/broken.rs", "item":"", "hash":hash}),
    ]);
    assert!(
        found.contains("src/broken.rs: cannot parse rust source"),
        "{found}"
    );
}
Input 10: outline tests/evidence_boundaries.rs fn[symlinks_may_resolve_inside_but_not_to_a_sibling_with_the_same_prefix]
// {test}`requirements.ci.input_containment`
// {test}`requirements.ci.outline_inputs`
// {test}`requirements.ci.schema`
#[cfg(unix)]
#[test]
fn symlinks_may_resolve_inside_but_not_to_a_sibling_with_the_same_prefix() {
    use std::os::unix::fs::symlink;

    let temp = fixture();
    let root = temp.path().join("project");
    symlink(root.join("data.txt"), root.join("inside.txt")).unwrap();
    write_inputs(&root, vec![outline(&root, "inside.txt", "")]);
    assert!(validate_repository(&root).unwrap().errors.is_empty());

    let sibling = temp.path().join("project-sibling");
    fs::create_dir(&sibling).unwrap();
    fs::write(sibling.join("outside.rs"), "fn outside() {}\n").unwrap();
    symlink(sibling.join("outside.rs"), root.join("escape.rs")).unwrap();
    {
        let input = json!({"file":"escape.rs", "item":"fn[outside]", "hash":"0".repeat(64)});
        write_inputs(&root, vec![input]);
        let errors = validate_repository(&root).unwrap().errors.join("\n");
        assert!(
            errors.contains("escape.rs resolves outside the repository"),
            "{errors}"
        );
    }
}
Input 11: outline tests/evidence_boundaries.rs fn[configured_external_inputs_validate_and_remain_subject_to_freshness_and_disallow]
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.ci.input_containment`
// {test}`requirements.ci.outline_inputs`
// {test}`requirements.configuration.loading`
#[test]
fn configured_external_inputs_validate_and_remain_subject_to_freshness_and_disallow() {
    let temp = fixture();
    let root = temp.path().join("project");
    let external = temp.path().join("generated");
    fs::create_dir(&external).unwrap();
    let source = external.join("generated.rs");
    fs::write(&source, "pub fn generated() {}\n").unwrap();
    let external_toml = toml::Value::String(external.display().to_string());
    let config = format!("version = 1\n[evidence]\nallow = [{external_toml}]\n");
    fs::write(root.join("habeas.toml"), &config).unwrap();
    {
        let input = outline(&root, source.to_str().unwrap(), "fn[generated]");
        write_inputs(&root, vec![input]);
        fs::write(root.join("habeas.toml"), "version = 1\n").unwrap();
        assert!(
            validate_repository(&root)
                .unwrap()
                .errors
                .join("\n")
                .contains("outside the repository")
        );
        fs::write(root.join("habeas.toml"), &config).unwrap();
        let report = validate_repository(&root).unwrap();
        assert!(report.errors.is_empty(), "{:?}", report.errors);
        fs::write(&source, "pub fn generated() { changed(); }\n").unwrap();
        assert!(
            validate_repository(&root)
                .unwrap()
                .errors
                .join("\n")
                .contains("outline input changed")
        );
        fs::write(&source, "pub fn generated() {}\n").unwrap();
        fs::write(
            root.join("habeas.toml"),
            format!("{config}disallow = [{external_toml}]\n"),
        )
        .unwrap();
        assert!(
            validate_repository(&root)
                .unwrap()
                .errors
                .join("\n")
                .contains("disallowed")
        );
    }
}
Input 12: outline tests/evidence_boundaries.rs fn[evidence_rejects_disallowed_ancestors_even_when_symlinks_target_allowed_sources]
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.ci.input_containment`
// {test}`requirements.ci.outline_inputs`
#[cfg(unix)]
#[test]
fn evidence_rejects_disallowed_ancestors_even_when_symlinks_target_allowed_sources() {
    let temp = fixture();
    let root = temp.path().join("project");
    for directory in ["private", "public", "sub"] {
        fs::create_dir(root.join(directory)).unwrap();
    }
    // Every struct needs a reference under rust_item_coverage.
    let cite = "// {cite}`rules.ready`".to_owned();
    fs::write(
        root.join("public/source.rs"),
        format!("{cite}\npub struct Source;\n"),
    )
    .unwrap();
    std::os::unix::fs::symlink("../public", root.join("private/link")).unwrap();
    fs::write(
        root.join("habeas.toml"),
        "version = 1\n[evidence]\nallow = ['public']\ndisallow = ['private']\n",
    )
    .unwrap();
    for file in [
        "public/source.rs",
        "private/link/source.rs",
        "sub/../private/link/source.rs",
    ] {
        {
            let mut input = outline(&root, "public/source.rs", "struct[Source]");
            input["file"] = json!(file);
            write_inputs(&root, vec![input]);
            let errors =
                without_citation_reviews(validate_repository(&root).unwrap().errors).join("\n");
            if file == "public/source.rs" {
                assert!(errors.is_empty(), "{errors}");
            } else {
                assert!(errors.contains("disallowed"), "{file}: {errors}");
                assert!(errors.contains(file), "{errors}");
            }
        }
    }
}
Input 13: outline tests/evidence_boundaries.rs fn[discovered_external_cargo_outputs_validate_freshness_and_obey_disallow]
// {test}`requirements.authoring.generated_inputs`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.ci.input_containment`
// {test}`requirements.ci.outline_inputs`
// {test}`requirements.integration.report_api`
#[test]
fn discovered_external_cargo_outputs_validate_freshness_and_obey_disallow() {
    let temp = fixture();
    let root = temp.path().join("project");
    fs::write(
        root.join("Cargo.toml"),
        "[package]\nname = 'fixture'\nversion = '0.1.0'\n",
    )
    .unwrap();
    fs::write(
        root.join("Cargo.lock"),
        "version = 4\n\n[[package]]\nname = 'fixture'\nversion = '0.1.0'\n",
    )
    .unwrap();
    fs::write(root.join("src/lib.rs"), "").unwrap();
    fs::create_dir(root.join(".cargo")).unwrap();
    let build = temp.path().join("external-build");
    let target = temp.path().join("external-target");
    fs::write(
        root.join(".cargo/config.toml"),
        format!(
            "[build]\nbuild-dir = {}\ntarget-dir = {}\n",
            toml::Value::String(build.display().to_string()),
            toml::Value::String(target.display().to_string()),
        ),
    )
    .unwrap();
    let out = build.join("debug/build/fixture-hash/out");
    fs::create_dir_all(&out).unwrap();
    fs::write(
        out.parent().unwrap().join("root-output"),
        out.to_str().unwrap(),
    )
    .unwrap();
    let generated = out.join("generated.rs");
    fs::write(&generated, "pub fn generated() {}\n").unwrap();
    {
        fs::write(root.join("habeas.toml"), "version = 1\n").unwrap();
        let input = outline(&root, generated.to_str().unwrap(), "fn[generated]");
        write_inputs(&root, vec![input]);
        let report = validate_repository(&root).unwrap();
        assert!(report.errors.is_empty(), "{:?}", report.errors);
        fs::write(&generated, "pub fn generated() { changed(); }\n").unwrap();
        let errors = validate_repository(&root).unwrap().errors.join("\n");
        assert!(errors.contains("outline input changed"), "{errors}");
        fs::write(&generated, "pub fn generated() {}\n").unwrap();
        fs::write(
            root.join("habeas.toml"),
            "version = 1\n[evidence]\ndisallow = ['../external-build']\n",
        )
        .unwrap();
        let errors = validate_repository(&root).unwrap().errors.join("\n");
        assert!(errors.contains("disallowed"), "{errors}");
    }
    assert!(!target.exists(), "metadata must not run a build");
}
Input 14: outline tests/outcomes.rs fn[fixme_does_not_hide_stale_inputs_or_uncovered_references]
// {test}`requirements.ci.outline_inputs`
// {test}`requirements.ci.determination`
// {test}`requirements.references.evidence_coverage`
// {test}`requirements.ci.fixme_stale_input`
// {test}`requirements.index.state`
// {test}`requirements.cli.fixme_summary`
#[test]
fn fixme_does_not_hide_stale_inputs_or_uncovered_references() {
    let temp = fixture();
    let observed = temp.path().join("observed.rs");
    let source = fs::read_to_string(&observed).unwrap();
    fs::write(&observed, source.replace("= 1;", "= 2;")).unwrap();
    let report = habeas::validate_repository(temp.path()).unwrap();
    assert!(
        report
            .errors
            .iter()
            .any(|error| error.contains("outline input changed: observed.rs <root>")),
        "{:?}",
        report.errors
    );
    let status = habeas::status_markdown(temp.path(), false).unwrap();
    let row = status
        .lines()
        .find(|line| line.starts_with("| `requirements.timeout`"))
        .unwrap();
    assert!(row.contains("Invalid"), "{row}");
    assert!(status.contains("example/io#125"), "{status}");
    assert!(status.contains("outline input changed"), "{status}");
    fs::write(
        temp.path().join("other.txt"),
        "{test}`requirements.timeout`",
    )
    .unwrap();
    let report = habeas::validate_repository(temp.path()).unwrap();
    assert!(
        report
            .errors
            .iter()
            .any(|error| error.contains("no input covers") && error.contains("other.txt:1"))
    );
}

Referenced definitions

Input 2: requirements selection requirements.references.outlines
:::{req} outlines
Habeas MUST parse Rust, Python, TypeScript, CSS, Markdown, TOML, and YAML
sources with pinned tree-sitter grammars, selected by file extension compared
case-insensitively. A source with any syntax error MUST fail to parse, reporting
the line of its first error. Every
other text file MUST use a plain-text profile in which each line that is not
blank is an anonymous outline node of kind `line`. Each supported language MUST
have an outline profile that maps grammar node kinds to short outline kind names
and, for each mapped kind, states whether a node is named, and by which fields
or children, or anonymous. Only mapped kinds MUST appear in the outline; other
nodes MUST be transparent, so their outline descendants appear under the
nearest outline ancestor. A profile MAY attach grammar siblings to an outline
node, such as Rust attributes and doc comments preceding an item, so the outline
tree need not match the grammar tree exactly; attached siblings are part of that
node for its line range and hash. Every file's outline MUST have a root node
for the whole file, independent of language. Source in no other outline node,
such as top-level statements no profile maps, MUST belong to the root node;
profiles MUST NOT invent fallback kinds for it. Comments MUST NOT be outline nodes. Profiles MUST be
documented. Upgrading a grammar or profile MAY change outlines and MUST be
treated as a deliberate change.
:::
Input 3: requirements selection requirements.references.outline_selectors
:::{req} outline_selectors
An outline selector MUST be a `/`-separated path of segments from the file's
root node to an outline node; the empty selector MUST select the root node. A
named node's segment MUST be `kind[name]`. An anonymous node's segment MUST be
`kind@hash`, where `hash` is the first twelve hexadecimal digits of its identity
hash under {cite}`requirements.references.structural_hash`. Siblings whose
segments would otherwise be identical MUST be disambiguated by `#N`, their
one-based position among those siblings in source order, except `line` nodes:
identical lines are interchangeable, so a `line` selector MUST resolve when any
line with that content exists in the file. In names, `%`, `[`, `]`, `/`, `#`,
`@`, and whitespace MUST be percent-encoded as UTF-8 bytes, so selectors are
reversible. Line numbers MUST NOT form part of a selector.
:::
Input 4: requirements selection requirements.references.structural_hash
:::{req} structural_hash
A node's structural hash MUST be the SHA-256 digest of an unambiguous encoding of
its outline-relevant structure, including siblings its profile attaches to it:
the kinds of its named grammar nodes and, in source order, its text pieces. A
text piece MUST be the text of a leaf token, or text inside a node that no child
token covers. Each text piece MUST be hashed as its ordered list of words, where
words are separated by whitespace, the whitespace itself, including leading and
trailing whitespace, is never hashed, and each word is encoded separately, so
`ab cd` and `abcd` differ. The same rule MUST apply in every language. Comments
MUST be excluded, except comment kinds the profile includes; the Rust profile MUST include doc comments. For an included comment, only its text and its
profile's comment group MUST be hashed, not its delimiter tokens such as `//`,
`///`, `//!`, `/*`, `*/`, or a leading `*`; the Rust profile's groups are inner
and outer doc comments. The words of consecutive included comments of one group
MUST be hashed as one ordered list, so reflowing them across more or fewer lines
or comments does not change the hash, while moving text between groups does. A `line`
node's hash MUST be computed by the same word rule over the line's text. A node's
identity hash MUST be computed the same way but MUST also exclude its outline
descendants and their attached siblings, so editing a descendant does not change
its ancestors' selectors.
:::

Other sources

Input 1: requirements selection requirements.ci.outline_inputs
:::{req} outline_inputs
For an outline input, Habeas MUST parse `file` with its language's grammar under
{cite}`requirements.references.outlines` and resolve `item` to exactly one
outline node under {cite}`requirements.references.outline_selectors`. It MUST
compare `hash` with the node's current structural hash under
{cite}`requirements.references.structural_hash`. It MUST derive the node's
inclusive line range, including attached comments and attributes, during
validation for display and reference coverage. Moving the node, editing other
nodes, or editing comments its profile does not hash MUST NOT invalidate the
input. Habeas MUST report a missing file, unsupported language, parse failure,
invalid or ambiguous selector, or changed hash.
:::