requirements.authoring.finish_search.no_additional_source
Requirements index · View definition
Requirement
finish_searchMUST NOT require another model-requested source read or deliver additional source text or definitions.
Rationale
The requirement has two obligations: finish_search must not require another model-requested source read, and it must not deliver additional source text or definitions.
src/authoring/searches.rs#mod[tests]/fn[selected_dependencies_keep_the_delivered_hash_and_accumulate_without_reads] is marked {test} for this requirement and covers both.
- No read needed.
- The test runs a
fnsearch and never reads the file withhabeasbefore finishing. - It then rewrites the source file, so the file on disk no longer matches what the search delivered.
- It calls
finish_searchwithused:["1","1"]. - It asserts
finish.inputs == [original], whereoriginalis the outline input captured before the rewrite. The recorded input therefore comes from the delivered snippet and not from a new read. - Validating the recorded input against the mutated file reports a hash error. This shows no fresh read was done.
- A second finish with
used:["2"]also yieldsfn[second]without any read.
- The test runs a
- No extra delivery.
- It asserts
finish.result == {"search_id":…, "finished":true}exactly. This rules out any added text, definitions or other fields in the tool result. - It also asserts that
resulthas notextkey.
- It asserts
- Repeated and empty completions. Finishing again with a
usedtag that was already selected, and withused:[], leaves the recorded inputs unchanged. Neither delivers anything or needs a read.
An implementation that re-read the source, or that returned source text or definitions in the finish result, would fail these assertions. dispatch_paged routes finish_search straight to pages.finish_search, so the tested result is the delivered tool output. I found no untested mode of this requirement.
Inputs
Tests
Input 2: outline src/authoring/searches.rs mod[tests]/fn[selected_dependencies_keep_the_delivered_hash_and_accumulate_without_reads]
- File:
src/authoring/searches.rs - Selector:
mod[tests]/fn[selected_dependencies_keep_the_delivered_hash_and_accumulate_without_reads] - Kind:
fn src/authoring/searches.rs:269–353
// {test}`requirements.authoring.finish_search.completion`
// {test}`requirements.authoring.finish_search.no_additional_source`
// {test}`requirements.authoring.finish_search.inputs`
// {test}`requirements.authoring.finish_search.snapshot`
// {test}`requirements.authoring.finish_search.unselected`
// {test}`requirements.authoring.finish_search.deduplication`
// {test}`requirements.authoring.finish_search.repetition`
// {test}`requirements.authoring.delivered_inputs`
// {test}`requirements.authoring.finish_search`
#[test]
fn selected_dependencies_keep_the_delivered_hash_and_accumulate_without_reads() {
let root = project();
fs::write(
root.path().join("src/lib.rs"),
"fn first() { assert!(true); }\nfn second() {}\n",
)
.unwrap();
let mut sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let mut pages = ResultPages::default();
let result = search(&sources, &mut pages, "fn");
let original =
crate::inputs::outline_input(root.path(), "src/lib.rs", "fn[first]").unwrap();
// Mutation after delivery must not silently substitute a new hash.
fs::write(
root.path().join("src/lib.rs"),
"fn first() {}\nfn second() {}\n",
)
.unwrap();
let finish = pages
.finish_search(&json!({"search_id":result["search_id"],"used":["1","1"]}))
.unwrap();
assert_eq!(finish.inputs, [original]);
assert_eq!(
finish.result,
json!({"search_id":result["search_id"],"finished":true})
);
assert!(finish.result.get("text").is_none());
assert!(pages.outstanding_searches().is_empty());
sources.record_inputs(&finish.inputs);
assert_eq!(sources.recorded_inputs().len(), 1);
assert_eq!(sources.recorded_inputs()[0]["item"], "fn[first]");
let mut errors = Vec::new();
crate::evidence::validate_input(
root.path(),
&BTreeMap::new(),
&crate::inputs::OutlineCache::default(),
&finish.inputs[0],
"selected",
&mut errors,
);
assert!(
errors.iter().any(|error| error.contains("hash")),
"{errors:?}"
);
let second = pages
.finish_search(&json!({"search_id":result["search_id"],"used":["2"]}))
.unwrap();
assert_eq!(
second.inputs,
[crate::inputs::outline_input(root.path(), "src/lib.rs", "fn[second]").unwrap()]
);
sources.record_inputs(&second.inputs);
assert_eq!(sources.recorded_inputs().len(), 2);
// A separately read item can be included harmlessly, or omitted.
let read = dispatch_paged(
&sources,
&mut pages,
"habeas",
&json!({"file":"src/lib.rs","item":"fn[second]"}),
)
.unwrap();
sources.record_inputs(&read.inputs);
let repeated = pages
.finish_search(&json!({"search_id":result["search_id"],"used":["2"]}))
.unwrap();
sources.record_inputs(&repeated.inputs);
let empty = pages
.finish_search(&json!({"search_id":result["search_id"],"used":[]}))
.unwrap();
sources.record_inputs(&empty.inputs);
assert_eq!(sources.recorded_inputs().len(), 2);
assert_eq!(sources.recorded_inputs()[0]["item"], "fn[first]");
assert_eq!(sources.recorded_inputs()[1]["item"], "fn[second]");
}
Other sources
Input 1: requirements selection requirements.authoring.finish_search.no_additional_source
requirements.authoring.finish_search.no_additional_source:md/requirements/authoring.md:995–998
:::{req} finish_search.no_additional_source
`finish_search` MUST NOT require another model-requested source read or
deliver additional source text or definitions.
:::