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.search_accounting.helper_freshness

Requirements index · View definition

evidence Valid

Example

A marked test calls assert_refusal. A search excerpt of that helper supplies the refusal and byte-preservation assertions used to justify the judgment. The model finishes the search with the helper’s tag without reading it with habeas. Saved evidence MUST include the helper’s outline input.

Replacing the helper with a no-op MUST make that evidence stale, even when the marked test source is unchanged. test requirements.authoring.finish_search.inputs test requirements.authoring.finish_search.snapshot

Rationale

The example describes a concrete case. A marked test calls assert_refusal. A search snippet supplies the helper, and the model finishes the search without using habeas. The expected outcomes are that saved evidence includes the helper’s outline input, and that replacing the helper with a no-op makes that evidence stale while the marked test source is unchanged.

The test src/authoring/mod.rs#mod[tests]/fn[a_helper_used_only_through_a_search_snippet_invalidates_saved_evidence_when_weakened] covers this scenario and carries {test} references to the example’s requirements.

Setup

  • It writes a src/lib.rs containing the assert_refusal helper, try_insert, a marked test refuses_without_change that calls the helper, and an unrelated fn.
  • A scripted provider runs ripgrep for assert_refusal with context 5. It then calls finish_search with tag “1” and submits the judgment. It never calls habeas.

Outcome 1: the evidence includes the helper’s outline input

  • inputs.iter().find(item == "fn[assert_refusal]").unwrap() fails if the helper input is missing. The tag “1” entry must therefore be the helper’s node.
  • assert!(inputs.contains(&marked_test)) checks that the marked test is also recorded.
  • assert!(!inputs.iter().any(item == "fn[unrelated]")) checks that no unrelated node is recorded.
  • helper.get("text").is_none() checks that the helper input was saved as an outline hash input.
  • validate_input on the unchanged source produces no errors.
  • The final log assertions show that habeas was never called and that finish_search was called once. This confirms the helper reached the evidence only through the search snippet.

Outcome 2: weakening the helper makes the evidence stale

  • The test replaces the helper with fn assert_refusal(_bytes: &mut Vec<u8>) {}.
  • It asserts that outline_input for the marked test is equal to the earlier marked_test, so the marked test is unchanged.
  • It re-runs validate_input on the saved helper input and asserts that an error mentioning “hash” is reported.

The test accepts neither a missing helper input nor a helper input that stays valid after the no-op replacement. I found no gap.

Inputs

Tests

Input 2: outline src/authoring/mod.rs mod[tests]/fn[a_helper_used_only_through_a_search_snippet_invalidates_saved_evidence_when_weakened]
  • File: src/authoring/mod.rs
  • Selector: mod[tests]/fn[a_helper_used_only_through_a_search_snippet_invalidates_saved_evidence_when_weakened]
  • Kind: fn
  • src/authoring/mod.rs:3153–3235
    // {test}`requirements.authoring.search_accounting.helper_freshness`
    // {test}`requirements.authoring.finish_search.snapshot`
    // {test}`requirements.authoring.finish_search.inputs`
    // {test}`requirements.authoring.delivered_inputs`
    #[tokio::test]
    async fn a_helper_used_only_through_a_search_snippet_invalidates_saved_evidence_when_weakened()
    {
        use SearchAction::{Call, Finish};
        let root = inputs::tests::project();
        let helper_source = "fn assert_refusal(bytes: &mut Vec<u8>) {\n    let before = bytes.clone();\n    assert!(!try_insert(bytes));\n    assert_eq!(*bytes, before);\n}";
        let source = format!(
            "{helper_source}\nfn try_insert(_bytes: &mut Vec<u8>) -> bool {{ false }}\n\
            // {{test}}`requirements.ready`\n#[test]\nfn refuses_without_change() {{\n\
                let mut bytes = vec![1, 2];\n    assert_refusal(&mut bytes);\n}}\nfn unrelated() {{}}\n"
        );
        fs::write(root.path().join("src/lib.rs"), &source).unwrap();
        let marked_test =
            crate::inputs::outline_input(root.path(), "src/lib.rs", "fn[refuses_without_change]")
                .unwrap();
        let mut sources = AssessmentSources::prepare(root.path(), "requirements.ready").unwrap();
        let state = tempfile::tempdir().unwrap();
        let mut usage = UsageLog::start(state.path(), root.path(), &sources.subject_name).unwrap();
        let provider = SearchProvider {
            submit: "submit_judgment",
            turns: vec![
                vec![Call(
                    "ripgrep",
                    json!({"pattern":"assert_refusal","path":"src/lib.rs","context":5}),
                )],
                vec![Finish(0, vec!["1"])],
                vec![Call(
                    "submit_judgment",
                    json!({"determination":true,
                    "rationale":"The assert_refusal snippet asserts refusal and byte preservation."}),
                )],
            ],
            requests: RefCell::default(),
        };
        let (_, evidence) = assess(&provider, &mut sources, &mut usage).await.unwrap();
        let inputs = evidence["inputs"].as_array().unwrap();
        let helper = inputs
            .iter()
            .find(|input| input["item"] == "fn[assert_refusal]")
            .unwrap();
        assert!(inputs.contains(&marked_test));
        assert!(!inputs.iter().any(|input| input["item"] == "fn[unrelated]"));
        assert!(helper.get("text").is_none());
        let mut errors = Vec::new();
        crate::evidence::validate_input(
            root.path(),
            &std::collections::BTreeMap::new(),
            &crate::inputs::OutlineCache::default(),
            helper,
            "helper",
            &mut errors,
        );
        assert!(errors.is_empty(), "{errors:?}");
        fs::write(
            root.path().join("src/lib.rs"),
            source.replace(helper_source, "fn assert_refusal(_bytes: &mut Vec<u8>) {}"),
        )
        .unwrap();
        assert_eq!(
            crate::inputs::outline_input(root.path(), "src/lib.rs", "fn[refuses_without_change]")
                .unwrap(),
            marked_test
        );
        crate::evidence::validate_input(
            root.path(),
            &std::collections::BTreeMap::new(),
            &crate::inputs::OutlineCache::default(),
            helper,
            "helper",
            &mut errors,
        );
        assert!(
            errors.iter().any(|error| error.contains("hash")),
            "{errors:?}"
        );
        let log: Value = serde_json::from_str(&fs::read_to_string(&usage.path).unwrap()).unwrap();
        assert!(log["tool_calls"].get("habeas").is_none());
        assert_eq!(log["tool_calls"]["finish_search"], 1);
    }

Other sources

Input 1: requirements selection requirements.authoring.search_accounting.helper_freshness
:::{example} search_accounting.helper_freshness
A marked test calls `assert_refusal`. A search excerpt of that helper supplies
the refusal and byte-preservation assertions used to justify the judgment.
The model finishes the search with the helper's tag without reading it with
`habeas`. Saved evidence MUST include the helper's outline input.

Replacing the helper with a no-op MUST make that evidence stale, even when
the marked test source is unchanged.
{test}`requirements.authoring.finish_search.inputs`
{test}`requirements.authoring.finish_search.snapshot`
:::