requirements.configuration.evidence_paths
Requirements index · View definition
Requirement
The workspace
[evidence]table MUST serialize EvidenceConfig.allowanddisallowMUST be arrays of nonempty literal paths, each naming a file or a directory subtree. Relative paths MUST resolve from the selectedhabeas.tomldirectory; absolute paths MUST be supported. These paths are not glob patterns. An omittedallowordisallowMUST mean an empty array, and an absent[evidence]table MUST mean both are empty, so only the default source-access rules apply. No operation requires the section. The table has no user-file counterpart, and these rules have no invocation options. This section refinesfor the evidence feature.
For authoring reads, a matching disallow MUST reject the path; otherwise a matching allow MUST permit it; otherwise the default source-access rules MUST apply. Explicit allow MUST override every default, including Git tracking, project containment, generated-evidence exclusion, and automatic generated-output rules. Disallow MUST win even when an allow or generated-output rule also matches. Both the requested path and its resolved symlink target MUST be checked for disallow, so an allowed alias cannot expose a disallowed target.
The same explicit disallow rules and external-path exceptions MUST apply when resolving recorded evidence inputs, including ordinary validation. Validation MUST remain independent of Git index membership: it checks the recorded inputs’ existence and contents. Loading path policy MUST NOT resolve credentials or validate unused authoring settings.
Rationale
The reviewed tests cover every obligation in requirements.configuration.evidence_paths. I did not need implementation source.
Configuration shape and defaults
tests/configuration.rs#fn[feature_sections_are_scoped_and_absent_sections_use_defaults]covers an absent[evidence]table, an empty table and omitted arrays. In each case both lists are empty.- The same test shows
allowanddisalloware rejected outside[evidence]and thatUserConfigrejects[evidence]. That covers “no user-file counterpart”. tests/configuration.rs#fn[evidence_configuration_ignores_unused_authoring_settings_and_detects_credentials]rejects an empty-stringallowentry, a non-stringdisallowentry and unknown keys. It also checks that the path from the file is carried as written.tests/configuration.rs#fn[workspace_discovery_uses_nearest_file_without_merging_or_rewriting_it]checks that allow and disallow are populated as paths and that the config round-trips.- Only
allowis tested with an empty string. Thedisallowlist almost certainly shares the same type, so I did not treat this as a gap.
Literal paths, files and subtrees
src/authoring/access.rs#fn[evidence_rules_are_literal_paths_not_globs]shows glob-looking rules match nothing, while a file literally named*.txtorsrc/*is matched exactly.- Both file and directory rules are exercised:
target/docandbook/page.htmlinexplicit_allow_overrides_the_build_output_refusal, andsrc/main.rsinstatus_applies_workspace_disallow_to_existing_evidence.
Relative and absolute paths
- Relative paths resolve from the
habeas.tomldirectory in theSourceAccesstests and intests/configuration.rs(closest.root). - Absolute paths are tested through external temp directories in
explicit_allow_overrides_defaults_but_disallow_wins_for_alias_targetsandconfigured_external_inputs_validate_and_remain_subject_to_freshness_and_disallow.
Authoring-read precedence
- Disallow beats allow:
generated/privateinside allowedgenerated, inexplicit_allow_overrides_defaults_but_disallow_wins_for_alias_targetsand in thesrc/authoring/tools.rstestallowed_ignored_and_external_sources_are_discoverable_but_disallowed_descendants_are_not. - Allow beats the defaults:
- Git tracking and the ignored file:
generated. - Project containment: the external directory.
- Generated-evidence exclusion:
evidence/old.txt. - Build-output rules:
explicit_allow_overrides_the_build_output_refusal.
- Git tracking and the ignored file:
- Disallow beats the automatic generated-output rule in
cargo_output_is_discovered_and_read_without_building_or_allowing_other_target_files. That test also checks thePermissionDeniedkind and that the message names the path. - The default rules apply when nothing matches, in
evidence_rules_are_literal_paths_not_globs.
Symlinks
- Alias targets: an allowed alias to a disallowed target is denied in
explicit_allow_overrides_defaults_but_disallow_wins_for_alias_targets. - Disallowed ancestors:
disallowed_ancestors_cannot_redirect_reads_into_allowed_targetsandpolicy_resolves_symlinks_before_parent_components_without_allowing_wrong_subtreescover symlinks,..components and wrong-subtree cases.
Recorded evidence inputs and validation
- The same disallow rules apply, with ancestors and symlinks, in
tests/evidence_boundaries.rs#fn[evidence_rejects_disallowed_ancestors_even_when_symlinks_target_allowed_sources]. - External-path exceptions apply, and removing the allow produces “outside the repository” in
configured_external_inputs_validate_and_remain_subject_to_freshness_and_disallow. - A disallow on a discovered external Cargo output directory is rejected in
discovered_external_cargo_outputs_validate_freshness_and_obey_disallow. status_applies_workspace_disallow_to_existing_evidencecovers thestatuspath.validation_of_recorded_inputs_is_independent_of_the_git_indexshows an unstaged file validates and an edit to it is detected. Existence and content checks are covered there and inunreadable_and_missing_inputs_are_reported.
No credential resolution or unused-authoring validation
load_workspace_evidencesucceeds despite an unknown backend, credentials and invalid authoring values, and the credential text never appears in errors. This is inevidence_configuration_ignores_unused_authoring_settings_and_detects_credentials.validation_checks_workspace_common_config_without_loading_unused_authoring_settingsshows validation passes with invalid unused authoring settings.status_loads_nearest_workspace_file_without_validating_authoringshows thestatuscommand does the same.
“No invocation options” is a negative structural statement with no behavior to test.
Inputs
Tests
Input 2: outline src/authoring/access.rs mod[tests]/fn[explicit_allow_overrides_defaults_but_disallow_wins_for_alias_targets]
- File:
src/authoring/access.rs - Selector:
mod[tests]/fn[explicit_allow_overrides_defaults_but_disallow_wins_for_alias_targets] - Kind:
fn src/authoring/access.rs:860–906
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.read_denial`
// {test}`requirements.ci.input_containment`
#[test]
fn explicit_allow_overrides_defaults_but_disallow_wins_for_alias_targets() {
let root = tempfile::tempdir().unwrap();
let external = tempfile::tempdir().unwrap();
fs::create_dir_all(root.path().join("generated/private")).unwrap();
fs::create_dir(root.path().join("evidence")).unwrap();
fs::write(root.path().join("generated/ok.txt"), "generated\n").unwrap();
fs::write(root.path().join("generated/private/secret.txt"), "secret\n").unwrap();
fs::write(root.path().join("evidence/old.txt"), "old judgment\n").unwrap();
fs::write(external.path().join("outside.txt"), "outside\n").unwrap();
git(root.path(), &["init", "--quiet"]);
let external_toml = toml::Value::String(external.path().display().to_string());
fs::write(root.path().join("habeas.toml"), format!(
"version = 1\n[evidence]\nallow = ['generated', 'evidence', {external_toml}]\ndisallow = ['generated/private']\n"
)).unwrap();
let root = fs::canonicalize(root.path()).unwrap();
let access = SourceAccess::load(&root).unwrap();
for path in [
root.join("generated/ok.txt"),
root.join("evidence/old.txt"),
external.path().join("outside.txt"),
] {
assert!(access.file(&root, &path).is_ok(), "{}", path.display());
assert!(resolve_evidence_file(&root, path.to_str().unwrap()).is_ok());
}
let error = access
.file(&root, Path::new("generated/private/secret.txt"))
.unwrap_err();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied);
assert!(resolve_evidence_file(&root, "generated/private/secret.txt").is_err());
#[cfg(unix)]
{
std::os::unix::fs::symlink(
root.join("generated/private/secret.txt"),
root.join("generated/alias.txt"),
)
.unwrap();
let error = access
.file(&root, Path::new("generated/alias.txt"))
.unwrap_err();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied);
}
}
Input 3: outline src/authoring/access.rs mod[tests]/fn[explicit_allow_overrides_the_build_output_refusal]
- File:
src/authoring/access.rs - Selector:
mod[tests]/fn[explicit_allow_overrides_the_build_output_refusal] - Kind:
fn src/authoring/access.rs:908–935
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.authoring.generated_inputs`
// {test}`requirements.authoring.read_denial.build_output`
#[test]
fn explicit_allow_overrides_the_build_output_refusal() {
let root = tempfile::tempdir().unwrap();
for directory in ["target/doc", "book"] {
fs::create_dir_all(root.path().join(directory)).unwrap();
fs::write(root.path().join(directory).join("page.html"), "built\n").unwrap();
}
let root = fs::canonicalize(root.path()).unwrap();
for file in ["target/doc/page.html", "book/page.html"] {
let error = SourceAccess::load(&root)
.unwrap()
.file(&root, Path::new(file))
.unwrap_err();
assert!(error.to_string().contains("holds build output"), "{error}");
}
fs::write(
root.join("habeas.toml"),
"version = 1\n[evidence]\nallow = ['target/doc', 'book/page.html']\n",
)
.unwrap();
let access = SourceAccess::load(&root).unwrap();
for file in ["target/doc/page.html", "book/page.html"] {
assert!(access.file(&root, Path::new(file)).is_ok(), "{file}");
}
}
Input 4: outline src/authoring/access.rs mod[tests]/fn[evidence_rules_are_literal_paths_not_globs]
- File:
src/authoring/access.rs - Selector:
mod[tests]/fn[evidence_rules_are_literal_paths_not_globs] - Kind:
fn src/authoring/access.rs:937–972
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.authoring.tool_descriptions.special_cases`
#[test]
fn evidence_rules_are_literal_paths_not_globs() {
let root = tempfile::tempdir().unwrap();
fs::create_dir_all(root.path().join("src")).unwrap();
fs::write(root.path().join("src/lib.rs"), "pub fn lib() {}\n").unwrap();
fs::write(root.path().join("notes.txt"), "notes\n").unwrap();
git(root.path(), &["init", "--quiet"]);
git(root.path(), &["add", "src/lib.rs"]);
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\nallow = ['*.txt', 'note?.txt']\ndisallow = ['src/*', 'src/[a-z]*.rs']\n",
)
.unwrap();
let root = fs::canonicalize(root.path()).unwrap();
let access = SourceAccess::load(&root).unwrap();
// No pattern matches: the tracked file stays readable and the
// untracked one stays refused by the default rules.
assert!(access.file(&root, Path::new("src/lib.rs")).is_ok());
assert!(access.file(&root, Path::new("notes.txt")).is_err());
#[cfg(unix)]
{
// A rule names exactly the path written, metacharacters included.
fs::write(root.join("*.txt"), "literal\n").unwrap();
fs::write(root.join("src/*"), "literal\n").unwrap();
let access = SourceAccess::load(&root).unwrap();
assert!(access.file(&root, Path::new("*.txt")).is_ok());
let error = access.file(&root, Path::new("src/*")).unwrap_err();
assert!(
error.to_string().contains("disallowed by habeas.toml rule"),
"{error}"
);
assert!(access.file(&root, Path::new("src/lib.rs")).is_ok());
}
}
Input 5: outline src/authoring/access.rs mod[tests]/fn[workspace_configuration_with_credentials_is_readable_unless_disallowed]
- File:
src/authoring/access.rs - Selector:
mod[tests]/fn[workspace_configuration_with_credentials_is_readable_unless_disallowed] - Kind:
fn src/authoring/access.rs:974–996
// {test}`requirements.authoring.credentials`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.authoring.read_denial`
// {test}`requirements.authoring.source_tools`
#[test]
fn workspace_configuration_with_credentials_is_readable_unless_disallowed() {
let root = tempfile::tempdir().unwrap();
let config = "version = 1\n[authoring.configs.local]\nbackend = 'ollama'\nmodel = 'fixture'\napi_key = 'TEST_KEY'\n";
fs::write(root.path().join("habeas.toml"), config).unwrap();
let access = SourceAccess::load(root.path()).unwrap();
assert!(access.file(root.path(), Path::new("habeas.toml")).is_ok());
fs::write(
root.path().join("habeas.toml"),
format!("{config}\n[evidence]\ndisallow = ['habeas.toml']\n"),
)
.unwrap();
let error = SourceAccess::load(root.path())
.unwrap()
.file(root.path(), Path::new("habeas.toml"))
.unwrap_err();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied);
assert!(!error.to_string().contains("TEST_KEY"));
}
Input 6: outline src/authoring/access.rs mod[tests]/fn[disallowed_ancestors_cannot_redirect_reads_into_allowed_targets]
- File:
src/authoring/access.rs - Selector:
mod[tests]/fn[disallowed_ancestors_cannot_redirect_reads_into_allowed_targets] - Kind:
fn src/authoring/access.rs:998–1035
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.read_denial`
// {test}`requirements.ci.input_containment`
#[cfg(unix)]
#[test]
fn disallowed_ancestors_cannot_redirect_reads_into_allowed_targets() {
let root = tempfile::tempdir().unwrap();
for directory in ["private", "public", "sub"] {
fs::create_dir(root.path().join(directory)).unwrap();
}
fs::write(root.path().join("public/file.txt"), "public source\n").unwrap();
std::os::unix::fs::symlink("../public", root.path().join("private/link")).unwrap();
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\nallow = ['public']\ndisallow = ['private']\n",
)
.unwrap();
let access = SourceAccess::load(root.path()).unwrap();
assert!(
access
.file(root.path(), Path::new("public/file.txt"))
.is_ok()
);
for path in [
"private/link/file.txt",
"sub/../private/link/file.txt",
"private/link",
] {
let error = access.path(root.path(), Path::new(path)).unwrap_err();
assert_eq!(
error.kind(),
io::ErrorKind::PermissionDenied,
"{path}: {error}"
);
assert!(error.to_string().contains(path), "{error}");
}
}
Input 7: outline src/authoring/access.rs mod[tests]/fn[policy_resolves_symlinks_before_parent_components_without_allowing_wrong_subtrees]
- File:
src/authoring/access.rs - Selector:
mod[tests]/fn[policy_resolves_symlinks_before_parent_components_without_allowing_wrong_subtrees] - Kind:
fn src/authoring/access.rs:1064–1140
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.read_denial`
// {test}`requirements.ci.input_containment`
#[cfg(unix)]
#[test]
fn policy_resolves_symlinks_before_parent_components_without_allowing_wrong_subtrees() {
let root = tempfile::tempdir().unwrap();
for directory in ["actual/nested", "actual/private", "private"] {
fs::create_dir_all(root.path().join(directory)).unwrap();
}
fs::write(root.path().join("actual/private/file.txt"), "actual\n").unwrap();
fs::write(root.path().join("private/file.txt"), "wrong subtree\n").unwrap();
std::os::unix::fs::symlink(root.path().join("actual/nested"), root.path().join("alias"))
.unwrap();
git(root.path(), &["init", "--quiet"]);
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\nallow = ['alias/../private']\n",
)
.unwrap();
let access = SourceAccess::load(root.path()).unwrap();
assert!(
access
.file(root.path(), Path::new("actual/private/file.txt"))
.is_ok()
);
assert!(
access
.file(root.path(), Path::new("alias/../private/file.txt"))
.is_ok()
);
assert_eq!(
access
.file(root.path(), Path::new("private/file.txt"))
.unwrap_err()
.kind(),
io::ErrorKind::PermissionDenied
);
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\nallow = ['.']\ndisallow = ['alias/../private']\n",
)
.unwrap();
let access = SourceAccess::load(root.path()).unwrap();
for denied in ["actual/private/file.txt", "alias/../private/file.txt"] {
assert_eq!(
access
.file(root.path(), Path::new(denied))
.unwrap_err()
.kind(),
io::ErrorKind::PermissionDenied
);
assert!(resolve_evidence_file(root.path(), denied).is_err());
}
assert!(
access
.file(root.path(), Path::new("private/file.txt"))
.is_ok()
);
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\nallow = ['actual/private']\n",
)
.unwrap();
let access = SourceAccess::load(root.path()).unwrap();
assert_eq!(
access
.file(
root.path(),
Path::new("actual/private/../../private/file.txt")
)
.unwrap_err()
.kind(),
io::ErrorKind::PermissionDenied
);
}
Input 8: outline src/authoring/inputs.rs mod[tests]/fn[disallowed_mandatory_inputs_abort_preparation]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[disallowed_mandatory_inputs_abort_preparation] - Kind:
fn src/authoring/inputs.rs:1215–1231
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.authoring.mandatory_inputs`
// {test}`requirements.authoring.read_denial`
#[test]
fn disallowed_mandatory_inputs_abort_preparation() {
let root = project();
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\ndisallow = ['md/requirements.md']\n",
)
.unwrap();
let error = AssessmentSources::prepare(root.path(), "requirements.ready")
.err()
.unwrap();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied, "{error}");
assert!(error.to_string().contains("md/requirements.md"), "{error}");
}
Input 9: outline src/authoring/tools.rs mod[tests]/fn[allowed_ignored_and_external_sources_are_discoverable_but_disallowed_descendants_are_not]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[allowed_ignored_and_external_sources_are_discoverable_but_disallowed_descendants_are_not] - Kind:
fn src/authoring/tools.rs:2432–2566
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.file_discovery`
// {test}`requirements.authoring.text_search`
// {test}`requirements.authoring.read_denial`
// {test}`requirements.authoring.structural_search`
#[test]
fn allowed_ignored_and_external_sources_are_discoverable_but_disallowed_descendants_are_not() {
let root = project();
let external = tempfile::tempdir().unwrap();
fs::create_dir_all(root.path().join("generated/private")).unwrap();
fs::write(
root.path().join("generated/visible.txt"),
"needle allowed\n",
)
.unwrap();
fs::write(
root.path().join("generated/private/hidden.txt"),
"needle denied\n",
)
.unwrap();
fs::write(external.path().join("outside.txt"), "needle external\n").unwrap();
fs::write(external.path().join("outside.rs"), "fn external() {}\n").unwrap();
fs::write(
root.path().join("generated/visible.rs"),
"fn visible() {}\n",
)
.unwrap();
fs::write(
root.path().join("generated/private/denied.rs"),
"fn denied() {}\n",
)
.unwrap();
fs::write(root.path().join(".hidden.rs"), "fn hidden() {}\n").unwrap();
fs::write(root.path().join(".gitignore"), "generated/\n").unwrap();
git(root.path(), &["init", "--quiet"]);
git(root.path(), &["add", "."]);
let external_toml = toml::Value::String(external.path().display().to_string());
fs::write(root.path().join("habeas.toml"), format!(
"version = 1\n[evidence]\nallow = ['generated', '.hidden.rs', {external_toml}]\ndisallow = ['generated/private']\n"
)).unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let listing = dispatch(&sources, "list_files", &json!({})).unwrap();
let paths = listing
.result
.get("entries")
.unwrap_or(&listing.result)
.as_array()
.unwrap()
.iter()
.map(|entry| entry["path"].as_str().unwrap())
.collect::<Vec<_>>();
assert!(paths.contains(&"generated"));
assert!(paths.contains(&external.path().to_str().unwrap()));
let generated = dispatch(&sources, "list_files", &json!({"path":"generated"})).unwrap();
assert_eq!(
generated.result,
json!([
{"path":"generated/visible.rs", "kind":"file"},
{"path":"generated/visible.txt", "kind":"file"}
])
);
assert!(generated.inputs.is_empty());
let external_listing =
dispatch(&sources, "list_files", &json!({"path":external.path()})).unwrap();
assert_eq!(
external_listing.result,
json!([
{"path":external.path().join("outside.rs"),"kind":"file"},
{"path":external.path().join("outside.txt"),"kind":"file"}
])
);
assert!(external_listing.inputs.is_empty());
let structural = dispatch(
&sources,
"ast_grep",
&json!({"language":"rust","rule":{"rule":{"kind":"function_item"}}}),
)
.unwrap();
let structural_files = matched(&structural)
.iter()
.map(|entry| entry["file"].as_str().unwrap())
.collect::<Vec<_>>();
for expected in [
".hidden.rs",
"generated/visible.rs",
external.path().join("outside.rs").to_str().unwrap(),
] {
assert!(structural_files.contains(&expected), "{structural_files:?}");
}
assert!(!structural_files.contains(&"generated/private/denied.rs"));
assert!(structural.inputs.is_empty());
let search = dispatch(
&sources,
"ripgrep",
&json!({"pattern":"needle", "context":0}),
)
.unwrap();
assert_eq!(matched(&search).len(), 2);
assert!(
matched(&search)
.iter()
.any(|input| input["file"] == "generated/visible.txt")
);
assert!(matched(&search).iter().any(|input| input["file"] == external.path().join("outside.txt").to_str().unwrap()));
let read = dispatch(
&sources,
"habeas",
&json!({"file":external.path().join("outside.txt"), "line_start":1}),
)
.unwrap();
assert_eq!(read.result["inputs"][0]["text"], json!(["needle external"]));
for (name, args) in [
(
"habeas",
json!({"file":"generated/private/hidden.txt", "line_start":1}),
),
("list_files", json!({"path":"generated/private"})),
(
"ripgrep",
json!({"path":"generated/private", "pattern":"needle"}),
),
(
"ast_grep",
json!({"path":"generated/private","language":"rust","rule":{"rule":{"kind":"function_item"}}}),
),
] {
assert_eq!(
dispatch(&sources, name, &args).err().unwrap().kind(),
io::ErrorKind::PermissionDenied
);
}
}
Input 10: outline src/authoring/tools.rs mod[tests]/fn[cargo_output_is_discovered_and_read_without_building_or_allowing_other_target_files]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[cargo_output_is_discovered_and_read_without_building_or_allowing_other_target_files] - Kind:
fn src/authoring/tools.rs:2568–2703
// {test}`requirements.authoring.generated_inputs`
// {test}`requirements.authoring.file_discovery`
// {test}`requirements.authoring.text_search`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.authoring.read_denial`
// {test}`requirements.authoring.read_denial.build_output`
// {test}`requirements.authoring.structural_search`
#[test]
fn cargo_output_is_discovered_and_read_without_building_or_allowing_other_target_files() {
let root = project();
fs::write(root.path().join("src/lib.rs"), "pub fn ready() {}\n").unwrap();
fs::write(
root.path().join("Cargo.lock"),
"version = 4\n\n[[package]]\nname = 'fixture'\nversion = '0.1.0'\n",
)
.unwrap();
fs::write(root.path().join(".gitignore"), "target/\n").unwrap();
git(root.path(), &["init", "--quiet"]);
git(root.path(), &["add", "."]);
let unbuilt = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
assert!(
dispatch(
&unbuilt,
"habeas",
&json!({"file":"src/lib.rs", "line_start":1})
)
.is_ok()
);
assert!(!root.path().join("target").exists());
let out = root.path().join("target/debug/build/fixture-hash/out");
fs::create_dir_all(&out).unwrap();
fs::write(out.join("generated.rs"), "pub fn generated_needle() {}\n").unwrap();
fs::write(
out.parent().unwrap().join("root-output"),
out.to_str().unwrap(),
)
.unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let listing = dispatch(&sources, "list_files", &json!({})).unwrap();
assert!(
listing
.result
.get("entries")
.unwrap_or(&listing.result)
.as_array()
.unwrap()
.iter()
.any(|entry| entry["path"] == "target/debug/build/fixture-hash/out")
);
let search = dispatch(&sources, "ripgrep", &json!({"pattern":"generated_needle"})).unwrap();
let generated = dispatch(
&sources,
"list_files",
&json!({"path":"target/debug/build/fixture-hash/out"}),
)
.unwrap();
assert_eq!(
generated.result,
json!([{"path":"target/debug/build/fixture-hash/out/generated.rs","kind":"file"}])
);
assert!(generated.inputs.is_empty());
assert_eq!(matched(&search).len(), 1);
let structural_arguments =
json!({"language":"rust","rule":{"rule":{"pattern":"pub fn generated_needle() {}"}}});
let structural = dispatch(&sources, "ast_grep", &structural_arguments).unwrap();
assert_eq!(
found(&structural),
["target/debug/build/fixture-hash/out/generated.rs#fn[generated_needle]"]
);
assert!(structural.inputs.is_empty());
let read = dispatch(&sources, "habeas", &json!({"file":"target/debug/build/fixture-hash/out/generated.rs", "item":"fn[generated_needle]"})).unwrap();
assert_eq!(
read.result["input"]["text"],
json!(["pub fn generated_needle() {}"])
);
// Other build output under target is an ordinary read failure.
let error = dispatch(
&sources,
"habeas",
&json!({"file":"target/debug/build/fixture-hash/root-output", "line_start":1}),
)
.err()
.unwrap();
assert_ne!(error.kind(), io::ErrorKind::PermissionDenied, "{error}");
assert!(error.to_string().contains("holds build output"), "{error}");
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\ndisallow = ['target/debug/build/fixture-hash/out']\n",
)
.unwrap();
let denied = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let listing = dispatch(&denied, "list_files", &json!({})).unwrap();
assert!(
!listing
.result
.get("entries")
.unwrap_or(&listing.result)
.as_array()
.unwrap()
.iter()
.any(|entry| entry["path"] == "target/debug/build/fixture-hash/out")
);
assert!(
matched(&dispatch(&denied, "ripgrep", &json!({"pattern":"generated_needle"})).unwrap())
.is_empty()
);
assert!(matched(&dispatch(&denied, "ast_grep", &structural_arguments).unwrap()).is_empty());
for (name, arguments) in [
(
"habeas",
json!({"file":"target/debug/build/fixture-hash/out/generated.rs", "line_start":1}),
),
(
"list_files",
json!({"path":"target/debug/build/fixture-hash/out"}),
),
(
"ripgrep",
json!({"path":"target/debug/build/fixture-hash/out", "pattern":"generated_needle"}),
),
(
"ast_grep",
json!({"path":"target/debug/build/fixture-hash/out","language":"rust","rule":{"rule":{"kind":"function_item"}}}),
),
] {
let error = dispatch(&denied, name, &arguments).err().unwrap();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied, "{error}");
assert!(error.to_string().contains("disallowed"), "{error}");
let path = arguments["file"]
.as_str()
.or_else(|| arguments["path"].as_str())
.unwrap();
assert!(error.to_string().contains(path), "{error}");
}
}
Input 11: outline src/authoring/tools.rs mod[tests]/fn[search_uses_the_validated_target_when_symlinks_precede_parent_components]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[search_uses_the_validated_target_when_symlinks_precede_parent_components] - Kind:
fn src/authoring/tools.rs:2705–2730
// {test}`requirements.authoring.text_search`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.ci.input_containment`
#[cfg(unix)]
#[test]
fn search_uses_the_validated_target_when_symlinks_precede_parent_components() {
let root = project();
fs::create_dir_all(root.path().join("actual/nested")).unwrap();
fs::write(root.path().join("actual/needle.txt"), "actual needle\n").unwrap();
fs::write(root.path().join("needle.txt"), "wrong needle\n").unwrap();
std::os::unix::fs::symlink(root.path().join("actual/nested"), root.path().join("alias"))
.unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let result = dispatch(
&sources,
"ripgrep",
&json!({"path":"alias/../needle.txt", "pattern":"needle", "context":0}),
)
.unwrap();
assert_eq!(matched(&result).len(), 1);
assert_eq!(matched(&result)[0]["file"], "actual/needle.txt");
assert_eq!(
matched(&result)[0]["lines"],
json!([{"text": "actual needle", "matched": true}])
);
}
Input 12: outline tests/commands.rs fn[status_loads_nearest_workspace_file_without_validating_authoring]
- File:
tests/commands.rs - Selector:
fn[status_loads_nearest_workspace_file_without_validating_authoring] - Kind:
fn tests/commands.rs:223–269
// {test}`requirements.configuration.workspace_location`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.loading`
// {test}`requirements.authoring.deterministic_validation`
// {test}`requirements.cli.status`
// {test}`requirements.ci.errors`
#[test]
fn status_loads_nearest_workspace_file_without_validating_authoring() {
let temp = fixture();
let nested = temp.path().join("src/nested");
fs::write(temp.path().join("habeas.toml"), "version = 99\n").unwrap();
fs::write(
nested.join("habeas.toml"),
"version = 1\n[authoring]\nconfigs = 'invalid but unused'\n",
)
.unwrap();
let output = habeas(&nested, &["status"]);
assert!(output.status.success(), "{output:?}");
// An invalid workspace file is one validation finding: `status` and
// `info` still run and report the checks that do not depend on it.
for args in [["status"].as_slice(), ["info", "requirements.*"].as_slice()] {
let output = habeas(temp.path(), args);
assert!(output.status.success(), "{args:?}: {output:?}");
let text = String::from_utf8(output.stdout).unwrap();
assert!(
text.contains("habeas.toml: version: expected version = 1"),
"{args:?}: {text}"
);
assert!(
text.contains("evidence/requirements.malformed.json: invalid JSON"),
"{args:?}: {text}"
);
}
fs::write(temp.path().join("habeas.toml"), "version = 1\n").unwrap();
fs::write(nested.join("habeas.toml"), "version = [\n").unwrap();
let output = habeas(&nested, &["status"]);
assert!(output.status.success(), "{output:?}");
let text = String::from_utf8(output.stdout).unwrap();
assert!(
text.contains(&nested.join("habeas.toml").display().to_string())
&& text.contains("evidence/requirements.malformed.json: invalid JSON"),
"{text}"
);
}
Input 13: outline tests/commands.rs fn[status_applies_workspace_disallow_to_existing_evidence]
- File:
tests/commands.rs - Selector:
fn[status_applies_workspace_disallow_to_existing_evidence] - Kind:
fn tests/commands.rs:271–291
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.ci.input_containment`
// {test}`requirements.cli.status`
// {test}`requirements.authoring.deterministic_validation`
#[test]
fn status_applies_workspace_disallow_to_existing_evidence() {
let temp = fixture();
fs::write(
temp.path().join("habeas.toml"),
"version = 1\n[evidence]\nallow = ['src']\ndisallow = ['src/main.rs']\n",
)
.unwrap();
let output = habeas(temp.path(), &["status", "requirements.ready"]);
assert!(output.status.success(), "{output:?}");
let text = String::from_utf8(output.stdout).unwrap();
assert!(
text.contains("Invalid") && text.contains("disallowed"),
"{text}"
);
assert!(text.contains("src/main.rs"), "{text}");
}
Input 14: outline tests/configuration.rs fn[workspace_discovery_uses_nearest_file_without_merging_or_rewriting_it]
- File:
tests/configuration.rs - Selector:
fn[workspace_discovery_uses_nearest_file_without_merging_or_rewriting_it] - Kind:
fn tests/configuration.rs:416–474
// {test}`requirements.configuration.workspace_location`
// {test}`requirements.authoring.configuration_serialization`
// {test}`requirements.authoring.configuration_structure`
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.loading`
// {test}`requirements.configuration.serialization`
#[test]
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.documentation`
fn workspace_discovery_uses_nearest_file_without_merging_or_rewriting_it() {
let temp = tempfile::tempdir().unwrap();
let project = temp.path().join("project");
let nested = project.join("nested/deep");
fs::create_dir_all(&nested).unwrap();
let outer = temp.path().join("habeas.toml");
fs::write(&outer, "version = 1\n[evidence]\nallow = ['outer']\n").unwrap();
let inherited = load_workspace_config(&project).unwrap().unwrap();
assert_eq!(inherited.path, outer);
assert_eq!(inherited.root, temp.path().canonicalize().unwrap());
let path = project.join("nested/habeas.toml");
let text = "# preserved\nversion = 1\n[authoring]\ndefault = 'cloud'\n[evidence]\ndisallow = ['private']\n";
fs::write(&path, text).unwrap();
let closest = load_workspace_config(&nested).unwrap().unwrap();
assert_eq!(closest.path, path);
assert_eq!(closest.root, path.parent().unwrap());
assert!(
closest
.config
.authoring
.as_ref()
.unwrap()
.configs
.is_empty()
);
assert!(closest.config.evidence.as_ref().unwrap().allow.is_empty());
assert_eq!(
closest.config.evidence.as_ref().unwrap().disallow,
vec![Path::new("private")]
);
assert_eq!(fs::read_to_string(&path).unwrap(), text);
let serialized = closest.config.to_toml().unwrap();
assert!(!serialized.contains("configs"));
assert_eq!(
WorkspaceConfig::parse(&serialized, &path).unwrap(),
closest.config
);
fs::write(&path, "version = 1\n[evidence\n").unwrap();
let error = load_workspace_config(&nested).unwrap_err().to_string();
assert!(error.contains(path.to_str().unwrap()), "{error}");
assert!(error.contains("invalid TOML"), "{error}");
assert_eq!(
fs::read_to_string(&path).unwrap(),
"version = 1\n[evidence\n"
);
fs::remove_file(path).unwrap();
fs::remove_file(outer).unwrap();
assert!(load_workspace_config(&nested).unwrap().is_none());
}
Input 15: outline tests/configuration.rs fn[evidence_configuration_ignores_unused_authoring_settings_and_detects_credentials]
- File:
tests/configuration.rs - Selector:
fn[evidence_configuration_ignores_unused_authoring_settings_and_detects_credentials] - Kind:
fn tests/configuration.rs:476–517
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.loading`
// {test}`requirements.authoring.credentials`
#[test]
fn evidence_configuration_ignores_unused_authoring_settings_and_detects_credentials() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("habeas.toml");
fs::write(&path, "version = 1\n[evidence]\nallow = ['generated', '../shared']\ndisallow = ['generated/private']\n[authoring.configs.cloud]\nbackend = 'unknown'\ncredentials = 'DO_NOT_PRINT_THIS_CREDENTIAL'\n").unwrap();
let policy = load_workspace_evidence(temp.path()).unwrap().unwrap();
assert_eq!(policy.path, path);
assert_eq!(policy.root, temp.path().canonicalize().unwrap());
assert_eq!(
policy.evidence.allow,
vec![Path::new("generated"), Path::new("../shared")]
);
assert!(policy.contains_credentials);
let error = load_workspace_config(temp.path()).unwrap_err().to_string();
assert!(!error.contains("DO_NOT_PRINT_THIS_CREDENTIAL"), "{error}");
fs::write(&path, "version = 1\n[authoring]\ndefault = 123\n").unwrap();
assert!(
!load_workspace_evidence(temp.path())
.unwrap()
.unwrap()
.contains_credentials
);
assert!(load_workspace_config(temp.path()).is_err());
for source in [
"version = 2",
"version = 1\nunknown = true",
"version = 1\n[evidence]\nallow = ['']",
"version = 1\n[evidence]\ndisallow = [42]",
"version = 1\n[evidence]\nunknown = []",
] {
fs::write(&path, source).unwrap();
let error = load_workspace_evidence(temp.path())
.unwrap_err()
.to_string();
assert!(error.contains(path.to_str().unwrap()), "{error}");
}
}
Input 16: outline tests/configuration.rs fn[feature_sections_are_scoped_and_absent_sections_use_defaults]
- File:
tests/configuration.rs - Selector:
fn[feature_sections_are_scoped_and_absent_sections_use_defaults] - Kind:
fn tests/configuration.rs:1203–1271
// {test}`requirements.configuration.feature_sections`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.structure`
// {test}`requirements.configuration.workspace_structure`
#[test]
fn feature_sections_are_scoped_and_absent_sections_use_defaults() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("habeas.toml");
// An absent `[evidence]` table, or omitted arrays, mean empty lists.
for source in ["version = 1\n", "version = 1\n[evidence]\n"] {
fs::write(&path, source).unwrap();
let policy = load_workspace_evidence(temp.path()).unwrap().unwrap();
assert!(policy.evidence.allow.is_empty() && policy.evidence.disallow.is_empty());
}
let config = WorkspaceConfig::parse("version = 1\n", &path).unwrap();
assert!(config.authoring.is_none() && config.evidence.is_none() && config.coverage.is_none());
let config =
WorkspaceConfig::parse("version = 1\n[coverage]\nreauthorings = 5\n", &path).unwrap();
assert_eq!(config.coverage.unwrap().reauthorings, Some(5));
// The one positivity rule applies to the whole-file parse too.
let error = WorkspaceConfig::parse("version = 1\n[coverage]\nreauthorings = 0\n", &path)
.unwrap_err()
.to_string();
assert!(error.contains("coverage.reauthorings"), "{error}");
// Feature settings must stay within their sections.
for source in [
"version = 1\nallow = ['generated']\n",
"version = 1\ndefault = 'cloud'\n",
"version = 1\n[authoring]\nallow = ['generated']\n",
"version = 1\n[evidence]\ndefault = 'cloud'\n",
"version = 1\nreauthorings = 3\n",
"version = 1\n[coverage]\nallow = ['generated']\n",
] {
assert!(WorkspaceConfig::parse(source, &path).is_err(), "{source}");
}
assert!(UserConfig::parse("version = 1\n[evidence]\nallow = []\n", &path).is_err());
// `[coverage]` has no user-file counterpart.
assert!(UserConfig::parse("version = 1\n[coverage]\nreauthorings = 3\n", &path).is_err());
// The evidence feature does not reinterpret or validate authoring settings.
fs::write(
&path,
"version = 1\n[authoring]\ndefault = 'missing'\nunknown = 1\n[evidence]\nallow = ['generated']\n",
)
.unwrap();
let policy = load_workspace_evidence(temp.path()).unwrap().unwrap();
assert_eq!(policy.evidence.allow, vec![Path::new("generated")]);
// Authoring settings stay in `[authoring]`; its provider-owned options
// cannot replace harness settings.
for source in [
"version = 1\n[authoring.configs.c]\nbackend = 'ollama'\nmodel = 'm'\nallow = []\n",
"version = 1\n[authoring.configs.c]\nbackend = 'ollama'\nmodel = 'm'\n[authoring.configs.c.options]\nmodel = 'x'\n",
] {
assert!(UserConfig::parse(source, &path).is_err(), "{source}");
assert!(WorkspaceConfig::parse(source, &path).is_err(), "{source}");
}
// An absent authoring section configures nothing.
let user = UserConfig::parse("version = 1\n", &path).unwrap();
assert!(user.authoring.is_none());
for feature in [
"[authoring]\nconfigs = {}",
"[evidence]\nallow = []",
"[coverage]\nreauthorings = 3",
] {
let error = WorkspaceConfig::parse(&format!("version = 2\n{feature}\n"), &path)
.unwrap_err()
.to_string();
assert!(error.contains("version"), "{error}");
}
}
Input 17: outline tests/evidence_boundaries.rs fn[unreadable_and_missing_inputs_are_reported]
- File:
tests/evidence_boundaries.rs - Selector:
fn[unreadable_and_missing_inputs_are_reported] - Kind:
fn tests/evidence_boundaries.rs:267–295
// {test}`requirements.ci.input_containment`
// {test}`requirements.configuration.evidence_paths`
#[cfg(unix)]
#[test]
fn unreadable_and_missing_inputs_are_reported() {
use std::os::unix::fs::PermissionsExt;
let temp = fixture();
let root = temp.path().join("project");
fs::write(root.join("locked.txt"), "secret\n").unwrap();
let input = outline(&root, "locked.txt", "");
fs::set_permissions(root.join("locked.txt"), fs::Permissions::from_mode(0o000)).unwrap();
let missing = json!({"file": "gone.txt", "item": "", "hash": "0".repeat(64)});
write_inputs(&root, vec![input, missing]);
let errors = validate_repository(&root).unwrap().errors.join("\n");
// A privileged user can read the file regardless of its mode.
let unreadable = fs::read(root.join("locked.txt")).is_err();
fs::set_permissions(root.join("locked.txt"), fs::Permissions::from_mode(0o644)).unwrap();
assert!(
errors.contains("inputs[1]: cannot open gone.txt"),
"{errors}"
);
if unreadable {
assert!(
errors.contains("inputs[0]: cannot read locked.txt"),
"{errors}"
);
}
}
Input 18: outline tests/evidence_boundaries.rs fn[configured_external_inputs_validate_and_remain_subject_to_freshness_and_disallow]
- File:
tests/evidence_boundaries.rs - Selector:
fn[configured_external_inputs_validate_and_remain_subject_to_freshness_and_disallow] - Kind:
fn tests/evidence_boundaries.rs:410–461
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.ci.input_containment`
// {test}`requirements.ci.outline_inputs`
// {test}`requirements.configuration.loading`
#[test]
fn configured_external_inputs_validate_and_remain_subject_to_freshness_and_disallow() {
let temp = fixture();
let root = temp.path().join("project");
let external = temp.path().join("generated");
fs::create_dir(&external).unwrap();
let source = external.join("generated.rs");
fs::write(&source, "pub fn generated() {}\n").unwrap();
let external_toml = toml::Value::String(external.display().to_string());
let config = format!("version = 1\n[evidence]\nallow = [{external_toml}]\n");
fs::write(root.join("habeas.toml"), &config).unwrap();
{
let input = outline(&root, source.to_str().unwrap(), "fn[generated]");
write_inputs(&root, vec![input]);
fs::write(root.join("habeas.toml"), "version = 1\n").unwrap();
assert!(
validate_repository(&root)
.unwrap()
.errors
.join("\n")
.contains("outside the repository")
);
fs::write(root.join("habeas.toml"), &config).unwrap();
let report = validate_repository(&root).unwrap();
assert!(report.errors.is_empty(), "{:?}", report.errors);
fs::write(&source, "pub fn generated() { changed(); }\n").unwrap();
assert!(
validate_repository(&root)
.unwrap()
.errors
.join("\n")
.contains("outline input changed")
);
fs::write(&source, "pub fn generated() {}\n").unwrap();
fs::write(
root.join("habeas.toml"),
format!("{config}disallow = [{external_toml}]\n"),
)
.unwrap();
assert!(
validate_repository(&root)
.unwrap()
.errors
.join("\n")
.contains("disallowed")
);
}
}
Input 19: outline tests/evidence_boundaries.rs fn[evidence_rejects_disallowed_ancestors_even_when_symlinks_target_allowed_sources]
- File:
tests/evidence_boundaries.rs - Selector:
fn[evidence_rejects_disallowed_ancestors_even_when_symlinks_target_allowed_sources] - Kind:
fn tests/evidence_boundaries.rs:463–506
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.ci.input_containment`
// {test}`requirements.ci.outline_inputs`
#[cfg(unix)]
#[test]
fn evidence_rejects_disallowed_ancestors_even_when_symlinks_target_allowed_sources() {
let temp = fixture();
let root = temp.path().join("project");
for directory in ["private", "public", "sub"] {
fs::create_dir(root.join(directory)).unwrap();
}
// Every struct needs a reference under rust_item_coverage.
let cite = "// {cite}`rules.ready`".to_owned();
fs::write(
root.join("public/source.rs"),
format!("{cite}\npub struct Source;\n"),
)
.unwrap();
std::os::unix::fs::symlink("../public", root.join("private/link")).unwrap();
fs::write(
root.join("habeas.toml"),
"version = 1\n[evidence]\nallow = ['public']\ndisallow = ['private']\n",
)
.unwrap();
for file in [
"public/source.rs",
"private/link/source.rs",
"sub/../private/link/source.rs",
] {
{
let mut input = outline(&root, "public/source.rs", "struct[Source]");
input["file"] = json!(file);
write_inputs(&root, vec![input]);
let errors =
without_citation_reviews(validate_repository(&root).unwrap().errors).join("\n");
if file == "public/source.rs" {
assert!(errors.is_empty(), "{errors}");
} else {
assert!(errors.contains("disallowed"), "{file}: {errors}");
assert!(errors.contains(file), "{errors}");
}
}
}
}
Input 20: outline tests/evidence_boundaries.rs fn[validation_checks_workspace_common_config_without_loading_unused_authoring_settings]
- File:
tests/evidence_boundaries.rs - Selector:
fn[validation_checks_workspace_common_config_without_loading_unused_authoring_settings] - Kind:
fn tests/evidence_boundaries.rs:508–533
// {test}`requirements.configuration.workspace_location`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.loading`
// {test}`requirements.authoring.deterministic_validation`
#[test]
fn validation_checks_workspace_common_config_without_loading_unused_authoring_settings() {
let temp = fixture();
let root = temp.path().join("project");
for text in [
"version = 2\n",
"version = 1\nunknown = true\n",
"version = [\n",
] {
fs::write(root.join("habeas.toml"), text).unwrap();
let errors = validate_repository(&root).unwrap().errors.join("\n");
assert!(errors.contains("habeas.toml"), "{text:?}: {errors}");
}
fs::write(
root.join("habeas.toml"),
"version = 1\n[authoring]\nconfigs = 'invalid unused authoring settings'\n",
)
.unwrap();
let report = validate_repository(&root).unwrap();
assert!(report.errors.is_empty(), "{:?}", report.errors);
}
Input 21: outline tests/evidence_boundaries.rs fn[discovered_external_cargo_outputs_validate_freshness_and_obey_disallow]
- File:
tests/evidence_boundaries.rs - Selector:
fn[discovered_external_cargo_outputs_validate_freshness_and_obey_disallow] - Kind:
fn tests/evidence_boundaries.rs:535–595
// {test}`requirements.authoring.generated_inputs`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.ci.input_containment`
// {test}`requirements.ci.outline_inputs`
// {test}`requirements.integration.report_api`
#[test]
fn discovered_external_cargo_outputs_validate_freshness_and_obey_disallow() {
let temp = fixture();
let root = temp.path().join("project");
fs::write(
root.join("Cargo.toml"),
"[package]\nname = 'fixture'\nversion = '0.1.0'\n",
)
.unwrap();
fs::write(
root.join("Cargo.lock"),
"version = 4\n\n[[package]]\nname = 'fixture'\nversion = '0.1.0'\n",
)
.unwrap();
fs::write(root.join("src/lib.rs"), "").unwrap();
fs::create_dir(root.join(".cargo")).unwrap();
let build = temp.path().join("external-build");
let target = temp.path().join("external-target");
fs::write(
root.join(".cargo/config.toml"),
format!(
"[build]\nbuild-dir = {}\ntarget-dir = {}\n",
toml::Value::String(build.display().to_string()),
toml::Value::String(target.display().to_string()),
),
)
.unwrap();
let out = build.join("debug/build/fixture-hash/out");
fs::create_dir_all(&out).unwrap();
fs::write(
out.parent().unwrap().join("root-output"),
out.to_str().unwrap(),
)
.unwrap();
let generated = out.join("generated.rs");
fs::write(&generated, "pub fn generated() {}\n").unwrap();
{
fs::write(root.join("habeas.toml"), "version = 1\n").unwrap();
let input = outline(&root, generated.to_str().unwrap(), "fn[generated]");
write_inputs(&root, vec![input]);
let report = validate_repository(&root).unwrap();
assert!(report.errors.is_empty(), "{:?}", report.errors);
fs::write(&generated, "pub fn generated() { changed(); }\n").unwrap();
let errors = validate_repository(&root).unwrap().errors.join("\n");
assert!(errors.contains("outline input changed"), "{errors}");
fs::write(&generated, "pub fn generated() {}\n").unwrap();
fs::write(
root.join("habeas.toml"),
"version = 1\n[evidence]\ndisallow = ['../external-build']\n",
)
.unwrap();
let errors = validate_repository(&root).unwrap().errors.join("\n");
assert!(errors.contains("disallowed"), "{errors}");
}
assert!(!target.exists(), "metadata must not run a build");
}
Input 22: outline tests/evidence_boundaries.rs fn[validation_of_recorded_inputs_is_independent_of_the_git_index]
- File:
tests/evidence_boundaries.rs - Selector:
fn[validation_of_recorded_inputs_is_independent_of_the_git_index] - Kind:
fn tests/evidence_boundaries.rs:635–672
// {test}`requirements.configuration.evidence_paths`
#[test]
fn validation_of_recorded_inputs_is_independent_of_the_git_index() {
let temp = fixture();
let root = temp.path().join("project");
write_inputs(
&root,
habeas::outline_inputs_for_lines(&root, "data.txt", 1, 2).unwrap(),
);
assert_eq!(
validate_repository(&root).unwrap().errors,
Vec::<String>::new()
);
// In a Git worktree, the recorded file is neither staged nor allowed by
// configuration; validation still accepts the current input.
git(&root, &["init", "--quiet"]);
git(&root, &["add", "Cargo.toml", "book.toml", "md", "evidence"]);
let untracked = std::process::Command::new("git")
.current_dir(&root)
.args(["ls-files", "--error-unmatch", "data.txt"])
.output()
.unwrap();
assert!(
!untracked.status.success(),
"data.txt must not be in the index"
);
assert_eq!(
validate_repository(&root).unwrap().errors,
Vec::<String>::new()
);
// An edit to it is still detected.
fs::write(root.join("data.txt"), "first\nchanged\n").unwrap();
let errors = validate_repository(&root).unwrap().errors;
assert!(
errors.iter().any(|error| error.contains("data.txt")),
"{errors:#?}"
);
}
Input 23: outline tests/references.rs fn[disallowed_paths_are_skipped_and_projects_outside_git_scan_every_file]
- File:
tests/references.rs - Selector:
fn[disallowed_paths_are_skipped_and_projects_outside_git_scan_every_file] - Kind:
fn tests/references.rs:748–799
// {test}`requirements.references.discovery`
// {test}`requirements.references.rust_item_coverage`
// {test}`requirements.configuration.evidence_paths`
#[test]
fn disallowed_paths_are_skipped_and_projects_outside_git_scan_every_file() {
let temp = project();
let root = temp.path();
let source = format!("// {}`rules.missing`\nfn uncited() {{}}\n", role("impl"));
for file in [
"private/hidden.rs",
"src/secret.rs",
"notes/other.rs",
"vendor/dep/lib.rs",
"crates/sub/target/out.rs",
"book/out.rs",
] {
let path = root.join(file);
fs::create_dir_all(path.parent().unwrap()).unwrap();
fs::write(path, &source).unwrap();
}
fs::write(
root.join("habeas.toml"),
"version = 1\n\n[evidence]\ndisallow = [\"private\", \"src/secret.rs\"]\n",
)
.unwrap();
let errors = errors(root);
for skipped in [
"private/hidden.rs",
"src/secret.rs",
"crates/sub/target/out.rs",
"book/out.rs",
] {
assert!(!has(&errors, skipped), "{skipped}: {errors:#?}");
}
// Outside Git every other project file is considered, untracked or not;
// vendored Rust sources still carry references but are not covered.
assert!(has(&errors, "notes/other.rs:1"), "{errors:#?}");
assert!(
has(&errors, "notes/other.rs:2: function uncited"),
"{errors:#?}"
);
assert!(has(&errors, "vendor/dep/lib.rs:1"), "{errors:#?}");
assert!(
!has(&errors, "vendor/dep/lib.rs:2: function uncited"),
"{errors:#?}"
);
let status = habeas::status_markdown(root, false).unwrap();
assert!(
!status.contains("Untracked files with references"),
"{status}"
);
}
Other sources
Input 1: requirements selection requirements.configuration.evidence_paths
requirements.configuration.evidence_paths:md/requirements/configuration.md:126–150
:::{req} evidence_paths
The workspace `[evidence]` table MUST serialize EvidenceConfig. `allow` and
`disallow` MUST be arrays of nonempty literal paths, each naming a file or a
directory subtree. Relative paths MUST resolve from the selected `habeas.toml`
directory; absolute paths MUST be supported. These paths are not glob patterns.
An omitted `allow` or `disallow` MUST mean an empty array, and an absent
`[evidence]` table MUST mean both are empty, so only the default source-access
rules apply. No operation requires the section. The table has no user-file
counterpart, and these rules have no invocation options. This section refines
{impl}`requirements.configuration.feature_sections` for the evidence feature.
For authoring reads, a matching disallow MUST reject the path; otherwise a
matching allow MUST permit it; otherwise the default source-access rules MUST
apply. Explicit allow MUST override every default, including Git tracking,
project containment, generated-evidence exclusion, and automatic generated-output
rules. Disallow MUST win even when an allow or generated-output rule also matches.
Both the requested path and its resolved symlink target MUST be checked for
disallow, so an allowed alias cannot expose a disallowed target.
The same explicit disallow rules and external-path exceptions MUST apply when
resolving recorded evidence inputs, including ordinary validation. Validation MUST
remain independent of Git index membership: it
checks the recorded inputs' existence and contents. Loading path policy MUST NOT
resolve credentials or validate unused authoring settings.
:::