requirements.authoring.generated_inputs
Requirements index · View definition
Requirement
Habeas MUST permit existing Cargo build-script output directories as an exception to default Git tracking and containment restrictions. It MUST discover the Cargo build directory using metadata and inspect existing build-script output records, without running a build or executing build scripts. It MUST NOT treat its own inherited
OUT_DIRenvironment variable as the workspace’s output directory. Only discovered output directories and their contents MUST receive this default permission; unrelated build artifacts MUST remain subject to ordinary rules. Workspace disallow entries MUST override this permission.Discovery MUST tolerate missing builds or unavailable metadata; callers MUST be able to allow undiscovered outputs explicitly using
habeas.toml. The model’s root directory listing MUST expose available generated-output directories, including external ones. Generated inputs MUST use outline inputs and receive ordinary freshness checks. Validation MUST NOT invoke a build to materialize an input.
Rationale
I judge the marked tests adequate for requirements.authoring.generated_inputs. I read only the supplied test sources and did not request implementation source.
Exception to Git tracking and containment
src/authoring/tools.rs#mod[tests]/fn[cargo_output_is_discovered_and_read_without_building_or_allowing_other_target_files]covers the Git-tracking exception.target/is gitignored, yet the in-workspaceoutdirectory is listed, and its file is found by ripgrep, ast_grep and habeas.an_external_build_directory_lists_its_generated_outputcovers the containment exception. The target directory is outside the root, and the test lists it and searches it.tests/evidence_boundaries.rs#fn[discovered_external_cargo_outputs_validate_freshness_and_obey_disallow]covers validation of an external generated file, using bothbuild-dirandtarget-dirconfiguration.
Discovery and scope
src/authoring/access.rs#mod[tests]/fn[generated_discovery_accepts_out_directories_but_not_arbitrary_root_output_targets]checks whichroot-outputrecords count. It accepts thedebug/.../outand cross-targetoutdirectories. It rejects a fakeroot-outputrecord that points to an unrelated directory.- The tools test reads
root-outputin the build directory, which sits next toout, and gets an ordinary “holds build output” failure rather thanPermissionDenied. This shows that only the discoveredoutdirectories and their contents get the exception.
No build, no scripts
- The tools test asserts
targetdoes not exist afterprepareon an unbuilt project. - The validation test asserts the external target directory is never created (“metadata must not run a build”).
Inherited OUT_DIR
inherited_out_dir_is_ignored_and_metadata_failure_preserves_ordinary_readsruns a child process withOUT_DIRset to an unrelated directory. It asserts thatgeneratedis empty and that reading a file under that directory returnsPermissionDenied.
Missing builds and unavailable metadata
- The unbuilt project case in the tools test shows that missing builds are tolerated.
- The same
OUT_DIRtest uses an invalidCargo.toml. It asserts thatSourceAccess::loadsucceeds and that ordinary tracked reads still work.
Explicit allow through habeas.toml
explicit_allow_overrides_the_build_output_refusalshows that an[evidence] allowentry makes the otherwise refusedtarget/docandbook/page.htmlreadable.
Disallow override
- The tools test adds a
disallowentry for the discoveredoutdirectory. The directory then disappears from the root listing, search and structural search return nothing, and direct habeas, list_files, ripgrep and ast_grep calls fail withPermissionDenied, “disallowed” and the path. - The validation test adds a
disallowentry and asserts a “disallowed” error.
Root listing
- Both the in-workspace and external tests assert that the
outdirectory appears in the rootlist_filesresult.
Outline inputs and freshness
- The validation test writes an outline input over the generated file. It asserts validation passes, then asserts an “outline input changed” error after the file is edited.
- The tools test reads the generated file by outline item.
list_filesandast_grepover the generated directory return emptyinputs.
I found no unexercised obligation and no assertion that contradicts the text.
Inputs
Tests
Input 2: 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 3: outline src/authoring/access.rs mod[tests]/fn[generated_discovery_accepts_out_directories_but_not_arbitrary_root_output_targets]
- File:
src/authoring/access.rs - Selector:
mod[tests]/fn[generated_discovery_accepts_out_directories_but_not_arbitrary_root_output_targets] - Kind:
fn src/authoring/access.rs:1037–1062
// {test}`requirements.authoring.generated_inputs`
#[test]
fn generated_discovery_accepts_out_directories_but_not_arbitrary_root_output_targets() {
let root = tempfile::tempdir().unwrap();
let out = root.path().join("debug/build/package-hash/out");
fs::create_dir_all(&out).unwrap();
fs::write(
out.parent().unwrap().join("root-output"),
out.to_str().unwrap(),
)
.unwrap();
let cross = root
.path()
.join("target-triple/custom/build/other-hash/out");
fs::create_dir_all(&cross).unwrap();
fs::write(
cross.parent().unwrap().join("root-output"),
cross.to_str().unwrap(),
)
.unwrap();
let unrelated = tempfile::tempdir().unwrap();
let fake = root.path().join("debug/build/fake-hash");
fs::create_dir_all(fake.join("out")).unwrap();
fs::write(fake.join("root-output"), unrelated.path().to_str().unwrap()).unwrap();
assert_eq!(discover_generated_roots(root.path()), vec![out, cross]);
}
Input 4: outline src/authoring/access.rs mod[tests]/fn[inherited_out_dir_is_ignored_and_metadata_failure_preserves_ordinary_reads]
- File:
src/authoring/access.rs - Selector:
mod[tests]/fn[inherited_out_dir_is_ignored_and_metadata_failure_preserves_ordinary_reads] - Kind:
fn src/authoring/access.rs:1142–1185
// {test}`requirements.authoring.generated_inputs`
// {test}`requirements.authoring.source_tools`
// {test}`requirements.authoring.read_denial`
#[test]
fn inherited_out_dir_is_ignored_and_metadata_failure_preserves_ordinary_reads() {
if let Some(root) = std::env::var_os("HABEAS_TEST_OUT_DIR_PROBE_ROOT") {
let root = PathBuf::from(root);
let access = SourceAccess::load(&root).unwrap();
assert!(access.generated.is_empty());
assert!(access.file(&root, Path::new("tracked.txt")).is_ok());
let inherited = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let error = access
.file(&root, &inherited.join("unrelated.txt"))
.unwrap_err();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied, "{error}");
return;
}
let root = tempfile::tempdir().unwrap();
let unrelated = tempfile::tempdir().unwrap();
fs::write(root.path().join("tracked.txt"), "ordinary source\n").unwrap();
fs::write(
root.path().join("Cargo.toml"),
"deliberately invalid TOML [\n",
)
.unwrap();
fs::write(
unrelated.path().join("unrelated.txt"),
"unrelated generated data\n",
)
.unwrap();
git(root.path(), &["init", "--quiet"]);
git(root.path(), &["add", "."]);
let output = Command::new(std::env::current_exe().unwrap())
.args(["--exact", "authoring::access::tests::inherited_out_dir_is_ignored_and_metadata_failure_preserves_ordinary_reads", "--nocapture"])
.env("HABEAS_TEST_OUT_DIR_PROBE_ROOT", root.path())
.env("OUT_DIR", unrelated.path())
.output().unwrap();
assert!(
output.status.success(),
"{}\n{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
}
Input 5: 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 6: outline src/authoring/tools.rs mod[tests]/fn[an_external_build_directory_lists_its_generated_output]
- File:
src/authoring/tools.rs - Selector:
mod[tests]/fn[an_external_build_directory_lists_its_generated_output] - Kind:
fn src/authoring/tools.rs:4319–4377
// {test}`requirements.authoring.generated_inputs`
#[test]
fn an_external_build_directory_lists_its_generated_output() {
let root = project();
let external = tempfile::tempdir().unwrap();
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::create_dir_all(root.path().join(".cargo")).unwrap();
fs::write(
root.path().join(".cargo/config.toml"),
format!(
"[build]\ntarget-dir = {}\n",
toml::Value::String(external.path().display().to_string())
),
)
.unwrap();
git(root.path(), &["init", "--quiet"]);
git(root.path(), &["add", "."]);
let out = external.path().join("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();
let out = fs::canonicalize(&out).unwrap();
let paths = listing
.result
.get("entries")
.unwrap_or(&listing.result)
.as_array()
.unwrap()
.iter()
.map(|entry| entry["path"].as_str().unwrap().to_owned())
.collect::<Vec<_>>();
assert!(
paths.iter().any(|path| std::path::Path::new(path) == out),
"{paths:?}"
);
let search = dispatch(
&sources,
"ripgrep",
&json!({"pattern": "generated_needle", "path": out.to_str().unwrap()}),
)
.unwrap();
assert_eq!(
search.result["matches"].as_array().unwrap().len(),
1,
"{}",
search.result
);
}
Input 7: 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");
}
Other sources
Input 1: requirements selection requirements.authoring.generated_inputs
requirements.authoring.generated_inputs:md/requirements/authoring.md:736–752
:::{req} generated_inputs
Habeas MUST permit existing Cargo build-script output directories as an exception
to default Git tracking and containment restrictions. It MUST discover the Cargo
build directory using metadata and inspect existing build-script output records,
without running a build or executing build scripts. It MUST NOT treat its own
inherited `OUT_DIR` environment variable as the workspace's output directory.
Only discovered output directories and their contents MUST receive this default
permission; unrelated build artifacts MUST remain subject to ordinary rules.
Workspace disallow entries MUST override this permission.
Discovery MUST tolerate missing builds or unavailable metadata; callers MUST be
able to allow undiscovered outputs explicitly using `habeas.toml`. The model's
root directory listing MUST expose available generated-output directories,
including external ones. Generated inputs MUST use outline inputs and receive
ordinary freshness checks. Validation MUST NOT
invoke a build to materialize an input.
:::