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

Requirements index · View definition

evidence Valid

Requirement

The harness MUST expose a submit_judgment tool accepting exactly these fields:

submit_judgment({ determination: Judgment, rationale: String })

Judgment = Boolean | { FIXME: Array<String> }

The judgment MUST use the three outcomes and nonempty FIXME entries defined by cite requirements.ci.outcomes. rationale MUST be nonempty Markdown. This tool call MUST supply the final assessment result. The model MUST obtain exactly one accepted submission over the entire assessment. Rejected attempts under cite requirements.authoring.submission.searches.recovery and cite requirements.authoring.line_numbers.rejection do not count as accepted submissions. If a response ends without invoking it, and the assessment has not already been reminded, the harness MUST continue the conversation with one user message, Reminder: you MUST submit your result with the submit_judgment tool., naming the assessment’s submission tool. If a later response also ends without invoking it, or a response contains multiple submission calls, the harness MUST report an error and leave existing evidence unchanged. The reminder MUST be counted in usage like any other turn. The harness MUST check the complete model response for multiple submissions before accepting one. Invalid submission arguments MUST also fail the assessment. A valid single submission MUST finish the assessment; there is no submission repair or resubmission loop, except the one continuation after a response cut off at its output limit under cite requirements.authoring.output_limit, the one reminder above, and the one resubmission after a rejection under cite requirements.authoring.line_numbers.rejection, and recovery under cite requirements.authoring.submission.searches.recovery. An assessment that fails before accepting a valid judgment MUST emit no evidence JSON to stdout.

Rationale

I judge that the reviewed tests adequately check requirements.authoring.submission. I read only the supplied test sources and did not request implementation source.

Tool shape. src/authoring/mod.rs#mod[tests]/fn[submit_judgment_is_advertised_with_exactly_its_two_fields] checks the advertised schema.

  • It asserts additionalProperties is false.
  • It asserts required is exactly determination and rationale, and that those are the only properties.
  • It asserts the rationale schema is a string with minLength 1, and that the boolean branch of determination is present.
  • tests/authoring_cli.rs#fn[bedrock_cli_uses_selected_profile_region_and_converse_tools] checks the FIXME branch: an array with minItems 1 and string items with minLength 1. It also checks that the tool list includes submit_judgment.

Judgment outcomes and arguments. src/authoring/mod.rs#mod[tests]/fn[submissions_accept_exactly_a_judgment_and_a_nonempty_rationale] covers both the accepted and the rejected inputs.

  • It accepts true, false and a nonempty FIXME array, and checks the parsed judgment and the rationale.
  • It rejects non-object arguments, missing or extra fields, string, numeric and null determinations, empty or non-array FIXME values, and empty, blank and numeric FIXME entries.
  • It rejects extra keys inside the determination object, an empty determination object, and an empty, whitespace-only or non-string rationale.

Single accepted submission and finishing. src/authoring/mod.rs#mod[tests]/fn[a_submission_finishes_the_assessment_wherever_it_arrives] covers these cases:

  • A submission after earlier tool turns is accepted.
  • A submission before or after other calls in the same response is accepted, and the other calls are skipped (checked through tool_skipped and the absence of delivered inputs).
  • Multiple submissions anywhere in one response fail even when the first is valid, which checks the whole response before accepting.
  • Invalid arguments fail with no retry; the request count stays at the first turn.
  • Line-number rationales do not trigger the rejection path when the submission is invalid or duplicated.

Reminder. src/authoring/mod.rs#mod[tests]/fn[a_response_without_a_submission_is_reminded_once] covers the reminder.

  • It checks the exact reminder text, which names submit_judgment.
  • It checks the reminder is sent once and the first request has none.
  • It checks both turns are counted in usage.
  • It checks success when the next response submits.
  • It checks an error (“even after a reminder”) when a later response also lacks a submission, including after an intervening tool turn.

Search gate and recovery. src/authoring/mod.rs#mod[tests]/fn[the_search_gate_validates_arguments_first_and_does_not_consume_the_reminder] covers three behaviors. Malformed arguments fail on validation, not on outstanding searches. A valid submission with outstanding searches leaves the assessment open. After the searches are finished, the next submission is accepted, and the reminder is not consumed by the rejection.

Rejection and resubmission. src/authoring/mod.rs#mod[tests]/fn[a_rationale_citing_line_numbers_is_rejected_once] covers the three resubmission cases.

  • Resubmitting with the exact UUID as the rationale keeps the rejected submission, and the UUID is not recorded.
  • A rationale without line numbers replaces it.
  • Line numbers again fail the assessment.
  • It also checks that the rejection quotes the citation, repeats the location guidance, and counts both turns in usage.

Failure leaves evidence unchanged and stdout empty. tests/authoring_cli.rs#fn[missing_duplicate_and_invalid_submissions_preserve_existing_evidence] runs the CLI with no submission, duplicate submissions, an invalid rationale and an empty FIXME array.

  • It runs each case in both file and --stdout modes.
  • It asserts a non-success exit, empty stdout, unchanged evidence file, evidence_written false and a null determination.
  • It asserts two requests (reminder) for the no-submission case and one request (no retry) otherwise.

Output-limit continuation exception. tests/authoring_cli.rs#fn[a_response_cut_off_at_the_output_limit_is_continued_once] covers the single continuation after a cut-off response. The cut-off submission is not executed, and the conversation resumes with the limit note. The second-cut-off failure belongs to requirements.authoring.output_limit, which has its own review.

Acceptance and usage. The Bedrock CLI test and fn[live_bedrock_authoring] check an accepted submission end to end, including the final evidence determination and usage counts.

Cited requirements. The cited rules are covered by their own reviews. The submission-side behavior (finishing on a valid submission, and one resubmission after a rejection) is exercised above.

Markdown. The “Markdown” part of the rationale has no testable constraint beyond being a nonempty string, which is tested.

I found no untested obligation and no assertion that contradicts the requirement text.

Inputs

Tests

Input 6: outline src/authoring/mod.rs mod[tests]/struct[JudgmentProvider]
    // {test}`requirements.authoring.submission`
    struct JudgmentProvider(Value);
Input 7: outline src/authoring/mod.rs mod[tests]/impl[JudgmentProvider/CompletionProvider]/fn[complete]
        // {test}`requirements.authoring.submission`
        async fn complete(&self, _request: CompletionRequest) -> io::Result<CompletionResponse> {
            Ok(CompletionResponse::new(
                vec![AssistantContent::ToolCall(ToolCall::from_wire(
                    "judgment",
                    ToolFunction::new(
                        ToolName::new("submit_judgment").unwrap(),
                        json!({"determination": self.0, "rationale": "The supplied source implements the requirement."}),
                    ),
                ))],
                Usage::default(),
                Origin::new("fixture", "fixture", "fixture"),
                Value::Null,
            ).with_finish_reason(FinishReason::ToolCalls))
        }
Input 8: outline src/authoring/mod.rs mod[tests]/fn[submissions_accept_exactly_a_judgment_and_a_nonempty_rationale]
    // {test}`requirements.authoring.submission`
    #[test]
    fn submissions_accept_exactly_a_judgment_and_a_nonempty_rationale() {
        for (determination, expected) in [
            (json!(true), Judgment::True),
            (json!(false), Judgment::False),
            (
                json!({"FIXME": ["#125", "gap"]}),
                Judgment::Fixme(vec!["#125".into(), "gap".into()]),
            ),
        ] {
            let (judgment, rationale) =
                submission(&json!({"determination": determination, "rationale": "**Done.**"}))
                    .unwrap();
            assert_eq!(judgment, expected);
            assert_eq!(rationale, "**Done.**");
        }
        for arguments in [
            json!("true"),
            json!([true, "rationale"]),
            json!({}),
            json!({"rationale": "Missing determination."}),
            json!({"determination": true}),
            json!({"determination": true, "rationale": "Extra.", "confidence": 1}),
            json!({"determination": "true", "rationale": "String judgment."}),
            json!({"determination": 1, "rationale": "Numeric judgment."}),
            json!({"determination": null, "rationale": "Null judgment."}),
            json!({"determination": {"FIXME": []}, "rationale": "Empty FIXME."}),
            json!({"determination": {"FIXME": "#1"}, "rationale": "Not an array."}),
            json!({"determination": {"FIXME": [""]}, "rationale": "Empty entry."}),
            json!({"determination": {"FIXME": ["  "]}, "rationale": "Blank entry."}),
            json!({"determination": {"FIXME": [1]}, "rationale": "Numeric entry."}),
            json!({"determination": {"FIXME": ["#1"], "note": "x"}, "rationale": "Extra key."}),
            json!({"determination": {}, "rationale": "Empty object."}),
            json!({"determination": true, "rationale": ""}),
            json!({"determination": true, "rationale": " \n\t"}),
            json!({"determination": true, "rationale": 7}),
        ] {
            assert!(submission(&arguments).is_err(), "accepted {arguments}");
        }
    }
Input 9: outline src/authoring/mod.rs mod[tests]/fn[submit_judgment_is_advertised_with_exactly_its_two_fields]
    // {test}`requirements.authoring.submission`
    #[test]
    fn submit_judgment_is_advertised_with_exactly_its_two_fields() {
        let definitions = serde_json::to_value(tool_definitions().unwrap()).unwrap();
        let submit = definitions
            .as_array()
            .unwrap()
            .iter()
            .find(|definition| definition["name"] == "submit_judgment")
            .expect("submit_judgment is advertised");
        let parameters = &submit["parameters"];
        assert_eq!(parameters["type"], "object");
        assert_eq!(parameters["additionalProperties"], false);
        assert_eq!(
            parameters["required"],
            json!(["determination", "rationale"])
        );
        assert_eq!(
            parameters["properties"]
                .as_object()
                .unwrap()
                .keys()
                .collect::<Vec<_>>(),
            ["determination", "rationale"]
        );
        assert_eq!(
            parameters["properties"]["rationale"],
            json!({"type": "string", "minLength": 1})
        );
        assert_eq!(
            parameters["properties"]["determination"]["oneOf"][0],
            json!({"type": "boolean"})
        );
        assert!(
            submit["description"]
                .as_str()
                .unwrap()
                .contains("until one submission is accepted")
        );
    }
Input 10: outline src/authoring/mod.rs mod[tests]/fn[the_search_gate_validates_arguments_first_and_does_not_consume_the_reminder]
  • File: src/authoring/mod.rs
  • Selector: mod[tests]/fn[the_search_gate_validates_arguments_first_and_does_not_consume_the_reminder]
  • Kind: fn
  • src/authoring/mod.rs:3097–3151
    // {test}`requirements.authoring.submission.searches.line_numbers`
    // {test}`requirements.authoring.submission`
    #[tokio::test]
    async fn the_search_gate_validates_arguments_first_and_does_not_consume_the_reminder() {
        use SearchAction::{Call, Finish};
        for malformed in [true, false] {
            let root = inputs::tests::project();
            fs::write(root.path().join("src/lib.rs"), "fn helper() {}\n").unwrap();
            let mut sources =
                AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
            let state = tempfile::tempdir().unwrap();
            let mut usage =
                UsageLog::start(state.path(), root.path(), &sources.subject_name).unwrap();
            let valid = json!({"determination":true,"rationale":"Complete."});
            let mut turns = vec![
                vec![Call("ripgrep", json!({"pattern":"absent"}))],
                vec![Call(
                    "submit_judgment",
                    if malformed {
                        json!({"determination":true,"rationale":""})
                    } else {
                        valid.clone()
                    },
                )],
            ];
            if !malformed {
                turns.extend([
                    vec![],
                    vec![Finish(0, vec![])],
                    vec![Call("submit_judgment", valid)],
                ]);
            }
            let provider = SearchProvider {
                submit: "submit_judgment",
                turns,
                requests: RefCell::default(),
            };
            let result = assess(&provider, &mut sources, &mut usage).await;
            if malformed {
                let error = result.unwrap_err().to_string();
                assert!(error.contains("rationale"), "{error}");
                assert!(!error.contains("outstanding searches"), "{error}");
                assert_eq!(provider.requests.borrow().len(), 2);
                assert!(usage.record.determination.is_none());
            } else {
                assert_eq!(result.unwrap().0, Judgment::True);
                assert_eq!(provider.requests.borrow().len(), 5);
                assert!(
                    provider.requests.borrow()[3]
                        .to_string()
                        .contains("Reminder:")
                );
            }
        }
    }
Input 11: outline src/authoring/mod.rs mod[tests]/fn[a_rationale_citing_line_numbers_is_rejected_once]
    // {test}`requirements.authoring.line_numbers.rejection`
    // {test}`requirements.authoring.line_numbers.resubmission`
    // {test}`requirements.authoring.submission`
    #[tokio::test]
    async fn a_rationale_citing_line_numbers_is_rejected_once() {
        let cited = json!({"determination": false, "rationale": "`work` at src/lib.rs:1 fails."});
        type Next = fn(&str) -> Value;
        let uuid = regex::Regex::new(r"[0-9a-f]{8}-[0-9a-f]{4}-").unwrap();
        let cases: [(Next, Option<&str>); 3] = [
            // Exactly the UUID keeps the rejected submission.
            (
                |uuid| json!({"determination": true, "rationale": uuid}),
                Some("`work` at src/lib.rs:1 fails."),
            ),
            // A rationale without line numbers replaces it.
            (
                |_| json!({"determination": false, "rationale": "`src/lib.rs#fn[work]` fails."}),
                Some("`src/lib.rs#fn[work]` fails."),
            ),
            // Line numbers again fail the assessment.
            (
                |_| json!({"determination": false, "rationale": "Line 1 fails."}),
                None,
            ),
        ];
        for (next, accepted) in cases {
            let project = inputs::tests::project();
            fs::write(project.path().join("src/lib.rs"), "fn work() {}\n").unwrap();
            let mut sources =
                AssessmentSources::prepare(project.path(), "requirements.ready").unwrap();
            let state = tempfile::tempdir().unwrap();
            let mut usage =
                UsageLog::start(state.path(), project.path(), &sources.subject_name).unwrap();
            let provider = ResubmittingProvider {
                first: cited.clone(),
                next,
                requests: RefCell::default(),
            };
            let result = assess(&provider, &mut sources, &mut usage).await;
            let requests = provider.requests.borrow();
            assert_eq!(requests.len(), 2);
            // The rejection quotes the citation and repeats the guidance.
            assert!(requests[1].contains("src/lib.rs:1"), "{}", requests[1]);
            assert!(
                requests[1].contains("Give a source location"),
                "{}",
                requests[1]
            );
            // Both turns are counted in usage.
            let record = serde_json::to_value(&usage.record).unwrap();
            assert_eq!(
                record["requests"].as_array().unwrap().len(),
                2,
                "{record:#}"
            );
            match accepted {
                Some(rationale) => {
                    let (_, evidence) = result.unwrap();
                    assert_eq!(evidence["rationale"], rationale);
                    // The UUID is not recorded.
                    assert!(!uuid.is_match(&evidence.to_string()), "{evidence}");
                }
                None => {
                    let error = result.unwrap_err().to_string();
                    assert!(error.contains("after a rejection"), "{error}");
                }
            }
        }
    }
Input 12: outline src/authoring/mod.rs mod[tests]/fn[a_response_without_a_submission_is_reminded_once]
    // {test}`requirements.authoring.submission`
    // {test}`requirements.authoring.submission_count`
    #[tokio::test]
    async fn a_response_without_a_submission_is_reminded_once() {
        let submit = json!({"determination": true, "rationale": "Fine."});
        for (turns, accepted, count) in [
            (
                vec![vec![], vec![("submit_judgment", submit.clone())]],
                true,
                2,
            ),
            (vec![vec![], vec![]], false, 2),
            (
                vec![
                    vec![],
                    vec![("habeas", json!({"file":"src/lib.rs","item":"fn[work]"}))],
                    vec![],
                ],
                false,
                3,
            ),
        ] {
            let project = inputs::tests::project();
            fs::write(project.path().join("src/lib.rs"), "fn work() {}\n").unwrap();
            let mut sources =
                AssessmentSources::prepare(project.path(), "requirements.ready").unwrap();
            let state = tempfile::tempdir().unwrap();
            let mut usage =
                UsageLog::start(state.path(), project.path(), &sources.subject_name).unwrap();
            let provider = RemindedProvider {
                turns,
                requests: RefCell::default(),
            };
            let result = assess(&provider, &mut sources, &mut usage).await;
            let requests = provider.requests.borrow();
            assert_eq!(requests.len(), count);
            assert!(!requests[0].contains("Reminder:"));
            assert!(
                requests[1].contains(
                    "Reminder: you MUST submit your result with the submit_judgment tool."
                ),
                "{}",
                requests[1]
            );
            // Both turns are counted in usage.
            let record = serde_json::to_value(&usage.record).unwrap();
            assert_eq!(record["requests"].as_array().unwrap().len(), count);
            assert_eq!(
                requests
                    .last()
                    .unwrap()
                    .matches("Reminder: you MUST")
                    .count(),
                1
            );
            if accepted {
                assert_eq!(result.unwrap().1["rationale"], "Fine.");
            } else {
                let error = result.unwrap_err().to_string();
                assert!(error.contains("even after a reminder"), "{error}");
            }
        }
    }
Input 13: outline src/authoring/mod.rs mod[tests]/fn[a_submission_finishes_the_assessment_wherever_it_arrives]
    // {test}`requirements.authoring.submission`
    // {test}`requirements.authoring.line_numbers.rejection`
    // {test}`requirements.authoring.submission.searches.accompanying_calls`
    #[tokio::test]
    async fn a_submission_finishes_the_assessment_wherever_it_arrives() {
        let read = json!({"file": "src/lib.rs", "item": "fn[work]"});
        let submit = json!({"determination": false, "rationale": "Gaps remain."});
        let invalid = json!({"determination": "false", "rationale": "Gaps remain."});
        let cited = json!({"determination": false, "rationale": "See line 10."});
        let invalid_cited = json!({"determination": "false", "rationale": "See line 10."});
        for (turns, accepted, requests) in [
            // After earlier tool turns.
            (
                vec![
                    vec![("habeas", read.clone())],
                    vec![("habeas", read.clone())],
                    vec![("submit_judgment", submit.clone())],
                ],
                true,
                3,
            ),
            // Alongside other tool calls in the same response, before or after
            // them: the submission finishes and the other calls are skipped.
            (
                vec![vec![
                    ("habeas", read.clone()),
                    ("submit_judgment", submit.clone()),
                ]],
                true,
                1,
            ),
            (
                vec![vec![
                    ("submit_judgment", submit.clone()),
                    ("ripgrep", json!({"pattern": "work"})),
                ]],
                true,
                1,
            ),
            // Multiple submissions anywhere in one response fail even when the
            // first is valid, and invalid arguments fail without a retry.
            (
                vec![vec![
                    ("submit_judgment", submit.clone()),
                    ("habeas", read.clone()),
                    ("submit_judgment", submit.clone()),
                ]],
                false,
                1,
            ),
            (
                vec![
                    vec![("habeas", read.clone())],
                    vec![("submit_judgment", invalid.clone())],
                    vec![("submit_judgment", submit.clone())],
                ],
                false,
                2,
            ),
            (
                vec![vec![
                    ("submit_judgment", cited.clone()),
                    ("submit_judgment", cited.clone()),
                ]],
                false,
                1,
            ),
            (vec![vec![("submit_judgment", invalid_cited)]], false, 1),
        ] {
            let project = inputs::tests::project();
            fs::write(project.path().join("src/lib.rs"), "fn work() {}\n").unwrap();
            let mut sources =
                AssessmentSources::prepare(project.path(), "requirements.ready").unwrap();
            let state = tempfile::tempdir().unwrap();
            let mut usage =
                UsageLog::start(state.path(), project.path(), &sources.subject_name).unwrap();
            let provider = ScriptedProvider {
                turns: turns.clone(),
                requests: RefCell::default(),
            };
            let result = assess(&provider, &mut sources, &mut usage).await;
            assert_eq!(*provider.requests.borrow(), requests, "{turns:?}");
            let record = serde_json::to_value(&usage.record).unwrap();
            if accepted {
                let (judgment, evidence) = result.unwrap();
                assert_eq!(judgment, Judgment::False);
                assert_eq!(evidence["rationale"], "Gaps remain.");
                let last = turns.last().unwrap();
                if last.len() > 1 {
                    // The other calls in the submitting response were skipped,
                    // not run, so they delivered no inputs.
                    let skipped = record["tool_skipped"].as_object().unwrap();
                    assert_eq!(
                        skipped.values().filter_map(Value::as_u64).sum::<u64>(),
                        1,
                        "{record:#}"
                    );
                    assert!(record["tool_failures"].as_object().unwrap().is_empty());
                    assert!(
                        evidence["inputs"]
                            .as_array()
                            .unwrap()
                            .iter()
                            .all(|input| input["file"] != "src/lib.rs"),
                        "{evidence}"
                    );
                }
            } else {
                let error = result.unwrap_err().to_string();
                assert!(!error.contains("line numbers"), "{turns:?}: {error}");
                if turns.last().unwrap().len() > 1 {
                    assert!(error.contains("exactly once"), "{error}");
                } else {
                    assert!(error.contains("expected true, false"), "{error}");
                }
            }
        }
    }
Input 14: outline tests/authoring_cli.rs fn[missing_duplicate_and_invalid_submissions_preserve_existing_evidence]
// {test}`requirements.authoring.submission_count`
// {test}`requirements.authoring.submission`
// {test}`requirements.authoring.usage_storage`
#[test]
fn missing_duplicate_and_invalid_submissions_preserve_existing_evidence() {
    let valid =
        json!({"determination":true,"rationale":"The reviewed sources support the subject."});
    for calls in [
        vec![],
        vec![
            call("one", "submit_judgment", valid.clone()),
            call("two", "submit_judgment", valid),
        ],
        vec![call(
            "bad",
            "submit_judgment",
            json!({"determination":true,"rationale":""}),
        )],
        vec![call(
            "empty",
            "submit_judgment",
            json!({"determination":{"FIXME":[]},"rationale":"No gap identified."}),
        )],
    ] {
        for stdout in [false, true] {
            let count = if calls.is_empty() { 2 } else { 1 };
            let server = Server::start(vec![reply(calls.clone()); count]);
            let fixture = Fixture::new(&server.endpoint);
            let mut args = vec!["author-evidence", SUBJECT];
            if stdout {
                args.push("--stdout");
            }
            let output = fixture.run(&args);
            assert!(!output.status.success());
            assert!(output.stdout.is_empty());
            assert_eq!(server.finish().len(), count);
            if calls.is_empty() {
                assert!(String::from_utf8_lossy(&output.stderr).contains("even after a reminder"));
            }
            assert_eq!(
                fs::read_to_string(&fixture.evidence).unwrap(),
                fixture.original
            );
            let usage = fixture.usage();
            assert_eq!(usage["outcome"], "failed");
            assert_eq!(
                usage["evidence_output"],
                if stdout { "stdout" } else { "file" }
            );
            assert_eq!(usage["evidence_written"], false);
            // A response without a submission is reminded once.
            assert_eq!(usage["request_count"], if calls.is_empty() { 2 } else { 1 });
            assert!(usage["determination"].is_null());
        }
    }
}
Input 15: 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");
    }
}
Input 16: outline tests/authoring_cli.rs fn[a_response_cut_off_at_the_output_limit_is_continued_once]
// {test}`requirements.authoring.output_limit`
// {test}`requirements.authoring.submission`
#[test]
fn a_response_cut_off_at_the_output_limit_is_continued_once() {
    let mut cut_off = cut_off_submission("cut");
    cut_off["output"]["message"]["content"].as_array_mut().unwrap().push(
        json!({"toolUse":{"toolUseId":"read-cut","name":"habeas","input":{"file":"src/lib.rs"}}}),
    );
    let (output, bodies, usage) = bedrock_exchange(
        "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
        vec![
            cut_off,
            json!({
                "output":{"message":{"role":"assistant","content":[{"toolUse":
                    {"toolUseId":"submit","name":"submit_judgment","input":
                        {"determination":true,"rationale":"Short."}}}]}},
                "stopReason":"tool_use",
                "usage":{"inputTokens":9,"outputTokens":5,"totalTokens":14},
                "metrics":{"latencyMs":1}
            }),
        ],
    );
    assert!(
        output.status.success(),
        "{}",
        String::from_utf8_lossy(&output.stderr)
    );
    let bodies: Vec<_> = bodies.iter().map(without_cache_points).collect();
    assert_eq!(bodies.len(), 2);
    // The same conversation continues: the cut-off turn as sent, then one
    // user message answering its incomplete call and carrying the note.
    let first = bodies[0]["messages"].as_array().unwrap();
    let second = bodies[1]["messages"].as_array().unwrap();
    assert_eq!(second.len(), first.len() + 2);
    assert_eq!(&second[..first.len()], first.as_slice());
    let cut = &second[first.len()];
    assert_eq!(cut["role"], "assistant");
    assert_eq!(cut["content"][1]["toolUse"]["toolUseId"], "cut");
    let note = &second[first.len() + 1];
    assert_eq!(note["role"], "user");
    let content = note["content"].as_array().unwrap();
    assert_eq!(content.len(), 3, "{note}");
    assert_eq!(content[0]["toolResult"]["toolUseId"], "cut");
    assert_eq!(content[0]["toolResult"]["status"], "error");
    assert!(
        content[0]["toolResult"].to_string().contains("not run"),
        "{note}"
    );
    assert_eq!(content[1]["toolResult"]["toolUseId"], "read-cut");
    assert_eq!(content[1]["toolResult"]["status"], "error");
    assert!(
        content[1]["toolResult"].to_string().contains("not run"),
        "{note}"
    );
    assert_eq!(content[2]["text"], LIMIT_NOTE);
    // Both requests are recorded, and the cut-off call never ran.
    assert_eq!(usage["request_count"], 2);
    assert_eq!(usage["requests"].as_array().unwrap().len(), 2);
    assert_eq!(usage["tool_calls"]["submit_judgment"], 2);
    assert_eq!(usage["tool_skipped"]["submit_judgment"], 1);
    assert_eq!(usage["tool_skipped"]["habeas"], 1);
    assert_eq!(usage["outcome"], "completed");
}
Input 17: outline tests/live_bedrock.rs fn[live_bedrock_authoring]
// {test}`requirements.integration.live_bedrock_test`
// {test}`requirements.authoring.delivered_inputs`
// {test}`requirements.authoring.provider`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.submission`
// {test}`requirements.authoring.persistence`
// {test}`requirements.authoring.usage_storage`
// {impl}`requirements.integration.live_bedrock_test`
#[test]
fn live_bedrock_authoring() {
    if std::env::var_os("CI").is_some() {
        report("warning: skipping live Bedrock test: CI is set");
        return;
    }
    let LiveSelection {
        config: selected,
        workspace,
    } = selected_config()
        .expect("cannot select live Bedrock configuration")
        .expect("no Bedrock authoring configuration; add one to your Habeas user config (see md/reference.md), or set CI=1 to disable live testing");
    let BackendConfig::Bedrock(backend) = &selected.backend else {
        unreachable!("selection only returns Bedrock configurations");
    };
    if !credentials_available(backend) {
        return;
    }
    report(format!(
        "live Bedrock test: configuration {:?}, model {:?}",
        selected.name, backend.model
    ));

    let temp = tempfile::tempdir().unwrap();
    let project = temp.path().join("project");
    for directory in [project.join("md"), project.join("src")] {
        fs::create_dir_all(directory).unwrap();
    }
    fs::write(
        project.join("Cargo.toml"),
        "[package]\nname = 'live-fixture'\nversion = '0.1.0'\nedition = '2024'\n",
    )
    .unwrap();
    fs::write(project.join("book.toml"), "[book]\nsrc = 'md'\n").unwrap();
    if let Some(workspace) = &workspace {
        fs::write(project.join("habeas.toml"), workspace).unwrap();
    }
    fs::write(
        project.join("md/SUMMARY.md"),
        "# Summary\n\n- [Requirements](requirements.md)\n",
    )
    .unwrap();
    fs::write(
        project.join("md/requirements.md"),
        format!(":::{{req}} parity\n{REQUIREMENT}\n:::\n"),
    )
    .unwrap();
    // No citation points to this file, so assessing its implementation requires
    // an additional source read instead of only the mandatory initial inputs.
    fs::write(project.join("src/parity.rs"), "pub fn is_even(value: u32) -> bool {\n    value % 2 == 0\n}\n\n#[test]\nfn parity_cases() {\n    assert!(is_even(0));\n    assert!(!is_even(1));\n    assert!(is_even(2));\n    assert!(!is_even(u32::MAX));\n}\n").unwrap();
    let checkout_evidence = Path::new(env!("CARGO_MANIFEST_DIR")).join("evidence");
    let before = evidence_snapshot(&checkout_evidence);
    let output = Command::new(env!("CARGO_BIN_EXE_habeas"))
        .current_dir(&project)
        .args([
            "author-evidence",
            SUBJECT,
            "--config",
            &selected.name,
            "--stdout",
        ])
        .output()
        .unwrap();
    let stderr = String::from_utf8_lossy(&output.stderr);
    report(&stderr);
    assert!(
        output.status.success(),
        "live Bedrock authoring failed: {stderr}"
    );
    let evidence: Value = serde_json::from_slice(&output.stdout).expect("stdout is evidence JSON");
    assert_eq!(evidence["requirement"], REQUIREMENT);
    habeas::judgment::Judgment::from_value(&evidence["determination"]).unwrap();
    assert!(!evidence["rationale"].as_str().unwrap().trim().is_empty());
    assert!(
        evidence["inputs"].as_array().unwrap().iter().any(|input| {
            input["file"] == "src/parity.rs"
                && input["item"].is_string()
                && input["hash"].is_string()
                && input.get("text").is_none()
        }),
        "model must inspect the fixture's source through a read tool"
    );
    assert!(!project.join("evidence").exists());
    assert_eq!(
        evidence_snapshot(&checkout_evidence),
        before,
        "checkout evidence changed"
    );
    let usage_path = stderr
        .lines()
        .find_map(|line| line.strip_prefix("Usage: "))
        .expect("reported usage path");
    let usage: Value = serde_json::from_slice(&fs::read(usage_path).unwrap()).unwrap();
    assert_eq!(usage["backend"], "bedrock");
    assert_eq!(usage["model"], backend.model);
    assert_eq!(usage["outcome"], "completed");
    assert_eq!(usage["evidence_output"], "stdout");
    assert_eq!(usage["evidence_written"], true);
    assert!(usage["request_count"].as_u64().unwrap() >= 2);
    assert!(usage["tool_calls"]["submit_judgment"].as_u64().unwrap() >= 1);
    assert!(
        usage["tool_calls"]["habeas"].as_u64().unwrap_or(0)
            + usage["tool_calls"]["ripgrep"].as_u64().unwrap_or(0)
            > 0
    );
}

Referenced definitions

Input 2: 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.
:::
Input 3: requirements selection requirements.authoring.submission.searches.recovery
:::{req} submission.searches.recovery
An outstanding-search rejection MUST leave the assessment open for the model
to finish its searches and submit again. It MUST NOT accept a judgment or
publish evidence.
:::
Input 4: requirements selection requirements.authoring.line_numbers.rejection
:::{req} line_numbers.rejection
When the only submission in a response under
{cite}`requirements.authoring.submission`, or a `submit_verification` call under
{cite}`requirements.authoring.verifier_prompt`, is otherwise valid but its
rationale cites line numbers under
{cite}`requirements.authoring.line_numbers.detection`, and it is the
assessment's first such submission, and it passes the outstanding-search gate
under {cite}`requirements.authoring.submission.searches.line_numbers`, the
harness MUST reject it instead of
accepting it and continue the conversation. The tool result MUST quote the
matched text, repeat the location guidance of
{cite}`requirements.authoring.judgment_rules`, and give a fresh random UUID,
saying the model may submit once more, either without line numbers or with
`rationale` set to exactly that UUID to keep the rejected submission as it was.
A rejection MUST be counted in usage like any other turn.
:::
Input 5: requirements selection requirements.authoring.output_limit
:::{req} output_limit
When a Bedrock configuration sets no `maxTokens` option, each provider request
MUST ask for at most 16,384 output tokens. A configured `maxTokens` MUST be used
as given.

When a response stops because it reached a known output limit, the harness MUST
continue the same conversation once, adding a user message with an error result
for each tool call in the cut-off response, followed by this text with `<limit>`
replaced by the limit:

```text
Your previous response reached the <limit>-token output limit and was cut off,
so its tool call was incomplete. Keep within the limit: make your rationale
shorter, then call the tool again.
```

A second response that reaches the limit, or a response that stops at an
output limit that is not known, MUST fail the assessment as an incomplete
response. Where the provider reports whether a response stopped at the output
limit or because the conversation exceeded the model's context window, the
harness SHOULD continue only the former and fail the assessment on the latter;
where it does not, the stop MUST be treated as reaching the output limit.
:::

Other sources

Input 1: requirements selection requirements.authoring.submission
:::{req} submission
The harness MUST expose a `submit_judgment` tool accepting exactly these fields:

```text
submit_judgment({ determination: Judgment, rationale: String })

Judgment = Boolean | { FIXME: Array<String> }
```

The judgment MUST use the three outcomes and nonempty FIXME entries defined by
{cite}`requirements.ci.outcomes`.
`rationale` MUST be nonempty Markdown. This tool call MUST supply the final
assessment result. The model MUST obtain exactly one accepted submission over the entire
assessment. Rejected attempts under
{cite}`requirements.authoring.submission.searches.recovery` and
{cite}`requirements.authoring.line_numbers.rejection` do not count as accepted
submissions. If a response ends without invoking it, and the assessment has
not already been reminded, the harness MUST continue the conversation with one
user message, `Reminder: you MUST submit your result with the submit_judgment
tool.`, naming the assessment's submission tool. If a later response also ends
without invoking it, or a response contains multiple submission calls, the harness MUST
report an error and leave existing evidence unchanged. The reminder MUST be
counted in usage like any other turn.
The harness MUST check the complete model response for multiple submissions
before accepting one. Invalid submission arguments MUST also fail the assessment.
A valid single submission MUST finish the assessment; there is no submission
repair or resubmission loop, except the one continuation after a response cut
off at its output limit under {cite}`requirements.authoring.output_limit`, the
one reminder above, and the one resubmission after a rejection under
{cite}`requirements.authoring.line_numbers.rejection`, and recovery under
{cite}`requirements.authoring.submission.searches.recovery`. An assessment that fails before accepting a valid
judgment MUST emit no evidence JSON to stdout.
:::