requirements.ci.span
Requirements index · View definition
Requirement
A
{req}definition MUST use an opening fence of at least three colons immediately followed by{req} <name>. A closing fence MUST have at least as many colons as the opening fence and nothing else on its line except whitespace. As in CommonMark fences, an opening or closing fence MAY be indented by up to three spaces; a line indented by four or more spaces MUST NOT be a fence. The requirement body MUST be all Markdown between those fence lines, including headings, examples, diagrams, and blank lines, except for the header option lines of, and MUST NOT include text after the closing fence. Leading and trailing whitespace MUST be excluded when comparing the body with evidence.
Rationale
The reviewed tests cover every obligation in requirements.ci.span, and their assertions enforce the expected outcomes. I did not request implementation source. The tests were enough to map each clause.
Opening fence: at least three colons, immediately followed by {req} <name>
lib.rs#mod[tests]/fn[closing_fences_allow_no_trailing_text_and_fences_allow_three_spaces_of_indent]asserts that these are not definitions:- two colons (
::{req}), - a space between the colons and
{req}(::: {req}), - no space between
{req}and the name (:::{req}ready).
- two colons (
evidence.rs#mod[tests]/fn[validates_four_or_more_colon_fences_and_longer_closers]covers 4 and 7 colon openers.
Closing fence: at least as many colons as the opener, nothing else on its line except whitespace
validates_four_or_more_colon_fences_and_longer_closerscovers equal and longer closers (::::/::::,::::/:::::, and 7/8 colons).a_longer_colon_fence_contains_a_shorter_nested_directiveasserts that a shorter:::line does not close a::::block. The test asserts the exact body slice and that the block is closed.closing_fences_allow_no_trailing_text_and_fences_allow_three_spaces_of_indentasserts that:::foodoes not close the block and that:::with trailing whitespace does.
Indentation: up to three spaces allowed, four or more is not a fence
closing_fences_allow_no_trailing_text_and_fences_allow_three_spaces_of_indentasserts that:- a 3-space opener and closer work,
- a 4-space opener is not a definition,
- a 4-space closer leaves the block unclosed.
Body is all Markdown between the fences, including headings, examples, diagrams and blank lines
colon_requirement_span_includes_markdown_and_excludes_following_textuses a body with an ATX heading, a setext heading, a code block that contains:::and a heading-like line, and blank lines. It requires the evidence text to equal the whole body.validates_full_names_requirement_text_and_input_linesandvalidates_four_or_more_colon_fences_and_longer_closersinclude code blocks, a nested:::{note}directive, and blank lines.
Exclusion of header option lines
lib.rs#mod[tests]/fn[anchor_options_are_metadata_not_body_text]asserts thewithout_optionsoutput and the rendered output. Options directly after the opening fence are stripped. Inline:impl:text and later:test:lines stay in the body.evidence.rs#mod[tests]/fn[anchored_files_must_be_completely_covered_and_resolvable]asserts that the evidence text equals the body without the option lines (no “text changed” error).
No text after the closing fence
colon_requirement_span_includes_markdown_and_excludes_following_textplaces “Outside the requirement.” after the closing fence and still requires the evidence to match.validates_four_or_more_colon_fences_and_longer_closersanda_longer_colon_fence_contains_a_shorter_nested_directivecheck the same thing with an “Outside” paragraph after the fence.
Leading and trailing whitespace excluded when comparing
requirement_bodies_are_compared_without_surrounding_whitespaceuses a body with leading indentation and trailing spaces. It asserts that validation passes when the evidence holds the trimmed text.
Missing closing fence
reports_a_missing_closing_colon_fenceasserts a specific error for an unclosed definition. The requirement implies this case through the “MUST have a closing fence” clause.
No gap found.
Inputs
Tests
Input 3: outline src/evidence.rs mod[tests]/fn[validates_full_names_requirement_text_and_input_lines]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[validates_full_names_requirement_text_and_input_lines] - Kind:
fn src/evidence.rs:2533–2564
// {test}`requirements.integration.report_api`
// {test}`requirements.ci.book_source`
// {test}`requirements.ci.coverage`
// {test}`requirements.ci.requirement_text`
// {test}`requirements.ci.outline_inputs`
// {test}`requirements.ci.identifiers`
// {test}`requirements.ci.span`
#[test]
fn validates_full_names_requirement_text_and_input_lines() {
let temp = fixture();
fs::write(
temp.path().join("md/reqs/foo/bar.md"),
"# Requirements\n\n:::{req} ready\n\n The check MUST pass.\n\n```text\n{req}`example`\n```\n:::\n",
)
.unwrap();
fs::write(
temp.path().join("evidence/foo.bar.ready.json"),
json!({
"requirement": "The check MUST pass.\n\n```text\n{req}`example`\n```",
"determination": true,
"rationale": "The inspected file has the expected lines.",
"inputs": [outline(temp.path(), "src/main.rs", "")]
})
.to_string(),
)
.unwrap();
let report = validate_repository(temp.path()).unwrap();
assert_eq!(report.requirements, 1);
assert_eq!(report.evidence_files, 1);
assert!(report.errors.is_empty(), "{:?}", report.errors);
}
Input 4: outline src/evidence.rs mod[tests]/fn[requirement_bodies_are_compared_without_surrounding_whitespace]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[requirement_bodies_are_compared_without_surrounding_whitespace] - Kind:
fn src/evidence.rs:3275–3297
// {test}`requirements.ci.span`
#[test]
fn requirement_bodies_are_compared_without_surrounding_whitespace() {
let temp = fixture();
fs::write(
temp.path().join("md/requirements.md"),
"# Requirements\n\n:::{req} one\n\n Body MUST hold. \n\n:::\n",
)
.unwrap();
fs::write(
temp.path().join("evidence/requirements.one.json"),
json!({
"requirement": "Body MUST hold.",
"determination": true,
"rationale": "Examined.",
"inputs": []
})
.to_string(),
)
.unwrap();
let report = validate_repository(temp.path()).unwrap();
assert!(report.errors.is_empty(), "{:?}", report.errors);
}
Input 5: outline src/evidence.rs mod[tests]/fn[colon_requirement_span_includes_markdown_and_excludes_following_text]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[colon_requirement_span_includes_markdown_and_excludes_following_text] - Kind:
fn src/evidence.rs:3373–3405
// {test}`requirements.ci.span`
// {test}`requirements.ci.fence_lengths`
// {test}`requirements.ci.span`
#[test]
fn colon_requirement_span_includes_markdown_and_excludes_following_text() {
let temp = fixture();
let first = "First MUST work.\n\n```text\n# Example heading\n:::\n```\n\n## New section\n\nSetext section\n--------------";
fs::write(
temp.path().join("md/requirements.md"),
format!(
"# Requirements\n\n:::{{req}} first\n{first}\n:::\n\nOutside the requirement.\n\n:::{{req}} second\nSecond MUST work.\n:::\n"
),
)
.unwrap();
for (name, requirement) in [("first", first), ("second", "Second MUST work.")] {
fs::write(
temp.path()
.join(format!("evidence/requirements.{name}.json")),
json!({
"requirement": requirement,
"determination": true,
"rationale": "The fixture records the current requirement body.",
"inputs": []
})
.to_string(),
)
.unwrap();
}
let report = validate_repository(temp.path()).unwrap();
assert_eq!(report.requirements, 2);
assert!(report.errors.is_empty(), "{:?}", report.errors);
}
Input 6: outline src/evidence.rs mod[tests]/fn[reports_a_missing_closing_colon_fence]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[reports_a_missing_closing_colon_fence] - Kind:
fn src/evidence.rs:3407–3438
// {test}`requirements.ci.span`
// {test}`requirements.ci.definition_errors`
#[test]
fn reports_a_missing_closing_colon_fence() {
let temp = fixture();
fs::write(
temp.path().join("md/requirements.md"),
":::{req} ready\nReady.\n",
)
.unwrap();
fs::write(
temp.path().join("evidence/requirements.ready.json"),
json!({
"requirement": "Ready.",
"determination": true,
"rationale": "The current body was examined.",
"inputs": []
})
.to_string(),
)
.unwrap();
let report = validate_repository(temp.path()).unwrap();
assert_eq!(report.requirements, 1);
assert!(
report.errors.join("\n").contains(
"md/requirements.md:1: requirement requirements.ready is missing a closing colon fence"
),
"{:?}",
report.errors
);
}
Input 7: outline src/evidence.rs mod[tests]/fn[validates_four_or_more_colon_fences_and_longer_closers]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[validates_four_or_more_colon_fences_and_longer_closers] - Kind:
fn src/evidence.rs:3440–3474
// {test}`requirements.ci.fence_lengths`
// {test}`requirements.ci.span`
#[test]
fn validates_four_or_more_colon_fences_and_longer_closers() {
let body = "Body MUST remain.\n\n:::{note}\nNested.\n:::\n\nStill in the requirement.";
for (opening, closing) in [("::::", "::::"), ("::::", ":::::"), (":::::::", "::::::::")] {
let temp = fixture();
fs::write(
temp.path().join("md/requirements.md"),
format!(
"# Requirements\n\n{opening}{{req}} ready\n{body}\n{closing}\n\nOutside the requirement.\n"
),
)
.unwrap();
fs::write(
temp.path().join("evidence/requirements.ready.json"),
json!({
"requirement": body,
"determination": true,
"rationale": "The entire fenced body was examined.",
"inputs": []
})
.to_string(),
)
.unwrap();
let report = validate_repository(temp.path()).unwrap();
assert_eq!(report.requirements, 1, "{opening} ... {closing}");
assert!(
report.errors.is_empty(),
"{opening} ... {closing}: {:?}",
report.errors
);
}
}
Input 8: outline src/evidence.rs mod[tests]/fn[anchored_files_must_be_completely_covered_and_resolvable]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[anchored_files_must_be_completely_covered_and_resolvable] - Kind:
fn src/evidence.rs:3760–3851
// {test}`requirements.references.anchors`
// {test}`requirements.ci.requirement_text`
// {test}`requirements.references.evidence_coverage`
// {test}`requirements.ci.span`
// {test}`requirements.examples.definition`
#[test]
fn anchored_files_must_be_completely_covered_and_resolvable() {
let temp = fixture();
let root = temp.path();
fs::create_dir_all(root.join("skills")).unwrap();
fs::write(root.join("skills/ready.md"), "# Skill\nUse ready.\n").unwrap();
fs::write(
root.join("md/requirements.md"),
":::{req} ready\n:test: skills/ready.md\n:test: missing.sh\nReady MUST hold.\n:::\n\n:::{example} case\n:test: skills/ready.md\nA ready case. {cite}`requirements.ready`\n:::\n",
)
.unwrap();
// The root node is the whole file; its heading's section is not.
let skill = |item: &str| outline(root, "skills/ready.md", item);
let write = |name: &str, field: &str, text: &str, inputs: Value| {
fs::write(
root.join(format!("evidence/{name}.json")),
json!({
field: text,
"determination": true,
"rationale": "Checked.",
"inputs": inputs,
})
.to_string(),
)
.unwrap();
};
// The option lines are not part of the definition text.
write(
"requirements.ready",
"requirement",
"Ready MUST hold.",
json!([skill("section[Skill]")]),
);
write(
"requirements.case",
"example",
"A ready case. {cite}`requirements.ready`",
json!([skill("")]),
);
let errors = validate_repository(root).unwrap().errors.join("\n");
assert!(!errors.contains("text changed"), "{errors}");
assert!(
errors.contains("evidence/requirements.ready.json: no input selects skills/ready.md (lines 1-2) anchored by :test: on requirement requirements.ready"),
"{errors}"
);
assert!(
errors.contains("evidence/requirements.ready.json: :test: anchor missing.sh on requirement requirements.ready at md/requirements.md:1 does not resolve"),
"{errors}"
);
assert!(!errors.contains("requirements.case.json"), "{errors}");
fs::write(
root.join("md/requirements.md"),
":::{req} ready\n:test: skills/ready.md\nReady MUST hold.\n:::\n\n:::{example} case\n:test: skills/ready.md\nA ready case. {cite}`requirements.ready`\n:::\n",
)
.unwrap();
write(
"requirements.ready",
"requirement",
"Ready MUST hold.",
json!([skill("")]),
);
let report = validate_repository(root).unwrap();
assert!(report.errors.is_empty(), "{:?}", report.errors);
// Changing the anchored file makes the evidence stale.
fs::write(root.join("skills/ready.md"), "# Skill\nUse ready now.\n").unwrap();
let errors = validate_repository(root).unwrap().errors.join("\n");
assert!(
errors.contains("evidence/requirements.ready.json: inputs[0]: outline input changed: skills/ready.md <root> (now lines 1-2) no longer has the recorded hash"),
"{errors}"
);
fs::write(
root.join("habeas.toml"),
"version = 1\n[evidence]\ndisallow = ['skills/ready.md']\n",
)
.unwrap();
let errors = validate_repository(root).unwrap().errors;
assert!(
errors
.iter()
.any(|error| error.contains("anchor skills/ready.md")
&& error.contains("requirements.ready")
&& error.contains("disallow")),
"{errors:?}"
);
}
Input 9: outline src/lib.rs mod[tests]/fn[anchor_options_are_metadata_not_body_text]
- File:
src/lib.rs - Selector:
mod[tests]/fn[anchor_options_are_metadata_not_body_text] - Kind:
fn src/lib.rs:1006–1048
// {test}`requirements.references.anchors`
#[test]
// {test}`requirements.ci.span`
// {test}`requirements.examples.definition`
fn anchor_options_are_metadata_not_body_text() {
let source = "::::{req} ready\n:impl: skills/ready.md\n:test: tests/ready.sh\nReady.\n\n:::{example} case\n:test: tests/case.sh\nA case.\n:::\n::::\n\n:::{req} plain\nText :impl: inline.\n\n:test: later.md\n:::\n";
let blocks = definition_blocks(source);
assert_eq!(blocks.len(), 3);
let options = |index: usize| {
blocks[index]
.options
.iter()
.map(|option| (option.name.as_str(), option.value.as_str(), option.line))
.collect::<Vec<_>>()
};
assert_eq!(
options(0),
[
("impl", "skills/ready.md", 2),
("test", "tests/ready.sh", 3)
]
);
assert_eq!(options(1), [("test", "tests/case.sh", 7)]);
// Only lines immediately after the opening fence are options.
assert!(options(2).is_empty());
assert_eq!(
super::without_options(source, blocks[0].body_start..blocks[0].body_end, &blocks)
.trim(),
"Ready.\n\n:::{example} case\nA case.\n:::"
);
assert_eq!(
super::without_options(source, blocks[1].body_start..blocks[1].body_end, &blocks)
.trim(),
"A case."
);
let rendered = replace_definitions(source, "requirements", None, None);
assert!(!rendered.contains(":impl: skills"), "{rendered}");
assert!(!rendered.contains("skills/ready.md"), "{rendered}");
assert!(!rendered.contains("tests/case.sh"), "{rendered}");
assert!(rendered.contains("Text :impl: inline."), "{rendered}");
assert!(rendered.contains(":test: later.md"), "{rendered}");
}
Input 10: outline src/lib.rs mod[tests]/fn[a_longer_colon_fence_contains_a_shorter_nested_directive]
- File:
src/lib.rs - Selector:
mod[tests]/fn[a_longer_colon_fence_contains_a_shorter_nested_directive] - Kind:
fn src/lib.rs:1890–1904
// {test}`requirements.ci.span`
// {test}`requirements.ci.fence_lengths`
#[test]
fn a_longer_colon_fence_contains_a_shorter_nested_directive() {
let content = "::::{req} ready\nIntro.\n\n:::{note}\nNested.\n:::\n::::\n\nOutside.";
let blocks = definition_blocks(content);
assert_eq!(blocks.len(), 1);
assert!(blocks[0].closed);
assert_eq!(blocks[0].kind, DefinitionKind::Requirement);
assert_eq!(
&content[blocks[0].body_start..blocks[0].body_end],
"Intro.\n\n:::{note}\nNested.\n:::\n"
);
assert!(content[blocks[0].end..].contains("Outside."));
}
Input 11: outline src/lib.rs mod[tests]/fn[closing_fences_allow_no_trailing_text_and_fences_allow_three_spaces_of_indent]
- File:
src/lib.rs - Selector:
mod[tests]/fn[closing_fences_allow_no_trailing_text_and_fences_allow_three_spaces_of_indent] - Kind:
fn src/lib.rs:1906–1939
// {test}`requirements.ci.span`
#[test]
fn closing_fences_allow_no_trailing_text_and_fences_allow_three_spaces_of_indent() {
let content = ":::{req} ready\nBody.\n:::foo\nStill body.\n::: \n\nAfter.";
let blocks = definition_blocks(content);
assert_eq!(blocks.len(), 1);
assert!(blocks[0].closed);
assert_eq!(
&content[blocks[0].body_start..blocks[0].body_end],
"Body.\n:::foo\nStill body.\n",
"a colon line with trailing text does not close the body; trailing whitespace may"
);
let indented = " :::{req} ready\nBody.\n :::\n";
let blocks = definition_blocks(indented);
assert_eq!(blocks.len(), 1);
assert!(blocks[0].closed);
assert_eq!(
&indented[blocks[0].body_start..blocks[0].body_end],
"Body.\n"
);
assert!(definition_blocks(" :::{req} ready\nBody.\n:::\n").is_empty());
let unclosed = definition_blocks(":::{req} ready\nBody.\n :::\n");
assert_eq!(unclosed.len(), 1);
assert!(
!unclosed[0].closed,
"a four-space-indented fence does not close"
);
assert!(definition_blocks(":::{req}ready\nBody.\n:::\n").is_empty());
// An opening fence needs at least three colons immediately followed
// by `{req}`.
assert!(definition_blocks("::{req} ready\nBody.\n::\n").is_empty());
assert!(definition_blocks("::: {req} ready\nBody.\n:::\n").is_empty());
}
Referenced definitions
Input 2: requirements selection requirements.references.anchors
requirements.references.anchors:md/requirements/references.md:176–197
:::{req} anchors
A `{req}` declaration MAY list `:impl:` and `:test:` options, and an `{example}`
declaration MAY list `:test:` options, immediately after its opening fence and
before its body, one per option line, naming a project file path or
`path#selector` for one outline node under
{cite}`requirements.references.outline_selectors`. Each anchor MUST be an `{impl}` or `{test}` edge, under
{cite}`requirements.references.roles`, from the definition to the anchored file or
node, for files that cannot or should not carry a reference themselves.
Paths MUST follow the path rules in {cite}`requirements.ci.schema`. Option lines
MUST NOT form part of the definition's text for evidence comparison or for
requirements inputs, and MUST NOT render as body text.
For each `:test:` anchor, the harness MUST include the selected file or node's
source text in the initial model request under
{cite}`requirements.authoring.mandatory_inputs` and MUST record that selection
as an evidence input under {cite}`requirements.references.evidence_coverage`,
so changing that source makes the evidence stale.
A `:impl:` anchor alone MUST NOT require an input selecting its source. A path or selector that
does not resolve to a readable, permitted file or node MUST be a validation error naming the
definition and the path; authoring MUST report it before inference. Any other option line in a `{req}` or
`{example}` declaration MUST be a validation error.
:::
Other sources
Input 1: requirements selection requirements.ci.span
requirements.ci.span:md/requirements/ci.md:317–319
:::{req} span
A `{req}` definition MUST use an opening fence of at least three colons immediately followed by `{req} <name>`. A closing fence MUST have at least as many colons as the opening fence and nothing else on its line except whitespace. As in CommonMark fences, an opening or closing fence MAY be indented by up to three spaces; a line indented by four or more spaces MUST NOT be a fence. The requirement body MUST be all Markdown between those fence lines, including headings, examples, diagrams, and blank lines, except for the header option lines of {cite}`requirements.references.anchors`, and MUST NOT include text after the closing fence. Leading and trailing whitespace MUST be excluded when comparing the body with evidence.
:::