requirements.definitions.reassessment
Requirements index · View definition
Example
An evidence record has determination true and a current definition input. After the definition changes, validation reports stale evidence without modifying the record.
Rationale
The example requirements.definitions.reassessment describes a concrete case. An evidence record has determination true and a current definition input. The definition then changes, and validation reports stale evidence without modifying the record. It cites requirements.definitions.inputs.
tests/definitions.rs#fn[cyclic_dependencies_are_required_once_and_changes_require_review] carries a {test} reference to the example. It covers each part of the scenario:
- Setup.
capturewrites a record withdefinition(root, "glossary.a")anddefinition(root, "glossary.b")inputs.approvethen setsdeterminationto true.validate_repositoryreturns no errors, so the record is approved and its definition inputs are current. The test then reads the file bytes intobefore. - Definition changes.
- Prepending blank lines to
md/glossary.mdmoves the definitions. Validation still returns no errors, which matches the requirement that moving a definition must not invalidate it. - Three real edits follow. One changes the phrase option of
glossary.b. One changes the body text ofglossary.a. One changes the body text ofglossary.b.
- Prepending blank lines to
- Stale report. After each edit the test asserts that some error contains both “input text changed” and the changed definition’s name. This matches the
requirements.definitions.inputsrule that validation rejects changed snapshot text and identifies the definition. - Record not modified. After each validation the test asserts
assert_eq!(before, fs::read(&path).unwrap()), so the record file is byte-for-byte unchanged.
The test also covers reassessment: re-running capture and approve leaves validation clean. It checks missing and duplicate definition inputs as well.
The record in the test is for a requirement (rules.ready), not an example. That does not matter, because the example’s behavior is about definition inputs and staleness. I found no scenario or outcome that the tests would accept while violating the example.
Inputs
Tests
Input 3: outline tests/definitions.rs fn[cyclic_dependencies_are_required_once_and_changes_require_review]
- File:
tests/definitions.rs - Selector:
fn[cyclic_dependencies_are_required_once_and_changes_require_review] - Kind:
fn tests/definitions.rs:173–250
// {test}`requirements.definitions.transitive_cycle`
// {test}`requirements.definitions.reassessment`
// {test}`requirements.definitions.dependencies`
// {test}`requirements.definitions.inputs`
#[test]
fn cyclic_dependencies_are_required_once_and_changes_require_review() {
let temp = fixture();
let root = temp.path();
capture(root);
let path = root.join("evidence/rules.ready.json");
approve(&path);
let report = validate_repository(root).unwrap();
assert!(report.errors.is_empty(), "{:?}", report.errors);
let before = fs::read(&path).unwrap();
let glossary = root.join("md/glossary.md");
let original = fs::read_to_string(&glossary).unwrap();
fs::write(&glossary, format!("\n\n{original}")).unwrap();
assert!(validate_repository(root).unwrap().errors.is_empty());
for (changed, definition) in [
(
original.replace(":phrase: beta", ":phrase: new beta"),
"glossary.b",
),
(
original
.replace("See TERM", "Read TERM")
.replace("See {term}", "Read {term}"),
"glossary.a",
),
(
original.replace("See {term}`glossary.a`.", "Read {term}`glossary.a`."),
"glossary.b",
),
] {
fs::write(&glossary, changed).unwrap();
let report = validate_repository(root).unwrap();
assert!(
report
.errors
.iter()
.any(|e| e.contains("input text changed") && e.contains(definition)),
"{:?}",
report.errors
);
assert_eq!(before, fs::read(&path).unwrap());
}
// Reassessment records the current snapshots.
capture(root);
let refreshed: Value = serde_json::from_str(&fs::read_to_string(&path).unwrap()).unwrap();
approve(&path);
assert!(validate_repository(root).unwrap().errors.is_empty());
let mut missing = refreshed.clone();
missing["inputs"]
.as_array_mut()
.unwrap()
.retain(|i| i.get("definition") != Some(&json!("glossary.b")));
fs::write(&path, missing.to_string()).unwrap();
assert!(
validate_repository(root)
.unwrap()
.errors
.iter()
.any(|e| e.contains("glossary.b, found 0"))
);
let mut duplicate = refreshed;
let input = duplicate["inputs"][1].clone();
duplicate["inputs"].as_array_mut().unwrap().push(input);
fs::write(&path, duplicate.to_string()).unwrap();
assert!(
validate_repository(root)
.unwrap()
.errors
.iter()
.any(|e| e.contains("found 2"))
);
}
Referenced definitions
Input 2: requirements selection requirements.definitions.inputs
requirements.definitions.inputs:md/requirements/definitions.md:15–19
:::{req} inputs
Evidence inputs MAY have a definition form containing exactly `definition` and `text`. `definition` MUST identify one named definition; `text` MUST contain its complete raw fenced declaration as source lines, including its phrase option and explanatory body.
Validation MUST reject missing definitions and changed snapshot text, identifying the definition and showing a compact diff when available. Moving an unchanged definition within its chapter MUST NOT invalidate its snapshot. Evidence displays MUST show the definition name, current source location, and recorded text.
:::
Other sources
Input 1: requirements selection requirements.definitions.reassessment
requirements.definitions.reassessment:md/requirements/definitions.md:47–49
:::{example} reassessment
An evidence record has determination true and a current definition input. After the definition changes, validation reports stale evidence without modifying the record. {cite}`requirements.definitions.inputs`
:::