%% 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(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).