talmudic_engine: add Form 4 (self-grounding) and expose Form 2 (golden_calf) via the API

Two related gaps in the avodah_zarah halt rules.

Form 4: SELF-GROUNDING / FAKE TZIVAH (new)

Vayikra 10:1 — eish zarah asher lo tzivah otam. Form 2 (golden_calf)
catches the EMPTY coupling trace; nothing caught the *non-empty trace
whose anchors do not terminate in L1*. The system has cited something,
but what it cited is its own prior_decision, system_view, consensus,
or another interpretation — the trace LOOKS substantial from outside
and a casual reader sees coupling entries and relaxes. But the
entries do not anchor in any L1-derived primitive. One degree more
elaborate than the empty calf, but the same idolatry.

  halt_check_self_grounding(Interpretation, Halt) fires when the
  trace is non-empty AND at least one coupling fails the recognized
  L1-anchor schema. Recognized terminators (the only legitimate
  anchors):

    coupled(_, verse(Book, Ch, Vs))
    coupled(_, mitzvah(ID))
    coupled(_, mitzvah(ID), via_verse(Book, Ch, Vs))

  Any other shape — coupled(_, prior_decision(_)),
  coupled(_, system_view(_)), coupled(_, consensus(_)),
  coupled(_, interpretation(_)) — fails the check. Adding a new
  legitimate coupling shape requires adding a clause to
  is_l1_grounded_coupling/1 — that is the safety property.

  The empty case is intentionally left to Form 2 (golden_calf) — we
  do not want both halts firing on the same input.

12 new tests in self_grounding suite cover: all 3 valid anchor shapes,
the 3 most likely ungrounded shapes (prior_decision, system_view,
interpretation/1), mixed traces (halts on weakest link), the
empty-trace exclusion, and the schema predicate's own positive and
negative cases.

Form 2 exposure (golden_calf):

halt_check_golden_calf was implemented and tested in halt_test but
never wired into format_halt_check — meaning callers using the JSON
socket API could not actually invoke it. Added
format_interpretation_halt_check/2 to api.pl that walks both
interpretation-shaped checks (golden_calf + self_grounding), plus
process_request(request(halt_check_interpretation, _)) so the
socket protocol surface is consistent. 3 new API tests verify the
new entry point catches both halts.

Test results: halt_test 45/45 (was 30, +15). Full Prolog suite
210/210 across all six test files.

Closes Pass 2 finding D from ~/shorashim-conversation-review.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Scott KarpandClaude Opus 4.7 committed 2026-04-26 11:38:39 -04:00
1 parent 5e00f75640
commit b254ee95f3
3 files changed
+213 -3

No files matched your search

+28 -2
View File
@@ -10,7 +10,8 @@
process_request/2,
format_interpretation/2,
format_resolution/2,
format_halt_check/2
format_halt_check/2,
format_interpretation_halt_check/2
]).
:- use_module('../reasoning/interpret').
@@ -43,6 +44,9 @@ process_request(request(resolve, CaseRef, Domain, Roots, Question), Response) :-
process_request(request(halt_check, Action), Response) :-
format_halt_check(Action, Response).
process_request(request(halt_check_interpretation, Interpretation), Response) :-
format_interpretation_halt_check(Interpretation, Response).
%% ============================================================
%% RESPONSE FORMATTING
%% ============================================================
@@ -81,7 +85,8 @@ format_resolution(no_interpretation(Ref),
response(ok, no_interpretation,
result(ref(Ref)))).
%% Format halt check results
%% Format halt check results — for action-shaped checks
%% (avodah_zarah Form 1, shfichut_damim, gilui_arayot)
format_halt_check(Action, Response) :-
findall(Halt,
( halt_check_avodah_zarah(Action, Halt)
@@ -93,3 +98,24 @@ format_halt_check(Action, Response) :-
-> Response = response(ok, no_halt, action(Action))
; Response = response(halt, violations(Halts), action(Action))
).
%% Format halt check results — for interpretation-shaped checks
%% (avodah_zarah Form 2 = golden_calf, Form 4 = self_grounding).
%%
%% Form 1 fires on actions that name a non-Torah authority.
%% Forms 2 and 4 fire on the *output of reasoning* — an interpretation
%% with empty trace + confidence (golden_calf), or with a non-empty
%% trace whose anchors do not terminate in L1 (self_grounding).
%% Wire-protocol callers should run BOTH format_halt_check (for actions)
%% and format_interpretation_halt_check (for produced interpretations)
%% before treating either as safe.
format_interpretation_halt_check(Interpretation, Response) :-
findall(Halt,
( halt_check_golden_calf(Interpretation, Halt)
; halt_check_self_grounding(Interpretation, Halt)
),
Halts),
( Halts = []
-> Response = response(ok, no_halt, interpretation(Interpretation))
; Response = response(halt, violations(Halts), interpretation(Interpretation))
).