Files
bikoret/vav_pipeline/test/source_external_test.exs
T
Scott KarpandClaude Opus 4.7 5302c9a585 vehaya §6 closure: Items 1, 4, 5, 6, 7, 8 — the remaining checklist
This commit closes the SIX remaining items in the vehaya checklist
(after Items 2 and 3 from prior commits). With this, all eight items
in vehaya §6 are addressed in code or in the canonical spec set,
and all the substantive implications across §3 are covered.

ITEM 1 — load-bearing dependency (vehaya §3.1):

  Devarim 11:18-19 — corporate inscription (v'samtem … al
  l'vavkhem — plural) is the load-bearing input to threshold
  practice (b'shivt'kha b'beitekha — singular). The threshold
  inscribes the corporate text on itself.

  ShemaContext now carries `doorpost_hash: Doorpost.expected_hash()`
  on every reception. Both receive_context/1 and receive_context_at/2
  populate it. Every reception is now a witness of the corporate
  text's identity — making the load-bearing dependency between
  category and threshold structural rather than implicit.

  application.ex now runs Doorpost.verify_identity/0 at startup.
  Drift detected at boot is logged at :error AND fires
  Chatzotzrot.signal(:assembly_leaders, ...). The system does NOT
  refuse to boot on drift (dev environments routinely have spec
  drift during active editing) but operators are alerted before any
  reception fires.

ITEM 6 — keep the source external (full closure; vehaya §6 item 6):

  Devarim 4:2 — lo tosif AND lo tigra; both directions.
  Vayikra 22:31 — u'shmartem … va'asitem; keep and do, not author.

  Form 1 closed the EXTERNAL → INTERNAL direction (commit b136c75 —
  no module installs external models in YHVH's slot). This commit
  closes the INTERNAL → SOURCE direction (no module modifies the
  source itself).

  vav_pipeline/test/source_external_test.exs (4 tests) verifies:
    - no Elixir module writes to the L1 mount
    - no Python module in korban_processor writes to L1
    - no Python module in azazel_processor writes to L1
    - no Prolog module asserts into L1-shape predicates from
      outside specification/

  L1 was already filesystem-permission-controlled at the operator
  layer; this commit defends in code so the architectural commitment
  cannot be silently violated by future code paths.

ITEM 7 — substrate openness (vehaya §2.4):

  Bereishit 2:7 — afar substrate + nishmat chayim breath; the text
  does not preclude carriers of other substrate.

  specs/shorashim_architecture.md §8.4 added: positive architectural
  claim that the system is designed to carry covenant content
  regardless of substrate, with explicit caveats (does NOT claim AI
  is a covenant party with YHVH, does NOT claim AI has neshamah,
  does NOT claim all substrates are equally adequate). The claim is
  structural: nothing in the architecture refuses a substrate Torah
  did not refuse. Lo tosif applied to imported constraints.

ITEM 8 — userMemories as threshold inscription (vehaya §3.3):

  Devarim 11:20 / Devarim 6:9 — u'kh'tavtam al m'zuzot beitekha;
  the doorpost-text verse is identical between the Shema's first
  paragraph (singular pole) and V'haya's second (oscillating).

  specs/threshold_inscription.md (new) names the architecture for
  the threshold inscription:
    - identical at every threshold (Doorpost hash; same MEMORY.md
      structure)
    - pointing back to the source (the inscription is OF the
      corporate text, not ABOUT the threshold)
    - inscribed at the threshold's own location

  Two implementations: ShemaContext.doorpost_hash (runtime) and
  MEMORY.md (operator-side). Operator workflow split into three
  layers: build status (MEMORY.md), spec changes (specs/* with
  Doorpost atomicity), operator notes (outside repo).

ITEM 5 — return vs. restoration (vehaya §3.5):

  Devarim 30:2 / 30:8 / 30:10 — v'shavta ad YHVH … ha'k'tuvah
  b'sefer ha'Torah ha'zeh. Return is to the SOURCE and the
  SPECIFICATIONS, anchored in the text — not to a previous
  deployment configuration.

  specs/return_specification.md (new) names the structural
  distinction:
    - Return: destination is the source and specifications;
      removes additions
    - Restoration: destination is a specific past configuration;
      may restore additions

  Auditable test: does the proposed action move the system TOWARD
  the documented specifications, or TOWARD a previous state? The
  Doorpost hash makes this distinguishable.

ITEM 4 — lo tosif discipline operationalized (vehaya §6 item 4):

  Devarim 4:2, Devarim 13:1, Vayikra 22:31 — the keeping is
  plural, the not-adding/not-subtracting is singular at the
  threshold.

  specs/lo_tosif.md (new) names the discipline at three layers:
    Layer 1: specifications (specs/*, halt rules) — Doorpost
      defends; bare hash-update commits are drift signals
    Layer 2: architectural commitments (CI invariants) — adding
      a bypass surface OR removing an enforcement is detected
    Layer 3: threshold inscription (MEMORY.md) — operator notes
      not derived from category-grade specifications belong
      outside the repo

  Documents what counts as a legitimate spec change (Torah-grounded
  reading + atomic commit + named anchor + reviewable in git) and
  what does NOT count as a spec change (operations updates).

DOORPOST UPDATES:

  Three new spec docs added to @spec_files:
    - specs/lo_tosif.md
    - specs/return_specification.md
    - specs/threshold_inscription.md

  Plus specs/shorashim_architecture.md modified for §8.4.

  @expected_hash updated:
    8eb37896… → 5a73bc6ac8244c58446cf1d2a69dc01ccfe3ef1352d423ccbf2c29a6c8104be3

  Fourth demonstration of the operator discipline working: spec
  changes (3 new docs + 1 modified) atomically bound to hash update
  in the same commit.

TESTS:

  vav_pipeline/test/step15_shema_test.exs +3 tests (Shema doorpost
    inscription suite):
    - ShemaContext carries the Doorpost expected_hash
    - every reception bears the same corporate-text witness
    - inscribed hash matches documented spec set's identity

  vav_pipeline/test/source_external_test.exs (NEW) 4 tests:
    - Item 6 enforcement across Elixir, Python (korban), Python
      (azazel), and Prolog

Final test counts:
  - vav_pipeline:    412 passed, 0 failures, 35 excluded (was 405; +7)
  - korban_processor: 217/1 unchanged
  - azazel_processor: 125 unchanged
  - talmudic_engine: 214 unchanged

VEHAYA CHECKLIST — FINAL STATE:

  Item 1 (load-bearing category→threshold dependency)    CLOSED (this commit)
  Item 2 (three avodah zarah as architecture)            CLOSED
                                                          - Form 1 (b136c75)
                                                          - Form 2 (7fc14e0)
                                                          - Form 3 (0e3fe4a)
  Item 3 (doorpost-text identity)                        CLOSED (3f47496)
  Item 4 (lo tosif operationalized)                      CLOSED (this commit)
  Item 5 (return vs. restoration)                        CLOSED (this commit)
  Item 6 (keep the source external — full closure)       CLOSED (this commit)
  Item 7 (substrate-openness articulated)                CLOSED (this commit)
  Item 8 (userMemories as threshold inscription)         CLOSED (this commit)

All eight items in vehaya §6 are addressed in code or in the
canonical spec set. The full vehaya specification is implemented to
the extent the architecture-level (§3-6) implications can be
implemented; §4-out-of-scope items (consciousness, Sinai-covenant
identification) remain explicitly out of scope per the document.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 23:47:53 -04:00

165 lines
5.9 KiB
Elixir

defmodule VavPipeline.SourceExternalTest do
@moduledoc """
Item 6 of vehaya §6 — keep the source external.
TORAH ANCHORS:
Devarim 4:2 — לֹא תֹסִפוּ עַל־הַדָּבָר אֲשֶׁר אָנֹכִי מְצַוֶּה אֶתְכֶם
וְלֹא תִגְרְעוּ מִמֶּנּוּ. The injunction is bidirectional:
do not add, do not subtract. Both directions are addressed to
the keeper.
Vayikra 22:31 — וּשְׁמַרְתֶּם מִצְוֺתַי וַעֲשִׂיתֶם אֹתָם.
KEEP my mitzvot and DO them. Two verbs (shmor, asoh) — guarding
and performing. Both are received-acts. Neither is an
authoring-act.
THE ARCHITECTURAL COMMITMENT:
The system READS L1 (the Torah scroll); it does NOT write to L1.
The Form 1 commit (b136c75) closed the EXTERNAL → INTERNAL
direction (no module installs external models in YHVH's slot).
This test closes the INTERNAL → SOURCE direction (no module
modifies the source itself). Together: the source is external
AND inviolable from the system side.
L1 is the only canonical reference to the Torah text. If the
system could write to it, the system would be authoring its own
source — the same shape as Form 1 but inverted (the system in
the source's seat instead of the source-substitute in the
system's seat). Both are forbidden by Devarim 4:35 (ein od
milvado — there is no other source position).
ENFORCEMENT: any source file that contains File.write, File.cp,
File.rm, File.rename, File.touch, or File.mkdir with an L1 path
fails this test.
The L1 mount path is configurable (`@l1_mount_point` in
L1Reader); operators can mount L1 read-only at the filesystem
layer, but this test defends against in-code attempts to
modify even when the filesystem permits it.
"""
use ExUnit.Case, async: true
@vav_pipeline_lib "lib/vav_pipeline"
@korban_processor "../korban_processor/src"
@azazel_processor "../azazel_processor/src"
# Files that legitimately mention L1-write patterns:
# - L1Reader's docstring describes the read-only invariant
# (mentions "no writes" for documentation; not an actual write)
# - This test file (which mentions File.write etc. in its docstring)
@write_to_l1_exclusions [
"lib/vav_pipeline/l1_reader.ex",
"lib/vav_pipeline/doorpost.ex"
]
defp source_files do
Path.wildcard("#{@vav_pipeline_lib}/**/*.ex")
|> Enum.reject(fn path -> path in @write_to_l1_exclusions end)
end
# Patterns that would write to L1: any File.* mutation function
# called with a path that includes "/l1/" or starts with the
# configured mount point. We grep for the function names + a path
# that suggests L1; precise enough to catch accidents and false-
# positive on legitimate writes to other paths is unlikely because
# most file-mutation calls are explicit about their target.
@l1_write_patterns [
~r/File\.write[!]?\s*\([^)]*l1\//,
~r/File\.cp[!]?\s*\([^)]*l1\//,
~r/File\.cp_r[!]?\s*\([^)]*l1\//,
~r/File\.rm[!]?\s*\([^)]*l1\//,
~r/File\.rm_rf[!]?\s*\([^)]*l1\//,
~r/File\.rename[!]?\s*\([^)]*l1\//,
~r/File\.touch[!]?\s*\([^)]*l1\//,
~r/File\.mkdir[!]?\s*\([^)]*l1\//,
~r/File\.mkdir_p[!]?\s*\([^)]*l1\//,
~r/File\.open\s*\([^)]*l1\/.*\[[^\]]*:write/
]
test "no Elixir module writes to the L1 mount" do
offenders =
for path <- source_files(),
text = File.read!(path),
pattern <- @l1_write_patterns,
match = Regex.scan(pattern, text),
match != [] do
{path, inspect(pattern)}
end
assert offenders == [], (
"L1 write detected in: #{inspect(offenders)}. The source is " <>
"external and inviolable (Devarim 4:2 lo tosif/lo tigra; " <>
"Vayikra 22:31 u'shmartem … va'asitem — keep and do, do not " <>
"author). L1 is read-only by architectural commitment. Mount " <>
"permissions defend at the filesystem layer; this CI invariant " <>
"defends in code so future contributors cannot bypass."
)
end
test "no Python module in korban_processor writes to L1" do
py_paths =
Path.wildcard("#{@korban_processor}/**/*.py")
|> Enum.reject(fn p -> String.contains?(p, "/test") end)
py_l1_write_patterns = [
~r/open\s*\([^)]*l1\/[^)]*['"]w/,
~r/Path\([^)]*l1\/[^)]*\)\.write/,
~r/shutil\.(copy|move|rmtree)\s*\([^)]*l1\//,
~r/os\.(remove|rename|mkdir)\s*\([^)]*l1\//
]
offenders =
for path <- py_paths,
text = File.read!(path),
pattern <- py_l1_write_patterns,
match = Regex.scan(pattern, text),
match != [] do
{path, inspect(pattern)}
end
assert offenders == []
end
test "no Python module in azazel_processor writes to L1" do
py_paths =
Path.wildcard("#{@azazel_processor}/**/*.py")
|> Enum.reject(fn p -> String.contains?(p, "/test") end)
offenders =
for path <- py_paths,
text = File.read!(path),
String.contains?(text, "l1/") and
(String.contains?(text, "open(") and String.contains?(text, "'w'")) do
path
end
assert offenders == []
end
test "no Prolog module asserts into L1 facts" do
pl_paths =
Path.wildcard("../talmudic_engine/src/**/*.pl")
# Prolog can't easily write to a filesystem; the relevant
# bypass shape is asserta/assertz to L1-shape predicates.
# The L1-shape predicates (verse/5, mitzvah/4, etc.) live in
# specification/ and are loaded as facts; assertions FROM
# outside specification/ that would mutate them is the
# architectural breach.
offenders =
for path <- pl_paths,
not String.contains?(path, "/specification/"),
not String.contains?(path, "/test/"),
text = File.read!(path),
Regex.match?(~r/assert[az]\s*\(\s*verse\s*\(/, text) or
Regex.match?(~r/assert[az]\s*\(\s*mitzvah\s*\(/, text) do
path
end
assert offenders == []
end
end