requirements.authoring.additional_read
Requirements index · View definition
Example
The model calls
list_filesto find a directory, thenripgrepto find matching lines in a Rust file. The listing creates no evidence input; the search returns the selector of the innermost Rust item containing each match, with the matching and context lines but no line numbers, and creates no evidence input. Anoutlinerequest for that file lists its items without content and creates no evidence input. Ahabeasrequest with the file and one item’s selector returns and records that item, along with any required terminology. A line-range request omittingline_endreads through EOF and records the outline nodes it covers.![]()
![]()
![]()
Rationale
The example describes a concrete scenario with stated outcomes: list_files, then ripgrep on a Rust file, then outline, then a habeas item read, then a habeas line-range read with no line_end. The test src/authoring/tools.rs#mod[tests]/fn[additional_read_flow_searches_outlines_and_reads_a_rust_file] runs this whole flow against a Rust file src/lib.rs. That file has fn work with an attached {term} comment, plus fn other. Each outcome is checked as follows:
- Listing creates no input.
- The root
list_filesreturns asrcentry of kinddirectory, anddirectories.inputsis empty. - Listing
srcreturns exactly one file entry forsrc/lib.rs, andlisting.inputsis empty. listed_git_directories_need_an_eligible_descendant_at_any_depthadds Git-worktree listing checks and confirms that listings record no inputs.
- The root
- Search returns the innermost item, no line numbers, and no input.
ripgrepwith patternworkandcontext0 onsrc/lib.rsis compared withassert_eq!to an exact JSON value. That value has filesrc/lib.rs, itemfn[work], kindfn, and one matching line with no line-number fields.search.inputsis empty.search_merges_context_windows_and_respects_ignore_rulesalso asserts that entries and lines have no line-number keys.search_records_nothing_clamps_at_eof_and_reports_failureschecks that no definitions are returned, that nothing is recorded, and that item-boundary context stops at the item.
- Outline lists items without content and creates no input. The
outlineresult’s items equal["fn[work]","fn[other]"]. The result does not contain the body text offn other, andoutline.inputsis empty. - Item read returns and records the item with terminology.
- The
habeasread withfileanditemreturns an input whose item isfn[work]and whose text includes thefn worksource line. - It returns one definition,
terms.value, and itsinputshas length 2. - After
record_inputs, the recorded set contains thefn[work]outline input, and its length is 2.
- The
- Line range without
line_endreads through EOF and records the covered nodes.- A
habeasrequest with onlyline_startreturns inputs whose items equal["fn[work]","fn[other]"]. - After recording, both outline inputs and the terminology definition are present.
- A
The CLI test tests/authoring_cli.rs#fn[ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free] checks the end-to-end flow, which strengthens the habeas and listing assertions:
list_filesrecords no evidence input.ripgreponly locates lines. It counts toward usage but is not an evidence input.- A line-range read with no
line_endis recorded as the plain-text line nodes it covers. A repeated read is recorded once, by selector and hash only.
The tests cover every outcome the example states, and the expected values come from the example and the cited requirements. They would reject an implementation that gave a search or listing an evidence input, added line numbers or item content to results, or failed to record the item, the line-range nodes or the terminology. I found no unresolved gap.
Inputs
Tests
Input 6: outline src/authoring/tools.rs mod[tests]/fn[additional_read_flow_searches_outlines_and_reads_a_rust_file]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[additional_read_flow_searches_outlines_and_reads_a_rust_file] - Kind:
fn src/authoring/tools.rs:1351–1495
// {test}`requirements.authoring.additional_read`
// {test}`requirements.authoring.github_reads`
// {test}`requirements.authoring.file_discovery`
// {test}`requirements.authoring.read_denial`
#[test]
fn additional_read_flow_searches_outlines_and_reads_a_rust_file() {
let root = project();
fs::write(
root.path().join("md/terms.md"),
":::{definition} value\n:phrase: value\nA useful value.\n:::\n",
)
.unwrap();
fs::write(
root.path().join("src/lib.rs"),
format!(
"// {}\nfn work() {{}}\n\nfn other() {{}}\n",
role("term", "terms.value")
),
)
.unwrap();
let mut sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
for arguments in [json!({}), json!({"issue": 7})] {
let error = dispatch(&sources, "github", &arguments).err().unwrap();
assert!(
error
.to_string()
.contains("github expects exactly an issue field"),
"{error}"
);
}
// GitHub reads return tool errors here, since unit tests never contact
// GitHub, and are never evidence inputs.
for (issue, message) in [
("example/app#1", "cannot read GitHub issue example/app#1"),
("example/app", "is not an issue reference"),
] {
let error = dispatch(&sources, "github", &json!({ "issue": issue }))
.err()
.unwrap();
assert!(error.to_string().contains(message), "{error}");
}
let directories = dispatch(&sources, "list_files", &json!({})).unwrap();
let directory = directories
.result
.as_array()
.unwrap()
.iter()
.find(|entry| entry["path"] == "src")
.unwrap();
assert_eq!(directory["kind"], "directory");
assert!(directories.inputs.is_empty());
// The listing finds the directory's file and records nothing.
let listing = dispatch(&sources, "list_files", &json!({"path":directory["path"]})).unwrap();
assert_eq!(listing.result, json!([{"path":"src/lib.rs","kind":"file"}]));
assert!(listing.inputs.is_empty());
// Searching the Rust file returns the innermost item containing the match.
let search = dispatch(
&sources,
"ripgrep",
&json!({"path":"src/lib.rs","pattern":"work","context":0}),
)
.unwrap();
// It only locates the item: nothing is recorded and no definitions
// accompany it.
assert!(search.inputs.is_empty());
assert_eq!(
search.result["matches"],
json!([{
"file": "src/lib.rs", "item": "fn[work]", "kind": "fn", "tag":"1",
"lines": [{"text": "fn work() {}", "matched": true}],
}])
);
// Outlining it lists its items without content and records nothing.
let outline = dispatch(&sources, "outline", &json!({"file":"src/lib.rs"})).unwrap();
assert!(outline.inputs.is_empty());
let items = outline
.result
.get("entries")
.unwrap_or(&outline.result)
.as_array()
.unwrap()
.iter()
.map(|entry| entry["item"].as_str().unwrap())
.collect::<Vec<_>>();
assert_eq!(items, ["fn[work]", "fn[other]"]);
assert!(!outline.result.to_string().contains("fn other()"));
// Reading one item by selector returns it with its terminology.
let item = dispatch(
&sources,
"habeas",
&json!({"file":"src/lib.rs","item":"fn[work]"}),
)
.unwrap();
assert_eq!(item.result["input"]["item"], "fn[work]");
assert!(
item.result["input"]["text"]
.as_array()
.unwrap()
.iter()
.any(|line| line == "fn work() {}")
);
assert_eq!(item.result["definitions"].as_array().unwrap().len(), 1);
assert_eq!(item.result["definitions"][0]["definition"], "terms.value");
assert!(
item.inputs
.iter()
.any(|input| input["definition"] == "terms.value")
);
assert_eq!(item.inputs.len(), 2);
sources.record_inputs(&item.inputs);
assert!(sources.recorded_inputs().contains(
&crate::inputs::outline_input(root.path(), "src/lib.rs", "fn[work]").unwrap()
));
assert_eq!(sources.recorded_inputs().len(), 2);
// A line range without line_end reads through EOF.
let eof = dispatch(
&sources,
"habeas",
&json!({"file":"src/lib.rs","line_start":2}),
)
.unwrap();
let covered = eof.result["inputs"]
.as_array()
.unwrap()
.iter()
.map(|input| input["item"].as_str().unwrap())
.collect::<Vec<_>>();
assert_eq!(covered, ["fn[work]", "fn[other]"]);
sources.record_inputs(&eof.inputs);
let recorded = sources.recorded_inputs();
for item in ["fn[work]", "fn[other]"] {
assert!(
recorded.contains(
&crate::inputs::outline_input(root.path(), "src/lib.rs", item).unwrap()
),
"{item} recorded: {recorded:?}"
);
}
assert!(
recorded
.iter()
.any(|input| input["definition"] == "terms.value"),
"terminology recorded: {recorded:?}"
);
}
Input 7: outline src/authoring/tools.rs mod[tests]/fn[listed_git_directories_need_an_eligible_descendant_at_any_depth]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[listed_git_directories_need_an_eligible_descendant_at_any_depth] - Kind:
fn src/authoring/tools.rs:1497–1530
// {test}`requirements.authoring.additional_read`
// {test}`requirements.authoring.file_discovery`
#[test]
fn listed_git_directories_need_an_eligible_descendant_at_any_depth() {
let root = project();
fs::create_dir_all(root.path().join("a/b")).unwrap();
fs::create_dir(root.path().join("blocked-only")).unwrap();
fs::write(root.path().join("a/b/file.txt"), "eligible\n").unwrap();
fs::write(root.path().join("blocked-only/hidden.txt"), "blocked\n").unwrap();
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\ndisallow = ['blocked-only/hidden.txt']\n",
)
.unwrap();
git(root.path(), &["init", "--quiet"]);
git(root.path(), &["add", "."]);
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let root_listing = dispatch(&sources, "list_files", &json!({})).unwrap();
let entries = root_listing.result.as_array().unwrap();
assert!(
entries
.iter()
.any(|e| e["path"] == "a" && e["kind"] == "directory"),
"{entries:?}"
);
assert!(
!entries.iter().any(|e| e["path"] == "blocked-only"),
"{entries:?}"
);
let nested = dispatch(&sources, "list_files", &json!({"path":"a"})).unwrap();
assert_eq!(nested.result, json!([{"path":"a/b","kind":"directory"}]));
assert!(root_listing.inputs.is_empty());
assert!(nested.inputs.is_empty());
}
Input 8: outline src/authoring/tools.rs mod[tests]/fn[search_merges_context_windows_and_respects_ignore_rules]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[search_merges_context_windows_and_respects_ignore_rules] - Kind:
fn src/authoring/tools.rs:1900–1976
// {test}`requirements.authoring.text_search`
// {test}`requirements.authoring.additional_read`
// {test}`requirements.authoring.file_discovery`
// {test}`requirements.authoring.no_line_numbers`
#[test]
fn search_merges_context_windows_and_respects_ignore_rules() {
let root = project();
git(root.path(), &["init", "--quiet"]);
fs::write(root.path().join(".gitignore"), "ignored.txt\n").unwrap();
fs::write(root.path().join("ignored.txt"), "needle\n").unwrap();
fs::write(root.path().join(".hidden.txt"), "needle\n").unwrap();
let lines = (1..=20)
.map(|number| {
if number == 2 || number == 6 {
"needle".to_owned()
} else {
format!("line {number}")
}
})
.collect::<Vec<_>>();
fs::write(root.path().join("sample.txt"), lines.join("\n")).unwrap();
git(root.path(), &["add", "--force", "."]);
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let search = dispatch(&sources, "ripgrep", &json!({"pattern":"needle"})).unwrap();
// Each plain-text line is an item. Even a large context window must
// not include neighboring items.
assert!(search.inputs.is_empty());
let matches = search.result["matches"].as_array().unwrap();
assert_eq!(matches.len(), 2, "{matches:#?}");
let shown = matches
.iter()
.map(|entry| {
assert_eq!(entry["file"], "sample.txt");
assert_eq!(entry["kind"], "line");
assert!(entry.get("line_start").is_none());
entry["lines"]
.as_array()
.unwrap()
.iter()
.map(|line| {
assert!(line.get("line").is_none());
(
line["text"].as_str().unwrap(),
line["matched"].as_bool().unwrap(),
)
})
.collect::<Vec<_>>()
})
.collect::<Vec<_>>();
assert_eq!(shown, [vec![("needle", true)], vec![("needle", true)]]);
let exact = dispatch(
&sources,
"ripgrep",
&json!({"pattern":"needle","path":"sample.txt","context":0}),
)
.unwrap();
assert_eq!(
exact.result["matches"][0]["lines"],
json!([{"text": "needle", "matched": true}])
);
assert_eq!(
exact.result["matches"][1]["lines"],
json!([{"text": "needle", "matched": true}])
);
let absent = dispatch(&sources, "ripgrep", &json!({"pattern":"NEEDLE"})).unwrap();
assert_eq!(absent.result["matches"], json!([]));
assert!(dispatch(&sources, "ripgrep", &json!({"pattern":"["})).is_err());
assert!(
dispatch(
&sources,
"ripgrep",
&json!({"pattern":"needle","context":-1})
)
.is_err()
);
assert!(dispatch(&sources, "list_files", &json!({"path":"../"})).is_err());
}
Input 9: outline src/authoring/tools.rs mod[tests]/fn[search_records_nothing_clamps_at_eof_and_reports_failures]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[search_records_nothing_clamps_at_eof_and_reports_failures] - Kind:
fn src/authoring/tools.rs:3861–3951
// {test}`requirements.authoring.text_search`
// {test}`requirements.authoring.read_denial`
// {test}`requirements.authoring.additional_read`
#[test]
fn search_records_nothing_clamps_at_eof_and_reports_failures() {
let root = project();
fs::write(
root.path().join("md/terms.md"),
":::{definition} value\n:phrase: value\nA useful value.\n:::\n",
)
.unwrap();
fs::write(
root.path().join("src/lib.rs"),
format!(
"fn first() {{}}\n\n// {}\nfn needle() {{}}\n",
role("term", "terms.value")
),
)
.unwrap();
// An allowed hidden directory is searched; an unallowed one is not.
fs::create_dir_all(root.path().join(".generated")).unwrap();
fs::write(root.path().join(".generated/out.txt"), "needle allowed\n").unwrap();
fs::create_dir_all(root.path().join(".other")).unwrap();
fs::write(root.path().join(".other/out.txt"), "needle hidden\n").unwrap();
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\nallow = ['.generated']\n",
)
.unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let search = dispatch(
&sources,
"ripgrep",
&json!({"pattern":"fn needle","path":"src","context":5}),
)
.unwrap();
// Context includes the attached comment and stops at the item boundary.
assert_eq!(
matched(&search),
&vec![
json!({"file": "src/lib.rs", "item": "fn[needle]", "kind": "fn", "tag":"1",
"lines": [
{"text": "// {term}`terms.value`", "matched": false},
{"text": "fn needle() {}", "matched": true},
]})
]
);
// The terminology the node uses is neither supplied nor recorded.
assert!(search.result.get("definitions").is_none());
assert!(sources.recorded_inputs().is_empty());
let hidden = dispatch(
&sources,
"ripgrep",
&json!({"pattern":"needle (allowed|hidden)","context":0}),
)
.unwrap();
let files = matched(&hidden)
.iter()
.map(|input| input["file"].as_str().unwrap())
.collect::<Vec<_>>();
assert_eq!(files, [".generated/out.txt"]);
// Invalid arguments are explanatory tool errors.
for (arguments, message) in [
(json!({}), "pattern must be a string"),
(json!({"pattern": 1}), "pattern must be a string"),
(json!({"pattern":"x","path":1}), "path must be a string"),
(
json!({"pattern":"x","context":1.5}),
"context must be a nonnegative integer",
),
(
json!({"pattern":"x","extra":true}),
"unexpected tool argument \"extra\"",
),
(json!({"pattern":"("}), "invalid ripgrep pattern"),
] {
let error = dispatch(&sources, "ripgrep", &arguments).err().unwrap();
assert!(error.to_string().contains(message), "{arguments}: {error}");
}
// A matched file that cannot be parsed fails the search with an
// explanatory error rather than silently dropping the match.
fs::write(root.path().join("src/broken.rs"), "fn needle( {\n").unwrap();
let error = dispatch(
&sources,
"ripgrep",
&json!({"pattern":"fn needle","path":"src"}),
)
.err()
.unwrap();
assert!(error.to_string().contains("syntax error"), "{error}");
}
Input 10: outline tests/authoring_cli.rs fn[ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free]
- File:
tests/authoring_cli.rs - Selector:
fn[ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free] - Kind:
fn tests/authoring_cli.rs:366–676
// {test}`requirements.authoring.complete_initial_bundle`
// {test}`requirements.authoring.invocation`
// {test}`requirements.authoring.additional_read`
// {test}`requirements.authoring.acknowledged_gap`
// {test}`requirements.authoring.configuration_precedence`
// {test}`requirements.authoring.rig_configuration_mapping`
// {test}`requirements.authoring.configuration_storage`
// {test}`requirements.authoring.initial_prompt`
// {test}`requirements.ci.review_criteria`
// {test}`requirements.authoring.delivered_inputs`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.authoring.usage_inputs`
// {test}`requirements.authoring.usage_requests`
// {test}`requirements.authoring.mandatory_inputs`
// {test}`requirements.authoring.github_reads`
// {test}`requirements.authoring.invocation`
// {test}`requirements.configuration.serialization`
// {test}`requirements.ci.fixme_implementation_gap`
// {test}`requirements.authoring.finish_search.empty`
// {test}`requirements.authoring.finish_search.completion`
#[test]
// {test}`requirements.authoring.persistence`
// {test}`requirements.authoring.reporting`
fn ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free() {
let server = Server::start(vec![
reply(vec![
call("list", "list_files", json!({})),
call(
"search",
"ripgrep",
json!({"path":"extra.txt","pattern":"needle"}),
),
call(
"read",
"habeas",
json!({"file":"extra.txt","line_start":10}),
),
call(
"repeat",
"habeas",
json!({"file":"extra.txt","line_start":10}),
),
call(
"missing",
"habeas",
json!({"file":"absent.txt","line_start":1}),
),
]),
json!({"__finish_latest_search":true}),
reply(vec![call(
"submit",
"submit_judgment",
json!({
"determination":{"FIXME":["example/app#125"]},"rationale":"SECRET_RATIONALE: `src/lib.rs#fn[ready]` documents the gap."}),
)]),
]);
let fixture = Fixture::new(&server.endpoint);
let user_config = fixture.config.join("habeas/config.toml");
let configured = fs::read(&user_config).unwrap();
let output = fixture.run(&["author-evidence", SUBJECT]);
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
// The user configuration, with its environment-resolved key, is not
// rewritten.
assert_eq!(fs::read(&user_config).unwrap(), configured);
let requests = server.finish();
assert_eq!(requests.len(), 3);
for request in &requests {
assert!(request.headers.starts_with("POST /api/chat HTTP/1.1\r\n"));
assert!(request.headers.to_ascii_lowercase().contains(&format!(
"authorization: bearer {}",
AUTH.to_ascii_lowercase()
)));
assert_eq!(request.body["model"], MODEL);
assert_eq!(request.body["options"]["temperature"], 0.25);
assert_eq!(request.body["options"]["num_ctx"], 4096);
assert_eq!(request.body["think"], false);
assert_eq!(request.body["stream"], false);
}
let prompt = prompt_text(&requests[0].body);
for text in [
"Assess whether a project's tests adequately check one requirement.",
REQUIREMENT,
"SECRET_DEFINITION_TEXT",
"fn ready_test()",
"You MUST end by calling submit_judgment",
] {
assert!(prompt.contains(text), "prompt missing {text}");
}
assert!(!prompt.contains("pub fn ready()"), "{prompt}");
assert!(!prompt.contains("OLD_RATIONALE_MUST_NOT_REACH_MODEL"));
let mut tools = requests[0].body["tools"]
.as_array()
.unwrap()
.iter()
.map(|tool| tool["function"]["name"].as_str().unwrap())
.collect::<Vec<_>>();
tools.sort();
assert_eq!(
tools,
[
"ast_grep",
"finish_search",
"github",
"habeas",
"list_files",
"next_page",
"outline",
"references",
"ripgrep",
"submit_judgment"
]
);
let results = requests[1].body["messages"]
.as_array()
.unwrap()
.iter()
.filter(|message| message["role"] == "tool")
.collect::<Vec<_>>();
assert_eq!(results.len(), 5);
assert!(results.iter().any(|message| {
message["content"]
.as_str()
.unwrap()
.contains("SECRET_SOURCE_PAYLOAD")
}));
assert!(
results
.iter()
.any(|message| message["content"].as_str().unwrap().contains("absent.txt"))
);
let evidence: Value = serde_json::from_slice(&fs::read(&fixture.evidence).unwrap()).unwrap();
assert_eq!(
evidence["determination"],
json!({"FIXME":["example/app#125"]})
);
assert_eq!(
evidence["rationale"],
"SECRET_RATIONALE: `src/lib.rs#fn[ready]` documents the gap."
);
assert_eq!(evidence["requirement"], REQUIREMENT);
let inputs = evidence["inputs"].as_array().unwrap();
assert!(
inputs
.iter()
.any(|input| input["file"] == "src/lib.rs" && input["item"] == "fn[ready_test]"),
"{inputs:#?}"
);
// The acknowledgment reaches the model as metadata, without the
// containing implementation. Its body is protected by the reference set.
assert!(prompt.contains(":github: example/app#125"));
assert!(prompt.contains("One acknowledged gap."));
// GitHub is unreachable, so the issue is supplied as open, but the state
// is not recorded.
assert!(
prompt.contains("\"reference\": \"example/app#125\"")
&& prompt.contains("\"state\": \"open\""),
"{prompt}"
);
assert!(!evidence.to_string().contains("github_issues"));
assert!(!fixture.usage().to_string().contains("github_issues"));
assert!(
!inputs
.iter()
.any(|input| input["file"] == "src/lib.rs" && input["item"] == "fn[ready]"),
"{inputs:#?}"
);
// CI accepts the FIXME judgment: its evidence has no validation error.
let report = habeas::validate_repository(&fixture.project).unwrap();
let label = format!("evidence/{SUBJECT}.json");
assert!(
!report.errors.iter().any(|error| error.contains(&label)),
"{:#?}",
report.errors
);
// The same record with a false determination is rejected.
let mut rejected = evidence.clone();
rejected["determination"] = json!(false);
let accepted = fs::read(&fixture.evidence).unwrap();
fs::write(&fixture.evidence, rejected.to_string()).unwrap();
let report = habeas::validate_repository(&fixture.project).unwrap();
assert!(
report.errors.iter().any(|error| error.contains(&label)),
"{:#?}",
report.errors
);
fs::write(&fixture.evidence, accepted).unwrap();
assert!(
inputs
.iter()
.any(|input| input["definition"] == "terms.readiness")
);
let extra = inputs
.iter()
.filter(|input| input["file"] == "extra.txt")
.collect::<Vec<_>>();
// The search only locates lines and records nothing; the reads cover
// lines 10-12, one plain-text line node each, and the repeated delivery
// is recorded once, by selector and hash only.
assert_eq!(
extra,
habeas::outline_inputs_for_lines(&fixture.project, "extra.txt", 10, 12)
.unwrap()
.iter()
.collect::<Vec<_>>(),
"repeated delivery is deduplicated in evidence"
);
assert!(
!evidence["inputs"]
.to_string()
.contains("SECRET_SOURCE_PAYLOAD")
);
assert!(
!inputs
.iter()
.any(|input| input["file"] == "absent.txt" || input["file"] == ".")
);
let usage = fixture.usage();
assert_eq!(usage["outcome"], "completed");
assert_eq!(usage["determination"], "FIXME");
assert_eq!(usage["evidence_written"], true);
assert_eq!(usage["request_count"], 3);
assert_eq!(usage["tool_call_count"], 7);
assert_eq!(usage["tool_calls"]["habeas"], 3);
assert_eq!(usage["tool_failures"]["habeas"], 1);
// The directory listing counts as a tool call but is not an input.
assert_eq!(usage["tool_calls"]["list_files"], 1);
assert_eq!(usage["tool_calls"]["ripgrep"], 1);
assert_eq!(usage["tool_calls"]["finish_search"], 1);
let usage_inputs = usage["inputs"].as_array().unwrap();
assert!(
!usage_inputs
.iter()
.any(|input| input["origin"] == "list_files"),
"{usage_inputs:?}"
);
// Search snippets count toward usage, without becoming evidence inputs.
assert!(
usage_inputs.iter().any(|input| input["origin"] == "ripgrep"
&& input["kind"] == "search"
&& input["bytes"].as_u64().unwrap() > 0
&& input["lines"].as_u64().unwrap() > 0),
"{usage_inputs:?}"
);
assert!(
usage_inputs
.iter()
.any(|input| input["origin"] == "habeas" && input["unique"] == true),
"{usage_inputs:?}"
);
assert_eq!(usage["tokens"]["input"], 33);
assert_eq!(usage["tokens"]["output"], 21);
assert_eq!(usage["tokens"]["complete"], true);
assert!(
usage["inputs"]
.as_array()
.unwrap()
.iter()
.any(|input| input["origin"] == "habeas"
&& input["unique"] == false
&& input["sent_in_request"] == 1)
);
assert!(
usage["inputs"]
.as_array()
.unwrap()
.iter()
.any(|input| input["origin"] == "mandatory"
&& input["kind"] == "definition"
&& input["bytes"].as_u64().unwrap() > 0)
);
let serialized = usage.to_string();
for secret in [
"SECRET_REQUIREMENT_TEXT",
"SECRET_DEFINITION_TEXT",
"SECRET_SOURCE_PAYLOAD",
"SECRET_RATIONALE",
AUTH,
"#125",
] {
assert!(
!serialized.contains(secret),
"usage contains source or credential content: {secret}"
);
}
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains(MODEL) && stdout.contains("Evidence:") && stdout.contains("Usage:"));
// By default the report names the subject and backend and identifies the
// evidence file it wrote.
assert!(
stdout.starts_with(&format!("{SUBJECT}: ollama / {MODEL}")),
"{stdout}"
);
let evidence = stdout
.lines()
.find_map(|line| line.strip_prefix("Evidence: "))
.unwrap();
assert!(
evidence.ends_with(&format!("evidence/{SUBJECT}.json")),
"{stdout}"
);
assert_eq!(
fs::canonicalize(evidence).unwrap(),
fs::canonicalize(fixture.project.join(format!("evidence/{SUBJECT}.json"))).unwrap()
);
}
Referenced definitions
Input 2: requirements selection requirements.authoring.file_discovery
requirements.authoring.file_discovery:md/requirements/authoring.md:762–786
:::{req} file_discovery
The harness MUST expose a `list_files` tool with this interface:
```text
list_files({ path: String = "." }) -> Array<DirectoryEntry>
DirectoryEntry {
path: String,
kind: "file" | "directory",
}
```
The tool MUST list the immediate children of the requested directory, returning
project-relative paths where possible and absolute paths for permitted external
files. Its root listing MUST also expose available generated-output directories
and configured external allow paths. The model can list a returned
directory in another call to explore further. A failed listing MUST return an
explanatory tool error unless access was denied, which MUST be handled under
{cite}`requirements.authoring.read_denial`. Directory listings MUST NOT become evidence inputs.
Listings MUST omit files excluded by {cite}`requirements.authoring.source_tools`.
In a Git worktree, directories MUST have at least one eligible source
descendant to be listed unless explicitly allowed or discovered as generated
output. Explicitly requesting an excluded path MUST be handled as a denial under
{cite}`requirements.authoring.read_denial`.
:::
Input 3: requirements selection requirements.authoring.text_search
requirements.authoring.text_search:md/requirements/authoring.md:816–884
:::{req} text_search
The harness MUST expose a `ripgrep` tool with this interface:
```text
ripgrep({ pattern: String, path: String = ".", context: Integer = 2,
referencing: Optional<ReferenceScope> }) -> SearchResult
ReferenceScope {
selection: String, // full name or definition glob
roles: Array<Role> = ["impl", "test", "cite"],
scope: "node" | "file" = "file",
}
SearchResult {
search_id: UUID,
instructions: Optional<String>,
matches: Array<SearchMatch>,
}
SearchMatch {
tag: String, // short tag for finish_search
file: String,
item: String, // selector of the innermost outline node
kind: String,
lines: Array<{ text: String, matched: Boolean }>,
}
```
The tool MUST search the requested permitted file or directory using
ripgrep's regular-expression syntax and default case-sensitive search and ignore
rules. It MUST search in process using ripgrep's library crates, without
requiring an external `rg` executable, and MUST apply source-access policy while
walking files rather than filtering results afterwards. It MAY search files in
parallel; results MUST be ordered by path and then line regardless of
parallelism, so the same sources always produce the same inputs. Explicitly allowed paths and discovered generated-output directories MUST
be searched even when ignored or hidden; workspace disallow rules still apply.
`context`
MUST be nonnegative and specify how many lines before and after each matching
line to include, defaulting to two on each side. Windows MUST stop at item
boundaries under {cite}`requirements.authoring.search_accounting.excerpts`,
and overlapping windows within the same item MUST be merged. The result
MUST give one entry for each innermost outline node containing a match, where a
match in a comment belongs to the node the comment belongs to under
{cite}`requirements.references.outline_comments`: the node's file, selector
under {cite}`requirements.references.outline_selectors`, kind, and its matching
and context lines in source order, each marked as matching or not and redacted
under {cite}`requirements.authoring.redaction`. Results MUST NOT give line
numbers; the model locates and cites code by selector. Separate windows within
one node MUST be distinguishable, such as by an elision line that is not
marked as matching. Search results MUST NOT include definitions. Selected snippets MUST contribute
evidence inputs through {cite}`requirements.authoring.finish_search.inputs`;
unselected snippets MUST NOT contribute inputs merely through discovery.
Results and descriptions MUST follow
{cite}`requirements.authoring.search_accounting.instructions` and
{cite}`requirements.authoring.finish_search.description`. Setting `context` to zero MUST return only matching lines.
With `referencing`, the tool MUST search only sources, within `path`, that carry
a reference in one of `roles` to a requirement or example the `selection`
matches under {cite}`requirements.references.definition_globs`, including
anchors under {cite}`requirements.references.anchors`: with `scope` `node`, only
the outline nodes that contain or are named by those references, and with
`file`, their whole files. A selection matching no requirement or example, or an
unknown role or scope, MUST return an explanatory tool error. Its model-facing
description MUST explain `referencing`.
Search results MUST exclude files disallowed by
{cite}`requirements.authoring.source_tools`; explicitly requesting an excluded
path MUST be handled as a denial under {cite}`requirements.authoring.read_denial`.
No matches MUST return an empty array; invalid arguments or a failed search MUST
return an explanatory tool error.
:::
Input 4: requirements selection requirements.authoring.source_tools
requirements.authoring.source_tools:md/requirements/authoring.md:637–699
:::{req} source_tools
The harness MUST expose a `habeas` tool accepting exactly one of these request
forms. Each form MUST correspond to one existing evidence-input kind:
| Request fields | Evidence input returned | Definition |
| --- | --- | --- |
| `file: String`, `line_start: Integer`, optional `line_end: Integer` | Outline inputs for the innermost outline nodes covering the range | {cite}`requirements.ci.outline_inputs` |
| `file: String`, `item: String` | Outline input | {cite}`requirements.ci.outline_inputs` |
| `requirements: String` | Requirements input, including its matching names | {cite}`requirements.ci.requirements_inputs` |
| `definition: String` | Definition input | {cite}`requirements.definitions.inputs` |
Selector arguments MUST use the syntax defined by
{cite}`requirements.references.outline_selectors`. Reads MUST use the current
project working tree, including unstaged changes to tracked files and staged new
files. By default, source inputs MUST stay within the project root after
resolving symlinks; in a Git worktree, both the requested file and its resolved
target MUST be present in the Git index. Projects outside Git MUST use the same
containment rules without requiring an index. Failure to read an existing
repository's index MUST be reported as an error.
The project-root `evidence/` directory MUST be excluded from model reads by
default, including symlink aliases. Every source the harness supplies to the
model MUST be redacted under {cite}`requirements.authoring.redaction`. Generated build outputs MUST follow
{cite}`requirements.authoring.generated_inputs`. Workspace path overrides MUST
follow {cite}`requirements.configuration.evidence_paths`, including explicit
permission for otherwise excluded inputs. A denied mandatory input MUST abort
under {cite}`requirements.authoring.read_denial.mandatory`, and a denied model
read MUST return a tool error under {cite}`requirements.authoring.read_denial`.
Line numbers are only a way to request sources; recorded evidence MUST identify
sources by outline selector and structural hash, never by line number. Request
line numbers MUST be one-based and inclusive, and omitting `line_end` MUST read
through EOF. A line-range request MUST be resolved to the innermost outline
nodes covering the requested lines, which are `line` nodes in a file using the
plain-text profile; the result MUST show the model each node's selector and
source text, without line numbers, and the harness MUST record those nodes as
outline inputs. The model-facing tool description MUST include the argument conventions
from the cited requirements, including outline selector syntax, definition
selections, and full definition names, with a short request example for each form.
A successful call MUST return the requested evidence input, populated by the
harness with the selected source text, using the existing evidence schema.
{cite}`requirements.ci.schema`
Required terminology dependencies MUST be returned alongside it as additional
definition inputs under {cite}`requirements.definitions.authoring_inputs`.
For item, requirement, and definition selections, the result MUST have this shape:
```text
HabeasResult {
input: EvidenceInput,
definitions: Array<DefinitionInput>,
}
```
Line-range selections can contain multiple outline nodes. Their result MUST use
`inputs: Array<EvidenceInput>` instead of the singular `input` field, including
when only one node is selected.
`definitions` MUST be empty when no additional terminology is required. The
harness MUST record inputs supplied to the model in the assessment's evidence.
A failed read MUST add no evidence input. Access-policy denials MUST be handled
under {cite}`requirements.authoring.read_denial`; other failed reads MUST return
an explanatory tool error.
:::
Input 5: requirements selection requirements.authoring.delivered_inputs
requirements.authoring.delivered_inputs:md/requirements/authoring.md:2142–2150
:::{req} delivered_inputs
The harness MUST record the sources it supplies to the model, including
mandatory inputs, additional reads, and selected search dependencies under
{cite}`requirements.authoring.finish_search.inputs`, using the evidence input formats
defined by {cite}`requirements.ci.outline_inputs`,
{cite}`requirements.ci.requirements_inputs`, and
{cite}`requirements.definitions.inputs`. The harness MUST create these records
itself so ordinary evidence validation can check them later.
:::
Other sources
Input 1: requirements selection requirements.authoring.additional_read
requirements.authoring.additional_read:md/requirements/authoring.md:2233–2246
:::{example} additional_read
The model calls `list_files` to find a directory, then `ripgrep` to find matching
lines in a Rust file. The listing creates no evidence input; the search returns
the selector of the innermost Rust item containing each match, with the
matching and context lines but no line numbers, and creates no evidence input. An `outline` request
for that file lists its items without content and creates no evidence input. A
`habeas` request with the file and one item's selector returns and records that
item, along with any required terminology. A line-range request omitting
`line_end` reads through EOF and records the outline nodes it covers.
{cite}`requirements.authoring.file_discovery`
{cite}`requirements.authoring.text_search`
{cite}`requirements.authoring.source_tools`
{cite}`requirements.authoring.delivered_inputs`
:::