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.ci.review_criteria

Requirements index · View definition

evidence Valid

Requirement

The reviewer MUST assess the named subject using its text, referenced requirements, and terminology definitions. For a requirement, the reviewer MUST assess whether the reviewed tests adequately check its stated obligations, including relevant input classes, boundaries, condition combinations, state transitions, and failure cases. These cases MUST follow from the requirement’s obligations; the reviewer MUST NOT require behavior for inputs the text leaves unspecified. The reviewer MUST derive expected outcomes from the text, inspect the tests and relevant helpers or fixtures, and map each obligation assessed here to concrete test inputs and assertions in the rationale. It MUST separately identify obligations delegated to a refining requirement or a distributed site’s review and any established testing exemptions. It MUST assess both whether expected results conform to the text and whether the assertions enforce those results.

For every proposed adequacy gap, the reviewer MUST describe plausible behavior that violates a stated obligation but would be accepted by the reviewed tests, and explain which missing scenarios or weak assertions allow it. For an incorrect expected result, it MUST instead identify the assertion and explain its conflict with the text. A counterexample MUST identify a requirement-relevant distinction that the tests miss; another untested value in an already represented input class MUST NOT by itself establish a gap without explaining why it could expose different required behavior. It MUST check other relevant tests and helpers before reporting a gap and distinguish missing information from an established inadequacy. A marking gap or an ambiguity MUST be identified as such, without requiring a behavioral counterexample. A judgment of true MUST mean the reviewed tests adequately check the subject under these criteria, including the testing exemptions of cite requirements.authoring.testing_bar; it MUST NOT assert implementation correctness. The reviewer MAY request implementation source to resolve a specific question and MUST state that question in its rationale. It MUST NOT derive expected behavior from the implementation or assess implementation correctness, implementation reachability, or unspecified implementation behavior as additional tasks.

When another requirement implements part of the subject, the reviewer MUST assess whether its text carries out that part, and MUST NOT reassess its implementation, tests, or evidence; that requirement is assessed separately. When there are no tests, the reviewer MUST apply the testing exemptions of cite requirements.authoring.testing_bar and explain any exemption it establishes.

The reviewer MUST apply these rules in every assessment. MUST and MUST NOT state obligations; a SHOULD MUST impose an obligation unless the subject’s text or a source comment gives a reason it does not apply, and the reviewer MUST apply the testing criteria to every applicable SHOULD in a test-adequacy assessment and explain each exception in the rationale; MAY imposes nothing to check; examples and sample output in the text illustrate the obligations its prose states and bind their exact form only where the text says so. When the subject’s text admits two readings its wording supports equally and they lead to different conclusions, such as whether code conforms or which role a citation calls for, the ambiguity MUST be treated as a gap and the rationale MUST name the readings. A test that verifies the subject without a {test} reference to it MUST be treated as a marking gap; a helper reached from a marked test MUST NOT need a reference of its own. A gap MUST be reported only for a specific obligation with relevant sources the reviewer has read. Before reporting a missing test, the reviewer MUST perform targeted discovery of relevant tests and identify the missing scenario; an absent test MUST NOT require an invented source location. Style, performance, logging, how helpers are factored, robustness the text does not require, and silently ignoring input the text does not mention MUST NOT be treated as gaps, and the reviewer MUST NOT report bugs or issues outside the subject’s text.

For a distributed requirement under cite requirements.references.distributed, the reviewer MUST also assess the requirement and its queries. Each obligation MUST be either one that each site upholds on its own, checked by its review under cite requirements.references.site_review, or one that particular code carries out, assessed as above through its {impl} and {test} references; an obligation neither covers MUST be treated as a gap. The reviewer MUST judge whether each query’s conditions are adequate and adequately tested: the site queries MUST select every place the text’s description of a site covers and no place outside the requirement’s stated scope, and each query’s match and no_match snippets MUST test its conditions as tests of code would, judged as such; a condition without a snippet of its own MUST NOT by itself be treated as a gap. Because queries are heuristics, the reviewer MUST judge them by a preponderance of the evidence, asking whether it is more likely than not that the site queries find the places the requirement applies: a specific place in the sources that a site query misses or wrongly selects MUST be treated as a gap, and a form that does not occur in the sources MUST NOT. Obligations that decide which places are sites, such as a naming rule, MUST be checked by the reviewer’s search of the sources. Violation queries direct site reviews to likely problems; the reviewer SHOULD note constructs they miss, but their incompleteness MUST NOT by itself make the determination false. Any other gap in the queries or snippets MUST be treated as a gap under cite requirements.ci.outcomes, even when the code is correct. The reviewer SHOULD run each site query once, scan its matches, and search briefly for the construct the text describes, and MUST NOT review each site or treat a site without an {impl} reference as a gap.

For an example, the reviewer MUST assess whether tests exist whose setup and assertions cover its scenario and expected outcomes. The rationale MUST identify the relevant sources and explain the testing judgment for a requirement, or the test coverage for an example. Referenced requirements provide context; they MUST NOT become additional subjects to assess in full.

Rationale

Result: the reviewed tests adequately check requirements.ci.review_criteria. I found no gap. I did not request implementation source and did not assess implementation correctness.

What the requirement obliges and where it is carried out. The requirement binds the reviewer’s behavior. That behavior is carried out only by the prompt the harness gives the model. references shows two {impl} sites:

  • the prompt template in md/requirements/authoring.md (requirements.authoring.initial_prompt), and
  • src/authoring/mod.rs#fn[initial_prompt].

The prompt text itself comes from the approved blocks in the authoring chapter. src/authoring/mod.rs#fn[approved_text] reads those blocks from the chapter, which is the sole source of the instructions. This is the habeas_background, judgment_rules, requirement_task, testing_bar, example_task and distributed_task text.

Under the task rules, I judge only whether the refining prompt text carries the obligations. I do not reassess its implementation or tests. I found nothing it omits.

The behavioral obligations map to these testable prompt properties:

  • Obligations to derive obligations, inputs and boundaries, inspect tests and helpers, map to assertions, flag delegated obligations, give counterexamples, flag marking gaps and ambiguities, treat SHOULD as binding, and avoid reporting unspecified behavior are all instructions to the reviewer. They are tested as delivery of the approved requirement_task and judgment_rules text.
  • The testing exemptions of requirements.authoring.testing_bar are tested as delivery of the testing_bar text, placed immediately after the requirement task.
  • Distributed-requirement obligations (queries, site reviews) are tested as delivery of the filled distributed_task.
  • Example handling is tested as the example task replacing the requirement task and the testing bar.
  • Using the subject’s text, its references and its definitions as inputs is tested as delivery of those inputs in the prompt.

Tests and assertions.

  1. src/authoring/mod.rs#mod[tests]/fn[initial_prompt_carries_the_review_criteria]:
    • For a requirement, it asserts the prompt contains the subject line, habeas_background blocks 0 and 1, the judgment_rules block, the requirement_task block and the testing_bar block. It also asserts the key opening lines of the task and the subject’s own text.
    • It asserts the testing criteria immediately follow the requirement task.
    • It asserts the example task, the distributed text and any unfilled {{ placeholders are absent for a plain requirement.
    • For an example subject, it asserts the example task and its “concrete case” first-check text are present. It asserts the requirement task, the testing bar and “Testing criteria:” are absent, so the requirement-only criteria are not applied to examples.
  2. a_distributed_requirement_task_continues_with_the_filled_distributed_task:
    • For a distributed requirement, it asserts the filled distributed_task appears in the subject message after “Judge against…”. It asserts the requirement task and testing bar stay in the system prompt, habeas_background block 1 is present, and no placeholders remain.
    • It also asserts the verifier prompt carries the distributed task.
  3. tests/authoring_cli.rs#fn[ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free] is an end-to-end check:
    • The first request contains the task statement, the requirement text, the definition text, the {test} source (fn ready_test()) and the submit instruction.
    • It does not contain implementation source (pub fn ready()).
    • The tool set is exact, the acknowledgment metadata reaches the model, and a FIXME judgment validates while the same record with false is rejected.

Counterexample check. Plausible violations are: omitting the testing bar for requirements, applying it to examples, dropping the distributed task for distributed requirements, leaking implementation source as mandatory input, or failing to deliver test sources and definitions. Each is caught by the assertions above. No obligation in the text depends on an input class or boundary that these three tests leave unexercised. The three subject kinds (plain requirement, example, distributed requirement) each have a test.

Not gaps. Whether a model actually obeys the instructions is not a test-adequacy obligation of this text. The requirement’s prose on the reviewer’s outputs is an obligation on the instruction content, not on code branches.

Marking. All three tests carry {test} references to requirements.ci.review_criteria. I found no relevant unmarked test.

Acknowledgments. There are none, and none are needed.

Inputs

Implementation

Input 6: requirements selection requirements.authoring.initial_prompt
:::{req} initial_prompt
The initial request MUST provide the ten tool definitions above and the
following prompt, the first block as its system prompt and the second as its
subject message under {cite}`requirements.authoring.prompt_parts`. The harness MUST replace `{{subject_kind}}` with `requirement`
or `example`, `{{subject_name}}` with the full subject name,
`{{habeas_background}}`, `{{reference_roles}}`, and `{{distributed_background}}`
under {cite}`requirements.authoring.habeas_background`, `{{judgment_rules}}` under
{cite}`requirements.authoring.judgment_rules`, `{{acknowledgments}}` with the JSON
array of {cite}`requirements.authoring.fixme_inputs`, and `{{mandatory_inputs}}` with the
complete mandatory inputs as a JSON array using
the existing evidence-input formats. It MUST replace `{{subject_task}}`, for a requirement, with the text of
{cite}`requirements.authoring.requirement_task` followed by that of
{cite}`requirements.authoring.testing_bar`, and for an example, with the text of
{cite}`requirements.authoring.example_task`. It MUST replace
`{{distributed_task}}` with the filled text of
{cite}`requirements.authoring.distributed_task` for a distributed requirement,
and with nothing otherwise. The template MUST otherwise
be used as written. Their review guidance MUST follow
{impl}`requirements.ci.review_criteria`, {cite}`requirements.examples.evidence`,
and {cite}`requirements.ci.outcomes`.

```text
# Task

Assess whether a project's tests adequately check one {{subject_kind}}.
Your determination should be the one any careful reviewer would reach from the
same text and sources.

# Background: Habeas terms

{{habeas_background}}

{{reference_roles}}

# Your task

The mandatory inputs at the end contain the subject, the requirements and
examples it cites, the vocabulary definitions it uses, and the source text of
its {test} items and :test: anchors. Requirement and example declarations that
refine the subject through {impl} are also included. Implementation source is
not included merely because it carries an {impl} reference or :impl: anchor.
You can locate it with references and request it with habeas when needed.
Each {fixme} acknowledgment includes the state of the issues it names.

Cited requirements and examples are context: when the subject requires behavior
under or following a cited requirement, check that the subject's tests cover
applying it in the subject's case. Do not reassess the cited requirement's
implementation or tests.

When another requirement's text carries an {impl} reference to the subject,
assess only whether that text carries out the obligations it covers; do not
reassess its implementation or tests, and those obligations need no test here.

Judge test adequacy, rather than whether the current implementation is correct.
Derive expected behavior from the requirement and examples, even if you request
implementation source. A true judgment means the reviewed tests adequately
check the subject under the criteria below. You do not need to find a defect
when those criteria are met.

{{subject_task}}

# How to judge

{{judgment_rules}}

# Submitting

Choose true when your task finds no gap, {"FIXME": ["..."]} when every gap is
acknowledged, and false otherwise. You MUST end by calling submit_judgment
with determination and rationale until one submission is accepted.
A rejected submission does not complete the assessment. A judgment written in your
reply text is not accepted.
```

```text
# Subject

Subject: {{subject_kind}} {{subject_name}}
Judge against: the subject's text.

{{distributed_task}}

# Acknowledgments

{{acknowledgments}}

# Mandatory inputs

{{mandatory_inputs}}
```
:::

Tests

Input 7: outline src/authoring/mod.rs mod[tests]/fn[initial_prompt_carries_the_review_criteria]
    // {test}`requirements.ci.review_criteria`
    // {test}`requirements.authoring.requirement_task`
    // {test}`requirements.authoring.testing_bar`
    // {test}`requirements.authoring.example_task`
    // {test}`requirements.authoring.judgment_rules`
    // {test}`requirements.authoring.habeas_background`
    // {test}`requirements.examples.evidence`
    // {test}`requirements.examples.definition`
    #[test]
    fn initial_prompt_carries_the_review_criteria() {
        let project = inputs::tests::project();
        let sources = AssessmentSources::prepare(project.path(), "requirements.ready").unwrap();
        let prompt = initial_prompt(&sources).unwrap().joined();
        for criterion in [
            "Subject: requirement requirements.ready\nJudge against: the subject's text.",
            approved_text("habeas_background", 0),
            approved_text("habeas_background", 1),
            approved_text("judgment_rules", 0),
            approved_text("requirement_task", 0),
            approved_text("testing_bar", 0),
            "Derive testable obligations and expected outcomes from each MUST, MUST NOT,",
            "Testing criteria:",
            "The project MUST be ready.",
        ] {
            assert!(
                prompt.contains(criterion),
                "missing {criterion:?} in:\n{prompt}"
            );
        }
        // The testing criteria follow the requirement task.
        assert!(prompt.contains(&format!(
            "{}\n{}",
            approved_text("requirement_task", 0),
            approved_text("testing_bar", 0)
        )));
        assert!(!prompt.contains(approved_text("example_task", 0)));
        assert!(!prompt.contains("This subject is a distributed requirement."));
        assert!(!prompt.contains(distributed_background()));
        assert!(!prompt.contains("{{"), "{prompt}");

        // An example's task replaces the requirement task.
        let requirements = project.path().join("md/requirements.md");
        let mut book = fs::read_to_string(&requirements).unwrap();
        let cite = "{cite}`requirements.ready`";
        book.push_str(&format!(
            "\n:::{{example}} case\nA ready case. {cite}\n:::\n"
        ));
        fs::write(&requirements, book).unwrap();
        let sources = AssessmentSources::prepare(project.path(), "requirements.case").unwrap();
        let prompt = initial_prompt(&sources).unwrap().joined();
        assert!(
            prompt.contains("Subject: example requirements.case"),
            "{prompt}"
        );
        assert!(
            prompt.contains(approved_text("example_task", 0)),
            "{prompt}"
        );
        assert!(
            prompt.contains("First check that it describes a concrete case\nwith expected behavior; a missing concrete case or expected behavior is a gap."),
            "{prompt}"
        );
        assert!(
            !prompt.contains(approved_text("requirement_task", 0)),
            "{prompt}"
        );
        assert!(
            !prompt.contains(approved_text("testing_bar", 0)),
            "{prompt}"
        );
        assert!(!prompt.contains("Testing criteria:"), "{prompt}");
        assert!(!prompt.contains("{{"), "{prompt}");
    }
Input 8: outline src/authoring/mod.rs mod[tests]/fn[a_distributed_requirement_task_continues_with_the_filled_distributed_task]
  • File: src/authoring/mod.rs
  • Selector: mod[tests]/fn[a_distributed_requirement_task_continues_with_the_filled_distributed_task]
  • Kind: fn
  • src/authoring/mod.rs:4418–4462
    // {test}`requirements.authoring.distributed_task`
    // {test}`requirements.authoring.habeas_background`
    // {test}`requirements.authoring.initial_prompt`
    // {test}`requirements.ci.review_criteria`
    #[test]
    fn a_distributed_requirement_task_continues_with_the_filled_distributed_task() {
        let project =
            crate::sites::tests::project(crate::sites::tests::RULE, crate::sites::tests::SOURCE);
        let sources = AssessmentSources::prepare(project.path(), "requirements.rule").unwrap();
        let prompt = initial_prompt(&sources).unwrap();
        let task = fill(
            approved_text("distributed_task", 0),
            &[("distributed_background", distributed_background())],
        );
        assert!(task.starts_with(distributed_background()), "{task}");
        // The requirement task stays in the system prompt; the distributed
        // task follows the subject line in the subject message.
        assert!(
            prompt.system.contains(&format!(
                "{}\n{}\n\n# How to judge",
                approved_text("requirement_task", 0),
                approved_text("testing_bar", 0)
            )),
            "{}",
            prompt.system
        );
        assert!(!prompt.system.contains(&task), "{}", prompt.system);
        assert!(
            prompt.subject.contains(&format!(
                "Judge against: the subject's text.\n\n{task}\n\n# Acknowledgments\n\n[]\n\n# Mandatory inputs"
            )),
            "{}",
            prompt.subject
        );
        assert!(
            prompt
                .system
                .contains(approved_text("habeas_background", 1))
        );
        assert!(!prompt.joined().contains("{{"), "{}", prompt.joined());
        // The verifier's criteria carry the distributed task too.
        let verifier = verification_prompt(&sources, &Judgment::False, "A gap.").unwrap();
        assert!(verifier.subject.contains(&task), "{}", verifier.subject);
        assert!(!verifier.system.contains(&task), "{}", verifier.system);
    }
Input 9: 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()
    );
}

Referenced definitions

Input 2: requirements selection requirements.authoring.testing_bar
:::{req} testing_bar
The requirement task MUST continue with these criteria, which set when a
requirement's obligations need tests:

```text
Testing criteria:
   - Every obligation assessed here, and every boundary or failure case the text
     names for that obligation, needs
     a test that exercises the required behavior and asserts its outcome.
   - Distinct modes and scenarios the text governs, such as verbose and
     default modes, each need a relevant test. Implementation branches for
     cases the text does not distinguish need no test of their own.
   - An untested obligation is a gap unless the code carrying it out has no
     conditional and no transformation of its own, such as passing a value
     through unchanged, or running it would need network services, real elapsed
     time, or process-wide state such as environment variables or the current
     directory, and no test in the project sets that up; say which, and why.
     Request source if needed to establish a claimed exemption. Files and
     directories a test can create do not qualify.
   - That exemption does not cover an obligation that itself states that a value
     stays unchanged, distinct, or present; such an obligation needs a test.
```
:::
Input 3: requirements selection requirements.references.distributed
:::{req} distributed
A requirement MAY be distributed: it states obligations that each of many sites
in the sources must uphold on its own, such as a convention every validation
function follows, and MAY also state obligations that particular code carries
out, which that code implements with `{impl}`. A `{req}` body declares a distributed requirement
by containing one or more nested query directives: `:::{sites} <name>` for a
site query, which finds the places the obligation applies, or
`:::{violations} <name>` for a violation query, which finds constructs likely to
break it. A requirement with a violation query MUST also have a site query.
Query names MUST be single identifier segments under
{cite}`requirements.ci.identifiers`, unique within the requirement. A query
directive outside a `{req}` body MUST be a validation error. Each query body
MUST be one fenced `yaml` code block containing a mapping with only these keys:

- `language`, required: the name of an outline profile with a grammar under
  {cite}`requirements.references.outlines`: `rust`, `python`, `typescript`,
  `tsx`, `css`, `markdown`, `toml`, or `yaml`.
- `paths`, optional: project-relative files or directories. Only sources at or
  under one of them are searched; without it, every source of the language is.
- `exclude`, optional: project-relative files or directories whose sources are
  not searched, even under `paths`.
- `rule`, required, with optional `utils` and `constraints`: an ast-grep rule
  core in the syntax of Habeas's pinned `ast-grep-config` version, matched
  against the language's pinned grammar.
- `within`, required for violation queries and not allowed for site queries:
  the name of a site query in the same requirement.
- `match` and `no_match`, required: nonempty lists of source snippets in the
  query's language. Each `match` snippet MUST contain at least one match of the
  query, and each `no_match` snippet none, where a violation query counts only matches inside a site of its `within` query in the same snippet.

Validation MUST report a query whose body is not such a mapping, whose rule does
not compile, whose `within` names no site query of the requirement, a violation query without `within`, or one of whose snippets fails to parse or has the wrong match result, and a site query
that matches nothing in the project. Queries MUST search exactly the sources
reference discovery considers under {cite}`requirements.references.discovery`, in
their original text.

A match's site MUST be the innermost outline node, under
{cite}`requirements.references.outlines`, whose range contains the match; for a violation query, it MUST instead be the innermost site of its `within` query that contains the match, and a match inside none of that query's
sites MUST be discarded. A requirement's sites MUST be the distinct sites of all
its queries' matches. Each site MUST have a site review under
{cite}`requirements.references.site_review`, and needs no reference to the
requirement; being a site MUST NOT count as a reference for
{cite}`requirements.references.rust_item_coverage`, because a distributed
requirement concerns a cross-cutting obligation, not why the item exists.
Upgrading `ast-grep-config` MAY change matches and MUST be treated as a
deliberate change. The book MUST render each query directive as a badge
naming its kind and name, followed by its code block.
:::
Input 4: requirements selection requirements.references.site_review
:::{req} site_review
Every site of a distributed requirement under
{cite}`requirements.references.distributed` MUST have a site review: an
assessment of whether that site upholds the requirement, recorded at
`evidence/sites/<full-name>/<file>/<selector>.json`, where `<file>` and
`<selector>` are encoded as under
{cite}`requirements.references.citation_review`. The review MUST use the prompt
defined by {cite}`requirements.authoring.site_prompt`. Mandatory inputs, under
{cite}`requirements.authoring.mandatory_inputs`, MUST be the site's outline
node, the requirement's complete declaration, and each declaration the
requirement cites. The record MUST contain the requirement's full name, the
site's file and selector, `queries`, the sorted names of the queries with a
match at the site, `applies`, `determination`, `rationale`, and `inputs`, with
determinations under {cite}`requirements.ci.outcomes`. `applies` MUST be a
Boolean recording whether the requirement applies to the site. A site to which
the requirement does not apply MUST be judged `true`, and the rationale MUST
explain why it does not apply. `habeas info` MUST report, for each selected
distributed requirement, how many of its sites the requirement does not apply
to.

Validation MUST require a current, accepted review for every site, MUST report a
false review with its rationale, and MUST report stale, missing, or orphaned
reviews; a review is orphaned when its file and selector no longer name a site
of the requirement. A `{fixme}` naming the requirement inside a site
acknowledges a gap at that site only: it MUST be an input to that site's review
and MUST NOT contribute to the requirement's own review, coverage, or reference
set. A review MUST become stale when the site's hash, the requirement's
declaration, a cited declaration, its `queries`, or the `{fixme}` references
naming the requirement inside the site, with the words of their bodies, change.
Each site review's determination MUST be checked on its own, independently of
the requirement's evidence. Authoring with `--all` MUST include site reviews,
`habeas author sites:<full-name>` MUST author the site reviews of the named
requirement, and `habeas author sites:<full-name>/<file>#<selector>` MUST author
the review of the one site it names, under
{cite}`requirements.authoring.refresh`, where omitting `#<selector>` names the
file's root node. `habeas status` MUST report missing, stale, invalid, and false
site reviews with their requirement, file, and selector, and `habeas info` MUST
list each selected requirement's sites with their determinations.
:::
Input 5: requirements selection requirements.ci.outcomes
:::{req} outcomes
Every assessment judgment MUST use one of these outcomes, applying
{cite}`requirements.ci.review_criteria`:

- `true`: the reviewed tests adequately check a requirement or example under
  {cite}`requirements.ci.review_criteria`, including applicable testing
  exemptions and obligations assessed by a refining requirement or a site's
  own review. For a citation or site review, the review finds no gap under its
  own task.
- `false`: the sources do not support the subject, or information is missing,
  and the gaps are not all acknowledged by `{fixme}` references to it.
- `FIXME`: some aspects remain unmet or untested, and `{fixme}` references to
  the subject acknowledge every one of those gaps. The reviewer MUST explain the
  gaps and their source locations in the rationale and record their issue
  references or other identifying content from the supplied acknowledgments or
  inputs.

The JSON `determination` MUST be `true`, `false`, or an object containing exactly
`"FIXME"` with a nonempty array of nonempty strings, such as
`{"FIXME": ["example/queue#125", "rust-lang/rust#123"]}`. A gap MUST count as
acknowledged only by a `{fixme}` reference under
{cite}`requirements.references.roles` whose body describes that gap and that
references the assessed definition, or, for a site review, the distributed requirement from within that site; a citation review MUST NOT accept a `{fixme}`; a plain
`FIXME` comment, another marker such as `TODO`, or prose MUST NOT. The strings
MUST list each distinct issue reference the acknowledging `{fixme}` references
name in their option lines, as written after `:github:`, and, for a `{fixme}`
naming no issue, its body's words, without comment delimiters, joined by single
spaces. A `{fixme}` reference describing a gap that the review establishes no
longer exists within its task's scope MUST itself be treated as a gap. A reference
describing only an implementation defect MUST NOT create a test-adequacy gap or
require implementation review; it MUST acknowledge a testing gap only when its
body describes that same gap. A `{fixme}` naming a GitHub issue that
{cite}`requirements.authoring.github_reads` reports closed MUST NOT count as
acknowledging its gap. A FIXME judgment MUST be grounded in recorded evidence
inputs or, for an acknowledgment supplied under
{cite}`requirements.authoring.fixme_inputs`, the reference-set digest covering
that acknowledgment.
:::

Other sources

Input 1: requirements selection requirements.ci.review_criteria
:::{req} review_criteria
The reviewer MUST assess the named subject using its text, referenced requirements,
and terminology definitions. For a requirement, the reviewer MUST assess whether
the reviewed tests adequately check its stated obligations, including relevant
input classes, boundaries, condition combinations, state transitions, and failure
cases. These cases MUST follow from the requirement's obligations; the reviewer
MUST NOT require behavior for inputs the text leaves unspecified. The reviewer
MUST derive expected outcomes from the text, inspect the tests and relevant
helpers or fixtures, and map each obligation assessed here to concrete test
inputs and assertions in the rationale. It MUST separately identify obligations
delegated to a refining requirement or a distributed site's review and any
established testing exemptions. It MUST assess both whether expected results conform
to the text and whether the assertions enforce those results.

For every proposed adequacy gap, the reviewer MUST describe plausible behavior
that violates a stated obligation but would be accepted by the reviewed tests,
and explain which missing scenarios or weak assertions allow it. For an incorrect
expected result, it MUST instead identify the assertion and explain its conflict
with the text. A counterexample MUST identify a requirement-relevant distinction
that the tests miss; another untested value in an already represented input class
MUST NOT by itself establish a gap without explaining why it could expose
different required behavior. It MUST check other relevant tests and helpers before reporting a
gap and distinguish missing information from an established inadequacy. A marking
gap or an ambiguity MUST be identified as such, without requiring a behavioral
counterexample. A judgment of `true` MUST mean the reviewed tests adequately check
the subject under these criteria, including the testing exemptions of
{cite}`requirements.authoring.testing_bar`; it MUST NOT assert implementation
correctness. The reviewer MAY request implementation source to resolve a
specific question and MUST state that question in its rationale. It MUST NOT
derive expected behavior from the implementation or assess implementation
correctness, implementation reachability, or unspecified implementation behavior
as additional tasks.

When another requirement implements part of the subject, the
reviewer MUST assess whether its text carries out that part, and MUST NOT
reassess its implementation, tests, or evidence; that requirement is assessed
separately. When there are no tests, the reviewer MUST apply the testing
exemptions of {cite}`requirements.authoring.testing_bar` and explain any
exemption it establishes.

The reviewer MUST apply these rules in every assessment. MUST and MUST NOT state
obligations; a SHOULD MUST impose an obligation unless the subject's text or a
source comment gives a reason it does not apply, and the reviewer MUST apply the
testing criteria to every applicable SHOULD in a test-adequacy assessment and
explain each exception in the rationale; MAY imposes nothing to
check; examples and sample output in the text illustrate the obligations its
prose states and bind their exact form only where the text says so. When the subject's
text admits two readings its wording supports equally and they lead to different conclusions, such as whether code conforms or which role a citation calls for, the ambiguity MUST be treated as a gap and the rationale MUST name
the readings. A test that verifies the subject without a `{test}` reference to it
MUST be treated as a marking gap; a helper reached from a marked test MUST NOT
need a reference of its own. A gap MUST be
reported only for a specific obligation with relevant sources the reviewer
has read. Before reporting a missing test, the reviewer MUST perform targeted
discovery of relevant tests and identify the missing scenario; an absent test
MUST NOT require an invented source location. Style, performance, logging, how
helpers are factored, robustness the text does not require, and silently ignoring input the text does not mention MUST NOT be treated as gaps, and the reviewer MUST NOT report bugs or issues outside the
subject's text.

For a distributed requirement under {cite}`requirements.references.distributed`,
the reviewer MUST also assess the requirement and its queries. Each obligation
MUST be either one that each site upholds on its own, checked by its review under
{cite}`requirements.references.site_review`, or one that particular code carries
out, assessed as above through its `{impl}` and `{test}` references; an
obligation neither covers MUST be treated as a gap. The reviewer MUST judge whether
each query's conditions are adequate and adequately tested: the site queries
MUST select every place the text's description of a site covers and no place
outside the requirement's stated scope, and each query's `match` and `no_match`
snippets MUST test its conditions as tests of code would, judged as such; a
condition without a snippet of its own MUST NOT by itself be treated as a gap. Because queries are heuristics, the reviewer MUST
judge them by a preponderance of the evidence, asking whether it is more likely
than not that the site queries find the places the requirement applies: a
specific place in the sources that a site query misses or wrongly selects MUST be
treated as a gap, and a form that does not occur in the sources MUST NOT.
Obligations that decide which places are sites, such as a naming rule, MUST be
checked by the reviewer's search of the sources. Violation queries direct site
reviews to likely problems; the reviewer SHOULD note constructs they miss, but
their incompleteness MUST NOT by itself make the determination false. Any other
gap in the queries or snippets MUST be treated as a gap under
{cite}`requirements.ci.outcomes`, even when the code is correct. The reviewer SHOULD run each site query once, scan its matches,
and search briefly for the construct the text describes, and MUST NOT review each
site or treat a site without an `{impl}` reference as a gap.

For an example, the reviewer MUST assess whether tests exist whose setup and
assertions cover its scenario and expected outcomes. The rationale MUST identify
the relevant sources and explain the testing judgment for a
requirement, or the test coverage for an example. Referenced requirements provide
context; they MUST NOT become additional subjects to assess in full.
:::
Input 10: outline src/authoring/mod.rs fn[approved_text]
/// The `index`th text block of approved requirement `name` in the authoring
/// chapter, which is the sole source of these instructions.
// {impl}`requirements.authoring.initial_prompt`
// {impl}`requirements.authoring.habeas_background`
// {impl}`requirements.authoring.judgment_rules`
fn approved_text(name: &str, index: usize) -> &'static str {
    let chapter = include_str!("../../md/requirements/authoring.md");
    let opening = format!(":::{{req}} {name}\n");
    let start = chapter.find(&opening).expect("approved requirement") + opening.len();
    let body = &chapter[start..];
    let body = &body[..body.find("\n:::\n").expect("requirement closing fence")];
    body.split("```text\n")
        .nth(index + 1)
        .and_then(|block| block.split("\n```").next())
        .expect("approved text block")
}
Input 11: outline src/authoring/mod.rs fn[distributed_background]
/// The account of distributed requirements that the site prompt, the
/// distributed task, and a site review's verifier receive.
// {impl}`requirements.authoring.habeas_background`
fn distributed_background() -> &'static str {
    approved_text("habeas_background", 2)
}