requirements.authoring.usage_inputs
Requirements index · View definition
Requirement
Usage MUST record mandatory input counts and sizes by evidence kind, in UTF-8 bytes and lines, and the same information for additional inputs requested through
habeasorripgrep. A requirements input MUST also record its number of matched declarations. Usage MUST distinguish unique inputs from repeated reads, successful from failed reads, and prepared inputs from those actually sent to the model. File-discovery calls MUST count as tool calls without recording directory listings as evidence or source inputs.
Rationale
The reviewed tests cover each obligation in requirements.authoring.usage_inputs.
Counts and sizes by kind, in UTF-8 bytes and lines.
usage.rs#mod[tests]/fn[input_metadata_counts_components_and_reads_without_persisting_source]assertskind,bytesandlinesfor each input kind thatUsageLog::preparedproduces: outline, requirements, search, definition and builtin.- The byte assertions use multi-byte text (
λ) and the newline-joined byte length, so they check UTF-8 bytes and not characters. - The mandatory origin is covered by
prepared("mandatory", ...). - Additional habeas reads are covered by
prepared("habeas", ...). - Additional ripgrep results are covered by
search_result, withkind == "search"and non-zerobytesandlinesasserted. - The CLI test
tests/authoring_cli.rs#fn[ollama_cli_delivers_sources_records_fixme_and_keeps_usage_content_free]asserts the same end to end. It checks originsripgrepandhabeas, a mandatorydefinitionwith non-zero bytes, and that the logged usage contains none of the secret source, requirement or rationale text.
Number of matched declarations for a requirements input. The unit test builds a requirements input with two entries in matches and asserts components == 2. It also asserts kind == "requirements", bytes and lines for that input.
Unique versus repeated reads.
- The unit test asserts
uniquetrue for the first and false for the repeated habeas read. - It asserts the same for a repeated search result.
- The CLI test asserts a repeated habeas read recorded with
unique == false.
Successful versus failed reads.
usage.rs#mod[tests]/fn[tool_outcomes_are_distinct_and_unknown_names_do_not_leak_model_text]assertstool_failuresandtool_skippedseparately fromtool_calls.- The CLI test asserts that a read of a missing file gives
tool_failures.habeas == 1, alongsidetool_calls.habeas == 3.
Prepared versus sent to the model.
- The unit test asserts
submitted_in_requestandsent_in_requeststart null, then thatsubmitted_in_requestis set afterbegin_requestandsent_in_requestis set after a completedend_request. failed_submission_can_be_confirmed_on_a_later_attemptassertssent_in_requeststays null after a failed request and is set to the retry index after a successful one.mod.rs#fn[throttled_requests_retry_unchanged_and_record_every_attempt]assertssubmitted_in_request == 0andsent_in_request == 5over five throttled attempts.- The CLI test asserts
sent_in_request == 1on a repeated read.
File-discovery calls count as tool calls but are not inputs.
- The CLI test asserts
tool_calls.list_files == 1and that no usage input hasorigin == "list_files". - The tool-outcome unit test asserts
list_filesandoutlineare counted as tool calls whileinputsstays empty. - The CLI test also asserts that evidence inputs exclude
".".
I found no unexercised obligation or missing assertion.
Inputs
Implementation
Input 8: outline src/authoring/usage.rs impl[UsageLog]/fn[search_result]
- File:
src/authoring/usage.rs - Selector:
impl[UsageLog]/fn[search_result] - Kind:
fn src/authoring/usage.rs:169–184
/// Search snippets contribute usage metadata, never evidence inputs.
// {impl}`requirements.authoring.usage_inputs`
pub(super) fn search_result(&mut self, result: &Value) {
for entry in result["matches"].as_array().into_iter().flatten() {
let Some(lines) = entry["lines"].as_array() else {
continue;
};
let text: Vec<_> = lines
.iter()
.filter_map(|line| line["text"].as_str())
.collect();
let input =
json!({"search": true, "file": entry["file"], "item": entry["item"], "text": text});
self.prepared("ripgrep", &[input]);
}
}
Tests
Input 2: outline src/authoring/mod.rs mod[tests]/fn[throttled_requests_retry_unchanged_and_record_every_attempt]
- File:
src/authoring/mod.rs - Selector:
mod[tests]/fn[throttled_requests_retry_unchanged_and_record_every_attempt] - Kind:
fn src/authoring/mod.rs:2228–2268
// {test}`requirements.authoring.provider_backoff`
// {test}`requirements.authoring.usage_requests`
// {test}`requirements.authoring.usage_requests.failures`
// {test}`requirements.authoring.usage_inputs`
// {test}`requirements.ci.reference_set`
#[tokio::test(start_paused = true)]
async fn throttled_requests_retry_unchanged_and_record_every_attempt() {
let (_project, _state, mut sources, mut usage) = retry_fixture();
let provider = ThrottledProvider {
failures: 5,
status: 429,
code: "ThrottlingException",
requests: RefCell::default(),
};
let started = tokio::time::Instant::now();
let (_, record) = assess(&provider, &mut sources, &mut usage).await.unwrap();
assert!(started.elapsed() >= Duration::from_millis(500));
let requests = provider.requests.borrow();
assert_eq!(requests.len(), 6);
assert!(requests.iter().all(|request| request == &requests[0]));
assert_eq!(record["inputs"], json!(sources.mandatory_inputs()));
assert_eq!(record["references"], json!(sources.reference_set));
let log: Value = serde_json::from_slice(&fs::read(&usage.path).unwrap()).unwrap();
assert_eq!(log["request_count"], 6);
for attempt in 0..5 {
assert_eq!(log["requests"][attempt]["outcome"], "failed");
assert_eq!(log["requests"][attempt]["tokens"]["complete"], false);
assert_eq!(
log["requests"][attempt]["failure"],
json!({"http_status": 429, "error_code": "ThrottlingException", "retried": true})
);
}
assert!(log["requests"][5].get("failure").is_none());
assert_eq!(log["requests"][5]["outcome"], "completed");
assert_eq!(log["tool_calls"]["submit_judgment"], 1);
for input in log["inputs"].as_array().unwrap() {
assert_eq!(input["submitted_in_request"], 0);
assert_eq!(input["sent_in_request"], 5);
}
}
Input 3: outline src/authoring/usage.rs mod[tests]/fn[input_metadata_counts_components_and_reads_without_persisting_source]
- File:
src/authoring/usage.rs - Selector:
mod[tests]/fn[input_metadata_counts_components_and_reads_without_persisting_source] - Kind:
fn src/authoring/usage.rs:455–551
// {test}`requirements.authoring.usage_inputs`
// {test}`requirements.authoring.usage_storage`
#[test]
fn input_metadata_counts_components_and_reads_without_persisting_source() {
let state = tempfile::tempdir().unwrap();
let mut log =
UsageLog::start(state.path(), Path::new("/project"), "requirements.case").unwrap();
let file = json!({
"file": "private-source-file.rs", "item": "fn[private_item]", "hash": "0".repeat(64),
"kind": "fn", "line_start": 1, "line_end": 2,
"text": ["λ", "DO_NOT_LOG_SOURCE"]
});
let requirements = json!({
"requirements": "private.match.*",
"matches": ["private.match.a", "private.match.b"],
"text": ["PRIVATE_REQUIREMENT_TEXT"]
});
log.prepared("mandatory", &[file.clone(), requirements]);
log.prepared("habeas", &[file]);
let search = json!({"matches":[{"file":"private-source-file.rs","item":"fn[private_item]","lines":[{"text":"λ"},{"text":"DO_NOT_LOG_SOURCE"}]}]});
log.search_result(&search);
log.search_result(&search);
log.save().unwrap();
let prepared = persisted(&log);
assert_eq!(prepared["inputs"][0]["kind"], "outline");
assert_eq!(prepared["inputs"][0]["bytes"], "λ\nDO_NOT_LOG_SOURCE".len());
assert_eq!(prepared["inputs"][0]["lines"], 2);
assert_eq!(prepared["inputs"][1]["components"], 2);
assert_eq!(prepared["inputs"][1]["kind"], "requirements");
assert_eq!(
prepared["inputs"][1]["bytes"],
"PRIVATE_REQUIREMENT_TEXT".len()
);
assert_eq!(prepared["inputs"][1]["lines"], 1);
assert_eq!(prepared["inputs"][0]["unique"], true);
assert_eq!(prepared["inputs"][2]["unique"], false);
assert_eq!(prepared["inputs"][2]["origin"], "habeas");
assert!(prepared["inputs"][0]["submitted_in_request"].is_null());
assert!(prepared["inputs"][0]["sent_in_request"].is_null());
assert_eq!(prepared["inputs"][3]["kind"], "search");
assert_eq!(prepared["inputs"][3]["bytes"], "λ\nDO_NOT_LOG_SOURCE".len());
assert_eq!(prepared["inputs"][3]["lines"], 2);
assert_eq!(prepared["inputs"][3]["unique"], true);
assert_eq!(prepared["inputs"][4]["unique"], false);
assert!(prepared["inputs"][3]["sent_in_request"].is_null());
log.prepared(
"habeas",
&[
json!({"definition":"private.term","text":["PRIVATE_TERM_TEXT","λ"]}),
json!({"builtin":"habeas:util","text":["PRIVATE_BUILTIN_TEXT"]}),
],
);
log.save().unwrap();
let kinds = persisted(&log);
assert_eq!(kinds["inputs"][5]["kind"], "definition");
assert_eq!(kinds["inputs"][5]["bytes"], "PRIVATE_TERM_TEXT\nλ".len());
assert_eq!(kinds["inputs"][5]["lines"], 2);
assert_eq!(kinds["inputs"][6]["kind"], "builtin");
assert_eq!(kinds["inputs"][6]["bytes"], "PRIVATE_BUILTIN_TEXT".len());
assert_eq!(kinds["inputs"][6]["lines"], 1);
let index = log.begin_request().unwrap();
let submitted = persisted(&log);
assert_eq!(submitted["inputs"][0]["submitted_in_request"], index);
assert!(submitted["inputs"][0]["sent_in_request"].is_null());
log.end_request(index, 7, Some(&Usage::new()), None)
.unwrap();
log.record.determination = Some("FIXME".into());
log.record.evidence_written = true;
log.finish("completed").unwrap();
let sent = persisted(&log);
assert_eq!(sent["inputs"][0]["sent_in_request"], index);
assert_eq!(sent["inputs"][3]["sent_in_request"], index);
assert_eq!(sent["requests"][0]["outcome"], "completed");
assert_eq!(sent["outcome"], "completed");
assert_eq!(sent["determination"], "FIXME");
assert_eq!(sent["evidence_written"], true);
assert!(sent["tokens"]["input"].is_null());
assert!(sent["tokens"]["output"].is_null());
assert_eq!(sent["tokens"]["complete"], false);
let serialized = fs::read_to_string(&log.path).unwrap();
for private in [
"DO_NOT_LOG_SOURCE",
"PRIVATE_REQUIREMENT_TEXT",
"private-source-file.rs",
"private_item",
"private.match",
"private.term",
"PRIVATE_TERM_TEXT",
"PRIVATE_BUILTIN_TEXT",
] {
assert!(
!serialized.contains(private),
"stored source content: {private}"
);
}
}
Input 4: outline src/authoring/usage.rs mod[tests]/fn[tool_outcomes_are_distinct_and_unknown_names_do_not_leak_model_text]
- File:
src/authoring/usage.rs - Selector:
mod[tests]/fn[tool_outcomes_are_distinct_and_unknown_names_do_not_leak_model_text] - Kind:
fn src/authoring/usage.rs:725–758
// {test}`requirements.authoring.usage_requests`
// {test}`requirements.authoring.usage_inputs`
// {test}`requirements.authoring.usage_storage`
#[test]
fn tool_outcomes_are_distinct_and_unknown_names_do_not_leak_model_text() {
let state = tempfile::tempdir().unwrap();
let mut log =
UsageLog::start(state.path(), Path::new("/project"), "requirements.case").unwrap();
log.tool("list_files", false);
log.tool("outline", false);
log.tool("habeas", true);
log.skipped_tool("ripgrep");
log.tool("ast_grep", false);
log.tool("github", false);
log.tool("MODEL_TEXT_SHOULD_NOT_APPEAR", true);
log.skipped_tool("OTHER_MODEL_TEXT");
log.finish("completed").unwrap();
let value = persisted(&log);
assert_eq!(value["tool_call_count"], 8);
assert_eq!(value["tool_calls"]["list_files"], 1);
assert_eq!(value["tool_calls"]["ast_grep"], 1);
assert_eq!(value["tool_calls"]["github"], 1);
assert_eq!(value["tool_calls"]["outline"], 1);
assert_eq!(value["tool_failures"]["habeas"], 1);
assert_eq!(value["tool_skipped"]["ripgrep"], 1);
assert_eq!(value["tool_calls"]["unknown"], 2);
assert_eq!(value["tool_failures"]["unknown"], 1);
assert_eq!(value["tool_skipped"]["unknown"], 1);
assert!(value["inputs"].as_array().unwrap().is_empty());
assert!(value["tokens"]["input"].is_null());
assert_eq!(value["tokens"]["complete"], false);
let serialized = fs::read_to_string(&log.path).unwrap();
assert!(!serialized.contains("MODEL_TEXT"));
}
Input 5: outline src/authoring/usage.rs mod[tests]/fn[failed_submission_can_be_confirmed_on_a_later_attempt]
- File:
src/authoring/usage.rs - Selector:
mod[tests]/fn[failed_submission_can_be_confirmed_on_a_later_attempt] - Kind:
fn src/authoring/usage.rs:760–799
// {test}`requirements.authoring.usage_inputs`
// {test}`requirements.authoring.usage_requests`
// {test}`requirements.authoring.usage_requests.failures`
#[test]
fn failed_submission_can_be_confirmed_on_a_later_attempt() {
let state = tempfile::tempdir().unwrap();
let mut log =
UsageLog::start(state.path(), Path::new("/project"), "requirements.case").unwrap();
log.prepared(
"mandatory",
&[json!({"file": "source", "text": ["source content"]})],
);
let first = log.begin_request().unwrap();
log.end_request(
first,
2,
None,
Some((Some(429), Some("ThrottlingException".to_owned()))),
)
.unwrap();
assert!(persisted(&log)["inputs"][0]["sent_in_request"].is_null());
// A failed request records its status, code, and retry, but no
// message text.
assert_eq!(
persisted(&log)["requests"][first]["failure"],
json!({"http_status": 429, "error_code": "ThrottlingException", "retried": false})
);
log.retried(first).unwrap();
assert_eq!(
persisted(&log)["requests"][first]["failure"]["retried"],
true
);
let retry = log.begin_request().unwrap();
log.end_request(retry, 3, Some(&Usage::new()), None)
.unwrap();
let value = persisted(&log);
assert_eq!(value["inputs"][0]["submitted_in_request"], first);
assert_eq!(value["inputs"][0]["sent_in_request"], retry);
assert_eq!(value["request_count"], 2);
}
Input 6: 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()
);
}
Other sources
Input 1: requirements selection requirements.authoring.usage_inputs
requirements.authoring.usage_inputs:md/requirements/authoring.md:2181–2189
:::{req} usage_inputs
Usage MUST record mandatory input counts and sizes by evidence kind, in UTF-8
bytes and lines, and the same information for additional inputs requested through
`habeas` or `ripgrep`. A requirements input MUST also record its number of matched declarations.
Usage MUST distinguish unique inputs from repeated reads, successful from
failed reads, and prepared inputs from those actually sent to the model.
File-discovery calls MUST count as tool calls without recording directory
listings as evidence or source inputs.
:::
Input 7: outline src/authoring/usage.rs impl[UsageLog]/fn[prepared]
- File:
src/authoring/usage.rs - Selector:
impl[UsageLog]/fn[prepared] - Kind:
fn src/authoring/usage.rs:186–224
pub(super) fn prepared(&mut self, origin: &str, inputs: &[Value]) {
for input in inputs {
let kind = if input.get("search").is_some() {
"search"
} else if input.get("item").is_some() {
"outline"
} else if input.get("requirements").is_some() {
"requirements"
} else if input.get("builtin").is_some() {
// A built-in's fixed text, supplied but not recorded as evidence.
"builtin"
} else {
"definition"
};
let text = input["text"]
.as_array()
.map(Vec::as_slice)
.unwrap_or_default();
let bytes = text
.iter()
.filter_map(Value::as_str)
.map(str::len)
.sum::<usize>()
+ text.len().saturating_sub(1);
self.record.inputs.push(InputUsage {
origin: origin.to_owned(),
kind,
bytes,
lines: text.len(),
components: input
.get("matches")
.and_then(Value::as_array)
.map_or(1, Vec::len),
unique: self.seen.insert(input.to_string()),
submitted_in_request: None,
sent_in_request: None,
});
}
}