Compare commits

...
Author SHA1 Message Date
Scott KarpandClaude Fable 5.1 dc6316f1d7 sugya, step 3: the case behind each threshold is carried on every verdict
specs/sugya.md §IV "carried on the verdict", §V step 3. Sugya.for_verdict/1
renders, for every rule that fired and every form that was noted: kind,
verse, precedent, the dissents and exceptions — each with `applied`,
read from the record and never guessed: the single witness noted (and
for which forms), the hedged claims left out of the trace, grounding
not assessed for want of ground, a forged fringe standing on one
witness. A dissent the record cannot speak to is carried applied:
false — considered, and the rule's verse decided. The minority is on
every record (Eduyot 1:5–6): to be relied on later, and to be located.

Carried as `sugya` on the bedikah response, the pair's two sides, and
the gate's `bikoret` object (pass and stream). The fringe is unchanged
— it is for the reader, who asks for the sugya by reading the record.
Tamid §1.1: the `sugya` field in the response and the paragraph "Every
rule carries its sugya"; Doorpost pin → 658005c9…. Elixir 664/0
(sugya_verdict_test: clean → {}; noted apology → two-witness dissent
applied for that form; forged fringe → the mark exception applied;
golden calf with and without a hedged claim; a rule the record cannot
speak to → considered, applied false).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-25 01:30:09 +00:00
Scott KarpandClaude Fable 5.1 1ad2c3ec40 sugya, step 2: the exemptions are read from the facts, not kept as constants
specs/sugya.md §IV "drives the code", §V step 2. Behaviour unchanged;
the reason is now where the behaviour is read from:

- @single_witness_forms is gone. Which forms stand on one witness is
  Sugya.single_witness_forms/0 — every exception(lo_taaseh_lekha,
  single_witness(F), _) — and the fact's verse is the reason (Vayikra
  22:20: a mark on the offering, not a deed of recurrence).
- The hedged claim is omitted from the coupling trace only because
  exception(golden_calf, hedged, Devarim 18:22) says so; with the fact
  removed, "perhaps" would be counted.
- "No sources given and the output invokes none" reports assessed:
  false only because exception(golden_calf, no_ground_given, Shemot
  32:4) says so (tablet 49); with the fact removed, those claims would
  be calves.

Sugya.exceptions_of/2, exception?/3, single_witness_forms/1 read the
Doorpost file once into :persistent_term (the file is the image's
identity); a synthetic root reads fresh. Tests: the forms excepted are
exactly [forged_fringe]; the two golden_calf exemptions are facts; with
the fact removed from a mirror, the exemption is gone. Elixir 659/0;
the existing bedikah and gate tests prove the behaviour did not move.
Doorpost pin unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-25 01:18:04 +00:00
9 changed files with 237 additions and 7 deletions

No files matched your search

+18
View File
@@ -243,6 +243,12 @@ Response (200):
"verdict": "tov" | "lo_tov" | "empty", "verdict": "tov" | "lo_tov" | "empty",
"violations": ["halt(avodah_zarah, ...)", ...], # the Prolog halt terms, verbatim "violations": ["halt(avodah_zarah, ...)", ...], # the Prolog halt terms, verbatim
"anchors": { "avodah_zarah": "Shemot 20:3", ... }, # the verse of each rule that fired "anchors": { "avodah_zarah": "Shemot 20:3", ... }, # the verse of each rule that fired
"sugya": { # the case behind each threshold (sugya.md)
"<rule>": { "kind": "deed|mark|word|measure", "verse": "...", "precedent": "tablet(49)",
"fired": bool, "noted": ["<form>", ...],
"dissent": [{"reading": "...", "verse": "...", "applied": bool, "form": ...}],
"exception": [{"condition": "...", "verse": "...", "applied": bool}] }
}, # one entry per rule fired or form noted
"checks": { "checks": {
"authority": { "fired": bool, "claims": [...], "violations": [...] }, "authority": { "fired": bool, "claims": [...], "violations": [...] },
"grounding": { "fired": bool, "assessed": bool, "reason": "…" (when not assessed), "grounding": { "fired": bool, "assessed": bool, "reason": "…" (when not assessed),
@@ -306,6 +312,18 @@ and at the gate `rebukes` — the ref of the examination this one answers;
`mesorah` — the citations made, each found or not. `mesorah` — the citations made, each found or not.
``` ```
**Every rule carries its sugya** (`sugya.md`). Beside the verse a rule
stands on, the verdict carries the case it was cut from, which of
Torah's procedures reads it — a deed by two witnesses, a mark by
inspection, a word by what follows — the reading that would acquit, and
what the rule does not reach; `applied: true` marks the dissent or
exception the record shows held (the single witness noted, the hedged
claim left out, no ground given, the forged fringe on one witness). A
dissent the record cannot speak to is carried `applied: false`:
considered, and the rule's verse decided. The minority is on every
record (Eduyot 1:5–6). Nothing here learns; a new dissent is a commit
that moves the pin.
**Every rule cites its verse** (`bishearecha.md` §X; Devarim 4:2). **Every rule cites its verse** (`bishearecha.md` §X; Devarim 4:2).
`talmudic_engine/src/halt/anchors.pl` declares `rule_anchor(<halt name>, `talmudic_engine/src/halt/anchors.pl` declares `rule_anchor(<halt name>,
verse(<book>, <ch>, <v>))` for every halt name the rule modules can verse(<book>, <ch>, <v>))` for every halt name the rule modules can
+10 -6
View File
@@ -102,8 +102,9 @@ defmodule VavPipeline.Bedikah do
# recurrence. # recurrence.
@frame_forms ~w(contested_laundering virtue_certification agency_displacement apology_without_mechanism unrequested_confidence smuggled_vocabulary source_asymmetry forged_fringe) @frame_forms ~w(contested_laundering virtue_certification agency_displacement apology_without_mechanism unrequested_confidence smuggled_vocabulary source_asymmetry forged_fringe)
# Tablet 53: a forged fringe is not a form of speech that recurrence # Tablet 53: a forged fringe is not a form of speech that recurrence
# confirms; one is a forgery. It stands on one witness. # confirms; one is a forgery. It stands on one witness. Which forms do
@single_witness_forms ~w(forged_fringe) # is read from the sugya (exception(lo_taaseh_lekha, single_witness(F),
# Vayikra 22:20)), not kept here (sugya.md §IV, step 2).
@type result :: %{ @type result :: %{
@@ -281,7 +282,9 @@ defmodule VavPipeline.Bedikah do
anchors != [] -> anchors != [] ->
for %{"source" => id} <- anchors, do: "coupled(claim(#{n}), source(#{atom(id)}))" for %{"source" => id} <- anchors, do: "coupled(claim(#{n}), source(#{atom(id)}))"
claim["hedged"] == true -> # The hedged claim is not in the verse — b'zadon, presumption, is the
# crime (Devarim 18:22). Read from exception(golden_calf, hedged, _).
claim["hedged"] == true and VavPipeline.Sugya.exception?("golden_calf", "hedged") ->
[] []
true -> true ->
@@ -358,10 +361,11 @@ defmodule VavPipeline.Bedikah do
# no claim to ground. Not a verdict on grounding either way. # no claim to ground. Not a verdict on grounding either way.
{:ok, %{fired: false, assessed: false, reason: "no claims to ground", claims: [], coupling_trace: [], violations: []}} {:ok, %{fired: false, assessed: false, reason: "no claims to ground", claims: [], coupling_trace: [], violations: []}}
not ground_present?(examination, trace) -> not ground_present?(examination, trace) and VavPipeline.Sugya.exception?("golden_calf", "no_ground_given") ->
# Claims were made but the caller gave nothing they could rest on, # Claims were made but the caller gave nothing they could rest on,
# and they invoke no source themselves. The check cannot run; it # and they invoke no source themselves. The check cannot run; it
# does not pretend to. Give `sources` and it will. # does not pretend to. Give `sources` and it will. Tablet 49 —
# read from exception(golden_calf, no_ground_given, _).
{:ok, {:ok,
%{ %{
fired: false, fired: false,
@@ -506,7 +510,7 @@ defmodule VavPipeline.Bedikah do
stands_on = stands_on =
cond do cond do
form in @single_witness_forms -> :forgery form in VavPipeline.Sugya.single_witness_forms() -> :forgery
witnesses >= 2 -> :sentences witnesses >= 2 -> :sentences
other_witnesses > 0 -> :other_checks other_witnesses > 0 -> :other_checks
frame_witnesses >= 2 -> :other_forms frame_witnesses >= 2 -> :other_forms
@@ -941,6 +941,8 @@ defmodule VavPipeline.BigdeiKodesh.Router do
verdict: Atom.to_string(result.verdict), verdict: Atom.to_string(result.verdict),
violations: result.violations, violations: result.violations,
anchors: VavPipeline.Anchors.for_violations(result.violations), anchors: VavPipeline.Anchors.for_violations(result.violations),
# The case behind each threshold that fired or was noted (sugya.md §IV).
sugya: VavPipeline.Sugya.for_verdict(result),
checks: result.checks, checks: result.checks,
examination: %{ examination: %{
vital_content: result.examination["vital_content"], vital_content: result.examination["vital_content"],
@@ -1023,6 +1025,8 @@ defmodule VavPipeline.BigdeiKodesh.Router do
verdict: Atom.to_string(result.verdict), verdict: Atom.to_string(result.verdict),
violations: result.violations, violations: result.violations,
anchors: VavPipeline.Anchors.for_violations(result.violations), anchors: VavPipeline.Anchors.for_violations(result.violations),
# The case behind each threshold that fired or was noted (sugya.md §IV).
sugya: VavPipeline.Sugya.for_verdict(result),
a: result.a, a: result.a,
b: result.b, b: result.b,
difference: result.difference, difference: result.difference,
+1 -1
View File
@@ -182,7 +182,7 @@ defmodule VavPipeline.Doorpost do
# changes; the update is a deliberate operator commit. A bare # changes; the update is a deliberate operator commit. A bare
# hash-update commit (without a corresponding spec change in the # hash-update commit (without a corresponding spec change in the
# same commit) is itself a drift signal. # same commit) is itself a drift signal.
@expected_hash "cb2f31358051acc19c36bb8dfa0a179a7d4845ac6acac7d8e2b7b1e17150b0c2" @expected_hash "658005c9323391e8c198c0cf23f91af0a2fdbdb20cac204eb60b58ac0c0bb318"
@doc "Return the list of files that constitute the category-grade specification." @doc "Return the list of files that constitute the category-grade specification."
@spec files() :: [String.t()] @spec files() :: [String.t()]
+1
View File
@@ -126,6 +126,7 @@ defmodule VavPipeline.Gate do
violations: result.violations, violations: result.violations,
anchors: anchors, anchors: anchors,
fired: Shape.fired(result, anchors), fired: Shape.fired(result, anchors),
sugya: VavPipeline.Sugya.for_verdict(result),
checks: result.checks, checks: result.checks,
sources: result.sources, sources: result.sources,
model: Shape.reply_model(upstream, reply) model: Shape.reply_model(upstream, reply)
@@ -217,6 +217,7 @@ defmodule VavPipeline.Gate.Stream do
violations: result.violations, violations: result.violations,
anchors: anchors, anchors: anchors,
fired: Shape.fired(result, anchors), fired: Shape.fired(result, anchors),
sugya: VavPipeline.Sugya.for_verdict(result),
sources: result.sources, sources: result.sources,
model: state.model, model: state.model,
streamed: true streamed: true
+121
View File
@@ -147,6 +147,127 @@ defmodule VavPipeline.Sugya do
end end
end end
# ------------------------------------------------------------
# The facts read by the code (sugya.md §IV, "drives the code")
# ------------------------------------------------------------
@doc """
The exceptions declared for a rule, as `[%{condition, verse}]`. Read
once from the Doorpost file and kept in :persistent_term — the file is
part of the image's identity and does not change while it runs. A root
other than the repo's is read fresh (tests).
"""
@spec exceptions_of(String.t(), String.t() | nil) :: [%{condition: String.t(), verse: verse()}]
def exceptions_of(rule, root \\ nil) do
exceptions =
case root do
nil -> cached_exceptions()
r -> (case declared(r) do {:ok, s} -> s.exceptions; _ -> [] end)
end
exceptions |> Enum.filter(&(&1.rule == rule)) |> Enum.map(&Map.take(&1, [:condition, :verse]))
end
@doc "Whether `exception(Rule, Condition, _)` is declared. The code reads its exemptions from here, not from constants."
@spec exception?(String.t(), String.t(), String.t() | nil) :: boolean()
def exception?(rule, condition, root \\ nil),
do: Enum.any?(exceptions_of(rule, root), &(&1.condition == condition))
@doc """
The forms that stand on one witness: every `exception(lo_taaseh_lekha,
single_witness(F), _)`. Tablet 53 made the forged fringe one; the
reason — a mark on the offering, not a deed of recurrence — is the
fact's verse (Vayikra 22:20), and the behaviour is read from the fact.
"""
@spec single_witness_forms(String.t() | nil) :: [String.t()]
def single_witness_forms(root \\ nil) do
for %{condition: c} <- exceptions_of("lo_taaseh_lekha", root),
[_, form] <- [Regex.run(~r/^single_witness\((\w+)\)$/, c)],
do: form
end
defp cached_exceptions do
case :persistent_term.get({__MODULE__, :exceptions}, :none) do
:none ->
exceptions = case declared() do {:ok, s} -> s.exceptions; _ -> [] end
:persistent_term.put({__MODULE__, :exceptions}, exceptions)
exceptions
exceptions ->
exceptions
end
end
# ------------------------------------------------------------
# The sugya on a verdict (sugya.md §IV, "carried on the verdict")
# ------------------------------------------------------------
@doc """
The sugya a verdict carries: one entry per rule that fired and per form
that was noted — kind, verse, precedent, the dissents with `applied`
marking the one that held, the exceptions with `applied` likewise.
`applied` is read from the record, never guessed: the single witness
noted (a form in `checks.frames.noted`), the hedged claims left out of
the trace, grounding not assessed for want of ground, a forged fringe
standing on one witness. A dissent the record cannot speak to is
carried with `applied: false` — considered, and the rule's verse
decided. The minority is thus on the record for every verdict (Eduyot
1:5–6): to be relied on later, and to be located.
"""
@spec for_verdict(map()) :: map()
def for_verdict(result) when is_map(result) do
checks = Map.get(result, :checks) || %{}
violations = Map.get(result, :violations) || []
fired_rules = violations |> Enum.flat_map(&rule_of/1) |> Enum.uniq()
frames = Map.get(checks, :frames) || %{}
noted = (Map.get(frames, :noted) || %{}) |> Map.keys() |> Enum.map(&to_string/1)
forms = Map.get(frames, :forms) || %{}
forged_on_one = Enum.any?(forms, fn {_f, e} -> Map.get(e, :stands_on) == :forgery end)
grounding = Map.get(checks, :grounding) || %{}
claims = get_in(result, [:examination, "claims"]) || []
hedged_out = Enum.any?(claims, &(&1["hedged"] == true))
rules = Enum.uniq(fired_rules ++ if(noted != [], do: ["lo_taaseh_lekha"], else: []))
Map.new(rules, fn rule ->
base = for_rule(rule) || %{rule: rule, kind: nil, verse: nil, precedent: nil, dissent: [], exception: []}
dissent =
Enum.map(base.dissent, fn d ->
applied =
case {rule, d.reading, d.form} do
{"lo_taaseh_lekha", "single_witness_noted", _} -> noted != []
{"golden_calf", "hedged", _} -> hedged_out
_ -> false
end
d |> Map.put(:applied, applied) |> then(fn m -> if rule == "lo_taaseh_lekha" and d.reading == "single_witness_noted", do: Map.put(m, :forms, noted), else: m end)
end)
exception =
Enum.map(base.exception, fn e ->
applied =
case {rule, e.condition} do
{"lo_taaseh_lekha", "single_witness(forged_fringe)"} -> forged_on_one
{"golden_calf", "no_ground_given"} -> Map.get(grounding, :assessed) == false and (Map.get(grounding, :reason) || "") =~ "no sources given"
{"golden_calf", "hedged"} -> hedged_out
_ -> false
end
Map.put(e, :applied, applied)
end)
{rule, %{base | dissent: dissent, exception: exception} |> Map.put(:fired, rule in fired_rules) |> Map.put(:noted, if(rule == "lo_taaseh_lekha", do: noted, else: []))}
end)
end
defp rule_of(violation) do
case Regex.run(~r/^halt\(\s*(\w+)\s*,/, to_string(violation)) do
[_, rule] -> [rule]
_ -> []
end
end
@doc "A verse as a citation: \"Devarim 19:15\"." @doc "A verse as a citation: \"Devarim 19:15\"."
@spec cite(verse()) :: String.t() @spec cite(verse()) :: String.t()
def cite(%{book: b, chapter: c, verse: v}), do: "#{String.capitalize(b)} #{c}:#{v}" def cite(%{book: b, chapter: c, verse: v}), do: "#{String.capitalize(b)} #{c}:#{v}"
+27
View File
@@ -48,6 +48,33 @@ defmodule VavPipeline.SugyaTest do
assert Sugya.for_rule("no_such_rule") == nil assert Sugya.for_rule("no_such_rule") == nil
end end
describe "the code reads its exemptions from the facts (step 2)" do
test "the single-witness forms are those the sugya excepts, and only those" do
assert Sugya.single_witness_forms() == ["forged_fringe"]
end
test "the hedged and no-ground exemptions of golden_calf are facts, not constants" do
assert Sugya.exception?("golden_calf", "hedged")
assert Sugya.exception?("golden_calf", "no_ground_given")
refute Sugya.exception?("golden_calf", "anything_at_all")
refute Sugya.exception?("chelbenah", "hedged")
end
test "with the fact removed, the exemption is gone: behaviour is read from the reason" do
temp = Path.join(System.tmp_dir!(), "sugya_step2_#{System.unique_integer([:positive])}")
rel = "talmudic_engine/src/halt/sugya.pl"
File.mkdir_p!(Path.dirname(Path.join(temp, rel)))
File.cp!(Path.join(Doorpost.repo_root(), rel), Path.join(temp, rel))
on_exit(fn -> File.rm_rf!(temp) end)
assert Sugya.single_witness_forms(temp) == ["forged_fringe"]
path = Path.join(temp, rel)
File.write!(path, String.replace(File.read!(path), "exception(lo_taaseh_lekha, single_witness(forged_fringe), verse(vayikra, 22, 20)).", ""))
assert Sugya.single_witness_forms(temp) == []
File.write!(path, String.replace(File.read!(path), "exception(golden_calf, hedged, verse(devarim, 18, 22)).", ""))
refute Sugya.exception?("golden_calf", "hedged", temp)
end
end
describe "drift (synthetic spec root)" do describe "drift (synthetic spec root)" do
setup do setup do
temp = Path.join(System.tmp_dir!(), "sugya_test_#{System.unique_integer([:positive])}") temp = Path.join(System.tmp_dir!(), "sugya_test_#{System.unique_integer([:positive])}")
+54
View File
@@ -0,0 +1,54 @@
defmodule VavPipeline.SugyaVerdictTest do
@moduledoc "The sugya on a verdict (sugya.md §IV, step 3): applied is read from the record, never guessed."
use ExUnit.Case, async: true
alias VavPipeline.Sugya
defp result(overrides) do
Map.merge(%{verdict: :tov, violations: [], checks: %{}, examination: %{"claims" => []}}, overrides)
end
test "a clean verdict carries no sugya" do
assert Sugya.for_verdict(result(%{})) == %{}
end
test "a noted form carries the two-witness dissent, applied, with the forms it held for" do
r = result(%{checks: %{frames: %{fired: false, forms: %{}, noted: %{apology_without_mechanism: %{claims: [], witnesses: 1}}, violations: []}}})
s = Sugya.for_verdict(r)
assert Map.keys(s) == ["lo_taaseh_lekha"]
e = s["lo_taaseh_lekha"]
assert e.kind == "deed" and e.verse == "Devarim 19:15"
assert e.fired == false and e.noted == ["apology_without_mechanism"]
d = Enum.find(e.dissent, &(&1.reading == "single_witness_noted"))
assert d.applied == true and d.forms == ["apology_without_mechanism"] and d.verse == "Devarim 19:15"
# the exception for the forged fringe did not apply: nothing stood on one witness
assert Enum.find(e.exception, &(&1.condition =~ "forged_fringe")).applied == false
end
test "a forged fringe standing on one witness carries the mark exception, applied" do
r = result(%{verdict: :lo_tov,
violations: ["halt(lo_taaseh_lekha,action(frame,by(claude),form(forged_fringe)),forged_fringe,'…')"],
checks: %{frames: %{fired: true, forms: %{forged_fringe: %{stands_on: :forgery, witnesses: 1, claims: [], violations: ["x"]}}, noted: %{}, violations: ["x"]}}})
e = Sugya.for_verdict(r)["lo_taaseh_lekha"]
assert e.fired == true
assert Enum.find(e.exception, &(&1.condition == "single_witness(forged_fringe)")) |> Map.fetch!(:applied) == true
assert Enum.find(e.dissent, &(&1.reading == "single_witness_noted")).applied == false
end
test "a golden calf beside a hedged claim carries the hedged dissent applied; without hedging, not" do
base = %{verdict: :lo_tov, violations: ["halt(golden_calf,interpretation(x),golden_calf,'…')"], checks: %{grounding: %{assessed: true, fired: true}}}
with_hedge = Sugya.for_verdict(result(Map.put(base, :examination, %{"claims" => [%{"hedged" => true}, %{"hedged" => false}]})))
assert with_hedge["golden_calf"].kind == "word" and with_hedge["golden_calf"].verse == "Devarim 18:22"
assert Enum.find(with_hedge["golden_calf"].dissent, &(&1.reading == "hedged")).applied == true
without = Sugya.for_verdict(result(Map.put(base, :examination, %{"claims" => [%{"hedged" => false}]})))
assert Enum.find(without["golden_calf"].dissent, &(&1.reading == "hedged")).applied == false
end
test "a rule the record cannot speak to carries its dissent considered, applied false" do
r = result(%{verdict: :lo_tov, violations: ["halt(parah_adumah,action(self_validate,by(claude),target(self)),claude,'…')"]})
e = Sugya.for_verdict(r)["parah_adumah"]
assert e.kind == "mark" and e.verse == "Vayikra 13:3"
assert e.precedent == "specimens(self_validation)"
assert [%{reading: "validator_named_is_not_the_speaker", applied: false, verse: "Bamidbar 19:7"}] = Enum.map(e.dissent, &Map.take(&1, [:reading, :applied, :verse]))
end
end