Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

requirements.authoring.reporting

Requirements index · View definition

evidence Valid

Requirement

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

Rationale

The reviewed tests cover the obligations of requirements.authoring.reporting, and each one has a concrete assertion.

Default reporting

  • False judgments in batch, redirected: batch_reports_false_rationales_only_when_verbose (non-verbose pass) asserts that requirements.alpha: false (usage: is on stderr and that no : true (usage: line appears. It also asserts that stderr has no ANSI escape and that the false rationale is absent.
  • False judgments in batch, terminal: terminal_progress_distinguishes_judgments_from_authoring_errors runs the batch in a pty. It asserts that the false line is shown, the true line is suppressed, and the rationale and “Fixture judgment” text are absent.
  • False judgments in single-subject mode: false_is_a_completed_assessment asserts that {SUBJECT}: false is on stderr and not on stdout. It also asserts that the rationale is not printed.
  • Progress counters and summaries kept: the pty test asserts the counted inspection progress, 6/6 finished, active and queued counts, the elapsed timer, and the final true 3, false 1, FIXME 1, errors 1 counts. The stdout summary line is also asserted.
  • FIXME notices and authoring errors visible: the batch tests assert requirements.beta: FIXME and fixture model rejected. The --stdout test asserts — FIXME for a FIXME judgment.
  • Single-subject metadata: ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free asserts the subject, backend, model, Evidence: path and Usage:. The --stdout test asserts Evidence: stdout and the usage-record path.

Verbose reporting

  • Rationale shown only for false judgments: verbose_single_author_reports_only_false_rationale_without_source_inputs covers -v and --verbose with a false judgment, and -v with a true judgment. The rationale appears on stderr only for false, never on stdout, and never for true. The batch test asserts diagnostics.contains(&rationale) == verbose.
  • True rationales not printed: the batch test checks that the gamma true rationale is absent in both modes.
  • No input snapshots: several tests assert that source text such as pub fn alpha() and pub fn ready() does not appear in the output.
  • Readable above terminal progress: verbose_false_rationale_is_readable_above_terminal_progress checks the rationale in a pty with -v.
  • No additional inference: the batch tests assert that server.subjects().len() is 6 in both modes. The single-subject tests assert exactly one model request.

--stdout mode: stdout_emits_only_evidence_json_without_changing_project_files includes verbose runs for false and true judgments. It parses all of stdout as JSON and checks the exact schema keys. Diagnostics and the rationale go to stderr only for false verbose runs.

Verbosity does not change persistence, validation, or exit status

  • Verbose and non-verbose runs both assert evidence contents.
  • The single-subject verbose test asserts exit success and runs validate_repository. Validation fails only for false judgments, whether or not -v is given.
  • The batch verbose run asserts a nonzero exit and the same stdout summary as the default run.

Residual risk: I found no single-subject run in a pty and no single-subject authoring-error test. The terminal behaviour is tested through the batch path. The requirement does not distinguish the two paths, so I do not count this as a gap.

Inputs

Tests

Input 4: outline tests/authoring_batch.rs fn[failed_assessment_keeps_other_results_and_reports_failure]
// {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 5: outline tests/authoring_batch.rs fn[terminal_progress_distinguishes_judgments_from_authoring_errors]
// {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 6: outline tests/authoring_batch.rs fn[batch_reports_false_rationales_only_when_verbose]
// {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 7: outline tests/authoring_batch.rs fn[verbose_false_rationale_is_readable_above_terminal_progress]
// {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 8: outline tests/authoring_cli.rs fn[ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free]
// {test}`requirements.authoring.complete_initial_bundle`
// {test}`requirements.authoring.invocation`
// {test}`requirements.authoring.additional_read`
// {test}`requirements.authoring.acknowledged_gap`
// {test}`requirements.authoring.configuration_precedence`
// {test}`requirements.authoring.rig_configuration_mapping`
// {test}`requirements.authoring.configuration_storage`
// {test}`requirements.authoring.initial_prompt`
// {test}`requirements.ci.review_criteria`
// {test}`requirements.authoring.delivered_inputs`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.authoring.usage_inputs`
// {test}`requirements.authoring.usage_requests`
// {test}`requirements.authoring.mandatory_inputs`
// {test}`requirements.authoring.github_reads`
// {test}`requirements.authoring.invocation`
// {test}`requirements.configuration.serialization`
// {test}`requirements.ci.fixme_implementation_gap`
// {test}`requirements.authoring.finish_search.empty`
// {test}`requirements.authoring.finish_search.completion`
#[test]
// {test}`requirements.authoring.persistence`
// {test}`requirements.authoring.reporting`
fn ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free() {
    let server = Server::start(vec![
        reply(vec![
            call("list", "list_files", json!({})),
            call(
                "search",
                "ripgrep",
                json!({"path":"extra.txt","pattern":"needle"}),
            ),
            call(
                "read",
                "habeas",
                json!({"file":"extra.txt","line_start":10}),
            ),
            call(
                "repeat",
                "habeas",
                json!({"file":"extra.txt","line_start":10}),
            ),
            call(
                "missing",
                "habeas",
                json!({"file":"absent.txt","line_start":1}),
            ),
        ]),
        json!({"__finish_latest_search":true}),
        reply(vec![call(
            "submit",
            "submit_judgment",
            json!({
            "determination":{"FIXME":["example/app#125"]},"rationale":"SECRET_RATIONALE: `src/lib.rs#fn[ready]` documents the gap."}),
        )]),
    ]);
    let fixture = Fixture::new(&server.endpoint);
    let user_config = fixture.config.join("habeas/config.toml");
    let configured = fs::read(&user_config).unwrap();
    let output = fixture.run(&["author-evidence", SUBJECT]);
    assert!(
        output.status.success(),
        "{}",
        String::from_utf8_lossy(&output.stderr)
    );
    // The user configuration, with its environment-resolved key, is not
    // rewritten.
    assert_eq!(fs::read(&user_config).unwrap(), configured);
    let requests = server.finish();
    assert_eq!(requests.len(), 3);
    for request in &requests {
        assert!(request.headers.starts_with("POST /api/chat HTTP/1.1\r\n"));
        assert!(request.headers.to_ascii_lowercase().contains(&format!(
            "authorization: bearer {}",
            AUTH.to_ascii_lowercase()
        )));
        assert_eq!(request.body["model"], MODEL);
        assert_eq!(request.body["options"]["temperature"], 0.25);
        assert_eq!(request.body["options"]["num_ctx"], 4096);
        assert_eq!(request.body["think"], false);
        assert_eq!(request.body["stream"], false);
    }
    let prompt = prompt_text(&requests[0].body);
    for text in [
        "Assess whether a project's tests adequately check one requirement.",
        REQUIREMENT,
        "SECRET_DEFINITION_TEXT",
        "fn ready_test()",
        "You MUST end by calling submit_judgment",
    ] {
        assert!(prompt.contains(text), "prompt missing {text}");
    }
    assert!(!prompt.contains("pub fn ready()"), "{prompt}");
    assert!(!prompt.contains("OLD_RATIONALE_MUST_NOT_REACH_MODEL"));
    let mut tools = requests[0].body["tools"]
        .as_array()
        .unwrap()
        .iter()
        .map(|tool| tool["function"]["name"].as_str().unwrap())
        .collect::<Vec<_>>();
    tools.sort();
    assert_eq!(
        tools,
        [
            "ast_grep",
            "finish_search",
            "github",
            "habeas",
            "list_files",
            "next_page",
            "outline",
            "references",
            "ripgrep",
            "submit_judgment"
        ]
    );
    let results = requests[1].body["messages"]
        .as_array()
        .unwrap()
        .iter()
        .filter(|message| message["role"] == "tool")
        .collect::<Vec<_>>();
    assert_eq!(results.len(), 5);
    assert!(results.iter().any(|message| {
        message["content"]
            .as_str()
            .unwrap()
            .contains("SECRET_SOURCE_PAYLOAD")
    }));
    assert!(
        results
            .iter()
            .any(|message| message["content"].as_str().unwrap().contains("absent.txt"))
    );

    let evidence: Value = serde_json::from_slice(&fs::read(&fixture.evidence).unwrap()).unwrap();
    assert_eq!(
        evidence["determination"],
        json!({"FIXME":["example/app#125"]})
    );
    assert_eq!(
        evidence["rationale"],
        "SECRET_RATIONALE: `src/lib.rs#fn[ready]` documents the gap."
    );
    assert_eq!(evidence["requirement"], REQUIREMENT);
    let inputs = evidence["inputs"].as_array().unwrap();
    assert!(
        inputs
            .iter()
            .any(|input| input["file"] == "src/lib.rs" && input["item"] == "fn[ready_test]"),
        "{inputs:#?}"
    );
    // The acknowledgment reaches the model as metadata, without the
    // containing implementation. Its body is protected by the reference set.
    assert!(prompt.contains(":github: example/app#125"));
    assert!(prompt.contains("One acknowledged gap."));
    // GitHub is unreachable, so the issue is supplied as open, but the state
    // is not recorded.
    assert!(
        prompt.contains("\"reference\": \"example/app#125\"")
            && prompt.contains("\"state\": \"open\""),
        "{prompt}"
    );
    assert!(!evidence.to_string().contains("github_issues"));
    assert!(!fixture.usage().to_string().contains("github_issues"));
    assert!(
        !inputs
            .iter()
            .any(|input| input["file"] == "src/lib.rs" && input["item"] == "fn[ready]"),
        "{inputs:#?}"
    );
    // CI accepts the FIXME judgment: its evidence has no validation error.
    let report = habeas::validate_repository(&fixture.project).unwrap();
    let label = format!("evidence/{SUBJECT}.json");
    assert!(
        !report.errors.iter().any(|error| error.contains(&label)),
        "{:#?}",
        report.errors
    );
    // The same record with a false determination is rejected.
    let mut rejected = evidence.clone();
    rejected["determination"] = json!(false);
    let accepted = fs::read(&fixture.evidence).unwrap();
    fs::write(&fixture.evidence, rejected.to_string()).unwrap();
    let report = habeas::validate_repository(&fixture.project).unwrap();
    assert!(
        report.errors.iter().any(|error| error.contains(&label)),
        "{:#?}",
        report.errors
    );
    fs::write(&fixture.evidence, accepted).unwrap();
    assert!(
        inputs
            .iter()
            .any(|input| input["definition"] == "terms.readiness")
    );
    let extra = inputs
        .iter()
        .filter(|input| input["file"] == "extra.txt")
        .collect::<Vec<_>>();
    // The search only locates lines and records nothing; the reads cover
    // lines 10-12, one plain-text line node each, and the repeated delivery
    // is recorded once, by selector and hash only.
    assert_eq!(
        extra,
        habeas::outline_inputs_for_lines(&fixture.project, "extra.txt", 10, 12)
            .unwrap()
            .iter()
            .collect::<Vec<_>>(),
        "repeated delivery is deduplicated in evidence"
    );
    assert!(
        !evidence["inputs"]
            .to_string()
            .contains("SECRET_SOURCE_PAYLOAD")
    );
    assert!(
        !inputs
            .iter()
            .any(|input| input["file"] == "absent.txt" || input["file"] == ".")
    );

    let usage = fixture.usage();
    assert_eq!(usage["outcome"], "completed");
    assert_eq!(usage["determination"], "FIXME");
    assert_eq!(usage["evidence_written"], true);
    assert_eq!(usage["request_count"], 3);
    assert_eq!(usage["tool_call_count"], 7);
    assert_eq!(usage["tool_calls"]["habeas"], 3);
    assert_eq!(usage["tool_failures"]["habeas"], 1);
    // The directory listing counts as a tool call but is not an input.
    assert_eq!(usage["tool_calls"]["list_files"], 1);
    assert_eq!(usage["tool_calls"]["ripgrep"], 1);
    assert_eq!(usage["tool_calls"]["finish_search"], 1);
    let usage_inputs = usage["inputs"].as_array().unwrap();
    assert!(
        !usage_inputs
            .iter()
            .any(|input| input["origin"] == "list_files"),
        "{usage_inputs:?}"
    );
    // Search snippets count toward usage, without becoming evidence inputs.
    assert!(
        usage_inputs.iter().any(|input| input["origin"] == "ripgrep"
            && input["kind"] == "search"
            && input["bytes"].as_u64().unwrap() > 0
            && input["lines"].as_u64().unwrap() > 0),
        "{usage_inputs:?}"
    );
    assert!(
        usage_inputs
            .iter()
            .any(|input| input["origin"] == "habeas" && input["unique"] == true),
        "{usage_inputs:?}"
    );
    assert_eq!(usage["tokens"]["input"], 33);
    assert_eq!(usage["tokens"]["output"], 21);
    assert_eq!(usage["tokens"]["complete"], true);
    assert!(
        usage["inputs"]
            .as_array()
            .unwrap()
            .iter()
            .any(|input| input["origin"] == "habeas"
                && input["unique"] == false
                && input["sent_in_request"] == 1)
    );
    assert!(
        usage["inputs"]
            .as_array()
            .unwrap()
            .iter()
            .any(|input| input["origin"] == "mandatory"
                && input["kind"] == "definition"
                && input["bytes"].as_u64().unwrap() > 0)
    );
    let serialized = usage.to_string();
    for secret in [
        "SECRET_REQUIREMENT_TEXT",
        "SECRET_DEFINITION_TEXT",
        "SECRET_SOURCE_PAYLOAD",
        "SECRET_RATIONALE",
        AUTH,
        "#125",
    ] {
        assert!(
            !serialized.contains(secret),
            "usage contains source or credential content: {secret}"
        );
    }
    let stdout = String::from_utf8_lossy(&output.stdout);
    assert!(stdout.contains(MODEL) && stdout.contains("Evidence:") && stdout.contains("Usage:"));
    // By default the report names the subject and backend and identifies the
    // evidence file it wrote.
    assert!(
        stdout.starts_with(&format!("{SUBJECT}: ollama / {MODEL}")),
        "{stdout}"
    );
    let evidence = stdout
        .lines()
        .find_map(|line| line.strip_prefix("Evidence: "))
        .unwrap();
    assert!(
        evidence.ends_with(&format!("evidence/{SUBJECT}.json")),
        "{stdout}"
    );
    assert_eq!(
        fs::canonicalize(evidence).unwrap(),
        fs::canonicalize(fixture.project.join(format!("evidence/{SUBJECT}.json"))).unwrap()
    );
}
Input 9: outline tests/authoring_cli.rs fn[false_is_a_completed_assessment]
// {test}`requirements.authoring.negative_assessment`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.authoring.persistence`
// {test}`requirements.ci.fixme_with_unacknowledged_gap`
// {test}`requirements.authoring.reporting`
#[test]
fn false_is_a_completed_assessment() {
    let server = Server::start(vec![reply(vec![call(
        "submit",
        "submit_judgment",
        json!({"determination":false,"rationale":"The test checks refusal for a full positive-capacity queue, without acknowledging missing checks for preservation and zero capacity."}),
    )])]);
    let fixture = Fixture::new(&server.endpoint);
    fs::write(fixture.project.join("md/requirements.md"), ":::{req} ready\nInserting into a full queue MUST return false without overwriting its entries, including at zero capacity.\n:::\n").unwrap();
    fs::write(fixture.project.join("src/lib.rs"), "// {impl}`requirements.ready`\n// FIXME(#125): zero-capacity insertion panics.\npub fn push(queue: &mut [u8], value: u8) -> bool {\n    queue[0] = value;\n    true\n}\n\n// {test}`requirements.ready`\n#[test]\nfn full_queue() { let mut queue = [1]; assert!(!push(&mut queue, 2)); }\n").unwrap();
    let output = fixture.run(&["author-evidence", SUBJECT, "--config", "mock"]);
    assert!(
        output.status.success(),
        "{}",
        String::from_utf8_lossy(&output.stderr)
    );
    let requests = server.finish();
    let prompt = prompt_text(&requests[0].body);
    assert!(prompt.contains("and false otherwise."));
    assert!(!prompt.contains("FIXME(#125): zero-capacity insertion panics"));
    assert!(!prompt.contains("queue[0] = value"));
    assert!(prompt.contains("fn full_queue()"));
    let evidence: Value = serde_json::from_slice(&fs::read(&fixture.evidence).unwrap()).unwrap();
    assert_eq!(evidence["determination"], false);
    assert!(!evidence["inputs"].as_array().unwrap().is_empty());
    assert!(
        evidence["rationale"]
            .as_str()
            .unwrap()
            .contains("without acknowledging")
    );
    // Outline inputs record selectors and hashes, never the source text.
    assert!(
        evidence["inputs"]
            .as_array()
            .unwrap()
            .iter()
            .any(|input| input["item"].is_string() && input["hash"].is_string())
    );
    assert!(!evidence["inputs"].to_string().contains("FIXME(#125)"));
    assert_eq!(fixture.usage()["outcome"], "completed");
    assert_eq!(fixture.usage()["determination"], "false");
    let diagnostics = format!(
        "{}{}",
        String::from_utf8_lossy(&output.stdout),
        String::from_utf8_lossy(&output.stderr)
    );
    let stderr = String::from_utf8_lossy(&output.stderr);
    assert!(stderr.contains(&format!("{SUBJECT}: false")), "{stderr}");
    assert!(
        !String::from_utf8_lossy(&output.stdout).contains(&format!("{SUBJECT}: false")),
        "{diagnostics}"
    );
    assert!(
        !diagnostics.contains("without acknowledging"),
        "{diagnostics}"
    );
    // CI rejects the false judgment even though a FIXME acknowledges one gap.
    let report = habeas::validate_repository(&fixture.project).unwrap();
    let evidence_file = format!("evidence/{SUBJECT}.json");
    let rejection = report
        .errors
        .iter()
        .find(|error| error.starts_with(&evidence_file) && error.contains("determination is false"))
        .unwrap_or_else(|| panic!("{:?}", report.errors));
    assert!(rejection.contains("without acknowledging"), "{rejection}");
}
Input 10: outline tests/authoring_cli.rs fn[verbose_single_author_reports_only_false_rationale_without_source_inputs]
// {test}`requirements.authoring.reporting`
// {test}`requirements.authoring.invocation`
// {test}`requirements.authoring.persistence`
#[test]
fn verbose_single_author_reports_only_false_rationale_without_source_inputs() {
    for (determination, flag) in [(false, "-v"), (false, "--verbose"), (true, "-v")] {
        let rationale = "REVIEW_RATIONALE_ONLY:\n\n- The captured test misses an interesting boundary.\n- Add an assertion for that boundary.";
        let server = Server::start(vec![reply(vec![call(
            "submit",
            "submit_judgment",
            json!({"determination": determination, "rationale": rationale}),
        )])]);
        let fixture = Fixture::new(&server.endpoint);
        common::coverage_setup(&fixture.project);
        let output = fixture.run(&["author", SUBJECT, flag]);
        assert!(output.status.success(), "{output:?}");
        assert_eq!(server.finish().len(), 1);
        let stdout = String::from_utf8_lossy(&output.stdout);
        let stderr = String::from_utf8_lossy(&output.stderr);
        assert_eq!(
            stderr.contains(&format!("{SUBJECT}: false")),
            !determination,
            "{stderr}"
        );
        assert_eq!(stderr.contains(rationale), !determination, "{stderr}");
        assert!(!stdout.contains(rationale), "{stdout}");
        for text in [&stdout, &stderr] {
            assert!(!text.contains("SECRET_REQUIREMENT_TEXT"), "{text}");
            assert!(!text.contains("SECRET_DEFINITION_TEXT"), "{text}");
            assert!(!text.contains("pub fn ready()"), "{text}");
            assert!(!text.contains("— true"), "{text}");
            assert!(!text.contains(&format!("{SUBJECT}: true")), "{text}");
        }
        assert!(stdout.contains("Evidence:"), "{stdout}");
        assert!(stdout.contains("Usage:"), "{stdout}");
        let evidence: Value =
            serde_json::from_slice(&fs::read(&fixture.evidence).unwrap()).unwrap();
        assert_eq!(evidence["determination"], determination);
        assert_eq!(evidence["rationale"], rationale);
        let errors = habeas::validate_repository(&fixture.project)
            .unwrap()
            .errors;
        assert_eq!(
            errors
                .iter()
                .any(|error| error.contains("determination is false")),
            !determination,
            "{errors:?}"
        );
        if determination {
            assert!(errors.is_empty(), "{errors:?}");
        }
    }
}
Input 11: outline tests/authoring_cli.rs fn[stdout_emits_only_evidence_json_without_changing_project_files]
// {test}`requirements.authoring.invocation`
// {test}`requirements.authoring.persistence`
// {test}`requirements.authoring.delivered_inputs`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.authoring.reporting`
// {test}`requirements.ci.schema`
#[test]
fn stdout_emits_only_evidence_json_without_changing_project_files() {
    for (determination, kind, existing_evidence, verbose) in [
        (json!(true), "true", true, false),
        (json!(false), "false", true, false),
        (json!({"FIXME":["#125"]}), "FIXME", true, false),
        (json!(true), "true", false, false),
        (json!(false), "false", true, true),
        (json!(true), "true", true, true),
    ] {
        let rationale = "The supplied sources explain this judgment.";
        let server = Server::start(vec![reply(vec![call(
            "submit",
            "submit_judgment",
            json!({"determination":determination,"rationale":rationale}),
        )])]);
        let fixture = Fixture::new(&server.endpoint);
        if !existing_evidence {
            fs::remove_dir_all(fixture.project.join("evidence")).unwrap();
        }
        let mut args = vec!["author-evidence", SUBJECT, "--stdout"];
        if verbose {
            args.push("--verbose");
        }
        let output = fixture.run(&args);
        assert!(
            output.status.success(),
            "{}",
            String::from_utf8_lossy(&output.stderr)
        );
        assert_eq!(server.finish().len(), 1);
        let evidence: Value = serde_json::from_slice(&output.stdout).unwrap();
        assert!(output.stdout.ends_with(b"\n"));
        assert_eq!(evidence["requirement"], REQUIREMENT);
        assert_eq!(evidence["determination"], determination);
        assert_eq!(evidence["rationale"], rationale);
        let inputs = evidence["inputs"].as_array().unwrap();
        assert!(inputs.iter().any(|input| input["requirements"] == SUBJECT));
        assert!(
            inputs
                .iter()
                .any(|input| input["definition"] == "terms.readiness")
        );
        assert!(
            inputs
                .iter()
                .any(|input| input["file"] == "src/lib.rs" && input["item"].is_string())
        );
        // The record has exactly the schema's fields, and outline inputs carry
        // only their file, selector, and hash, never source text.
        let keys = |value: &Value| {
            let mut keys: Vec<_> = value.as_object().unwrap().keys().cloned().collect();
            keys.sort();
            keys
        };
        assert_eq!(
            keys(&evidence),
            [
                "determination",
                "inputs",
                "rationale",
                "references",
                "requirement"
            ]
        );
        for input in inputs.iter().filter(|input| input.get("item").is_some()) {
            assert_eq!(keys(input), ["file", "hash", "item"], "{input}");
        }
        if existing_evidence {
            assert_eq!(
                fs::read_to_string(&fixture.evidence).unwrap(),
                fixture.original
            );
        } else {
            assert!(!fixture.project.join("evidence").exists());
        }
        let stderr = String::from_utf8_lossy(&output.stderr);
        assert!(
            stderr.contains(&format!("{SUBJECT}: ollama / {MODEL}")),
            "{stderr}"
        );
        assert!(!stderr.contains("— true"), "{stderr}");
        assert!(!stderr.contains(&format!("{SUBJECT}: true")), "{stderr}");
        assert_eq!(
            stderr.contains(&format!("{SUBJECT}: false")),
            kind == "false",
            "{stderr}"
        );
        if kind == "FIXME" {
            assert!(stderr.contains("— FIXME"), "{stderr}");
        }
        assert_eq!(
            stderr.contains(rationale),
            verbose && kind == "false",
            "{stderr}"
        );
        assert!(!stderr.contains("SECRET_REQUIREMENT_TEXT"), "{stderr}");
        assert!(!stderr.contains("SECRET_DEFINITION_TEXT"), "{stderr}");
        assert!(stderr.contains("Evidence: stdout\n"));
        let usage_path = stderr
            .lines()
            .find_map(|line| line.strip_prefix("Usage: "))
            .expect("stderr reports usage location");
        assert!(std::path::Path::new(usage_path).is_file());
        let usage = fixture.usage();
        assert_eq!(usage["outcome"], "completed");
        assert_eq!(usage["determination"], kind);
        assert_eq!(usage["evidence_output"], "stdout");
        assert_eq!(usage["evidence_written"], true);
    }
}

Referenced definitions

Input 2: requirements selection requirements.authoring.invocation
:::{req} invocation
`habeas author <full-name> [--config <name>] [--missing | --force] [--stdout] [-v|--verbose]`
MUST author the evidence of one existing requirement or named example in the
current project, under {cite}`requirements.authoring.refresh`. It MUST report the
selected subject, backend, model, evidence destination, and usage-record path on
completion. The evidence destination MUST identify the evidence-file path by
default or stdout when `--stdout` is selected. In stdout mode, the completion
report and diagnostics MUST go to stderr. `author-evidence` MUST remain an alias
for the single-subject command.
:::
Input 3: requirements selection requirements.authoring.batch
:::{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`
:::

Other sources

Input 1: requirements selection requirements.authoring.reporting
:::{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`
:::