requirements.test-coverage.index.file_map.notes.render_only
Requirements index · View definition
Requirement
Rendering the view of
MUST NOT invoke an assessment model. It MUST follow
.
Rationale
The tests adequately check requirements.test-coverage.index.file_map.notes.render_only.
Obligations
- Rendering the file-notes view MUST NOT invoke an assessment model.
- Rendering MUST follow
requirements.test-coverage.index.render_only: building the book must not run tests or collect coverage.
How the tests cover them
src/execution_coverage/book.rs#mod[tests]/fn[gap_notes_use_current_source_without_collecting]callspopulateon a book whose workspace already holds a recorded coverage run. It then checks the following:- The captured
attempt.jsonbytes are unchanged. - The retained
1-1.profrawfixture is unchanged. - No
evidencedirectory was created. - Each file has exactly one notes page at a distinct path, and the pages show the current source text added after capture.
- These checks together show that rendering reads current files and neither collects coverage nor writes evidence.
- The captured
src/execution_coverage/notes.rs#mod[tests]/fn[each_render_reads_current_notes_and_validates_saved_reviews_without_writing]renders the notes page twice, with a source edit in between. It checks the following:- The saved review file bytes are identical after rendering.
- The review state flips to “not accepted” because the citations changed. The renderer reads and validates saved reviews and does not author new ones, so no model is needed.
- No
targetdirectory appears, so no build or test run happened.
Why no model-invocation test is needed
I read the implementation of notes.rs#fn[pages] to settle one question: whether any code path could call a model. It only reads references, definitions and outlines from disk and formats the chapter text. The execution_coverage search found no model-invocation code. Child processes appear only in runner.rs, the coverage collector, and in a node test helper in check.rs. The notes tests’ “unchanged saved review” and “no evidence written” assertions would catch a render that wrote or authored an assessment. A negative obligation with no model hook has no further scenario to exercise.
I found no unacknowledged gap and no marking gap. Both tests carry {test} references to the subject.
Inputs
Implementation
Input 6: outline src/execution_coverage/notes.rs fn[pages]
- File:
src/execution_coverage/notes.rs - Selector:
fn[pages] - Kind:
fn src/execution_coverage/notes.rs:24–77
// {impl}`requirements.test-coverage.index.file_map.notes`
// {impl}`requirements.test-coverage.index.file_map.notes.justifications`
// {impl}`requirements.test-coverage.index.file_map.notes.current`
// {impl}`requirements.test-coverage.index.file_map.notes.availability`
// {impl}`requirements.test-coverage.index.file_map.notes.reviews`
// {impl}`requirements.test-coverage.index.file_map.notes.render_only`
pub(super) fn pages(root: &Path, files: &BTreeSet<String>, index: &Path) -> Vec<Chapter> {
let outlines = OutlineCache::default();
let mut diagnostics = Vec::new();
let references = crate::evidence::collect_references(root, &mut diagnostics);
let definitions = crate::evidence::load_definitions(root).unwrap_or_else(|error| {
diagnostics.push(error.to_string());
BTreeMap::new()
});
let items = citation_items(root, &definitions, &references, &outlines);
files
.iter()
.map(|file| {
let path = path(index, file);
let mut content = format!(
"# Coverage explanations\n\n[Back to coverage index]({})\n\nFile: <code>{}</code>.\n\n**Current workspace source notes**, read at book-render time. These explanations and review states describe the current source.\n\n",
crate::chapter_href(&path, index, None), escaped(file),
);
match outlines.parse(root, file).as_ref() {
Err(error) => diagnostic(&mut content, error),
Ok(parsed) => {
for error in &diagnostics {
diagnostic(&mut content, error);
}
let mut count = 0;
for item in items.values().filter(|item| item.file == *file) {
let Ok(node) = parsed.resolve(file, &item.item) else {
diagnostic(&mut content, "Cannot resolve the cited source item.");
continue;
};
if !(item.item.is_empty() || parsed.outline.nodes[node].kind == "fn")
|| !item.citations.iter().any(|cite| cite.name == "habeas:coverage")
{
continue;
}
count += 1;
entry(&mut content, root, parsed, node, item, &definitions, &outlines);
}
if count == 0 && diagnostics.is_empty() {
content.push_str("No coverage explanations are present on this file's root or explicitly declared functions and methods.\n");
}
},
}
let mut chapter = Chapter::new(&format!("File notes: {file}"), content, path, vec![]);
chapter.source_path = None;
chapter
})
.collect()
}
Tests
Input 4: outline src/execution_coverage/book.rs mod[tests]/fn[gap_notes_use_current_source_without_collecting]
- File:
src/execution_coverage/book.rs - Selector:
mod[tests]/fn[gap_notes_use_current_source_without_collecting] - Kind:
fn src/execution_coverage/book.rs:1644–1718
// {test}`requirements.test-coverage.index.file_map.notes`
// {test}`requirements.test-coverage.index.file_map.notes.current`
// {test}`requirements.test-coverage.index.file_map.notes.render_only`
#[test]
fn gap_notes_use_current_source_without_collecting() {
let (temp, mut book) = fixture();
let root = temp.path();
fs::create_dir(root.join("md")).unwrap();
fs::write(root.join("book.toml"), "[book]\nsrc='md'\n").unwrap();
fs::write(root.join("md/SUMMARY.md"), "# Summary\n").unwrap();
fs::create_dir_all(root.join("src/nested")).unwrap();
for file in ["src/a.rs", "src/nested/a.rs"] {
fs::write(root.join(file), "fn another() {}\n").unwrap();
}
let attempt = record(root, "one", 1, "a", &[(1, 1)]);
let run_path = attempt.parent().unwrap().parent().unwrap().join("run.json");
let mut run: Run = load(&run_path).unwrap();
let mut process: Attempt = load(&attempt.join("attempt.json")).unwrap();
for file in ["src/a.rs", "src/nested/a.rs"] {
run.sources
.insert(file.into(), fs::read_to_string(root.join(file)).unwrap());
process.processes[0]
.lines
.insert(file.into(), BTreeMap::from([(1, 1)]));
}
save(&run_path, &run).unwrap();
save(&attempt.join("attempt.json"), &process).unwrap();
let captured = fs::read(attempt.join("attempt.json")).unwrap();
fs::write(root.join("code.rs"),
"// :::{cite} habeas:coverage\n// Current explanation, added after capture.\n// :::\nfn current() {}\n").unwrap();
populate(&mut book, root).unwrap();
let index = book.chapters().next().unwrap();
let notes_path = super::super::notes::path(index.path.as_ref().unwrap(), "code.rs");
let notes = book
.chapters()
.find(|chapter| chapter.path.as_ref() == Some(¬es_path))
.unwrap();
assert!(
notes
.content
.contains("Current explanation, added after capture.")
);
assert!(notes.content.contains("Current workspace source notes"));
assert!(notes.content.contains("code.rs"));
assert_eq!(
book.chapters()
.filter(|chapter| chapter.path.as_ref() == Some(¬es_path))
.count(),
1
);
let mut distinct = BTreeSet::new();
for file in ["code.rs", "src/a.rs", "src/nested/a.rs"] {
let path = super::super::notes::path(index.path.as_ref().unwrap(), file);
assert!(
distinct.insert(path.clone()),
"files must have distinct views"
);
let notes = book
.chapters()
.find(|chapter| chapter.path.as_ref() == Some(&path))
.unwrap();
assert!(
notes
.content
.contains(&format!("File: <code>{file}</code>"))
);
assert!(index.content.contains("Coverage unavailable"));
}
assert_eq!(fs::read(attempt.join("attempt.json")).unwrap(), captured);
assert_eq!(
fs::read_to_string(attempt.join("1-1.profraw")).unwrap(),
"retained profile fixture"
);
assert!(!root.join("evidence").exists());
}
Input 5: outline src/execution_coverage/notes.rs mod[tests]/fn[each_render_reads_current_notes_and_validates_saved_reviews_without_writing]
- File:
src/execution_coverage/notes.rs - Selector:
mod[tests]/fn[each_render_reads_current_notes_and_validates_saved_reviews_without_writing] - Kind:
fn src/execution_coverage/notes.rs:495–523
// {test}`requirements.test-coverage.index.file_map.notes.current`
// {test}`requirements.test-coverage.index.file_map.notes.render_only`
#[test]
fn each_render_reads_current_notes_and_validates_saved_reviews_without_writing() {
let source = "// :::{cite} habeas:coverage\n// Original platform explanation.\n// :::\nfn other() {}\n";
let temp = fixture(source);
let reviews = write_reviews(temp.path(), true);
let saved_review = fs::read(&reviews[0]).unwrap();
assert!(render(temp.path()).contains("current and accepted"));
fs::write(
temp.path().join("code.rs"),
source.replace("Original platform", "Updated platform"),
)
.unwrap();
let content = render(temp.path());
assert!(content.contains("Updated platform explanation."));
assert!(
!content
.split("Review:")
.next()
.unwrap()
.contains("Original platform explanation.")
);
assert!(content.contains("Current workspace source notes"));
assert!(content.contains("Review: **not accepted**"));
assert!(content.contains("citations changed"));
assert_eq!(fs::read(&reviews[0]).unwrap(), saved_review);
assert!(!temp.path().join("target").exists());
}
Referenced definitions
Input 2: requirements selection requirements.test-coverage.index.file_map.notes
requirements.test-coverage.index.file_map.notes:md/requirements/test-coverage.md:312–316
:::{req} index.file_map.notes
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.
:::
Input 3: requirements selection requirements.test-coverage.index.render_only
requirements.test-coverage.index.render_only:md/requirements/test-coverage.md:495–497
:::{req} index.render_only
Building the book MUST NOT run tests or collect coverage.
:::
Other sources
Input 1: requirements selection requirements.test-coverage.index.file_map.notes.render_only
requirements.test-coverage.index.file_map.notes.render_only:md/requirements/test-coverage.md:361–366
:::{req} index.file_map.notes.render_only
Rendering the view of
{cite}`requirements.test-coverage.index.file_map.notes` MUST NOT invoke an
assessment model. It MUST follow
{cite}`requirements.test-coverage.index.render_only`.
:::