Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

requirements.definitions.reassessment

Requirements index · View definition

evidence Valid

Example

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

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. capture writes a record with definition(root, "glossary.a") and definition(root, "glossary.b") inputs. approve then sets determination to true. validate_repository returns no errors, so the record is approved and its definition inputs are current. The test then reads the file bytes into before.
  • Definition changes.
    • Prepending blank lines to md/glossary.md moves 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 of glossary.a. One changes the body text of glossary.b.
  • 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.inputs rule 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]
// {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
:::{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
:::{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`
:::