requirements.references.roles
Requirements index · View definition
Requirement
Project text files MAY use the
{impl},{cite}, and{test}roles with a backtick-delimited full requirement or example name, or with a built-in name under, and MAY use the
{fixme}role in fenced form. A reference MAY instead be written in fenced form,:::{role} nameon one line, a body, and a closing fence, following the fence rules ofand
; the fenced form is the same edge with attached commentary, and the inline form carries none. In a source comment, fence lines MUST be recognized after removing each line’s comment delimiters within one comment run under
, and a fence that does not close within its comment run MUST be a validation error. Each reference is a directed edge between its source and the named definition. A source is a project source item or a requirement or example declaration. The roles MUST mean:
{cite}: the source relies on, supports, or refers to the definition. It is an edge from the source to the definition.{impl}: the source implements part of the definition: it makes a decision, performs a check, produces an output, or handles a case that the definition specifies. A requirement MAY implement part of another requirement by refining one of its obligations. Calling code that implements a definition, or producing a result a caller uses to meet it, MUST NOT by itself count as implementing it. A check MUST count only if the definition states it, or the source could not meet one of the definition’s obligations without it; source that checks it is consistent with a definition, such as recognizing a form the definition specifies in order to decide whether to run other behavior, relies on that definition and calls for{cite}. A requirement stating a convention for every output of a kind, such as every validation error, is implemented by the source that carries out the convention as a whole, such as the step that collects and reports those outputs.{test}: the source is designed to verify behavior the definition specifies: a test through its scenario and the assertions about that scenario’s outcome, or a named example through the concrete case it describes.{fixme}: the source acknowledges a known gap in fulfilling the definition. It MUST use the fenced form, and its body MUST describe the gap. The body MAY begin with option lines naming issues that track the gap, one per line, in the form:github: <owner>/<repo>#<number>, such as:github: rust-lang/rust#123.githubMUST be the only recognized option. A named{fixme}MAY appear only in sources outside the book. Validation MUST report any other option line, a:github:value not in that form, an inline{fixme}, a{fixme}in a requirement or example declaration, and a{fixme}whose body, without option lines and comment delimiters, is empty. An unnamed{fixme}, a fence of:::{fixme}with no name, MAY appear in any project text, including a requirement or example body, to tie that place to the issues it names. It MUST have at least one:github:option line and MAY have a description; it is not a reference edge, acknowledges no gap, needs no coverage, and does not count as a reference for Rust item coverage. Its issues are checked under.
{impl},{test}, and{fixme}are edges from the definition to the source. Only requirements and examples are assessed; code is reviewed as part of the definitions it implements or tests.{impl}`requirements.references.roles` {cite}`requirements.references.roles` {test}`requirements.references.roles`
Rationale
I judge the tests adequate. I read only the supplied test sources and did not request any implementation source. The marked tests cover each testable obligation of requirements.references.roles:
-
Role and name recognition.
src/fenced.rs#mod[tests]/fn[opening_fences_take_a_role_and_one_valid_or_built_in_name]checks theimpl,citeandtestroles with project names. It also checks the built-in name form (habeas:util) and a syntactically built-in unknown name, and indentation of up to three spaces. It rejects four-space indentation, bad names and unknown roles such as{term}, which stay literal text. -
Fence rules in Markdown.
src/fenced.rs#mod[tests]/fn[markdown_fences_close_with_enough_colons_and_skip_code]checks a four-colon outer fence containing a nested three-colon fence, code-block skipping, and an unclosed fence reported as not closed. -
Fences in source comments.
fn[comment_delimiters_are_removed_per_line]checks delimiter stripping for//,///,//!,#, block-comment and HTML-comment forms.fn[comment_fences_close_within_one_comment_run]checks that a later run’s fence does not close an earlier fence, and checks//runs and/* * */runs.- The integration test
tests/references.rs#fn[fenced_references_in_comments_and_built_in_rules_are_validated]asserts the “has no closing fence” validation error.
-
Built-in names under
{cite}. The same integration test checks that an unknown built-in is rejected inline and fenced, and that{impl}ofhabeas:utilis reported as not permitted. It also checks that a valid fenced{cite}ofhabeas:utilcovers its function. -
Edge directions.
src/authoring/inputs.rs#mod[tests]/fn[only_edges_leaving_the_subject_contribute_inputs]checks that edges leaving the subject contribute inputs, including{cite}on a requirement or example and{impl}from a refining requirement. It checks that{test}sources contribute,{impl}and{cite}source code does not, and cites of the subject by other definitions do not.src/evidence.rs#mod[tests]/fn[only_test_references_require_recorded_source_coverage]checks that only{test}sources require recorded coverage. -
{fixme}rules.tests/references.rs#fn[fixme_references_are_fenced_described_and_named_only_outside_the_book]asserts a validation error for each of these cases:- an inline
{fixme}; - an unsupported option;
- a malformed
:github:value; - an empty body;
- an unnamed
{fixme}without an issue; - a named
{fixme}in a declaration; - a named
{fixme}in the book; - a
{fixme}naming an unknown definition.
It also asserts that a valid unnamed
{fixme}is accepted anywhere, including a requirement body.src/fixme.rs#mod[tests]/fn[fixme_bodies_split_github_options_from_their_description]covers option parsing, withgithubas the only recognised option and the issue-reference format.tests/references.rs#fn[a_fixme_does_not_count_as_an_items_reference]shows that neither named nor unnamed{fixme}counts as a reference for Rust item coverage.src/authoring/inputs.rs#mod[tests]/fn[references_contribute_their_owning_outline_nodes]shows that a named{fixme}yields an acknowledgment and an unnamed one does not. - an inline
The semantic clauses on what counts as implementing, such as calling code not counting, are review criteria for assessors rather than mechanical behavior. They are not gaps in test adequacy.
Inputs
Tests
Input 7: outline src/authoring/inputs.rs mod[tests]/fn[only_edges_leaving_the_subject_contribute_inputs]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[only_edges_leaving_the_subject_contribute_inputs] - Kind:
fn src/authoring/inputs.rs:1298–1362
// {test}`requirements.references.authoring_inputs`
// {test}`requirements.references.roles`
// {test}`requirements.authoring.mandatory_inputs`
// {test}`requirements.examples.definition`
#[test]
fn only_edges_leaving_the_subject_contribute_inputs() {
let root = project();
let declarations = format!(
":::{{req}} ready\nReady relies on {} and refines {}.\n:::\n\n:::{{req}} base\nBase MUST hold.\n:::\n\n:::{{req}} parent\nParent MUST hold.\n:::\n\n:::{{example}} citer\nA case relying on ready. {}\n:::\n\n:::{{example}} tester\nA ready case. {} {}\n:::\n",
role("cite", "requirements.base"),
role("impl", "requirements.parent"),
role("cite", "requirements.ready"),
role("cite", "requirements.base"),
role("test", "requirements.ready")
);
fs::write(root.path().join("md/requirements.md"), declarations).unwrap();
fs::write(
root.path().join("src/lib.rs"),
format!(
"// {}\nfn run() {{}}\n// {}\nfn helper() {{}}\n// {}\nfn check() {{}}\n",
role("impl", "requirements.ready"),
role("cite", "requirements.ready"),
role("test", "requirements.ready")
),
)
.unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let inputs = sources.mandatory_inputs();
let has_requirements =
|name: &str| inputs.iter().any(|input| input["requirements"] == name);
let has_item = |item: &str| inputs.iter().any(|input| input["item"] == item);
assert!(has_requirements("requirements.ready"));
assert!(has_requirements("requirements.base"), "{inputs:#?}");
assert!(has_requirements("requirements.tester"), "{inputs:#?}");
assert!(!has_item("fn[run]"), "{inputs:#?}");
assert!(has_item("fn[check]"), "{inputs:#?}");
assert!(!has_item("fn[helper]"), "{inputs:#?}");
assert!(!has_requirements("requirements.citer"), "{inputs:#?}");
assert!(!has_requirements("requirements.parent"), "{inputs:#?}");
let example = AssessmentSources::prepare(root.path(), "requirements.citer").unwrap();
assert!(
example
.mandatory_inputs()
.iter()
.any(|input| input["requirements"] == "requirements.ready"),
"{:#?}",
example.mandatory_inputs()
);
let parent = AssessmentSources::prepare(root.path(), "requirements.parent").unwrap();
let inputs = parent.mandatory_inputs();
assert!(
inputs
.iter()
.any(|input| input["requirements"] == "requirements.ready"),
"{inputs:#?}"
);
assert!(
!inputs
.iter()
.any(|input| input["requirements"] == "requirements.base"),
"{inputs:#?}"
);
}
Input 8: outline src/authoring/inputs.rs mod[tests]/fn[references_contribute_their_owning_outline_nodes]
- File:
src/authoring/inputs.rs - Selector:
mod[tests]/fn[references_contribute_their_owning_outline_nodes] - Kind:
fn src/authoring/inputs.rs:1706–1766
// {test}`requirements.references.authoring_inputs`
// {test}`requirements.references.outline_comments`
// {test}`requirements.references.anchors`
// {test}`requirements.authoring.mandatory_inputs`
// {test}`requirements.authoring.fixme_inputs`
// {test}`requirements.references.roles`
#[test]
fn references_contribute_their_owning_outline_nodes() {
let root = project();
fs::create_dir_all(root.path().join("docs")).unwrap();
fs::write(
root.path().join("md/requirements.md"),
":::{req} ready\n:impl: src/lib.rs#mod[inner]\nThe project MUST be ready.\n:::\n",
)
.unwrap();
// A `{fixme}` contributes metadata for the node its comment belongs to;
// an unnamed one is not an acknowledgment edge.
fs::write(
root.path().join("src/lib.rs"),
"mod inner {\n fn unrelated() {}\n}\n\n// :::{fixme} requirements.ready\n// The gap.\n// :::\nfn gap() {}\n\n// :::{fixme}\n// :github: example/app#1\n// :::\nfn tracked() {}\n",
)
.unwrap();
fs::write(
root.path().join("docs/guide.md"),
format!(
"# Intro\n\nText.\n\n# Usage\n\nSee {}.\n",
role("test", "requirements.ready")
),
)
.unwrap();
fs::write(
root.path().join("notes.txt"),
format!("first\n{}\n", role("test", "requirements.ready")),
)
.unwrap();
let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
let items = sources
.mandatory_inputs()
.iter()
.filter(|input| input.get("item").is_some())
.map(|input| {
(
input["file"].as_str().unwrap(),
input["item"].as_str().unwrap(),
)
})
.collect::<Vec<_>>();
assert_eq!(
items,
[
("docs/guide.md", "section[Usage]"),
// A plain-text file contributes the complete file.
("notes.txt", ""),
]
);
let acknowledgments = sources.model_acknowledgments();
assert_eq!(acknowledgments.len(), 1, "{acknowledgments:#?}");
assert_eq!(acknowledgments[0]["file"], "src/lib.rs");
assert_eq!(acknowledgments[0]["item"], "fn[gap]");
assert_eq!(acknowledgments[0]["body"], "The gap.");
}
Input 9: outline src/evidence.rs mod[tests]/fn[only_test_references_require_recorded_source_coverage]
- File:
src/evidence.rs - Selector:
mod[tests]/fn[only_test_references_require_recorded_source_coverage] - Kind:
fn src/evidence.rs:3634–3691
// {test}`requirements.references.evidence_coverage`
// {test}`requirements.references.roles`
#[test]
fn only_test_references_require_recorded_source_coverage() {
let temp = fixture();
fs::write(
temp.path().join("md/rules.md"),
":::{req} ready\nReady.\n:::\n",
)
.unwrap();
let source = "// {cite}`rules.ready`\nfn helper() {}\n// {impl}`rules.ready`\nfn run() {}\n// {test}`rules.ready`\nfn check() {}\n";
fs::write(temp.path().join("src/main.rs"), source).unwrap();
let record = |inputs: serde_json::Value| {
json!({
"requirement": "Ready.",
"determination": true,
"rationale": "The implementation and test were examined.",
"inputs": inputs
})
.to_string()
};
let path = temp.path().join("evidence/rules.ready.json");
fs::write(&path, record(json!([]))).unwrap();
let errors = without_citation_reviews(validate_repository(temp.path()).unwrap().errors);
let uncovered: Vec<_> = errors
.iter()
.filter(|error| error.contains("no input covers"))
.collect();
assert_eq!(uncovered.len(), 1, "{errors:#?}");
assert!(
uncovered
.iter()
.any(|error| error.contains("test") && error.contains("src/main.rs:5")),
"{errors:#?}"
);
assert!(
!errors.iter().any(|error| error.contains("src/main.rs:1")),
"{errors:#?}"
);
fs::write(
&path,
record(json!([outline(temp.path(), "src/main.rs", "fn[check]")])),
)
.unwrap();
let errors = without_citation_reviews(validate_repository(temp.path()).unwrap().errors);
assert!(errors.is_empty(), "{errors:?}");
// The unread implementation's body can change without invalidating
// this assessment; its reference set still describes the same roots.
fs::write(
temp.path().join("src/main.rs"),
source.replace("fn run() {}", "fn run() { panic!(\"changed\"); }"),
)
.unwrap();
let errors = without_citation_reviews(validate_repository(temp.path()).unwrap().errors);
assert!(errors.is_empty(), "{errors:?}");
}
Input 10: outline src/fenced.rs mod[tests]/fn[opening_fences_take_a_role_and_one_valid_or_built_in_name]
- File:
src/fenced.rs - Selector:
mod[tests]/fn[opening_fences_take_a_role_and_one_valid_or_built_in_name] - Kind:
fn src/fenced.rs:291–330
// {test}`requirements.references.roles`
// {test}`requirements.ci.identifiers`
// {test}`requirements.references.builtin_definitions`
#[test]
fn opening_fences_take_a_role_and_one_valid_or_built_in_name() {
let role = |name: &str| format!(":::{{{name}}}");
assert_eq!(
opening_fence(&format!("{} requirements.ready", role("impl"))),
Some((ReferenceKind::Impl, "requirements.ready", 3))
);
assert_eq!(
opening_fence("::::{cite} habeas:util"),
Some((ReferenceKind::Cite, "habeas:util", 4))
);
// A syntactically built-in name is recognized so validation can report
// an unknown built-in rather than leaving it literal.
assert_eq!(
opening_fence(&format!("{} habeas:unknown", role("impl"))),
Some((ReferenceKind::Impl, "habeas:unknown", 3))
);
assert_eq!(
opening_fence(&format!(" {} a.b", role("test"))),
Some((ReferenceKind::Test, "a.b", 3))
);
for literal in [
format!(" {} a.b", role("test")),
format!("{}a.b", role("cite")),
format!("{} a b", role("cite")),
format!("{} a..b", role("cite")),
format!("{} .a", role("cite")),
format!("{} a.", role("cite")),
format!("{} a/b", role("impl")),
format!("{} caf\u{e9}.b", role("impl")),
format!("{} other:none", role("cite")),
format!("{} a.b", role("term")),
"::{cite} a.b".to_owned(),
] {
assert_eq!(opening_fence(&literal), None, "{literal}");
}
}
Input 11: outline src/fenced.rs mod[tests]/fn[markdown_fences_close_with_enough_colons_and_skip_code]
- File:
src/fenced.rs - Selector:
mod[tests]/fn[markdown_fences_close_with_enough_colons_and_skip_code] - Kind:
fn src/fenced.rs:332–352
// {test}`requirements.references.roles`
// {test}`requirements.ci.fence_lengths`
#[test]
fn markdown_fences_close_with_enough_colons_and_skip_code() {
let content = "::::{cite} a.b\nouter\n:::{impl} c.d\ninner\n:::\n::::\n```text\n:::{cite} e.f\n```\n:::{test} g.h\nnever closed\n".to_owned();
let fences = markdown_fences(&content, true);
assert_eq!(fences.len(), 3);
assert_eq!(fences[0].name, "a.b");
assert!(fences[0].closed);
assert_eq!(
&content[fences[0].body.clone()],
"outer\n:::{impl} c.d\ninner\n:::\n"
);
assert_eq!(fences[1].name, "c.d");
assert_eq!(&content[fences[1].body.clone()], "inner\n");
assert_eq!(fences[2].name, "g.h");
assert!(!fences[2].closed);
assert_eq!(fences[2].line, 10);
// In plain text, the code fence is ordinary text.
assert_eq!(markdown_fences(&content, false).len(), 4);
}
Input 12: outline src/fenced.rs mod[tests]/fn[comment_delimiters_are_removed_per_line]
- File:
src/fenced.rs - Selector:
mod[tests]/fn[comment_delimiters_are_removed_per_line] - Kind:
fn src/fenced.rs:377–391
// {test}`requirements.references.roles`
#[test]
fn comment_delimiters_are_removed_per_line() {
assert_eq!(
strip_comment_delimiters(" // :::{cite} a"),
" :::{cite} a"
);
assert_eq!(strip_comment_delimiters("/// body"), " body");
assert_eq!(strip_comment_delimiters("//! body"), " body");
assert_eq!(strip_comment_delimiters("# body"), " body");
assert_eq!(strip_comment_delimiters("/* body */"), " body ");
assert_eq!(strip_comment_delimiters(" * body"), " body");
assert_eq!(strip_comment_delimiters(" ::: */"), "::: ");
assert_eq!(strip_comment_delimiters("<!-- ::: -->"), " ::: ");
}
Input 13: outline src/fenced.rs mod[tests]/fn[comment_fences_close_within_one_comment_run]
- File:
src/fenced.rs - Selector:
mod[tests]/fn[comment_fences_close_within_one_comment_run] - Kind:
fn src/fenced.rs:393–410
// {test}`requirements.references.roles`
// {test}`requirements.references.outline_comments`
#[test]
fn comment_fences_close_within_one_comment_run() {
let source = "// :::{cite} habeas:util\n// Exists for its caller.\n// :::\nfn a() {}\n\n// :::{cite} habeas:util\n// never closed here\n\n// :::\nfn b() {}\n/*\n * :::{impl} requirements.ready\n * Checks it.\n * :::\n */\nfn c() {}\n".to_owned();
let outline = crate::outline::parse(std::path::Path::new("lib.rs"), &source).unwrap();
let fences = comment_fences(&source, &outline);
assert_eq!(fences.len(), 3, "{fences:?}");
assert_eq!(fences[0].body, "Exists for its caller.");
assert!(fences[0].closed);
assert_eq!(fences[0].line, 1);
assert_eq!(outline.nodes[fences[0].owner.unwrap()].selector, "fn[a]");
assert!(!fences[1].closed, "a later run's fence does not close it");
assert_eq!(fences[1].line, 6);
assert_eq!(fences[2].kind, ReferenceKind::Impl);
assert_eq!(fences[2].body, "Checks it.");
assert_eq!(outline.nodes[fences[2].owner.unwrap()].selector, "fn[c]");
}
Input 14: outline src/fixme.rs mod[tests]/fn[fixme_bodies_split_github_options_from_their_description]
- File:
src/fixme.rs - Selector:
mod[tests]/fn[fixme_bodies_split_github_options_from_their_description] - Kind:
fn src/fixme.rs:308–339
// {test}`requirements.references.roles`
#[test]
fn fixme_bodies_split_github_options_from_their_description() {
let parsed = FixmeBody::parse(
" :github: rust-lang/rust#123\n :github: example/io#125\n Retry is\n untested.",
);
assert_eq!(parsed.issues, ["rust-lang/rust#123", "example/io#125"]);
assert_eq!(parsed.description, "Retry is untested.");
assert!(parsed.problems.is_empty(), "{parsed:?}");
let parsed = FixmeBody::parse(
":github: o/r#1\n:gitlab: o/r#2\n:github: o/r\n:github: o/r#01\n:github:\nGap.\n:github: o/r#3",
);
assert_eq!(parsed.issues, ["o/r#1"]);
// Option lines end at the first other line.
assert_eq!(parsed.description, "Gap. :github: o/r#3");
assert_eq!(parsed.problems.len(), 4, "{parsed:?}");
assert!(parsed.problems[0].contains(":gitlab:"), "{parsed:?}");
for (problem, value) in parsed.problems[1..].iter().zip(["o/r", "o/r#01", ""]) {
assert!(problem.contains(&format!("{value:?}")), "{problem}");
}
assert!(FixmeBody::parse(":github: o/r#1").description.is_empty());
for valid in ["o/r#1", "rust-lang/rust#123", "a1/b.c_d-e#90"] {
assert!(is_issue_reference(valid), "{valid}");
}
for invalid in [
"#1", "o/r#0", "o/r#01", "o/r/s#1", "-o/r#1", "o/r#1x", " o/r#1",
] {
assert!(!is_issue_reference(invalid), "{invalid}");
}
}
Input 15: outline tests/references.rs fn[fenced_references_in_comments_and_built_in_rules_are_validated]
- File:
tests/references.rs - Selector:
fn[fenced_references_in_comments_and_built_in_rules_are_validated] - Kind:
fn tests/references.rs:72–129
// {test}`requirements.references.roles`
// {test}`requirements.references.builtin_definitions`
// {test}`requirements.references.rust_item_coverage`
// {test}`requirements.references.procedure`
// {test}`requirements.references.util`
#[test]
fn fenced_references_in_comments_and_built_in_rules_are_validated() {
let temp = project();
let root = temp.path();
let cr = role("cite");
let source = format!(
"// :::{cr} habeas:util\n// Glue that formats output.\n// :::\nfn glue() {{}}\n\n\
// {cr}`habeas:none`\nfn inline() {{}}\n\n\
// :::{cr} habeas:util\n// {cr}`rules.ready`\n// :::\nfn empty() {{}}\n\n\
// :::{im} habeas:util\n// Wrong role.\n// :::\nfn wrong_role() {{}}\n\n\
// :::{cr} habeas:other\n// Unknown.\n// :::\nfn unknown() {{}}\n\n\
// :::{cr} rules.ready\n// never closed\n\n// :::\nfn unclosed() {{}}\n\n\
// :::{cr} habeas:none\n// Formats output.\n// :::\nfn fenced_none() {{}}\n",
im = role("impl"),
);
fs::write(root.join("src/lib.rs"), source).unwrap();
let errors = errors(root);
for expected in [
// `habeas:none` was removed: it is an unknown name in either form.
"src/lib.rs:6: {cite}`habeas:none` has no matching built-in definition",
"src/lib.rs:30: {cite}`habeas:none` has no matching built-in definition",
"src/lib.rs:14: built-in habeas:util may only be referenced with {cite}",
"src/lib.rs:19: {cite}`habeas:other` has no matching built-in definition",
"src/lib.rs:24: fenced {cite} reference to rules.ready has no closing fence",
"src/lib.rs:7: function inline has no recent coverage: it has no requirement or example reference, and no recent evidence record or review read it",
"src/lib.rs:17: function wrong_role has no recent coverage: it has no requirement or example reference, and no recent evidence record or review read it",
"src/lib.rs:22: function unknown has no recent coverage: it has no requirement or example reference, and no recent evidence record or review read it",
"src/lib.rs:28: function unclosed has no recent coverage: it has no requirement or example reference, and no recent evidence record or review read it",
"src/lib.rs:33: function fenced_none has no recent coverage: it has no requirement or example reference, and no recent evidence record or review read it",
] {
assert!(has(&errors, expected), "missing {expected:?}: {errors:#?}");
}
// A fenced citation of habeas:util covers its function, as does an
// inline reference in a fence body.
assert!(!has(&errors, "function glue"), "{errors:#?}");
assert!(!has(&errors, "function empty"), "{errors:#?}");
// Only valid citations other than habeas:util need reviews.
assert!(has(
&errors,
"missing citation review for src/lib.rs fn[empty]"
));
for item in ["glue", "inline", "fenced_none"] {
assert!(
!has(
&errors,
&format!("missing citation review for src/lib.rs fn[{item}]")
),
"{errors:#?}"
);
}
// Built-ins need no evidence.
assert!(!has(&errors, "evidence/habeas:"), "{errors:#?}");
}
Input 16: outline tests/references.rs fn[fixme_references_are_fenced_described_and_named_only_outside_the_book]
- File:
tests/references.rs - Selector:
fn[fixme_references_are_fenced_described_and_named_only_outside_the_book] - Kind:
fn tests/references.rs:315–361
// {test}`requirements.references.roles`
// {test}`requirements.references.discovery`
#[test]
fn fixme_references_are_fenced_described_and_named_only_outside_the_book() {
let temp = project();
let root = temp.path();
let fx = role("fixme");
fs::write(
root.join("src/gaps.rs"),
format!(
"// {fx}`rules.ready`\n\n\
// :::{fx} rules.ready\n// :github: example/rules#1\n// :gitlab: example/rules#2\n// :github: example/rules\n// The gap.\n// :::\n\n\
// :::{fx} rules.ready\n// :github: example/rules#1\n// :::\n\n\
// :::{fx}\n// Only words.\n// :::\n\n\
// :::{fx}\n// :github: example/rules#4\n// Tracked here.\n// :::\n\n\
// :::{fx} rules.missing\n// Gap.\n// :::\n"
),
)
.unwrap();
fs::write(
root.join("md/rules.md"),
format!(
"::::{{req}} ready\nReady.\n\n:::{fx} rules.ready\nIn a declaration.\n:::\n\n:::{fx}\n:github: example/rules#3\n:::\n::::\n\n:::{fx} rules.ready\nIn the book.\n:::\n"
),
)
.unwrap();
let errors = errors(root);
for expected in [
"src/gaps.rs:1: inline {fixme} reference to rules.ready must use the fenced form",
"src/gaps.rs:3: unsupported {fixme} option :gitlab:",
"src/gaps.rs:3: :github: value \"example/rules\" is not of the form <owner>/<repo>#<number>",
"src/gaps.rs:10: {fixme} to rules.ready has an empty body",
"src/gaps.rs:14: an unnamed {fixme} must name at least one issue",
"src/gaps.rs:23: {fixme}`rules.missing` has no matching requirement or example",
"md/rules.md:4: a named {fixme} to rules.ready must not appear in a requirement or example declaration",
"md/rules.md:13: a named {fixme} to rules.ready must appear in a source outside the book",
] {
assert!(has(&errors, expected), "missing {expected:?}: {errors:#?}");
}
// An unnamed `{fixme}` with an issue is valid anywhere, including a
// requirement body, and is not an edge needing coverage.
for line in ["src/gaps.rs:18", "md/rules.md:8"] {
assert!(!has(&errors, line), "{line}: {errors:#?}");
}
// A misplaced named `{fixme}` is reported once, not also as uncovered.
assert!(!has(&errors, "` at md/"), "{errors:#?}");
}
Input 17: outline tests/references.rs fn[a_fixme_does_not_count_as_an_items_reference]
- File:
tests/references.rs - Selector:
fn[a_fixme_does_not_count_as_an_items_reference] - Kind:
fn tests/references.rs:363–389
// {test}`requirements.references.procedure`
// {test}`requirements.references.rust_item_coverage`
// {test}`requirements.references.roles`
#[test]
fn a_fixme_does_not_count_as_an_items_reference() {
let temp = project();
let root = temp.path();
let fx = role("fixme");
fs::write(
root.join("src/lib.rs"),
format!(
"// :::{fx} rules.ready\n// The gap.\n// :::\nfn gap() {{}}\n\n\
// :::{fx}\n// :github: example/rules#1\n// :::\nfn tracked() {{}}\n\n\
// {}`rules.ready`\n// :::{fx} rules.ready\n// Another gap.\n// :::\nfn implemented() {{}}\n",
role("impl")
),
)
.unwrap();
let errors = errors(root);
for expected in [
"src/lib.rs:4: function gap has no recent coverage: it has no requirement or example reference, and no recent evidence record or review read it",
"src/lib.rs:9: function tracked has no recent coverage: it has no requirement or example reference, and no recent evidence record or review read it",
] {
assert!(has(&errors, expected), "missing {expected:?}: {errors:#?}");
}
assert!(!has(&errors, "function implemented"), "{errors:#?}");
}
Referenced definitions
Input 2: requirements selection requirements.references.builtin_definitions
requirements.references.builtin_definitions:md/requirements/references.md:126–144
:::{req} builtin_definitions
Habeas MUST provide built-in definitions named `habeas:<name>`, available in
every project without a declaration. Each built-in MUST have fixed text, which
states its obligations and is documented in Habeas's reference documentation, and
MUST state which reference roles may use it. References MUST resolve built-in
names alongside project definitions. So that every book stands alone, the book
MUST render a reference to a built-in as a badge without a link whose hover text
gives the built-in's full text. Built-ins themselves MUST NOT require or permit
definition evidence files and MUST NOT appear as definitions in the requirements
index, `habeas status`, or the missing-evidence check of
{cite}`requirements.ci.coverage`. Per-source citation reviews under
{cite}`requirements.references.citation_review` MAY be required for references
to a built-in. A project definition
MUST NOT use a full name beginning with `habeas:`; validation MUST report one,
and the `:` character already makes such names invalid under
{cite}`requirements.ci.identifiers`. Validation MUST report a reference to a
built-in in a role the built-in does not permit, or that breaks the built-in's
stated form.
:::
Input 3: 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.
:::
Input 4: requirements selection requirements.ci.fence_lengths
requirements.ci.fence_lengths:md/requirements/ci.md:321–323
:::{req} fence_lengths
A `{req}` opening fence MAY contain four or more colons. Habeas MUST accept opening fences of any length of at least three colons. A colon-only line with fewer colons than the opener MUST remain inside the requirement body, allowing a nested colon directive. A closing fence outside a fenced code example with at least as many colons as the opener MUST end the body.
:::
Input 5: requirements selection requirements.references.outline_comments
requirements.references.outline_comments:md/requirements/references.md:415–430
:::{req} outline_comments
Each documented profile defines which grammar nodes are comments; the Markdown
profile's comments are HTML comment blocks, so an inline HTML comment within a
paragraph is text of its section. In every supported language, comments on consecutive lines with no other source
between them MUST form one comment run. A comment that follows other source on
the same line, including another comment, MUST form a run by itself and MUST belong to the innermost outline node
containing that line. Any other run MUST belong to the next outline node that
starts after it within the smallest node containing it; when that container has
no such node, the run MUST belong to the container, which is the root node at top
level. A profile MAY bind a comment kind to its container
instead: such a run MUST belong to the smallest node containing it. The Rust
profile MUST bind inner doc comments (`//!`, `/*!`) to their container, so a
file-level inner doc comment belongs to the root node. A reference in a comment MUST count for the node its run belongs to under
{cite}`requirements.references.rust_item_coverage` and
{cite}`requirements.references.authoring_inputs`.
:::
Input 6: requirements selection requirements.cli.fixme_issues
requirements.cli.fixme_issues:md/requirements/cli.md:40–50
:::{req} fixme_issues
`habeas status` MUST look up, under {cite}`requirements.authoring.github_reads`,
every issue that a `:github:` option line of a named or unnamed `{fixme}` under
{cite}`requirements.references.roles` names, and MUST report each `{fixme}`
naming an issue that is closed or does not exist as an error, with its file and
line and the issue. It MUST also report the item that contains that `{fixme}` as
failing: the outline node containing it, or the requirement or example
declaration whose body contains it, in the same way it reports an uncovered
Rust item. When GitHub cannot be reached, the issue MUST be assumed open.
Repository validation MUST NOT contact GitHub.
:::
Other sources
Input 1: requirements selection requirements.references.roles
requirements.references.roles:md/requirements/references.md:3–49
:::{req} roles
Project text files MAY use the `{impl}`, `{cite}`, and `{test}` roles with a backtick-delimited full requirement or example name, or with a built-in name under {cite}`requirements.references.builtin_definitions`, and MAY use the `{fixme}` role in fenced form. A reference MAY instead be written in fenced form, `:::{role} name` on one line, a body, and a closing fence, following the fence rules of {cite}`requirements.ci.span` and {cite}`requirements.ci.fence_lengths`; the fenced form is the same edge with attached commentary, and the inline form carries none. In a source comment, fence lines MUST be recognized after removing each line's comment delimiters within one comment run under {cite}`requirements.references.outline_comments`, and a fence that does not close within its comment run MUST be a validation error. Each reference is a directed edge between its source and the named definition. A source is a project source item or a requirement or example declaration. The roles MUST mean:
- `{cite}`: the source relies on, supports, or refers to the definition. It is an
edge from the source to the definition.
- `{impl}`: the source implements part of the definition: it makes a decision,
performs a check, produces an output, or handles a case that the definition
specifies. A requirement MAY implement part of another requirement by refining
one of its obligations. Calling code that implements a definition, or
producing a result a caller uses to meet it, MUST NOT by itself count as
implementing it. A check MUST count only if the definition states it, or the
source could not meet one of the definition's obligations without it; source
that checks it is consistent with a definition, such as recognizing a form the
definition specifies in order to decide whether to run other behavior, relies
on that definition and calls for `{cite}`. A requirement stating a convention
for every output of a kind, such as every validation error, is implemented by
the source that carries out the convention as a whole, such as the step that
collects and reports those outputs.
- `{test}`: the source is designed to verify behavior the definition specifies:
a test through its scenario and the assertions about that scenario's outcome,
or a named example through the concrete case it describes.
- `{fixme}`: the source acknowledges a known gap in fulfilling the definition. It
MUST use the fenced form, and its body MUST describe the gap. The body MAY
begin with option lines naming issues that track the gap, one per line, in the
form `:github: <owner>/<repo>#<number>`, such as
`:github: rust-lang/rust#123`. `github` MUST be the only recognized option.
A named `{fixme}` MAY appear only in sources outside the book. Validation MUST report
any other option line, a `:github:` value not in that form, an inline
`{fixme}`, a `{fixme}` in a requirement or example declaration, and a
`{fixme}` whose body, without option lines and comment delimiters, is empty.
An unnamed `{fixme}`, a fence of `:::{fixme}` with no name, MAY appear in any
project text, including a requirement or example body, to tie that place to
the issues it names. It MUST have at least one `:github:` option line and MAY
have a description; it is not a reference edge, acknowledges no gap, needs no
coverage, and does not count as a reference for Rust item coverage. Its
issues are checked under {cite}`requirements.cli.fixme_issues`.
`{impl}`, `{test}`, and `{fixme}` are edges from the definition to the source.
Only requirements and examples are assessed; code is reviewed as part of the
definitions it implements or tests.
```text
{impl}`requirements.references.roles`
{cite}`requirements.references.roles`
{test}`requirements.references.roles`
```
:::