requirements.authoring.submission.searches
Requirements index · View definition
Requirement
An otherwise valid
submit_judgmentorsubmit_verificationcall MUST be rejected while any search remains outstanding.
Rationale
The subject is requirements.authoring.submission.searches. It says an otherwise valid submit_judgment or submit_verification call MUST be rejected while any search is outstanding. The only supplied test is src/authoring/mod.rs#mod[tests]/fn[every_submission_kind_waits_for_all_searches_and_can_recover]. It adequately covers the requirement. I did not read the SearchProvider helper or the implementation. My reading relies on the test’s own assertions.
Test coverage
- Both submission kinds. The test loops over
submit_judgmentandsubmit_verification, so both calls named in the requirement are exercised. The arguments are valid for each kind, so the call is “otherwise valid”. - Setup. The first turn runs two searches, a
ripgrepwith matches and anast_grepwith none. This matches thesearch_accounting.recoveryexample, where one outstanding search has no matches. - Rejection with both searches outstanding. In turn 2 a submission arrives while both searches are still open. The test asserts that the blocked response names both search UUIDs and tells the model to call
finish_searchfor every listedsearch_id, then resubmit. The submission is therefore not accepted. - Rejection with one search outstanding. In turn 4 the first search has been finished, and the model submits alone with only the empty search open. The test asserts that the latest response says “outstanding searches”, omits the first UUID and includes the second. The request count of 6 shows the submission did not end the assessment.
- Failures. The
tool_failuressum of 2 matches the two rejected submissions. - Recovery. Finishing the empty search with
Finish(1, vec![])lets the final submission succeed. Forsubmit_judgment,assessreturnsOkwith evidence. Forsubmit_verification,verifyreturns a result withreal == false.
Cases checked
- A submission is rejected when two searches are open and when one is open.
- A submission is accepted once all searches are finished, including an empty search finished with
used: []. - Finishing only some searches leaves the rest still blocking.
I found no gap.
Inputs
Tests
Input 2: requirements selection requirements.authoring.search_accounting.recovery
requirements.authoring.search_accounting.recovery:md/requirements/authoring.md:1080–1087
:::{example} search_accounting.recovery
Two search results remain outstanding; one has no matches. Submission MUST
return an error naming both UUIDs. Finishing only the first MUST leave
submission rejected with the second UUID. Finishing the empty search with
`used: []` MUST permit an otherwise valid subsequent submission.
{test}`requirements.authoring.submission.searches`
{test}`requirements.authoring.submission.searches.recovery`
:::
Input 3: outline src/authoring/mod.rs mod[tests]/fn[every_submission_kind_waits_for_all_searches_and_can_recover]
- File:
src/authoring/mod.rs - Selector:
mod[tests]/fn[every_submission_kind_waits_for_all_searches_and_can_recover] - Kind:
fn src/authoring/mod.rs:2735–2855
// {test}`requirements.authoring.submission.searches`
// {test}`requirements.authoring.submission.searches.diagnostic`
// {test}`requirements.authoring.submission.searches.recovery`
// {test}`requirements.authoring.submission.searches.accompanying_calls`
// {test}`requirements.authoring.finish_search.inputs`
// {test}`requirements.authoring.search_accounting.recovery`
#[tokio::test]
async fn every_submission_kind_waits_for_all_searches_and_can_recover() {
use SearchAction::{Call, Finish};
for submit in ["submit_judgment", "submit_verification"] {
let root = inputs::tests::project();
fs::write(
root.path().join("src/lib.rs"),
"fn helper() { assert!(true); }\nfn untouched() {}\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 arguments = if submit == "submit_judgment" {
json!({"determination":true,"rationale":"Helper checks its assertion."})
} else {
json!({"real":false,"acknowledged":false,"acknowledgments":[],
"rationale":"Helper checks its assertion."})
};
let provider = SearchProvider {
submit,
turns: vec![
vec![
Call("ripgrep", json!({"pattern":"assert","path":"src/lib.rs"})),
Call(
"ast_grep",
json!({"language":"rust","rule":{"rule":{"pattern":"absent()"}}}),
),
],
// Accompanying completion is skipped, so both IDs remain open.
vec![
Finish(0, vec!["1"]),
Call(
"habeas",
json!({"file":"src/lib.rs","item":"fn[untouched]"}),
),
Call("ripgrep", json!({"pattern":"absent","path":"src/lib.rs"})),
Call(submit, arguments.clone()),
],
vec![Finish(0, vec!["1"])],
vec![Call(submit, arguments.clone())],
vec![Finish(1, vec![])],
vec![Call(submit, arguments)],
],
requests: RefCell::default(),
};
if submit == "submit_judgment" {
let (_, evidence) = assess(&provider, &mut sources, &mut usage).await.unwrap();
assert!(
evidence["inputs"]
.as_array()
.unwrap()
.iter()
.any(|input| input["item"] == "fn[helper]" && input.get("hash").is_some())
);
} else {
let result = verify(
&provider,
&mut sources,
&mut usage,
&Judgment::False,
"Alleged gap",
)
.await
.unwrap();
assert!(!result.real);
}
let requests = provider.requests.borrow();
assert_eq!(requests.len(), 6);
let mut searches = Vec::new();
delivered_searches(&requests[1], &mut searches);
assert_eq!(searches.len(), 2);
let blocked = requests[2].as_array().unwrap().last().unwrap().to_string();
assert!(blocked.contains("not run: the response also made a submission"));
assert!(blocked.contains(searches[0]["search_id"].as_str().unwrap()));
assert!(blocked.contains(searches[1]["search_id"].as_str().unwrap()));
assert!(blocked.contains("Call finish_search for every listed search_id"));
assert!(blocked.contains("then resubmit"));
let latest = requests[4].as_array().unwrap().last().unwrap().to_string();
assert!(latest.contains("outstanding searches"));
assert!(!latest.contains(searches[0]["search_id"].as_str().unwrap()));
assert!(latest.contains(searches[1]["search_id"].as_str().unwrap()));
assert_eq!(
sources
.recorded_inputs()
.iter()
.filter(|input| input["item"] == "fn[helper]")
.count(),
1
);
let log: Value =
serde_json::from_str(&fs::read_to_string(&usage.path).unwrap()).unwrap();
assert_eq!(log["tool_calls"]["finish_search"], 3);
assert_eq!(log["tool_skipped"]["finish_search"], 1);
assert_eq!(log["tool_skipped"]["habeas"], 1);
assert_eq!(log["tool_skipped"]["ripgrep"], 1);
assert!(
!sources
.recorded_inputs()
.iter()
.any(|input| input["item"] == "fn[untouched]")
);
assert_eq!(
log["tool_failures"]
.as_object()
.unwrap()
.values()
.filter_map(Value::as_u64)
.sum::<u64>(),
2
);
}
}
Other sources
Input 1: requirements selection requirements.authoring.submission.searches
requirements.authoring.submission.searches:md/requirements/authoring.md:1039–1042
:::{req} submission.searches
An otherwise valid `submit_judgment` or `submit_verification` call MUST be
rejected while any search remains outstanding.
:::