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.authoring_input

Requirements index · View definition

evidence Valid

Requirement

When authoring evidence for a requirement, its fenced declaration, including its complete body but excluding anchor option lines, MUST be included in the mandatory input set defined by cite requirements.authoring.mandatory_inputs.

Rationale

I judged the tests adequate for requirements.authoring_input. The requirement has three testable obligations. The subject’s fenced declaration must be in the mandatory input set. That declaration must include its complete body. It must exclude anchor option lines. I did not request implementation source, because the supplied tests were enough to judge.

  • Declaration included with a complete body, and anchor option lines excluded. src/authoring/inputs.rs#mod[tests]/fn[anchored_files_contribute_root_node_inputs] is the key test.
    • It declares requirements.ready with :impl: and :test: anchor lines, a multi-paragraph body that includes a blank line, and a body line that reads :impl: this is body text.
    • It asserts exact equality of the whole mandatory input list. The requirement entry’s text is :::{req} ready, the full body (including the blank line and the body-text :impl: line), then :::. The real anchor option lines are absent, and the look-alike body line is kept.
    • A harness that dropped body lines, truncated the body, stripped every :impl: line, or left the anchors in would fail this test.
    • It also asserts that subject_text is the body without anchors.
  • Simple case and exact content. fn[unresolvable_earlier_inputs_do_not_block_reassessment] asserts the sole mandatory input is the full requirements.ready declaration (fence, body, closing fence). The declaration is therefore present even when earlier evidence inputs are unresolvable.
  • Subject-kind variation. fn[bundle_combines_direct_references_terms_and_current_existing_selectors] prepares an example subject (requirements.case). It asserts the first mandatory input is the complete declaration text, and that the requirement subject’s own declaration is included alongside the other inputs.
  • Declaration required before use. fn[mandatory_git_inputs_require_staging_declarations_sources_and_terms] shows prepare fails when the declaring md/requirements.md is not staged. The declaration is therefore a required input, not an optional one.

The tests cover the distinct classes the text names: a body with and without anchors, a multi-paragraph body, an option-like body line, and both requirement and example subjects. Mandatory-set mechanics such as deduplication and the evidence/ exclusion belong to requirements.authoring.mandatory_inputs, which is cited context, so I did not reassess them here. I found no gap and no acknowledgment was needed.

Inputs

Tests

Input 3: outline src/authoring/inputs.rs mod[tests]/fn[bundle_combines_direct_references_terms_and_current_existing_selectors]
  • File: src/authoring/inputs.rs
  • Selector: mod[tests]/fn[bundle_combines_direct_references_terms_and_current_existing_selectors]
  • Kind: fn
  • src/authoring/inputs.rs:955–1058
    // {test}`requirements.authoring.complete_initial_bundle`
    // {test}`requirements.authoring.mandatory_inputs`
    // {test}`requirements.authoring_input`
    // {test}`requirements.examples.authoring_inputs`
    // {test}`requirements.references.authoring_inputs`
    // {test}`requirements.definitions.authoring_inputs`
    // {test}`requirements.ci.authoring_inputs`
    // {test}`requirements.ci.reference_set`
    #[test]
    fn bundle_combines_direct_references_terms_and_current_existing_selectors() {
        let root = project();
        let terms = format!(
            ":::{{definition}} unit\n:phrase: unit\nA {}.\n:::\n\n:::{{definition}} value\n:phrase: value\nA {}.\n:::\n",
            role("term", "terms.value"),
            role("term", "terms.unit")
        );
        fs::write(root.path().join("md/terms.md"), terms).unwrap();
        let declarations = format!(
            ":::{{req}} ready\nReady uses {} and {}.\n:::\n\n:::{{req}} base\nBase cites {}.\n:::\n\n:::{{req}} distant\nDistant MUST work.\n:::\n\n:::{{example}} case\nReady example. {} {}\n:::\n",
            role("cite", "requirements.base"),
            role("term", "terms.unit"),
            role("cite", "requirements.distant"),
            role("cite", "requirements.ready"),
            role("test", "requirements.ready")
        );
        fs::write(root.path().join("md/requirements.md"), declarations).unwrap();
        fs::write(root.path().join("src/lib.rs"), format!("struct Thing;\nimpl Thing {{\n    // {}\n    fn run(&self) {{}}\n    fn unrelated(&self) {{}}\n}}\n// {}\nfn test_ready() {{}}\n", role("impl", "requirements.ready"), role("test", "requirements.ready"))).unwrap();
        fs::write(root.path().join("notes.txt"), "new source text\n").unwrap();
        fs::create_dir(root.path().join("evidence")).unwrap();
        fs::write(
            root.path().join("evidence/requirements.ready.json"),
            json!({
                "determination": false, "rationale": "old secret judgment",
                "inputs": [{"file":"notes.txt", "line_start":1, "line_end":1, "text":["old text"]}]
            })
            .to_string(),
        )
        .unwrap();
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        // The recorded digest covers the same `{impl}` and `{test}` edges.
        assert_eq!(
            sources.reference_set,
            crate::evidence::reference_set_digest_for(root.path(), "requirements.ready").unwrap()
        );
        let inputs = sources.mandatory_inputs();
        assert!(sources.recorded_inputs().is_empty());
        assert!(
            !inputs
                .iter()
                .any(|input| input["item"] == "impl[Thing]/fn[run]")
        );
        assert!(inputs.iter().any(|input| input["item"] == "fn[test_ready]"));
        assert!(!inputs.iter().any(|input| input["item"] == "impl[Thing]"));
        assert!(
            inputs
                .iter()
                .any(|input| input["requirements"] == "requirements.case")
        );
        assert!(
            inputs
                .iter()
                .any(|input| input["requirements"] == "requirements.base")
        );
        assert!(
            !inputs
                .iter()
                .any(|input| input["requirements"] == "requirements.distant")
        );
        assert_eq!(
            inputs
                .iter()
                .filter(|input| input.get("definition").is_some())
                .count(),
            2
        );
        // Earlier evidence inputs are not carried forward.
        assert!(!inputs.iter().any(|input| input["file"] == "notes.txt"));
        assert!(
            !serde_json::to_string(inputs)
                .unwrap()
                .contains("old secret judgment")
        );
        let example = AssessmentSources::prepare(root.path(), "requirements.case").unwrap();
        assert!(matches!(
            example.subject_kind,
            AssessmentKind::Definition(DefinitionKind::Example, false)
        ));
        assert_eq!(
            example.mandatory_inputs()[0]["requirements"],
            "requirements.case"
        );
        assert_eq!(
            example.mandatory_inputs()[0]["text"],
            json!([
                ":::{example} case",
                format!(
                    "Ready example. {} {}",
                    role("cite", "requirements.ready"),
                    role("test", "requirements.ready")
                ),
                ":::"
            ])
        );
    }
Input 4: outline src/authoring/inputs.rs mod[tests]/fn[unresolvable_earlier_inputs_do_not_block_reassessment]
    // {test}`requirements.authoring.mandatory_inputs`
    // {test}`requirements.ci.authoring_inputs`
    // {test}`requirements.authoring_input`
    #[test]
    fn unresolvable_earlier_inputs_do_not_block_reassessment() {
        let root = project();
        fs::create_dir(root.path().join("evidence")).unwrap();
        fs::write(
            root.path().join("evidence/requirements.ready.json"),
            json!({
                "inputs": [
                    {"file":"missing.txt", "line_start":1, "line_end":1},
                    {"rust_file":"src/lib.rs", "rust_item":"fn[removed]", "text":["fn removed() {}"]},
                    {"requirements":"requirements.removed", "matches":["requirements.removed"], "text":["gone"]}
                ]
            })
            .to_string(),
        )
        .unwrap();
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        assert_eq!(
            sources.mandatory_inputs(),
            &[json!({
                "requirements": "requirements.ready",
                "matches": ["requirements.ready"],
                "text": [":::{req} ready", "The project MUST be ready.", ":::"]
            })]
        );
        assert!(AssessmentSources::prepare(root.path(), "missing").is_err());
    }
Input 5: outline src/authoring/inputs.rs mod[tests]/fn[mandatory_git_inputs_require_staging_declarations_sources_and_terms]
    // {test}`requirements.authoring.source_tools`
    // {test}`requirements.authoring.mandatory_inputs`
    // {test}`requirements.definitions.authoring_inputs`
    // {test}`requirements.authoring_input`
    // {test}`requirements.references.authoring_inputs`
    // {test}`requirements.authoring.read_denial`
    // {test}`requirements.references.discovery`
    #[test]
    fn mandatory_git_inputs_require_staging_declarations_sources_and_terms() {
        let root = project();
        git(root.path(), &["init", "--quiet"]);
        git(root.path(), &["add", "Cargo.toml", "book.toml"]);
        let error = AssessmentSources::prepare(root.path(), "requirements.ready")
            .err()
            .unwrap();
        assert!(
            error.to_string().contains("md/requirements.md")
                && error.to_string().contains("git add"),
            "{error}"
        );
        git(root.path(), &["add", "md"]);
        fs::write(
            root.path().join("src/lib.rs"),
            format!(
                "// {}\nfn ready() {{}}\n",
                role("test", "requirements.ready")
            ),
        )
        .unwrap();
        // Discovery does not consider an untracked source, so its reference is
        // not yet an input; staging it makes the source mandatory.
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        let supplied = serde_json::to_string(sources.mandatory_inputs()).unwrap();
        assert!(!supplied.contains("src/lib.rs"), "{supplied}");
        git(root.path(), &["add", "src"]);
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        let supplied = serde_json::to_string(sources.mandatory_inputs()).unwrap();
        assert!(supplied.contains("src/lib.rs"), "{supplied}");
        fs::write(
            root.path().join("md/terms.md"),
            ":::{definition} ready\n:phrase: ready\nReady to proceed.\n:::\n",
        )
        .unwrap();
        fs::write(
            root.path().join("src/lib.rs"),
            format!(
                "// {} {}\nfn ready() {{}}\n",
                role("test", "requirements.ready"),
                role("term", "terms.ready")
            ),
        )
        .unwrap();
        let error = AssessmentSources::prepare(root.path(), "requirements.ready")
            .err()
            .unwrap();
        assert!(
            error.to_string().contains("md/terms.md") && error.to_string().contains("git add"),
            "{error}"
        );
        git(root.path(), &["add", "md/terms.md"]);
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        assert!(
            sources
                .mandatory_inputs()
                .iter()
                .any(|input| input["definition"] == "terms.ready")
        );
    }
Input 6: outline src/authoring/inputs.rs mod[tests]/fn[anchored_files_contribute_root_node_inputs]
    // {test}`requirements.references.anchors`
    // {test}`requirements.references.authoring_inputs`
    // {test}`requirements.authoring.mandatory_inputs`
    // {test}`requirements.authoring_input`
    // {test}`requirements.authoring.no_line_numbers`
    #[test]
    fn anchored_files_contribute_root_node_inputs() {
        let root = project();
        fs::create_dir_all(root.path().join("skills")).unwrap();
        fs::write(root.path().join("skills/ready.md"), "# Skill\nBe ready.\n").unwrap();
        fs::write(
            root.path().join("md/requirements.md"),
            ":::{req} ready\n:impl: skills/ready.md\n:test: skills/ready.md\nThe project MUST be ready.\n\nKeep the whole body.\n:impl: this is body text\n:::\n",
        )
        .unwrap();
        let sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        let inputs = sources.mandatory_inputs();
        let hash =
            crate::inputs::outline_input(root.path(), "skills/ready.md", "").unwrap()["hash"]
                .clone();
        assert_eq!(
            inputs,
            &[
                json!({
                    "requirements": "requirements.ready",
                    "matches": ["requirements.ready"],
                    "text": [":::{req} ready", "The project MUST be ready.", "", "Keep the whole body.", ":impl: this is body text", ":::"]
                }),
                json!({
                    "file": "skills/ready.md",
                    "item": "",
                    "hash": hash,
                    "kind": "file",
                    "text": ["# Skill", "Be ready."]
                }),
            ]
        );
        assert_eq!(
            sources.subject_text,
            "The project MUST be ready.\n\nKeep the whole body.\n:impl: this is body text"
        );
    }

Referenced definitions

Input 2: requirements selection requirements.authoring.mandatory_inputs
:::{req} mandatory_inputs
The harness MUST construct each assessment's mandatory input set by combining
the contributions specified by the requirements applicable to that subject and
its inputs. A requirement that contributes inputs MUST cite this requirement and
define which sources it contributes and when. The harness MUST include every
applicable contribution, deduplicate identical selections, and report
unresolvable mandatory inputs before inference. The complete set MUST be supplied
in the initial model request.
Generated output under project-root `evidence/`, including symlink aliases, MUST
be omitted from mandatory inputs when the default exclusion applies. An explicit
workspace allow MUST permit those selections; an explicit disallow MUST abort
under {cite}`requirements.authoring.read_denial.mandatory`.
:::

Other sources

Input 1: requirements selection requirements.authoring_input
:::{req} authoring_input
When authoring evidence for a requirement, its fenced declaration, including its complete body but excluding anchor option lines, MUST
be included in the mandatory input set defined by
{cite}`requirements.authoring.mandatory_inputs`.
:::