requirements.test-coverage.index.gaps.summary
Requirements index · View definition
Requirement
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.
Rationale
I judged this from the three supplied {test} items and did not read implementation source. Together they cover each obligation of requirements.test-coverage.index.gaps.summary.
1. The overview gives the numbers of unsatisfied file and function obligations, grouped by source file.
combined_directory_minimum_includes_hidden_passing_filesinsrc/execution_coverage/book.rsasserts the exact overview line “1 file obligations · 3 function obligations”. The fixture has several files, and each uncovered file has its owndata-filecard.book_verdict_and_gaps_follow_the_native_policy_and_current_reviewsinsrc/execution_coverage/check.rsasserts “0 file obligations · 2 function obligations” and “2 unresolved gaps”. Its obligation-table rows are keyed by file and location (code.rs:1,code.rs:5). One scenario has a file-level obligation (“File root … 1/3 (33.3%); 80% target”) next to function obligations.- The same test asserts that the counts fall as exceptions are accepted (1 unresolved) and as functions become covered (0 unresolved).
2. Each directory summary gives the count for the directory and its descendants, regardless of expansion.
- The book test builds a nested tree:
srchasgap.rs,nested/passing.rsandnested/deep/gap.rs. It asserts “2 uncovered obligations” forsrc, and “1 uncovered obligations” for each ofsrc/nestedandsrc/nested/deep. - This shows that descendant obligations are aggregated.
src/nesteddirectly contains only a passing file, which is hidden, and its count of 1 comes entirely fromdeep. - The assertions read the
<summary>element throughdirectory_summary. They check the count independently of the contents shown under each directory. - The tests never collapse a directory. The count is read from the summary element, which is always present, so I judged this acceptable.
3. Counts are identified as unavailable or incomplete when measurement, discovery or parsing prevents establishing them.
- Missing measurement: the test deletes
profile.profraw. It asserts “gap counts unavailable”, “CI would fail” and “missing or unreadable coverage”. It also asserts that “0 unresolved gaps” is absent and that no “zero execution” rows appear before</section>. - Parse failure, in
overview_exposes_parse_and_discovery_findings_and_used_file_exceptions:- It adds an unparseable
src/nested/driver.rs. - It asserts “Gap counts incomplete” and “cannot parse rust source”.
- It asserts that “0 unresolved gaps” is absent.
- It asserts that the
srcandsrc/nesteddirectory summaries contain “Gap counts incomplete: 1 established uncovered obligations”, so the affected directory counts are flagged.
- It adds an unparseable
- Discovery failure: a corrupt git index produces “cannot discover reference sources”. The test asserts “Gap counts incomplete” or “gap counts unavailable”, and the absence of “0 unresolved gaps”. The disjunction is loose but matches the requirement’s “unavailable or incomplete”.
4. An empty list must not imply the check passes when other failures exist.
- In each failure scenario the tests assert
!report(root).passed, “CI would fail” and no “0 unresolved gaps”. The “Coverage-check findings” footer is also asserted. - A control scenario shows “CI would pass” with “0 unresolved gaps” when nothing fails.
I found no unexercised obligation or mode in the subject text. The discovery-failure case does not assert directory-level labels, but the text only requires the affected counts to be flagged, and the overview-level flag is asserted.
Inputs
Tests
Input 3: outline src/execution_coverage/book.rs mod[tests]/fn[combined_directory_minimum_includes_hidden_passing_files]
- File:
src/execution_coverage/book.rs - Selector:
mod[tests]/fn[combined_directory_minimum_includes_hidden_passing_files] - Kind:
fn src/execution_coverage/book.rs:1030–1114
// {test}`requirements.test-coverage.index.file_map.combined`
// {test}`requirements.test-coverage.index.file_map.directories.initial`
// {test}`requirements.test-coverage.index.file_map.directories.data`
// {test}`requirements.test-coverage.index.file_map.minimum`
// {test}`requirements.test-coverage.index.gaps.summary`
// {test}`requirements.test-coverage.index.file_map.directories`
#[test]
fn combined_directory_minimum_includes_hidden_passing_files() {
let (temp, mut book) = fixture();
let root = temp.path();
fs::create_dir_all(root.join("src/nested/deep")).unwrap();
fs::write(
root.join("src/gap.rs"),
format!("fn gap() {{\n{}}}\n", " let value = 1;\n".repeat(18)),
)
.unwrap();
fs::write(
root.join("src/nested/passing.rs"),
"fn passing() {\n let a = 1;\n let b = 2;\n let c = 3;\n}\n",
)
.unwrap();
fs::write(root.join("src/nested/deep/gap.rs"), "fn nested_gap() {}\n").unwrap();
let path = record(root, "all", 1, "same", &[(1, 0), (2, 1)]);
let run_path = path.parent().unwrap().parent().unwrap().join("run.json");
let mut run: Run = load(&run_path).unwrap();
let mut attempt: Attempt = load(&path.join("attempt.json")).unwrap();
for (file, total, covered, count) in [
("src/gap.rs", 20, 19, 0),
("src/nested/passing.rs", 5, 4, 1),
("src/nested/deep/gap.rs", 1, 1, 0),
] {
run.sources
.insert(file.into(), fs::read_to_string(root.join(file)).unwrap());
attempt.processes[0].lines.insert(
file.into(),
(1..=total)
.map(|line| (line, u64::from(line <= covered)))
.collect(),
);
attempt.processes[0].functions.as_mut().unwrap().push(
super::super::FunctionExecution {
file: file.into(),
line: 1,
column: 1,
count,
},
);
}
save(&run_path, &run).unwrap();
save(&path.join("attempt.json"), &attempt).unwrap();
populate(&mut book, root).unwrap();
let overview = &book.chapters().next().unwrap().content;
let map = map_html(overview);
assert!(map.contains("data-directory=\"src\" open"));
assert!(map.contains("data-min-covered=\"4\" data-min-instrumented=\"5\">80.0%"));
assert!(map.contains("2 uncovered obligations"));
for (directory, expected) in [("src", 2), ("src/nested", 1), ("src/nested/deep", 1)] {
let summary = directory_summary(map, directory);
assert!(summary.contains(&format!("{expected} uncovered obligations")));
assert!(summary.contains("Minimum measured file coverage:"));
}
assert_directory_contents(map, "src", &["src/nested"], &["src/gap.rs"]);
assert_directory_contents(map, "src/nested", &["src/nested/deep"], &[]);
assert_directory_contents(map, "src/nested/deep", &[], &["src/nested/deep/gap.rs"]);
for directory in ["src", "src/nested", "src/nested/deep"] {
assert!(map.contains(&format!("data-directory=\"{directory}\" open")));
}
assert!(map.contains("data-file=\"code.rs\""));
assert!(
map.find("data-file=\"code.rs\"").unwrap()
< map.find("<details class=\"gap-directory\"").unwrap(),
"root file rows are outside directory controls"
);
assert_eq!(map.matches("data-file=").count(), 3);
assert!(map.contains("data-file=\"src/gap.rs\""));
assert!(map.contains("95.0%"));
assert!(file_card(map, "src/gap.rs").contains("<code>src/gap.rs</code>"));
assert!(map.contains("zero execution"));
assert!(!map.contains("data-file=\"src/nested/passing.rs\""));
assert!(
book.chapters()
.all(|chapter| chapter.name != "File notes: src/nested/passing.rs")
);
assert!(overview.contains("1 file obligations · 3 function obligations"));
}
Input 4: outline src/execution_coverage/check.rs mod[tests]/fn[book_verdict_and_gaps_follow_the_native_policy_and_current_reviews]
- File:
src/execution_coverage/check.rs - Selector:
mod[tests]/fn[book_verdict_and_gaps_follow_the_native_policy_and_current_reviews] - Kind:
fn src/execution_coverage/check.rs:757–946
// {test}`requirements.test-coverage.index.gaps`
// {test}`requirements.test-coverage.index.gaps.summary`
// {test}`requirements.test-coverage.index.gaps.details`
// {test}`requirements.test-coverage.index.gaps.details.initial`
// {test}`requirements.test-coverage.index.gaps.explanations`
// {test}`requirements.test-coverage.index.gaps.accepted`
// {test}`requirements.test-coverage.index.file_map.combined`
// {test}`requirements.test-coverage.index.file_map.combined.measurement`
// {test}`requirements.test-coverage.index.file_map.minimum`
// {test}`requirements.test-coverage.index.file_map.combined.details`
#[test]
fn book_verdict_and_gaps_follow_the_native_policy_and_current_reviews() {
use mdbook_preprocessor::book::{Book, Chapter};
let source = "fn a() {}\n\n/// Invariant fallback, unreachable through the public API.\n// {cite}`habeas:coverage`\nfn b() {}\n";
let temp = fixture(source);
let root = temp.path();
let mut p = process(root, &[(1, 1), (2, 1), (3, 1), (4, 1), (5, 0)], 0);
p.functions.as_mut().unwrap()[0].count = 0;
let path = record(root, "both", 1, "same", vec![p]);
let render = || {
let mut book = Book::new();
book.push_item(Chapter::new(
"Requirements index",
"# Requirements index\n".into(),
"requirements-index.md",
vec![],
));
book::populate_in(
&mut book,
root,
Some(root.join("target")),
Path::new("requirements-index.md"),
)
.unwrap();
book.chapters()
.find(|chapter| chapter.name == "Coverage gaps")
.unwrap()
.content
.clone()
};
let missing = render();
exercise_file_click(&missing);
let permitted_details = regex::Regex::new(r#"<details class="([^"]+)""#).unwrap();
let assert_details = |html: &str| {
for tag in permitted_details.captures_iter(html) {
assert!(
matches!(
&tag[1],
"gap-directory" | "gap-explanation" | "gap-accepted-group" | "gap-footer"
),
"unexpected expandable section: {}",
&tag[1]
);
}
assert!(!html.contains("Test runs and provenance"));
assert!(!html.contains("habeas-coverage-test"));
};
assert_details(&missing);
let unresolved_rows = missing
.split("class=\"gap-obligation-table\"")
.nth(1)
.unwrap()
.split("</tbody></table>")
.next()
.unwrap();
for row in [
"<code>fn[a]</code><br><span class=\"gap-meta\">code.rs:1</span></td><td>zero execution</td>",
"<code>fn[b]</code><br><span class=\"gap-meta\">code.rs:5</span></td><td>zero execution</td>",
] {
assert!(unresolved_rows.contains(row));
}
assert!(!report(root).passed);
assert!(missing.contains("CI would fail"));
assert!(missing.contains("2 unresolved gaps"));
assert!(missing.contains("0 file obligations · 2 function obligations"));
assert!(missing.contains("Missing habeas:coverage proposal"));
assert!(missing.contains("Review missing"));
assert!(missing.contains("Invariant fallback, unreachable through the public API."));
assert!(missing.contains("aria-expanded=\"false\""));
assert!(missing.contains("class=\"gap-detail-row\" id=\"habeas-gap-file-0\" hidden"));
assert!(missing.contains("code.rs:1"));
assert!(missing.contains("code.rs:5"));
reviews(root, json!(true));
let accepted = render();
assert_details(&accepted);
assert!(accepted.contains("1 unresolved gaps"));
assert!(accepted.contains("Documented gaps — 1 accepted exceptions"));
assert!(!accepted.contains("class=\"gap-accepted-group\" open"));
assert!(accepted.contains("fn[b]"));
assert!(accepted.contains("current and accepted"));
let documented = accepted
.split("class=\"gap-accepted-group\"")
.nth(1)
.unwrap()
.split("class=\"gap-footer\"")
.next()
.unwrap();
for field in [
"fn[b]",
"code.rs:5",
"zero execution",
"Invariant fallback, unreachable through the public API.",
"current and accepted",
"Current workspace source notes",
"coverage-reports/files/",
] {
assert!(
documented.contains(field),
"missing documented field: {field}"
);
}
assert!(accepted.contains("80.0%")); // Accepted exceptions add no execution.
reviews(root, json!(false));
let rejected = render();
assert_details(&rejected);
assert!(
rejected.contains("<details class=\"gap-footer\"><summary>Coverage-check findings")
);
assert!(rejected.contains("2 unresolved gaps"));
assert!(rejected.contains("Review not accepted"));
assert!(rejected.contains("determination is false"));
assert!(rejected.contains("Documented gaps — 0 accepted exceptions"));
reviews(root, json!(true));
let mut attempt: Attempt = load(&path.join("attempt.json")).unwrap();
for entry in attempt.processes[0].functions.as_mut().unwrap() {
entry.count = 1;
}
save(&path.join("attempt.json"), &attempt).unwrap();
let covered = render();
assert!(report(root).passed);
assert!(covered.contains("CI would pass"));
assert!(covered.contains("0 unresolved gaps"));
assert!(!covered.contains("data-file=\"code.rs\""));
assert!(covered.contains("Documented gaps — 0 accepted exceptions"));
fs::remove_file(path.join("profile.profraw")).unwrap();
let unavailable = render();
assert!(!report(root).passed);
assert!(unavailable.contains("CI would fail"));
assert!(unavailable.contains("gap counts unavailable"));
assert!(!unavailable.contains("0 unresolved gaps"));
assert!(
!unavailable
.split("</section>")
.next()
.unwrap()
.contains("zero execution")
);
assert!(unavailable.contains("missing or unreadable coverage"));
fs::write(
root.join("code.rs"),
"fn a() {}\n// {cite}`habeas:coverage`\nfn b() {}\n",
)
.unwrap();
record(
root,
"both",
2,
"same",
vec![process(root, &[(1, 1), (2, 1), (3, 1)], 0)],
);
let no_justification = render();
assert!(no_justification.contains("No tracked justification is present."));
// File-level and function-level obligations share the same file control
// and must both expose their source, measurement and explanation.
record(
root,
"both",
3,
"same",
vec![process(root, &[(1, 1), (2, 0), (3, 0)], 0)],
);
let below_target = render();
exercise_file_click(&below_target);
let rows = below_target
.split("class=\"gap-obligation-table\"")
.nth(1)
.unwrap()
.split("</tbody></table>")
.next()
.unwrap();
assert!(
rows.contains("<code>File root</code><br><span class=\"gap-meta\">code.rs:1</span>")
);
assert!(rows.contains("1/3 (33.3%); 80% target; uncovered lines: 2-3"));
assert!(rows.contains("Missing habeas:coverage proposal"));
assert!(rows.contains("<code>fn[a]</code>"));
assert!(rows.contains("<code>fn[b]</code>"));
assert_details(&below_target);
}
Input 5: outline src/execution_coverage/check.rs mod[tests]/fn[overview_exposes_parse_and_discovery_findings_and_used_file_exceptions]
- File:
src/execution_coverage/check.rs - Selector:
mod[tests]/fn[overview_exposes_parse_and_discovery_findings_and_used_file_exceptions] - Kind:
fn src/execution_coverage/check.rs:948–1068
// {test}`requirements.test-coverage.index.gaps`
// {test}`requirements.test-coverage.index.gaps.summary`
// {test}`requirements.test-coverage.index.file_map.combined`
// {test}`requirements.test-coverage.index.gaps.accepted`
#[test]
fn overview_exposes_parse_and_discovery_findings_and_used_file_exceptions() {
use mdbook_preprocessor::book::{Book, Chapter};
let source = "//! :::{cite} habeas:coverage\n//! This platform adapter is unreachable from the public interface.\n//! :::\n\n/// Same invariant protects entry to this adapter.\n// {cite}`habeas:coverage`\nfn adapter() {}\n";
let temp = fixture(source);
let root = temp.path();
let render = || {
let mut book = Book::new();
book.push_item(Chapter::new(
"Requirements index",
"# Requirements index\n".into(),
"requirements-index.md",
vec![],
));
book::populate_in(
&mut book,
root,
Some(root.join("target")),
Path::new("requirements-index.md"),
)
.unwrap();
book.chapters()
.find(|chapter| chapter.name == "Coverage gaps")
.unwrap()
.content
.clone()
};
reviews(root, json!(true));
record(
root,
"adapter",
1,
"same",
vec![process(root, &[(7, 0)], 0)],
);
let accepted = render();
assert!(report(root).passed);
assert!(accepted.contains("CI would pass"));
assert!(accepted.contains("Documented gaps — 2 accepted exceptions"));
assert!(!accepted.contains("data-file=\"code.rs\""));
let documented = accepted
.split("class=\"gap-accepted-group\"")
.nth(1)
.unwrap()
.split("<p class=\"gap-footer")
.next()
.unwrap();
for text in [
"File root",
"code.rs:1",
"code.rs:7",
"fn[adapter]",
"zero execution",
"0/1 (0.0%)",
"This platform adapter is unreachable",
"Same invariant",
"current and accepted",
"Current workspace source notes",
"coverage-reports/files/",
] {
assert!(
documented.contains(text),
"missing documented field: {text}"
);
}
// Measurement still succeeds when a discovered source cannot be parsed.
fs::create_dir_all(root.join("src/nested")).unwrap();
fs::write(root.join("src/nested/driver.rs"), "fn broken(").unwrap();
let mut p = process(root, &[(7, 0)], 0);
p.lines
.insert("src/nested/driver.rs".into(), BTreeMap::from([(1, 0)]));
let attempt = record(root, "adapter", 2, "same", vec![p]);
let run_path = attempt.parent().unwrap().parent().unwrap().join("run.json");
let mut run: Run = super::super::load(&run_path).unwrap();
run.sources
.insert("src/nested/driver.rs".into(), "fn broken(".into());
save(&run_path, &run).unwrap();
let broken = render();
assert!(!report(root).passed);
assert!(broken.contains("CI would fail"));
assert!(broken.contains("Gap counts incomplete"));
assert!(broken.to_lowercase().contains("cannot parse rust source"));
assert!(broken.contains("Coverage-check findings"));
assert!(!broken.contains("0 unresolved gaps"));
assert!(broken.contains("driver.rs"));
for directory in ["src", "src/nested"] {
let summary = broken
.split(&format!("data-directory=\"{directory}\""))
.nth(1)
.unwrap()
.split("</summary>")
.next()
.unwrap();
assert!(
summary.contains("Gap counts incomplete: 1 established uncovered obligations"),
"{summary}"
);
}
assert!(
report(root)
.text
.contains("src/nested/driver.rs: below 80%"),
"independent measured file threshold must still run after parse failure"
);
fs::remove_file(root.join("src/nested/driver.rs")).unwrap();
git2::Repository::init(root).unwrap();
fs::write(root.join(".git/index"), "not a valid index").unwrap();
let discovery = render();
assert!(!report(root).passed);
assert!(discovery.contains("CI would fail"));
assert!(discovery.contains("cannot discover reference sources"));
assert!(
discovery.contains("Gap counts incomplete")
|| discovery.contains("gap counts unavailable")
);
assert!(!discovery.contains("0 unresolved gaps"));
}
Referenced definitions
Input 2: requirements selection requirements.test-coverage.index.gaps
requirements.test-coverage.index.gaps:md/requirements/test-coverage.md:407–413
:::{req} index.gaps
The combined coverage overview MUST identify whether the post-suite check of
{cite}`requirements.test-coverage.check` 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.
:::
Other sources
Input 1: requirements selection requirements.test-coverage.index.gaps.summary
requirements.test-coverage.index.gaps.summary:md/requirements/test-coverage.md:415–427
:::{req} index.gaps.summary
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
{cite}`requirements.test-coverage.index.gaps` reports other failures.
:::