requirements.definitions.glob_dependency
Requirements index · View definition
Example
A requirements input selects
requirements.cli.*. A selected requirement referencesglossary.command, which is captured as a separate definition input despite not matching that selection. An unreferenced definition namedrequirements.cli.unrelatedis not selected merely because its name matches the selection.
Rationale
tests/definitions.rs#fn[globs_exclude_terms_but_capture_referenced_terms_outside_the_glob] carries a {test} reference to requirements.definitions.glob_dependency. Its setup matches the example: a glob rules.* selects rules.ready. That requirement references glossary.a, which is outside the glob, and rules.used. A definition rules.unrelated matches the glob’s name prefix but nothing references it.
Its assertions cover each stated outcome:
- With inputs for the selection,
glossary.a,glossary.bandrules.used, and no input forrules.unrelated, validation has no errors. So the unreferenced definition is not selected or required, and the glob selects only the requirement. - Omitting
rules.usedgivesrules.used, found 0, and no error ever mentionsrules.unrelated. - Omitting
glossary.a, which is outside the glob, givesglossary.a, found 0. So a referenced definition that does not match the selection is required as a separate input. - A selection whose recorded matches include the named definition
rules.usedis reported as stale. This shows named definitions are excluded from selection.
No gaps found.
Inputs
Tests
Input 3: outline tests/definitions.rs fn[globs_exclude_terms_but_capture_referenced_terms_outside_the_glob]
- File:
tests/definitions.rs - Selector:
fn[globs_exclude_terms_but_capture_referenced_terms_outside_the_glob] - Kind:
fn tests/definitions.rs:252–347
// {test}`requirements.definitions.selection`
// {test}`requirements.definitions.glob_dependency`
#[test]
fn globs_exclude_terms_but_capture_referenced_terms_outside_the_glob() {
let temp = fixture();
// `rules.used` matches the glob and is referenced; `rules.unrelated`
// matches the glob and shares its prefix but is not referenced.
fs::write(
temp.path().join("md/rules.md"),
":::{req} ready\nUse {term}`glossary.a` and {term}`rules.used`.\n:::\n\n:::{definition} used\n:phrase: used\n\nReferenced.\n:::\n\n:::{definition} unrelated\n:phrase: unrelated\n\nNot referenced.\n:::\n",
)
.unwrap();
let root = temp.path();
let selection = requirements(root, "rules.*", &["rules.ready"]);
let path = record(
root,
"rules.ready",
vec![
selection.clone(),
definition(root, "glossary.a"),
definition(root, "glossary.b"),
definition(root, "rules.used"),
],
);
approve(&path);
// The glob selects only the requirement, and exactly the referenced
// definitions are required as separate inputs.
let errors = validate_repository(root).unwrap().errors;
assert!(errors.is_empty(), "{errors:?}");
// The referenced definition is required although the glob does not
// select it; the unreferenced one is never required.
record(
root,
"rules.ready",
vec![
selection,
definition(root, "glossary.a"),
definition(root, "glossary.b"),
],
);
approve(&path);
let errors = validate_repository(root).unwrap().errors;
assert!(
errors
.iter()
.any(|error| error.contains("rules.used, found 0")),
"{errors:?}"
);
assert!(
errors
.iter()
.all(|error| !error.contains("rules.unrelated")),
"{errors:?}"
);
// A directly referenced definition outside the glob is also mandatory.
record(
root,
"rules.ready",
vec![
requirements(root, "rules.*", &["rules.ready"]),
definition(root, "glossary.b"),
definition(root, "rules.used"),
],
);
approve(&path);
let errors = validate_repository(root).unwrap().errors;
assert!(
errors
.iter()
.any(|error| error.contains("glossary.a, found 0")),
"{errors:?}"
);
// A selection whose recorded matches include named definitions is stale.
let definitions = requirements(root, "rules.*", &["rules.ready", "rules.used"]);
record(
root,
"rules.ready",
vec![
definitions,
definition(root, "glossary.a"),
definition(root, "glossary.b"),
definition(root, "rules.used"),
],
);
approve(&path);
let errors = validate_repository(root).unwrap().errors;
assert!(
errors
.iter()
.any(|error| error.starts_with("evidence/rules.ready.json")),
"{errors:?}"
);
}
Referenced definitions
Input 2: requirements selection requirements.definitions.selection
requirements.definitions.selection:md/requirements/definitions.md:31–33
:::{req} selection
A {term}`requirements.references.definition_selection` in a requirements input MUST continue to select requirements and named examples, excluding named definitions. Definitions referenced by selected texts MUST be captured as separate definition inputs, regardless of whether their names match the selection. Sharing a selection's matching name prefix alone MUST NOT make a definition a dependency.
:::
Input 4: definition requirements.references.definition_selection
requirements.references.definition_selection:md/requirements/references.md:335–342
:::{definition} definition_selection
:phrase: definition selection
A full requirement or example name, or a definition glob, identifying the
requirements and named examples it matches under
{cite}`requirements.references.definition_globs`. A name without `*` selects
exactly that definition.
:::
Other sources
Input 1: requirements selection requirements.definitions.glob_dependency
requirements.definitions.glob_dependency:md/requirements/definitions.md:43–45
:::{example} glob_dependency
A requirements input selects `requirements.cli.*`. A selected requirement references `glossary.command`, which is captured as a separate definition input despite not matching that selection. An unreferenced definition named `requirements.cli.unrelated` is not selected merely because its name matches the selection. {cite}`requirements.definitions.selection`
:::