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.references.coverage.report

Requirements index · View definition

evidence Valid

Requirement

habeas status, and habeas author after it finishes, MUST report the number of nodes without recent coverage under cite requirements.references.coverage.history, except items inside a module named tests, using the following summary:

N nodes have coverage warnings. Use `status --coverage` to see them.

The summary MUST report zero when no nodes have warnings. Default output MUST NOT list individual coverage warnings or coverage-history details, including with status --all or status --verbose. habeas status --coverage MUST list every warning, naming its file, line, kind, and name, and report incomplete coverage history when applicable. A warning MUST NOT fail validation, and repository validation MUST NOT read Git history.

Rationale

The reviewed tests cover each obligation of requirements.references.coverage.report. I did not read any implementation source. Every mapping below comes from the supplied test text.

  • Summary line in habeas status.

    • tests/commands.rs#fn[status_preserves_repository_wide_rust_findings_in_every_form] asserts the exact summary text with the count, “N nodes have coverage warnings. Use status --coverage to see them.”, in default output.
    • It runs with no flags, --all, --verbose and --all --verbose, each with and without a selection.
    • tests/coverage.rs#fn[status_shows_coverage_warnings_and_says_when_history_is_incomplete] asserts the summary with count 2. The count is 2 because helper and render are unread while the mod tests fixture is excluded.
  • Summary line after habeas author.

    • tests/coverage.rs#fn[habeas_author_prints_only_the_coverage_warning_count_on_stderr] runs author --all. It asserts the stderr summary with a count of 3. It also asserts that no individual warnings and no history note appear on stderr or stdout.
    • The tests/authoring_batch.rs tests assert the summary on stderr after a batch, after skipped-as-current runs, and after a single --stdout citation review.
    • missing_keeps_current_records_and_force_reassesses_every_selected_subject also asserts that the individual warning for orphan is not printed.
  • Zero case. tests/coverage.rs#fn[incomplete_history_is_noted_even_with_nothing_to_warn_about] asserts the summary with a count of 0 in default status.

  • No individual warnings or history details in default output.

    • The tests/commands.rs test asserts there is no “has no recent coverage” text and no “## Coverage warnings” heading in any non-coverage form, including --all and --verbose.
    • The default status in tests/coverage.rs asserts the absence of “history is incomplete”, including for a shallow clone.
    • One small gap in rigor: the incomplete-history case is not run with --all or --verbose. The default-output path is the same code, so I did not treat this as a gap.
  • Items in mod tests excluded from the count.

    • The fixture in mod tests is excluded from the warned set in tests/coverage.rs.
    • items_in_out_of_line_tests_modules_are_not_warned_about covers out-of-line tests.rs and tests/mod.rs.
    • src/coverage_history.rs#mod[tests]/fn[files_declared_as_tests_modules_are_in_a_tests_module] covers the path classification.
    • src/rust_coverage.rs#mod[tests]/fn[a_test_without_a_test_reference_is_an_error_not_a_coverage_warning] asserts that a bare #[test] is an error, not a warning, while helper is only a warning.
  • status --coverage lists every warning with file, line, kind and name.

    • The tests/commands.rs test asserts the full warning text (file, line, “function”, name, “has no recent coverage…”) under the “## Coverage warnings” heading, in all flag and selection combinations.
    • The tests/coverage.rs status test asserts the same form for render. It also asserts that a covered parse is not listed, and it asserts that parse is listed once its coverage lapses.
    • coverage_lasts_for_three_reauthorings_of_the_record_that_read_an_item asserts that the full warned set is ["parse", "helper"], which checks that every warning is reported.
  • Incomplete history. The shallow-clone tests assert “Coverage history is incomplete” under --coverage (status_shows_coverage_warnings_and_says_when_history_is_incomplete and incomplete_history_is_noted_even_with_nothing_to_warn_about). They also assert that it is absent from a complete history.

  • A warning does not fail validation. coverage_lasts_for_three_reauthorings_of_the_record_that_read_an_item calls validate_repository while parse is warned and asserts that no error mentions it. The tests/commands.rs status runs succeed with warnings present, and the authoring tests assert that validation has no errors.

  • Validation does not read Git history. validation_does_not_read_git_history removes the Git object database. It asserts that validation errors are unchanged and that coverage_warnings becomes incomplete, which shows that validation does not depend on Git history.

The examples coverage.reauthored, coverage.new_function and coverage.test_module are exercised by coverage_lasts_for_three_reauthorings_of_the_record_that_read_an_item. It shows helper warned immediately, parse covered through two re-authorings and warned after the third, and the mod tests fixture never warned.

I found no unacknowledged gaps.

Inputs

Tests

Input 3: requirements selection requirements.references.coverage.reauthored
:::{example} coverage.reauthored
Function `parse` has no reference, and the evidence of `requirements.cli.check`
read it. The requirement is re-authored and committed twice, and neither new
record reads `parse`. With the default window of 3, the record's third most
recent version still names `parse`, so `habeas status --coverage` does not warn.
After a third such commit, no version in the window names it, and
`habeas status --coverage` warns about `parse`.
{test}`requirements.references.coverage.history`
{test}`requirements.references.coverage.report`
:::
Input 4: requirements selection requirements.references.coverage.new_function
:::{example} coverage.new_function
A new function `helper` has no reference, and no evidence record has ever read
it. `habeas status --coverage` warns about it at once; nothing in any window
names it.
{test}`requirements.references.coverage.report`
:::
Input 5: requirements selection requirements.references.coverage.test_module
:::{example} coverage.test_module
A helper function inside `mod tests` has no reference and is read by no record.
`habeas status --coverage` does not warn about it. A `#[test]` function in the
same module without a `{test}` reference is still a validation error.
{test}`requirements.references.coverage.report`
{test}`requirements.references.coverage.tests`
:::
Input 6: outline src/coverage_history.rs mod[tests]/fn[files_declared_as_tests_modules_are_in_a_tests_module]
    // {test}`requirements.references.coverage.report`
    // {test}`requirements.references.coverage.test_module`
    #[test]
    fn files_declared_as_tests_modules_are_in_a_tests_module() {
        for path in [
            "src/tests.rs",
            "src/foo/tests.rs",
            "src/foo/tests/mod.rs",
            "src/foo/tests/helpers.rs",
            "crates/a/src/b/tests.rs",
            "src/bin/tool/tests.rs",
            "tests/common/tests.rs",
        ] {
            assert!(in_tests_file(Path::new(path)), "{path}");
        }
        for path in [
            "src/lib.rs",
            "src/main.rs",
            "src/foo.rs",
            "src/foo/mod.rs",
            "src/bin/tests.rs",
            "tests/tests.rs",
            "tests/coverage.rs",
            "tests/common/mod.rs",
            "examples/tests.rs",
            "build.rs",
        ] {
            assert!(!in_tests_file(Path::new(path)), "{path}");
        }
    }
Input 7: outline src/rust_coverage.rs mod[tests]/fn[a_test_without_a_test_reference_is_an_error_not_a_coverage_warning]
  • File: src/rust_coverage.rs
  • Selector: mod[tests]/fn[a_test_without_a_test_reference_is_an_error_not_a_coverage_warning]
  • Kind: fn
  • src/rust_coverage.rs:767–796
    // {test}`requirements.references.coverage.tests`
    // {test}`requirements.references.coverage.report`
    #[test]
    fn a_test_without_a_test_reference_is_an_error_not_a_coverage_warning() {
        let project = TempDir::new().unwrap();
        fs::create_dir_all(project.path().join("tests")).unwrap();
        fs::write(
            project.path().join("tests/foo.rs"),
            "#[test]\nfn bare() {}\n\nfn helper() {}\n",
        )
        .unwrap();
        let mut errors = Vec::new();
        let uncovered = validate_rust_functions(
            project.path(),
            &crate::evidence::discovered_files(project.path(), &mut Vec::new()),
            &definitions(),
            &super::EvidenceReads::default(),
            &mut errors,
            &mut Vec::new(),
            &mut |_| {},
        );
        assert_eq!(errors.len(), 1, "{errors:?}");
        assert!(
            errors[0].contains("tests/foo.rs:2: test function bare"),
            "{errors:?}"
        );
        let warned: Vec<&str> = uncovered.iter().map(|item| item.error.as_str()).collect();
        assert_eq!(warned.len(), 1, "{warned:?}");
        assert!(warned[0].contains("function helper"), "{warned:?}");
    }
Input 8: outline tests/authoring_batch.rs fn[dumb_terminal_keeps_plain_batch_diagnostics]
// {test}`requirements.authoring.progress`
// {test}`requirements.authoring.batch`
// {test}`requirements.references.coverage.report`
// {test}`requirements.references.coverage.history`
#[cfg(unix)]
#[test]
fn dumb_terminal_keeps_plain_batch_diagnostics() {
    let server = Server::start(false, None);
    let fixture = Fixture::new(&server.endpoint, Some(2));
    let output = fixture.run_in_pty(false, "dumb");
    assert!(output.status.success(), "{output:?}");
    assert_eq!(server.subjects().len(), 6);
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(!stderr.contains('\x1b'), "{stderr}");
    assert!(
        stderr.contains("Authoring 6 assessments under the once policy with concurrency 2"),
        "{stderr}"
    );
    assert!(!stderr.contains("6/6 finished"), "{stderr}");
    assert_eq!(
        String::from_utf8_lossy(&output.stdout).trim(),
        "6 authored; 0 skipped as current; 0 failed; policy once"
    );
    // A finished batch reports only the count; history details are opt-in.
    assert!(
        stderr.contains("nodes have coverage warnings. Use `status --coverage` to see them."),
        "{stderr}"
    );
    assert!(
        !stderr.contains("coverage history is incomplete"),
        "{stderr}"
    );
}
Input 9: outline tests/authoring_batch.rs fn[interrupted_terminal_progress_keeps_unstarted_work_incomplete]
// {test}`requirements.authoring.progress`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.authoring.batch`
// {test}`requirements.authoring.concurrency`
// {test}`requirements.references.coverage.report`
#[cfg(unix)]
#[test]
fn interrupted_terminal_progress_keeps_unstarted_work_incomplete() {
    // Concurrency one is the Ollama default: only one assessment is running.
    for (overlap, concurrency) in [(true, 2), (false, 1)] {
        assert_interruption_stops_the_batch(overlap, concurrency);
    }
}
Input 10: outline tests/authoring_batch.rs fn[batch_authors_citation_reviews_and_preserves_current_ones]
// {test}`requirements.references.citation_review`
// {test}`requirements.authoring.batch`
// {test}`requirements.authoring.refresh`
// {test}`requirements.references.coverage.report`
#[test]
fn batch_authors_citation_reviews_and_preserves_current_ones() {
    let server = Server::start(false, None);
    let fixture = Fixture::new(&server.endpoint, None);
    let source = fixture.project.join("src/lib.rs");
    let cite = "// {cite}`requirements.alpha`\n".to_owned();
    fs::write(
        &source,
        format!(
            "{}{cite}pub fn helper() {{}}\n",
            fs::read_to_string(&source).unwrap()
        ),
    )
    .unwrap();
    let output = fixture.run(&["author", "--all"]);
    assert!(
        output.status.success(),
        "{}",
        String::from_utf8_lossy(&output.stderr)
    );
    let subjects = server.subjects();
    assert_eq!(subjects.len(), 7, "{subjects:?}");
    assert!(
        subjects.contains(&"src/lib.rs fn[helper]".to_owned()),
        "{subjects:?}"
    );
    let review: Value = serde_json::from_slice(
        &fs::read(
            fixture
                .project
                .join("evidence/citations/src/lib.rs/fn[helper].json"),
        )
        .unwrap(),
    )
    .unwrap();
    assert_eq!(
        review["citations"],
        json!([{"role": "cite", "name": "requirements.alpha", "commentary": ""}])
    );
    let report = habeas::validate_repository(&fixture.project).unwrap();
    assert!(report.errors.is_empty(), "{:?}", report.errors);

    let again = fixture.run(&["author", "--all"]);
    assert_eq!(
        String::from_utf8_lossy(&again.stdout).trim(),
        "0 authored; 7 skipped as current; 0 failed"
    );
    // A single named citation review that is current is kept under
    // `--missing`, the default, without a model or configuration.
    fs::write(&fixture.config, "not toml [").unwrap();
    let citation = "citations:src/lib.rs#fn[helper]";
    for args in [
        &["author", citation][..],
        &["author", citation, "--missing"],
    ] {
        let output = fixture.run(args);
        assert!(
            output.status.success(),
            "{args:?}: {}",
            String::from_utf8_lossy(&output.stderr)
        );
        assert_eq!(
            String::from_utf8_lossy(&output.stdout).trim(),
            format!(
                "{citation}: evidence is current; 1 skipped as current (use --force to reassess)"
            )
        );
    }
    assert_eq!(server.subjects().len(), 7, "no model was invoked");
    fs::write(&fixture.config, &fixture.config_text).unwrap();
    let path = fixture
        .project
        .join("evidence/citations/src/lib.rs/fn[helper].json");
    let mut before: Value = serde_json::from_slice(&fs::read(&path).unwrap()).unwrap();
    before["rationale"] = json!("CURRENT_RECORD_BEFORE_FORCE");
    fs::write(&path, before.to_string()).unwrap();
    let output = fixture.run(&["author", citation, "--force"]);
    assert!(output.status.success(), "{output:?}");
    assert_eq!(server.subjects().len(), 8);
    assert_eq!(
        serde_json::from_slice::<Value>(&fs::read(&path).unwrap()).unwrap()["item"],
        "fn[helper]"
    );
    assert!(
        !fs::read_to_string(&path)
            .unwrap()
            .contains("CURRENT_RECORD_BEFORE_FORCE")
    );
    let output = fixture.run(&["author", "--all", "--force"]);
    assert!(output.status.success(), "{output:?}");
    assert_eq!(server.subjects().len(), 15);
    assert_eq!(
        server
            .subjects()
            .iter()
            .filter(|s| *s == "src/lib.rs fn[helper]")
            .count(),
        3
    );
    // A citation review can also be named on its own.
    let single = fixture.run(&["author", "citations:src/lib.rs#fn[helper]", "--stdout"]);
    assert!(
        single.status.success(),
        "{}",
        String::from_utf8_lossy(&single.stderr)
    );
    let printed: Value = serde_json::from_slice(&single.stdout).unwrap();
    assert_eq!(printed["item"], "fn[helper]");
    // The coverage summary stays on stderr; stdout holds only the record.
    let stderr = String::from_utf8_lossy(&single.stderr);
    assert!(
        stderr.contains("nodes have coverage warnings. Use `status --coverage` to see them."),
        "{stderr}"
    );
    assert!(
        !stderr.contains("coverage history is incomplete"),
        "{stderr}"
    );
    assert_eq!(server.subjects().len(), 16);
}
Input 11: outline tests/authoring_batch.rs fn[missing_keeps_current_records_and_force_reassesses_every_selected_subject]
/// Under `--missing`, the default, a named subject or `--all` keeps current
/// records without a model or configuration; `--force` reassesses them, and
/// `--stdout` implies it.
// {test}`requirements.authoring.refresh`
// {test}`requirements.authoring.invocation`
// {test}`requirements.authoring.batch`
// {test}`requirements.references.coverage.report`
#[test]
fn missing_keeps_current_records_and_force_reassesses_every_selected_subject() {
    let server = Server::start(false, None);
    let fixture = Fixture::new(&server.endpoint, None);
    let first = fixture.run(&["author", "--all"]);
    assert!(
        first.status.success(),
        "{}",
        String::from_utf8_lossy(&first.stderr)
    );
    assert_eq!(server.subjects().len(), 6);
    let alpha = fixture.evidence("requirements.alpha");

    // Without a usable configuration, current records are still kept: no
    // configuration is resolved when nothing needs assessment.
    fs::write(&fixture.config, "not toml [").unwrap();
    // An item nothing reads is warned about even when nothing is assessed.
    fs::write(fixture.project.join("src/extra.rs"), "pub fn orphan() {}\n").unwrap();
    for args in [
        &["author", "requirements.alpha"][..],
        &["author", "requirements.alpha", "--missing"],
        &["author-evidence", "requirements.alpha_case"],
    ] {
        let output = fixture.run(args);
        assert!(
            output.status.success(),
            "{args:?}: {}",
            String::from_utf8_lossy(&output.stderr)
        );
        assert_eq!(
            String::from_utf8_lossy(&output.stdout).trim(),
            format!(
                "{}: evidence is current; 1 skipped as current (use --force to reassess)",
                args[1]
            )
        );
        let stderr = String::from_utf8_lossy(&output.stderr);
        assert!(
            stderr.contains("nodes have coverage warnings. Use `status --coverage` to see them."),
            "{args:?}: {stderr}"
        );
        assert!(
            !stderr.contains("function orphan has no recent coverage"),
            "{stderr}"
        );
    }
    for args in [&["author", "--all"][..], &["author", "--all", "--missing"]] {
        let output = fixture.run(args);
        assert!(
            output.status.success(),
            "{args:?}: {}",
            String::from_utf8_lossy(&output.stderr)
        );
        assert_eq!(
            String::from_utf8_lossy(&output.stdout).trim(),
            "0 authored; 6 skipped as current; 0 failed"
        );
    }
    assert_eq!(server.subjects().len(), 6, "no model was invoked");
    assert_eq!(fixture.usage().len(), 6);
    assert_eq!(fixture.evidence("requirements.alpha"), alpha);

    // `--missing` and `--force` are mutually exclusive, and `--stdout`
    // already implies `--force`.
    for args in [
        &["author", "requirements.alpha", "--missing", "--force"][..],
        &["author", "--all", "--missing", "--force"],
        &["author", "requirements.alpha", "--stdout", "--missing"],
    ] {
        let output = fixture.run(args);
        assert!(!output.status.success(), "{args:?}");
        assert!(
            String::from_utf8_lossy(&output.stderr).contains("cannot be used with"),
            "{args:?}: {}",
            String::from_utf8_lossy(&output.stderr)
        );
    }
    assert_eq!(server.subjects().len(), 6);

    fs::write(&fixture.config, &fixture.config_text).unwrap();
    let forced = fixture.run(&["author", "requirements.alpha", "--force"]);
    assert!(
        forced.status.success(),
        "{}",
        String::from_utf8_lossy(&forced.stderr)
    );
    assert_eq!(
        server.subjects().last().unwrap(),
        "requirement requirements.alpha"
    );
    assert_eq!(server.subjects().len(), 7);
    let stdout = fixture.run(&["author", "requirements.alpha", "--stdout"]);
    assert!(
        stdout.status.success(),
        "{}",
        String::from_utf8_lossy(&stdout.stderr)
    );
    let printed: Value = serde_json::from_slice(&stdout.stdout).unwrap();
    assert_eq!(printed["requirement"], alpha["requirement"]);
    assert_eq!(server.subjects().len(), 8, "--stdout implies --force");
    let all = fixture.run(&["author", "--all", "--force"]);
    assert!(
        all.status.success(),
        "{}",
        String::from_utf8_lossy(&all.stderr)
    );
    assert_eq!(
        String::from_utf8_lossy(&all.stdout).trim(),
        "6 authored; 0 skipped as current; 0 failed; policy once"
    );
    assert_eq!(server.subjects().len(), 14);
    fs::write(
        fixture.project.join("evidence/requirements.alpha.json"),
        "{invalid",
    )
    .unwrap();
    let repaired = fixture.run(&["author", "--all", "--missing"]);
    assert!(repaired.status.success(), "{repaired:?}");
    assert_eq!(server.subjects().len(), 15);
    assert_eq!(
        fixture.evidence("requirements.alpha")["determination"],
        true
    );

    let report = habeas::validate_repository(&fixture.project).unwrap();
    assert!(report.errors.is_empty(), "{:?}", report.errors);
}
Input 12: outline tests/commands.rs fn[status_preserves_repository_wide_rust_findings_in_every_form]
  • File: tests/commands.rs
  • Selector: fn[status_preserves_repository_wide_rust_findings_in_every_form]
  • Kind: fn
  • tests/commands.rs:460–513
// {test}`requirements.cli.status`
// {test}`requirements.references.rust_item_coverage`
// {test}`requirements.references.definition_globs`
// {test}`requirements.references.coverage.report`
#[test]
fn status_preserves_repository_wide_rust_findings_in_every_form() {
    let temp = fixture();
    let nested = temp.path().join("src/nested");
    // `main` is read by an evidence record; this item is read by none.
    fs::write(temp.path().join("src/extra.rs"), "fn unread() {}\n").unwrap();
    for flags in [
        [].as_slice(),
        ["--all"].as_slice(),
        ["--verbose"].as_slice(),
        ["--all", "--verbose"].as_slice(),
    ] {
        for selection in [None, Some("requirements.ready")] {
            for coverage in [false, true] {
                let mut args = vec!["status"];
                args.extend_from_slice(flags);
                args.extend(selection);
                if coverage {
                    args.push("--coverage");
                }
                let output = habeas(&nested, &args);
                assert!(output.status.success(), "{args:?}: {output:?}");
                let text = String::from_utf8(output.stdout).unwrap();
                if coverage {
                    assert!(text.contains("## Coverage warnings"), "{args:?}: {text}");
                    assert!(
                    text.contains(
                        "src/extra.rs:1: function unread has no recent coverage: it has no requirement or example reference, and no recent evidence record or review read it"
                    ),
                    "{args:?}: {text}"
                );
                } else {
                    assert!(
                        text.contains(
                            "1 nodes have coverage warnings. Use `status --coverage` to see them."
                        ),
                        "{args:?}: {text}"
                    );
                    assert!(!text.contains("has no recent coverage"), "{args:?}: {text}");
                    assert!(!text.contains("## Coverage warnings"), "{args:?}: {text}");
                }
                assert!(
                    !text.contains("function main has no recent coverage"),
                    "{args:?}: {text}"
                );
                assert!(!text.contains("attestation"), "{args:?}: {text}");
            }
        }
    }
}
Input 13: outline tests/coverage.rs fn[coverage_lasts_for_three_reauthorings_of_the_record_that_read_an_item]
  • File: tests/coverage.rs
  • Selector: fn[coverage_lasts_for_three_reauthorings_of_the_record_that_read_an_item]
  • Kind: fn
  • tests/coverage.rs:98–137
// {test}`requirements.references.coverage.reauthored`
// {test}`requirements.references.coverage.new_function`
// {test}`requirements.references.coverage.test_module`
// {test}`requirements.references.coverage.history`
// {test}`requirements.references.coverage.report`
#[test]
fn coverage_lasts_for_three_reauthorings_of_the_record_that_read_an_item() {
    let temp = project();
    let root = temp.path();
    record(root, "rules.check", &["fn[parse]"]);
    record(root, "rules.render", &["fn[render]"]);
    commit(root, "first");
    // `helper` was never read, and `fixture` is in `mod tests`.
    assert_eq!(warned(root), ["helper"]);
    for round in 1..=2 {
        // Each re-authoring changes the file, so each commit counts.
        fs::write(
            root.join("evidence/rules.check.json"),
            json!({"requirement": "x", "determination": true, "rationale": format!("round {round}"), "inputs": []})
                .to_string(),
        )
        .unwrap();
        commit(root, &format!("round {round}"));
        assert_eq!(warned(root), ["helper"], "round {round}");
    }
    fs::write(
        root.join("evidence/rules.check.json"),
        json!({"requirement": "x", "determination": true, "rationale": "round 3", "inputs": []})
            .to_string(),
    )
    .unwrap();
    commit(root, "round 3");
    assert_eq!(warned(root), ["parse", "helper"]);
    // A warning does not fail validation.
    let errors = habeas::validate_repository(root).unwrap().errors;
    assert!(
        !errors.iter().any(|error| error.contains("parse")),
        "{errors:#?}"
    );
}
Input 14: outline tests/coverage.rs fn[status_shows_coverage_warnings_and_says_when_history_is_incomplete]
  • File: tests/coverage.rs
  • Selector: fn[status_shows_coverage_warnings_and_says_when_history_is_incomplete]
  • Kind: fn
  • tests/coverage.rs:231–283
// {test}`requirements.references.coverage.shallow_clone`
// {test}`requirements.references.coverage.history`
// {test}`requirements.references.coverage.report`
#[test]
fn status_shows_coverage_warnings_and_says_when_history_is_incomplete() {
    let temp = project();
    let root = temp.path();
    record(root, "rules.check", &["fn[parse]"]);
    commit(root, "first");
    let status = habeas::status_markdown(root, false).unwrap();
    assert!(
        status.contains("2 nodes have coverage warnings. Use `status --coverage` to see them."),
        "{status}"
    );
    assert!(!status.contains("has no recent coverage"), "{status}");
    assert!(!status.contains("## Coverage warnings"), "{status}");
    let status = coverage_status(root);
    assert!(status.contains("## Coverage warnings"), "{status}");
    assert!(
        status.contains("src/lib.rs:3: function render has no recent coverage"),
        "{status}"
    );
    assert!(
        !status.contains("function parse has no recent coverage"),
        "{status}"
    );
    assert!(!status.contains("history is incomplete"), "{status}");
    record(root, "rules.check", &[]);
    commit(root, "second");
    let clone = tempfile::tempdir().unwrap();
    let target = clone.path().join("shallow");
    let output = Command::new("git")
        .args([
            "clone",
            "--quiet",
            "--depth",
            "1",
            &format!("file://{}", root.display()),
        ])
        .arg(&target)
        .output()
        .unwrap();
    assert!(output.status.success(), "{output:?}");
    let status = coverage_status(&target);
    assert!(
        status.contains("Coverage history is incomplete"),
        "{status}"
    );
    assert!(
        status.contains("function parse has no recent coverage"),
        "{status}"
    );
}
Input 15: outline tests/coverage.rs fn[habeas_author_prints_only_the_coverage_warning_count_on_stderr]
  • File: tests/coverage.rs
  • Selector: fn[habeas_author_prints_only_the_coverage_warning_count_on_stderr]
  • Kind: fn
  • tests/coverage.rs:323–345
// {test}`requirements.references.coverage.report`
#[test]
fn habeas_author_prints_only_the_coverage_warning_count_on_stderr() {
    let temp = project();
    let root = temp.path();
    // No definitions need assessment, so authoring needs no model.
    fs::write(root.join("md/rules.md"), "# Rules\n").unwrap();
    commit(root, "first");
    let output = Command::new(env!("CARGO_BIN_EXE_habeas"))
        .args(["author", "--all"])
        .current_dir(root)
        .output()
        .unwrap();
    assert!(output.status.success(), "{output:?}");
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(
        stderr.contains("3 nodes have coverage warnings. Use `status --coverage` to see them."),
        "{stderr}"
    );
    assert!(!stderr.contains("has no recent coverage"), "{stderr}");
    assert!(!stderr.contains("history is incomplete"), "{stderr}");
    assert!(!String::from_utf8_lossy(&output.stdout).contains("has no recent coverage"));
}
Input 16: outline tests/coverage.rs fn[incomplete_history_is_noted_even_with_nothing_to_warn_about]
  • File: tests/coverage.rs
  • Selector: fn[incomplete_history_is_noted_even_with_nothing_to_warn_about]
  • Kind: fn
  • tests/coverage.rs:347–394
// {test}`requirements.references.coverage.history`
// {test}`requirements.references.coverage.shallow_clone`
// {test}`requirements.references.coverage.report`
#[test]
fn incomplete_history_is_noted_even_with_nothing_to_warn_about() {
    let temp = project();
    let root = temp.path();
    record(
        root,
        "rules.check",
        &["fn[parse]", "fn[render]", "fn[helper]"],
    );
    commit(root, "first");
    commit(root, "second");
    let clone = tempfile::tempdir().unwrap();
    let target = clone.path().join("shallow");
    let output = Command::new("git")
        .args(["clone", "--quiet", "--depth", "1"])
        .arg(format!("file://{}", root.display()))
        .arg(&target)
        .output()
        .unwrap();
    assert!(output.status.success(), "{output:?}");
    assert!(warned(&target).is_empty());
    assert_eq!(
        habeas::coverage_warnings(&target).unwrap(),
        habeas::CoverageWarnings {
            items: Vec::new(),
            incomplete: true
        }
    );
    let status = habeas::status_markdown(&target, false).unwrap();
    assert!(
        status.contains("0 nodes have coverage warnings. Use `status --coverage` to see them."),
        "{status}"
    );
    assert!(!status.contains("history is incomplete"), "{status}");
    let status = coverage_status(&target);
    assert!(
        status.contains("Coverage history is incomplete"),
        "{status}"
    );
    assert!(warned(root).is_empty());
    assert_eq!(
        habeas::coverage_warnings(root).unwrap(),
        habeas::CoverageWarnings::default()
    );
}
Input 17: outline tests/coverage.rs fn[validation_does_not_read_git_history]
// {test}`requirements.references.coverage.report`
// {test}`requirements.references.coverage.history`
#[test]
fn validation_does_not_read_git_history() {
    let temp = project();
    let root = temp.path();
    record(root, "rules.check", &["fn[parse]"]);
    commit(root, "first");
    let before = habeas::validate_repository(root).unwrap().errors;
    // Without the object database, no committed version can be read.
    for entry in fs::read_dir(root.join(".git/objects")).unwrap() {
        let path = entry.unwrap().path();
        if path.file_name().unwrap().len() == 2 {
            fs::remove_dir_all(path).unwrap();
        }
    }
    assert_eq!(habeas::validate_repository(root).unwrap().errors, before);
    assert!(habeas::coverage_warnings(root).unwrap().incomplete);
}
Input 18: outline tests/coverage.rs fn[items_in_out_of_line_tests_modules_are_not_warned_about]
// {test}`requirements.references.coverage.report`
// {test}`requirements.references.coverage.test_module`
#[test]
fn items_in_out_of_line_tests_modules_are_not_warned_about() {
    let temp = project();
    let root = temp.path();
    fs::create_dir_all(root.join("src/foo")).unwrap();
    fs::create_dir_all(root.join("src/bar/tests")).unwrap();
    fs::write(root.join("src/foo.rs"), "mod tests;\n\nfn in_foo() {}\n").unwrap();
    fs::write(root.join("src/foo/tests.rs"), "fn foo_fixture() {}\n").unwrap();
    fs::write(root.join("src/bar.rs"), "mod tests;\n").unwrap();
    fs::write(root.join("src/bar/tests/mod.rs"), "fn bar_fixture() {}\n").unwrap();
    commit(root, "first");
    let mut names = warned(root);
    names.sort();
    assert_eq!(names, ["helper", "in_foo", "parse", "render"]);
}

Referenced definitions

Input 2: requirements selection requirements.references.coverage.history
:::{req} coverage.history
{impl}`requirements.configuration.feature_sections`
An item has recent coverage when it has a reference that covers it under
{cite}`requirements.references.rust_item_coverage`, or when its outline node, or
an outline node containing it, is named by file and selector in the inputs of
any version of an existing evidence record, citation review, or site review in
its coverage window. A file's coverage window MUST be its current contents on
disk, committed or not, together with its contents in each of the last N
commits in its Git history that changed it, read through a Git library rather
than by running `git`. A recorded hash MUST NOT matter here: an earlier version
names the node, whatever its code was then. N MUST be the workspace
`[coverage]` setting `reauthorings`, a positive integer, and 3 when it is not
set. When the history is unavailable, such as outside Git or in a shallow clone
missing those commits, the window MUST be the commits that are available, and
`habeas status --coverage` MUST say that coverage history is incomplete.
:::

Other sources

Input 1: requirements selection requirements.references.coverage.report
:::{req} coverage.report
`habeas status`, and `habeas author` after it finishes, MUST report the number
of nodes without recent coverage under
{cite}`requirements.references.coverage.history`, except items inside a module
named `tests`, using the following summary:

```text
N nodes have coverage warnings. Use `status --coverage` to see them.
```

The summary MUST report zero when no nodes have warnings. Default output MUST
NOT list individual coverage warnings or coverage-history details, including
with `status --all` or `status --verbose`.
`habeas status --coverage` MUST list every warning, naming its file, line, kind,
and name, and report incomplete coverage history when applicable.
A warning MUST NOT fail validation, and repository validation MUST NOT read
Git history.
:::