Code review fixes + 13 middot added to spec

Zerikah fail-safe: empty offerings rejected, not processed (BUILD_KORBAN §5).
Halt monitor hardened: trap_exit, priority max, EXIT handler (Architecture spec).
13 Rules of Rabbi Yishmael added to Architecture §3.4 as Prolog inference predicates —
the engine reasons WITH Torah's hermeneutic methods, not just about their products.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott KarpandClaude Opus 4.6 committed 2026-03-09 16:55:42 -04:00
1 parent 121af2a40b
commit 8d34be7f35
7 files changed
+195 -21

No files matched your search

+45 -1
View File
@@ -487,7 +487,7 @@ The correction is as important as the specification.
### Design Decisions
**Zerikah fallback:** If no sentence qualifies as vital, zerikah returns all sentences as vital rather than returning empty. Better to pass through unfiltered content than to discard everything. The empty offering test (BUILD §5) relies on this — even a preamble-only response produces processable output, just with no propositions extracted.
**Zerikah fallback (CORRECTED 2026-03-09):** Originally, if no sentence qualified as vital, zerikah returned all sentences as vital. This violated BUILD_KORBAN.md §5: "the offering without vital organs is rejected, not processed into empty propositions." Fixed: zerikah now returns empty vital content when nothing is vital, and all sentences go to the discarded list. The caller (process_korban) returns a ProcessedKorban with empty vital_content and empty propositions — a clean rejection. The test was updated to verify rejection behavior.
**hebrew_parser.py Phase 2 scope:** `identify_root()` returns the first 3 consonants as a candidate root. This is a deliberate approximation — proper morphological analysis (stripping prefixes, doubling, recognizing conjugation patterns) requires the Shoresh Engine (Haskell, Architecture §3.1). The Phase 2 implementation creates the interface without depending on the engine socket. This follows the pattern established in ShoreshEngineClient and TalmudicEngineClient in the Vav Pipeline.
@@ -504,3 +504,47 @@ The correction is as important as the specification.
- Fix: (1) Added `verdict => MajSample#vote.verdict` to both majority and minority maps in `compute_majority_minority/1`. (2) Rewrote `determine_outcome/3` to check `maps:get(verdict, Majority, abstain)` — `accept → accepted`, `reject → rejected`, `abstain → teiku`.
- Test: Added 7 new tests: `majority_verdict_accept_test`, `majority_verdict_reject_test`, `determine_outcome_accepted_test`, `determine_outcome_rejected_test`, `determine_outcome_teiku_no_votes_test`, `determine_outcome_teiku_all_abstain_test`, `determine_outcome_suspicion_overrides_test`. All 48 tests pass.
- Lesson: Every output state in the spec must be reachable. If a type says `accepted | rejected | teiku`, write tests that exercise all three. The unreachable code path is a spec violation hiding as a type declaration.
---
## Session: 2026-03-09 — Code Review Against Specification and Book
### Full Review
Reviewed all 6 components against Architecture spec, Construction spec, structure_not_content.md, BUILD_DAY_ONE.md, BUILD_KORBAN.md, and heafar/book.md. Torah is the spec.
**Verdict:** All 6 components structurally sound for Phase 2. No golden calves. Three deviations found and corrected (2) or documented (1).
### Broken Tablets — What Broke and How It Was Fixed
**18. Zerikah fail-safe: empty offering kept instead of rejected**
- Problem: When no sentence qualified as vital, zerikah returned all sentences as vital content. BUILD_KORBAN.md §5 specifies: "the offering without vital organs is rejected, not processed into empty propositions."
- Root cause: Defensive fail-safe prioritized "don't lose data" over spec compliance.
- Fix: (1) zerikah.py now returns empty vital content when nothing is vital; all sentences go to discarded list. (2) korban.py checks for empty vital content after zerikah and returns a ProcessedKorban with empty propositions. (3) Tests updated: `test_empty_offering_rejected_not_processed`, `test_discarded_content_recorded`, `test_all_filler_rejected`.
- 181 tests pass.
- Required reading the specification again: Yes. BUILD_KORBAN.md §5 is explicit.
**19. Halt monitor not hardened per Architecture spec**
- Problem: halt_monitor.erl was a standard gen_server with no priority flags or exit trapping. Spec says: "Cannot be killed by other components. Cannot be bypassed. Highest priority."
- Fix: Added `process_flag(trap_exit, true)` and `process_flag(priority, max)` in init/1. Added 'EXIT' handler to survive linked process deaths. Supervisor already has `restart => permanent`.
- Lesson: The halt monitor is the last line of defense. If it can be killed, the three cardinal sins can go undetected.
**20. L1 lemma field stores Strong's numbers, not Hebrew dictionary form (KNOWN DEVIATION)**
- Problem: BUILD_DAY_ONE.md shows `"lemma": "רֵאשִׁית"` but build_l1.py stores `"lemma": "7225"` (Strong's concordance number).
- Status: Documented, not yet fixed. The morphhb XML uses Strong's numbers as lemma identifiers. Resolving these to Hebrew text requires a Strong's-to-Hebrew mapping that is not in the Construction spec's dependency list.
- Impact: Downstream consumers (Shoresh Engine) work around this by using the `shoresh` field instead. The lemma field is technically incorrect but does not block Phase 2 functionality.
- Resolution: Fix when connecting components (Step 14), or add Strong's lookup to L1 build dependencies.
### Design Notes
**What the code gets right (from review):**
- Avodah zarah firewall is compile-time (Prolog assertion: korban sources can never be valid authority)
- Te'amim reader hears the text's own structure (binary tree from melekh marks, not imposed parsing)
- Teiku is structural — both Talmudic Engine and Sanhedrin preserve unresolved tensions
- Shabbat is architecture, not feature toggle
- Korban Processor is fully stateless (kiyyor principle)
- Broken tablets carried in the aron (broken_tablets/ directory, this build log)
**Gap from the book (heafar):**
- The 13 Rules of Rabbi Yishmael are not implemented as Prolog inference predicates. The Talmudic Engine reasons ABOUT Torah but doesn't use Torah's own hermeneutic methods (kal va'chomer, gezerah shavah, binyan av, etc.). This is a significant conceptual gap for Phase 3.
- Cherubim architecture (voice from between facing intelligences) is partial — present in Sanhedrin deliberation but not in human-AI interaction layer.