requirements.authoring.read_denial.mandatory
Requirements index · View definition
Requirement
When source-access policy denies a mandatory input, the assessment MUST abort before any model request and report the denied path and reason to its caller; for an untracked file, the report MUST say what
says. The aborted assessment MUST NOT write evidence or emit evidence JSON, and its usage record MUST identify the failure. In a batch, other assessments MUST continue, including queued assessments, and their successful writes MUST be retained; the command MUST return a nonzero exit status after the batch finishes.
Rationale
The tests adequately cover each obligation in requirements.authoring.read_denial.mandatory. I did not read the implementation source. I judged only from the supplied tests and the requirement text.
Abort before any model request.
tests/authoring_batch.rs#fn[a_denied_mandatory_input_aborts_only_its_assessment]makes an:impl: private.txtanchor ofrequirements.alphadisallowed byhabeas.toml. It asserts that the mock server never saw the subjectrequirement requirements.alpha. It also asserts that the usage record hasrequest_count == 0.fn[an_untracked_mandatory_input_is_reported_with_how_to_stage_it]assertsserver.subjects().is_empty()for the untracked case.src/authoring/inputs.rs#mod[tests]/fn[unreadable_or_denied_anchors_fail_before_inference]andfn[outside_test_anchors_follow_explicit_allow_and_disallow_rules]show thatAssessmentSources::preparefails withPermissionDeniedbefore inference. The second one covers an outside-the-project path, an explicit allow, and allow plus disallow.
Report the denied path and reason to the caller.
- The batch test checks that stderr contains
private.txt,disallowedandhabeas.toml rule. - The
inputs.rstests check that the error namesprivate/skill.md,outside the project, ordisallowed. - The reasons covered are policy disallow, outside the project, and missing or unreadable anchor.
Untracked file report. The test an_untracked_mandatory_input_is_reported_with_how_to_stage_it stages the project with git, adds an untracked notes.txt anchor, and asserts that stderr contains notes.txt, untracked, git add and allow rule. It also checks a nonzero exit status. That matches the cited requirements.authoring.read_denial.untracked text.
No evidence written and no evidence JSON.
- The batch test asserts that
evidence/requirements.alpha.jsondoes not exist, and that the usage record hasevidence_written == false. - It runs
author requirements.alpha --stdoutand asserts a nonzero status and empty stdout.
Usage record identifies the failure. The batch test finds the usage record for requirements.alpha and asserts outcome == "failed", request_count == 0 and evidence_written == false.
Batch behaviour.
- The fixture runs with concurrency 1, so the later assessments were queued behind the aborted one. The test asserts that
requirements.alpha_case,requirements.betaandrequirements.gammaall have evidence withdetermination == true. This shows queued assessments continued and their writes were retained. - The command returned a nonzero status, and the other evidence was already complete when it was checked. That fits a nonzero return after the batch finishes.
The other mandatory-input classes, such as declarations and terms, go through the same preparation denial path. They are tested under the parent requirements.authoring.read_denial reference, for example in fn[disallowed_mandatory_inputs_abort_preparation]. I found no distinct required behavior that these tests would miss, so I report no gap.
Inputs
Tests
Input 3: outline src/authoring/inputs.rs mod[tests]/fn[outside_test_anchors_follow_explicit_allow_and_disallow_rules]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[outside_test_anchors_follow_explicit_allow_and_disallow_rules] - Kind:
fn src/authoring/inputs.rs:1442–1494
// {test}`requirements.references.anchors`
// {test}`requirements.authoring.read_denial.mandatory`
#[test]
fn outside_test_anchors_follow_explicit_allow_and_disallow_rules() {
let root = project();
let outside = tempfile::tempdir().unwrap();
let path = outside.path().join("check.txt");
fs::write(&path, "CHECK_OUTSIDE_SOURCE\n").unwrap();
let relative = format!(
"../{}/check.txt",
outside.path().file_name().unwrap().to_str().unwrap()
);
for anchor in [path.to_string_lossy().into_owned(), relative] {
fs::write(
root.path().join("md/requirements.md"),
format!(":::{{req}} ready\n:test: {anchor}\nThe project MUST be ready.\n:::\n"),
)
.unwrap();
let config = root.path().join("habeas.toml");
fs::write(&config, "version = 1\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("outside the project"), "{error}");
fs::write(
&config,
format!("version = 1\n[evidence]\nallow = ['{}']\n", path.display()),
)
.unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
assert!(
super::super::initial_prompt(&sources)
.unwrap()
.joined()
.contains("CHECK_OUTSIDE_SOURCE")
);
fs::write(
&config,
format!(
"version = 1\n[evidence]\nallow = ['{}']\ndisallow = ['{}']\n",
path.display(),
path.display()
),
)
.unwrap();
let error = AssessmentSources::prepare(root.path(), "requirements.ready")
.err()
.unwrap();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied, "{error}");
assert!(error.to_string().contains("disallowed"), "{error}");
}
}
Input 4: outline src/authoring/inputs.rs mod[tests]/fn[unreadable_or_denied_anchors_fail_before_inference]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[unreadable_or_denied_anchors_fail_before_inference] - Kind:
fn src/authoring/inputs.rs:1568–1624
// {test}`requirements.references.anchors`
// {test}`requirements.authoring.read_denial`
// {test}`requirements.authoring.read_denial.mandatory`
#[test]
// {test}`requirements.authoring.mandatory_inputs`
fn unreadable_or_denied_anchors_fail_before_inference() {
let root = project();
fs::write(
root.path().join("md/requirements.md"),
":::{req} ready\n:impl: skills/missing.md\nThe project MUST be ready.\n:::\n",
)
.unwrap();
let error = AssessmentSources::prepare(root.path(), "requirements.ready")
.err()
.unwrap();
assert!(
error
.to_string()
.contains("requirements.ready: cannot read :impl: anchor skills/missing.md"),
"{error}"
);
// An anchor naming a node its existing file lacks fails the same way.
fs::write(root.path().join("src/lib.rs"), "fn present() {}\n").unwrap();
fs::write(
root.path().join("md/requirements.md"),
":::{req} ready\n:impl: src/lib.rs#fn[missing]\nThe project MUST be ready.\n:::\n",
)
.unwrap();
let error = AssessmentSources::prepare(root.path(), "requirements.ready")
.err()
.unwrap();
assert!(
error
.to_string()
.contains("cannot read :impl: anchor src/lib.rs#fn[missing]"),
"{error}"
);
fs::create_dir_all(root.path().join("private")).unwrap();
fs::write(root.path().join("private/skill.md"), "secret\n").unwrap();
fs::write(
root.path().join("md/requirements.md"),
":::{req} ready\n:impl: private/skill.md\nThe project MUST be ready.\n:::\n",
)
.unwrap();
fs::write(
root.path().join("habeas.toml"),
"version = 1\n[evidence]\ndisallow = ['private']\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("private/skill.md"), "{error}");
}
Input 5: outline tests/authoring_batch.rs fn[a_denied_mandatory_input_aborts_only_its_assessment]
- File:
tests/authoring_batch.rs - Selector:
fn[a_denied_mandatory_input_aborts_only_its_assessment] - Kind:
fn tests/authoring_batch.rs:1210–1283
// {test}`requirements.authoring.batch`
// {test}`requirements.authoring.concurrency`
// {test}`requirements.authoring.read_denial.mandatory`
// {test}`requirements.authoring.persistence`
// {test}`requirements.authoring.usage_storage`
#[test]
fn a_denied_mandatory_input_aborts_only_its_assessment() {
let server = Server::start_with(
false,
Behavior::Judgments {
failing_subject: None,
},
);
// One at a time, so the assessments after the aborted one were queued.
let fixture = Fixture::new(&server.endpoint, Some(1));
fs::write(fixture.project.join("private.txt"), "private\n").unwrap();
fs::write(
fixture.project.join("habeas.toml"),
"version = 1\n\n[evidence]\ndisallow = [\"private.txt\"]\n",
)
.unwrap();
// The workspace disallows this anchor, a mandatory input of
// `requirements.alpha`.
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: private.txt\n",
1,
),
)
.unwrap();
let output = fixture.run(&["author", "--all"]);
assert!(!output.status.success(), "{output:?}");
let diagnostic = String::from_utf8_lossy(&output.stderr);
assert!(diagnostic.contains("private.txt"), "{diagnostic}");
assert!(diagnostic.contains("disallowed"), "{diagnostic}");
assert!(diagnostic.contains("habeas.toml rule"), "{diagnostic}");
// It made no request; the others ran and kept their evidence.
let subjects = server.subjects();
assert!(
!subjects
.iter()
.any(|subject| subject == "requirement requirements.alpha"),
"{subjects:?}"
);
assert!(
!fixture
.project
.join("evidence/requirements.alpha.json")
.exists()
);
for name in [
"requirements.alpha_case",
"requirements.beta",
"requirements.gamma",
] {
assert_eq!(fixture.evidence(name)["determination"], true, "{name}");
}
let usage = fixture.usage();
let aborted = usage
.iter()
.find(|run| run["subject"] == "requirements.alpha")
.expect("the aborted assessment has a usage record");
assert_eq!(aborted["outcome"], "failed");
assert_eq!(aborted["request_count"], 0);
assert_eq!(aborted["evidence_written"], false);
// With --stdout it emits no evidence JSON.
let single = fixture.run(&["author", "requirements.alpha", "--stdout"]);
assert!(!single.status.success(), "{single:?}");
assert!(single.stdout.is_empty(), "{single:?}");
}
Input 6: 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());
}
Referenced definitions
Input 2: 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.
:::
Other sources
Input 1: requirements selection requirements.authoring.read_denial.mandatory
requirements.authoring.read_denial.mandatory:md/requirements/authoring.md:725–734
:::{req} read_denial.mandatory
When source-access policy denies a mandatory input, the assessment MUST abort
before any model request and report the denied path and reason to its caller;
for an untracked file, the report MUST say what {cite}`requirements.authoring.read_denial.untracked`
says. The aborted assessment MUST NOT write evidence or emit evidence JSON, and
its usage record MUST identify the failure. In a batch, other assessments MUST
continue, including queued assessments, and their successful writes MUST be
retained; the command MUST return a nonzero exit status after the batch
finishes.
:::