From 6b9625025521562b167a5028024d1ae5ba5adeae Mon Sep 17 00:00:00 2001 From: Scott Karp Date: Sun, 26 Apr 2026 11:44:50 -0400 Subject: [PATCH] =?UTF-8?q?talmudic=5Fengine:=20regression=20test=20?= =?UTF-8?q?=E2=80=94=20interpret/2=20output=20must=20pass=20self=5Fgroundi?= =?UTF-8?q?ng=20halt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Audit follow-up to commit b254ee9 (which added Form 4 self_grounding). Verified every coupling_trace construction site across the codebase (9 files) against is_l1_grounded_coupling/1: Production builders — SAFE: interpret.pl:128 — coupling_trace([]) empty triggers golden_calf (Form 2) only at non-low confidence, which is intentional interpret.pl:135 — coupling_trace(Couplings) where Couplings come from lines 76, 82, 104: coupled(domain(_), mitzvah(_)) OK coupled(root(_), mitzvah(_), via_verse(_,_,_)) OK coupled(root(_), verse(_,_,_)) OK all match is_l1_grounded_coupling/1. Different layer — SAFE: vav_pipeline/lib/.../l3/interpretation.ex — Ecto field is {:array, :string}. L3 stores SERIALIZED string traces, not Prolog terms. They are not parsed back into Prolog or re-checked by halt rules. (Separate concern from finding L: the round-trip loses schema, but this is L's concern, not D's.) Tests / pattern matching / docs — SAFE: read positions, deliberate ungrounded test cases, comments only. Conclusion: no production path trips the new self_grounding halt. To prevent FUTURE schema drift in interpret.pl from silently introducing ungrounded coupling shapes (which would then trip the halt on real pipeline output), added two regression tests in interpret_self_grounding_regression suite: 1. interpret_output_does_not_self_ground — runs interpret/2 on a real case and asserts halt_check_self_grounding does not fire. 2. every_interpret_coupling_is_l1_grounded — stronger: every coupling individually passes is_l1_grounded_coupling/1. If anyone adds a new coupling shape to interpret.pl that does not match the recognized L1 anchors (e.g. coupled(_, prior_decision(_)), coupled(_, system_view(_))), these tests fail BEFORE the schema drift becomes a production halt. The canary is in the same suite as the halt rule it protects. Test results: halt_test 47/47 (was 45, +2). Full Prolog suite 212/212 across all six test files. Closes the verification half of Pass 2 finding L (coupling_trace end-to-end population) for the Prolog layer. The Elixir L3 round-trip is a separate concern — traces stored as strings cannot be re-validated — and remains tracked under finding L. Co-Authored-By: Claude Opus 4.7 (1M context) --- talmudic_engine/test/halt_test.pl | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/talmudic_engine/test/halt_test.pl b/talmudic_engine/test/halt_test.pl index 421268fd..9ebfc504 100644 --- a/talmudic_engine/test/halt_test.pl +++ b/talmudic_engine/test/halt_test.pl @@ -174,6 +174,40 @@ test(consensus_coupling_not_grounded, [fail]) :- :- end_tests(self_grounding). +%% ============================================================ +%% INTEGRATION REGRESSION: interpret/2 output must always pass +%% halt_check_self_grounding. If any future change to interpret.pl +%% adds a new coupling shape that does not match +%% is_l1_grounded_coupling/1, this test fails — and the system halt +%% would fire on real pipeline output. Catch the schema drift here, +%% before it becomes a production halt. +%% ============================================================ + +:- begin_tests(interpret_self_grounding_regression). +:- use_module('../src/reasoning/interpret'). + +%% Every coupling produced by interpret/2 on a real case must be +%% one of the recognized L1-grounded shapes. We construct a case +%% with a known root (bet_resh_aleph appears in Bereishit 1:1) and +%% assert the interpretation's trace passes the halt check. +test(interpret_output_does_not_self_ground, [nondet]) :- + Case = case(test_regression_1, creation, [bet_resh_aleph], + 'Regression: every interpret/2 coupling must be L1-grounded'), + interpret(Case, Interp), + \+ halt_check_self_grounding(Interp, _). + +%% Stronger: every coupling in the trace individually passes +%% is_l1_grounded_coupling. If a new shape is introduced (e.g. +%% coupled(_, prior_decision(_))), this fails immediately. +test(every_interpret_coupling_is_l1_grounded, [nondet]) :- + Case = case(test_regression_2, justice, [bet_resh_aleph], + 'Schema check: every coupling matches the recognized shape'), + interpret(Case, interpretation(_, _, _, _, _, coupling_trace(Trace))), + forall(member(C, Trace), is_l1_grounded_coupling(C)). + +:- end_tests(interpret_self_grounding_regression). + + :- begin_tests(shfichut_damim). %% Detects deletion of a user (tzelem carrier)