Test execution coverage
Execution coverage records which instrumented Rust code ran in test processes.
The evidence-input coverage of
records which code requirement
assessments read; execution coverage does not replace those assessments.
The nextest integration uses nextest-owned configuration in
.config/nextest.toml. It adds no settings to habeas.toml; that file’s existing
[coverage] table continues to control evidence-input coverage history.
Habeas’s bundled agent instructions MUST direct agents in Habeas-enabled Cargo
projects to use the coverage workflow of
by default for Rust unit and integration
test runs, including focused or filtered runs. That workflow MUST execute tests
through
cargo nextest.
Habeas’s bundled agent instructions MUST direct agents to run Cargo doctests
separately with cargo test --doc --workspace.
habeas coverage [-- <nextest arguments>] MUST run LLVM-instrumented Rust tests
through cargo nextest run, forwarding the supplied arguments and preserving
nextest’s configured test concurrency, filtering, and retries. With no supplied
arguments it MUST select the workspace.
The coverage workflow MUST verify that the effective nextest profile and configuration selected for the invocation route every selected test attempt through Habeas’s per-process collector, accounting for profile inheritance and wrapper-rule precedence. If that cannot be established, it MUST fail before executing tests with a diagnostic identifying the conflicting profile or setting, rather than silently collecting incomplete coverage.
Each coverage run MUST retain LLVM coverage profiles independently for each test process, identifying its nextest binary, test name, and attempt. Concurrent tests, tests with the same name in different binaries, retries, and separate runs MUST NOT overwrite or combine one another’s stored profiles. Profiles from instrumented child processes MUST remain separate and associated with the test attempt that spawned them.
Habeas MUST support deriving both a report for an individual recorded process
and a combined report without discarding the separate profiles of
. Retained run data MUST remain
sufficient to display those reports using the matching captured source after
the project is rebuilt or its source changes.
During report conversion, on a terminal enabled under
, Habeas MUST
display updating progress with elapsed time and completed and total
test-attempt counts. The total MUST count the recorded attempts selected for
conversion. An attempt MUST advance the completed count only after its
conversion has finished or reported a collection failure, including processing
its associated child-process profiles. These counts MUST measure conversion
work regardless of the attempt’s test outcome.
During coverage-data preparation, on a terminal enabled under
, Habeas MUST
display updating activity and identify the current preparation stage.
Habeas coverage progress MUST be displayed when stderr is an interactive
terminal and TERM is not dumb. NO_COLOR MUST disable color without
disabling progress. When stderr is redirected or TERM=dumb, Habeas coverage
progress MUST NOT emit animation or terminal control sequences.
Temporary progress displays MUST be cleared when their stage ends, including empty work and early collection failures. Final diagnostics and the coverage artifact location MUST remain readable. Progress reporting MUST NOT change coverage results, retained profiles, or command exit status.
Coverage runs MUST be stored as disposable build artifacts under
habeas/coverage/ in the project’s Cargo target directory
(target/habeas/coverage/ with default Cargo settings), retaining earlier runs
until those artifacts are removed. Each run record MUST identify the run,
capture time, command, and test selection, and, when available, the source
revision and whether the source had uncommitted changes.
Habeas’s bundled agent instructions MUST tell agents that coverage artifacts
under , including profiles, reports,
and captured source snapshots, are disposable build output and MUST NOT be
staged or committed to Git.
Each coverage record MUST identify its instrumented build configuration and capture enough source-input identity to determine whether its coverage remains compatible with the project’s current source. Source identity MUST account for uncommitted content changes rather than rely only on the Git revision.
Source identity MUST include the paths and contents of the workspace’s first-party Rust sources and the recorded source and build inputs that affect the instrumented program, including manifests and the dependency lockfile when present. Adding, removing, or changing an included input MUST invalidate the workspace’s collected coverage for the combined view. Freshness checking MUST NOT require rebuilding the project.
Each coverage record MUST identify the recorded toolchain, compilation target, Cargo build profile, enabled features, and instrumentation-affecting compiler settings. These settings MUST determine build-configuration compatibility for the combined view. A nextest scheduling profile alone MUST NOT make otherwise compatible build configurations incompatible.
Each coverage run MUST record the outcome of every test attempt that started. It MUST distinguish successful, failed, and interrupted runs and identify attempts with missing or unreadable coverage rather than treating them as zero execution. An empty test selection MUST be identified as empty; nextest’s success or failure for that selection MUST remain the test execution result.
The coverage workflow MUST return a failing exit status when test execution or coverage collection fails, preserve any profiles already collected, and report the failure. Collecting coverage MUST NOT turn a failing test run into a successful command.
When required nextest or LLVM coverage tooling is unavailable or has an unsupported version, the coverage workflow MUST identify the prerequisite and explain how to obtain a supported version.
habeas mdbook MUST automatically generate exactly one execution-coverage
subchapter under the requirements index of
, whether that requirements index is
explicitly placed or automatically generated.
The requirements index MUST link to its execution-coverage subchapter under
.
habeas mdbook MUST NOT require a separate authored coverage chapter or
{coverage-index} directive, or use such a directive to control generation
of the subchapter under .
The generated coverage subchapter MUST have no authored source file or edit
target.
The coverage index MUST combine the most recent recorded test attempt for each
nextest binary and test name among the retained runs. “Most recent” MUST refer
to when the attempt started, including failed or interrupted attempts. A newer
filtered run MUST update only the tests it executes, leaving other compatible
test records available to the combined view. A newer attempt with missing or
unreadable coverage MUST be shown as unavailable rather than replaced with an
older successful attempt. Results from incompatible instrumented build
configurations MUST NOT be combined under
.
The main combined view MUST use the instrumented build configuration of the most recently started recorded test attempt. Latest-per-test selection MUST occur within that configuration. Records from other configurations MUST be identified as excluded historical coverage. Configuration selection MUST use recorded metadata without building or executing tests.
Only records whose captured source inputs match the current project source and
whose build configurations are compatible MAY contribute execution counts to
the combined view of .
Records invalidated by a source change, or whose compatibility cannot be
established, MUST be identified as stale or unavailable and excluded from the
combined coverage totals. Their per-process reports and matching captured source
MUST remain retained in the build artifacts until those artifacts are removed.
The coverage index MUST display the combined view selected under
and
. It MUST show the number of
selected test attempts and summarize coverage excluded because it is stale,
unavailable, or from a historical build configuration. Detailed test identities,
run provenance, and per-test execution data MUST remain in the saved coverage
artifacts rather than being included in the generated book.
For first-party Rust files under
, the summary MUST compute
line coverage from the union of instrumented file-and-line locations in the
selected fresh records, including their associated child-process records.
Each location MUST count once in the denominator and count as covered when any
selected record has a positive execution count for it. Percentages MUST be
computed from those union counts rather than averaged across process reports.
A view with no instrumented lines MUST show coverage as unavailable. The index
MUST visibly identify incomplete coverage and MUST NOT imply that every current
test has coverage merely because all available records are valid.
A file coverage map MUST identify each file by its workspace-relative path and
show its covered and instrumented line counts and percentage. These counts MUST
use the union rule of ,
restricted to the file and the records represented by that map, including
associated child processes. The map MUST visually distinguish coverage levels
while also displaying percentages as text. The percentage MUST describe the
map’s recorded instrumented lines, rather than all physical source lines.
A listed file with instrumented lines but no positive execution counts MUST show 0%. A listed file with no recorded instrumented lines in otherwise usable coverage MUST show “not measured” without a percentage. Coverage whose completeness cannot be established MUST be identified as unavailable rather than as 0% or “not measured”.
Each file coverage map MUST present its listed files in a compact table, with
one row per file and columns for its workspace-relative path and coverage
percentage or measurement status. Covered and instrumented line counts MUST
remain available in each measured file’s row or expanded details.
The counts, statuses, and visual distinction of coverage levels MUST follow
.
The table of MUST group
its listed files by their directory hierarchy. Each non-root directory
containing a listed file, directly or through descendants, MUST have a group.
Each group MUST be independently expandable and collapsible.
A collapsed group MUST show its workspace-relative path and the summaries
required by and
, while
hiding its file rows and descendant groups.
Directory groups under
MUST be expanded
initially in the combined gaps overview. File rows at the workspace root MUST
remain visible.
Expanding or collapsing a directory group under
MUST NOT change
the files, coverage counts, or measurement statuses represented by the map.
Each directory group under
MUST display the
minimum measured file coverage percentage within its directory, including
descendant directories.
For the combined gaps overview, the minimum MUST consider all current
first-party Rust files represented by the map within that directory,
including files hidden because they have no unsatisfied obligations.
The minimum MUST use the file coverage fractions of
before rounding for display,
regardless of which groups are expanded. Its label MUST identify it as the
minimum measured file coverage. Not-measured and unavailable files MUST NOT
contribute a percentage. A group with no measured files MUST show no numerical
minimum.
Each directory group under
MUST display
the number of its listed files, including descendants, that are not measured
whenever that count is nonzero. The status MUST follow
. The count MUST describe
only files listed by the map, regardless of which groups are expanded.
A map lists src/a.rs with 1 of 2 instrumented lines covered,
src/nested/b.rs with 1 of 4 covered, and src/nested/c.rs as not measured.
Both the src and src/nested groups show a minimum measured file coverage
of 25% and one not-measured file, including while collapsed.
Each listed first-party Rust file in the combined file coverage map MUST provide access to a file-notes view identifying its workspace-relative path.
The view of MUST show
each
habeas:coverage citation attached to the file root or an explicitly
declared function or method. Each entry MUST identify its source item and
source location and show the fenced citation commentary and Rust doc comments
supplying its tracked justification under
.
When no tracked justification is present, the entry MUST say so.
File-root citations MUST be labelled as file-threshold exception proposals;
function and method citations MUST be labelled as function exception proposals,
following .
The view of MUST use
the current workspace source at book-render time and explicitly identify its
contents as current workspace source notes.
The view of MUST show
a readable statement when successfully read and parsed current source contains
no citations within the scope of
.
Missing, unreadable, or unparseable current source MUST instead produce a visible diagnostic, without preventing the rest of the book from rendering. These failures MUST NOT be presented as an absence of coverage explanations.
Each citation entry under
MUST
show whether its source item’s citation review is current and accepted under
.
Missing, unreadable, stale, invalid, or rejected reviews MUST NOT be presented as accepted. The view MUST distinguish a missing review from a present review that is not accepted and expose the validation findings explaining non-acceptance.
Rendering the view of
MUST NOT invoke an
assessment model. It MUST follow
.
The coverage index MUST present a gaps-focused file coverage map representing
all current first-party Rust files under
as its primary overview.
Its primary file rows MUST list only files with unsatisfied coverage
obligations under
or
. A file meeting its line
target MUST still be listed when it contains an unsatisfied function obligation.
Its coverage counts MUST use only records eligible for the combined view under
and
, following
.
The combined gaps overview MUST visibly identify coverage excluded because it
is stale, missing, or unreadable. Measurement failures under
MUST be reported separately
from uncovered file and function obligations. They MUST NOT be presented as
zero execution or as absence of individual function measurement in otherwise
usable coverage.
When the coverage check reports a measurement failure under
, the combined overview
MUST show coverage as unavailable and omit file rows and directory groups.
Measurement findings MUST remain inspectable under
. When no usable selected coverage
exists, the overview MUST retain the collection guidance of
. Numerical coverage MUST
NOT be fabricated from missing or incomplete data.
The combined coverage overview MUST restrict its expandable details to coverage gaps, explanation status, and coverage-check findings. It MUST NOT include a test-run provenance table or embed per-test coverage data.
The combined coverage overview MUST identify whether the post-suite check of
would pass or fail using the same
saved coverage and current exception evidence. Findings that cause the check
to fail MUST remain inspectable, including measurement, source discovery,
source parsing, and exception-review findings.
The combined coverage overview MUST identify the numbers of unsatisfied file and function obligations and group those obligations by source file. Each directory summary MUST identify the number of unsatisfied obligations within that directory and its descendants, regardless of which groups are expanded.
When measurement or source discovery or parsing prevents establishing those
counts, the affected counts MUST be identified as unavailable or incomplete
rather than presented as complete counts. An empty list of established
unsatisfied obligations MUST NOT imply that the check passes when
reports other failures.
In the combined gaps overview, clicking a listed file MUST expand or collapse its uncovered obligations in place. Each expanded file MUST show each obligation’s source item and source location, measurement, and explanation status.
Per-file uncovered obligations under
MUST be collapsed
initially.
Each unsatisfied obligation under
MUST distinguish a
missing
habeas:coverage proposal from a present proposal whose review is
missing or is not current and accepted. When a present proposal contains no
tracked justification, the view MUST say so.
Present justification text and review validation findings MUST remain
inspectable following
and
.
Accepted exceptions actually used to satisfy current file or function
coverage obligations MUST be shown separately in an initially collapsed
documented-gaps section. Each entry MUST identify its source item and source
location, its uncovered measurement, its tracked justification, and its current
accepted review state, using current source notes under
.
Accepted exceptions MUST NOT increase reported execution-coverage percentages. Citations on items whose measured coverage already satisfies their obligations MUST NOT be listed as active gaps.
The coverage index MUST NOT offer per-test file coverage maps or a test
selector. Its file coverage map MUST focus on insufficient combined coverage
under .
habeas mdbook MUST NOT generate per-test coverage subchapters or captured-source
pages under the execution-coverage chapter of
. File-notes pages supporting coverage
gap explanations under
MUST remain available.
Generated coverage-index and coverage-report paths MUST be distinct. The preprocessor MUST reject a generated coverage path that conflicts with an existing book chapter, including another generated chapter.
When no coverage run has been recorded, the coverage index MUST show a readable message explaining how to collect one. Missing, unreadable, or incomplete run data MUST produce a visible diagnostic in the index without preventing the rest of the book from rendering.
Building the book MUST NOT run tests or collect coverage.
In addition to ,
habeas setup MUST enable the
automatic coverage subchapter of
without creating a separate coverage source chapter, adding a coverage
entry to
SUMMARY.md, or requiring a coverage source directive.
Setup MUST preserve existing authored chapter contents and SUMMARY.md.
The generated coverage subchapter MUST make coverage-collection and
post-suite-checking guidance available under
, without requiring
separate authored content.
habeas setup MUST configure native nextest settings in
.config/nextest.toml at the Cargo workspace root so the coverage workflow of
routes each executed test attempt through
the per-process collector of
.
Those settings MUST use nextest’s own configuration format.
Repeating setup MUST avoid duplicate configuration, preserve unrelated nextest
settings, and report conflicting settings for review rather than overwrite them.
Repository validation, including the test calling habeas::validate() under
, MUST check that the saved nextest
integration required by
is present and valid
for the coverage workflow’s default profile, accounting for profile inheritance
and wrapper-rule precedence. A missing, unreadable, malformed, or incompatible
integration MUST be a validation error naming the affected file or setting and
directing the agent to repair it with
habeas setup. The check MUST inspect the
collector settings and selection rules rather than only the file’s existence.
Nextest’s unrelated settings MUST retain their native meaning.
The setup validation of
MUST NOT run tests, collect coverage, or require an existing completed coverage
run. It MUST work during the first instrumented test run, before that run’s
profiles and reports have been written.
Post-suite coverage check
Stricter coverage policy for security-sensitive code, including how projects identify that code, is deferred to issue #47.
habeas coverage-check MUST check saved execution coverage against
and
, returning success only when
every applicable obligation is satisfied or has accepted exception evidence
under
. The command MUST NOT
build the project, execute tests, collect coverage, or invoke an assessment model.
habeas test MUST run the full-workspace instrumented nextest workflow of
and, only after that workflow succeeds,
run the post-suite check of
. 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.
The coverage check MUST consider every explicitly declared function or method
with a body in the first-party Rust sources of
, including test functions,
test helpers, and default trait methods. Declarations without bodies MUST NOT
create execution-coverage obligations. Source discovery or parsing failures
MUST cause the check to fail rather than silently omit functions.
A function whose measurement cannot be established MUST be reported as not
measured rather than silently excluded. Functions excluded by the selected
build configuration require exception evidence under
.
Each first-party Rust file under
MUST have at least 80%
execution coverage of its instrumented lines, or current accepted exception
evidence explaining why the file falls below that target under
. Counts MUST use the
file-and-line union rule of
;
a line counts as executed when any eligible test process or its associated
child processes has a positive execution count for it.
The check MUST use the combined selection and freshness rules of
and
, restricted to the active
build configuration. It MUST compare exact counts rather than rounded displayed
percentages, average file percentages, or impose an 80% target within each
function. A file whose executable code is not measured MUST require exception
evidence rather than pass with a fabricated percentage. A file established to
contain no executable coverage obligations MUST be reported as such and MUST
NOT require a threshold exception.
Absence of recorded instrumented lines alone MUST NOT establish that a file
contains no executable coverage obligations.
Every function under without
recorded execution attributable to it MUST have current accepted exception
evidence under
, even when
its containing file meets the target of
.
Execution attributable only to another function, including a nested function or closure, MUST NOT establish coverage of the enclosing function merely because their source locations overlap. Having no recorded lines alone MUST NOT establish that a function has no executable coverage obligations.
The coverage check MUST fail when no usable coverage has been collected, or when a selected latest attempt has missing, unreadable, or stale coverage. It MUST distinguish these measurement failures from measured lines with zero execution and from individual functions absent from otherwise usable coverage. Exception evidence MUST NOT excuse measurement failures or permit substitution of an older attempt. Excluded historical runs and incompatible configurations MUST NOT by themselves cause failure.
Coverage whose format does not support the function attribution required by
MUST be rejected with guidance
to recollect coverage. When missing or corrupt metadata prevents establishing
the latest-per-test selection or active configuration, the check MUST fail
rather than silently use remaining records. Historical data MAY be disregarded
without failure only when its exclusion can be established.
An unmet file threshold or an unexecuted or not-measured function MAY satisfy
the coverage policy only
through current, accepted, independently assessed evidence explaining why its
coverage is incomplete. An exception MUST be attached to the source file or
function whose incomplete coverage it justifies. A file-threshold exception
MUST NOT automatically excuse untested functions.
An exception MUST NOT excuse another source item’s incomplete coverage.
Changes to the source item, justification, or other inputs
of its citation review MUST invalidate the affected exception under
.
A source comment or unassessed justification alone MUST NOT count as accepted exception evidence. Function and gap identities MUST remain portable between equivalent local and CI checkouts rather than depend on checkout paths, run identifiers, timestamps, or process identifiers.
Habeas MUST provide the built-in habeas:coverage under
, 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 . The built-in MUST be
available in every project without a project requirement, site query, or
exception-specific configuration.
Exception proposals MUST be {cite} references to habeas:coverage
under . Each proposal
MUST have a current, accepted citation review of its source item under
. The reviewer MUST assess
whether the justification adequately explains the proposed exception, not merely
whether the citation has the right role. An acknowledgment of missing coverage
without an adequate justification MUST NOT authorize an exception.
File-threshold proposals MUST belong to the source file’s root item. Proposals concerning unexecuted or not-measured functions MUST belong to their explicitly declared function’s item. One accepted function proposal MUST cover both zero execution and absence from otherwise usable measurement, without separate exception kinds. A proposal in a nested function MUST NOT authorize exceptions for its enclosing function, and an enclosing function’s proposal MUST NOT authorize exceptions for nested functions.
The coverage check MUST use the citation’s source attachment and current accepted review to identify an exception. It MUST NOT require structured exception metadata, match exceptions to targets, profiles, or feature sets, or interpret build conditions in prose as machine-enforced restrictions. A citation with a current accepted review MUST remain eligible across build configurations even when its prose describes a condition specific to one configuration. Satisfying the item’s measured coverage obligations MUST NOT by itself invalidate the citation or make its presence a coverage-check error.
The habeas author workflow MUST support authoring and refreshing exception
evidence under . Assessment
inputs MUST include the current file or function source, the built-in’s fixed
text, and its citation commentary under
.
Justifications and their assessment evidence MUST be retainable in Git
independently of the disposable coverage artifacts under
. Raw profiles, coverage reports, and
captured source snapshots MUST NOT be required in Git to validate an exception
against freshly collected coverage.
Setup-generated coverage documentation and bundled agent instructions MUST
explain how to write a standard habeas:coverage citation with a prose
justification under
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.
The coverage check MUST show each file’s measured coverage and threshold result, identify each unsatisfied function by source file and function, list uncovered locations or absence of measurement, and explain missing, stale, or rejected exception evidence. It MUST report accepted exceptions separately from executed coverage; accepting an exception MUST NOT increase any displayed execution-coverage percentage.
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 .
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.
The habeas-bootstrap-requirements skill MUST direct agents to check the
coverage setup under and
help establish or repair it with
habeas setup before bootstrapping requirement
evidence. It MUST direct agents to report conflicting configuration for review
rather than overwrite project-specific nextest settings.