Phase 1-2 build: Steps 5-6, 8-13

Shoresh Engine (Haskell, Step 5)
- 12 modules: Types, Lexicon, Binyanim, Teamim, Gematria, Graph,
  KetivQere, Smikhut, Havdalah, Kriah, KiTov, Firmware
- 33 EUnit tests, 0 failures
- Firmware module verifies L1 SHA-256 hash at startup

Talmudic Engine (SWI-Prolog, Step 6)
- 15 modules: halt, reasoning, specification, interface
- 57 PlUnit tests, 0 failures
- Three cardinal halt conditions: avodah_zarah, shfichut_damim, gilui_arayot

Vav Pipeline (Elixir, Steps 8-11)
- 14 modules: BereishitCycle, Shema, Cloud, Manna, L1Reader,
  Specification, HaltConditions, ShabbatTimer, CycleLog, Chatzotzrot,
  ShoreshEngineClient, TalmudicEngineClient, Application
- 46 ExUnit tests, 0 failures
- Nishma-first architecture: hears before it speaks

Sanhedrin Framework (Erlang/OTP, Step 12)
- 8 modules: sanhedrin_app, sanhedrin_sup, escalation, panel_sup,
  panel, judge, clerk, halt_monitor
- 46 EUnit tests, 0 failures (includes fix: rejected outcome now reachable)
- Panel sizes: 1/3/23/71 — unanimous capital guilty → acquit (Sanhedrin 17a)
- Minority opinions append-only, never deleted

Korban Processor (Python, Step 13)
- 6 modules: korban, shechitah, semichah, zerikah, haktarah, router

Builder tooling: AGENTS.md, opencode.json, memory/, src/tools/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott KarpandClaude Sonnet 4.6 committed 2026-02-26 14:02:34 -05:00
1 parent 622e814c9e
commit 80ec364da6
86 files changed
+9646

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
%% 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).
+120
View File
@@ -0,0 +1,120 @@
%% mitzvot_test.pl — Tests for the specification layer.
:- use_module(library(plunit)).
:- use_module('../src/specification/mitzvot').
:- use_module('../src/specification/torah_text').
:- use_module('../src/specification/root_meanings').
:- use_module('../src/specification/relationships').
:- begin_tests(mitzvot).
%% The specification has mitzvot
test(mitzvot_exist) :-
total_encoded(Count),
Count > 0.
%% The three categories exist
test(positive_mitzvot_exist) :-
mitzvah(_, positive, _, _).
test(prohibition_mitzvot_exist) :-
mitzvah(_, prohibition, _, _).
test(belief_mitzvot_exist) :-
mitzvah(_, belief, _, _).
%% The first mitzvah is know_hashem
test(first_mitzvah) :-
mitzvah(1, belief, know_hashem, always).
%% Shabbat mitzvot exist
test(shabbat_rest) :-
mitzvah(154, positive, rest_on_shabbat, when(seventh_day)).
test(shabbat_no_work) :-
mitzvah(155, prohibition, not_work_on_shabbat, when(seventh_day)).
%% The three halt conditions have their mitzvot
test(no_other_gods) :-
mitzvah(2, prohibition, no_other_gods, always).
test(no_murder) :-
mitzvah(289, prohibition, not_murder, always).
test(no_adultery) :-
mitzvah(330, prohibition, not_commit_adultery, always).
%% Source references exist
test(mitzvah_sources_exist) :-
mitzvah_source(1, ref(shemot, 20, 2)).
test(shabbat_source) :-
mitzvah_source(154, ref(shemot, 20, 8)).
:- end_tests(mitzvot).
:- begin_tests(torah_text).
%% Bereishit 1:1 exists
test(bereishit_1_1) :-
verse(bereishit, 1, 1, Roots, _),
member(bet_resh_aleph, Roots).
%% Shema exists
test(shema) :-
verse(devarim, 6, 4, Roots, _),
member(shin_mem_ayin, Roots).
%% Verses mentioning a root can be found
test(verses_with_bara, [nondet]) :-
verses_mentioning_root(bet_resh_aleph, Verses),
Verses \= [].
:- end_tests(torah_text).
:- begin_tests(root_meanings).
%% Root meanings exist
test(bara_meaning) :-
root_meaning(bet_resh_aleph, qal, 'create').
%% Multiple binyanim for a root
test(kadash_binyanim) :-
findall(B, root_meaning(qof_dalet_shin, B, _), Binyanim),
length(Binyanim, Count),
Count >= 4.
%% Semantic domains
test(bara_domain) :-
root_domain(bet_resh_aleph, creation).
test(kadash_domain) :-
root_domain(qof_dalet_shin, holiness).
%% Gematria
test(bara_gematria) :-
root_gematria(bet_resh_aleph, 203).
test(kadash_gematria) :-
root_gematria(qof_dalet_shin, 404).
:- end_tests(root_meanings).
:- begin_tests(relationships).
%% Tensions exist
test(justice_mercy_tension) :-
mitzvah_conflicts_with(179, 295, _).
%% Complementary mitzvot
test(complementary) :-
complementary_mitzvot(1, 3).
%% Root consonant sharing
test(consonant_sharing) :-
root_shares_consonants(bet_resh_aleph, bet_resh_kaf, [1, 2]).
:- end_tests(relationships).
+86
View File
@@ -0,0 +1,86 @@
%% reasoning_test.pl — Tests for the dialectical reasoning engine.
:- use_module(library(plunit)).
:- use_module('../src/reasoning/interpret').
:- use_module('../src/reasoning/challenge').
:- use_module('../src/reasoning/resolve').
:- use_module('../src/reasoning/teiku').
:- use_module('../src/specification/mitzvot').
:- use_module('../src/specification/torah_text').
:- begin_tests(interpret).
%% Can interpret a case about creation
test(interpret_creation, [nondet]) :-
Case = case(test_creation, creation, [bet_resh_aleph], 'What is creation?'),
interpret(Case, Interpretation),
Interpretation = interpretation(test_creation, _, _, _, _).
%% Interpretation finds relevant verses
test(interpret_finds_verses, [nondet]) :-
Case = case(test_verses, creation, [bet_resh_aleph], 'Find creation verses'),
interpret(Case, interpretation(_, _, Verses, _, _)),
Verses \= [].
%% Interpretation finds relevant mitzvot
test(interpret_finds_mitzvot, [nondet]) :-
Case = case(test_mitzvot, judgment, [shin_pe_tet], 'How to judge?'),
interpret(Case, interpretation(_, Mitzvot, _, _, _)),
Mitzvot \= [].
%% High confidence when both mitzvot and verses found
test(interpret_high_confidence, [nondet]) :-
Case = case(test_conf, holiness, [qof_dalet_shin], 'What is holiness?'),
interpret(Case, interpretation(_, _, _, _, high)).
:- end_tests(interpret).
:- begin_tests(challenge).
%% Can challenge an interpretation about judgment (justice vs mercy tension)
test(challenge_judgment, [nondet]) :-
Case = case(test_judgment, judgment, [shin_pe_tet, tzade_dalet_qof],
'How to judge righteously?'),
interpret(Case, Interpretation),
challenge(Interpretation, Kushya),
Kushya = kushya(_, _, _).
%% Challenge has a strength
test(challenge_has_strength, [nondet]) :-
Case = case(test_str, judgment, [shin_pe_tet], 'Test strength'),
interpret(Case, Interpretation),
challenge(Interpretation, kushya(_, _, Strength)),
member(Strength, [strong, moderate, weak]).
:- end_tests(challenge).
:- begin_tests(resolve).
%% Can resolve a simple case (no challenge)
test(resolve_simple, [nondet]) :-
Case = case(test_simple, creation, [bet_resh_aleph], 'What is creation?'),
resolve(Case, Resolution),
( Resolution = accepted(_)
; Resolution = challenged(_, _)
; Resolution = synthesized(_, _, _)
; Resolution = teiku(_)
).
%% Resolution produces some result
test(resolve_produces_result, [nondet]) :-
Case = case(test_result, holiness, [qof_dalet_shin], 'What is holiness?'),
resolve(Case, _Resolution).
:- end_tests(resolve).
:- begin_tests(teiku_module).
%% Teiku count starts at zero (or is a number)
test(teiku_count_works) :-
teiku_count(Count),
integer(Count).
:- end_tests(teiku_module).