requirements.authoring.not_listed
Requirements index · View definition
Requirement
A
list_files,ripgrep, orast_grepresult MUST includenot_listed, an array of{path, reason}with reasonuntracked, naming each untracked file inside the project that the listing would otherwise include or that contains a match, so the model can tell that sources exist which it cannot read. It MUST be omitted when there are none, and for a paged result it MUST appear on the first page, continuing across subsequent pages when needed to obey the page size limit. Page counts MUST include these entries as well as the ordinary result entries, and each array MUST retain its order. It MUST NOT give those files’ contents, and they MUST NOT become evidence inputs. Files excluded for another reason, such as a workspace disallow rule or generatedevidence/output, MUST NOT be read to find matches and MUST NOT be listed.
Rationale
I judged this from the three supplied tests only, and I didn’t request any implementation source. Together they cover each obligation in requirements.authoring.not_listed.
Content and format
src/authoring/tools.rs#mod[tests]/fn[listings_and_searches_name_untracked_files_without_their_contents]runslist_files,ripgrepandast_grepon a repo with untracked files.- It asserts
not_listednames exactly the expected paths:["drafts","untracked.rs"]forlist_files,["drafts/plan.txt","untracked.rs"]forripgrep, and["untracked.rs"]forast_grep. - For
ast_grep, the untrackeddrafts/plan.txtis not a Rust file andsecret.rsis disallowed, so naming onlyuntracked.rsshows that only files that actually match are listed. - Every entry has
reason == "untracked", and the test asserts the entries carry notag. - Result order is checked, because the expected arrays are sorted lists compared with
assert_eq!.
No contents, no evidence
- The same test asserts the serialized result does not contain the untracked file text, either “fn needle” or “a needle here”.
- It asserts
inputsis empty for every tool. - The paging test also asserts
page.inputs.is_empty()on every page.
Omission when there are none
- A
ripgrepquery with no untracked matches has nonot_listedkey. - A
list_filescall onsrc, which has no untracked files at that point, also has nonot_listedkey.
Scope: “inside the project … would otherwise include”
- Untracked files outside the listed or searched path are not named. This is shown by the
list_filesonsrc, which does not nameuntracked.rsordrafts. - After
src/draft.rsis added, the path forms./src,src/../srcand an absolute path each name onlysrc/draft.rs, for all three tools.
Exclusions
- A disallowed
secret.rs(which contains the match) andevidence/note.txtare never named, inlist_files,ripgreporast_grep. The exact-equality assertions on the named lists enforce this. - Whether the excluded files are actually read is not directly observable. A match in them that stayed hidden is the observable consequence, and it is asserted.
Paging
src/authoring/pages.rs#mod[tests]/fn[not_listed_comes_on_the_first_page_within_the_page_limit]uses 800 tracked files and 40 untracked ones throughlist_files.- It asserts the first page has all 40
not_listedentries, every page serializes withinPAGE_LIMIT, and later pages have nonot_listed. src/authoring/pages.rs#mod[tests]/fn[untracked_entries_page_without_tracked_entries_or_oversized_overhead]uses 1000 untracked entries with 0, 1 and 500 tracked entries, sonot_listedmust continue across pages.- It asserts the first page has a non-empty
not_listed, and every page is withinPAGE_LIMITand has no evidence inputs. - It asserts
total_entriesequals tracked plus untracked, andreturned_entriesequals entries plusnot_listedon each page. - The concatenated tracked and untracked arrays equal the originals in order.
I found no unmet obligation or missing boundary case that the text names.
Inputs
Tests
Input 2: outline src/authoring/pages.rs mod[tests]/fn[not_listed_comes_on_the_first_page_within_the_page_limit]
- File:
src/authoring/pages.rs - Selector:
mod[tests]/fn[not_listed_comes_on_the_first_page_within_the_page_limit] - Kind:
fn src/authoring/pages.rs:513–562
// {test}`requirements.authoring.result_pages`
// {test}`requirements.authoring.not_listed`
#[test]
fn not_listed_comes_on_the_first_page_within_the_page_limit() {
let root = project();
for index in 0..800 {
fs::write(
root.path()
.join(format!("src/file_with_a_rather_long_name_{index:04}.rs")),
"fn f() {}\n",
)
.unwrap();
}
let git = |args: &[&str]| {
let output = std::process::Command::new("git")
.current_dir(root.path())
.args(args)
.output()
.unwrap();
assert!(output.status.success(), "{output:?}");
};
git(&["init", "--quiet"]);
git(&["add", "."]);
for index in 0..40 {
fs::write(
root.path().join(format!(
"src/untracked_draft_with_a_long_name_{index:02}.rs"
)),
"fn f() {}\n",
)
.unwrap();
}
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let mut pages = ResultPages::default();
let first =
dispatch_paged(&sources, &mut pages, "list_files", &json!({"path":"src"})).unwrap();
let delivered = all_pages(&mut pages, first);
assert_eq!(
delivered[0].result["not_listed"].as_array().unwrap().len(),
40,
"{}",
delivered[0].result
);
for (number, page) in delivered.iter().enumerate() {
assert!(page.result.to_string().len() <= PAGE_LIMIT, "page {number}");
if number > 0 {
assert!(page.result.get("not_listed").is_none(), "page {number}");
}
}
}
Input 3: outline src/authoring/pages.rs mod[tests]/fn[untracked_entries_page_without_tracked_entries_or_oversized_overhead]
- File:
src/authoring/pages.rs - Selector:
mod[tests]/fn[untracked_entries_page_without_tracked_entries_or_oversized_overhead] - Kind:
fn src/authoring/pages.rs:564–616
// {test}`requirements.authoring.result_pages`
// {test}`requirements.authoring.not_listed`
#[test]
fn untracked_entries_page_without_tracked_entries_or_oversized_overhead() {
let root = project();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let untracked: Vec<Value> = (0..1000)
.map(|i| json!({"path":format!("src/{i:04}_{}.rs", "x".repeat(70)), "reason":"untracked"}))
.collect();
for count in [0, 1, 500] {
let tracked: Vec<Value> = (0..count)
.map(|i| json!({"path":format!("src/tracked_{i:04}.rs"),"kind":"file"}))
.collect();
let mut pages = ResultPages::default();
let first = pages
.deliver(
&sources,
Listing::array(tracked.clone()).with_not_listed(untracked.clone()),
)
.unwrap();
assert!(
first.result["not_listed"]
.as_array()
.is_some_and(|v| !v.is_empty())
);
let delivered = all_pages(&mut pages, first);
let mut actual_tracked = Vec::new();
let mut actual_untracked = Vec::new();
for page in delivered {
assert!(page.result.to_string().len() <= PAGE_LIMIT);
assert!(page.inputs.is_empty(), "untracked paths are never evidence");
let entries = page.result["entries"].as_array().unwrap();
let omitted = page
.result
.get("not_listed")
.and_then(Value::as_array)
.cloned()
.unwrap_or_default();
assert_eq!(
page.result["page"]["total_entries"],
count + untracked.len()
);
assert_eq!(
page.result["page"]["returned_entries"],
entries.len() + omitted.len()
);
actual_tracked.extend(entries.iter().cloned());
actual_untracked.extend(omitted);
}
assert_eq!(actual_tracked, tracked);
assert_eq!(actual_untracked, untracked);
}
}
Input 4: outline src/authoring/tools.rs mod[tests]/fn[listings_and_searches_name_untracked_files_without_their_contents]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[listings_and_searches_name_untracked_files_without_their_contents] - Kind:
fn src/authoring/tools.rs:4220–4317
// {test}`requirements.authoring.not_listed`
// {test}`requirements.authoring.search_accounting.entry_tags`
#[test]
// {test}`requirements.authoring.read_denial`
fn listings_and_searches_name_untracked_files_without_their_contents() {
let root = project();
fs::write(root.path().join("src/lib.rs"), "fn tracked() {}\n").unwrap();
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\ndisallow = ['secret.rs']\n",
)
.unwrap();
git(root.path(), &["init", "--quiet"]);
git(root.path(), &["add", "."]);
fs::write(root.path().join("untracked.rs"), "fn needle() {}\n").unwrap();
fs::create_dir(root.path().join("drafts")).unwrap();
fs::write(root.path().join("drafts/plan.txt"), "a needle here\n").unwrap();
fs::write(root.path().join("secret.rs"), "fn needle() {}\n").unwrap();
fs::create_dir_all(root.path().join("evidence")).unwrap();
fs::write(root.path().join("evidence/note.txt"), "needle\n").unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let named = |result: &Value| {
result["not_listed"]
.as_array()
.map(|entries| {
entries
.iter()
.map(|entry| {
assert_eq!(entry["reason"], "untracked");
assert!(entry.get("tag").is_none());
entry["path"].as_str().unwrap().to_owned()
})
.collect::<Vec<_>>()
})
.unwrap_or_default()
};
let listing = dispatch(&sources, "list_files", &json!({})).unwrap();
assert_eq!(named(&listing.result), ["drafts", "untracked.rs"]);
assert!(
listing.result["entries"]
.as_array()
.unwrap()
.iter()
.any(|entry| entry["path"] == "src")
);
let search = dispatch(&sources, "ripgrep", &json!({"pattern": "needle"})).unwrap();
assert_eq!(named(&search.result), ["drafts/plan.txt", "untracked.rs"]);
let text = search.result.to_string();
assert!(
!text.contains("a needle here") && !text.contains("fn needle"),
"{text}"
);
assert!(search.inputs.is_empty());
let rust = dispatch(
&sources,
"ast_grep",
&json!({"language": "rust", "rule": {"rule": {"pattern": "fn needle() {}"}}}),
)
.unwrap();
assert_eq!(named(&rust.result), ["untracked.rs"]);
for delivery in [&listing, &rust] {
assert!(delivery.inputs.is_empty());
let text = delivery.result.to_string();
assert!(
!text.contains("fn needle") && !text.contains("a needle here"),
"{text}"
);
}
// Nothing untracked matches: no not_listed.
let none = dispatch(&sources, "ripgrep", &json!({"pattern": "tracked\\(\\)"})).unwrap();
assert!(none.result.get("not_listed").is_none(), "{}", none.result);
let inside = dispatch(&sources, "list_files", &json!({"path": "src"})).unwrap();
assert!(
inside.result.get("not_listed").is_none(),
"{}",
inside.result
);
fs::write(root.path().join("src/draft.rs"), "fn needle() {}\n").unwrap();
for path in [
"./src".to_owned(),
"src/../src".to_owned(),
root.path().join("src").to_string_lossy().into_owned(),
] {
for (tool, arguments) in [
("list_files", json!({"path":path})),
("ripgrep", json!({"path":path,"pattern":"needle"})),
(
"ast_grep",
json!({"path":path,"language":"rust","rule":{"rule":{"pattern":"fn needle() {}"}}}),
),
] {
let delivery = dispatch(&sources, tool, &arguments).unwrap();
assert_eq!(named(&delivery.result), ["src/draft.rs"], "{tool}: {path}");
assert!(delivery.inputs.is_empty());
}
}
}
Other sources
Input 1: requirements selection requirements.authoring.not_listed
requirements.authoring.not_listed:md/requirements/authoring.md:605–618
:::{req} not_listed
A `list_files`, `ripgrep`, or `ast_grep` result MUST include `not_listed`, an
array of `{path, reason}` with reason `untracked`, naming each untracked file
inside the project that the listing would otherwise include or that contains a
match, so the model can tell that sources exist which it cannot read. It MUST
be omitted when there are none, and for a paged result it MUST appear on the
first page, continuing across subsequent pages when needed to obey the page
size limit. Page counts MUST include these entries as well as the ordinary
result entries, and each array MUST retain its order. It MUST NOT give those
files' contents, and they MUST NOT become
evidence inputs. Files excluded for another reason, such as a workspace disallow
rule or generated `evidence/` output, MUST NOT be read to find matches and MUST
NOT be listed.
:::