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

branch main Branches Tags History

aien-architecture-mv / tools / candidate / parity / mkcases.sh

271 lines · 23989 bytes Raw Blame History
1#!/usr/bin/env bash
2# tools/candidate/parity/mkcases.sh <repo> <outdir>: (re)build the case directories of the parity
3# corpus from scripts/testdata/cand-draft-fixture.toml, the live CAND-0/CAND-4 manifests and the
4# recipes of the two test suites, plus the adversarial cases. The committed cases/ were made by
5# this script; expected/ was then recorded with run.sh ... record from the bash checkers at
6# 1dd84d1 (git show 1dd84d1:scripts/check_candidate.sh), which the .om binaries must reproduce.
7# Each case is a directory: m.toml (+ amendments, files/), optional `args` (one arg per line,
8# default "m.toml"), `mode` (sha | shawords | emptysha | gh | files | fileswords, see run.sh) and
9# optional `limit` (a named difference from the bash; README "Limits").
10set -eu
11repo="$1"; out="$2"
12good="$repo/scripts/testdata/cand-draft-fixture.toml"
13live0="$repo/qualification/candidates/CAND-0.toml"
14live4src="$repo/qualification/candidates/CAND-4.toml"
15H64a=$(printf 'a%.0s' $(seq 64)); H64b=$(printf 'b%.0s' $(seq 64)); H64c=$(printf 'c%.0s' $(seq 64)); Z64=$(printf '0%.0s' $(seq 64))
16rm -rf "$out"; mkdir -p "$out/candidate" "$out/pins"
17# The live manifests are frozen records naming the build host and its home directory. The corpus
18# copies them with a synthetic home (/home/alice) and host name (spark); nothing the checkers judge
19# reads those two values, and CAND-4's amendment is re-pointed at the copy's own sha256 below.
20synth() { sed -e 's#/home/[a-z]*/#/home/alice/#g' -e 's/"spark-[0-9a-f]\{4\}, /"spark, /' "$1"; }
21live="$out/live-cand0.toml"; synth "$live0" > "$live"
22live4="$out/live-cand4.toml"; synth "$live4src" > "$live4"
23C="$out/candidate"
24mk() { mkdir -p "$C/$1"; echo "${2:-sha}" > "$C/$1/mode"; }
25frozen() { sed -e 's/^status = .*/status = "frozen"/' -e "s/^omega-runtime = .*/omega-runtime = \"$H64a\"/" \
26 -e "s/^aienos-boot-image = .*/aienos-boot-image = \"$H64b\"/" -e "s/^aien-proof = .*/aien-proof = \"$H64c\"/" "$good"; }
27mk good; cp "$good" "$C/good/m.toml"
28mk missing-omega; sed '/^omega = /d' "$good" > "$C/missing-omega/m.toml"
29mk missing-id; sed 's/^id = .*//' "$good" > "$C/missing-id/m.toml"
30mk short-sha; sed 's/^omega = .*/omega = "abc123"/' "$good" > "$C/short-sha/m.toml"
31mk nonexistent-sha; sed 's/^aienos = .*/aienos = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"/' "$good" > "$C/nonexistent-sha/m.toml"
32mk frozen-unbuilt; sed 's/^status = .*/status = "frozen"/' "$good" > "$C/frozen-unbuilt/m.toml"
33mk no-executables; sed '/^omega-runtime/d;/^aienos-boot/d;/^aien-proof =/d' "$good" > "$C/no-executables/m.toml"
34mk frozen-ok; frozen > "$C/frozen-ok/m.toml"
35mk zero-digest-frozen; frozen | sed "s/^aien-proof = .*/aien-proof = \"$Z64\"/" > "$C/zero-digest-frozen/m.toml"
36mk zero-digest-draft; sed "s/^aien-proof = .*/aien-proof = \"$Z64\"/" "$good" > "$C/zero-digest-draft/m.toml"
37mk hash-in-digest; frozen | sed "s/^aien-proof = .*/aien-proof = \"${H64c}#frag\"/" > "$C/hash-in-digest/m.toml"
38mk hash-in-note; sed 's/^note = .*/note = "issue #5 and #6" # trailing comment/' "$good" > "$C/hash-in-note/m.toml"
39mk missing-crumb-spec; sed '/^crumb-spec = /d' "$good" > "$C/missing-crumb-spec/m.toml"
40mk missing-spark-crumbs; sed '/^spark-crumbs = /d' "$good" > "$C/missing-spark-crumbs/m.toml"
41mk nonexistent-spark-crumbs; sed 's/^spark-crumbs = .*/spark-crumbs = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"/' "$good" > "$C/nonexistent-spark-crumbs/m.toml"
42mk short-crumb-spec; sed 's/^crumb-spec = .*/crumb-spec = "abc"/' "$good" > "$C/short-crumb-spec/m.toml"
43mk gh-good gh; cp "$good" "$C/gh-good/m.toml"
44mk gh-404 gh; cp "$C/nonexistent-sha/m.toml" "$C/gh-404/m.toml"
45mk gh-404-contract gh; cp "$C/nonexistent-spark-crumbs/m.toml" "$C/gh-404-contract/m.toml"
46mk live-cand0; cp "$live" "$C/live-cand0/m.toml"
47mk gh-live-cand0 gh; cp "$live" "$C/gh-live-cand0/m.toml"
48mk short-physics; sed 's/^physics = .*/physics = "abc123"/' "$live" > "$C/short-physics/m.toml"
49mk nonexistent-interplane; sed 's/^interplane = .*/interplane = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"/' "$live" > "$C/nonexistent-interplane/m.toml"
50mk frozen-live-unbuilt; sed 's/^omega-runtime = .*/omega-runtime = "UNBUILT"/' "$live" > "$C/frozen-live-unbuilt/m.toml"
51# amendments
52amend() { # amend <dir> <n> <manifest-sha> [extra line...]
53 local d="$1" n="$2" s="$3"; shift 3
54 { printf 'schema = "CandidateAmendmentV1"\ncandidate = "CAND-0"\namendment = "%s"\ndate = "2026-10-06"\nreason = "test"\nmanifest-sha256 = "%s"\n\n[model]\n' "$n" "$s"
55 printf 'oracle-fixture-safetensors-sha256 = "%s"\n' "$H64a"; for l in "$@"; do printf '%s\n' "$l"; done; } > "$d/m.amendment-$n.toml"
56}
57cx() { frozen; printf '\n[model]\nmodel-id = "m"\n'; }
58cx > /tmp/cx.$$; MSHA=$(sha256sum /tmp/cx.$$ | cut -d' ' -f1)
59am() { mk "$1"; cp /tmp/cx.$$ "$C/$1/m.toml"; }
60am amend-valid; amend "$C/amend-valid" 1 "$MSHA"
61am amend-zero-digest; amend "$C/amend-zero-digest" 1 "$MSHA" "tokenizer-json-sha256 = \"$Z64\""
62am amend-edited; amend "$C/amend-edited" 1 "$MSHA"; echo '# edited after the freeze' >> "$C/amend-edited/m.toml"
63am amend-executables; amend "$C/amend-executables" 1 "$MSHA" "[executables]" "omega-runtime = \"$H64b\""
64am amend-commits; amend "$C/amend-commits" 1 "$MSHA" "[commits]" "physics = \"0123456789012345678901234567890123456789\""
65am amend-override; amend "$C/amend-override" 1 "$MSHA" "model-id = \"other\""
66am amend-wrong-candidate; amend "$C/amend-wrong-candidate" 1 "$MSHA"; sed -i 's/^candidate = .*/candidate = "CAND-9"/' "$C/amend-wrong-candidate/m.amendment-1.toml"
67am amend-wrong-number; amend "$C/amend-wrong-number" 1 "$MSHA"; sed -i 's/^amendment = .*/amendment = "2"/' "$C/amend-wrong-number/m.amendment-1.toml"
68am amend-two; amend "$C/amend-two" 1 "$MSHA"; amend "$C/amend-two" 2 "$MSHA" "[model]" "extra-sha256 = \"$H64b\""; sed -i 's/^amendment = "2"/amendment = "2"/' "$C/amend-two/m.amendment-2.toml"
69am amend-no-keys; amend "$C/amend-no-keys" 1 "$MSHA"; sed -i '/oracle-fixture/d' "$C/amend-no-keys/m.amendment-1.toml"
70am amend-unknown-top; amend "$C/amend-unknown-top" 1 "$MSHA"; printf 'stray = "x"\nother = "y"\nthird = "z"\n' >> "$C/amend-unknown-top/m.amendment-1.toml"
71am amend-bad-schema; amend "$C/amend-bad-schema" 1 "$MSHA"; sed -i 's/^schema = .*/schema = "Nope"/;/^date = /d' "$C/amend-bad-schema/m.amendment-1.toml"
72am amend-dir-skipped; amend "$C/amend-dir-skipped" 1 "$MSHA"; mkdir -p "$C/amend-dir-skipped/m.amendment-7.toml"; : > "$C/amend-dir-skipped/m.amendment-7.toml/.keep"
73am amend-many-bad; amend "$C/amend-many-bad" 1 "$MSHA" "[model]" $(for i in $(seq 1 24); do printf 'k%02d-sha256 = "zz"\n' $i; done | tr '\n' ' ') "[contracts]" 'x = "1"' "[consumed_pins]" 'y = "2"' 'model-id = "dup"' ; sed -i 's/ k\([0-9]*\)-sha256 = "zz"/\nk\1-sha256 = "zz"/g' "$C/amend-many-bad/m.amendment-1.toml"
74am amend-sha-not-real; amend "$C/amend-sha-not-real" 1 "$MSHA" "a-sha256 = \"abc\"" "b-sha256 = \"$Z64\"" "c-sha256 = \"$H64c\""
75am amend-order; for n in 1 2 10; do amend "$C/amend-order" $n "$MSHA"; sed -i 's/^candidate = .*/candidate = "CAND-X"/' "$C/amend-order/m.amendment-$n.toml"; done; echo "bash globs <stem>.amendment-*.toml in the locale's collation (en_US: 10, 1, 2); the .om walks the names in byte order (1, 10, 2); only the order of FAIL lines of several amendments differs" > "$C/amend-order/limit"
76mk live-cand4; cp "$live4" "$C/live-cand4/m.toml"
77sed "s/^manifest-sha256 = \"[0-9a-f]*\" # CAND-4.toml at /manifest-sha256 = \"$(sha256sum "$live4" | cut -d' ' -f1)\" # synthetic-host copy of CAND-4.toml at /" \
78 "$repo/qualification/candidates/CAND-4.amendment-1.toml" > "$C/live-cand4/m.amendment-1.toml"
79rm -f "$live" "$live4"
80# adversarial
81mk dup-key; { cat "$good"; printf '\n[commits]\nomega = "abc"\nid = "later"\n'; } > "$C/dup-key/m.toml"
82mk dup-key-section; sed 's/^id = .*/id = "first"\nid = "second"/' "$good" > "$C/dup-key-section/m.toml"; sed -i 's/^aien-proof = .*/aien-proof = "UNBUILT"\naien-proof = "zz"/' "$C/dup-key-section/m.toml"
83mk wrong-type; sed 's/^status = .*/status = frozen/; s/^created = .*/created = 2026/; s/^omega-runtime = .*/omega-runtime = [1, 2]/' "$good" > "$C/wrong-type/m.toml"
84mk wrong-type-amend; cp /tmp/cx.$$ "$C/wrong-type-amend/m.toml"; amend "$C/wrong-type-amend" 1 "$MSHA"; sed -i 's/^amendment = .*/amendment = 1/' "$C/wrong-type-amend/m.amendment-1.toml"
85mk extra-section; { cat "$good"; printf '\n[extra]\nfoo = "bar"\n[[array]]\nx = "y"\n[executables.sub]\nz = "UNBUILT"\n'; } > "$C/extra-section/m.toml"
86mk crlf; sed 's/$/\r/' "$good" > "$C/crlf/m.toml"
87mk crlf-amend; sed 's/$/\r/' /tmp/cx.$$ > "$C/crlf-amend/m.toml"; amend "$C/crlf-amend" 1 "$(sha256sum "$C/crlf-amend/m.toml" | cut -d' ' -f1)"; sed -i 's/$/\r/' "$C/crlf-amend/m.amendment-1.toml"
88mk trailing-space; sed 's/^\(\[[a-z]*\]\)$/\1 /; s/^\(schema = ".*"\)$/\1 \t /; s/^\(omega = ".*"\)$/ \1 /' "$good" > "$C/trailing-space/m.toml"
89mk no-final-newline; printf '%s' "$(cat "$good")" > "$C/no-final-newline/m.toml"
90mk no-final-newline-exe; { sed '/^aien-proof = /d' "$good"; printf 'aien-proof = "UNBUILT"'; } > "$C/no-final-newline-exe/m.toml"
91mk nul-byte; { printf 'id = "CA\0ND-0"\n'; sed '/^id = /d' "$good"; } > "$C/nul-byte/m.toml"
92mk non-ascii; { printf 'note = "caf\xc3\xa9"\nnote2 = "caf\xe9 raw"\n'; sed 's/^id = .*/id = "CAND-caf\xc3\xa9"/' "$good"; } > "$C/non-ascii/m.toml"
93mk non-ascii-invalid; sed 's/^id = .*/id = "CAND-\xe9"/; s/^created = .*/created = "2026" # \xe9/' "$good" > "$C/non-ascii-invalid/m.toml"; echo "bash under a UTF-8 LANG refuses the regex on invalid UTF-8; the .om matches bytes" > "$C/non-ascii-invalid/limit"
94mk non-ascii-space; sed 's/^status = .*/status = "draft, not frozen"\xe2\x80\x83/' "$good" > "$C/non-ascii-space/m.toml"; echo "bash under a UTF-8 LANG counts U+2003 (any iswspace character) as [[:space:]]; the .om knows the six ASCII spaces only" > "$C/non-ascii-space/limit"
95mk non-ascii-nbsp; sed 's/^status = .*/status = "draft, not frozen"\xc2\xa0/' "$good" > "$C/non-ascii-nbsp/m.toml"
96mk empty-value; sed 's/^id = .*/id = ""/; s/^status = .*/status = ""/' "$good" > "$C/empty-value/m.toml"
97mk junk-lines; { printf ' # leading comment\n\t[commits] junk\nkey = "v" junk\n= "x"\n[]\n[bad key]\nkey = "unterminated\nkey == "v"\n'; cat "$good"; printf '[ spaced ]\n [tail] # c\nzzz = "1"\n'; } > "$C/junk-lines/m.toml"
98mk compact; sed 's/ = /=/' "$good" > "$C/compact/m.toml"
99mk many-exe-bad; { cat "$good"; printf '[executables]\n'; for i in $(seq 1 40); do printf 'bin-%02d = "nope%d"\n' $i $i; done; for i in $(seq 1 10); do printf 'img-%02d = "UNBUILT"\n' $i; done; } | sed 's/^status = .*/status = "frozen"/' > "$C/many-exe-bad/m.toml"
100mk many-exe-ok; { cat "$good"; printf '[executables]\n'; for i in $(seq 1 200); do printf 'bin-%03d = "UNBUILT"\n' $i; done; } > "$C/many-exe-ok/m.toml"
101mk empty-file; : > "$C/empty-file/m.toml"
102mk only-comments; printf '# a\n\n # b\n' > "$C/only-comments/m.toml"
103mk no-arg; cp "$good" "$C/no-arg/m.toml"; : > "$C/no-arg/args"
104mk missing-file; printf 'nope.toml\n' > "$C/missing-file/args"
105mk dir-arg; mkdir -p "$C/dir-arg/d.toml"; : > "$C/dir-arg/d.toml/.keep"; printf 'd.toml\n' > "$C/dir-arg/args"
106mk subdir-path; mkdir -p "$C/subdir-path/sub"; cp /tmp/cx.$$ "$C/subdir-path/sub/m.toml"; (cd "$C/subdir-path/sub" && amend . 1 "$MSHA"); printf 'sub/m.toml\n' > "$C/subdir-path/args"
107mk dotslash-path; cp /tmp/cx.$$ "$C/dotslash-path/m.toml"; amend "$C/dotslash-path" 1 "$MSHA"; printf './m.toml\n' > "$C/dotslash-path/args"
108mk stem-no-toml; cp /tmp/cx.$$ "$C/stem-no-toml/m.txt"; amend "$C/stem-no-toml" 1 "$MSHA"; mv "$C/stem-no-toml/m.amendment-1.toml" "$C/stem-no-toml/m.txt.amendment-1.toml"; printf 'm.txt\n' > "$C/stem-no-toml/args"
109mk sha-check-words; cp "$good" "$C/sha-check-words/m.toml"; echo "shawords" > "$C/sha-check-words/mode"
110mk status-superseded; sed 's/^status = .*/status = "superseded"/' "$C/frozen-ok/m.toml" > "$C/status-superseded/m.toml"
111mk status-bad; sed 's/^status = .*/status = "final"/' "$good" > "$C/status-bad/m.toml"
112mk uppercase-sha; sed 's/^omega = .*/omega = "25B4A51141FA48BE01D1CDBAC8617D41065E523D"/' "$good" > "$C/uppercase-sha/m.toml"
113mk sha-check-unset-empty; cp "$good" "$C/sha-check-unset-empty/m.toml"; echo "emptysha" > "$C/sha-check-unset-empty/mode"
114rm -f /tmp/cx.$$ /tmp/nul.$$
115
116# ---------------- pins ----------------
117P="$out/pins"
118OM=1111111111111111111111111111111111111111; SC=2222222222222222222222222222222222222222
119AO=3333333333333333333333333333333333333333; PH=4444444444444444444444444444444444444444
120PR=5555555555555555555555555555555555555555; CS=6666666666666666666666666666666666666666
121SP=7777777777777777777777777777777777777777; AR=8888888888888888888888888888888888888888
122OTHER=9999999999999999999999999999999999999999
123serve() { mkdir -p "$(dirname "$cur/files/$1")"; cat > "$cur/files/$1"; }
124tree() {
125 rm -rf "$cur/files"
126 echo "$OM" | serve "aien-sovereign-core/$SC/omega.lock"
127 serve "aien-sovereign-core/$SC/Cargo.lock" <<L
128[[package]]
129name = "aien-protocol-types"
130source = "git+https://github.com/aien-dev/aien-protocols?rev=$PR#$PR"
131
132[[package]]
133name = "aien-probe"
134source = "git+https://github.com/aien-dev/aien-protocols?rev=$PR#$PR"
135
136[[package]]
137name = "crumb-spec"
138source = "git+https://github.com/aien-dev/crumb-spec?rev=$CS#$CS"
139
140[[package]]
141name = "spark-crumbs"
142source = "git+https://github.com/aien-dev/spark-crumbs?rev=$SP#$SP"
143
144[[package]]
145name = "serde"
146source = "registry+https://github.com/rust-lang/crates.io-index"
147L
148 echo "$PH" | serve "omega/$OM/physics.lock"
149 echo "$AO" | serve "omega/$OM/aienos.lock"
150 printf '%s\n# argus pin, comment with no hex\n' "$AR" | serve "omega/$OM/argus.lock"
151}
152manifest() {
153 cat > "$1" <<M
154schema = "CandidateManifestV1"
155id = "CAND-T"
156[commits]
157omega = "$OM"
158aienos = "$AO"
159aien-sovereign-core = "$SC"
160aien-protocols = "$PR"
161physics = "$PH"
162[contracts]
163crumb-spec = "$CS"
164spark-crumbs = "$SP"
165[consumed_pins]
166sovereign-core-omega-lock = "$OM"
167sovereign-core-cargo-lock-aien-protocols = "$PR"
168omega-physics-lock = "$PH"
169omega-aienos-lock = "$AO"
170omega-argus-lock = "$AR"
171something-else = "not read"
172M
173}
174pk() { cur="$P/$1"; mkdir -p "$cur"; echo files > "$cur/mode"; tree; manifest "$cur/m.toml"; }
175pk agree
176pk contract-other; sed -i "s/^crumb-spec = .*/crumb-spec = \"$OTHER\"/" "$cur/m.toml"
177pk protocols-other; sed -i "s/^aien-protocols = .*/aien-protocols = \"$OTHER\"/" "$cur/m.toml"
178pk aienos-other; sed -i "s/^aienos = .*/aienos = \"$OTHER\"/" "$cur/m.toml"
179pk physics-other; sed -i "s/^physics = .*/physics = \"$OTHER\"/" "$cur/m.toml"
180pk consumed-other; sed -i "s/^omega-argus-lock = .*/omega-argus-lock = \"$OTHER\"/" "$cur/m.toml"
181pk physics-unpinned; sed -i '/^physics = /d;/^omega-physics-lock/d' "$cur/m.toml"
182pk contract-missing; sed -i '/^spark-crumbs = /d' "$cur/m.toml"
183pk omega-lock-elsewhere; echo "$OTHER" | serve "aien-sovereign-core/$SC/omega.lock"
184pk cargo-unreadable; rm "$cur/files/aien-sovereign-core/$SC/Cargo.lock"
185pk aienos-unreadable; rm "$cur/files/omega/$OM/aienos.lock"
186pk two-revisions; printf '\n[[package]]\nname = "crumb-spec-extra"\nsource = "git+https://github.com/aien-dev/crumb-spec?rev=%s#%s"\n' "$OTHER" "$OTHER" >> "$cur/files/aien-sovereign-core/$SC/Cargo.lock"
187pk fork-name; sed -i "s/crumb-spec?rev=$CS#$CS/crumb-spec-fork?rev=$CS#$CS/" "$cur/files/aien-sovereign-core/$SC/Cargo.lock"
188pk error-body-ref; rm "$cur/files/omega/$OM/argus.lock"; sed -i "s/^omega-argus-lock = .*/omega-argus-lock = \"$OM\"/" "$cur/m.toml"
189pk leading-comment; printf '# pinned after %s\n%s\n' "$OTHER" "$AO" | serve "omega/$OM/aienos.lock"
190pk trailing-words; printf '%s %s\n' "$AO" "trailing words" | serve "omega/$OM/aienos.lock"
191pk no-sovereign; sed -i '/^aien-sovereign-core = /d' "$cur/m.toml"
192pk no-omega; sed -i '/^omega = /d' "$cur/m.toml"
193# adversarial
194pk three-revisions; printf '\n[[package]]\nname = "x"\nsource = "git+https://github.com/aien-dev/crumb-spec.git#%s"\n[[package]]\nname = "y"\nsource = "git+https://github.com/aien-dev/crumb-spec?branch=main#%s"\n' "$OTHER" "$OM" >> "$cur/files/aien-sovereign-core/$SC/Cargo.lock"
195pk omega-lock-empty; : > "$cur/files/aien-sovereign-core/$SC/omega.lock"
196pk omega-lock-comments-only; printf '# c\n\n # d\n' > "$cur/files/aien-sovereign-core/$SC/omega.lock"
197pk lock-crlf; printf '%s\r\n' "$OM" > "$cur/files/aien-sovereign-core/$SC/omega.lock"; printf ' %s \n' "$AO" > "$cur/files/omega/$OM/aienos.lock"
198pk lock-no-newline; printf '%s' "$PH" > "$cur/files/omega/$OM/physics.lock"
199pk lock-uppercase; printf '%s\n' "$(echo $PH | tr a-f A-F)" > "$cur/files/omega/$OM/physics.lock"; sed -i "s/^physics = .*/physics = \"AAAA\"/" "$cur/m.toml"
200pk cargo-empty; : > "$cur/files/aien-sovereign-core/$SC/Cargo.lock"
201pk cargo-crlf; sed -i 's/$/\r/' "$cur/files/aien-sovereign-core/$SC/Cargo.lock"
202pk cargo-two-on-line; printf '\n[[package]]\nname = "x"\nsource = "git+https://github.com/aien-dev/spark-crumbs?rev=%s#%s" # %s"\n' "$SP" "$SP" "$OTHER" >> "$cur/files/aien-sovereign-core/$SC/Cargo.lock"
203pk manifest-crlf; sed -i 's/$/\r/' "$cur/m.toml"
204pk dup-consumed; printf 'omega-argus-lock = "%s"\n' "$OTHER" >> "$cur/m.toml"
205pk many-consumed; for i in $(seq 1 30); do printf 'extra-%02d = "x"\n' $i >> "$cur/m.toml"; done; printf 'sovereign-core-omega-lock = "%s"\n' "$OTHER" >> "$cur/m.toml"
206pk all-unreadable; rm -rf "$cur/files"
207pk wrong-type; sed -i 's/^aienos = .*/aienos = 3/' "$cur/m.toml"
208pk extra-section; printf '[extra]\nfoo = "bar"\n[consumed_pins.sub]\nomega-argus-lock = "x"\n' >> "$cur/m.toml"
209pk no-arg; : > "$cur/args"
210pk missing-file; printf 'nope.toml\n' > "$cur/args"
211pk physics-pinned-unreadable; rm "$cur/files/omega/$OM/physics.lock"
212pk consumed-empty-value; sed -i 's/^omega-argus-lock = .*/omega-argus-lock = ""/' "$cur/m.toml"
213pk lock-leading-blank; printf '\n\n %s \n' "$OM" > "$cur/files/aien-sovereign-core/$SC/omega.lock"
214pk lock-ws-only; printf ' \n\t\n' > "$cur/files/aien-sovereign-core/$SC/omega.lock"
215pk lock-nul; printf '%s\0\n' "$OM" > "$cur/files/aien-sovereign-core/$SC/omega.lock"; echo "bash prints 'warning: command substitution: ignored null byte in input' on stderr when a fetched file holds a NUL byte; the .om drops the byte silently" > "$cur/limit"
216pk cargo-big; for i in $(seq 1 800); do printf '[[package]]\nname = "pad-%d"\nsource = "registry+https://github.com/rust-lang/crates.io-index"\n\n' $i; done >> "$cur/files/aien-sovereign-core/$SC/Cargo.lock"
217pk cargo-dotgit-and-hash; sed -i "s|aien-protocols?rev=$PR#$PR|aien-protocols.git#$PR|" "$cur/files/aien-sovereign-core/$SC/Cargo.lock"
218pk file-at-words; echo fileswords > "$cur/mode"
219# ---------------- extension cases (after the bash: -mv sources, in-tree contracts; DRA-46) ----------------
220# The bash oracle never read aien-dev/<name>-mv sources or in-tree contracts, so these cases have no frozen
221# output: their expected files are recorded with run.sh ... record-extensions and reviewed by hand (README
222# "Extension cases"). The `extension` file says what each one pins.
223px() { pk "$1"; printf '%s\n' "$2" > "$cur/extension"; }
224lockf() { printf '%s' "$cur/files/aien-sovereign-core/$SC/Cargo.lock"; }
225intree() { # the spark-crumbs package becomes a path package (no source line); the manifest states it
226 sed -i "/spark-crumbs?rev=$SP#$SP/d" "$(lockf)"; sed -i 's/^spark-crumbs = .*/&\nspark-crumbs-consumed = "in-tree"/' "$cur/m.toml"; }
227px mv-agree "every Cargo.lock pin consumed under its -mv name (aien-protocols-mv, crumb-spec-mv, spark-crumbs-mv.git) agrees"
228sed -i -e 's|aien-dev/aien-protocols?|aien-dev/aien-protocols-mv?|' -e 's|aien-dev/crumb-spec?|aien-dev/crumb-spec-mv?|' -e 's|aien-dev/spark-crumbs?|aien-dev/spark-crumbs-mv.git?|' "$(lockf)"
229px mv-other "aien-protocols-mv at a revision the manifest does not pin is refused"
230sed -i "s|aien-protocols?rev=$PR#$PR|aien-protocols-mv?rev=$OTHER#$OTHER|" "$(lockf)"
231px mv-two-names "the old and the -mv name at two revisions are one pin with several revisions: refused"
232printf '\n[[package]]\nname = "aien-provenance"\nsource = "git+https://github.com/aien-dev/aien-protocols-mv?rev=%s#%s"\n' "$OTHER" "$OTHER" >> "$(lockf)"
233px mv-two-names-same "the old and the -mv name at the same revision are one revision: agrees"
234printf '\n[[package]]\nname = "aien-provenance"\nsource = "git+https://github.com/aien-dev/aien-protocols-mv?rev=%s#%s"\n' "$PR" "$PR" >> "$(lockf)"
235px mv-prefix "a repo named <name>-mvx is neither the repo nor its -mv name: no revision"
236sed -i 's|aien-dev/crumb-spec?|aien-dev/crumb-spec-mvx?|' "$(lockf)"
237px intree-agree "contracts.spark-crumbs-consumed = \"in-tree\" with a path package spark-crumbs and no git source agrees"
238intree
239px intree-eof "the in-tree path package is the last block of Cargo.lock (closed by the end of the file)"
240intree; head -n -4 "$(lockf)" > "$cur/l.tmp"; mv "$cur/l.tmp" "$(lockf)"
241px intree-crlf "the in-tree check on a CRLF Cargo.lock"
242intree; sed -i 's/$/\r/' "$(lockf)"
243px intree-crumb-spec "both contracts stated in-tree, each with its path package"
244intree; sed -i "/crumb-spec?rev=$CS#$CS/d" "$(lockf)"; sed -i 's/^crumb-spec = .*/&\ncrumb-spec-consumed = "in-tree"/' "$cur/m.toml"
245px intree-undeclared "a path package spark-crumbs the manifest does not state as in-tree: refused, naming the in-tree key"
246sed -i "/spark-crumbs?rev=$SP#$SP/d" "$(lockf)"
247px intree-git-source "in-tree stated, but Cargo.lock also has a git source for spark-crumbs: refused"
248intree; printf '\n[[package]]\nname = "spark-crumbs"\nversion = "0.0.9"\nsource = "git+https://github.com/aien-dev/spark-crumbs?rev=%s#%s"\n' "$OTHER" "$OTHER" >> "$(lockf)"
249px intree-mv-git-source "in-tree stated, but Cargo.lock has a git source under the -mv name: refused"
250intree; printf '\n[[package]]\nname = "spark-crumbs-mv-copy"\nsource = "git+https://github.com/aien-dev/spark-crumbs-mv?rev=%s#%s"\n' "$SP" "$SP" >> "$(lockf)"
251px intree-no-package "in-tree stated, but no package of that name (only spark-crumbs-extra): refused"
252intree; sed -i 's/^name = "spark-crumbs"$/name = "spark-crumbs-extra"/' "$(lockf)"
253px intree-registry "in-tree stated, but the package of that name has a (registry) source line: refused"
254sed -i "s|^source = \"git+https://github.com/aien-dev/spark-crumbs?rev=$SP#$SP\"|source = \"registry+https://github.com/rust-lang/crates.io-index\"|" "$(lockf)"; sed -i 's/^spark-crumbs = .*/&\nspark-crumbs-consumed = "in-tree"/' "$cur/m.toml"
255px intree-word "a -consumed value other than \"in-tree\" is refused"
256intree; sed -i 's/^spark-crumbs-consumed = .*/spark-crumbs-consumed = "intree"/' "$cur/m.toml"
257px intree-empty-value "an empty -consumed value is refused, not read as unset"
258intree; sed -i 's/^spark-crumbs-consumed = .*/spark-crumbs-consumed = ""/' "$cur/m.toml"
259px intree-protocols-key "there is no in-tree form for [commits] aien-protocols: a commits.aien-protocols-consumed key is ignored"
260sed -i "/aien-protocols?rev=$PR#$PR/d" "$(lockf)"; sed -i 's/^aien-protocols = .*/&\naien-protocols-consumed = "in-tree"/' "$cur/m.toml"
261# The live CAND-5 manifest with the lock files of its pinned commits (scripts/testdata/cand5-locks: sovereign-core
262# dffdbd19 omega.lock and Cargo.lock, omega f9a9a40 aienos.lock, physics.lock, argus.lock, byte copies of those
263# git blobs). It names exactly one difference, spark-crumbs; the -intree copy adds the key a later manifest states.
264c5="$repo/qualification/candidates/CAND-5.toml"
265c5files() { # one copy of the real lock files: the case's files/ is a relative symlink to scripts/testdata/cand5-locks
266 ln -s "$(realpath --relative-to="$cur" "$repo/scripts/testdata/cand5-locks")" "$cur/files"; }
267px live-cand5 "the frozen CAND-5 manifest and its real lock files: only spark-crumbs differs (built in-tree; CAND-5 cannot state it)"
268synth "$c5" > "$cur/m.toml"; rm -r "$cur/files"; c5files
269px live-cand5-intree "CAND-5 plus contracts.spark-crumbs-consumed = \"in-tree\" (the form for later candidates) and its real lock files: agrees"
270synth "$c5" | sed 's/^spark-crumbs = .*/&\nspark-crumbs-consumed = "in-tree"/' > "$cur/m.toml"; rm -r "$cur/files"; c5files
271echo "cases: $(ls "$C" | wc -l) candidate, $(ls "$P" | wc -l) pins"