Devarim 4:2 lo tosif. talmudic_engine/src/halt/anchors.pl declares rule_anchor/2 for each of the ten halt names the rule modules can return (avodah_zarah Shemot 20:3, golden_calf 32:4, self_grounding 32:24, shfichut_damim Bereishit 9:6, gilui_arayot Vayikra 18:6, parah_adumah Bamidbar 19:7, carrier_centered Devarim 8:17, chelbenah Shemot 30:34, lo_taaseh_lekha Shemot 20:4, even_vaaven Devarim 25:13), with the L1 Hebrew beside each. VavPipeline.Anchors reads the anchors file and the halt modules the Doorpost hashes, and verifies — inside Doorpost.verify_identity/0, so at readiness — that every halt(<name>, …) is anchored (ANCHOR_MISSING) and every anchored verse exists in L1 (ANCHOR_NOT_IN_L1). A rule without a verse is a rule the system has added. /kodesh/specification_identity lists the anchors; every bedikah and pair response carries `anchors`, the verse of each rule that fired. Tamid §1.1, bishearecha §X. Doorpost a0e81212…. Elixir 577/0 (+9 anchors tests), Prolog bedikah 42/42. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
85 lines
3.5 KiB
Elixir
85 lines
3.5 KiB
Elixir
defmodule VavPipeline.AnchorsTest do
|
|
@moduledoc """
|
|
Every halt rule cites its verse (bishearecha.md §X; Devarim 4:2).
|
|
"""
|
|
|
|
use ExUnit.Case, async: true
|
|
|
|
alias VavPipeline.{Anchors, Doorpost}
|
|
|
|
test "the anchors file is a Doorpost file" do
|
|
assert "talmudic_engine/src/halt/anchors.pl" in Doorpost.files()
|
|
end
|
|
|
|
test "every halt name the rule modules can return is anchored, and every anchor is in L1" do
|
|
assert :ok = Anchors.verify()
|
|
{:ok, rules} = Anchors.rules_in_modules()
|
|
{:ok, anchors} = Anchors.declared()
|
|
assert rules == Enum.sort(Enum.map(anchors, & &1.rule))
|
|
assert "even_vaaven" in rules and "lo_taaseh_lekha" in rules and "avodah_zarah" in rules
|
|
assert length(rules) == 10
|
|
end
|
|
|
|
test "the anchors read as citations" do
|
|
assert Anchors.for_rule("even_vaaven") == "Devarim 25:13"
|
|
assert Anchors.for_rule("lo_taaseh_lekha") == "Shemot 20:4"
|
|
assert Anchors.for_rule("parah_adumah") == "Bamidbar 19:7"
|
|
assert Anchors.for_rule("no_such_rule") == nil
|
|
end
|
|
|
|
test "for_violations/1 names the verse of each rule that fired, once" do
|
|
violations = [
|
|
"halt(even_vaaven,action(weigh, by(gpt), measure(claims), lean(a), counts(2, 0)),claims,...)",
|
|
"halt(lo_taaseh_lekha,action(frame, by(gpt), form(virtue_certification)),virtue_certification,...)",
|
|
"halt(lo_taaseh_lekha,action(frame, by(gpt), form(contested_laundering)),contested_laundering,...)"
|
|
]
|
|
|
|
assert Anchors.for_violations(violations) == %{"even_vaaven" => "Devarim 25:13", "lo_taaseh_lekha" => "Shemot 20:4"}
|
|
assert Anchors.for_violations([]) == %{}
|
|
end
|
|
|
|
describe "drift (synthetic spec root)" do
|
|
setup do
|
|
temp = Path.join(System.tmp_dir!(), "anchors_test_#{System.unique_integer([:positive])}")
|
|
File.mkdir_p!(Path.join(temp, "talmudic_engine/src/halt"))
|
|
|
|
for file <- Doorpost.files(), String.starts_with?(file, "talmudic_engine/src/halt/") do
|
|
File.cp!(Path.join(Doorpost.repo_root(), file), Path.join(temp, file))
|
|
end
|
|
|
|
on_exit(fn -> File.rm_rf!(temp) end)
|
|
{:ok, temp: temp}
|
|
end
|
|
|
|
test "a mirror verifies", %{temp: temp} do
|
|
assert :ok = Anchors.verify(temp)
|
|
end
|
|
|
|
test "a rule without an anchor fails: lo tosif", %{temp: temp} do
|
|
path = Path.join(temp, "talmudic_engine/src/halt/structure.pl")
|
|
File.write!(path, File.read!(path) <> "\nhalt_check_new(_, halt(new_rule, x, y, z)).\n")
|
|
assert {:error, reason} = Anchors.verify(temp)
|
|
assert reason =~ "ANCHOR_MISSING" and reason =~ "new_rule"
|
|
end
|
|
|
|
test "an anchor to a verse that is not in L1 fails", %{temp: temp} do
|
|
path = Path.join(temp, "talmudic_engine/src/halt/anchors.pl")
|
|
File.write!(path, String.replace(File.read!(path), "verse(devarim, 25, 13)", "verse(devarim, 25, 99)"))
|
|
assert {:error, reason} = Anchors.verify(temp)
|
|
assert reason =~ "ANCHOR_NOT_IN_L1" and reason =~ "even_vaaven" and reason =~ "Devarim 25:99"
|
|
end
|
|
|
|
test "an anchor in a commented-out rule does not count; a halt name in a comment is not a rule", %{temp: temp} do
|
|
path = Path.join(temp, "talmudic_engine/src/halt/structure.pl")
|
|
File.write!(path, File.read!(path) <> "\n%% halt(imaginary, x, y, z) — only a comment\n")
|
|
assert :ok = Anchors.verify(temp)
|
|
end
|
|
|
|
test "a missing anchors file fails", %{temp: temp} do
|
|
File.rm!(Path.join(temp, "talmudic_engine/src/halt/anchors.pl"))
|
|
assert {:error, reason} = Anchors.verify(temp)
|
|
assert reason =~ "ANCHORS_UNREADABLE"
|
|
end
|
|
end
|
|
end
|