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.initial_prompt

Requirements index · View definition

evidence Valid

Requirement

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.

# 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.
# Subject

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

{{distributed_task}}

# Acknowledgments

{{acknowledgments}}

# Mandatory inputs

{{mandatory_inputs}}

Rationale

The reviewed tests cover each obligation in requirements.authoring.initial_prompt. I did not request implementation source, because the supplied tests and the requirement text were enough to judge adequacy.

Obligations and the tests that cover them

  1. Ten tool definitions are provided.

    • tests/authoring_cli.rs#fn[ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free] sorts the tool names in the first request. It asserts the exact ten: ast_grep, finish_search, github, habeas, list_files, next_page, outline, references, ripgrep and submit_judgment.
    • tests/authoring_cli.rs#fn[bedrock_cli_uses_selected_profile_region_and_converse_tools] asserts the same ten for the Bedrock backend. It also checks the schemas of habeas and submit_judgment.
    • The content of each tool definition is governed by other requirements, such as requirements.authoring.source_tools, not by this one.
  2. The first block is the system prompt and the second is the subject message.

    • tests/authoring_cli.rs#fn[initial_prompt_substitutes_subject_and_mandatory_inputs_into_the_template] reads both blocks from the book with approved_text. It takes the system and user messages from the actual request through opening. It asserts system == expected, where expected is the first block with the substitutions applied. It asserts the subject message starts with the filled head of the second block and ends with its tail. It does this for both a requirement and an example.
    • src/authoring/mod.rs#mod[tests]/fn[subjects_of_one_kind_share_a_byte_identical_system_prompt] checks the literal segments of both blocks against a regex built from the approved text. It checks the message roles are system then user. It checks that two subjects give equal system prompts and different subject messages, and that no {{ is left over.
  3. Placeholder substitution.

    • {{subject_kind}} and {{subject_name}} are asserted in the subject message as Subject: {kind} {subject}, for a requirement and an example. The system prompt is asserted not to contain the subject name.
    • {{habeas_background}} and {{reference_roles}} are checked against approved_text("habeas_background", 0) and ("habeas_background", 1). {{judgment_rules}} is checked against approved_text("judgment_rules", 0).
    • {{acknowledgments}} is asserted as the exact JSON array with body, file, issues and item for a requirement that has a {fixme}. It is asserted as [] for the example.
    • {{mandatory_inputs}} is parsed as a JSON array. Each element is asserted to have exactly one of the three evidence-input forms, and each form is checked for its required fields. The subject, the cited requirement for an example, and the definition terms.readiness for the requirement are asserted to be present.
    • src/authoring/mod.rs#mod[tests]/fn[placeholders_are_filled_in_one_pass] asserts that a substituted value containing {{b}} is not expanded again.
  4. {{subject_task}}. For a requirement, the test builds requirement_task followed by testing_bar from the book text. For an example, it uses example_task. In both cases it asserts the system prompt equals the exact expected string. The distributed test also asserts the system prompt contains requirement_task then testing_bar followed by # How to judge.

  5. {{distributed_task}}.

    • For a non-distributed subject, the test asserts it is replaced with an empty string, for both a requirement and an example.
    • For a distributed requirement, src/authoring/mod.rs#mod[tests]/fn[a_distributed_requirement_task_continues_with_the_filled_distributed_task] fills distributed_task with distributed_background. It asserts the filled text sits between Judge against: the subject's text. and # Acknowledgments in the subject message. It asserts the task is not in the system prompt. It also asserts no {{ remains anywhere.
  6. “Otherwise as written.” Exact equality with the approved blocks, together with the checks that no {{ remains, covers this. The approved text is read from md/requirements/authoring.md itself, so a template change is caught.

  7. Review guidance follows the cited requirements. This is covered by the tests above carrying requirements.ci.review_criteria, and by the prompt-content assertions on the task and judgment rules.

Conclusion. I found no obligation or named case without a test and an assertion. The tests carry {test} references to the subject. The helper approved_text is also marked. I found no ambiguity in the text.

Inputs

Tests

Input 12: outline src/authoring/mod.rs mod[tests]/fn[placeholders_are_filled_in_one_pass]
    // {test}`requirements.authoring.initial_prompt`
    // {test}`requirements.authoring.verifier_prompt`
    #[test]
    fn placeholders_are_filled_in_one_pass() {
        assert_eq!(
            fill("{{a}} {{b}} {{c}}", &[("a", "{{b}}"), ("b", "2")]),
            "{{b}} 2 {{c}}"
        );
    }
Input 13: 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 14: outline src/authoring/mod.rs mod[tests]/fn[subjects_of_one_kind_share_a_byte_identical_system_prompt]
    /// Every system prompt is the same for two subjects of its kind, and
    /// every subject-dependent value is in the subject message.
    // {test}`requirements.authoring.prompt_parts`
    // {test}`requirements.authoring.initial_prompt`
    // {test}`requirements.authoring.citation_prompt`
    // {test}`requirements.authoring.site_prompt`
    // {test}`requirements.authoring.verifier_prompt`
    #[test]
    fn subjects_of_one_kind_share_a_byte_identical_system_prompt() {
        // Check every literal segment of the selected approved blocks, allowing
        // only declared placeholders to expand, then check the opening message roles.
        fn assert_opening(prompt: &Prompt, template: &str) {
            let placeholders = regex::Regex::new(r"\{\{[^}]+\}\}").unwrap();
            for (index, actual) in [&prompt.system, &prompt.subject].into_iter().enumerate() {
                let expected = approved_text(template, index);
                let mut pattern = String::from(r"\A");
                let mut end = 0;
                for placeholder in placeholders.find_iter(expected) {
                    pattern.push_str(&regex::escape(&expected[end..placeholder.start()]));
                    pattern.push_str("(?s:.*?)");
                    end = placeholder.end();
                }
                pattern.push_str(&regex::escape(&expected[end..]));
                pattern.push_str(r"\z");
                assert!(
                    regex::Regex::new(&pattern).unwrap().is_match(actual),
                    "{template} block {index}: {actual}"
                );
                assert!(!actual.contains("{{"), "{actual}");
            }
            let request = Prompt {
                system: prompt.system.clone(),
                subject: prompt.subject.clone(),
            }
            .request();
            assert_eq!(
                request.chat_history,
                vec![
                    Message::system(prompt.system.clone()),
                    Message::user(prompt.subject.clone())
                ]
            );
        }
        let project =
            crate::sites::tests::project(crate::sites::tests::RULE, crate::sites::tests::SOURCE);
        let requirements = project.path().join("md/requirements.md");
        let mut book = fs::read_to_string(&requirements).unwrap();
        let cite = "{cite}`requirements.rule`";
        book.push_str(&format!(
            "\n:::{{req}} other\nThe project MUST also work.\n:::\n\n:::{{req}} second\nThe project MUST keep working.\n:::\n\n:::{{example}} first_case\nA case. {cite}\n:::\n\n:::{{example}} second_case\nAnother case. {cite}\n:::\n"
        ));
        fs::write(&requirements, book).unwrap();
        let source = project.path().join("src/lib.rs");
        let mut text = fs::read_to_string(&source).unwrap();
        text.push_str(&format!(
            "\n// {cite}\nfn cites_one() {{}}\n\n// {cite}\n// :::{{cite}} habeas:util\n// Formats output.\n// :::\nfn cites_two() {{}}\n"
        ));
        fs::write(&source, text).unwrap();
        for (first, second, template) in [
            (
                "requirements.other",
                "requirements.second",
                "initial_prompt",
            ),
            (
                "requirements.first_case",
                "requirements.second_case",
                "initial_prompt",
            ),
            (
                "citations:src/lib.rs#fn[cites_one]",
                "citations:src/lib.rs#fn[cites_two]",
                "citation_prompt",
            ),
            (
                "sites:requirements.rule/src/lib.rs#fn[check_one]",
                "sites:requirements.rule/src/lib.rs#fn[check_two]",
                "site_prompt",
            ),
        ] {
            let sources = |subject: &str| {
                AuthoringSubject::parse(subject)
                    .sources(project.path())
                    .unwrap()
            };
            let (first, second) = (sources(first), sources(second));
            let (one, two) = (
                initial_prompt(&first).unwrap(),
                initial_prompt(&second).unwrap(),
            );
            assert_opening(&one, template);
            assert_opening(&two, template);
            assert_eq!(one.system, two.system, "{}", first.subject_name);
            assert_ne!(one.subject, two.subject);
            assert!(one.subject.starts_with("# Subject\n\n"), "{}", one.subject);
            assert!(!one.system.contains(&first.subject_name));
            let (one, two) = (
                verification_prompt(&first, &Judgment::False, "One gap.").unwrap(),
                verification_prompt(&second, &Judgment::Fixme(vec!["#2".into()]), "Two gaps.")
                    .unwrap(),
            );
            assert_opening(&one, "verifier_prompt");
            assert_opening(&two, "verifier_prompt");
            assert_eq!(one.system, two.system, "verifier of {}", first.subject_name);
            assert!(one.subject.contains("One gap."));
            assert!(!one.system.contains("One gap."));
        }
    }
Input 15: 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 16: outline tests/authoring_cli.rs fn[approved_text]
/// The `index`th text block of requirement `name` in the authoring chapter.
// {test}`requirements.authoring.initial_prompt`
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).unwrap() + opening.len();
    let body = &chapter[start..];
    let body = &body[..body.find("\n:::\n").unwrap()];
    let block = body.split("```text\n").nth(index + 1).unwrap();
    block.split("\n```").next().unwrap()
}
Input 17: outline tests/authoring_cli.rs fn[initial_prompt_substitutes_subject_and_mandatory_inputs_into_the_template]
// {test}`requirements.authoring.initial_prompt`
// {test}`requirements.authoring.prompt_parts`
// {test}`requirements.authoring.fixme_inputs`
// {test}`requirements.authoring.invocation`
#[test]
fn initial_prompt_substitutes_subject_and_mandatory_inputs_into_the_template() {
    let template = approved_text("initial_prompt", 0);
    let subject_template = approved_text("initial_prompt", 1);
    for (subject, kind) in [
        (SUBJECT, "requirement"),
        ("requirements.ready_case", "example"),
    ] {
        let server = Server::start(vec![reply(vec![call(
            "submit",
            "submit_judgment",
            json!({"determination":true,"rationale":"covered"}),
        )])]);
        let fixture = Fixture::new(&server.endpoint);
        fs::write(
            fixture.project.join("md/requirements.md"),
            format!(
                ":::{{req}} ready\n{REQUIREMENT}\n:::\n\n:::{{example}} ready_case\nCalling ready succeeds. {{cite}}`requirements.ready`\n:::\n"
            ),
        )
        .unwrap();
        let output = fixture.run(&["author", subject]);
        assert!(output.status.success(), "{output:?}");
        let stdout = String::from_utf8_lossy(&output.stdout);
        assert!(
            stdout.starts_with(&format!("{subject}: ollama / {MODEL}")),
            "{stdout}"
        );
        let evidence_path = stdout
            .lines()
            .find_map(|line| line.strip_prefix("Evidence: "))
            .unwrap();
        assert_eq!(
            std::path::Path::new(evidence_path),
            fixture.project.join(format!("evidence/{subject}.json"))
        );
        let record: Value = serde_json::from_slice(&fs::read(evidence_path).unwrap()).unwrap();
        let field = if kind == "requirement" {
            "requirement"
        } else {
            "example"
        };
        let other = if kind == "requirement" {
            "example"
        } else {
            "requirement"
        };
        assert!(record.get(other).is_none(), "{record}");
        assert_eq!(
            record[field],
            if kind == "requirement" {
                REQUIREMENT
            } else {
                "Calling ready succeeds. {cite}`requirements.ready`"
            }
        );
        let usage_path = stdout
            .lines()
            .find_map(|line| line.strip_prefix("Usage: "))
            .unwrap();
        assert!(std::path::Path::new(usage_path).is_file(), "{stdout}");
        let requests = server.finish();
        let (system, prompt) = opening(&requests[0].body);

        let task = if kind == "requirement" {
            format!(
                "{}\n{}",
                approved_text("requirement_task", 0),
                approved_text("testing_bar", 0)
            )
        } else {
            approved_text("example_task", 0).to_owned()
        };
        // Apart from the substitutions, the system prompt is the first block
        // as written, with nothing that names the subject.
        let expected = template
            .replace("{{subject_kind}}", kind)
            .replace(
                "{{habeas_background}}",
                approved_text("habeas_background", 0),
            )
            .replace("{{reference_roles}}", approved_text("habeas_background", 1))
            .replace("{{subject_task}}", &task)
            .replace("{{judgment_rules}}", approved_text("judgment_rules", 0));
        assert!(!expected.contains("{{"), "{expected}");
        assert_eq!(system, expected);
        assert!(!system.contains(subject), "{system}");
        let acknowledgments: Value = serde_json::from_str(
            prompt
                .split_once("# Acknowledgments\n\n")
                .unwrap()
                .1
                .split_once("\n\n# Mandatory inputs")
                .unwrap()
                .0,
        )
        .unwrap();
        if kind == "requirement" {
            assert_eq!(
                acknowledgments,
                json!([{
                    "body": ":github: example/app#125\n One acknowledged gap.",
                    "file": "src/lib.rs",
                    "issues": [{"reference": "example/app#125", "state": "open"}],
                    "item": "fn[ready]",
                }])
            );
        } else {
            assert_eq!(acknowledgments, json!([]));
        }
        let (before, after) = subject_template.split_once("{{mandatory_inputs}}").unwrap();
        // The subject is not distributed, so its distributed task is empty.
        let before = before
            .replace("{{subject_kind}}", kind)
            .replace("{{subject_name}}", subject)
            .replace("{{distributed_task}}", "")
            .replace(
                "{{acknowledgments}}",
                &serde_json::to_string_pretty(&acknowledgments).unwrap(),
            );
        assert!(
            before.contains(&format!("\nSubject: {kind} {subject}\n")),
            "{before}"
        );
        assert!(!before.contains("{{") && !after.contains("{{"));
        // Apart from the substitutions, the subject message is the second
        // block as written.
        assert!(prompt.starts_with(&before), "{prompt}");
        assert!(prompt.ends_with(after), "{prompt}");
        let rendered = &prompt[before.len()..prompt.len() - after.len()];

        // The mandatory inputs are a JSON array of evidence inputs.
        let inputs: Vec<Value> = serde_json::from_str(rendered).unwrap();
        assert!(!inputs.is_empty());
        for input in &inputs {
            let forms = [
                ("file", &["item", "hash", "text"][..]),
                ("requirements", &["matches", "text"][..]),
                ("definition", &["text"][..]),
            ];
            let matching = forms
                .iter()
                .filter(|(key, _)| input.get(key).is_some())
                .collect::<Vec<_>>();
            assert_eq!(matching.len(), 1, "one evidence-input form: {input}");
            for field in matching[0].1 {
                assert!(input.get(field).is_some(), "{input} lacks {field}");
            }
        }
        let defined = |name: &str| {
            inputs
                .iter()
                .any(|input| input["definition"] == name || input["requirements"] == name)
        };
        assert!(defined(subject), "{inputs:?}");
        if kind == "example" {
            assert!(defined(SUBJECT), "cited requirement supplied: {inputs:?}");
        } else {
            assert!(defined("terms.readiness"), "{inputs:?}");
        }
    }
}
Input 18: outline tests/authoring_cli.rs fn[bedrock_cli_uses_selected_profile_region_and_converse_tools]
// {test}`requirements.authoring.provider`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.authoring.rig_configuration_mapping`
// {test}`requirements.authoring.configuration_precedence`
// {test}`requirements.authoring.initial_prompt`
// {test}`requirements.authoring.usage_requests`
// {test}`requirements.authoring.configuration_storage`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.submission`
// {test}`requirements.authoring.delivered_inputs`
// {test}`requirements.authoring.output_limit`
#[test]
fn bedrock_cli_uses_selected_profile_region_and_converse_tools() {
    for typed in [false, true] {
        let mut read_call = json!({"toolUseId":"bedrock-read","name":"habeas",
        "input":{"file":"extra.txt","line_start":1,"line_end":2}});
        let mut submit_call = json!({"toolUseId":"bedrock-submit","name":"submit_judgment",
        "input":{"determination":true,"rationale":"The supplied sources support the subject."}});
        if typed {
            read_call["type"] = json!("tool_use");
            submit_call["type"] = json!("tool_use");
        }
        let first_message = json!({"role":"assistant","content":[
            {"text":"Reading source."},{"toolUse":read_call}
        ]});
        let server = Server::start(vec![
            json!({
                "output":{"message":first_message.clone()},
                "stopReason":"tool_use",
                "usage":{"inputTokens":19,"outputTokens":5,"totalTokens":24},
                "metrics":{"latencyMs":1}
            }),
            json!({
                "output":{"message":{"role":"assistant","content":[{"toolUse":submit_call}]}},
                "stopReason":"tool_use",
                "usage":{"inputTokens":19,"outputTokens":5,"totalTokens":24},
                "metrics":{"latencyMs":1}
            }),
        ]);
        let fixture = Fixture::new(&server.endpoint);
        let credentials = fixture.temp.path().join("aws-credentials");
        let aws_config = fixture.temp.path().join("aws-config");
        fs::write(&credentials, "[default]\naws_access_key_id = WRONG_DEFAULT_ACCESS_KEY\naws_secret_access_key = wrong-default-secret\n[habeas-test]\naws_access_key_id = FAKE_PROFILE_ACCESS_KEY\naws_secret_access_key = fake-profile-secret-for-local-test-only\n").unwrap();
        fs::write(&aws_config, "[profile habeas-test]\nregion = eu-west-1\n").unwrap();
        fs::write(fixture.config.join("habeas/config.toml"), "version = 1\n[authoring]\ndefault = 'cloud'\n[authoring.configs.cloud]\npolicy = 'once'\nbackend = 'bedrock'\nmodel = 'fixture-bedrock-model'\naws_profile = 'habeas-test'\nregion = 'us-west-2'\n[authoring.configs.cloud.options]\ntemperature = 0.25\nmaxTokens = 321\ntopP = 0.75\nstopSequences = ['END']\ntop_k = 12\n").unwrap();
        let mut command = fixture.command();
        for key in [
            "AWS_ACCESS_KEY_ID",
            "AWS_SECRET_ACCESS_KEY",
            "AWS_SESSION_TOKEN",
            "AWS_SECURITY_TOKEN",
            "AWS_PROFILE",
            "AWS_DEFAULT_PROFILE",
            "AWS_REGION",
            "AWS_DEFAULT_REGION",
            "AWS_ENDPOINT_URL",
            "AWS_IGNORE_CONFIGURED_ENDPOINT_URLS",
            "AWS_BEARER_TOKEN_BEDROCK",
        ] {
            command.env_remove(key);
        }
        let output = command
            .env("AWS_CONFIG_FILE", aws_config)
            .env("AWS_SHARED_CREDENTIALS_FILE", credentials)
            .env("AWS_ENDPOINT_URL_BEDROCK_RUNTIME", &server.endpoint)
            .env("AWS_EC2_METADATA_DISABLED", "true")
            .args(["author-evidence", SUBJECT])
            .output()
            .unwrap();
        assert!(
            output.status.success(),
            "{}",
            String::from_utf8_lossy(&output.stderr)
        );
        let requests = server.finish();
        assert_eq!(requests.len(), 2);
        assert_eq!(requests[1].body["messages"][1], first_message);
        let result = &requests[1].body["messages"][2]["content"][0]["toolResult"];
        assert_eq!(result["toolUseId"], "bedrock-read");
        let delivered = result["content"][0]["text"].as_str().unwrap();
        assert!(delivered.contains("extra.txt") && delivered.contains("context line 1"));
        assert!(
            requests[0]
                .headers
                .starts_with("POST /model/fixture-bedrock-model/converse HTTP/1.1\r\n")
        );
        assert!(
            requests[0]
                .headers
                .contains("Credential=FAKE_PROFILE_ACCESS_KEY/")
        );
        assert!(
            requests[0]
                .headers
                .contains("/us-west-2/bedrock/aws4_request")
        );
        assert!(!requests[0].headers.contains("WRONG_DEFAULT_ACCESS_KEY"));
        let body = &requests[0].body;
        assert_eq!(
            body["inferenceConfig"],
            json!({"temperature":0.25,"maxTokens":321,"topP":0.75,"stopSequences":["END"]})
        );
        // A configured maxTokens is used as given on every request.
        assert_eq!(requests[1].body["inferenceConfig"]["maxTokens"], 321);
        assert_eq!(body["additionalModelRequestFields"], json!({"top_k":12}));
        let prompt = prompt_text(body);
        assert!(
            prompt.contains("Assess whether a project's tests adequately check")
                && prompt.contains(REQUIREMENT)
        );
        let tool_specs = body["toolConfig"]["tools"].as_array().unwrap();
        for tool in tool_specs {
            let schema = &tool["toolSpec"]["inputSchema"]["json"];
            assert_eq!(schema["type"], "object");
            for unsupported in ["oneOf", "allOf", "anyOf"] {
                assert!(
                    schema.get(unsupported).is_none(),
                    "Bedrock rejects {unsupported} at the root of {}'s input schema",
                    tool["toolSpec"]["name"]
                );
            }
        }
        let habeas_schema = &tool_specs
            .iter()
            .find(|tool| tool["toolSpec"]["name"] == "habeas")
            .unwrap()["toolSpec"]["inputSchema"]["json"];
        assert_eq!(habeas_schema["additionalProperties"], false);
        for field in ["file", "item", "requirements", "definition"] {
            assert_eq!(habeas_schema["properties"][field]["type"], "string");
        }
        for field in ["line_start", "line_end"] {
            assert_eq!(habeas_schema["properties"][field]["type"], "integer");
            assert_eq!(habeas_schema["properties"][field]["minimum"], 1);
        }
        let judgment_schema = &tool_specs
            .iter()
            .find(|tool| tool["toolSpec"]["name"] == "submit_judgment")
            .unwrap()["toolSpec"]["inputSchema"]["json"]["properties"]["determination"];
        let outcomes = judgment_schema["oneOf"].as_array().unwrap();
        assert!(outcomes.iter().any(|outcome| outcome["type"] == "boolean"));
        let fixme = &outcomes
            .iter()
            .find(|outcome| outcome["type"] == "object")
            .unwrap()["properties"]["FIXME"];
        assert_eq!(fixme["type"], "array");
        assert_eq!(fixme["minItems"], 1);
        assert_eq!(fixme["items"]["type"], "string");
        assert_eq!(fixme["items"]["minLength"], 1);
        let mut tools = tool_specs
            .iter()
            .map(|tool| tool["toolSpec"]["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 evidence: Value =
            serde_json::from_slice(&fs::read(&fixture.evidence).unwrap()).unwrap();
        assert_eq!(evidence["determination"], true);
        assert!(
            evidence["inputs"]
                .as_array()
                .unwrap()
                .iter()
                .filter(|input| input["file"] == "extra.txt")
                .collect::<Vec<_>>()
                == habeas::outline_inputs_for_lines(&fixture.project, "extra.txt", 1, 2)
                    .unwrap()
                    .iter()
                    .collect::<Vec<_>>()
        );
        let usage = fixture.usage();
        assert_eq!(usage["backend"], "bedrock");
        assert_eq!(usage["model"], "fixture-bedrock-model");
        assert_eq!(usage["tokens"]["input"], 38);
        assert_eq!(usage["tokens"]["output"], 10);
        assert_eq!(usage["request_count"], 2);
        assert_eq!(usage["tool_calls"]["habeas"], 1);
        assert_eq!(usage["tool_calls"]["submit_judgment"], 1);
        assert_eq!(usage["outcome"], "completed");
    }
}

Referenced definitions

Input 2: requirements selection requirements.authoring.prompt_parts
:::{req} prompt_parts
Each assessment conversation MUST send its prompt as a system prompt followed by
one user message, the subject message, filled from the first and second text
blocks of the prompt requirement for the assessment's kind. The kinds are
requirement, example, citation review, site review, and a verifier of each of
those. A system prompt MUST be the same for every assessment of its kind, so
every placeholder whose value depends on the subject MUST be in the subject
message.
:::
Input 3: requirements selection requirements.authoring.habeas_background
:::{req} habeas_background
Every assessment prompt MUST replace `{{habeas_background}}` with the first text
below. The requirement, citation, and verifier prompts MUST replace
`{{reference_roles}}` with the second, except that a verifier checking a site
review MUST replace it with nothing. The site prompt, the distributed task, and a
verifier checking a site review MUST replace `{{distributed_background}}` with
the third. So all assessments share the same account of Habeas's terms:

```text
Habeas traces a project's requirements, written in its mdBook, to the source
code and tests that implement and verify them.

- A requirement is a {req} directive in the book that states obligations with
  MUST, MUST NOT, SHOULD, and MAY. A named example is an {example} directive
  describing a concrete case of one or more requirements. Both have
  dot-separated full names, such as requirements.cli.status. A vocabulary
  definition, a {definition} directive, defines a term that other text uses with
  {term}; it is never the target of a reference.
- Source code marks the requirements and examples it implements, tests, or
  relies on with {impl}, {test}, and {cite} references, such as
  {impl}`requirements.cli.status`, and acknowledges known gaps in them with
  {fixme} references.
- Sources are identified by outline nodes: a file's functions, types, sections,
  and similar items, named by selectors such as fn[run] or impl[Thing]/fn[run].
  <root> is the whole file.
```

```text
The reference roles:

- {impl}: the source implements part of the requirement or example. Source code
  implements part of one when it makes a decision, performs a check, produces an
  output, or handles a case it specifies, or when it constrains a type's fields,
  variants, serialized form, or validation. Calling code that implements it, or
  producing a value a caller uses to meet it, does not by itself count. A check
  counts only if the text states it, or the item could not meet one of the
  text's obligations without it; then returning its outcome counts even when a
  caller acts on it. Code that checks it is consistent with a requirement, such
  as recognizing a form the requirement defines in order to decide whether to
  run other behavior, relies on that requirement ({cite}) rather than
  implementing it. A requirement stating a convention for every output of a
  kind, such as every validation error, is implemented by the code that carries
  out the convention as a whole, not by each item that produces one such output.
  Only a root needs the reference: an item that no other item marked {impl}
  for the same requirement reaches. Code a reviewer reaches by following a
  marked item, through what it calls, the types it uses, or the implementations
  of trait methods it calls, needs none; nor does a test helper reached from a
  test marked {test}. A site of a
  distributed requirement needs no reference to it for being a site.
- {test}: the source is a test or test helper designed to verify behavior the
  requirement or example specifies.
- {cite}: the source relies on or refers to the requirement or example, and
  should be re-checked or kept in sync when it changes, without implementing or
  testing it. A {cite} needs no coverage; each item with citations has its own
  citation review.
- {fixme}: the source acknowledges a known gap in fulfilling the requirement or
  example. It is always fenced; its body describes the gap and may begin with
  lines such as :github: rust-lang/rust#123 naming issues that track it.

A declaration can also name a whole file or one outline node it is implemented
or tested by, with an :impl: or :test: option line directly after its opening
fence; that counts as an {impl} or {test} reference from that source. A
reference written as a fence, :::{role} name, then commentary, then :::,
attaches commentary.
```

```text
A distributed requirement states obligations that each of many sites upholds on
its own. It contains site queries, which select its sites, and violation
queries, which select constructs likely to break those obligations. Each site is
the innermost outline node containing a site-query match.
```
:::
Input 4: requirements selection requirements.authoring.judgment_rules
:::{req} judgment_rules
Every assessment prompt MUST replace `{{judgment_rules}}` with this text, so all
assessments judge by the same rules:

```text
- Derive obligations from the supplied subject and contextual text. Base
  conclusions about tests or other source behavior only on source code you have
  received: mandatory inputs, items read with the habeas tool, or snippets
  returned by ripgrep or ast_grep. Close every delivered search with
  finish_search, recording the tags whose snippets you relied on without an
  additional source read. Supplied acknowledgments establish what a {fixme}
  reference says and which issues it names; they do not establish that its
  claimed gap is real. outline, list_files, and references only locate items;
  read any item whose code your conclusion relies on unless a search snippet
  provides the information you need. Comments state intent; check behavior and
  assertions in the code itself.
- Judge only against the text your task names. Report a gap only where your task
  or these rules define one, naming the obligation and the relevant sources you
  have reviewed. For a missing test, identify the obligation or scenario after
  looking where your task directs; do not invent a source item for absent code.
  Do not report other bugs or issues you notice; edge cases the text does not name are
  not gaps.
- A SHOULD imposes an obligation unless the text or a source comment gives a
  reason it does not apply. In a test-adequacy assessment, apply the testing
  criteria to each applicable SHOULD, and explain any exception in your rationale.
  MAY imposes nothing to check. Examples and sample output inside the text
  illustrate the obligations its prose states; they bind their exact form only
  where the text says the output takes that form.
- If the text admits two readings that its wording supports equally, not merely
  one it fails to exclude, and they lead to different conclusions, such as
  whether code conforms or which role a citation calls for, that ambiguity is a
  gap. Name the readings in your rationale.
- These are not gaps: style, performance, logging, how helpers are factored,
  robustness the text does not require, and silently ignoring input the text
  does not mention.
- A gap is acknowledged only by a {fixme} reference, in the supplied
  acknowledgments, in the inputs, or in a source you read, to the requirement
  or example your task judges against, or,
  in a site review, to the distributed requirement within the site, whose body
  describes that same gap, and whose named issues are open; a {fixme} naming a
  closed issue no longer acknowledges its gap. A plain FIXME or TODO comment is
  not an acknowledgment. Judge an acknowledgment only within your task's scope.
  An acknowledgment of an implementation bug alone does not establish a
  test-adequacy gap or acknowledge a different missing-test or assertion gap.
  Do not inspect implementation correctness merely to validate an out-of-scope
  acknowledgment. In a FIXME determination or an acknowledgments list,
  give each distinct issue its :github: option names once, such as
  "rust-lang/rust#123", and, for a {fixme} naming no issue, its body's words
  joined by single spaces. A {fixme} describing a gap that your review establishes
  no longer exists within its task's scope is itself a gap.
- Explain your judgment in a Markdown rationale with source locations, including
  any acknowledged gaps.
- Give a source location as its file and outline selector, the address the
  habeas and outline tools use, in backticks: `src/config.rs#fn[load]`, or
  `src/config.rs` for a whole file. Name requirements, examples, and
  definitions by full name in backticks. Name functions, types, and tests in
  backticks exactly as they are written. Do not give line numbers: they change
  whenever nearby code changes, while a selector stays correct.
```
:::
Input 5: requirements selection requirements.authoring.fixme_inputs
:::{req} fixme_inputs
For a requirement or example assessment, the initial request MUST include every
valid named `{fixme}` reference to the subject found under
{cite}`requirements.references.discovery`, except a reference inside one of
the subject's sites under {cite}`requirements.references.site_review`, in this
form:

```text
Acknowledgment {
    file: String,
    item: String,
    body: String,
    issues: Array<{ reference: String, state: "open" | "closed" }>,
}
```

`file` and `item` MUST locate the containing source by project-relative path and
outline selector, using `<root>` for a whole file. `body` MUST contain the
reference's complete fenced commentary without its fences or source-comment
delimiters, including its option lines, redacted under
{cite}`requirements.authoring.redaction`. `issues` MUST give every distinct issue
its `:github:` lines name, in their order, with state supplied under
{cite}`requirements.authoring.github_reads`. Acknowledgments MUST be ordered by
file and position in the file and MUST carry no line numbers or containing
implementation source.

The locations and bodies MUST be protected against staleness by the reference-set
digest under {cite}`requirements.ci.reference_set`; the acknowledgment MUST NOT
create an outline input merely to cover its containing source. Actual reads of
that source MUST still be recorded under
{cite}`requirements.authoring.delivered_inputs`. Sources MUST satisfy
{cite}`requirements.authoring.source_tools`; an inaccessible acknowledgment
MUST be reported before inference.

Terminology definitions referenced by an acknowledgment's body MUST contribute
their complete, transitive declarations to the mandatory input set under
{cite}`requirements.definitions.authoring_inputs` and MUST be recorded as
definition inputs. Only the acknowledgment's body MUST contribute these
dependencies; its containing implementation source MUST NOT be supplied merely
to discover them.
:::
Input 6: requirements selection requirements.authoring.requirement_task
:::{req} requirement_task
The requirement task of {cite}`requirements.authoring.initial_prompt` MUST be
this text, the steps a requirement's review follows to assess test adequacy:

```text
1. Derive testable obligations and expected outcomes from each MUST, MUST NOT,
   and SHOULD clause. Separate independent conditions and properties while
   preserving alternatives the text permits. Identify ambiguities separately.
2. Identify relevant input classes, boundaries, condition combinations, and
   state transitions from the requirement. Use only distinctions that affect
   an obligation; do not invent required behavior for unspecified inputs.
3. Read the supplied tests and request helpers or fixtures needed to understand
   their inputs and assertions. Use targeted discovery to look for relevant
   tests before reporting a missing scenario.
4. Map each obligation assessed here to concrete test scenarios and assertions
   in your rationale. Identify obligations delegated to a refining requirement
   or a distributed site's review, and any established testing exemptions,
   separately. Check both whether the expected result is correct under the
   requirement and whether the assertions enforce it. Execution without a
   relevant assertion does not establish adequacy; assertions in helpers,
   snapshots, and parameterized or property tests can do so.
5. For each proposed adequacy gap, describe plausible requirement-violating
   behavior that the reviewed tests would accept. Cite the requirement clause
   and explain why the tested inputs or assertions would miss it. A wrong
   expected result is a gap too: explain how the assertion contradicts the
   requirement rather than claiming it proves a missing scenario.
   Explain the requirement-relevant distinction the counterexample exposes.
   Another untested value in an already represented input class is not a gap
   without explaining why it could expose different required behavior.
6. Check whether another reviewed test or helper already rules out that
   behavior. Report unresolved questions separately from established gaps.
   If information needed to decide adequacy remains unavailable, choose false
   and explain what is missing without inventing a behavioral gap.
   A relevant test without a {test} reference to the subject is a marking gap;
   a helper reached from a marked test needs no reference of its own. Do not
   confuse marking gaps with inadequate assertions.
7. Request implementation source only to resolve a specific question, stating
   that question in your rationale. Derive expected behavior from the
   requirement, not the implementation. Do not assess implementation
   correctness, implementation reachability, or unspecified implementation
   behavior as additional tasks.
```
:::
Input 7: 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 8: requirements selection requirements.authoring.example_task
:::{req} example_task
For a named example, the task of {cite}`requirements.authoring.initial_prompt`
MUST be this text:

```text
The subject is a named example. First check that it describes a concrete case
with expected behavior; a missing concrete case or expected behavior is a gap.
Read its supplied tests and request helpers or
fixtures needed to understand their setup and assertions. Check that they cover
its scenario and assert each expected outcome it states, with expected results
derived from the example and its referenced requirements. Say which inputs and
assertions check each outcome. For a proposed gap, describe requirement-violating
behavior those tests would accept, or an assertion whose expected result
contradicts the example. Check whether another reviewed test or helper resolves
the gap, and report unresolved questions separately. Request implementation
source only for a specific question, stating it in your rationale.
If information needed to decide adequacy remains unavailable, choose false and
explain what is missing without inventing a behavioral gap.
A true judgment needs at least one {test} reference to the example in the
mandatory inputs; choose true when the tests adequately check it.
```
:::
Input 9: requirements selection requirements.authoring.distributed_task
:::{req} distributed_task
For a distributed requirement under {cite}`requirements.references.distributed`,
the subject message of {cite}`requirements.authoring.initial_prompt` MUST
include this text, which continues the requirement task to assess the
requirement's queries:

```text
{{distributed_background}} Each query is an ast-grep rule with match and
no_match snippets.

This subject is a distributed requirement. Its sites need no {impl} reference
and each has its own review, so do not vet them. Also assess the requirement and
its queries:

8. Each obligation must be either one that each site upholds on its own, or one
   that particular code carries out, whose tests you assess under 1 to 7 and the
   testing criteria. An obligation that
   neither covers is a gap.
9. The site queries must select every place the text's description of a site
   covers, and no place outside the requirement's stated scope. Run each site
   query once with ast_grep by its name, <subject>/<query>, scan its matches,
   and search briefly for the construct the text describes to find places the
   queries miss. Obligations that decide which places are sites, such as how a
   variable is named, are checked by this search.
10. Judge whether each query's conditions are adequately tested by its
   snippets, as you would judge tests of code: its match snippets should show
   what it selects, and its no_match snippets nearby code it must not select.
   A condition without a snippet of its own is not by itself a gap. This
   applies to violation queries too.

Queries are heuristics, so judge them by a preponderance of the evidence: is it
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 selects
outside the requirement's scope, is a gap; a form that does not occur in the
sources is not. A violation query that misses constructs is not a gap; note what
it misses.
```
:::
Input 10: requirements selection requirements.examples.evidence
:::{req} evidence
Every defined example MUST have an `evidence/<full-example-name>.json` file whose `example` string exactly matches the current example body. A true determination MUST have at least one `{test}` reference to the example, covered by an evidence input. The reviewer MUST assess its tests under {cite}`requirements.ci.review_criteria` and use the outcomes defined by {cite}`requirements.ci.outcomes`; the no-test justification for a requirement MUST NOT establish a true example judgment. Habeas MUST apply the same missing-evidence, determination, input validation, and reference-coverage checks used for requirements. It MUST report a true determination with no test reference and changed example text with a compact line-oriented diff.
:::
Input 11: 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.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}}
```
:::