ref:1bd4dc532b8609fcfd621e33cf0dc20904877073

fix(cli): accurate --json help + strict gate message; note #331 contract

Two defects surfaced while grading #33: - The global --json help said only "read and status subcommands" honor it, but this PR also added the {"ok":true,…} mutation envelope. Reword to describe reads, status, and mutations. - gate_result reported `counts.uncovered` in its error message even under --strict, so a strict run failing only on partials printed "0 uncovered requirement(s)". Report the whole failing-set size instead. Also note in the clear_requirements test that the list payload carries parent_id per the server contract (fangorn/anvil #331) — that fix is what makes the children-first ordering deterministic against the real API. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SHA: 1bd4dc532b8609fcfd621e33cf0dc20904877073
Author: CI <ci@anvil.test>
Date: 2026-07-06 22:06
Parents: 58c52f6
2 files changed +11 -3
Type
src/commands/mod.rs +5 −2
@@ -26,8 +26,11 @@
version = include_str!(concat!(env!("OUT_DIR"), "/version.txt"))
)]
pub struct Cli {
/// Output JSON instead of human-readable tables/details. Honored by read
/// and status subcommands (list, view, matrix, requirement status). Useful
/// Output JSON instead of human-readable tables/details. Honored across the
/// requirement/standards commands: reads (list, view, matrix, applicability
/// list) echo the server payload, `requirement status` emits a coverage
/// summary and keeps its non-zero exit, and mutations (create/update/delete,
/// link/unlink, applicability, seed) emit an {"ok":true, …} envelope. Useful
/// for scripting and agent tooling.
#[arg(long, global = true)]
pub json: bool,
src/commands/requirement.rs +6 −1
@@ -1588,6 +1588,9 @@
if summary.passed() {
Ok(())
} else {
// Count the whole failing set, not just uncovered: under --strict the
// gate also fails on partial/no_tests, so "N uncovered" would misreport
// (e.g. "0 uncovered" while failing on partials).
Err(format!("{} requirement(s) failing coverage", summary.failing.len()).into())
Err(format!("{} uncovered requirement(s)", summary.counts.uncovered).into())
}
}
@@ -2311,6 +2314,8 @@
let server = MockServer::start().await;
// Two-level tree: parent REQ-P (uuid "P") and child REQ-C (parent_id "P").
// The list endpoint includes parent_id per the server contract
// (fangorn/anvil #331) — without it, ordering would be undefined.
Mock::given(method("GET"))
.and(path("/api/v1/o/r/requirements"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({