requirements.authoring.read_denial.untracked
Requirements index · View definition
Requirement
A tool error for a denied file inside the project that is not in the Git index MUST say that the file is untracked and that the caller can stage it with
git addor permit it with a workspace allow rule. The harness MUST NOT stage or permit the file itself.
Rationale
The tests adequately cover requirements.authoring.read_denial.untracked.
Obligations derived from the text
- The tool error for a denied, in-project file that is not in the Git index says the file is untracked.
- The error says the caller can stage it with
git add. - The error says the caller can permit it with a workspace allow rule.
- The harness does not stage or permit the file itself.
Coverage
- Unit level:
src/authoring/tools.rs#mod[tests]/fn[untracked_diagnostics_name_git_add_and_an_allow_rule]uses a real git repo with an untracked file and an untracked directory.- It dispatches
habeason the file andlist_fileson the directory. - It asserts the error kind is
PermissionDenied. - It asserts the message contains
git addandhabeas.toml allow rule, and names the path. - The test does not assert the word “untracked” in the message. Other tests do, as described below.
- It runs
git status --porcelainafterwards and asserts both paths are still??, so nothing was staged. It also asserts nohabeas.tomlwas created, so nothing was permitted.
- It dispatches
- End to end, mandatory input:
tests/authoring_batch.rs#fn[an_untracked_mandatory_input_is_reported_with_how_to_stage_it]makes an untracked:impl:file and asserts the diagnostic containsnotes.txt,untracked,git addandallow rule. This covers the “says untracked” and “allow rule” clauses together with the stage hint. - End to end, all four tools:
tests/authoring_cli.rs#fn[explicit_untracked_reads_return_an_untracked_error_and_the_assessment_continues]runshabeas,ripgrep,ast_grepandlist_filesagainst untracked paths. It asserts the error returned to the model contains “is untracked” or “untracked, so” and containsgit add. It also asserts the file contents are not delivered and the assessment continues with a recorded tool failure.
Remaining checks
- This CLI test does not check the allow-rule wording. The unit and batch tests cover it, and the message comes from the same diagnostic path.
- Only the unit test checks that the harness does not stage or permit files. Its git-status and no-
habeas.tomlassertions match the “MUST NOT stage or permit” clause. - No distinction in the requirement text is left untested. Denials for other reasons are governed by other requirements.
Inputs
Tests
Input 2: outline src/authoring/tools.rs mod[tests]/fn[untracked_diagnostics_name_git_add_and_an_allow_rule]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[untracked_diagnostics_name_git_add_and_an_allow_rule] - Kind:
fn src/authoring/tools.rs:2205–2243
// {test}`requirements.authoring.read_denial`
// {test}`requirements.authoring.read_denial.untracked`
// {test}`requirements.authoring.tool_descriptions.special_cases`
#[test]
fn untracked_diagnostics_name_git_add_and_an_allow_rule() {
let root = project();
fs::write(root.path().join("tracked.txt"), "tracked\n").unwrap();
git(root.path(), &["init", "--quiet"]);
git(root.path(), &["add", "."]);
fs::create_dir(root.path().join("untracked-dir")).unwrap();
fs::write(root.path().join("untracked-dir/file.rs"), "fn f() {}\n").unwrap();
fs::write(root.path().join("untracked.rs"), "fn g() {}\n").unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
for (name, arguments) in [
("habeas", json!({"file": "untracked.rs", "line_start": 1})),
("list_files", json!({"path": "untracked-dir"})),
] {
let error = dispatch(&sources, name, &arguments).err().unwrap();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied, "{error}");
let message = error.to_string();
assert!(message.contains("git add"), "{message}");
assert!(message.contains("habeas.toml allow rule"), "{message}");
let path = arguments["file"]
.as_str()
.or_else(|| arguments["path"].as_str())
.unwrap();
assert!(message.contains(path), "{message}");
}
// The harness neither stages nor permits the files itself.
let status = std::process::Command::new("git")
.args(["status", "--porcelain"])
.current_dir(root.path())
.output()
.unwrap();
let status = String::from_utf8(status.stdout).unwrap();
assert!(status.contains("?? untracked-dir/"), "{status}");
assert!(status.contains("?? untracked.rs"), "{status}");
assert!(!root.path().join("habeas.toml").exists());
}
Input 3: outline tests/authoring_batch.rs fn[an_untracked_mandatory_input_is_reported_with_how_to_stage_it]
- File:
tests/authoring_batch.rs - Selector:
fn[an_untracked_mandatory_input_is_reported_with_how_to_stage_it] - Kind:
fn tests/authoring_batch.rs:1285–1319
// {test}`requirements.authoring.read_denial.mandatory`
// {test}`requirements.authoring.read_denial.untracked`
#[test]
fn an_untracked_mandatory_input_is_reported_with_how_to_stage_it() {
let server = Server::start_with(
false,
Behavior::Judgments {
failing_subject: None,
},
);
let fixture = Fixture::new(&server.endpoint, Some(1));
let chapter = fixture.project.join("md/requirements.md");
let text = fs::read_to_string(&chapter).unwrap();
fs::write(
&chapter,
text.replacen(":::{req} alpha\n", ":::{req} alpha\n:impl: notes.txt\n", 1),
)
.unwrap();
for args in [["init", "--quiet"], ["add", "."]] {
let git = Command::new("git")
.current_dir(&fixture.project)
.args(args)
.output()
.unwrap();
assert!(git.status.success(), "{git:?}");
}
fs::write(fixture.project.join("notes.txt"), "notes\n").unwrap();
let output = fixture.run(&["author", "requirements.alpha", "--stdout"]);
assert!(!output.status.success(), "{output:?}");
let diagnostic = String::from_utf8_lossy(&output.stderr);
for text in ["notes.txt", "untracked", "git add", "allow rule"] {
assert!(diagnostic.contains(text), "{text}: {diagnostic}");
}
assert!(server.subjects().is_empty());
}
Input 4: outline tests/authoring_cli.rs fn[explicit_untracked_reads_return_an_untracked_error_and_the_assessment_continues]
- File:
tests/authoring_cli.rs - Selector:
fn[explicit_untracked_reads_return_an_untracked_error_and_the_assessment_continues] - Kind:
fn tests/authoring_cli.rs:853–922
// {test}`requirements.authoring.read_denial`
// {test}`requirements.authoring.file_discovery`
// {test}`requirements.authoring.text_search`
// {test}`requirements.authoring.structural_search`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.persistence`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.authoring.usage_requests`
// {test}`requirements.authoring.read_denial.untracked`
// {test}`requirements.authoring.read_denial`
#[test]
fn explicit_untracked_reads_return_an_untracked_error_and_the_assessment_continues() {
for (tool, arguments) in [
("habeas", json!({"file":"untracked.txt", "line_start":1})),
(
"ripgrep",
json!({"path":"untracked.txt", "pattern":"hidden"}),
),
(
"ast_grep",
json!({"path":"untracked.txt", "language":"rust", "rule":{"rule":{"pattern":"hidden"}}}),
),
("list_files", json!({"path":"untracked-directory"})),
] {
let server = Server::start(vec![
reply(vec![call("denied", tool, arguments)]),
reply(vec![call(
"submit",
"submit_judgment",
json!({"determination": true, "rationale": "The tracked sources support it."}),
)]),
]);
let fixture = Fixture::new(&server.endpoint);
for args in [["init", "--quiet"], ["add", "."]] {
let git = Command::new("git")
.current_dir(&fixture.project)
.args(args)
.output()
.unwrap();
assert!(git.status.success(), "{git:?}");
}
fs::write(fixture.project.join("untracked.txt"), "hidden source\n").unwrap();
fs::create_dir(fixture.project.join("untracked-directory")).unwrap();
fs::write(
fixture.project.join("untracked-directory/hidden.txt"),
"hidden source\n",
)
.unwrap();
let output = fixture.run(&["author", SUBJECT, "--stdout"]);
assert!(output.status.success(), "{tool}: {output:?}");
// The model was told the path is untracked and how to fix it, and
// the file was neither delivered nor recorded.
let requests = server.finish();
assert_eq!(requests.len(), 2, "{tool}");
let second = requests[1].body.to_string();
assert!(
second.contains("is untracked") || second.contains("untracked, so"),
"{tool}: {second}"
);
assert!(second.contains("git add"), "{tool}: {second}");
assert!(!second.contains("hidden source"), "{tool}: {second}");
let evidence = String::from_utf8_lossy(&output.stdout);
assert!(!evidence.contains("untracked"), "{tool}: {evidence}");
let usage = fixture.usage();
assert_eq!(usage["outcome"], "completed", "{tool}: {usage}");
assert_eq!(usage["request_count"], 2, "{tool}: {usage}");
assert_eq!(usage["tool_failures"][tool], 1, "{tool}: {usage}");
}
}
Other sources
Input 1: requirements selection requirements.authoring.read_denial.untracked
requirements.authoring.read_denial.untracked:md/requirements/authoring.md:710–715
:::{req} read_denial.untracked
A tool error for a denied file inside the project that is not in the Git index
MUST say that the file is untracked and that the caller can stage it with
`git add` or permit it with a workspace allow rule. The harness MUST NOT stage or
permit the file itself.
:::