requirements.authoring.progress
Requirements index · View definition
Requirement
When stderr is an interactive terminal,
habeas author --allMUST display an updating progress bar with elapsed time, percentage, finished and total assessment counts, active and queued counts, and separate counts fortrue,false,FIXME, and authoring errors. The total MUST count only subjects selected for assessment; current accepted records remain in the unchanged count. A finished assessment MUST advance progress whether it writes a judgment or reports an authoring error. Progress measures completed work, not satisfaction of requirements.Inspection MUST also show a progress bar for each phase with a known amount of work, including evidence files, reference source files and coverage, Rust function coverage, and assessment selection. The display MUST label the current phase and show its completed and total checks; its percentage measures that phase’s checks, not estimated time or overall inspection completion. Discovery and other phases whose totals are not yet known MUST use an indeterminate activity display. Inspection progress MUST NOT change validation results or invoke inference. Enabled reports MUST remain readable alongside progress. An interrupted batch MUST retain its actual progress without counting unstarted assessments as finished. Empty batches and early errors MUST clear the temporary display. When stderr is redirected or
TERM=dumb, the command MUST retain its plain line-oriented reports without terminal control sequences.NO_COLORMUST disable color without disabling progress on a supported terminal. The existing stdout completion summary and exit-status rules MUST remain unchanged.![]()
Rationale
The reviewed tests cover each obligation in requirements.authoring.progress and assert its outcome.
Interactive batch progress is covered by tests/authoring_batch.rs#fn[terminal_progress_distinguishes_judgments_from_authoring_errors]. It runs under a PTY with NO_COLOR and CLICOLOR_FORCE set. It checks these things:
- the bar redraws, and no color escape sequences appear;
- the elapsed
[hh:mm:ss]time and100%appear; 6/6 finished,N activeandN queuedappear;- the final line shows
true 3,false 1,FIXME 1anderrors 1, with0 activeand0 queued; - the finished count reaches 6/6 even though one assessment ended in an authoring error;
- the stdout summary and the nonzero exit status are unchanged.
Total counts only selected subjects. fn[batch_fills_evidence_preserves_current_records_and_reauthors_only_changed_inputs] runs a no-op batch under a PTY. It asserts that no 0/0 finished display appears and that stdout reads 0 authored; 6 skipped as current; 0 failed. In the later run, with one changed input, it asserts 1/1 finished and not 6/6 finished. It also asserts the stdout summary 1 authored; 5 skipped as current. This checks both the total and the unchanged count.
Per-phase inspection progress
src/evidence.rs#fn[inspection_progress_preserves_validation_and_finishes_each_phase]checks counted phases forevidence files,reference source filesandreference coverage. Each phase’s completed counts run 0..=total with a stable total.- The same test shows an indeterminate update (
totalisNone) exists. It also compares reports, errors, discovery errors and definitions against plaininspect_repository, in both a valid and an invalid project. This covers “MUST NOT change validation results”. fn[citation_review_validation_reports_counted_progress]andsrc/sites.rs#fn[site_review_validation_reports_counted_progress]cover the citation-review and site-review phases.fn[inspection_progress_reports_empty_phases_as_complete]covers empty phases.src/rust_coverage.rs#fn[rust_function_coverage_reports_counted_progress_per_file]covers the Rust function coverage phase.src/authoring/batch.rs#fn[selection_counts_definitions_and_citation_reviews_in_one_phase]covers the assessment selection phase.- The phase label and the per-phase “completed/total” display are asserted in
src/authoring/progress.rs#fn[inspection_displays_counts_when_same_phase_discovers_its_total]. It checksPhase: Rust function coverageand50% 2/4. In the discovery state it asserts there is no%, which covers the indeterminate display. fn[percentage_does_not_round_unfinished_work_up_to_one_hundred]checks the percentage values. The PTY test also checks that anInspecting evidenceline shows%and a count.- Inference is not invoked: the server request count equals the 6 selected subjects.
Reports readable alongside progress. fn[verbose_false_rationale_is_readable_above_terminal_progress] runs -v under a PTY. It checks that the false line and rationale are visible and that true lines are absent. It also checks 6/6 finished and the stdout summary.
Interruption. fn[interrupted_terminal_progress_keeps_unstarted_work_incomplete] calls assert_interruption_stops_the_batch with concurrency 2 and 1. The final screen shows Stopped, {started}/6 finished, errors {concurrency}, 0 active and {remaining} queued. It has no 100% and no 6/6 finished. Only one evidence file is written, and the number of assessments not started is reported.
Empty batches and early errors. fn[empty_batches_and_early_errors_clear_the_terminal_display] covers the empty, configuration-error and discovery-error cases. In each, Phase: appears in the raw output. The final screen contains none of Phase:, Inspecting or finished. The error stays visible in the two error cases.
Redirected output and TERM=dumb.
fn[failed_assessment_keeps_other_results_and_reports_failure]asserts no\x1band no\ron redirected stderr.fn[dumb_terminal_keeps_plain_batch_diagnostics]asserts no\x1band no6/6 finisheddisplay underTERM=dumb. It checks the plain “Authoring 6 assessments…” line and the unchanged stdout summary.fn[batch_reports_false_rationales_only_when_verbose]also asserts there are no escape sequences on redirected stderr.
NO_COLOR. The terminal-progress test sets NO_COLOR together with CLICOLOR_FORCE and asserts there are no SGR color sequences. The same run still shows redraws and counts, so progress stays enabled.
I found no untested obligation and no assertion that contradicts the requirement text.
Inputs
Tests
Input 4: outline src/authoring/batch.rs mod[tests]/fn[selection_counts_definitions_and_citation_reviews_in_one_phase]
- File:
src/authoring/batch.rs - Selector:
mod[tests]/fn[selection_counts_definitions_and_citation_reviews_in_one_phase] - Kind:
fn src/authoring/batch.rs:694–750
// {test}`requirements.authoring.progress`
// {test}`requirements.authoring.batch`
#[test]
fn selection_counts_definitions_and_citation_reviews_in_one_phase() {
let temp = tempfile::tempdir().unwrap();
let root = temp.path();
fs::create_dir_all(root.join("md")).unwrap();
fs::create_dir_all(root.join("src")).unwrap();
fs::write(root.join("book.toml"), "[book]\nsrc = \"md\"\n").unwrap();
fs::write(
root.join("md/requirements.md"),
":::{req} ready\nReady.\n:::\n",
)
.unwrap();
let cite = "{cite}`requirements.ready`".to_owned();
fs::write(
root.join("src/main.rs"),
format!("// {cite}\nfn one() {{}}\n// {cite}\nfn two() {{}}\n"),
)
.unwrap();
let inspection = crate::evidence::inspect_repository(root).unwrap();
let mut updates = Vec::new();
let (subjects, unchanged) =
select_subjects(root, &inspection, None, false, &mut |update| {
updates.push(update)
});
assert_eq!(unchanged, 0);
assert_eq!(
subjects
.iter()
.map(AuthoringSubject::label)
.collect::<Vec<_>>(),
[
"requirements.ready",
"citations:src/main.rs#fn[one]",
"citations:src/main.rs#fn[two]"
]
);
assert!(
updates
.iter()
.all(|update| update.stage == "selecting assessments")
);
assert_eq!(
updates
.iter()
.map(|update| (update.completed, update.total))
.collect::<Vec<_>>(),
[
(0, None),
(0, Some(3)),
(1, Some(3)),
(2, Some(3)),
(3, Some(3))
]
);
}
Input 5: outline src/authoring/progress.rs mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[width]
- File:
src/authoring/progress.rs - Selector:
mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[width] - Kind:
fn src/authoring/progress.rs:200–203
// {test}`requirements.authoring.progress`
fn width(&self) -> u16 {
100
}
Input 6: outline src/authoring/progress.rs mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[move_cursor_up]
- File:
src/authoring/progress.rs - Selector:
mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[move_cursor_up] - Kind:
fn src/authoring/progress.rs:205–208
// {test}`requirements.authoring.progress`
fn move_cursor_up(&self, _lines: usize) -> io::Result<()> {
Ok(())
}
Input 7: outline src/authoring/progress.rs mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[move_cursor_down]
- File:
src/authoring/progress.rs - Selector:
mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[move_cursor_down] - Kind:
fn src/authoring/progress.rs:210–213
// {test}`requirements.authoring.progress`
fn move_cursor_down(&self, _lines: usize) -> io::Result<()> {
Ok(())
}
Input 8: outline src/authoring/progress.rs mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[write_line]
- File:
src/authoring/progress.rs - Selector:
mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[write_line] - Kind:
fn src/authoring/progress.rs:235–239
// {test}`requirements.authoring.progress`
fn write_line(&self, text: &str) -> io::Result<()> {
self.0.lock().unwrap().push_str(&format!("{text}\n"));
Ok(())
}
Input 9: outline src/authoring/progress.rs mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[write_str]
- File:
src/authoring/progress.rs - Selector:
mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[write_str] - Kind:
fn src/authoring/progress.rs:241–245
// {test}`requirements.authoring.progress`
fn write_str(&self, text: &str) -> io::Result<()> {
self.0.lock().unwrap().push_str(text);
Ok(())
}
Input 10: outline src/authoring/progress.rs mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[clear_line]
- File:
src/authoring/progress.rs - Selector:
mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[clear_line] - Kind:
fn src/authoring/progress.rs:247–250
// {test}`requirements.authoring.progress`
fn clear_line(&self) -> io::Result<()> {
Ok(())
}
Input 11: outline src/authoring/progress.rs mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[flush]
- File:
src/authoring/progress.rs - Selector:
mod[tests]/impl[RecordingTerm/indicatif::TermLike]/fn[flush] - Kind:
fn src/authoring/progress.rs:252–255
// {test}`requirements.authoring.progress`
fn flush(&self) -> io::Result<()> {
Ok(())
}
Input 12: outline src/authoring/progress.rs mod[tests]/fn[inspection_displays_counts_when_same_phase_discovers_its_total]
- File:
src/authoring/progress.rs - Selector:
mod[tests]/fn[inspection_displays_counts_when_same_phase_discovers_its_total] - Kind:
fn src/authoring/progress.rs:258–292
// {test}`requirements.authoring.progress`
#[test]
fn inspection_displays_counts_when_same_phase_discovers_its_total() {
let terminal = RecordingTerm::default();
let bar = ProgressBar::with_draw_target(
None,
ProgressDrawTarget::term_like(Box::new(terminal.clone())),
);
let mut progress = BatchProgress {
bar: Some(bar),
inspection_stage: None,
verbose: false,
positive: 0,
negative: 0,
fixme: 0,
errors: 0,
};
progress.inspect(InspectionProgress {
stage: "Rust function coverage",
completed: 0,
total: None,
});
let discovery = std::mem::take(&mut *terminal.0.lock().unwrap());
assert!(discovery.contains("Phase: Rust function coverage"));
assert!(!discovery.contains('%'), "{discovery}");
progress.inspect(InspectionProgress {
stage: "Rust function coverage",
completed: 2,
total: Some(4),
});
let counted = std::mem::take(&mut *terminal.0.lock().unwrap());
assert!(counted.contains("Phase: Rust function coverage"));
assert!(counted.contains("50% 2/4"), "{counted}");
}
Input 13: outline src/authoring/progress.rs mod[tests]/fn[percentage_does_not_round_unfinished_work_up_to_one_hundred]
- File:
src/authoring/progress.rs - Selector:
mod[tests]/fn[percentage_does_not_round_unfinished_work_up_to_one_hundred] - Kind:
fn src/authoring/progress.rs:294–305
// {test}`requirements.authoring.progress`
#[test]
fn percentage_does_not_round_unfinished_work_up_to_one_hundred() {
let bar = ProgressBar::hidden();
bar.set_length(200);
for (position, expected) in [(0, "0"), (1, "0"), (199, "99"), (200, "100")] {
bar.set_position(position);
let mut output = String::new();
bar.update(|state| write_percentage(state, &mut output));
assert_eq!(output, expected);
}
}
Input 14: outline src/evidence.rs mod[tests]/fn[inspection_progress_preserves_validation_and_finishes_each_phase]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[inspection_progress_preserves_validation_and_finishes_each_phase] - Kind:
fn src/evidence.rs:2309–2407
// {test}`requirements.authoring.progress`
// {test}`requirements.integration.report_api`
// {test}`requirements.ci.errors`
#[test]
fn inspection_progress_preserves_validation_and_finishes_each_phase() {
let temp = fixture();
let root = temp.path();
fs::write(
root.join("md/requirements.md"),
":::{req} ready\nThe check MUST pass.\n:::\n",
)
.unwrap();
fs::write(
root.join("evidence/requirements.ready.json"),
json!({
"requirement": "The check MUST pass.",
"determination": true,
"rationale": "The inspected file has the expected lines.",
"inputs": [outline(root, "src/main.rs", "")]
})
.to_string(),
)
.unwrap();
for invalid in [false, true] {
if invalid {
fs::write(root.join("evidence/broken.json"), "{").unwrap();
fs::write(root.join("src/broken.rs"), "fn {").unwrap();
fs::write(root.join("src/lib.rs"), "fn retained() {}\n").unwrap();
fs::write(root.join("src/binary.dat"), [0xff]).unwrap();
}
stamp_reference_sets(root);
let expected = super::inspect_repository(root).unwrap();
let mut updates = Vec::new();
let inspected =
super::inspect_repository_with_progress(root, |update| updates.push(update))
.unwrap();
assert_eq!(inspected.report.requirements, expected.report.requirements);
assert_eq!(inspected.report.examples, expected.report.examples);
assert_eq!(
inspected.report.evidence_files,
expected.report.evidence_files
);
assert_eq!(inspected.report.errors, expected.report.errors);
assert_eq!(inspected.discovery_errors, expected.discovery_errors);
assert_eq!(
inspected.definitions.keys().collect::<Vec<_>>(),
expected.definitions.keys().collect::<Vec<_>>()
);
assert_eq!(inspected.report.requirements, 1);
assert_eq!(inspected.report.examples, 0);
if invalid {
let errors = inspected.report.errors.join("\n");
for error in ["invalid JSON", "cannot parse Rust source"] {
assert!(errors.contains(error), "missing {error:?}: {errors}");
}
// An uncovered item is reported, not a validation error.
assert!(!errors.contains("retained"), "{errors}");
assert!(
inspected.uncovered.iter().any(|item| item
.error
.starts_with("src/lib.rs:1: function retained has no recent coverage")),
"{:?}",
inspected.uncovered
);
let discovery = inspected.discovery_errors.join("\n");
assert!(
discovery.contains("src/broken.rs")
&& discovery.contains("cannot parse Rust source"),
"{discovery}"
);
assert!(!discovery.contains("retained"), "{discovery}");
} else {
assert!(inspected.report.errors.is_empty());
}
assert!(updates.iter().any(|update| update.total.is_none()));
assert!(updates.iter().all(|update| {
update
.total
.map_or(update.completed == 0, |total| update.completed <= total)
}));
let expected_counts = [
("evidence files", if invalid { 2 } else { 1 }),
("reference source files", if invalid { 8 } else { 5 }),
("reference coverage", 1),
];
for (stage, total) in expected_counts {
let completed: Vec<_> = updates
.iter()
.filter(|update| update.stage == stage && update.total.is_some())
.map(|update| {
assert_eq!(update.total, Some(total), "{stage}");
update.completed
})
.collect();
assert_eq!(completed, (0..=total).collect::<Vec<_>>(), "{stage}");
}
}
}
Input 15: outline src/evidence.rs mod[tests]/fn[citation_review_validation_reports_counted_progress]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[citation_review_validation_reports_counted_progress] - Kind:
fn src/evidence.rs:2409–2450
// {test}`requirements.authoring.progress`
#[test]
fn citation_review_validation_reports_counted_progress() {
let temp = fixture();
let root = temp.path();
fs::write(
root.join("md/requirements.md"),
":::{req} ready\nReady.\n:::\n",
)
.unwrap();
let cite = "{cite}`requirements.ready`".to_owned();
fs::write(
root.join("src/main.rs"),
format!("// {cite}\nfn one() {{}}\n// {cite}\nfn two() {{}}\n"),
)
.unwrap();
fs::create_dir_all(root.join("evidence/citations/src")).unwrap();
fs::write(root.join("evidence/citations/src/gone.json"), "{}").unwrap();
let mut updates = Vec::new();
let inspected =
super::inspect_repository_with_progress(root, |update| updates.push(update)).unwrap();
assert_eq!(
inspected.report.errors,
super::inspect_repository(root).unwrap().report.errors
);
let phase: Vec<_> = updates
.iter()
.filter(|update| update.stage == "citation reviews")
.map(|update| (update.completed, update.total))
.collect();
// Discovery first, then two items and one orphaned review file.
assert_eq!(
phase,
[
(0, None),
(0, Some(3)),
(1, Some(3)),
(2, Some(3)),
(3, Some(3))
]
);
}
Input 16: outline src/evidence.rs mod[tests]/fn[inspection_progress_reports_empty_phases_as_complete]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[inspection_progress_reports_empty_phases_as_complete] - Kind:
fn src/evidence.rs:2452–2477
// {test}`requirements.authoring.progress`
#[test]
fn inspection_progress_reports_empty_phases_as_complete() {
let temp = TempDir::new().unwrap();
fs::create_dir(temp.path().join("md")).unwrap();
fs::write(temp.path().join("Cargo.toml"), "[workspace]\n").unwrap();
fs::write(temp.path().join("book.toml"), "[book]\nsrc = 'md'\n").unwrap();
let (path, source) = crate::execution_coverage::configure(temp.path()).unwrap();
fs::create_dir_all(path.parent().unwrap()).unwrap();
fs::write(path, source).unwrap();
let mut updates = Vec::new();
let inspected =
super::inspect_repository_with_progress(temp.path(), |update| updates.push(update))
.unwrap();
assert!(inspected.report.errors.is_empty());
for stage in ["evidence files", "reference coverage", "citation reviews"] {
assert!(
updates.contains(&super::InspectionProgress {
stage,
completed: 0,
total: Some(0),
}),
"{stage}: {updates:?}"
);
}
}
Input 17: outline src/rust_coverage.rs mod[tests]/fn[rust_function_coverage_reports_counted_progress_per_file]
- File:
src/rust_coverage.rs - Selector:
mod[tests]/fn[rust_function_coverage_reports_counted_progress_per_file] - Kind:
fn src/rust_coverage.rs:1107–1136
// {test}`requirements.authoring.progress`
#[test]
fn rust_function_coverage_reports_counted_progress_per_file() {
let project = TempDir::new().unwrap();
fs::create_dir_all(project.path().join("src")).unwrap();
for name in ["a", "b", "c"] {
fs::write(project.path().join(format!("src/{name}.rs")), "").unwrap();
}
let mut updates = Vec::new();
validate_rust_functions(
project.path(),
&crate::evidence::discovered_files(project.path(), &mut Vec::new()),
&definitions(),
&super::EvidenceReads::default(),
&mut Vec::new(),
&mut Vec::new(),
&mut |update| updates.push((update.stage, update.completed, update.total)),
);
let stage = "Rust function coverage";
assert_eq!(
updates,
[
(stage, 0, None),
(stage, 0, Some(3)),
(stage, 1, Some(3)),
(stage, 2, Some(3)),
(stage, 3, Some(3)),
]
);
}
Input 18: outline src/sites.rs mod[tests]/fn[site_review_validation_reports_counted_progress]
- File:
src/sites.rs - Selector:
mod[tests]/fn[site_review_validation_reports_counted_progress] - Kind:
fn src/sites.rs:1363–1396
// {test}`requirements.authoring.progress`
#[test]
fn site_review_validation_reports_counted_progress() {
let temp = project(RULE, SOURCE);
let root = temp.path();
write_review(root, "fn[other]", json!({}));
let mut updates = Vec::new();
let inspected =
crate::evidence::inspect_repository_with_progress(root, |update| updates.push(update))
.unwrap();
assert_eq!(
inspected.report.errors,
crate::evidence::inspect_repository(root)
.unwrap()
.report
.errors
);
let phase: Vec<_> = updates
.iter()
.filter(|update| update.stage == "site reviews")
.map(|update| (update.completed, update.total))
.collect();
// Three sites, then one orphaned review file.
assert_eq!(
phase,
[
(0, Some(4)),
(1, Some(4)),
(2, Some(4)),
(3, Some(4)),
(4, Some(4))
]
);
}
Input 19: outline tests/authoring_batch.rs fn[batch_fills_evidence_preserves_current_records_and_reauthors_only_changed_inputs]
- File:
tests/authoring_batch.rs - Selector:
fn[batch_fills_evidence_preserves_current_records_and_reauthors_only_changed_inputs] - Kind:
fn tests/authoring_batch.rs:531–686
// {test}`requirements.authoring.batch`
// {test}`requirements.authoring.concurrency`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.ci.determination`
// {test}`requirements.authoring.progress`
// {test}`requirements.configuration.loading`
// {test}`requirements.authoring.configuration`
// {test}`requirements.authoring.refresh`
// {test}`requirements.authoring.persistence`
#[test]
fn batch_fills_evidence_preserves_current_records_and_reauthors_only_changed_inputs() {
let server = Server::start(true, None);
let fixture = Fixture::new(&server.endpoint, Some(2));
let source = fixture.project.join("src/lib.rs");
fs::write(
&source,
format!(
"{}\n// {{test}}`requirements.alpha`\n#[test]\nfn alpha_requirement() {{ assert_eq!(alpha(), 1); }}\n",
fs::read_to_string(&source).unwrap().replace(
"pub fn beta()",
"// :::{fixme} requirements.beta\n// :github: example/app#123\n// Beta has no test yet.\n// :::\npub fn beta()",
)
),
)
.unwrap();
let output = fixture.run(&["author", "--all", "--config", "mock"]);
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
assert_eq!(server.subjects().len(), 6);
let report = habeas::validate_repository(&fixture.project).unwrap();
assert!(report.errors.is_empty(), "{:?}", report.errors);
assert!(!fixture.project.join("evidence/rust").exists());
let mut beta = fixture.evidence("requirements.beta");
beta["determination"] = json!({"FIXME":["example/app#123"]});
beta["rationale"] = "The source explicitly acknowledges the missing beta test.".into();
fs::write(
fixture.project.join("evidence/requirements.beta.json"),
serde_json::to_vec_pretty(&beta).unwrap(),
)
.unwrap();
let example = fixture.evidence("requirements.alpha_case");
let gamma = fixture.evidence("requirements.gamma");
let gamma_case = fixture.evidence("requirements.gamma_case");
for (record, name) in [(&example, "alpha_case"), (&gamma_case, "gamma_case")] {
assert!(record.get("requirement").is_none(), "{record}");
assert!(
record["example"]
.as_str()
.unwrap()
.contains(name.split('_').next().unwrap()),
"{record}"
);
}
let usage = fixture.usage();
assert_eq!(usage.len(), 6);
assert!(
usage
.iter()
.all(|run| run["outcome"] == "completed" && run["evidence_written"] == true)
);
{
let requests = server.requests.0.lock().unwrap();
assert_eq!(
requests.peak, 2,
"the configured concurrency bounds in-flight requests"
);
assert!(
requests.first_pair_overlapped,
"a second assessment must start before the first model response"
);
}
fs::write(&fixture.config, "invalid TOML [").unwrap();
let no_op = fixture.run(&["author", "--all"]);
assert!(
no_op.status.success(),
"{}",
String::from_utf8_lossy(&no_op.stderr)
);
fs::remove_file(&fixture.config).unwrap();
let no_config = fixture.run(&["author", "--all"]);
assert!(
no_config.status.success(),
"{}",
String::from_utf8_lossy(&no_config.stderr)
);
#[cfg(unix)]
{
let no_op_terminal = fixture.run_in_pty(false, "xterm-256color");
assert!(
no_op_terminal.status.success(),
"{}",
String::from_utf8_lossy(&no_op_terminal.stderr)
);
assert_eq!(
String::from_utf8_lossy(&no_op_terminal.stdout).trim(),
"0 authored; 6 skipped as current; 0 failed"
);
assert!(!String::from_utf8_lossy(&no_op_terminal.stderr).contains("0/0 finished"));
}
assert_eq!(server.subjects().len(), 6);
assert_eq!(fixture.usage().len(), 6);
fs::write(&fixture.config, &fixture.config_text).unwrap();
let changed = fs::read_to_string(&source)
.unwrap()
.replace("-> u8 { 1 }", "-> u8 { 1_u8 }");
fs::write(&source, changed).unwrap();
let unread_change = fixture.run(&["author", "--all"]);
assert!(unread_change.status.success(), "{unread_change:?}");
assert_eq!(server.subjects().len(), 6);
fs::write(
&source,
fs::read_to_string(&source).unwrap().replace(
"fn alpha_requirement() { assert_eq!(alpha(), 1); }",
"fn alpha_requirement() { assert_eq!(alpha(), 1_u8); }",
),
)
.unwrap();
#[cfg(unix)]
let updated = fixture.run_in_pty(false, "xterm-256color");
#[cfg(not(unix))]
let updated = fixture.run(&["author", "--all"]);
#[cfg(unix)]
{
let escape = regex::Regex::new(r"\x1b\[[0-?]*[ -/]*[@-~]").unwrap();
let raw = String::from_utf8_lossy(&updated.stderr);
let plain = escape.replace_all(&raw, "");
assert!(plain.contains("1/1 finished"), "{plain}");
assert!(!plain.contains("6/6 finished"), "{plain}");
}
assert!(
updated.status.success(),
"{}",
String::from_utf8_lossy(&updated.stderr)
);
assert_eq!(server.subjects().len(), 7);
assert_eq!(
server.subjects().last().unwrap(),
"requirement requirements.alpha"
);
assert_eq!(fixture.usage().len(), 7);
assert_eq!(
String::from_utf8_lossy(&updated.stdout).trim(),
"1 authored; 5 skipped as current; 0 failed; policy once"
);
assert_eq!(fixture.evidence("requirements.beta"), beta);
assert_eq!(fixture.evidence("requirements.alpha_case"), example);
assert_eq!(fixture.evidence("requirements.gamma"), gamma);
assert_eq!(fixture.evidence("requirements.gamma_case"), gamma_case);
let report = habeas::validate_repository(&fixture.project).unwrap();
assert!(report.errors.is_empty(), "{:?}", report.errors);
}
Input 20: outline tests/authoring_batch.rs fn[failed_assessment_keeps_other_results_and_reports_failure]
- File:
tests/authoring_batch.rs - Selector:
fn[failed_assessment_keeps_other_results_and_reports_failure] - Kind:
fn tests/authoring_batch.rs:804–859
// {test}`requirements.authoring.concurrency`
// {test}`requirements.authoring.batch`
// {test}`requirements.authoring.reporting`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.authoring.progress`
#[test]
fn failed_assessment_keeps_other_results_and_reports_failure() {
let server = Server::start(true, Some("requirement requirements.alpha"));
let fixture = Fixture::new(&server.endpoint, Some(2));
let output = fixture.run(&["author", "--all"]);
assert!(!output.stderr.contains(&b'\x1b'));
assert!(!output.stderr.contains(&b'\r'));
assert!(!output.status.success());
assert_eq!(server.subjects().len(), 6);
assert!(
!fixture
.project
.join("evidence/requirements.alpha.json")
.exists()
);
assert_eq!(fixture.evidence("requirements.beta")["determination"], true);
assert_eq!(
fixture.evidence("requirements.alpha_case")["determination"],
true
);
assert_eq!(
fixture.evidence("requirements.gamma")["determination"],
true
);
let usage = fixture.usage();
assert_eq!(usage.len(), 6);
assert_eq!(
usage
.iter()
.filter(|run| run["outcome"] == "failed")
.count(),
1
);
assert_eq!(
usage
.iter()
.filter(|run| run["outcome"] == "completed")
.count(),
5
);
let diagnostics = format!(
"{}{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
assert!(diagnostics.contains("requirements.alpha"), "{diagnostics}");
assert!(
diagnostics.contains("fixture model rejected"),
"{diagnostics}"
);
}
Input 21: outline tests/authoring_batch.rs fn[terminal_progress_distinguishes_judgments_from_authoring_errors]
- File:
tests/authoring_batch.rs - Selector:
fn[terminal_progress_distinguishes_judgments_from_authoring_errors] - Kind:
fn tests/authoring_batch.rs:861–953
// {test}`requirements.authoring.progress`
// {test}`requirements.authoring.persistence`
// {test}`requirements.authoring.batch`
// {test}`requirements.authoring.reporting`
#[cfg(unix)]
#[test]
fn terminal_progress_distinguishes_judgments_from_authoring_errors() {
let server = Server::start_with(true, Behavior::MixedJudgments);
let fixture = Fixture::new(&server.endpoint, Some(2));
let output = fixture.run_in_pty(false, "xterm-256color");
assert!(!output.status.success(), "{output:?}");
assert_eq!(server.subjects().len(), 6);
let terminal = String::from_utf8_lossy(&output.stderr);
assert!(terminal.contains('\x1b'), "no terminal redraw: {terminal}");
assert!(
!regex::Regex::new(r"\x1b\[[0-9;]*m")
.unwrap()
.is_match(&terminal),
"NO_COLOR must override forced color: {terminal}"
);
let escape = regex::Regex::new(r"\x1b\[[0-?]*[ -/]*[@-~]").unwrap();
let plain = escape.replace_all(&terminal, "");
let counted_progress = regex::Regex::new(r"\b[0-9]+/[1-9][0-9]*\b").unwrap();
assert!(
plain.split(['\r', '\n']).any(|line| {
line.contains("Inspecting evidence")
&& line.contains('%')
&& counted_progress.is_match(line)
}),
"inspection must show counted progress before authoring: {plain}"
);
assert!(plain.contains("100%"), "{plain}");
assert!(plain.contains("6/6 finished"), "{plain}");
assert!(
regex::Regex::new(r"\b[1-9][0-9]* active\b")
.unwrap()
.is_match(&plain),
"{plain}"
);
assert!(
regex::Regex::new(r"\b[1-9][0-9]* queued\b")
.unwrap()
.is_match(&plain),
"{plain}"
);
let elapsed = regex::Regex::new(r"\[\d{2}:\d{2}:\d{2}\]").unwrap();
assert!(
plain
.split(['\r', '\n'])
.any(|line| line.contains("Authoring") && elapsed.is_match(line)),
"{plain}"
);
assert!(plain.contains("Finished"), "{plain}");
let final_counts = plain
.split(['\r', '\n'])
.rfind(|line| line.contains("true ") && line.contains("errors "))
.expect("final outcome counts in the terminal progress display");
assert!(
!final_counts.contains("Error:"),
"the final progress line must end before command diagnostics: {final_counts}"
);
for count in [
"true 3", "false 1", "FIXME 1", "errors 1", "0 active", "0 queued",
] {
assert!(
final_counts.contains(count),
"missing {count}: {final_counts}"
);
}
assert!(plain.contains("fixture model rejected"), "{plain}");
assert!(!plain.contains(": true (usage:"), "{plain}");
assert!(
plain.contains("requirements.alpha: false (usage:"),
"{plain}"
);
assert!(!plain.contains("Fixture judgment for"), "{plain}");
assert!(!plain.contains("Fixture false rationale"), "{plain}");
assert!(plain.contains("requirements.beta: FIXME"), "{plain}");
let stdout = String::from_utf8_lossy(&output.stdout);
assert_eq!(
stdout.trim(),
"5 authored; 0 skipped as current; 1 failed; policy once"
);
assert_eq!(
fixture.evidence("requirements.alpha")["determination"],
false
);
assert_eq!(
fixture.evidence("requirements.beta")["determination"],
json!({"FIXME": ["#123"]})
);
}
Input 22: outline tests/authoring_batch.rs fn[batch_reports_false_rationales_only_when_verbose]
- File:
tests/authoring_batch.rs - Selector:
fn[batch_reports_false_rationales_only_when_verbose] - Kind:
fn tests/authoring_batch.rs:955–1002
// {test}`requirements.authoring.reporting`
// {test}`requirements.authoring.progress`
// {test}`requirements.authoring.batch`
#[test]
fn batch_reports_false_rationales_only_when_verbose() {
for verbose in [false, true] {
let server = Server::start_with(true, Behavior::MixedJudgments);
let fixture = Fixture::new(&server.endpoint, Some(2));
let args = if verbose {
vec!["author", "--all", "--verbose"]
} else {
vec!["author", "--all"]
};
let output = fixture.run(&args);
assert!(!output.status.success(), "{output:?}");
assert_eq!(server.subjects().len(), 6);
let diagnostics = String::from_utf8_lossy(&output.stderr);
assert!(!diagnostics.contains('\x1b'), "{diagnostics}");
assert!(!diagnostics.contains(": true (usage:"), "{diagnostics}");
assert!(
diagnostics.contains("requirements.alpha: false (usage:"),
"{diagnostics}"
);
let rationale = fixture.evidence("requirements.alpha")["rationale"]
.as_str()
.unwrap()
.to_owned();
assert_eq!(diagnostics.contains(&rationale), verbose, "{diagnostics}");
assert!(
diagnostics.contains("requirements.beta: FIXME"),
"{diagnostics}"
);
assert!(
diagnostics.contains("fixture model rejected"),
"{diagnostics}"
);
assert!(!diagnostics.contains("pub fn alpha()"), "{diagnostics}");
let true_rationale = fixture.evidence("requirements.gamma")["rationale"]
.as_str()
.unwrap()
.to_owned();
assert!(!diagnostics.contains(&true_rationale), "{diagnostics}");
assert_eq!(
String::from_utf8_lossy(&output.stdout).trim(),
"5 authored; 0 skipped as current; 1 failed; policy once"
);
}
}
Input 23: outline tests/authoring_batch.rs fn[verbose_false_rationale_is_readable_above_terminal_progress]
- File:
tests/authoring_batch.rs - Selector:
fn[verbose_false_rationale_is_readable_above_terminal_progress] - Kind:
fn tests/authoring_batch.rs:1004–1030
// {test}`requirements.authoring.reporting`
// {test}`requirements.authoring.progress`
#[cfg(unix)]
#[test]
fn verbose_false_rationale_is_readable_above_terminal_progress() {
let server = Server::start_with(true, Behavior::MixedJudgments);
let fixture = Fixture::new(&server.endpoint, Some(2));
let output = fixture.run_in_pty_with_args(false, "xterm-256color", &["author", "--all", "-v"]);
assert!(!output.status.success(), "{output:?}");
assert_eq!(server.subjects().len(), 6);
let terminal = String::from_utf8_lossy(&output.stderr);
let escape = regex::Regex::new(r"\x1b\[[0-?]*[ -/]*[@-~]").unwrap();
let plain = escape.replace_all(&terminal, "").replace('\r', "");
let rationale = fixture.evidence("requirements.alpha")["rationale"]
.as_str()
.unwrap()
.to_owned();
assert!(plain.contains("requirements.alpha: false"), "{plain}");
assert!(plain.contains(&rationale), "{plain}");
assert!(!plain.contains("pub fn alpha()"), "{plain}");
assert!(!plain.contains(": true (usage:"), "{plain}");
assert!(plain.contains("6/6 finished"), "{plain}");
assert_eq!(
String::from_utf8_lossy(&output.stdout).trim(),
"5 authored; 0 skipped as current; 1 failed; policy once"
);
}
Input 24: outline tests/authoring_batch.rs fn[dumb_terminal_keeps_plain_batch_diagnostics]
- File:
tests/authoring_batch.rs - Selector:
fn[dumb_terminal_keeps_plain_batch_diagnostics] - Kind:
fn tests/authoring_batch.rs:1032–1064
// {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 25: outline tests/authoring_batch.rs fn[interrupted_terminal_progress_keeps_unstarted_work_incomplete]
- File:
tests/authoring_batch.rs - Selector:
fn[interrupted_terminal_progress_keeps_unstarted_work_incomplete] - Kind:
fn tests/authoring_batch.rs:1066–1078
// {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 26: outline tests/authoring_batch.rs fn[empty_batches_and_early_errors_clear_the_terminal_display]
- File:
tests/authoring_batch.rs - Selector:
fn[empty_batches_and_early_errors_clear_the_terminal_display] - Kind:
fn tests/authoring_batch.rs:1731–1767
// {test}`requirements.authoring.progress`
#[cfg(unix)]
#[test]
fn empty_batches_and_early_errors_clear_the_terminal_display() {
for case in ["empty", "configuration error", "discovery error"] {
let fixture = Fixture::new("http://127.0.0.1:9", Some(1));
match case {
"empty" => {
fs::write(fixture.project.join("md/requirements.md"), "").unwrap();
fs::write(fixture.project.join("src/lib.rs"), "").unwrap();
}
"configuration error" => fs::write(&fixture.config, "invalid TOML [").unwrap(),
_ => fs::write(fixture.project.join("src/lib.rs"), "fn broken(").unwrap(),
}
let output = fixture.run_in_pty(false, "xterm-256color");
assert_eq!(
output.status.success(),
case == "empty",
"{case}: {output:?}"
);
let raw = String::from_utf8_lossy(&output.stderr);
assert!(
raw.contains("Phase:"),
"{case}: inspection was displayed: {raw:?}"
);
let screen = final_screen(&output.stderr);
for transient in ["Phase:", "Inspecting", "finished"] {
assert!(
!screen.contains(transient),
"{case}: {transient} left on screen:\n{screen}\nraw: {raw:?}"
);
}
if case != "empty" {
assert!(!screen.is_empty(), "{case}: the error remains visible");
}
}
}
Referenced definitions
Input 2: requirements selection requirements.authoring.batch
requirements.authoring.batch:md/requirements/authoring.md:19–60
:::{req} batch
`habeas author --all [--config <name>] [--missing | --force] [-v|--verbose]` MUST author
the evidence of every current requirement and named example, together with the
reviews {cite}`requirements.references.citation_review` and
{cite}`requirements.references.site_review` include, under
{cite}`requirements.authoring.refresh`.
`--all` MUST be mutually exclusive with a subject name and `--stdout`. It MUST
also delete each orphaned citation review under
{cite}`requirements.references.citation_review` and each orphaned site review
under {cite}`requirements.references.site_review`, and report each deletion; the
deletion MUST NOT require model configuration or credentials.
Failure to discover declarations or to read, scan, or parse project sources MUST report an error,
not a successful empty batch.
Each subject MUST receive an independent assessment with its own prompt, inputs,
judgment, and usage record. The command MUST report aggregate completion and each
authoring error under {cite}`requirements.authoring.reporting`, and retain
successful writes when another assessment fails. It MUST return a nonzero
exit status if any assessment fails. False judgments MUST still be written as
completed assessments; they remain failures under ordinary evidence validation.
A denied mandatory input MUST abort only the affected assessment under
{cite}`requirements.authoring.read_denial.mandatory`. Interruption MUST instead stop the
whole batch: queued assessments MUST NOT start, running assessments MUST be
cancelled, and an assessment whose evidence has not been written when the
interruption is observed MUST NOT begin committing it. After preparing a
temporary evidence file, the harness MUST check interruption again before its
atomic replacement; a replacement already in progress MAY finish. Evidence already written MUST be
retained, and the command MUST report the number of assessments not started as
a batch failure.
The bundled Habeas skills MUST direct the supervising agent to run this command
to create or refresh evidence. They MUST leave judgments, rationales, and input
snapshots to the authoring harness; the supervising agent addresses findings by
changing requirements, source citations, implementation, or tests.
{cite}`requirements.authoring.concurrency`
{cite}`requirements.authoring.usage_storage`
{cite}`requirements.authoring.persistence`
:::
Input 3: requirements selection requirements.authoring.reporting
requirements.authoring.reporting:md/requirements/authoring.md:520–537
:::{req} reporting
By default, authoring MUST suppress per-subject `true` judgment lines and show
each `false` judgment's subject and outcome on stderr, on both terminals and
redirected output. Existing progress counters and completion summaries MUST remain
available; FIXME notices and authoring errors MUST remain visible. Single-subject
authoring MUST retain its subject, backend, model, evidence destination, and
usage-record metadata.
`-v` and `--verbose` MUST additionally show each false judgment's recorded Markdown
rationale on stderr; rationales MUST be omitted by default. This applies to
single-subject and batch authoring. It MUST
NOT print true rationales or append recorded
input snapshots. Reporting MUST use the completed assessment's existing result,
without additional inference. In `--stdout` mode, stdout MUST remain only the
evidence JSON; verbose rationale and other diagnostics MUST go to stderr.
Verbosity MUST NOT change persistence, validation, or exit-status rules.
{cite}`requirements.authoring.invocation` {cite}`requirements.authoring.batch`
:::
Other sources
Input 1: requirements selection requirements.authoring.progress
requirements.authoring.progress:md/requirements/authoring.md:493–518
:::{req} progress
When stderr is an interactive terminal, `habeas author --all` MUST display an
updating progress bar with elapsed time, percentage, finished and total assessment
counts, active and queued counts, and separate counts for `true`, `false`, `FIXME`,
and authoring errors. The total MUST count only subjects selected for assessment;
current accepted records remain in the unchanged count. A finished assessment
MUST advance progress whether it writes a judgment or reports an authoring error.
Progress measures completed work, not satisfaction of requirements.
Inspection MUST also show a progress bar for each phase with a known amount of
work, including evidence files, reference source files and coverage, Rust
function coverage, and assessment selection. The display MUST label the current phase
and show its completed and total checks; its percentage measures that phase's
checks, not estimated time or overall inspection completion. Discovery and other
phases whose totals are not yet known MUST use an indeterminate activity display.
Inspection progress MUST NOT change validation results or invoke inference.
Enabled reports MUST remain readable alongside progress. An
interrupted batch MUST retain its actual progress without counting unstarted
assessments as finished. Empty batches and early errors MUST clear the temporary
display. When stderr is redirected or `TERM=dumb`, the command MUST retain its
plain line-oriented reports without terminal control sequences. `NO_COLOR` MUST
disable color without disabling progress on a supported terminal. The existing
stdout completion summary and exit-status rules MUST remain unchanged.
{cite}`requirements.authoring.batch`
{cite}`requirements.authoring.reporting`
:::
Input 27: outline tests/authoring_batch.rs impl[Fixture]/fn[run_in_pty_with_args]
- File:
tests/authoring_batch.rs - Selector:
impl[Fixture]/fn[run_in_pty_with_args] - Kind:
fn tests/authoring_batch.rs:429–507
// {cite}`habeas:util`
#[cfg(unix)]
fn run_in_pty_with_args(&self, interrupt: bool, term: &str, args: &[&str]) -> Output {
// Keep stdout piped: the bar belongs to stderr and must detect that
// terminal independently. Python's stdlib provides a portable Unix PTY.
let script = r#"
import errno
import fcntl
import os
import pty
import re
import select
import signal
import struct
import subprocess
import sys
import termios
import time
master, slave = pty.openpty()
fcntl.ioctl(slave, termios.TIOCSWINSZ, struct.pack('HHHH', 24, 160, 0, 0))
process = subprocess.Popen(
[sys.argv[1], *sys.argv[3:]],
stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=slave,
)
os.close(slave)
captured = bytearray()
interrupted = False
deadline = time.monotonic() + 20
try:
while True:
if time.monotonic() >= deadline:
raise RuntimeError('habeas PTY test did not finish within 20 seconds')
readable, _, _ = select.select([master], [], [], 0.1)
if not readable:
continue
try:
chunk = os.read(master, 65536)
except OSError as error:
if error.errno == errno.EIO:
break
raise
if not chunk:
break
captured.extend(chunk)
plain = re.sub(rb'\x1b\[[0-?]*[ -/]*[@-~]', b'', captured)
if sys.argv[2] == 'interrupt' and not interrupted and re.search(rb'Authoring[^\r\n]*\b[1-5]/6 finished\b', plain):
process.send_signal(signal.SIGINT)
interrupted = True
stdout, _ = process.communicate(timeout=5)
finally:
os.close(master)
if process.poll() is None:
process.kill()
process.wait()
sys.stdout.buffer.write(stdout)
sys.stderr.buffer.write(captured)
if sys.argv[2] == 'interrupt' and not interrupted:
raise RuntimeError('no partial progress frame was shown before completion')
raise SystemExit(process.returncode if process.returncode >= 0 else 128 - process.returncode)
"#;
Command::new("python3")
.arg("-c")
.arg(script)
.arg(env!("CARGO_BIN_EXE_habeas"))
.arg(if interrupt { "interrupt" } else { "complete" })
.args(args)
.current_dir(&self.project)
.env("XDG_CONFIG_HOME", &self.config_root)
.env("APPDATA", &self.config_root)
.env("XDG_STATE_HOME", &self.state)
.env("LOCALAPPDATA", &self.state)
.env("HABEAS_GITHUB_API_URL", "http://127.0.0.1:9")
.env("TERM", term)
.env("NO_COLOR", "1")
.env("CLICOLOR_FORCE", "1")
.output()
.expect("PTY progress tests require python3 on Unix")
}
Input 28: outline tests/authoring_batch.rs fn[assert_interruption_stops_the_batch]
- File:
tests/authoring_batch.rs - Selector:
fn[assert_interruption_stops_the_batch] - Kind:
fn tests/authoring_batch.rs:1080–1149
// {cite}`habeas:util`
#[cfg(unix)]
fn assert_interruption_stops_the_batch(overlap: bool, concurrency: usize) {
let server = Server::start_with(overlap, Behavior::WaitAfterFirst);
let fixture = Fixture::new(&server.endpoint, Some(concurrency));
let output = fixture.run_in_pty(true, "xterm-256color");
assert!(!output.status.success(), "{output:?}");
let terminal = String::from_utf8_lossy(&output.stderr);
let escape = regex::Regex::new(r"\x1b\[[0-?]*[ -/]*[@-~]").unwrap();
let plain = escape.replace_all(&terminal, "");
assert!(plain.contains("Stopped"), "{plain}");
assert!(plain.contains("assessments not started"), "{plain}");
let started = concurrency + 1;
let remaining = 6 - started;
assert!(
plain.contains(&format!("{remaining} assessments not started")),
"{plain}"
);
// A cancelled batch does not compute coverage warnings.
assert!(!plain.contains("coverage history"), "{plain}");
let stopped = &plain[plain.rfind("Stopped").unwrap()..];
assert!(!stopped.contains("100%"), "{stopped}");
assert!(!stopped.contains("6/6 finished"), "{stopped}");
assert!(String::from_utf8_lossy(&output.stdout).contains("1 authored;"));
// A launched assessment may be cancelled before its HTTP request arrives.
let received = server.subjects().len();
assert!(
(concurrency..=started).contains(&received),
"{received} requests for {started} launched assessments"
);
let usage = fixture.usage();
assert_eq!(usage.len(), started);
assert_eq!(
usage
.iter()
.filter(|run| run["evidence_written"] == true)
.count(),
1
);
// The assessment running at the interruption is cancelled without writing.
assert!(
usage
.iter()
.any(|run| run["outcome"] == "cancelled" && run["evidence_written"] == false),
"{usage:?}"
);
assert_eq!(
usage
.iter()
.filter(|run| run["outcome"] == "cancelled" && run["evidence_written"] == false)
.count(),
concurrency,
"{usage:?}"
);
let screen = final_screen(&output.stderr);
for expected in [
"Stopped".to_owned(),
format!("{started}/6 finished"),
format!("errors {concurrency}"),
"0 active".to_owned(),
format!("{remaining} queued"),
] {
assert!(screen.contains(&expected), "missing {expected}: {screen}");
}
assert!(!screen.contains("100%"), "{screen}");
let written = fs::read_dir(fixture.project.join("evidence"))
.unwrap()
.count();
assert_eq!(written, 1, "only the finished assessment wrote evidence");
}