interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

fix(candidate): bind amendment digests to raw manifest bytes

merged 2328c79ce64884c5 #325 · opened 2026-10-25 04:30 UTC · closed 2026-10-30 02:47 UTC · merged 2026-10-30 02:47 UTC

Imported from GitHub aien-dev/aien-architecture-mv#325, by drakestapleton

Base a211260cf7a840fac19d1efed02b7208794f8ca0 · Head 440a56da3b9463d71b91a4a5ca5799880f4eaa4c

Merged on GitHub as dba13c555118964d2a08c8fa32ebc73da3c4f3ae; reachable from main bccab5ea7a17be6c9ab30b1bd05db4898a4601be (observed 2026-11-18T16:37:27Z)

drakestapleton wrote on 2026-10-25 04:30 UTC

Follow-up to #324 under #316.

Compute the frozen manifest digest before parser normalization, retaining existing parser behavior. Add positive/negative exact-byte binding checks and a regression mutant in the existing suite.

Verification

  • Independent source review complete against #324 head ba140d2b3414fe7d85e976554d8ca9b9db75fc82 and the previous shell implementation.
  • Native compiler/suite execution: NOT_RUN because the execution workspace is unavailable. The updated suite contains 51 checks / 8 mutants; these counts are expectations, not passing receipts.
  • Existing #324 receipts apply only to ba140d2, not this repair.

Draft only; no deployment, merge, live hardware experiment or gate changes. Existing migration work is preserved.

Apply it

git checkout -b patch-2328c79ce64884c5 a211260cf7a840fac19d1efed02b7208794f8ca0
curl -fsSL https://interplane.io/drakestapleton/aien-architecture-mv/patches/2328c79ce64884c5.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-architecture-mv
325
440a56da3b9463d71b91a4a5ca5799880f4eaa4c
{"kind":"github-import","owner":"aien-dev","repo":"aien-architecture-mv","number":325,"url":"https://github.com/aien-dev/aien-architecture-mv/pull/325","export_sha256":"e0ab76730762f7bd707f3b0c07e133f83d4287854fada828261004f8d4bcaa1a","imported_utc":"2026-11-18T16:37:27Z"}

Changes

diff --git a/scripts/test_check_candidate.sh b/scripts/test_check_candidate.sh
index 36467c4..18e8115 100755
--- a/scripts/test_check_candidate.sh
+++ b/scripts/test_check_candidate.sh
@@ -98,6 +98,17 @@ amend() { # amend <n> <manifest-sha> [extra line...] : write CX.amendment-<n>.to
 MSHA=$(sha256sum "$amd/CX.toml" | cut -d' ' -f1)
 amend 1 "$MSHA";                                                expect 0 "amendment: valid amendment accepted" "$amd/CX.toml"
 "$chk" "$amd/CX.toml" 2>/dev/null | grep -q '(amendments: 1)' && pass=$((pass+1)) || { bad=$((bad+1)); echo "TEST FAIL: amendment file not picked up"; }
+# Exact-byte amendment binding: parsing may drop NUL, hashing must not.
+cp "$amd/CX.toml" "$amd/CX.raw-orig"
+printf '\0' >> "$amd/CX.toml"
+expect 1 "amendment: NUL-only frozen manifest edit refused" "$amd/CX.toml"
+cp -r "$amd" "$tmp/amdnul"  # original digest + altered bytes; retained for the mutant
+NULSHA=$(sha256sum "$amd/CX.toml" | cut -d' ' -f1)
+[ "$NULSHA" != "$MSHA" ] && pass=$((pass+1)) || { bad=$((bad+1)); echo "TEST FAIL: NUL fixture did not change raw digest"; }
+amend 1 "$NULSHA"
+expect 0 "amendment: actual raw NUL-containing manifest digest accepted" "$amd/CX.toml"
+cp "$amd/CX.raw-orig" "$amd/CX.toml"
+amend 1 "$MSHA"
 amend 1 "$MSHA" "tokenizer-json-sha256 = \"$Z64\"";             expect 1 "amendment: all-zero digest in amendment refused (file is read)" "$amd/CX.toml"
 cp "$amd/CX.toml" "$amd/CX.orig"; amend 1 "$MSHA"
 echo '# edited after the freeze' >> "$amd/CX.toml";              expect 1 "amendment: frozen manifest edited after amendment refused" "$amd/CX.toml"
@@ -131,5 +142,6 @@ mutant "optional pins not checked" '/^optpins$/d' "$tmp/p1.toml"
 mutant "optional pin sha existence not checked" '/^fn optpin /,/^fn optpins /s/^if not shaex i e$/if false/' "$tmp/p2.toml"
 mutant "manifest pin not checked" 's/^if not mfeq e$/if false/' "$amd/CX.toml"
 mutant "amendment may override" 's/^if inmf x$/if false/' "$tmp/amdov/CX.toml"
+mutant "raw manifest hash normalized" 's/^sha256$/dropnul\nsha256/' "$tmp/amdnul/CX.toml"
 echo "passed=$pass failed=$bad"
 [ "$bad" -eq 0 ]
diff --git a/tools/candidate/check_candidate.om b/tools/candidate/check_candidate.om
index 6803b7d..0d9f397 100644
--- a/tools/candidate/check_candidate.om
+++ b/tools/candidate/check_candidate.om
@@ -574,7 +574,6 @@ ret
 end
 slurpf int fd
 r = fclose int fd
-dropnul
 end
 
 fn loada to void
@@ -1783,9 +1782,11 @@ put pooln 0 0
 put failf 0 0
 put namend 0 0
 loadm
+note Bind amendments to the raw frozen file, before parser-only NUL removal.
+sha256
+dropnul
 parse 0
 put poolm 0 get pooln 0
-sha256
 for i ulong 4
 if eq vlen kfind 0 i 0
 fail0