From 872fecf478c185f94fbbdd977dab6c2973994753 Mon Sep 17 00:00:00 2001 From: Shay Date: Sat, 6 Jun 2026 06:33:13 -0700 Subject: [PATCH] =?UTF-8?q?test(determine):=20lookback=20coverage=20?= =?UTF-8?q?=E2=80=94=20multi-query,=20malformed-query,=20non-comprehension?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From the mandated lookback audit: three D0 refusal branches were asserted-but-unproven. Now they bite: - not_single_query: reachable from REAL input — a two-question prompt yields two queries. - malformed_query: a unary `member` query (hand-built; the reader only emits arity-2). - not_a_comprehension: a non-Comprehension/Refusal input. No code change — determine.py already refused all three; this closes the schema-proof-obligation gap (each would now fail if its guard were removed). --- tests/test_determine_d0.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test_determine_d0.py b/tests/test_determine_d0.py index d44ebd96..152ddb60 100644 --- a/tests/test_determine_d0.py +++ b/tests/test_determine_d0.py @@ -145,3 +145,34 @@ def test_unsupported_query_predicate_is_refused(vocab_persona) -> None: ) res = determine(subset_q, ctx) assert isinstance(res, Undetermined) and res.reason == "unsupported_query" + + +def test_multi_query_is_refused(vocab_persona) -> None: + # A two-question input yields TWO queries (reachable from real input); D0 answers + # one question at a time. + ctx = _ctx(vocab_persona) + _tell("Truth is a concept.", ctx) + res = _ask("Is truth a concept? Is knowledge a thought?", ctx) + assert isinstance(res, Undetermined) and res.reason == "not_single_query" + + +def test_malformed_member_query_is_refused(vocab_persona) -> None: + # `member` is binary; a unary member query is malformed. Hand-built, since the + # reader always emits arity-2 member queries — the guard would otherwise be + # asserted-but-unproven. + from generate.meaning_graph.model import MeaningGraph, MeaningSpan + from generate.meaning_graph.reader import Comprehension, Query + + ctx = _ctx(vocab_persona) + span = MeaningSpan(source_id="input", start=0, end=5, text="dummy") + unary = Comprehension( + meaning_graph=MeaningGraph(), queries=(Query("member", ("truth",), span),) + ) + res = determine(unary, ctx) + assert isinstance(res, Undetermined) and res.reason == "malformed_query" + + +def test_non_comprehension_input_is_refused(vocab_persona) -> None: + ctx = _ctx(vocab_persona) + res = determine(object(), ctx) # neither Comprehension nor Refusal + assert isinstance(res, Undetermined) and res.reason == "not_a_comprehension"