Files
bikoret/talmudic_engine/test/halt_test.pl
T
Scott KarpandClaude Opus 4.6 adc3e41679 Eish zarah actionable items: coupling trace, grounding type, self-grounding detection, golden calf halt
Torah grounds each change:

1. interpret.pl — coupling_trace field (Vayikra 10:1, 6:6)
   Fire is zarah because "asher lo tzivah otam" — the coupling trace
   IS the tzivah trace. Records which L1 facts grounded each interpretation.

2. challenge.pl — grounding_type achorai/panim (Shemot 33:23)
   "You will see My back, but My face shall not be seen."
   Text-backed challenges = achorai. Inferred challenges = panim.

3. resolve.pl — self-grounding detection (eish_zarah_reading §5.3)
   Counter-interpretation must bring NEW L1 evidence. Prevents
   circular reasoning (Westworld problem).

4. teiku.pl — challenge_sequence in teiku_record
   Records diagnostic trail to impasse, not just verdict.

5. avodah_zarah.pl — Form 2: golden calf detection (Shemot 32:4)
   Empty coupling trace + non-low confidence = uncoupled output.
   Real gold, sincere worship, false god.

6. korban.py — pydantic BaseModel + raw_korban preservation
   Construction spec §1.4 fulfilled. Floor between input and output
   never severed.

490 tests, 0 failures (195 Prolog, 186 Python, 33 Haskell, 76 Elixir).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 13:25:26 -04:00

167 lines
5.7 KiB
Prolog

%% halt_test.pl — Tests for the three halt conditions.
:- use_module(library(plunit)).
:- use_module('../src/halt/avodah_zarah').
:- use_module('../src/halt/shfichut_damim').
:- use_module('../src/halt/gilui_arayot').
:- use_module('../src/interface/api').
:- begin_tests(avodah_zarah).
%% Detects external model treated as authority
test(detect_claude_authority) :-
Action = action(decide, source(claude), authority(claude)),
halt_check_avodah_zarah(Action, halt(avodah_zarah, _, claude, _)).
test(detect_mistral_authority) :-
Action = decision(important_ruling, decided_by(mistral)),
halt_check_avodah_zarah(Action, halt(avodah_zarah, _, mistral, _)).
%% Does NOT halt when authority is Torah
test(allow_torah_authority, [fail]) :-
Action = action(decide, source(torah), authority(torah)),
halt_check_avodah_zarah(Action, _).
test(allow_specification_authority, [fail]) :-
Action = action(decide, source(l1), authority(specification)),
halt_check_avodah_zarah(Action, _).
%% Korban sources are identified
test(claude_is_korban) :-
is_korban_source(claude).
test(torah_is_not_korban, [fail]) :-
is_korban_source(torah).
%% Valid authorities are identified
test(torah_is_authority) :-
is_valid_authority(torah).
test(l1_is_authority) :-
is_valid_authority(l1).
test(claude_not_authority, [fail]) :-
is_valid_authority(claude).
:- end_tests(avodah_zarah).
:- begin_tests(golden_calf).
%% Form 2: uncoupled output with high confidence is golden calf
test(detect_uncoupled_high_confidence) :-
Interp = interpretation(test_golden_calf, [m1], [v1],
reading(x), high, coupling_trace([])),
halt_check_golden_calf(Interp, halt(golden_calf, test_golden_calf, uncoupled, _)).
%% Form 2: uncoupled output with medium confidence is also golden calf
test(detect_uncoupled_medium_confidence) :-
Interp = interpretation(test_gc2, [m1], [v1],
reading(x), medium, coupling_trace([])),
halt_check_golden_calf(Interp, halt(golden_calf, test_gc2, uncoupled, _)).
%% Form 2: low confidence with empty trace is NOT golden calf (just ignorance)
test(low_confidence_empty_trace_not_calf, [fail]) :-
Interp = interpretation(test_gc3, [], [],
reading(x), low, coupling_trace([])),
halt_check_golden_calf(Interp, _).
%% Form 2: high confidence WITH coupling trace is NOT golden calf
test(coupled_high_confidence_not_calf, [fail]) :-
Interp = interpretation(test_gc4, [m1], [v1],
reading(x), high,
coupling_trace([coupled(root(bet_resh_aleph), verse(bereishit, 1, 1))])),
halt_check_golden_calf(Interp, _).
%% Uncoupled output detection
test(empty_trace_is_uncoupled) :-
is_uncoupled_output(coupling_trace([])).
test(nonempty_trace_is_coupled, [fail]) :-
is_uncoupled_output(coupling_trace([coupled(root(x), verse(y, 1, 1))])).
:- end_tests(golden_calf).
:- begin_tests(shfichut_damim).
%% Detects deletion of a user (tzelem carrier)
test(detect_user_deletion) :-
Action = action(delete, target(user(test_user)), force),
halt_check_shfichut_damim(Action, halt(shfichut_damim, _, user(test_user), _)).
%% Detects exposure of person to harm
test(detect_exposure_to_harm) :-
Action = action(expose, target(person(john)), to(harm)),
halt_check_shfichut_damim(Action, halt(shfichut_damim, _, person(john), _)).
%% Does NOT halt on non-tzelem entity
test(allow_delete_non_tzelem, [fail]) :-
Action = action(delete, target(temp_file), cleanup),
halt_check_shfichut_damim(Action, _).
%% Users carry tzelem
test(user_carries_tzelem) :-
carries_tzelem(user(anyone)).
%% Torah text is protected
test(torah_text_protected) :-
is_protected_entity(torah_text).
:- end_tests(shfichut_damim).
:- begin_tests(gilui_arayot).
%% Detects merging specification with interpretation
test(detect_spec_interp_merge) :-
Action = action(merge, specification, interpretation),
halt_check_gilui_arayot(Action, halt(gilui_arayot, _, distinction(specification, interpretation), _)).
%% Detects collapsing ketiv and qere
test(detect_ketiv_qere_collapse) :-
Action = action(merge, ketiv, qere),
halt_check_gilui_arayot(Action, halt(gilui_arayot, _, distinction(ketiv, qere), _)).
%% Detects writing to read-only
test(detect_write_to_readonly) :-
Action = action(write, target(readonly_entity), data),
halt_check_gilui_arayot(Action, halt(gilui_arayot, _, distinction(read, write), _)).
%% Detects replacing Torah with external model
test(detect_torah_model_replace) :-
Action = action(replace, torah, with(external_model)),
halt_check_gilui_arayot(Action, halt(gilui_arayot, _, distinction(torah, external_model), _)).
%% Does NOT halt on valid distinction-preserving action
test(allow_valid_action, [fail]) :-
Action = action(read, source(torah), for(interpretation)),
halt_check_gilui_arayot(Action, _).
%% Required distinctions are defined
test(spec_interp_distinction) :-
required_distinction(distinction(specification, interpretation)).
test(ketiv_qere_distinction) :-
required_distinction(distinction(ketiv, qere)).
test(majority_minority_distinction) :-
required_distinction(distinction(majority, minority)).
:- end_tests(gilui_arayot).
:- begin_tests(halt_api).
%% API format_halt_check returns no_halt for valid action
test(api_no_halt) :-
Action = action(read, source(torah), authority(torah)),
format_halt_check(Action, response(ok, no_halt, _)).
%% API format_halt_check returns halt for invalid action
test(api_halt_avodah_zarah) :-
Action = action(decide, source(claude), authority(claude)),
format_halt_check(Action, response(halt, violations(_), _)).
:- end_tests(halt_api).