Compare commits

..
Author SHA1 Message Date
Scott KarpandClaude Fable 5.1 4e0eb2f983 cycle: the engine is consulted on every resolved question
The Talmudic route ran only on a teiku from ki_tov, and ki_tov returns
teiku only for a root with no Hebrew — which the Shoresh Engine never
leaves. So the engine had never read a real question. Now every cycle
that resolves tov consults it with the roots it activated
(consult_engine/2, on the socket directly — never the client's stub;
an unreachable engine is reported "not consulted" and the cycle's
answer stands). A tamid probe does not consult.

The reading is said plainly (engine_reading_text/1): "Talmudic Engine
(resolved): 11 verse(s): Bereishit 1:1, …; 4 mitzvah/mitzvot:
know_hashem (1, positive), …" — the engine's own term form is no longer
pasted into a reader's answer. The verses join the sources as
references ("Bereishit 1:3", engine form beside), the L3 interpretation
carries them in torah_references with the reading in its reasoning and
processing_component "bereishit_cycle+talmudic_engine".

Proven against the engine running locally on its socket, bereishit 1:1
through VavPipeline.process/1: consulted :ok, 11 verses in the answer
and the sources, L3 torah_references 12; engine stopped → "not
consulted (Cannot connect)", answer stands, L3 component
bereishit_cycle; tamid probe → not consulted. Elixir 632/0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-19 19:02:51 +00:00
Scott KarpandClaude Fable 5.1 ab6ca1ebcf cycle: the Talmudic routing sends roots the engine can read
route_if_unresolved sent the roots' Hebrew (ברא) to the Talmudic
Engine, whose verse facts name roots by letter (bet_resh_aleph, read
from "bet-resh-aleph"). Since Step 14 every interpretation the cycle
took from the engine was "resolved" over an empty trace — 0 verses,
0 mitzvot — and so was every case it escalated to the Sanhedrin. Now
the names go up (BereishitCycle.engine_root_name/1, from tablet 55's
third commit), on both the interpretation and the escalation.

Proven against the engine running locally on its socket, with the
roots the cycle itself activates for bereishit 1:1:
  HEBREW (as before): status=resolved verses=0  mitzvot=0
  NAMES  (now):       status=resolved verses=11 mitzvot=4
Elixir 632/0. The unresolved route cannot be driven in the test env
(it needs the Shoresh Engine to leave a root ungrounded); the live
proof is a pe'ah question with an ungroundable Hebrew word.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-19 18:45:06 +00:00
Scott KarpandClaude Fable 5.1 e01181959d tablet 55, fourth: the engine answers the whole dialectic over the wire
Live after vav :4bffa01e the judges consulted with roots the engine
could read — interpret found 4 mitzvot and 11 verses for bereishit 1:1
— and the other two seats still said teiku. The engine had no
"challenge" action at all (process_json_line failed and the socket
fell silent), and a resolve that SUCCEEDED came back
UNEXPECTED_RESPONSE because response(ok, resolved_accepted, ...) had
no JSON clause. Both pre-existing; both invisible until a judge asked.

- api.pl: request(challenge, ...) — interpret, then a kushya against
  it → resolved_challenged with the kushya; none → no_challenge with
  the reading.
- json_bridge.pl: interpreted | resolved_accepted | no_challenge share
  the "resolved" JSON; resolved_challenged now carries the
  interpretation's verses and mitzvot (a judge rejecting on the kushya
  cites its ground); resolved_synthesized and no_interpretation gain
  clauses.
- reasoning_test.pl: dialectic_over_the_wire — all three actions
  answer; no roots → resolved on an empty trace (the judge abstains).

Prolog: 7 suites green (bedikah 45, halt 49, middot 47, mitzvot 42,
phase3 28, reasoning 18, tzaraat 34). Local probe: interpret /
challenge / resolve each → resolved, 11 verses, 4 mitzvot.

Live proof waits for tomorrow's manna: today's five panels were all
spent on verification (503 MANNA_DEPLETED, as specified).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-19 18:25:17 +00:00
Scott KarpandClaude Fable 5.1 4bffa01e0e tablet 55, third: roots the engine can read; abstentions count; an empty trace is no ground
Live after the second commit (vav :046010f0): a monetary case naming
bereishit 1:1 convened three judges and came back "accepted" — the
interpret seat said "resolved (5 roots, 0 verses)" with
reading(mitzvot_count(0),verse_count(0),grounded_in([],[])), the other
two seats said teiku, and one accept beat two abstentions (the reply
showed majority 1, minority 2). Three defects the tests could not see:

- The engine names roots by letter (bet_resh_aleph; json_bridge reads
  "bet-resh-aleph") and the pipeline sent it the Hebrew, which its
  verse facts never match. BereishitCycle.engine_root_name/1 builds
  the engine's name from the Shoresh Engine's letter names or, for the
  L1 fallback, from the Hebrew with finals folded; the router sends
  that. (The cycle's own Talmudic routing still sends the Hebrew —
  recorded, not changed here: it alters /peah/ask and needs its own
  verification.)
- judge.erl: "resolved" with no verse and no mitzvah is a reading
  coupled to nothing (avodah_zarah.pl Form 2); the judge abstains and
  says "resolved on an empty trace; nothing to stand on".
- panel.erl: the majority is the verdict with the most votes,
  abstentions included; an abstaining plurality or an accept/reject
  tie is teiku.

EUnit 57/0 (plurality, tie, empty trace). Elixir 632/0 (engine_root_name
from names, from Hebrew, nil on nothing; the no-engine case is an
abstaining majority of one, teiku).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-19 18:18:50 +00:00
10 changed files with 352 additions and 24 deletions

No files matched your search

+9
View File
@@ -157,7 +157,16 @@ vote_from_consultation(Step, {ok, Map}, RootCount) ->
Status = maps:get(status, Map, <<"teiku">>), Status = maps:get(status, Map, <<"teiku">>),
Text = maps:get(text, Map, <<>>), Text = maps:get(text, Map, <<>>),
Verses = maps:get(verses, Map, []), Verses = maps:get(verses, Map, []),
Grounding = maps:get(grounding, Map, []),
case Status of case Status of
<<"resolved">> when Verses =:= [], Grounding =:= [] ->
%% The engine says "resolved" over an empty trace — no verse,
%% no mitzvah. That is a reading that stands on nothing, and
%% a vote to accept it would be the calf (avodah_zarah.pl
%% Form 2: the uncoupled output). Abstain, and say why.
{<<"Teiku — the reading is coupled to no verse and no mitzvah">>,
reasoning(Step, <<"resolved on an empty trace; nothing to stand on">>, RootCount, Verses),
[], abstain};
<<"resolved">> -> <<"resolved">> ->
{Text, {Text,
reasoning(Step, <<"resolved">>, RootCount, Verses), reasoning(Step, <<"resolved">>, RootCount, Verses),
+10 -4
View File
@@ -207,15 +207,21 @@ compute_majority_minority([]) ->
torah_refs => [], torah_refs => [],
vote_count => 0}}; vote_count => 0}};
compute_majority_minority(Votes) -> compute_majority_minority(Votes) ->
%% Count accepts vs rejects
Accepts = [V || V <- Votes, V#vote.verdict == accept], Accepts = [V || V <- Votes, V#vote.verdict == accept],
Rejects = [V || V <- Votes, V#vote.verdict == reject], Rejects = [V || V <- Votes, V#vote.verdict == reject],
Abstains = [V || V <- Votes, V#vote.verdict == abstain], Abstains = [V || V <- Votes, V#vote.verdict == abstain],
NA = length(Accepts), NR = length(Rejects), NB = length(Abstains),
%% The majority is the verdict with the most votes — abstentions
%% count (tablet 55: live, one accept "won" against two
%% abstentions, and the reply showed majority 1, minority 2). An
%% abstaining plurality, or an accept/reject tie, is teiku
%% (determine_outcome reads the majority's verdict).
{MajVotes, MinVotes} = {MajVotes, MinVotes} =
case length(Accepts) >= length(Rejects) of if
true -> {Accepts, Rejects ++ Abstains}; NA > NR, NA >= NB -> {Accepts, Rejects ++ Abstains};
false -> {Rejects, Accepts ++ Abstains} NR > NA, NR >= NB -> {Rejects, Accepts ++ Abstains};
true -> {Abstains, Accepts ++ Rejects}
end, end,
MajSample = case MajVotes of MajSample = case MajVotes of
+31
View File
@@ -506,6 +506,37 @@ majority_verdict_reject_test() ->
{Maj, _Min} = panel:compute_majority_minority(Votes), {Maj, _Min} = panel:compute_majority_minority(Votes),
?assertEqual(reject, maps:get(verdict, Maj)). ?assertEqual(reject, maps:get(verdict, Maj)).
%% Tablet 55: abstentions count. One accept against two abstentions is
%% not an accepting majority — it is teiku.
majority_abstaining_plurality_is_teiku_test() ->
Votes = [make_vote(accept), make_vote(abstain), make_vote(abstain)],
{Maj, Min} = panel:compute_majority_minority(Votes),
?assertEqual(abstain, maps:get(verdict, Maj)),
?assertEqual(2, maps:get(vote_count, Maj)),
?assertEqual(1, maps:get(vote_count, Min)),
?assertEqual(teiku, panel:determine_outcome(Maj, Min, passed)).
majority_accept_reject_tie_is_teiku_test() ->
Votes = [make_vote(accept), make_vote(reject)],
{Maj, _Min} = panel:compute_majority_minority(Votes),
?assertEqual(abstain, maps:get(verdict, Maj)),
?assertEqual(0, maps:get(vote_count, Maj)).
%% Tablet 55: "resolved" over an empty trace — no verse, no mitzvah —
%% is nothing to stand on; the judge abstains rather than accept.
judge_resolved_on_empty_trace_abstains_test() ->
{Pos, Reason, Refs, Verdict} =
judge:vote_from_consultation(interpret,
{ok, #{status => <<"resolved">>, text => <<"reading(0,0)">>, verses => [], grounding => []}}, 5),
?assertEqual(abstain, Verdict),
?assertEqual([], Refs),
?assertMatch({_, _}, binary:match(Pos, <<"Teiku">>)),
?assertMatch({_, _}, binary:match(Reason, <<"empty trace">>)),
%% a mitzvah without a verse is still ground
{_, _, _, V2} = judge:vote_from_consultation(interpret,
{ok, #{status => <<"resolved">>, text => <<"r">>, verses => [], grounding => [<<"mitzvah(5)">>]}}, 1),
?assertEqual(accept, V2).
%% ============================================================ %% ============================================================
%% determine_outcome tests — accepted, rejected, teiku reachable %% determine_outcome tests — accepted, rejected, teiku reachable
%% ============================================================ %% ============================================================
+18
View File
@@ -45,6 +45,24 @@ process_request(request(resolve, CaseRef, Domain, Roots, Question), Response) :-
; Response = response(error, no_resolution, CaseRef) ; Response = response(error, no_resolution, CaseRef)
). ).
%% The challenge step of the dialectic, on its own (tablet 55: the
%% Sanhedrin's second seat asks it; until now no handler answered and
%% the socket fell silent). Interpret, then look for a kushya against
%% the interpretation: one stands → resolved_challenged, the kushya
%% named; none → no_challenge, the interpretation as read.
process_request(request(challenge, CaseRef, Domain, Roots, Question), Response) :-
Case = case(CaseRef, Domain, Roots, Question),
( interpret(Case, Interpretation)
-> ( challenge(Interpretation, Kushya)
-> Response = response(ok, resolved_challenged,
result(interpretation(Interpretation),
challenge(Kushya)))
; format_interpretation(Interpretation, response(ok, interpreted, Result)),
Response = response(ok, no_challenge, Result)
)
; Response = response(error, no_interpretation, CaseRef)
).
process_request(request(halt_check, Action), Response) :- process_request(request(halt_check, Action), Response) :-
format_halt_check(Action, Response). format_halt_check(Action, Response).
+41 -6
View File
@@ -153,11 +153,15 @@ read_coupling_term(Str, Term) :-
%% JSON format (Construction §3.3): %% JSON format (Construction §3.3):
%% { "status": "resolved", "interpretation": { ... } } %% { "status": "resolved", "interpretation": { ... } }
%% Interpreted response %% Interpreted response — and the same shape under the names the
response_to_json(response(ok, interpreted, result(ref(Ref), mitzvot(Mitzvot), %% resolve and challenge steps give it when the reading stands
verses(Verses), reading(Reading), %% (tablet 55: resolved_accepted had no clause, so a resolve that
confidence(Conf))), %% succeeded came back UNEXPECTED_RESPONSE; no_challenge is new).
response_to_json(response(ok, Kind, result(ref(Ref), mitzvot(Mitzvot),
verses(Verses), reading(Reading),
confidence(Conf))),
Dict) :- Dict) :-
memberchk(Kind, [interpreted, resolved_accepted, no_challenge]),
maplist(term_to_string, Mitzvot, MitzvotStrs), maplist(term_to_string, Mitzvot, MitzvotStrs),
maplist(term_to_string, Verses, VerseStrs), maplist(term_to_string, Verses, VerseStrs),
term_to_string(Reading, ReadingStr), term_to_string(Reading, ReadingStr),
@@ -171,21 +175,52 @@ response_to_json(response(ok, interpreted, result(ref(Ref), mitzvot(Mitzvot),
confidence: ConfStr}, confidence: ConfStr},
challenge: null}. challenge: null}.
%% Challenged response %% Challenged response — the interpretation's verses and mitzvot are
%% carried, so a judge rejecting on the kushya still cites its ground.
response_to_json(response(ok, resolved_challenged, response_to_json(response(ok, resolved_challenged,
result(interpretation(Interp), challenge(Kushya))), result(interpretation(Interp), challenge(Kushya))),
Dict) :- Dict) :-
Interp = interpretation(_Ref, Mitzvot, Verses, _Reading, _Conf, _Trace),
maplist(term_to_string, Mitzvot, MitzvotStrs),
maplist(term_to_string, Verses, VerseStrs),
term_to_string(Interp, InterpStr), term_to_string(Interp, InterpStr),
term_to_string(Kushya, KushyaStr), term_to_string(Kushya, KushyaStr),
Dict = json{status: "challenged", Dict = json{status: "challenged",
interpretation: json{text: InterpStr, interpretation: json{text: InterpStr,
prolog_form: InterpStr, prolog_form: InterpStr,
grounding: [], grounding: MitzvotStrs,
verses: VerseStrs,
confidence: "medium"}, confidence: "medium"},
challenge: json{kushya: KushyaStr, challenge: json{kushya: KushyaStr,
contradicting: "", contradicting: "",
strength: "moderate"}}. strength: "moderate"}}.
%% Synthesized resolution: both readings stand on common ground.
response_to_json(response(ok, resolved_synthesized,
result(common(Common), verses(Verses), both_sides(Both))),
Dict) :-
maplist(term_to_string, Common, CommonStrs),
maplist(term_to_string, Verses, VerseStrs),
term_to_string(Both, BothStr),
Dict = json{status: "resolved",
interpretation: json{text: BothStr,
prolog_form: BothStr,
grounding: CommonStrs,
verses: VerseStrs,
confidence: "medium"},
challenge: null}.
%% No interpretation possible (from resolve)
response_to_json(response(ok, no_interpretation, result(ref(Ref))), Dict) :-
atom_string(Ref, RefStr),
Dict = json{status: "teiku",
interpretation: json{text: "No interpretation found",
prolog_form: RefStr,
grounding: [],
verses: [],
confidence: "low"},
challenge: null}.
%% Teiku response %% Teiku response
response_to_json(response(ok, teiku, result(record(Record))), Dict) :- response_to_json(response(ok, teiku, result(record(Record))), Dict) :-
term_to_string(Record, RecordStr), term_to_string(Record, RecordStr),
+49
View File
@@ -112,3 +112,52 @@ test(teiku_count_works) :-
integer(Count). integer(Count).
:- end_tests(teiku_module). :- end_tests(teiku_module).
%% ============================================================
%% Tablet 55 — the dialectic over the wire: interpret, challenge,
%% resolve each answer JSON a judge can vote on. Before this the
%% engine had no "challenge" action and a resolve that succeeded came
%% back UNEXPECTED_RESPONSE (resolved_accepted had no JSON clause).
%% ============================================================
:- use_module('../src/interface/api').
:- use_module('../src/interface/json_bridge').
:- use_module('../src/interface/socket_server').
:- begin_tests(dialectic_over_the_wire).
roots_line(Action, Line) :-
format(atom(Line),
'{"action":"~w","case":{"ref":"t55-~w","question":"q","context_roots":["bet-resh-aleph","aleph-lamed-he"]}}',
[Action, Action]).
test(interpret_answers_resolved_with_verses, [nondet]) :-
roots_line(interpret, L),
socket_server:process_json_line(L, R),
get_dict(status, R, "resolved"),
get_dict(interpretation, R, I),
get_dict(verses, I, Vs), Vs \== [].
test(challenge_answers_and_carries_the_ground, [nondet]) :-
roots_line(challenge, L),
socket_server:process_json_line(L, R),
get_dict(status, R, S),
memberchk(S, ["resolved", "challenged"]),
get_dict(interpretation, R, I),
get_dict(verses, I, Vs), Vs \== [].
test(resolve_answers_resolved_not_unexpected, [nondet]) :-
roots_line(resolve, L),
socket_server:process_json_line(L, R),
\+ get_dict(error, R, _),
get_dict(status, R, S),
memberchk(S, ["resolved", "challenged", "teiku"]).
test(no_roots_resolves_on_an_empty_trace, [nondet]) :-
socket_server:process_json_line('{"action":"interpret","case":{"ref":"t55-empty","question":"q","context_roots":[]}}', R),
get_dict(status, R, "resolved"),
get_dict(interpretation, R, I),
get_dict(verses, I, []),
get_dict(grounding, I, []).
:- end_tests(dialectic_over_the_wire).
+158 -11
View File
@@ -63,8 +63,8 @@ defmodule VavPipeline.BereishitCycle do
""" """
alias VavPipeline.{Specification, CycleLog, Manna, HaltConditions, alias VavPipeline.{Specification, CycleLog, Manna, HaltConditions,
ShoreshEngineClient, TalmudicEngineClient, SanhedrinClient, ShoreshEngineClient, TalmudicEngineClient, TalmudicEngineSocket,
Chatzotzrot} SanhedrinClient, Chatzotzrot}
require Logger require Logger
@@ -308,7 +308,11 @@ defmodule VavPipeline.BereishitCycle do
final = final =
case result do case result do
{:ok, data} -> {:ok, data} ->
check_halt_on_output(data) # Every question is read against the engine, not only a teiku
# that never comes (2026-10-19: ki_tov returns teiku only on a
# root with no Hebrew, and the Shoresh Engine never leaves one;
# the Talmudic route had never been walked by a real question).
data |> consult_engine(context) |> check_halt_on_output()
{:unresolved, data} -> {:unresolved, data} ->
case route_if_unresolved(data, context) do case route_if_unresolved(data, context) do
@@ -325,6 +329,90 @@ defmodule VavPipeline.BereishitCycle do
final final
end end
# ============================================================
# The engine, consulted on every resolved cycle
# ============================================================
# Architecture §3.3: the Talmudic Engine grounds a reading in verses
# and mitzvot over the case's roots. The cycle's own ki_tov says the
# roots stand in L1; the engine says what stands on them. Called
# directly on the socket — never the client's stub (tablet 41): an
# engine that cannot be reached is reported as not consulted, and the
# cycle's answer stands without it. A tamid probe does not consult
# (the fire is checked, the engine is not loaded by the check).
defp consult_engine(%{probe: true} = data, _context), do: data
defp consult_engine(data, _context) do
roots = Map.get(data, :roots_activated, [])
names = roots |> Enum.map(&engine_root_name/1) |> Enum.reject(&is_nil/1)
case_ref = Map.get(data, :case_ref, generate_case_ref())
cond do
names == [] ->
Map.put(data, :talmudic_consulted, {:skipped, :no_roots})
Process.whereis(TalmudicEngineSocket) == nil ->
Map.put(data, :talmudic_consulted, {:error, :engine_socket_not_started})
true ->
case TalmudicEngineSocket.interpret(case_ref, %{context_roots: names, question: Map.get(data, :raw, "")}) do
{:ok, %{"status" => _} = reply} ->
Map.merge(data, %{talmudic_interpretation: reply, talmudic_consulted: :ok})
{:ok, other} ->
Logger.warning("BereishitCycle: engine answered an unexpected shape for #{case_ref}: #{inspect(other)}")
Map.put(data, :talmudic_consulted, {:error, :unexpected_reply})
{:error, reason} ->
Logger.warning("BereishitCycle: engine not consulted for #{case_ref}: #{inspect(reason)}")
Map.put(data, :talmudic_consulted, {:error, reason})
end
end
end
@doc """
The engine's reading, said plainly: how many verses and mitzvot it
coupled to the roots, and which. `nil` when there is no reading.
"""
@spec engine_reading_text(map()) :: String.t() | nil
def engine_reading_text(data) do
case Map.get(data, :talmudic_interpretation) do
%{"interpretation" => interp} = reply when is_map(interp) ->
verses = interp |> Map.get("verses", []) |> List.wrap() |> Enum.map(&verse_ref_display/1) |> Enum.reject(&is_nil/1) |> Enum.uniq()
mitzvot = interp |> Map.get("grounding", []) |> List.wrap() |> Enum.map(&mitzvah_display/1) |> Enum.reject(&is_nil/1) |> Enum.uniq()
status = Map.get(reply, "status", "")
cond do
verses == [] and mitzvot == [] ->
"Talmudic Engine (#{status}): no verse or mitzvah is coupled to these roots."
true ->
v = if verses == [], do: "no verse", else: "#{length(verses)} verse(s): #{Enum.join(verses, ", ")}"
m = if mitzvot == [], do: "no mitzvah", else: "#{length(mitzvot)} mitzvah/mitzvot: #{Enum.join(mitzvot, ", ")}"
"Talmudic Engine (#{status}): #{v}; #{m}."
end
_ ->
nil
end
end
# "verse_ref(bereishit,1,1,'...')" / "verse(shemot,3,14)" → "Bereishit 1:1"
defp verse_ref_display(s) do
case Regex.run(~r/verse(?:_ref)?\((bereishit|shemot|vayikra|bamidbar|devarim)\s*,\s*(\d+)\s*,\s*(\d+)/, to_string(s)) do
[_, book, ch, vs] -> "#{String.capitalize(book)} #{ch}:#{vs}"
_ -> nil
end
end
# "mitzvah(1,positive,know_hashem,always)" → "know_hashem (1, positive)"
defp mitzvah_display(s) do
case Regex.run(~r/mitzvah\((\d+)\s*,\s*(\w+)\s*,\s*(\w+)/, to_string(s)) do
[_, id, kind, name] -> "#{name} (#{id}, #{kind})"
_ -> nil
end
end
# ============================================================ # ============================================================
# Compose — the answer and its sources, from the context # Compose — the answer and its sources, from the context
# ============================================================ # ============================================================
@@ -385,15 +473,19 @@ defmodule VavPipeline.BereishitCycle do
deliberation = deliberation =
case Map.get(data, :resolution) do case Map.get(data, :resolution) do
:talmudic -> :talmudic ->
text = get_in(data, [:talmudic_interpretation, "interpretation", "text"]) || "" " " <> (engine_reading_text(data) || "Talmudic Engine resolved the case.")
" Talmudic Engine: #{text}"
:sanhedrin -> :sanhedrin ->
pos = get_in(data, [:sanhedrin_decision, :majority, :position]) || "" pos = get_in(data, [:sanhedrin_decision, :majority, :position]) || ""
" Sanhedrin majority: #{pos}" " Sanhedrin majority: #{pos}"
_ -> _ ->
"" # Consulted after ki_tov (every resolved question), or not.
case {engine_reading_text(data), Map.get(data, :talmudic_consulted)} do
{text, _} when is_binary(text) -> " " <> text
{nil, {:error, reason}} -> " Talmudic Engine: not consulted (#{inspect(reason)})."
_ -> ""
end
end end
"Roots activated in #{verse.ref}: #{Enum.join(root_lines, "; ")}." <> "Roots activated in #{verse.ref}: #{Enum.join(root_lines, "; ")}." <>
@@ -426,10 +518,19 @@ defmodule VavPipeline.BereishitCycle do
text: verse.text_hebrew text: verse.text_hebrew
} }
# The engine's verses as references a reader can follow ("Bereishit
# 1:3"), the engine's own form kept beside them; the scope verse is
# not repeated.
talmudic_verses = talmudic_verses =
case get_in(data, [:talmudic_interpretation, "interpretation", "verses"]) do case get_in(data, [:talmudic_interpretation, "interpretation", "verses"]) do
vs when is_list(vs) -> Enum.map(vs, fn v -> %{ref: to_string(v)} end) vs when is_list(vs) ->
_ -> [] vs
|> Enum.map(fn v -> %{ref: verse_ref_display(v) || to_string(v), engine_form: to_string(v)} end)
|> Enum.uniq_by(& &1.ref)
|> Enum.reject(&(&1.ref == verse.ref))
_ ->
[]
end end
[primary | talmudic_verses] [primary | talmudic_verses]
@@ -604,13 +705,22 @@ defmodule VavPipeline.BereishitCycle do
{:interpretation, attrs, nil} {:interpretation, attrs, nil}
_ -> _ ->
# The engine's reading, when it was consulted, rides in the record:
# its verses beside the scope, its text in the reasoning, and the
# component names both readers.
interp = get_in(data, [:talmudic_interpretation, "interpretation"]) || %{}
engine_verses = interp |> Map.get("verses", []) |> to_string_list()
reading = engine_reading_text(data)
attrs = attrs =
Map.merge(base, %{ Map.merge(base, %{
reasoning: single_judge_reasoning(data, context), reasoning:
if(reading, do: single_judge_reasoning(data, context) <> " " <> reading, else: single_judge_reasoning(data, context)),
torah_references: Enum.uniq([scope_ref | engine_verses]),
panel_size: 1, panel_size: 1,
vote_count_for: 1, vote_count_for: 1,
vote_count_against: 0, vote_count_against: 0,
processing_component: "bereishit_cycle" processing_component: if(reading, do: "bereishit_cycle+talmudic_engine", else: "bereishit_cycle")
}) })
{:interpretation, attrs, nil} {:interpretation, attrs, nil}
@@ -740,7 +850,10 @@ defmodule VavPipeline.BereishitCycle do
@doc false @doc false
defp route_if_unresolved(data, context) do defp route_if_unresolved(data, context) do
roots = Map.get(data, :roots_activated, []) roots = Map.get(data, :roots_activated, [])
context_roots = Enum.map(roots, & &1.shoresh) # Tablet 55: the engine names roots by letter (bet_resh_aleph); the
# Hebrew was sent since Step 14 and never matched a verse fact, so
# every Talmudic interpretation was "resolved" over an empty trace.
context_roots = roots |> Enum.map(&engine_root_name/1) |> Enum.reject(&is_nil/1)
case_ref = Map.get(data, :case_ref, generate_case_ref()) case_ref = Map.get(data, :case_ref, generate_case_ref())
@@ -970,6 +1083,40 @@ defmodule VavPipeline.BereishitCycle do
defp letters_to_hebrew(_), do: nil defp letters_to_hebrew(_), do: nil
# The inverse: Hebrew consonant → letter name, finals folded to their base.
@hebrew_to_name Map.new(@consonant_names, fn {name, heb} -> {heb, name} end)
|> Map.merge(%{"ך" => "kaf", "ם" => "mem", "ן" => "nun", "ף" => "pe", "ץ" => "tsadi"})
@doc """
The root as the Talmudic Engine names it — letter names joined by `-`
(`json_bridge` `parse_root_name` → `bet_resh_aleph`, the form of its
verse facts). From the letter names the Shoresh Engine gives when it
has them, else from the Hebrew (the L1 fallback carries only that).
Tablet 55: the engine was being sent the Hebrew, which its facts never
match — 5 roots in, 0 verses out, and "resolved" over the emptiness.
`nil` when the root carries nothing nameable.
"""
@spec engine_root_name(map()) :: String.t() | nil
def engine_root_name(root) when is_map(root) do
letters = Map.get(root, :shoresh_letters) || []
names =
if is_list(letters) and letters != [] do
Enum.map(letters, &String.downcase(to_string(&1)))
else
root
|> Map.get(:shoresh)
|> case do
s when is_binary(s) -> s |> String.graphemes() |> Enum.map(&Map.get(@hebrew_to_name, &1))
_ -> [nil]
end
end
if names != [] and Enum.all?(names, &is_binary/1), do: Enum.join(names, "-"), else: nil
end
def engine_root_name(_), do: nil
# ============================================================ # ============================================================
# Private helpers # Private helpers
# ============================================================ # ============================================================
@@ -1250,7 +1250,11 @@ defmodule VavPipeline.BigdeiKodesh.Router do
{:ok, {:ok,
%{ %{
roots: Enum.map(roots_full, & &1.shoresh), # The engine's verse facts name roots by letter — bet_resh_aleph —
# and json_bridge reads "bet-resh-aleph". The cycle's root carries
# the letter names beside the Hebrew; the Hebrew never matches
# (live, 2026-10-19: 5 roots sent, 0 verses found, "resolved").
roots: roots_full |> Enum.map(&VavPipeline.BereishitCycle.engine_root_name/1) |> Enum.reject(&is_nil/1),
roots_full: roots_full, roots_full: roots_full,
torah_ref: {String.to_atom(scope.book), scope.chapter, scope.verse}, torah_ref: {String.to_atom(scope.book), scope.chapter, scope.verse},
read_from: Map.get(state, :roots_read_from) read_from: Map.get(state, :roots_read_from)
+4 -2
View File
@@ -403,8 +403,10 @@ defmodule VavPipeline.BigdeiKodeshTest do
body = Jason.decode!(conn.resp_body) body = Jason.decode!(conn.resp_body)
assert body["deliberation"]["outcome"] == "teiku" assert body["deliberation"]["outcome"] == "teiku"
assert body["deliberation"]["panel_size"] == 1 assert body["deliberation"]["panel_size"] == 1
assert body["deliberation"]["majority"]["votes"] == 0 # the one judge abstained: an abstaining majority of one, no dissent
assert body["deliberation"]["minority"]["reasoning"] =~ "no consultation" assert body["deliberation"]["majority"]["votes"] == 1
assert body["deliberation"]["majority"]["reasoning"] =~ "no consultation"
assert body["deliberation"]["minority"]["votes"] == 0
end end
# Tablet 55: with a consultation behind the judges, the dialectic # Tablet 55: with a consultation behind the judges, the dialectic
@@ -0,0 +1,27 @@
defmodule VavPipeline.Tablet55EngineRootNameTest do
@moduledoc """
Tablet 55: the Talmudic Engine names roots by letter (bet_resh_aleph,
read from "bet-resh-aleph"). The pipeline was sending it the Hebrew,
which its verse facts never match — roots in, no verses out, and a
"resolved" reading over the emptiness.
"""
use ExUnit.Case, async: true
alias VavPipeline.BereishitCycle
test "from the Shoresh Engine's letter names" do
assert BereishitCycle.engine_root_name(%{shoresh: "ברא", shoresh_letters: ["bet", "resh", "aleph"]}) ==
"bet-resh-aleph"
end
test "from the Hebrew alone (the L1 fallback), finals folded" do
assert BereishitCycle.engine_root_name(%{shoresh: "דבר", shoresh_letters: []}) == "dalet-bet-resh"
assert BereishitCycle.engine_root_name(%{shoresh: "מלך"}) == "mem-lamed-kaf"
end
test "nothing nameable → nil, never a Hebrew string the engine cannot read" do
assert BereishitCycle.engine_root_name(%{shoresh: nil}) == nil
assert BereishitCycle.engine_root_name(%{shoresh: "x1"}) == nil
assert BereishitCycle.engine_root_name(%{}) == nil
end
end