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

Requirements index · View definition

evidence Valid

Requirement

The harness MUST record the outcome the verification establishes: when real is false, the more favorable assessment, except that for a site review whose verifier’s applies differs from that assessment’s, a true determination with the verifier’s rationale; when real and acknowledged are true, a FIXME determination listing the verifier’s acknowledgments, which MUST then be nonempty; and otherwise false with the less favorable assessment’s rationale. For a site review, the recorded applies MUST be the verifier’s.

Rationale

The reviewed tests cover every branch of requirements.authoring.verifier_outcome. I did not read the implementation. Judging from the requirement text and the test code, I found no gap.

Non-site reviews: src/authoring/mod.rs#mod[tests]/fn[disagreeing_assessments_verify_the_less_favorable_one] runs eight scenarios. Each asserts the recorded Judgment, record["determination"], and that the recorded rationale starts with the rationale of the expected kept assessment. Each also asserts that the verifier’s rationale appears in the record.

  • real true, acknowledged false: three scenarios (false vs true, FIXME vs false, FIXME vs true) record false with the less favorable assessment’s rationale. The kept index is the less favorable one. The scenarios show that false ranks below FIXME and that FIXME ranks below true.
  • real true, acknowledged true: two scenarios record Judgment::Fixme with the verifier’s own acknowledgments (example/queue#9, #7). The first uses assessments that carry no FIXME, so the acknowledgments cannot have come from them.
  • real false: three scenarios record the more favorable assessment. They pair true with FIXME, FIXME with false, and true with FIXME again. The kept rationale is the more favorable one each time.

Nonempty acknowledgments: verifications_accept_exactly_their_four_fields rejects acknowledged: true with an empty acknowledgments list. It also rejects blank entries and wrong types, and it checks the submit_verification schema.

Site reviews: site_assessments_differing_only_in_applies_are_verified covers the applies rules.

  • Exception, verifier’s applies differs from the more favorable assessment’s: two cases (real false) record Judgment::True with the verifier’s rationale (“It is a checker after all.” and “Only a helper.”). The record’s applies is the verifier’s value, true in the first case and false in the second. In both, the kept assessment’s applies is the opposite.
  • No exception, applies agrees: the verifier agrees with the more favorable assessment’s applies (false). The record has applies false and the more favorable rationale.
  • real true: a real gap records False with the less favorable rationale and applies true. A real, acknowledged gap records Fixme(["o/r#1"]).
  • Agreement: two assessments that agree on applies and determination are not verified.

site_verifications_require_applies_and_no_real_gap_when_it_is_false checks that the verifier’s applies is parsed and that applies: false is accepted only with real: false. It also checks the submit schema. site_submissions_require_applies_and_a_true_determination_when_it_is_false checks the same consistency rule for assessments.

Residual case: no test has real true with a verifier applies that differs from the less favorable assessment’s. The consistency rules make this practically unreachable. applies: false forces a true determination, and real true forces applies true.

Inputs

Tests

Input 2: outline src/authoring/mod.rs mod[tests]/fn[disagreeing_assessments_verify_the_less_favorable_one]
    // {test}`requirements.authoring.confirmation`
    // {test}`requirements.authoring.verifier_prompt`
    // {test}`requirements.authoring.verifier_outcome`
    // {test}`requirements.authoring.habeas_background`
    // {test}`requirements.authoring.judgment_rules`
    #[tokio::test]
    async fn disagreeing_assessments_verify_the_less_favorable_one() {
        for (turns, recorded, kept, conclusion, less) in [
            // A real, unacknowledged gap records false with the less favorable
            // (second) assessment's rationale.
            (
                vec![
                    judgment(json!(true), "Looks complete."),
                    judgment(json!(false), "The empty case is unhandled."),
                    verdict(true, &[], "The empty case panics."),
                ],
                Judgment::False,
                1,
                "found an unacknowledged real gap",
                1,
            ),
            // A false assessment ranks below an acknowledged gap.
            (
                vec![
                    judgment(json!({"FIXME": ["#7"]}), "Only the known gap."),
                    judgment(json!(false), "An additional unacknowledged gap."),
                    verdict(true, &[], "The additional gap is real."),
                ],
                Judgment::False,
                1,
                "found an unacknowledged real gap",
                1,
            ),
            // A FIXME whose gap is real but unacknowledged also becomes false.
            (
                vec![
                    judgment(json!({"FIXME": ["#7"]}), "Issue 7 is open."),
                    judgment(json!(true), "Complete."),
                    verdict(true, &[], "Issue 7 is closed."),
                ],
                Judgment::False,
                0,
                "found an unacknowledged real gap",
                0,
            ),
            // Real and acknowledged gaps record FIXME with the verifier's
            // acknowledgments.
            (
                vec![
                    judgment(json!(true), "Looks complete."),
                    judgment(json!(false), "The empty case is unhandled."),
                    verdict(true, &["example/queue#9"], "A fixme tracks it."),
                ],
                Judgment::Fixme(vec!["example/queue#9".into()]),
                1,
                "found its real gaps all acknowledged",
                1,
            ),
            // No real gap records the more favorable (second) assessment.
            (
                vec![
                    judgment(json!({"FIXME": ["#7"]}), "Issue 7 is open."),
                    judgment(json!(true), "Complete."),
                    verdict(false, &[], "Issue 7 does not affect this."),
                ],
                Judgment::True,
                1,
                "found none of its claimed gaps real",
                0,
            ),
            (
                vec![
                    judgment(json!({"FIXME": ["#7"]}), "Only the known gap."),
                    judgment(json!(false), "An additional unacknowledged gap."),
                    verdict(false, &[], "The additional gap is not real."),
                ],
                Judgment::Fixme(vec!["#7".into()]),
                0,
                "found none of its claimed gaps real",
                1,
            ),
            (
                vec![
                    judgment(json!(true), "Complete."),
                    judgment(json!({"FIXME":["#7"]}), "Issue 7 is open."),
                    verdict(true, &["#7"], "The known gap is real and acknowledged."),
                ],
                Judgment::Fixme(vec!["#7".into()]),
                1,
                "found its real gaps all acknowledged",
                1,
            ),
            (
                vec![
                    judgment(json!(true), "Complete."),
                    judgment(json!({"FIXME":["#7"]}), "Issue 7 is open."),
                    verdict(false, &[], "The known gap does not apply."),
                ],
                Judgment::True,
                0,
                "found none of its claimed gaps real",
                1,
            ),
        ] {
            let (result, provider, logs) = confirmed(turns.clone(), true).await;
            let (judgment, record) = result.unwrap();
            assert_eq!(judgment, recorded);
            assert_eq!(record["determination"], judgment.to_value());
            let rationale = record["rationale"].as_str().unwrap();
            assert!(
                rationale.starts_with(turns[kept].1["rationale"].as_str().unwrap()),
                "{rationale}"
            );
            assert!(
                rationale.contains("the assessments disagreed"),
                "{rationale}"
            );
            assert!(rationale.contains(conclusion), "{rationale}");
            assert!(
                rationale.contains(turns[2].1["rationale"].as_str().unwrap()),
                "{rationale}"
            );

            // Prompts are recorded as serialized requests, so expected text is
            // compared in its JSON-escaped form.
            // The verifier receives the less favorable determination, its
            // rationale, and the criteria it applied, with the source tools
            // and submit_verification only.
            let prompts = provider.prompts();
            assert_eq!(prompts.len(), 3);
            let determination = turns[less].1["determination"].to_string();
            let less_rationale = turns[less].1["rationale"].as_str().unwrap();
            let escaped = serde_json::to_string(&format!(
                "The reviewer judged requirement requirements.ready as {determination}."
            ))
            .unwrap();
            let (text, tools) = &prompts[2];
            assert!(text.contains(escaped.trim_matches('"')), "{text}");
            assert!(text.contains(less_rationale), "{text}");
            assert!(
                text.contains("Judge against: the subject's text."),
                "{text}"
            );
            assert!(text.contains("Derive testable obligations"), "{text}");
            assert!(text.contains("# Mandatory inputs"), "{text}");
            // The verifier of a requirement carries both background texts,
            // the judgment rules, and the subject's mandatory input.
            let text = serde_json::from_str::<Value>(text).unwrap().to_string();
            for background in [
                approved_text("habeas_background", 0),
                approved_text("habeas_background", 1),
                approved_text("judgment_rules", 0),
                "\"requirements\": \"requirements.ready\"",
                "The project MUST be ready.",
            ] {
                let background = serde_json::to_string(background).unwrap();
                assert!(text.contains(background.trim_matches('"')), "{text}");
            }
            assert!(!text.contains("{{"), "{text}");
            assert!(tools.contains(&"submit_verification".to_owned()));
            assert!(tools.contains(&"habeas".to_owned()));
            assert!(!tools.contains(&"submit_judgment".to_owned()));
            // The verifier has the assessments' source tools.
            let source_tools = |tools: &[String]| {
                tools
                    .iter()
                    .filter(|tool| !tool.starts_with("submit_"))
                    .cloned()
                    .collect::<Vec<_>>()
            };
            assert_eq!(source_tools(tools), source_tools(&prompts[0].1));

            assert_eq!(logs.len(), 3);
            assert_eq!(logs[2]["subject"], "requirements.ready (verification)");
            assert_eq!(logs[2]["outcome"], "completed");
        }
    }
Input 3: outline src/authoring/mod.rs mod[tests]/fn[verifications_accept_exactly_their_four_fields]
    // {test}`requirements.authoring.verifier_prompt`
    // {test}`requirements.authoring.verifier_outcome`
    #[test]
    fn verifications_accept_exactly_their_four_fields() {
        assert_eq!(
            verification(&json!({"real": true, "acknowledged": true,
                "acknowledgments": ["example/queue#1"], "rationale": "Checked."}))
            .unwrap(),
            Verification {
                real: true,
                acknowledged: true,
                acknowledgments: vec!["example/queue#1".into()],
                rationale: "Checked.".into(),
                applies: None,
            }
        );
        assert!(
            verification(&json!({"real": false, "acknowledged": false,
                "acknowledgments": [], "rationale": "None hold."}))
            .is_ok()
        );
        for arguments in [
            json!({"real": "true", "acknowledged": false, "acknowledgments": [], "rationale": "x"}),
            json!({"real": true, "acknowledged": 1, "acknowledgments": [], "rationale": "x"}),
            json!({"real": true, "acknowledged": false, "acknowledgments": "", "rationale": "x"}),
            json!({"real": true, "acknowledged": false, "acknowledgments": [" "], "rationale": "x"}),
            json!({"real": true, "acknowledged": true, "acknowledgments": [], "rationale": "x"}),
            json!({"real": true, "acknowledged": false, "acknowledgments": []}),
            json!({"real": true, "acknowledged": false, "acknowledgments": [], "rationale": " "}),
            json!({"real": true, "acknowledged": false, "acknowledgments": [], "rationale": "x", "extra": 1}),
            json!({"confirmed": true, "rationale": "x"}),
        ] {
            assert!(verification(&arguments).is_err(), "accepted {arguments}");
        }
        let definitions =
            serde_json::to_value(tool_definitions_with("submit_verification", false).unwrap())
                .unwrap();
        let submit = definitions
            .as_array()
            .unwrap()
            .iter()
            .find(|definition| definition["name"] == "submit_verification")
            .unwrap();
        assert_eq!(
            submit["parameters"]["required"],
            json!(["real", "acknowledged", "acknowledgments", "rationale"])
        );
        assert_eq!(
            submit["parameters"]["properties"],
            json!({"real": {"type": "boolean"}, "acknowledged": {"type": "boolean"},
                "acknowledgments": {"type": "array", "items": {"type": "string", "minLength": 1}},
                "rationale": {"type": "string", "minLength": 1}})
        );
    }
Input 4: outline src/authoring/mod.rs mod[tests]/fn[site_submissions_require_applies_and_a_true_determination_when_it_is_false]
  • File: src/authoring/mod.rs
  • Selector: mod[tests]/fn[site_submissions_require_applies_and_a_true_determination_when_it_is_false]
  • Kind: fn
  • src/authoring/mod.rs:4981–5001
    // {test}`requirements.authoring.site_prompt`
    // {test}`requirements.authoring.verifier_outcome`
    #[test]
    fn site_submissions_require_applies_and_a_true_determination_when_it_is_false() {
        assert_eq!(
            site_submission(
                &json!({"applies": false, "determination": true, "rationale": "Not a checker."})
            )
            .unwrap(),
            (Judgment::True, "Not a checker.".to_owned(), false)
        );
        for arguments in [
            json!({"determination": true, "rationale": "x"}),
            json!({"applies": "no", "determination": true, "rationale": "x"}),
            json!({"applies": false, "determination": false, "rationale": "x"}),
            json!({"applies": false, "determination": {"FIXME": ["a"]}, "rationale": "x"}),
            json!({"applies": true, "determination": true, "rationale": "x", "extra": 1}),
        ] {
            assert!(site_submission(&arguments).is_err(), "accepted {arguments}");
        }
    }
Input 5: outline src/authoring/mod.rs mod[tests]/fn[site_verifications_require_applies_and_no_real_gap_when_it_is_false]
  • File: src/authoring/mod.rs
  • Selector: mod[tests]/fn[site_verifications_require_applies_and_no_real_gap_when_it_is_false]
  • Kind: fn
  • src/authoring/mod.rs:5003–5051
    // {test}`requirements.authoring.verifier_prompt`
    // {test}`requirements.authoring.verifier_outcome`
    #[test]
    fn site_verifications_require_applies_and_no_real_gap_when_it_is_false() {
        let verified = site_verification(&json!({"real": false, "acknowledged": false,
            "acknowledgments": [], "rationale": "Not a site.", "applies": false}))
        .unwrap();
        assert_eq!(verified.applies, Some(false));
        for arguments in [
            json!({"real": false, "acknowledged": false, "acknowledgments": [], "rationale": "x"}),
            json!({"real": true, "acknowledged": false, "acknowledgments": [], "rationale": "x", "applies": false}),
            json!({"real": true, "acknowledged": false, "acknowledgments": [], "rationale": "x", "applies": 1}),
        ] {
            assert!(
                site_verification(&arguments).is_err(),
                "accepted {arguments}"
            );
        }
        let definitions =
            serde_json::to_value(tool_definitions_with("submit_verification", true).unwrap())
                .unwrap();
        let submit = definitions
            .as_array()
            .unwrap()
            .iter()
            .find(|definition| definition["name"] == "submit_verification")
            .unwrap();
        assert_eq!(
            submit["parameters"]["required"],
            json!([
                "real",
                "acknowledged",
                "acknowledgments",
                "rationale",
                "applies"
            ])
        );
        assert_eq!(submit["parameters"]["additionalProperties"], false);
        assert_eq!(
            submit["parameters"]["properties"],
            json!({
                "real":{"type":"boolean"},
                "acknowledged":{"type":"boolean"},
                "acknowledgments":{"type":"array","items":{"type":"string","minLength":1}},
                "rationale":{"type":"string","minLength":1},
                "applies":{"type":"boolean"}
            })
        );
    }
Input 6: outline src/authoring/mod.rs mod[tests]/fn[site_assessments_differing_only_in_applies_are_verified]
    // {test}`requirements.authoring.confirmation`
    // {test}`requirements.authoring.verifier_prompt`
    // {test}`requirements.authoring.verifier_outcome`
    // {test}`requirements.authoring.habeas_background`
    #[tokio::test]
    // {test}`requirements.authoring.judgment_rules`
    async fn site_assessments_differing_only_in_applies_are_verified() {
        let site = |applies: bool, determination: Value, rationale: &str| {
            (
                "submit_judgment",
                json!({"applies": applies, "determination": determination, "rationale": rationale}),
            )
        };
        let check = |applies: bool, real: bool, rationale: &str| {
            (
                "submit_verification",
                json!({"real": real, "acknowledged": false, "acknowledgments": [],
                    "rationale": rationale, "applies": applies}),
            )
        };
        // Agreement needs the same applies too.
        let (result, provider) = site_confirmed(vec![
            site(true, json!(true), "Reports problems."),
            site(true, json!(true), "Also fine."),
        ])
        .await;
        assert_eq!(result.unwrap().1["rationale"], "Reports problems.");
        assert_eq!(provider.requests.borrow().len(), 2);

        for (turns, recorded, applies, kept) in [
            // The verifier finds the requirement does not apply, unlike the
            // more favorable assessment it keeps: true on its rationale.
            (
                vec![
                    site(false, json!(true), "Not a checker."),
                    site(true, json!(true), "Reports problems."),
                    check(true, false, "It is a checker after all."),
                ],
                Judgment::True,
                true,
                "It is a checker after all.",
            ),
            // The verifier agrees with the more favorable assessment.
            (
                vec![
                    site(true, json!(true), "Reports problems."),
                    site(false, json!(true), "Not a checker."),
                    check(false, false, "Only a helper."),
                ],
                Judgment::True,
                false,
                "Not a checker.",
            ),
            // A real gap in the applying assessment records false.
            (
                vec![
                    site(false, json!(true), "Not a checker."),
                    site(true, json!(false), "It panics."),
                    check(true, true, "It panics in `src/lib.rs#fn[check_one]`."),
                ],
                Judgment::False,
                true,
                "It panics.",
            ),
            (
                vec![
                    site(false, json!(true), "Not a checker."),
                    site(true, json!(false), "It panics."),
                    (
                        "submit_verification",
                        json!({
                            "applies":true, "real":true, "acknowledged":true,
                            "acknowledgments":["o/r#1"], "rationale":"The site acknowledges its panic."
                        }),
                    ),
                ],
                Judgment::Fixme(vec!["o/r#1".into()]),
                true,
                "It panics.",
            ),
            (
                vec![
                    site(true, json!({"FIXME":["o/r#1"]}), "The known gap."),
                    site(true, json!(false), "Another gap."),
                    check(false, false, "Only a helper."),
                ],
                Judgment::True,
                false,
                "Only a helper.",
            ),
        ] {
            let (result, provider) = site_confirmed(turns.clone()).await;
            let (judgment, record) = result.unwrap();
            assert_eq!(judgment, recorded);
            assert_eq!(record["determination"], judgment.to_value());
            assert_eq!(record["applies"], applies, "{record}");
            let rationale = record["rationale"].as_str().unwrap();
            assert!(rationale.starts_with(kept), "{rationale}");
            assert!(
                rationale.contains("the assessments disagreed"),
                "{rationale}"
            );

            let prompts = provider.prompts();
            let (text, tools) = &prompts[2];
            let text = serde_json::from_str::<Value>(text).unwrap().to_string();
            let escaped = |value: &str| {
                serde_json::to_string(value)
                    .unwrap()
                    .trim_matches('"')
                    .to_owned()
            };
            assert!(
                text.contains(&escaped(
                    "The reviewer judged site review sites:requirements.rule/src/lib.rs#fn[check_one] as"
                )),
                "{text}"
            );
            assert!(
                text.contains(&escaped(approved_text("judgment_rules", 0))),
                "{text}"
            );
            assert!(text.contains(&escaped(SITE_STEP)), "{text}");
            assert!(
                text.contains(&escaped(approved_text("habeas_background", 0))),
                "{text}"
            );
            assert!(
                text.contains(&escaped(&format!(
                    "requirement states for each of its sites.\n\n{}\n\nThe mandatory inputs at the end contain the site",
                    distributed_background()
                ))),
                "{text}"
            );
            assert!(
                !text.contains(&escaped(approved_text("habeas_background", 1))),
                "{text}"
            );
            assert!(!text.contains("{{"), "{text}");
            assert!(tools.contains(&"submit_verification".to_owned()));
        }
    }

Other sources

Input 1: requirements selection requirements.authoring.verifier_outcome
:::{req} verifier_outcome
The harness MUST record the outcome the verification establishes: when `real` is
false, the more favorable assessment, except that for a site review whose
verifier's `applies` differs from that assessment's, a `true` determination with
the verifier's rationale; when `real` and `acknowledged` are true, a FIXME
determination listing the verifier's `acknowledgments`, which MUST then be
nonempty; and otherwise `false` with the less favorable assessment's rationale.
For a site review, the recorded `applies` MUST be the verifier's.
:::