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.exceptions.setup

Requirements index · View definition

evidence Valid

Requirement

Setup-generated coverage documentation and bundled agent instructions MUST explain how to write a standard habeas:coverage citation with a prose justification under cite requirements.test-coverage.check.exceptions.anchor and author or refresh its citation review using habeas author. The instructions MUST explain that the anchor requires no project declaration or exception-specific configuration, that only current accepted citation evidence permits an exception, and that ordinary partially uncovered functions need none when their file meets its target.

Rationale

The tests adequately check every explanation the subject requires. The required explanations are: (a) how to write a standard habeas:coverage citation with a prose justification; (b) authoring or refreshing its citation review with habeas author; (c) that the anchor needs no project declaration or exception-specific configuration; (d) that only current accepted citation evidence permits an exception; and (e) that ordinary partly uncovered functions need no exception when their file meets its target.

Generated coverage documentation. The text is the GUIDANCE const in src/execution_coverage.rs. src/execution_coverage/book.rs#mod[tests]/fn[generated_reports_inherit_the_requirements_index_hierarchy] renders the chapter, with and without section numbers. It asserts that the chapter contains these phrases:

  • habeas:coverage
  • substantive prose justification
  • fenced commentary or a Rust doc comment
  • citation review with \habeas author``
  • current accepted review
  • No project declaration or special configuration
  • Ordinary partly covered functions need no exception when their file meets its target

Together these cover (a) through (e). The assertions are content checks, so a rewrite that dropped any of these explanations would fail the test. The test never asserts the word “standard” or the {cite} form for the generated chapter. The habeas:coverage and “substantive prose justification” phrases are enough for the “how to write” obligation, so this is not a gap.

Bundled agent instructions. tests/repository.rs#fn[shared_agent_guidance_documents_post_suite_checks_and_standard_explanations] reads assets/skills/habeas/SKILL.md. It asserts these phrases:

  • standard {cite} of habeas:coverage
  • rationale in fenced commentary or a Rust doc comment
  • citation review with habeas author
  • Only current accepted review evidence permits the exception
  • No project declaration or extra configuration is needed
  • Partly covered functions need no exception when their file meets its target

This covers (a) through (e) for the main skill. The skills habeas-evidence and habeas-requirements, and references/ci.md, only mention habeas:coverage briefly and point to the main skill’s explanation. They are not separately tested. I treat them as cross-references rather than the required explanation, so I do not count their absence as a gap.

Other marked tests. tests/setup.rs#fn[coverage_setup_is_idempotent_and_hook_needs_no_coverage_chapter] carries a {test} reference to the subject but asserts nothing about the guidance text. It is not needed for adequacy.

I found no unverified obligation and no acknowledged or unacknowledged gap.

Inputs

Implementation

Input 6: 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";
Input 7: outline assets/skills/habeas/SKILL.md section[Habeas]/section[Testing%20and%20coverage%20artifacts]
## Testing and coverage artifacts

Use `habeas coverage` by default for every Rust unit and integration test run,
including focused runs (`habeas coverage -- -E 'test(name)'`). The workflow uses
`cargo nextest` for parallel process runs and retains independent process
coverage. In this repository use the local alias, `cargo habeas coverage`.
Run doctests separately with `cargo test --doc --workspace`. Install prerequisites
with `cargo install cargo-nextest --locked` (>= 0.9.116) and
`rustup component add llvm-tools-preview` when needed.

Profiles, reports, and captured source under the Cargo target directory
(`target/habeas/coverage/` by default) are disposable build artifacts. Never stage
or commit them to Git. The book combines each test's latest compatible attempt;
source changes invalidate the combined coverage, while saved reports remain
inspectable. Building the book does not run tests.

For final verification, run `habeas test` (`cargo habeas test` in this repository).
It collects coverage for the full workspace, then checks it. In CI, recommend
`habeas coverage -- --workspace` followed, only on success, by
`habeas coverage-check`. The check reads saved data and calls no model; the
static `habeas::validate()` test requires no prior execution coverage.
{impl}`requirements.test-coverage.check.guidance`

When setting up or reviewing project CI, check that it runs both collection and
the post-suite check. Collection alone does not enforce the coverage policy.
Use the [CI example](references/ci.md) when adding these steps to an existing
workflow; setup configures the collector and static validation test, while CI
integration belongs in the project's workflow.

Each first-party Rust file needs 80% instrumented-line coverage. Each completely
unexecuted or not-measured function, including functions excluded by the build
configuration, needs an independently assessed explanation. Partly covered
functions need no exception when their file meets its target. Write a standard
`{cite}` of `habeas:coverage`, with the rationale in fenced commentary or a Rust
doc comment, and author its citation review with `habeas author`. A file-root
citation excuses only the file threshold; a function citation excuses only that
function. Only current accepted review evidence permits the exception. No
project declaration or extra configuration is needed. The citation applies
across build configurations and may remain when coverage is sufficient.
Exceptions never increase reported percentages.
{impl}`requirements.test-coverage.check.exceptions.setup`

The requirements index automatically includes a Coverage gaps subchapter.
Do not add a coverage source chapter or coverage-index directive. Use its CI
verdict and expandable file gaps to find missing tests or coverage explanations;
accepted documented gaps are separate. The book shows coverage gaps without
per-test maps or captured-source reports.

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 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 5: 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"
    );
}

Referenced definitions

Input 2: requirements selection requirements.test-coverage.check.exceptions.anchor
:::{req} check.exceptions.anchor
Habeas MUST provide the built-in `habeas:coverage` under
{cite}`requirements.references.builtin_definitions`, with this text:

> Cite this on a source file or explicitly declared function to propose a
> coverage exception. Explain in prose why the item's incomplete execution
> coverage is acceptable. Put the explanation in fenced citation commentary
> or Rust doc comments included in the source item's assessed input. An ordinary
> non-doc comment alone does not supply a tracked justification. The reason
> must be substantive; difficulty alone is not a justification.
> On a file's root item, the exception excuses only
> that file's 80% instrumented-line threshold, including absent measurement
> of its executable code. On an explicit function with a body, it excuses
> that function's recorded zero execution or absence from otherwise usable
> measurement, without excusing the file's threshold.
> The explanation must agree with the current source and any callers or
> configuration assumptions on which it relies. Only a current accepted
> independent assessment permits the exception. A file exception does not
> excuse unexecuted or not-measured functions in that file.
> The citation applies to its source item without conditional build matching
> and may remain when measured coverage satisfies the item's obligations.

Only `{cite}` MAY reference this built-in, inline or fenced using the standard
reference forms of {cite}`requirements.references.roles`. The built-in MUST be
available in every project without a project requirement, site query, or
exception-specific configuration.
:::

Other sources

Input 1: requirements selection requirements.test-coverage.check.exceptions.setup
:::{req} check.exceptions.setup
Setup-generated coverage documentation and bundled agent instructions MUST
explain how to write a standard `habeas:coverage` citation with a prose
justification under
{cite}`requirements.test-coverage.check.exceptions.anchor` and author or refresh
its citation review using `habeas author`. The instructions MUST explain that
the anchor requires no project declaration or exception-specific configuration,
that only current accepted citation evidence permits an exception, and that
ordinary partially uncovered functions need none when their file meets its
target.
:::