Shemot 39:43 — Vayar Moshe et kol ham'lakhah v'hineh asu otah
ka'asher tzivah Hashem ken asu, vayevarekh otam Moshe.
Step 30 — Sanhedrin stress test:
- 10 rapid submissions without crash
- Case ref preservation across decisions
- Rich context handling at simple complexity
- Decision structure consistency (7 required fields)
- Graceful degradation when Sanhedrin unavailable
- 20 concurrent Task.async submissions
Step 31 — Shema Test suite (Architecture §6.3, five tests):
1. Te'amim reception: raw cantillation from L1, etnachta detection,
L1→ShemaContext fidelity, surprising etnachta position
2. Ketiv/qere preservation: field exists, survives full pipeline
3. Cloud obedience: :camped allows processing, Shabbat triggers
major_transition, context immutability under override
4. Manna fidelity: no provision → {:waiting, :no_provision},
provision present → processing proceeds, MannaLedger tracks
5. Context immutability: context unchanged after pipeline,
keys stable, each stage receives same context
Step 32 — Full system verification (kol ham'lakhah):
- Full pipeline: Shema → BereishitCycle → output, multi-verse
- Halt conditions: check_all processes output
- Protection layer: AreiMiklat refuge→release, EglahArufah
declaration, Bikurim first-output review
- Chatzotzrot: subscribe→signal→receive→zikaron, routing isolation
- MannaLedger: load→consume→boundary cycle
- L1 integrity: hash valid, 5 core verses readable, roots present
- Supervision tree: all 7 GenServers running
- Cross-component: ShabbatTimer reads cloud, Shema builds from
L1+Cloud+Manna
All 206 Elixir + 19 L3 + 195 Prolog + 33 Haskell = 434+ tests, 0 failures
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
202 lines
6.8 KiB
Elixir
202 lines
6.8 KiB
Elixir
defmodule VavPipeline.Step30.SanhedrinStressTest do
|
|
@moduledoc """
|
|
Step 30: Stress test Sanhedrin with complex cases.
|
|
|
|
Architecture §4, Step 30:
|
|
Submit multiple cases of varying complexity to the Sanhedrin.
|
|
The Sanhedrin engine (Erlang) may not be running in dev —
|
|
the SanhedrinClient gracefully degrades to teiku.
|
|
|
|
This test verifies:
|
|
1. The client handles multiple submissions without crashing
|
|
2. Case refs are unique across submissions
|
|
3. Complex cases with rich context are accepted
|
|
4. The system degrades gracefully when Sanhedrin is unavailable
|
|
5. Decision structure is consistent regardless of outcome
|
|
"""
|
|
|
|
use ExUnit.Case, async: false
|
|
|
|
alias VavPipeline.SanhedrinClient
|
|
|
|
# ============================================================
|
|
# Basic submission stress
|
|
# ============================================================
|
|
describe "multiple case submissions" do
|
|
test "submits 10 cases without crashing" do
|
|
results =
|
|
Enum.map(1..10, fn i ->
|
|
SanhedrinClient.submit_case(%{
|
|
case_ref: "stress_test_#{i}",
|
|
complexity: :simple,
|
|
question: "Test case #{i}: is this permissible?",
|
|
context: %{test: true, iteration: i},
|
|
requested_by: "stress_test"
|
|
})
|
|
end)
|
|
|
|
# All should return {:ok, _} — either a real decision or teiku stub
|
|
Enum.each(results, fn result ->
|
|
assert {:ok, decision} = result
|
|
assert Map.has_key?(decision, :case_ref)
|
|
assert Map.has_key?(decision, :outcome)
|
|
end)
|
|
end
|
|
|
|
test "case refs are preserved in decisions" do
|
|
refs = Enum.map(1..5, fn i -> "ref_check_#{i}" end)
|
|
|
|
results =
|
|
Enum.map(refs, fn ref ->
|
|
{:ok, decision} =
|
|
SanhedrinClient.submit_case(%{
|
|
case_ref: ref,
|
|
question: "Reference preservation test"
|
|
})
|
|
|
|
decision
|
|
end)
|
|
|
|
returned_refs = Enum.map(results, & &1.case_ref)
|
|
|
|
Enum.each(refs, fn ref ->
|
|
assert ref in returned_refs
|
|
end)
|
|
end
|
|
end
|
|
|
|
# ============================================================
|
|
# Complex case structures
|
|
# ============================================================
|
|
describe "complex case handling" do
|
|
test "submits case with rich context" do
|
|
{:ok, decision} =
|
|
SanhedrinClient.submit_case(%{
|
|
case_ref: "complex_context_case",
|
|
complexity: :simple,
|
|
question: "When Shabbat prohibition (Shemot 35:3) conflicts with pikuach nefesh (Vayikra 18:5), which takes precedence for non-life-threatening conditions?",
|
|
context: %{
|
|
torah_refs: ["Shemot 35:3", "Vayikra 18:5", "Devarim 4:9"],
|
|
roots_involved: ["שבת", "אש", "חיי", "נפש"],
|
|
domain: :halacha,
|
|
prior_rulings: ["Yoma 85b"],
|
|
complexity_factors: [
|
|
"competing_positive_negative",
|
|
"degree_of_danger_ambiguous",
|
|
"multiple_torah_sources"
|
|
]
|
|
},
|
|
requested_by: "stress_test"
|
|
})
|
|
|
|
assert decision.case_ref == "complex_context_case"
|
|
assert decision.outcome in [:accepted, :rejected, :teiku]
|
|
end
|
|
|
|
test "submits case with minimal fields" do
|
|
{:ok, decision} =
|
|
SanhedrinClient.submit_case(%{
|
|
question: "Minimal case — does the system handle defaults?"
|
|
})
|
|
|
|
assert Map.has_key?(decision, :outcome)
|
|
assert Map.has_key?(decision, :panel_size)
|
|
end
|
|
|
|
test "submits case with complex context but simple complexity" do
|
|
# NOTE: escalation.erl currently only handles :simple complexity.
|
|
# Complex cases are a Phase 4 Step 21 refinement (Mistral fine-tuning).
|
|
# For now, we verify that cases with rich context are handled at :simple.
|
|
result =
|
|
SanhedrinClient.submit_case(%{
|
|
case_ref: "rich_context_case",
|
|
complexity: :simple,
|
|
question: "Rich context case — handled at simple complexity",
|
|
context: %{
|
|
torah_refs: ["Shemot 35:3", "Vayikra 18:5"],
|
|
roots_involved: ["שבת", "חיי"],
|
|
domain: :halacha
|
|
}
|
|
})
|
|
|
|
assert {:ok, decision} = result
|
|
assert decision.case_ref == "rich_context_case"
|
|
end
|
|
end
|
|
|
|
# ============================================================
|
|
# Decision structure consistency
|
|
# ============================================================
|
|
describe "decision structure" do
|
|
test "every decision has required fields" do
|
|
cases = [
|
|
%{case_ref: "struct_1", complexity: :simple, question: "Simple?"},
|
|
%{case_ref: "struct_2", complexity: :simple, question: "Another simple?"},
|
|
%{case_ref: "struct_3", question: "Default complexity?"}
|
|
]
|
|
|
|
Enum.each(cases, fn params ->
|
|
{:ok, decision} = SanhedrinClient.submit_case(params)
|
|
|
|
assert Map.has_key?(decision, :case_ref)
|
|
assert Map.has_key?(decision, :outcome)
|
|
assert Map.has_key?(decision, :majority)
|
|
assert Map.has_key?(decision, :minority)
|
|
assert Map.has_key?(decision, :panel_size)
|
|
assert Map.has_key?(decision, :deliberation_time_ms)
|
|
assert Map.has_key?(decision, :unanimous_check)
|
|
end)
|
|
end
|
|
|
|
test "majority and minority have position and reasoning" do
|
|
{:ok, decision} =
|
|
SanhedrinClient.submit_case(%{
|
|
case_ref: "majority_minority_check",
|
|
question: "Check majority/minority structure"
|
|
})
|
|
|
|
assert Map.has_key?(decision.majority, :position)
|
|
assert Map.has_key?(decision.majority, :reasoning)
|
|
assert Map.has_key?(decision.minority, :position)
|
|
assert Map.has_key?(decision.minority, :reasoning)
|
|
end
|
|
end
|
|
|
|
# ============================================================
|
|
# Graceful degradation
|
|
# ============================================================
|
|
describe "graceful degradation" do
|
|
test "returns teiku when Sanhedrin engine is not running" do
|
|
# In dev/test, the Sanhedrin Erlang app may not be fully running.
|
|
# The client should return teiku, not crash.
|
|
{:ok, decision} =
|
|
SanhedrinClient.submit_case(%{
|
|
case_ref: "degradation_test",
|
|
question: "Does the system degrade gracefully?"
|
|
})
|
|
|
|
# Either a real decision or a teiku — both are valid
|
|
assert decision.outcome in [:accepted, :rejected, :teiku]
|
|
end
|
|
|
|
test "rapid-fire submissions do not crash" do
|
|
# Submit 20 cases as fast as possible
|
|
tasks =
|
|
Enum.map(1..20, fn i ->
|
|
Task.async(fn ->
|
|
SanhedrinClient.submit_case(%{
|
|
case_ref: "rapid_#{i}",
|
|
question: "Rapid fire test #{i}"
|
|
})
|
|
end)
|
|
end)
|
|
|
|
results = Task.await_many(tasks, 30_000)
|
|
|
|
Enum.each(results, fn result ->
|
|
assert {:ok, _} = result
|
|
end)
|
|
end
|
|
end
|
|
end
|