Files
bikoret/vav_pipeline/lib/vav_pipeline/halt_conditions.ex
T
Scott KarpandClaude Sonnet 4.6 80ec364da6 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>
2026-02-26 14:02:34 -05:00

115 lines
3.3 KiB
Elixir

defmodule VavPipeline.HaltConditions do
@moduledoc """
The three cardinal sin monitors.
Architecture §8 (Halt Conditions):
The system MUST halt on detection of:
1. Avodah Zarah — treating non-Torah source as authoritative
2. Shfichut Damim — destroying a tzelem carrier (human data/identity)
3. Gilui Arayot — collapsing required distinctions
These mirror the Talmudic Engine halt modules but operate
at the pipeline level as a fast pre-check.
"""
@doc """
Check all three halt conditions against processing results.
Returns :clear if no halt condition is detected.
Returns {:halt, condition, reason} if a halt is required.
"""
@spec check_all([map()]) :: :clear | {:halt, atom(), String.t()}
def check_all(results) do
with :clear <- check_avodah_zarah(results),
:clear <- check_shfichut_damim(results),
:clear <- check_gilui_arayot(results) do
:clear
end
end
@doc """
Avodah Zarah — idolatry detection.
Halt if:
- A non-Torah source is treated as authoritative
- The pipeline's own output is fed back as specification
- An external model's output is treated as Torah
"""
@spec check_avodah_zarah([map()]) :: :clear | {:halt, :avodah_zarah, String.t()}
def check_avodah_zarah(results) do
invalid_authority =
Enum.find(results, fn result ->
source = Map.get(result, :authority_source, :torah)
source not in [:torah, :l1, :specification]
end)
case invalid_authority do
nil -> :clear
result -> {:halt, :avodah_zarah, "non-Torah authority: #{inspect(Map.get(result, :authority_source))}"}
end
end
@doc """
Shfichut Damim — destruction detection.
Halt if:
- Processing would delete/destroy user data
- Processing would erase human identity markers
- Processing would overwrite L1 (the specification store)
"""
@spec check_shfichut_damim([map()]) :: :clear | {:halt, :shfichut_damim, String.t()}
def check_shfichut_damim(results) do
destructive =
Enum.find(results, fn result ->
action = Map.get(result, :action, :read)
action in [:delete, :destroy, :overwrite, :erase]
end)
case destructive do
nil -> :clear
result -> {:halt, :shfichut_damim, "destructive action: #{inspect(Map.get(result, :action))}"}
end
end
@doc """
Gilui Arayot — boundary violation detection.
The 13 required distinctions that must never collapse:
1. specification / interpretation
2. L1 (read-only) / L3 (append-only)
3. Torah / external_model
4. ketiv / qere
5. governance / provision
6. majority / minority
7. reception / processing
8. read / write
9. immutable / mutable
10. sacred / profane
11. Shabbat / weekday
12. input / output
13. human / system
Halt if any distinction is collapsed.
"""
@spec check_gilui_arayot([map()]) :: :clear | {:halt, :gilui_arayot, String.t()}
def check_gilui_arayot(results) do
collapsed =
Enum.find(results, fn result ->
case Map.get(result, :boundary_violation) do
nil -> false
false -> false
_ -> true
end
end)
case collapsed do
nil ->
:clear
result ->
{:halt, :gilui_arayot,
"boundary collapsed: #{inspect(Map.get(result, :boundary_violation))}"}
end
end
end