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.test-coverage.check.guidance

Requirements index · View definition

evidence Valid

Requirement

Habeas’s bundled agent instructions and setup-generated coverage documentation MUST recommend running habeas coverage-check after a successful full-workspace instrumented nextest run using habeas coverage -- --workspace, as a separate CI step. They MUST document habeas test as the command running collection and post-suite checking in order under cite requirements.test-coverage.test.

The static validation test MUST NOT require current collected execution coverage or validate exception applicability against current runtime gaps. Those checks belong to the post-suite coverage command. Coverage checking MUST NOT depend on running the static validation test last.

Rationale

The reviewed tests cover every obligation in requirements.test-coverage.check.guidance.

Obligations and the tests that cover them

  1. Generated coverage documentation recommends habeas coverage -- --workspace, then a separate habeas coverage-check after success.

    • src/execution_coverage/book.rs#mod[tests]/fn[generated_reports_inherit_the_requirements_index_hierarchy] asserts that the generated coverage chapter contains habeas coverage -- --workspace.
    • It also asserts the phrase “after it succeeds,\nrun habeas coverage-check as a separate step”.
    • This text comes from GUIDANCE in src/execution_coverage.rs.
    • The same test asserts that the habeas test text is present, and that the coverage chapter needs no prior coverage.
  2. Bundled agent instructions give the same recommendation.

    • tests/repository.rs#fn[shared_agent_guidance_documents_post_suite_checks_and_standard_explanations] asserts these phrases in assets/skills/habeas/SKILL.md:
      • “habeas coverage -- --workspace followed, only on success, by habeas coverage-check”
      • “It collects coverage for the full workspace, then checks it”
    • It asserts matching phrases in md/reference.md.
    • It parses the YAML example in assets/skills/habeas/references/ci.md. That example has habeas coverage -- --locked --workspace and habeas coverage-check as separate steps, with no if and no continue-on-error.
    • tests/repository.rs#fn[ci_tests_pull_requests_and_main_then_deploys_the_book_from_main] checks the project’s CI workflow. It verifies that the collection step comes before coverage-check, and that coverage-check has no if or continue-on-error.
    • tests/repository.rs#fn[published_package_contains_the_bundled_skills_and_ci_example] verifies that the skills and the CI reference ship in the package.
    • tests/setup.rs#fn[coverage_setup_is_idempotent_and_hook_needs_no_coverage_chapter] covers the setup side of the requirement.
  3. habeas test is documented as running collection and then the post-suite check, in that order.

    • The habeas test phrases are asserted in the skill, in the generated coverage documentation, and in md/reference.md (“whole workspace, then check the saved results”).
    • tests/execution_coverage.rs#fn[full_test_flow_checks_real_function_counters_after_all_tests] exercises the real flow. It checks that the check runs after collection, and that a policy failure leaves the run outcome as “success”.
  4. The static validation test must not require current execution coverage, and must not use runtime gaps for exception applicability.

    • src/execution_coverage/check.rs#mod[tests]/fn[static_validation_never_uses_runtime_gaps_to_decide_citation_applicability] asserts that validate_repository has no errors when no coverage data exists.
    • It asserts the same with recorded zero-count and nonzero-count runs.
    • tests/validate.rs#fn[validate_fails_the_test_with_every_error_and_authoring_instructions] passes validation with target/habeas/coverage absent.
  5. Coverage checking must not depend on running the static validation test last.

    • The full-flow test runs saved_check and the full flow in a fixture with no static validation test, and the check still passes and fails correctly.
    • The guidance assertion that the check “need not run last” in md/reference.md is covered by the repository test above.

Reviewer notes

  • Only the main assets/skills/habeas/SKILL.md is asserted phrase by phrase. Other bundled skills and SOPs also mention habeas coverage-check, but I treated the main skill as the shared guidance. I did not count the other mentions as a gap.
  • No acknowledgments are present, and none are needed.

Inputs

Implementation

Input 11: outline src/execution_coverage.rs const[GUIDANCE]
// {impl}`requirements.test-coverage.check.guidance`
// {impl}`requirements.test-coverage.check.exceptions.setup`
pub(crate) const GUIDANCE: &str = "Collect Rust unit and integration test coverage with `habeas coverage`.\nFor focused runs, forward nextest arguments with `habeas coverage -- -E 'test(name)'`.\nRun doctests separately with `cargo test --doc --workspace`.\n\nFor full verification, `habeas test` collects coverage for the whole workspace,\nthen checks it. In CI, run `habeas coverage -- --workspace` and, after it succeeds,\nrun `habeas coverage-check` as a separate step. Checking saved coverage runs no\ntests and calls no model; the static validation test needs no prior coverage.\n\nEvery first-party Rust file needs 80% instrumented-line coverage. Every function\nwith zero execution or no measurement needs an accepted explanation, including\nfunctions excluded by features or platform. Ordinary partly covered functions\nneed no exception when their file meets its target.\n\nUse a standard `habeas:coverage` citation with a substantive prose justification\nin fenced commentary or a Rust doc comment. A file-root citation excuses only\nthe file threshold; a function citation excuses only that function. Author its\nindependent citation review with `habeas author`; only a current accepted review\npermits an exception. No project declaration or special configuration is needed.\nCitations remain applicable across build configurations and can remain after\ncoverage improves. Exceptions never increase measured percentages.\n\nCoverage is disposable build output in the Cargo target directory. The index\ncombines each test's latest compatible attempt; source changes invalidate its\ncontribution. Building this book reads saved reports and never runs tests.\n\nThe overview focuses on undocumented coverage gaps and accepted explanations. Expand\na file to inspect its uncovered obligations, measurements, and explanation status.\n";

Tests

Input 3: outline src/execution_coverage/book.rs mod[tests]/fn[generated_reports_inherit_the_requirements_index_hierarchy]
    // {test}`requirements.test-coverage.index`
    // {test}`requirements.test-coverage.index.navigation`
    // {test}`requirements.test-coverage.index.source`
    // {test}`requirements.test-coverage.index.guidance`
    // {test}`requirements.test-coverage.check.guidance`
    // {test}`requirements.test-coverage.check.exceptions.setup`
    // {test}`requirements.test-coverage.index.details`
    #[test]
    fn generated_reports_inherit_the_requirements_index_hierarchy() {
        for number in [Some(SectionNumber::new(vec![3, 2])), None] {
            let (temp, mut book) = fixture();
            let BookItem::Chapter(parent) = &mut book.items[0] else {
                unreachable!()
            };
            parent.path = Some("reports.md".into());
            parent.name = "Requirements index".into();
            parent.content = "# Requirements index\n".into();
            parent.parent_names = vec!["Reports".into()];
            parent.number = number.clone();
            parent.sub_items.push(BookItem::Chapter(Chapter::new(
                "Guide",
                "# Guide\n".into(),
                "reports/guide.md",
                vec![],
            )));
            record(temp.path(), "one", 1, "a", &[(1, 1)]);
            // Build fixture configuration before invoking the production path.
            fs::create_dir(temp.path().join("md")).unwrap();
            fs::write(temp.path().join("book.toml"), "[book]\nsrc='md'\n").unwrap();
            fs::write(temp.path().join("md/SUMMARY.md"), "# Summary\n").unwrap();
            super::populate_in(
                &mut book,
                temp.path(),
                Some(temp.path().join("target")),
                Path::new("reports.md"),
            )
            .unwrap();
            let BookItem::Chapter(parent) = &book.items[0] else {
                unreachable!()
            };
            assert!(
                parent
                    .content
                    .contains("[Coverage gaps](reports/coverage.html)")
            );
            assert_eq!(parent.number, number);
            let BookItem::Chapter(coverage) = &parent.sub_items[0] else {
                unreachable!()
            };
            assert_eq!(coverage.parent_names, ["Reports", "Requirements index"]);
            assert_eq!(
                coverage.path.as_deref(),
                Some(Path::new("reports/coverage.md"))
            );
            assert!(coverage.source_path.is_none());
            assert_eq!(
                coverage.number,
                number.as_ref().map(|_| SectionNumber::new(vec![3, 2, 1]))
            );
            assert_eq!(parent.sub_items.len(), 2);
            for (offset, item) in coverage.sub_items.iter().enumerate() {
                let BookItem::Chapter(page) = item else {
                    unreachable!()
                };
                assert_eq!(
                    page.parent_names,
                    ["Reports", "Requirements index", "Coverage gaps"]
                );
                assert_eq!(
                    page.number,
                    number
                        .as_ref()
                        .map(|_| SectionNumber::new(vec![3, 2, 1, offset as u32 + 1]))
                );
                assert!(page.source_path.is_none());
                assert!(page.content.contains("../coverage.html"));
            }
            for guidance in [
                "habeas test",
                "habeas coverage -- --workspace",
                "habeas coverage-check",
                "static validation test needs no prior coverage",
                "80%",
                "habeas:coverage",
                "current accepted review",
                "No project declaration or special configuration",
                "after it succeeds,\nrun `habeas coverage-check` as a separate step",
                "`habeas test` collects coverage for the whole workspace,\nthen checks it",
                "substantive prose justification",
                "fenced commentary or a Rust doc comment",
                "citation review with `habeas author`",
                "Ordinary partly covered functions\nneed no exception when their file meets its target",
            ] {
                assert!(
                    coverage.content.contains(guidance),
                    "missing generated guidance: {guidance}"
                );
            }
            assert!(!coverage.content.contains(":::{coverage-index}"));
        }
    }
Input 4: outline src/execution_coverage/check.rs mod[tests]/fn[static_validation_never_uses_runtime_gaps_to_decide_citation_applicability]
    // {test}`requirements.test-coverage.check.guidance`
    #[test]
    fn static_validation_never_uses_runtime_gaps_to_decide_citation_applicability() {
        let temp = fixture(
            "//! :::{cite} habeas:coverage\n//! File rationale.\n//! :::\n// :::{cite} habeas:coverage\n// Function rationale.\n// :::\nfn a() {}\n",
        );
        let root = temp.path();
        let (path, source) = crate::execution_coverage::configure(root).unwrap();
        fs::create_dir_all(path.parent().unwrap()).unwrap();
        fs::write(path, source).unwrap();
        reviews(root, json!(true));
        assert!(!root.join("target/habeas/coverage").exists());
        assert!(crate::validate_repository(root).unwrap().errors.is_empty());
        for (started, count) in [(1, 0), (2, 1)] {
            record(
                root,
                "a",
                started,
                "same",
                vec![process(root, &[(7, count)], count)],
            );
            let result = crate::validate_repository(root).unwrap();
            assert!(result.errors.is_empty(), "{:?}", result.errors);
        }
    }
Input 5: outline tests/execution_coverage.rs fn[full_test_flow_checks_real_function_counters_after_all_tests]
// {test}`requirements.test-coverage.test`
// {test}`requirements.test-coverage.check`
// {test}`requirements.test-coverage.check.functions`
// {test}`requirements.test-coverage.check.guidance`
#[test]
fn full_test_flow_checks_real_function_counters_after_all_tests() {
    let temp = fixture();
    let root = temp.path();
    let (requests, stop, server) = model_tripwire(root);
    fs::create_dir(root.join("evidence")).unwrap();
    fs::write(root.join("evidence/sentinel.txt"), "existing evidence").unwrap();
    let original_evidence = retained_files(&root.join("evidence"));
    let nextest = root.join(".config/nextest.toml");
    let mut configuration = fs::read_to_string(&nextest)
        .unwrap()
        .parse::<toml_edit::DocumentMut>()
        .unwrap();
    configuration["profile"]["default"]["default-filter"] = toml_edit::value("kind(lib)");
    fs::write(nextest, configuration.to_string()).unwrap();
    let manifest = fs::read_to_string(root.join("Cargo.toml")).unwrap();
    fs::write(
        root.join("Cargo.toml"),
        format!("{manifest}\n[dev-dependencies]\ntokio = {{ version = '1', features = ['macros', 'rt'] }}\n"),
    )
    .unwrap();
    fs::write(root.join("src/lib.rs"), "pub fn value(flag: bool) -> u32 {\n if flag { 10 } else { 20 }\n}\n#[cfg(test)] #[test] fn a() { assert_eq!(value(true), 10); }\n#[cfg(test)] #[test] fn b() { assert_eq!(value(false), 20); }\n#[cfg(test)] #[tokio::test] async fn asynchronous() { assert_eq!(value(true), 10); }\n").unwrap();
    fs::write(
        root.join("tests/processes.rs"),
        "#[test] fn integration() { assert_eq!(coverage_fixture::value(true),10); }\n",
    )
    .unwrap();
    let output = full_flow(root);
    assert_success(&output);
    assert!(String::from_utf8_lossy(&output.stdout).contains("Coverage check passed"));
    let checked = saved_check(root);
    assert_success(&checked);
    assert!(String::from_utf8_lossy(&checked.stdout).contains("Coverage check passed"));
    assert_eq!(retained_files(&root.join("evidence")), original_evidence);
    let saved = runs(root);
    assert_eq!(saved.len(), 1);
    assert_eq!(
        attempts(&saved[0].0).len(),
        4,
        "the full workspace includes sync and async unit tests AND integration targets"
    );
    for attempt in attempts(&saved[0].0) {
        for process in attempt["processes"].as_array().unwrap() {
            assert!(
                process["functions"]
                    .as_array()
                    .is_some_and(|functions| !functions.is_empty())
            );
        }
    }
    fs::write(root.join("src/lib.rs"), "pub fn value(flag: bool) -> u32 { if flag { 10 } else { 20 } }\npub fn outer() { fn hidden() {} let f = || {}; f(); }\n#[cfg(test)] #[test] fn a() { value(true); outer(); }\n#[cfg(test)] #[test] fn b() { value(false); }\n#[cfg(test)] #[tokio::test] async fn asynchronous() { assert_eq!(value(true), 10); }\n").unwrap();
    let output = full_flow(root);
    assert!(!output.status.success());
    let stdout = String::from_utf8_lossy(&output.stdout);
    assert!(
        stdout.contains("#fn[outer]/fn[hidden]: zero execution"),
        "{stdout}\n{}",
        String::from_utf8_lossy(&output.stderr)
    );
    assert!(!stdout.contains("#fn[outer]: zero execution"), "{stdout}");
    assert_eq!(
        runs(root).last().unwrap().1["outcome"],
        "success",
        "tests succeeded; the policy caused failure"
    );
    let checked = saved_check(root);
    assert!(!checked.status.success());
    assert!(String::from_utf8_lossy(&checked.stdout).contains("Coverage check failed"));
    assert_eq!(retained_files(&root.join("evidence")), original_evidence);
    stop.send(()).unwrap();
    server.join().unwrap();
    assert_eq!(
        requests.load(std::sync::atomic::Ordering::SeqCst),
        0,
        "verification must never call a model"
    );
}
Input 6: outline tests/repository.rs fn[shared_agent_guidance_documents_post_suite_checks_and_standard_explanations]
  • File: tests/repository.rs
  • Selector: fn[shared_agent_guidance_documents_post_suite_checks_and_standard_explanations]
  • Kind: fn
  • tests/repository.rs:92–138
// {test}`requirements.test-coverage.check.guidance`
// {test}`requirements.test-coverage.check.exceptions.setup`
#[test]
fn shared_agent_guidance_documents_post_suite_checks_and_standard_explanations() {
    let skill = repository_file("assets/skills/habeas/SKILL.md");
    for phrase in [
        "It collects coverage for the full workspace, then checks it",
        "`habeas coverage -- --workspace` followed, only on success, by\n`habeas coverage-check`",
        "static `habeas::validate()` test requires no prior execution coverage",
        "Partly covered\nfunctions need no exception when their file meets its target",
        "standard\n`{cite}` of `habeas:coverage`",
        "rationale in fenced commentary or a Rust\ndoc comment",
        "citation review with `habeas author`",
        "Only current accepted review evidence permits the exception",
        "No\nproject declaration or extra configuration is needed",
    ] {
        assert!(skill.contains(phrase), "agent guidance omits {phrase}");
    }
    let reference = repository_file("md/reference.md");
    for phrase in [
        "whole workspace, then check the saved results",
        "Run the second command only after the first succeeds",
        "it need not run last",
    ] {
        assert!(reference.contains(phrase), "reference omits {phrase}");
    }
    let example = repository_file("assets/skills/habeas/references/ci.md");
    let yaml = example
        .split_once("```yaml\n")
        .unwrap()
        .1
        .split_once("\n```")
        .unwrap()
        .0;
    let example: serde_json::Value = serde_saphyr::from_str(yaml).unwrap();
    let steps = example["steps"].as_array().unwrap();
    assert_eq!(steps[0]["run"], "habeas coverage -- --locked --workspace");
    assert_eq!(steps[1]["run"], "habeas coverage-check");
    assert_eq!(steps[2]["run"], "cargo test --locked --doc --workspace");
    for step in &steps[..2] {
        assert!(step.get("if").is_none(), "use the normal success condition");
        assert!(
            step.get("continue-on-error").is_none(),
            "a failed gate must fail CI"
        );
    }
}
Input 7: outline tests/repository.rs fn[ci_tests_pull_requests_and_main_then_deploys_the_book_from_main]
// {test}`requirements.integration.ci`
// {test}`requirements.test-coverage.check.guidance`
#[test]
fn ci_tests_pull_requests_and_main_then_deploys_the_book_from_main() {
    let workflow = repository_file(".github/workflows/ci.yml");
    assert!(
        workflow.contains("\non:\n  push:\n    branches: [main]\n  pull_request:\n\n"),
        "{workflow}"
    );

    let test = workflow_job(&workflow, "test-and-build");
    let steps = [
        "run: node --test .github/scripts/autofix.test.mjs",
        "cargo build --release --locked -p habeas",
        "cargo habeas coverage -- --locked --workspace",
        "run: cargo habeas coverage-check",
        "run: cargo test --locked --doc --workspace",
        "run: mdbook test",
        "run: mdbook build",
        "uses: actions/upload-pages-artifact@v4",
    ];
    let positions: Vec<_> = steps
        .iter()
        .map(|step| test.find(step).unwrap_or_else(|| panic!("{step}:\n{test}")))
        .collect();
    assert!(positions.is_sorted(), "{test}");
    assert!(test.contains("with:\n          path: book\n"), "{test}");
    let workflow_yaml: serde_json::Value = serde_saphyr::from_str(&workflow).unwrap();
    let gate = workflow_yaml["jobs"]["test-and-build"]["steps"]
        .as_array()
        .unwrap()
        .iter()
        .find(|step| step["run"] == "cargo habeas coverage-check")
        .unwrap();
    assert!(
        gate.get("if").is_none(),
        "check only after successful collection"
    );
    assert!(
        gate.get("continue-on-error").is_none(),
        "enforce coverage failures"
    );

    let hook = workflow_job(&workflow, "symposium-hook");
    assert!(
        hook.contains("run: python3 tests/symposium_hook_smoke.py"),
        "{hook}"
    );

    let deploy = workflow_job(&workflow, "deploy");
    assert!(
        deploy.contains("if: github.event_name == 'push' && github.ref == 'refs/heads/main'"),
        "{deploy}"
    );
    assert!(
        deploy.contains("needs: [test-and-build, symposium-hook]"),
        "{deploy}"
    );
    assert!(deploy.contains("uses: actions/deploy-pages@v4"), "{deploy}");

    let book = repository_toml("book.toml");
    assert_eq!(
        book["output"]["html"]["site-url"].as_str(),
        Some("/habeas-codicem/")
    );
}
Input 8: outline tests/repository.rs fn[published_package_contains_the_bundled_skills_and_ci_example]
// {test}`requirements.integration.symposium`
// {test}`requirements.test-coverage.check.guidance`
#[test]
fn published_package_contains_the_bundled_skills_and_ci_example() {
    let root = Path::new(env!("CARGO_MANIFEST_DIR"));
    let output = Command::new("cargo")
        .args(["package", "--list", "--allow-dirty", "--offline"])
        .current_dir(root)
        .output()
        .unwrap();
    assert!(
        output.status.success(),
        "{}",
        String::from_utf8_lossy(&output.stderr)
    );
    let packaged = String::from_utf8(output.stdout).unwrap();
    let manifest = repository_toml("Cargo.toml");
    let source = manifest["package"]["metadata"]["symposium"]["skills"][0]["source"]["path"]
        .as_str()
        .unwrap();
    let mut skills = 0;
    for entry in fs::read_dir(root.join(source)).unwrap() {
        let entry = entry.unwrap();
        if entry.path().join("SKILL.md").is_file() {
            let path = format!("{source}/{}/SKILL.md", entry.file_name().to_str().unwrap());
            assert!(
                packaged.lines().any(|file| file == path),
                "package omits {path}"
            );
            skills += 1;
        }
    }
    assert!(skills > 0, "the plugin's source directory contains skills");
    assert!(
        packaged
            .lines()
            .any(|file| file == format!("{source}/habeas/references/ci.md")),
        "the CI reference must ship with the skill that links to it"
    );
}
Input 9: outline tests/setup.rs fn[coverage_setup_is_idempotent_and_hook_needs_no_coverage_chapter]
  • File: tests/setup.rs
  • Selector: fn[coverage_setup_is_idempotent_and_hook_needs_no_coverage_chapter]
  • Kind: fn
  • tests/setup.rs:77–133
// {test}`requirements.test-coverage.setup`
// {test}`requirements.test-coverage.setup.configuration`
// {test}`requirements.test-coverage.check.guidance`
// {test}`requirements.test-coverage.check.exceptions.setup`
// {test}`requirements.integration.symposium_setup_hook`
#[test]
fn coverage_setup_is_idempotent_and_hook_needs_no_coverage_chapter() {
    let temp = fixture();
    let root = temp.path();
    let local_crate = env!("CARGO_MANIFEST_DIR");
    let summary = fs::read_to_string(root.join("md/SUMMARY.md")).unwrap();
    run(root, &["setup", "--path", local_crate]);
    let config = fs::read_to_string(root.join(".config/nextest.toml")).unwrap();
    assert!(!root.join("md/test-coverage.md").exists());
    assert_eq!(
        fs::read_to_string(root.join("md/SUMMARY.md")).unwrap(),
        summary
    );
    assert!(config.contains("coverage-process"));
    run(root, &["setup", "--path", local_crate]);
    assert_eq!(
        fs::read_to_string(root.join("md/SUMMARY.md")).unwrap(),
        summary
    );
    assert_eq!(
        fs::read_to_string(root.join(".config/nextest.toml")).unwrap(),
        config
    );
    assert!(!advises_setup(&session_start(root, root)));
    let conflicting = config.replace("all()", "test(one)");
    fs::write(root.join(".config/nextest.toml"), &conflicting).unwrap();
    assert!(advises_setup(&session_start(root, root)));
    assert_eq!(
        fs::read_to_string(root.join(".config/nextest.toml")).unwrap(),
        conflicting
    );
    fs::write(root.join(".config/nextest.toml"), config).unwrap();
    fs::write(root.join("md/SUMMARY.md"), "# Summary\n").unwrap();
    assert!(!advises_setup(&session_start(root, root)));
    assert_eq!(
        fs::read_to_string(root.join("md/SUMMARY.md")).unwrap(),
        "# Summary\n"
    );
    fs::write(root.join("md/test-coverage.md"), "User's coverage notes.\n").unwrap();
    run(root, &["setup", "--path", local_crate]);
    assert_eq!(
        fs::read_to_string(root.join("md/test-coverage.md")).unwrap(),
        "User's coverage notes.\n"
    );
    assert!(!advises_setup(&session_start(root, root)));
    fs::remove_file(root.join(".config/nextest.toml")).unwrap();
    assert!(advises_setup(&session_start(root, root)));
    assert!(
        !root.join(".config/nextest.toml").exists(),
        "hook must not repair configuration"
    );
}
Input 10: outline tests/validate.rs fn[validate_fails_the_test_with_every_error_and_authoring_instructions]
  • File: tests/validate.rs
  • Selector: fn[validate_fails_the_test_with_every_error_and_authoring_instructions]
  • Kind: fn
  • tests/validate.rs:43–121
// {test}`requirements.integration.validate`
// {test}`requirements.test-coverage.check.guidance`
#[test]
fn validate_fails_the_test_with_every_error_and_authoring_instructions() {
    let temp = TempDir::new().unwrap();
    let root = temp.path().join("project");
    let state = temp.path().join("state");
    fs::create_dir_all(root.join("md")).unwrap();
    fs::create_dir_all(root.join("src/nested")).unwrap();
    fs::create_dir_all(root.join("evidence")).unwrap();
    fs::create_dir_all(&state).unwrap();
    fs::write(root.join("Cargo.toml"), "[package]\nname = \"fixture\"\n").unwrap();
    fs::write(root.join("book.toml"), "[book]\nsrc = \"md\"\n").unwrap();
    fs::write(
        root.join("md/rules.md"),
        ":::{req} ready\nReady.\n:::\n\n:::{req} broken\nBroken.\n:::\n",
    )
    .unwrap();
    fs::write(root.join("evidence/rules.broken.json"), "{broken").unwrap();

    // Validation starts from a nested directory and finds the project.
    let output = validate_in(&root.join("src/nested"), &state);
    assert!(!output.status.success(), "{output:?}");
    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);
    let message = format!("{stdout}{stderr}");
    assert!(message.contains("Habeas validation failed"), "{message}");
    assert!(message.contains("rules.ready"), "{message}");
    assert!(message.contains("evidence/rules.broken.json"), "{message}");
    assert!(
        message.contains("Run `habeas author --all`")
            && message.contains("address any reported gaps and rerun the tests"),
        "{message}"
    );
    // Validation never authors: no evidence or usage history is written.
    assert_eq!(fs::read_dir(root.join("evidence")).unwrap().count(), 1);
    assert_eq!(fs::read_dir(&state).unwrap().count(), 0);

    // Repeating validation gives the same result.
    let again = validate_in(&root, &state);
    assert_eq!(
        format!(
            "{}{}",
            String::from_utf8_lossy(&again.stdout),
            String::from_utf8_lossy(&again.stderr)
        )
        .lines()
        .filter(|line| line.starts_with("- "))
        .collect::<Vec<_>>(),
        message
            .lines()
            .filter(|line| line.starts_with("- "))
            .collect::<Vec<_>>()
    );

    common::coverage_setup(&root);

    // Valid evidence passes.
    fs::write(root.join("md/rules.md"), ":::{req} ready\nReady.\n:::\n").unwrap();
    fs::remove_file(root.join("evidence/rules.broken.json")).unwrap();
    fs::write(
        root.join("evidence/rules.ready.json"),
        serde_json::json!({
            "requirement": "Ready.",
            "determination": true,
            "rationale": "Reviewed.",
            "references": habeas::reference_set_digest_for(&root, "rules.ready").unwrap(),
            "inputs": []
        })
        .to_string(),
    )
    .unwrap();
    let output = validate_in(&root, &state);
    assert!(output.status.success(), "{output:?}");
    assert!(
        !root.join("target/habeas/coverage").exists(),
        "static validation needs no execution data"
    );
}

Referenced definitions

Input 2: requirements selection requirements.test-coverage.test
:::{req} test
`habeas test` MUST run the full-workspace instrumented nextest workflow of
{cite}`requirements.test-coverage.run` and, only after that workflow succeeds,
run the post-suite check of {cite}`requirements.test-coverage.check`. It MUST
return a failing exit status if test execution, coverage collection, or the
post-suite check fails. It MUST NOT author exception evidence or invoke an
assessment model.
:::

Other sources

Input 1: requirements selection requirements.test-coverage.check.guidance
:::{req} check.guidance
Habeas's bundled agent instructions and setup-generated coverage documentation
MUST recommend running `habeas coverage-check` after a successful full-workspace
instrumented nextest run using `habeas coverage -- --workspace`, as a separate
CI step. They MUST document `habeas test` as the command running collection and
post-suite checking in order under {cite}`requirements.test-coverage.test`.

The static validation test MUST NOT require current collected execution
coverage or validate exception applicability against current runtime gaps.
Those checks belong to the post-suite coverage command. Coverage checking
MUST NOT depend on running the static validation test last.
:::