interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / core / sovereign-core / om / golden / ollm / drive.om

3426 lines · 57892 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note om/golden/ollm/drive.om: the DRA-52 golden-token gate drivers (Core #853, PR #926). Replaces the
3note former build.sh, record.sh, gate.sh, core-gate.sh and check.sh; every sequencing step and every
4note judgment of the drivers is made here, the comparisons themselves stay in gate.om.
5note Build (from the repository root): OMC=<omc bf54b19f> bash om/golden/build.sh OUT om/golden/ollm/drive.om
6note Run from the repository root (repo files are read relative to it). Modes:
7note drive build OMC TRAIN REV OUT [NEGCTL]
8note fetches the aien-train clone TRAIN's HEAD, heads, tags and remotes (never refs/replace)
9note into a private bare repository OUT/src.git made without templates, resolves REV there to
10note one commit and snapshots it with git archive from there, so TRAIN's working tree, index
11note flags, untracked files, replace refs, info/grafts, info/attributes and config never reach
12note the build; every git child runs as /usr/bin/env GIT_CONFIG_NOSYSTEM=1
13note GIT_CONFIG_GLOBAL=/dev/null GIT_ATTR_NOSYSTEM=1 git --no-replace-objects. The commit's own
14note .gitattributes (export-ignore, export-subst) is part of the commit and applies. Builds
15note it with the snapshot's own tests/omegallm/build.sh (TARGET=gb10, OMC pinned omega-mv
16note e5b32567), appends gdec.om, optionally applies one NEGCTL (.neg) perturbation, compiles
17note OUT/ollm-golden. Prints BUILD_OK sha path source_sha256 sha commit sha.
18note drive record TRAIN REV CK MERGES PROMPTS OUT [LABEL] (env OMC_TRAIN, OMC_GATE)
19note drive gate TRAIN REV REF CK MERGES PROMPTS OUT (env OMC_TRAIN, OMC_GATE, hold)
20note resolves REV once (as build does) to a commit id, pins OUT/src.git HEAD to it; candidate and
21note negctl build that id from OUT/src.git, and each build's commit must equal it (else BROKEN)
22note drive core (tests/gates/run.sh gb10-golden-tokens; env AIEN_*)
23note drive check (host arms; env OMC_GATE, optional OMC_TRAIN and TRAIN)
24note Child programs run through execprog with an empty environment; every child path is absolute.
25note Exit: build 0 ok, 1 build failure, 3 compiler not pinned, 4 composition refused, 2 usage;
26note gate 0 PASS, 1 FAIL, 3 NOT_RUN, 4 BROKEN; core 0 PASS, 1 FAIL or BROKEN, 77 NOT_RUN.
27
28const SCAP ulong 4096
29const BCAP ulong 4194304
30const SM ulong 0
31const SOMC ulong 1
32const STRN ulong 2
33const SREV ulong 3
34const SOUT ulong 4
35const SNEG ulong 5
36const SP ulong 6
37const SQ ulong 7
38const SHEX ulong 8
39const SOMG ulong 9
40const SREF ulong 10
41const SCK ulong 11
42const SMG ulong 12
43const SPR ulong 13
44const SSHA ulong 14
45const SNB ulong 15
46const SNF ulong 16
47const SNT ulong 17
48const SV ulong 18
49const SCWD ulong 19
50const SCORE ulong 20
51const SLAB ulong 21
52const ST ulong 22
53const SG ulong 23
54const SX ulong 24
55const SY ulong 25
56const SZ ulong 26
57const SA ulong 27
58const SB ulong 28
59const SH2 ulong 29
60const SE ulong 30
61const SLK ulong 31
62const SGD ulong 32
63const SF1 ulong 33
64const SF2 ulong 34
65const SF3 ulong 35
66const SR ulong 36
67const SC2 ulong 37
68const SNW ulong 38
69const SW ulong 39
70const SLST ulong 40
71const SD ulong 41
72const SFX ulong 42
73const SMX ulong 43
74const SK ulong 44
75const SBLK ulong 45
76const SEND ulong 46
77const SPRB ulong 48
78const NPMAX ulong 64
79
80global gs uchar 524288
81global gsl ulong 128
82global gb uchar 4194304
83global gbn ulong 1
84global gc uchar 4194304
85global gcn ulong 1
86global gav uchar 65536
87global gap ulong 2
88global gwst uchar 8
89global gio uchar 65536
90global gstb uchar 256
91global gxs ulong 2
92global gk ulong 8
93
94text tlong "drive: string too long\n"
95text tuse "usage: drive build OMC TRAIN REV OUT [NEGCTL] | record TRAIN REV CK MERGES PROMPTS OUT [LABEL] | gate TRAIN REV REF CK MERGES PROMPTS OUT | core | check"
96text tbuild "build"
97text trecord "record"
98text tgate "gate"
99text tcore "core"
100text tcheck "check"
101text tself "/proc/self/exe"
102text tgit "/usr/bin/git"
103text tnorep "--no-replace-objects"
104text trepl "replace"
105text thead1 "HEAD~1"
106text tb7 "b7"
107text treplA "snapshot-replace-ref"
108text tbrp "build-under-replace-ref"
109text trpok "build-ignores-replace-ref (refs/replace/<rev> planted: source_sha256 stays clean)"
110text trpbad "build-ignores-replace-ref: a replace ref changed the built source"
111text tgenv1 "GIT_CONFIG_NOSYSTEM=1"
112text tgenv2 "GIT_CONFIG_GLOBAL=/dev/null"
113text tgenv3 "GIT_ATTR_NOSYSTEM=1"
114text tgenv4 "GIT_GRAFT_FILE=/dev/null"
115text tupk "--upload-pack=/usr/bin/env GIT_GRAFT_FILE=/dev/null GIT_NO_REPLACE_OBJECTS=1 /usr/bin/git upload-pack"
116text tprv "src.git"
117text tinit "init"
118text tbare "--bare"
119text ttmpl "--template="
120text tfetch "fetch"
121text tnotags "--no-tags"
122text tnogc "--no-auto-gc"
123text tnofh "--no-write-fetch-head"
124text trs1 "+HEAD:refs/golden/HEAD"
125text trs2 "+refs/heads/*:refs/heads/*"
126text trs3 "+refs/tags/*:refs/tags/*"
127text trs4 "+refs/remotes/*:refs/remotes/*"
128text tupref "update-ref"
129text tnoderef "--no-deref"
130text tghead "refs/golden/HEAD"
131text thead2 "HEAD~2"
132text trvo "rev.txt"
133text tgrf ".git/info/grafts"
134text tatf ".git/info/attributes"
135text texig " export-ignore\n"
136text tb8 "b8"
137text tb9 "b9"
138text tbgr "build-under-info-grafts"
139text tgrok "build-ignores-info-grafts (HEAD grafted onto HEAD~2: HEAD~1 still builds its real commit's source_sha256)"
140text tallowe "--allow-empty"
141text tgrbase "snapshot-graft-base-commit"
142text tgrbad "build-ignores-info-grafts: a graft changed the resolved commit or the built source"
143text tbat "build-under-info-attributes"
144text tatok "build-ignores-info-attributes (export-ignore planted for a composed file: source_sha256 unchanged)"
145text tatbad "build-ignores-info-attributes: an info/attributes line changed the built source"
146text tfixbad "fixture step failed: "
147text tbres "BROKEN REV resolve rc="
148text tbidc "BROKEN cand build is not the commit REV resolved to"
149text tbidn "BROKEN neg build is not the commit REV resolved to"
150text th8 "== gate REV freeze (review finding 2): both builds are the commit REV resolved to once"
151text ttg "tg"
152text tgout "gout"
153text tnoref "noref"
154text tgmv "gmove"
155text tco "checkout"
156text tdb "-b"
157text tmvl1 "/usr/bin/git --no-replace-objects -C "
158text tmvl2 " update-ref refs/heads/gmove refs/heads/gmove~1"
159text theld1 "AIEN_GB10_LOCK_HELD=1"
160text tprocp "/proc/"
161text texe "/exe"
162text tgfa "gate-under-moving-branch"
163text tgnomx "GOLDEN-GATE NOT_RUN record has no max_tokens line"
164text tgfok "gate-freezes-rev (the branch moved during the builds: cand and negctl both built the commit REV named at gate start)"
165text tgfbad "gate-freezes-rev: a build is not the commit REV named at gate start"
166text tgmok "gate-freeze-branch-moved (the fixture's build.sh moved the branch: the arm is not vacuous)"
167text tgmbad "gate-freeze-branch-moved: the branch did not move, the arm is vacuous"
168text tcinfra ": infrastructure failure, not a kill (exit "
169text tgfx1 "gate-freeze-fixture-branch"
170text tgfx2 "gate-freeze-fixture-commit"
171text ttar "/usr/bin/tar"
172text tenv "/usr/bin/env"
173text tsh "/bin/sh"
174text trm "/bin/rm"
175text tdash "-C"
176text trevp "rev-parse"
177text tverify "--verify"
178text tcommit "^{commit}"
179text tarch "archive"
180text tfmtt "--format=tar"
181text tdo "-o"
182text tdx "-x"
183text tdf "-f"
184text tdrf "-rf"
185text tpath "PATH=/usr/bin:/bin"
186text ttgt "TARGET=gb10"
187text tomceq "OMC="
188text touteq "OUT="
189text tcoreq "CORE="
190text tpintr "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f"
191text tpingt "62775d2a391cfef7cde64e387655caa9809a267093112910ec76bfa568f3712b"
192text tgdec "om/golden/ollm/gdec.om"
193text tgateom "om/golden/ollm/gate.om"
194text tjson "om/vendor/json.om"
195text tshaom "om/vendor/sha256.om"
196text tom2 "om2\n"
197text tsl "/"
198text tsp " "
199text tnl "\n"
200text tnl0 ""
201text tsrc "src"
202text tsrctar "src.tar"
203text tbsh "tests/omegallm/build.sh"
204text ttrain "train"
205text tlog "train.log"
206text tollm "ollm-gb10.om"
207text tgold "ollm-golden.om"
208text tgoldb "ollm-golden"
209text terr ".err"
210text tdotom ".om"
211text tcmt "commit"
212text tcmterr "commit.err"
213text tsltrain "/train"
214text tslbsh "/tests/omegallm/build.sh"
215text tslollm "train/ollm.om"
216text tgoldtmp "ollm-golden.tmp"
217text tomcerr "omc.err"
218text tcoreq0 "CORE"
219text tmain "fn main to int"
220text toggm "fn oggmain to int"
221text tendl "end"
222text twant "want "
223text tblock "block "
224text tfrom "from "
225text tto "to "
226text tcpus "Cpus_allowed_list:"
227text tstatus "/proc/self/status"
228text thostf "/proc/sys/kernel/hostname"
229text tnrtr "NOT_RUN: set OMC to omega-mv e5b32567 seed/out/omc"
230text tnrgt "NOT_RUN: set OMC to omega-mv bf54b19f seed/out/omc"
231text tnrsha "NOT_RUN: omc sha256 "
232text tpinned ", pinned "
233text tbfail "BUILD_FAIL aien-train build.sh: "
234text tsfail "BUILD_FAIL snapshot: "
235text tbfomc "BUILD_FAIL omc rc="
236text tmcount "MAIN_COUNT "
237text twant1 ", want 1"
238text tnowant "PERTURB_NO_WANT "
239text tpchg "PERTURB_CHANGED "
240text tlines " lines, want "
241text tbok "BUILD_OK "
242text tsrcsha " source_sha256 "
243text tcmtsp " commit "
244text tcompile "compile "
245text tcolon ": "
246text tnoroot "drive: run from the repository root (om/golden/ollm/gate.om not found)"
247text tbuildf ".build"
248text tgdecr "rc="
249text tgtcpu "gtcpu"
250text tgtgpu "gtgpu"
251text tcand "cand"
252text tnegd "negctl"
253text tnegf "om/golden/ollm/negctl/softmax-log2e.neg"
254text tgateb "gate"
255text tcmp "cmp"
256text trec "rec"
257text tref "ref.txt"
258text tout ".out"
259text tcmpx ".cmp"
260text thost "SPARK_WINDOW"
261text theld "AIEN_GB10_LOCK_HELD"
262text tone "1"
263text tomctr "OMC_TRAIN"
264text tomcgt "OMC_GATE"
265text tnohold "GOLDEN-GATE NOT_RUN no GB10 hold (run inside spark-window run, or with AIEN_GB10_LOCK_HELD=1)"
266text tngate "NOT_RUN gate compiler not pinned"
267text tndec "NOT_RUN decoder compiler not pinned"
268text tbroken "BROKEN "
269text tbrc " build rc="
270text tbgate "BROKEN gate.om build rc="
271text tnomx "NOT_RUN record has no max_tokens line"
272text tnocmp "NOT_RUN record not comparable with CK/MERGES/PROMPTS"
273text tmaxtok "max_tokens "
274text tgrc " gtgpu rc="
275text tcrc " gtcpu rc="
276text tpass "PASS candidate matches; negative control blocked"
277text tbneg "BROKEN negative control rc="
278text tbneg2 ", must be 1 (blocked)"
279text tfailv "FAIL candidate diverges from the golden record"
280text tbcmp "BROKEN candidate cmp rc="
281text texists "drive: OUT exists: "
282text tmkd "drive: cannot create "
283text trecok "RECORD_OK "
284text trecbad "RECORD_FAIL gate rec rc="
285text treal "REAL"
286text tmx "48"
287text tfl "7812500"
288text tdr "1953125"
289text tsrcp "aien-dev/aien-train@"
290text tobs "AIEN-OBS "
291text tnrr "not_run_reason"
292text tq "\""
293text tgtrain "AIEN_GOLDEN_TRAIN"
294text tgdir "AIEN_GOLDEN_DIR"
295text tmdir "AIEN_MODELS_DIR"
296text thome "HOME"
297text tmodels "/models"
298text tolg "/omega-llm-golden"
299text taomctr "AIEN_OMC_TRAIN"
300text taomcgt "AIEN_OMC_GATE"
301text tlock "om/golden/ollm/aien-train.lock"
302text trefp "om/golden/ollm/ref/r10-ck60000.ref"
303text tprp "om/golden/ollm/ref/prompts.txt"
304text tckk "ckpt_sha256 "
305text tmgk "merges_sha256 "
306text ttm "train_missing"
307text ttmw "set AIEN_GOLDEN_TRAIN to aien-train at "
308text ttu "train_unpinned"
309text ttuw "aien-train has no commit "
310text tmm "model_missing"
311text tmmw "missing "
312text tcatf "cat-file"
313text tdash_e "-e"
314text tgcore "/tmp/golden-core-"
315text tgrec "golden_record"
316text tgpass "golden_pass"
317text tgneg "negctl_blocked"
318text ttrue "true"
319text tfalse "false"
320text tgnrun "golden gate not run"
321text tbrk "BROKEN golden gate rc="
322text tcpass "PASS "
323text tcfail "FAIL "
324text tcexit " (exit "
325text tcwant ", want "
326text tcend ")"
327text tcbad "golden-ollm check: FAILED"
328text tcgood "golden-ollm check: all arms as expected"
329text tcnor "NOT_RUN aien-train arms (set TRAIN and OMC_TRAIN)"
330text tgchk "/tmp/golden-check-"
331text tfx "om/golden/ollm/fixtures/"
332text tfck "ck.bin"
333text tfmg "merges.bin"
334text tfpr "prompts.txt"
335text tfill "fixture-host"
336text tfutc "2026-01-01T00:00:00Z"
337text tsyn "SYNTHETIC"
338text t8 "8"
339text tfsrc "aien-dev/aien-train@0000000000000000000000000000000000000000"
340text thead "HEAD"
341text tdc "-c"
342text tun "user.name=golden"
343text tue "user.email=golden@invalid"
344text tclone "clone"
345text tq0 "-q"
346text tnohl "--no-hardlinks"
347text tgrpath "native/omegallm/gpu/gr.om"
348text tmodel "native/omegallm/model.om"
349text ttamp "note tampered\n"
350text tupidx "update-index"
351text tskip "--skip-worktree"
352text tdasha "-a"
353text tdashm "-m"
354text ttamper "tamper"
355text ttmd "tm"
356text tclonea "snapshot-scratch-clone"
357text tskipa "snapshot-skip-worktree-flag"
358text tbwt "build-snapshot-dirty-tree"
359text twtok "build-ignores-worktree (tracked edit and skip-worktree edit left out: source_sha256 "
360text twtbad "build-ignores-worktree: the dirty clone built a different source"
361text tcommita "snapshot-commit-tamper"
362text tbcm "build-snapshot-committed-tamper"
363text tcmok "build-sees-commit (the committed edit changes source_sha256; negative control)"
364text tcmbad "build-sees-commit: the committed edit did not change the source"
365text th1 "== recorder (gate.om rec) on the synthetic decoder run fixtures/cpu.out"
366text th2 "== comparator (gate.om cmp) against the record"
367text th4 "== record bounds (review finding 2): header limits and row coverage"
368text th5 "== negative controls: one-line mutants of gate.om must fail their arm"
369text th6 "== decoder composition from TRAIN (host only)"
370text th7 "== source identity (review finding 1): the build is the resolved commit"
371text tcrefx "ref.expect"
372text tcpuo "cpu.out"
373text tcrr "rec-record (exit 0, byte-equal: hashes = sha256, prompt 0 ends at id 0, prompt 1 cut at the step-5 margin 0.005 < 2^-7)"
374text tcrrb "rec-record: not byte-equal to the expected record"
375text tamb "amb.out"
376text tl1 "T 1 1 21 9100000000 600000000"
377text tl1a "T 1 1 21 9100000000 7812499"
378text tl1b "T 1 1 21 9100000000 7812500"
379text tpamb "golden-ollm: refused ambiguous-prompt"
380text trecamb "rec-ambiguous-prompt"
381text tflo "flo.out"
382text tpflo "P 1 5 20 21 22 23 24"
383text trecflo "rec-floor-inclusive"
384text tgar "gpu-as-ref.out"
385text tgtec "GTE cpu "
386text tgteg "GTE gpu "
387text tpfmt "golden-ollm: refused format"
388text trecgpu "rec-refuses-gpu-run"
389text t9 "9"
390text trecsh "rec-refuses-short-run"
391text tord "order.out"
392text tt12 "T 1 2 22 "
393text tt13 "T 1 3 22 "
394text trecso "rec-refuses-step-order"
395text tnogte "nogte.out"
396text trecng "rec-refuses-missing-summary"
397text tmaybe "MAYBE"
398text tpbarg "golden-ollm: refused bad-argument"
399text treclab "rec-refuses-bad-label"
400text trecuse "rec-usage"
401text tgm "gpu-match.out"
402text tpm1 "golden-ollm cmp prompts=2 compared=11 match=2 diverge=0 drift=0 maxdrift_e9=1953125"
403text tcm1 "cmp-match"
404text tpm2 "MATCH 1 n=5 maxdrift_e9=1953"
405text tcm2 "cmp-match-ignores-dropped-steps"
406text tdiv "div.out"
407text tt13x "T 1 3 23 "
408text tt13y "T 1 3 33 "
409text tpdiv "DIVERGE 1 index=3 ref=23 cand=33"
410text tcdiv "cmp-diverge"
411text tt04 "T 0 4 "
412text tt05 "T 0 5 "
413text tg214 "GTE gpu 2 14 "
414text tg212 "GTE gpu 2 12 "
415text tshort "short.out"
416text tpshort "DIVERGE 0 index=4 ref=9 cand=end"
417text tcshort "cmp-candidate-ends-early"
418text tdrift "drift.out"
419text tt02 "T 0 2 7 11999999000 "
420text tt02d "T 0 2 7 12001953126 "
421text tpdrift "DRIFT 0 index=2 ref=12000000000 cand=12001953126"
422text tcdrift "cmp-drift"
423text tck2 "ck2.bin"
424text tck2t "SYNTHETIC another checkpoint"
425text tpnck "NOTCOMPARABLE ckpt_sha256"
426text tcock "cmp-other-checkpoint"
427text tpnmg "NOTCOMPARABLE merges_sha256"
428text tcomg "cmp-other-merges"
429text tpnpr "NOTCOMPARABLE prompts_sha256"
430text tcopr "cmp-other-prompts"
431text tt1 "T 1 "
432text tg16 "GTE gpu 1 6 "
433text tone0 "one.out"
434text tpnp "NOTCOMPARABLE prompts"
435text tccount "cmp-prompt-count"
436text tccpu "cmp-refuses-cpu-run"
437text tbadref "badref.txt"
438text trdg "ref_decoder gtcpu"
439text trdgg "ref_decoder gtgpu"
440text tcbadref "cmp-refuses-bad-record"
441text tlenref "lenref.txt"
442text tp15 "P 1 5 20 21 22 23 24"
443text tp14 "P 1 4 20 21 22 23"
444text tclen "cmp-refuses-row-lengths"
445text tcuse "cmp-usage"
446text tf2a "rmin.txt"
447text tp13 "P 1 3 20 21 22"
448text tl15 "L 1 5 9000000000 9100000000 9200000000 9300000000 -9400000000"
449text tl13 "L 1 3 9000000000 9100000000 9200000000"
450text tm15 "M 1 5 500000000 600000000 700000000 800000000 900000000"
451text tm13 "M 1 3 500000000 600000000 700000000"
452text tcrmin "cmp-refuses-short-coverage"
453text tf2b "floor.txt"
454text tm06 "M 0 6 2000000000 1500000000 900000000 800000000 3000000000 4000000000"
455text tm06b "M 0 6 2000000000 1500000000 900000000 7812499 3000000000 4000000000"
456text tcfloor "cmp-refuses-margin-below-floor"
457text tf2c "mx0.txt"
458text tmx8 "max_tokens 8"
459text tmx0 "max_tokens 0"
460text tcmx0 "cmp-refuses-max-tokens-0"
461text tf2d "mx5.txt"
462text tmx5 "max_tokens 5"
463text tcmx5 "cmp-refuses-row-over-max-tokens"
464text tf2e "mxbig.txt"
465text tmx4097 "max_tokens 4097"
466text tcmxbig "cmp-refuses-max-tokens-over-4096"
467text tf2f "dr0.txt"
468text tdr0a "drift_bound_e9 1953125"
469text tdr0b "drift_bound_e9 0"
470text tcdr0 "cmp-refuses-drift-0"
471text tf2g "fl0.txt"
472text tfl0a "margin_floor_e9 7812500"
473text tfl0b "margin_floor_e9 0"
474text tcfl0 "cmp-refuses-floor-0"
475text tm1 "M1-no-id-compare"
476text tm1a "if ne get gid o get grid o"
477text tm1b "if ne get gid o get gid o"
478text tm2 "M2-no-drift-check"
479text tm2a "if gt d dr"
480text tm2b "if gt d add dr 1000000"
481text tm3 "M3-no-identity"
482text tm3a "if eq get ghd 4 0"
483text tm3b "if eq get ghd 4 7"
484text tm4 "M4-no-floor"
485text tm4a "if lt get gmar o f"
486text tm4b "if lt get gmar o neg f"
487text tm5 "M5-early-end-accepted"
488text tm5a "if ge s get gcnt k"
489text tm5b "if gt s 99999"
490text tm6 "M6-no-margin-floor-check"
491text tm6a "if lt nl long get ghd 2"
492text tm6b "if lt nl -1000000000000000000"
493text tm7 "M7-no-coverage-floor"
494text tm7a "if or lt n RMIN gt n get ghd 1"
495text tm7b "if gt n get ghd 1"
496text tb0 "b0"
497text tb1 "b1"
498text tb2 "b2"
499text tb3 "b3"
500text tb4 "b4"
501text tb5 "b5"
502text tb6 "b6"
503text tbdec "build-decoder"
504text tbone "build-one-main (oggmain 1, main 1)"
505text tbnegc "build-negctl"
506text tnegl "gkmovi 28 grf 1.8033688011112043f64"
507text tnegok "negctl-one-kernel-constant ('> "
508text tcq2 "')"
509text tnegbad "negctl-one-kernel-constant: "
510text tnegsame "negctl-binary-differs: same binary"
511text tnegdiff "negctl-binary-differs"
512text ttwo "two.neg"
513text ttwot "want 1\nfrom gkmovi 28 grf 1.4426950408889634f64\nto gkmovi 28 grf 1.5f64"
514text tpchg2 "PERTURB_CHANGED 2 lines, want 1"
515text tbwrong "build-refuses-wrong-line-count"
516text ttrue0 "/bin/true"
517text tbother "build-refuses-other-omc"
518text tzrev "0000000000000000000000000000000000000000"
519text tbrev "build-refuses-unknown-rev"
520text tg0 "g0"
521text tgnohold "gate-refuses-without-gb10"
522text ttrainv "TRAIN"
523text tcout "out"
524text tcex "exit "
525text tcnol ": no line '"
526text tcin "' in: "
527text tcq1 ", '"
528text tcl1 ": line '"
529text tcnu "' not unique"
530text tsrcom ".bin"
531text tcmdb ": mutant did not build"
532text tcsurv ": mutant survived"
533text tckill " killed"
534text tmout "mout"
535text tschem "aien-golden-ollm/1"
536text tlsyn "label SYNTHETIC"
537text tprk "prompts_sha256 "
538text tref2 "prompts 2\nmax_tokens 8\nmargin_floor_e9 7812500\ndrift_bound_e9 1953125\nref_decoder gtcpu\nref_engine_sha256 "
539text tref3 "ref_source "
540text tref4 "host_id fixture-host\nutc 2026-01-01T00:00:00Z\nP 0 6 5 6 7 8 9 0\nL 0 6 10000000000 11000000000 12000000000 13000000000 14000000000 15000000000\nM 0 6 2000000000 1500000000 900000000 800000000 3000000000 4000000000\nP 1 5 20 21 22 23 24\nL 1 5 9000000000 9100000000 9200000000 9300000000 -9400000000\nM 1 5 500000000 600000000 700000000 800000000 900000000\nend\n"
541text tgateb0 "GOLDEN-GATE "
542text tsl0 ""
543text tsp0 ""
544text terr0 ".err"
545text tbcand "BROKEN cand build rc="
546text tbnegb "BROKEN neg build rc="
547text tnoprm "BROKEN prompt file unreadable or over 64 prompts"
548text tcpuout "cpu.out"
549text treftmp "ref.tmp"
550text tnrhdr "golden-tokens gate: NOT_RUN "
551text tgg "g"
552text tgnr "gate_not_run"
553text tgnr3 "gate exit 3"
554
555note ---- string slots: slot s holds gsl[s] bytes at gs[s*SCAP ..]
556
557fn sb s ulong c uchar to void
558n = get gsl s
559if ge n SCAP
560w = write 2 tlong 0 len tlong
561exit 2
562end
563put gs add mul s SCAP n c
564put gsl s add n 1
565end
566
567fn sclr s ulong to void
568put gsl s 0
569end
570
571fn sx s ulong t view uchar * to void
572for i ulong len t
573sb s get t i
574end
575end
576
577fn sset s ulong t view uchar * to void
578sclr s
579sx s t
580end
581
582fn sc s ulong i ulong to uchar
583ret get gs add mul s SCAP i
584end
585
586fn ss s ulong r ulong to void
587for i ulong get gsl r
588sb s sc r i
589end
590end
591
592fn scp s ulong r ulong to void
593sclr s
594ss s r
595end
596
597fn sn s ulong v ulong to void
598d = new uchar 24 0
599n = ulong 0
600x = v
601while true bound 21
602put d n uchar add rem x 10 48
603n = add n 1
604x = div x 10
605if eq x 0
606break
607end
608end
609for i ulong n
610sb s get d sub sub n 1 i
611end
612end
613
614fn sn2 s ulong v ulong to void
615if lt v 10
616sb s 48
617end
618sn s v
619end
620
621fn seqt s ulong t view uchar * to bool
622if ne get gsl s len t
623ret false
624end
625for i ulong len t
626if ne sc s i get t i
627ret false
628end
629end
630ret true
631end
632
633fn seqs a ulong b ulong to bool
634if ne get gsl a get gsl b
635ret false
636end
637for i ulong get gsl a
638if ne sc a i sc b i
639ret false
640end
641end
642ret true
643end
644
645fn sarg s ulong i ulong to bool
646r = argread i gs mul s SCAP SCAP
647if lt r 0
648ret false
649end
650put gsl s ulong r
651ret true
652end
653
654fn envhas t view uchar * r ulong to bool
655if le r len t
656ret false
657end
658for i ulong len t
659if ne get gio i get t i
660ret false
661end
662end
663ret eq get gio len t 61
664end
665
666note slot s = value of environment entry t; false when absent or empty
667fn senv s ulong t view uchar * to bool
668sclr s
669n = envcnt
670if le n 0
671ret false
672end
673for i ulong ulong n
674r = envread i gio 0 65536
675if gt r 0
676if envhas t ulong r
677k = add len t 1
678m = sub ulong r k
679for j ulong m
680sb s get gio add k j
681end
682ret gt get gsl s 0
683end
684end
685end
686ret false
687end
688
689note slot s made absolute against the current directory
690fn sabs s ulong to void
691if eq get gsl s 0
692ret
693end
694if eq sc s 0 47
695ret
696end
697r = cwd gio 0 65536
698if le r 1
699exit 2
700end
701sclr SCWD
702for i ulong sub ulong r 1
703sb SCWD get gio i
704end
705sb SCWD 47
706ss SCWD s
707scp s SCWD
708end
709
710note ---- output: slot s and a newline to fd
711
712fn wslot fd int s ulong to void
713n = get gsl s
714o = mul s SCAP
715p = ulong 0
716while lt p n bound 9999
717w = write fd gs add o p sub n p
718if le w 0
719ret
720end
721p = add p ulong w
722end
723end
724
725fn say fd int s ulong to void
726sb s 10
727wslot fd s
728put gsl s sub get gsl s 1
729end
730
731fn sayt fd int t view uchar * to void
732sset SM t
733say fd SM
734end
735
736note ---- files named by slots
737
738fn fopf s ulong fl int to int
739r = fopen gs mul s SCAP get gsl s fl 420
740if lt r 0
741ret -1
742end
743ret int r
744end
745
746fn fcls fd int to void
747if ge fd 3
748r = fclose fd
749end
750end
751
752fn there s ulong to bool
753r = stat gs mul s SCAP get gsl s gstb 0 256
754ret ge r 0
755end
756
757fn isexe s ulong to bool
758if eq get gsl s 0
759ret false
760end
761r = faccess gs mul s SCAP get gsl s 1
762ret eq r 0
763end
764
765fn mkd s ulong to bool
766r = makedir gs mul s SCAP get gsl s 493
767ret eq r 0
768end
769
770fn mkp s ulong to bool
771n = get gsl s
772sclr SCWD
773for i ulong n
774c = sc s i
775if and eq c 47 gt i 0
776r = makedir gs mul SCWD SCAP get gsl SCWD 493
777end
778sb SCWD c
779end
780r = makedir gs mul s SCAP n 493
781if eq r 0
782ret true
783end
784ret eq r -17
785end
786
787fn rmf s ulong to void
788r = unlink gs mul s SCAP get gsl s
789end
790
791note load slot s's file into gb
792fn fload s ulong to bool
793fd = fopf s 0
794if lt fd 0
795ret false
796end
797t = ulong 0
798while true bound 99999
799if ge t BCAP
800fcls fd
801ret false
802end
803k = read fd gb t sub BCAP t
804if lt k 0
805fcls fd
806ret false
807end
808if eq k 0
809break
810end
811t = add t ulong k
812end
813fcls fd
814put gbn 0 t
815ret true
816end
817
818fn floadc s ulong to bool
819fd = fopf s 0
820if lt fd 0
821ret false
822end
823t = ulong 0
824while true bound 99999
825if ge t BCAP
826fcls fd
827ret false
828end
829k = read fd gc t sub BCAP t
830if lt k 0
831fcls fd
832ret false
833end
834if eq k 0
835break
836end
837t = add t ulong k
838end
839fcls fd
840put gcn 0 t
841ret true
842end
843
844fn wgb fd int to bool
845n = get gbn 0
846p = ulong 0
847while lt p n bound 99999
848w = write fd gb p sub n p
849if le w 0
850ret false
851end
852p = add p ulong w
853end
854ret true
855end
856
857fn wgc fd int to bool
858n = get gcn 0
859p = ulong 0
860while lt p n bound 99999
861w = write fd gc p sub n p
862if le w 0
863ret false
864end
865p = add p ulong w
866end
867ret true
868end
869
870fn fsavb s ulong to bool
871fd = fopf s 577
872if lt fd 0
873ret false
874end
875ok = wgb fd
876fcls fd
877ret ok
878end
879
880fn fsavc s ulong to bool
881fd = fopf s 577
882if lt fd 0
883ret false
884end
885ok = wgc fd
886fcls fd
887ret ok
888end
889
890fn fsavs s ulong v ulong to bool
891fd = fopf s 577
892if lt fd 0
893ret false
894end
895wslot fd v
896fcls fd
897ret true
898end
899
900note copy slot s's file to fd d
901fn fcat d int s ulong to bool
902fd = fopf s 0
903if lt fd 0
904ret false
905end
906while true bound 99999
907k = read fd gio 0 65536
908if lt k 0
909fcls fd
910ret false
911end
912if eq k 0
913break
914end
915p = ulong 0
916while lt p ulong k bound 99999
917w = write d gio p sub ulong k p
918if le w 0
919fcls fd
920ret false
921end
922p = add p ulong w
923end
924end
925fcls fd
926ret true
927end
928
929note slot d = lowercase sha256 hex of slot s's file
930fn fsha s ulong d ulong to bool
931fd = fopf s 0
932if lt fd 0
933ret false
934end
935hreset
936while true bound 999999
937k = read fd gio 0 65536
938if lt k 0
939fcls fd
940ret false
941end
942if eq k 0
943break
944end
945for i ulong ulong k
946hok = hpush get gio i
947end
948end
949fcls fd
950ok = hfinal
951sclr d
952for j ulong 64
953sb d get hd j
954end
955ret ok
956end
957
958note ---- children: packed argv in gav, execprog with an empty environment
959
960fn aclr to void
961put gap 0 2
962put gap 1 0
963end
964
965fn apb c uchar to void
966p = get gap 0
967put gav p c
968put gap 0 add p 1
969end
970
971fn aps s ulong to void
972n = get gsl s
973apb uchar and n 255
974apb uchar shr n 8
975for i ulong n
976apb sc s i
977end
978put gap 1 add get gap 1 1
979end
980
981fn apt t view uchar * to void
982sset SA t
983aps SA
984end
985
986fn redir s int d int to void
987if lt s 0
988ret
989end
990if eq s d
991ret
992end
993r = dupfd s d 0
994if ne r long d
995exit 127
996end
997end
998
999note run gav with fds fi fo fe (-1 inherits); the exit status, 256+signal, or 1000 on spawn failure
1000fn apfin to void
1001n = get gap 1
1002put gav 0 uchar and n 255
1003put gav 1 uchar shr n 8
1004end
1005
1006fn spawn fi int fo int fe int to ulong
1007apfin
1008pid = fork
1009if lt pid 0
1010ret 1000
1011end
1012if eq pid 0
1013redir fi 0
1014redir fo 1
1015redir fe 2
1016r = execprog gav 0 get gap 0
1017exit 127
1018end
1019r = waitpid int pid gwst 0 4 0
1020if ne r pid
1021ret 1000
1022end
1023if ne get gwst 0 0
1024ret add 256 ulong and get gwst 0 127
1025end
1026ret ulong get gwst 1
1027end
1028
1029note spawn with stdout and stderr to slot s's file (truncated)
1030fn spawnf s ulong to ulong
1031fd = fopf s 577
1032if lt fd 0
1033ret 1000
1034end
1035rc = spawn -1 fd fd
1036fcls fd
1037ret rc
1038end
1039
1040fn rmrf s ulong to void
1041aclr
1042apt trm
1043apt tdrf
1044aps s
1045rc = spawn -1 -1 -1
1046end
1047
1048note ---- line transforms over gb into gc
1049
1050fn leol p ulong to ulong
1051n = get gbn 0
1052q = p
1053while lt q n bound 999999
1054if eq get gb q 10
1055ret q
1056end
1057q = add q 1
1058end
1059ret n
1060end
1061
1062fn lis p ulong e ulong s ulong to bool
1063if ne sub e p get gsl s
1064ret false
1065end
1066for i ulong sub e p
1067if ne get gb add p i sc s i
1068ret false
1069end
1070end
1071ret true
1072end
1073
1074fn lpre p ulong e ulong s ulong to bool
1075if lt sub e p get gsl s
1076ret false
1077end
1078for i ulong get gsl s
1079if ne get gb add p i sc s i
1080ret false
1081end
1082end
1083ret true
1084end
1085
1086fn cput c uchar to void
1087n = get gcn 0
1088if ge n BCAP
1089w = write 2 tlong 0 len tlong
1090exit 2
1091end
1092put gc n c
1093put gcn 0 add n 1
1094end
1095
1096fn crng p ulong e ulong to void
1097for i ulong sub e p
1098cput get gb add p i
1099end
1100end
1101
1102fn cslot s ulong to void
1103for i ulong get gsl s
1104cput sc s i
1105end
1106end
1107
1108note one line gb[p..e): mode 0 exact a -> b (inside block blk when blk is not empty), 1 prefix a -> b,
1109note 2 delete lines starting with a
1110fn xl mode ulong a ulong b ulong blk ulong p ulong e ulong to void
1111nl = lt e get gbn 0
1112hit = false
1113if eq mode 2
1114hit = lpre p e a
1115if not hit
1116crng p e
1117end
1118end
1119if eq mode 1
1120hit = lpre p e a
1121if hit
1122cslot b
1123crng add p get gsl a e
1124else
1125crng p e
1126end
1127end
1128if eq mode 0
1129inr = true
1130if gt get gsl blk 0
1131inr = false
1132if eq get gxs 0 1
1133inr = true
1134sset SEND tendl
1135if lis p e SEND
1136put gxs 0 0
1137end
1138else
1139if lis p e blk
1140inr = true
1141put gxs 0 1
1142end
1143end
1144end
1145if inr
1146hit = lis p e a
1147end
1148if hit
1149cslot b
1150else
1151crng p e
1152end
1153end
1154if hit
1155put gxs 1 add get gxs 1 1
1156end
1157keep = true
1158if and hit eq mode 2
1159keep = false
1160end
1161if and nl keep
1162cput 10
1163end
1164end
1165
1166fn xf mode ulong a ulong b ulong blk ulong to ulong
1167put gcn 0 0
1168put gxs 0 0
1169put gxs 1 0
1170p = ulong 0
1171n = get gbn 0
1172while lt p n bound 999999
1173e = leol p
1174xl mode a b blk p e
1175p = add e 1
1176end
1177ret get gxs 1
1178end
1179
1180note gc = gb without its last line
1181fn xlast to void
1182q = get gbn 0
1183if gt q 0
1184if eq get gb sub q 1 10
1185q = sub q 1
1186end
1187end
1188s = ulong 0
1189i = q
1190while gt i 0 bound 999999
1191if eq get gb sub i 1 10
1192s = i
1193break
1194end
1195i = sub i 1
1196end
1197put gcn 0 0
1198crng 0 s
1199end
1200
1201fn cback to void
1202n = get gcn 0
1203for i ulong n
1204put gb i get gc i
1205end
1206put gbn 0 n
1207end
1208
1209note gb[p..e) into slot s
1210fn lslot s ulong p ulong e ulong to void
1211sclr s
1212for i ulong sub e p
1213sb s get gb add p i
1214end
1215end
1216
1217note ---- compilers
1218
1219note slot SHEX = sha of compiler slot o; 0 pinned, 3 not pinned (message on stderr)
1220fn opin o ulong pin view uchar * nr view uchar * to ulong
1221if not isexe o
1222sayt 2 nr
1223ret 3
1224end
1225ok = fsha o SHEX
1226if not seqt SHEX pin
1227sset SM tnrsha
1228ss SM SHEX
1229sx SM tpinned
1230sx SM pin
1231say 2 SM
1232ret 3
1233end
1234ret 0
1235end
1236
1237note om/golden/build.sh in Omega: compile om2 + json + sha256 + slot src into slot out with bf54b19f
1238fn gcomp o ulong src ulong dst ulong to ulong
1239rc = opin o tpingt tnrgt
1240if ne rc 0
1241ret rc
1242end
1243scp SX dst
1244sx SX tdotom
1245scp SY dst
1246sx SY terr
1247fd = fopf SX 577
1248if lt fd 0
1249ret 1
1250end
1251w = write fd tom2 0 len tom2
1252sset SZ tjson
1253ok = fcat fd SZ
1254sset SZ tshaom
1255if ok
1256ok = fcat fd SZ
1257end
1258if ok
1259ok = fcat fd src
1260end
1261fcls fd
1262fi = fopf SX 0
1263fo = fopf dst 577
1264fe = fopf SY 577
1265aclr
1266aps o
1267rc = spawn fi fo fe
1268fcls fi
1269fcls fo
1270fcls fe
1271rmf SX
1272if or ne rc 0 not ok
1273ok = fload SY
1274sset SM tcompile
1275ss SM src
1276sx SM tcolon
1277wslot 2 SM
1278trimnl
1279ok = wgb 2
1280sayt 2 tnl0
1281rmf dst
1282rmf SY
1283ret 1
1284end
1285rmf SY
1286r = chmod gs mul dst SCAP get gsl dst 448
1287ret 0
1288end
1289
1290fn trimnl to void
1291n = get gbn 0
1292while gt n 0 bound 999999
1293if ne get gb sub n 1 10
1294break
1295end
1296n = sub n 1
1297end
1298put gbn 0 n
1299end
1300
1301fn rnm a ulong b ulong to bool
1302aclr
1303aps a
1304aps b
1305apfin
1306r = renames gav 0 get gap 0 0
1307ret eq r 0
1308end
1309
1310note slot d = slot a + "/" + text t
1311fn sjoin d ulong a ulong t view uchar * to void
1312scp d a
1313sb d 47
1314sx d t
1315end
1316
1317fn sdec s ulong to ulong
1318v = ulong 0
1319if eq get gsl s 0
1320ret 18446744073709551615
1321end
1322for i ulong get gsl s
1323c = sc s i
1324if or lt c 48 gt c 57
1325ret 18446744073709551615
1326end
1327v = add mul v 10 ulong sub c 48
1328end
1329ret v
1330end
1331
1332note last line of slot s's file into slot SM (after prefix t)
1333fn lastln s ulong t view uchar * to void
1334sset SM t
1335ok = fload s
1336if not ok
1337ret
1338end
1339trimnl
1340n = get gbn 0
1341i = n
1342while gt i 0 bound 999999
1343if eq get gb sub i 1 10
1344break
1345end
1346i = sub i 1
1347end
1348for j ulong sub n i
1349sb SM get gb add i j
1350end
1351end
1352
1353note ---- the negative-control file (.neg): want N, block LINE, from LINE, to LINE; '#' comments
1354fn negld s ulong to bool
1355sclr SNW
1356sclr SNB
1357sclr SNF
1358sclr SNT
1359ok = fload s
1360if not ok
1361ret false
1362end
1363p = ulong 0
1364n = get gbn 0
1365while lt p n bound 99999
1366e = leol p
1367sset SK twant
1368if lpre p e SK
1369lslot SNW add p 5 e
1370end
1371sset SK tblock
1372if lpre p e SK
1373lslot SNB add p 6 e
1374end
1375sset SK tfrom
1376if lpre p e SK
1377lslot SNF add p 5 e
1378end
1379sset SK tto
1380if lpre p e SK
1381lslot SNT add p 3 e
1382end
1383p = add e 1
1384end
1385ret true
1386end
1387
1388note ---- CORE: env CORE, else this process's Cpus_allowed_list
1389fn score to void
1390if senv SCORE tcoreq0
1391ret
1392end
1393sclr SCORE
1394sset SP tstatus
1395ok = fload SP
1396if not ok
1397ret
1398end
1399sset SK tcpus
1400p = ulong 0
1401n = get gbn 0
1402while lt p n bound 99999
1403e = leol p
1404if lpre p e SK
1405q = add p get gsl SK
1406while lt q e bound 99999
1407c = get gb q
1408if and ne c 9 ne c 32
1409sb SCORE c
1410end
1411q = add q 1
1412end
1413ret
1414end
1415p = add e 1
1416end
1417end
1418
1419fn bfail t view uchar * rc ulong to ulong
1420sset SM tsfail
1421sx SM t
1422sx SM tgdecr
1423sn SM rc
1424say 2 SM
1425ret 1
1426end
1427
1428note git child: /usr/bin/env drops the system and global config and attributes files and the graft
1429note file, and --no-replace-objects drops refs/replace (the child environment is otherwise empty)
1430fn agit to void
1431aclr
1432apt tenv
1433apt tgenv1
1434apt tgenv2
1435apt tgenv3
1436apt tgenv4
1437apt tgit
1438apt tnorep
1439end
1440
1441note private object-only repository SZ = SOUT/src.git: a bare repository made with no templates
1442note (no hooks, no info/grafts, no info/attributes, no alternates), fetched from TRAIN's HEAD,
1443note heads, tags and remotes (never refs/replace; fetched objects are hash-checked by index-pack).
1444note TRAIN's side of the fetch is an upload-pack run with GIT_GRAFT_FILE=/dev/null and
1445note GIT_NO_REPLACE_OBJECTS=1 (git clears repo-local variables for a local upload-pack, so they are
1446note set in its command), so it walks and sends the true history. REV resolves in SZ, never in TRAIN,
1447note so TRAIN's info/grafts, info/attributes, replace refs and config overlays cannot select the
1448note commit or shape the snapshot. Slot SSHA = the commit id; SOUT/commit holds it; returns 0 or the
1449note bfail code
1450fn rslv to ulong
1451sjoin SZ SOUT tprv
1452rmrf SZ
1453sjoin SP SOUT tcmt
1454sjoin SQ SOUT tcmterr
1455agit
1456apt tinit
1457apt tq0
1458apt tbare
1459apt ttmpl
1460aps SZ
1461rc = spawnf SQ
1462if ne rc 0
1463ret bfail tinit rc
1464end
1465agit
1466apt tdash
1467aps SZ
1468apt tfetch
1469apt tq0
1470apt tnotags
1471apt tnogc
1472apt tnofh
1473apt tupk
1474aps STRN
1475apt trs1
1476apt trs2
1477apt trs3
1478apt trs4
1479rc = spawnf SQ
1480if ne rc 0
1481ret bfail tfetch rc
1482end
1483agit
1484apt tdash
1485aps SZ
1486apt tupref
1487apt tnoderef
1488apt thead
1489apt tghead
1490rc = spawnf SQ
1491if ne rc 0
1492ret bfail tupref rc
1493end
1494agit
1495apt tdash
1496aps SZ
1497apt trevp
1498apt tverify
1499scp SV SREV
1500sx SV tcommit
1501aps SV
1502fo = fopf SP 577
1503fe = fopf SQ 577
1504rc = spawn -1 fo fe
1505fcls fo
1506fcls fe
1507if ne rc 0
1508ret bfail trevp rc
1509end
1510ok = fload SP
1511trimnl
1512if ne get gbn 0 40
1513ret bfail trevp 1000
1514end
1515lslot SSHA 0 40
1516ret 0
1517end
1518
1519note ---- drive build: slots SOMC STRN SREV SOUT SNEG (absolute); returns the exit code
1520fn dbuild to ulong
1521rc = opin SOMC tpintr tnrtr
1522if ne rc 0
1523ret rc
1524end
1525if gt get gsl SNEG 0
1526ok = negld SNEG
1527if or not ok eq get gsl SNW 0
1528sset SM tnowant
1529ss SM SNEG
1530say 2 SM
1531ret 4
1532end
1533end
1534ok = mkp SOUT
1535if not ok
1536sset SM tmkd
1537ss SM SOUT
1538say 2 SM
1539ret 1
1540end
1541note resolve REV to one commit in the private repository SZ
1542rc = rslv
1543if ne rc 0
1544ret rc
1545end
1546note snapshot that commit
1547sjoin SX SOUT tsrc
1548rmrf SX
1549ok = mkd SX
1550sjoin SY SOUT tsrctar
1551agit
1552apt tdash
1553aps SZ
1554apt tarch
1555apt tfmtt
1556apt tdo
1557aps SY
1558aps SSHA
1559rc = spawnf SQ
1560if ne rc 0
1561ret bfail tarch rc
1562end
1563rmrf SZ
1564aclr
1565apt ttar
1566apt tdx
1567apt tdf
1568aps SY
1569apt tdash
1570aps SX
1571rc = spawnf SQ
1572if ne rc 0
1573ret bfail ttar rc
1574end
1575rmf SY
1576rmf SQ
1577note the snapshot's own build.sh
1578score
1579aclr
1580apt tenv
1581apt tpath
1582apt ttgt
1583sset SV tomceq
1584ss SV SOMC
1585aps SV
1586sset SV touteq
1587ss SV SOUT
1588sx SV tsltrain
1589aps SV
1590sset SV tcoreq
1591ss SV SCORE
1592aps SV
1593apt tsh
1594scp SV SX
1595sx SV tslbsh
1596aps SV
1597sjoin SP SOUT tlog
1598rc = spawnf SP
1599rmrf SX
1600if ne rc 0
1601lastln SP tbfail
1602say 2 SM
1603ret 1
1604end
1605sjoin SP SOUT tslollm
1606ok = fload SP
1607if not ok
1608lastln SP tbfail
1609say 2 SM
1610ret 1
1611end
1612sset SA tmain
1613sclr SZ
1614nm = xf 0 SA SA SZ
1615if ne nm 1
1616sset SM tmcount
1617sn SM nm
1618sx SM twant1
1619say 2 SM
1620ret 4
1621end
1622sset SB tmain
1623sset SV toggm
1624sclr SZ
1625nm = xf 0 SB SV SZ
1626cback
1627if gt get gsl SNEG 0
1628w = sdec SNW
1629c = xf 0 SNF SNT SNB
1630if ne c w
1631sset SM tpchg
1632sn SM c
1633sx SM tlines
1634ss SM SNW
1635say 2 SM
1636ret 4
1637end
1638cback
1639end
1640sjoin SP SOUT tgold
1641fd = fopf SP 577
1642if lt fd 0
1643ret 1
1644end
1645ok = wgb fd
1646sset SQ tgdec
1647ok2 = fcat fd SQ
1648fcls fd
1649sjoin SX SOUT tgoldtmp
1650sjoin SY SOUT tomcerr
1651fi = fopf SP 0
1652fo = fopf SX 577
1653fe = fopf SY 577
1654aclr
1655aps SOMC
1656rc = spawn fi fo fe
1657fcls fi
1658fcls fo
1659fcls fe
1660if or ne rc 0 not and ok ok2
1661rmf SX
1662sset SM tbfomc
1663sn SM rc
1664sx SM tsp
1665wslot 2 SM
1666ok = fload SY
1667trimnl
1668ok = wgb 2
1669sayt 2 tnl0
1670ret 1
1671end
1672rmf SY
1673r = chmod gs mul SX SCAP get gsl SX 493
1674sjoin SZ SOUT tgoldb
1675ok = rnm SX SZ
1676sjoin SP SOUT tcmt
1677sclr SV
1678ss SV SSHA
1679ok = fsavs SP SV
1680sset SM tbok
1681ok = fsha SZ SHEX
1682ss SM SHEX
1683sx SM tsp
1684ss SM SZ
1685sx SM tsrcsha
1686sjoin SP SOUT tgold
1687ok = fsha SP SHEX
1688ss SM SHEX
1689sx SM tcmtsp
1690ss SM SSHA
1691say 1 SM
1692ret 0
1693end
1694
1695note ---- prompts: one per line (a final unterminated line counts when not empty) into slots SPRB..
1696fn pld s ulong to bool
1697put gk 0 0
1698ok = fload s
1699if not ok
1700ret false
1701end
1702p = ulong 0
1703n = get gbn 0
1704k = ulong 0
1705while lt p n bound 99999
1706e = leol p
1707if ge k NPMAX
1708ret false
1709end
1710if gt sub e p SCAP
1711ret false
1712end
1713lslot add SPRB k p e
1714k = add k 1
1715p = add e 1
1716end
1717put gk 0 k
1718ret true
1719end
1720
1721fn apprm to void
1722for k ulong get gk 0
1723aps add SPRB k
1724end
1725end
1726
1727note slot SV = digits of the record's max_tokens line; false when absent
1728fn rmaxt s ulong to bool
1729sclr SV
1730ok = fload s
1731if not ok
1732ret false
1733end
1734sset SK tmaxtok
1735p = ulong 0
1736n = get gbn 0
1737while lt p n bound 999999
1738e = leol p
1739if lpre p e SK
1740lslot SV add p get gsl SK e
1741if ne sdec SV 18446744073709551615
1742ret true
1743end
1744end
1745p = add e 1
1746end
1747sclr SV
1748ret false
1749end
1750
1751fn hold to bool
1752if senv SV thost
1753ret true
1754end
1755sclr SV
1756ok = senv SV theld
1757ret seqt SV tone
1758end
1759
1760fn verd t view uchar * c ulong to ulong
1761sset SM tgateb0
1762sx SM t
1763say 1 SM
1764ret c
1765end
1766
1767fn verdn t view uchar * v ulong u view uchar * c ulong to ulong
1768sset SM tgateb0
1769sx SM t
1770sn SM v
1771sx SM u
1772say 1 SM
1773ret c
1774end
1775
1776note print each line of slot s's file to fd 1 with prefix text t
1777fn catpre s ulong t view uchar * to void
1778ok = fload s
1779if not ok
1780ret
1781end
1782p = ulong 0
1783n = get gbn 0
1784while lt p n bound 999999
1785e = leol p
1786lslot SM p e
1787sset SK t
1788sx SK tcolon
1789ss SK SM
1790say 1 SK
1791p = add e 1
1792end
1793end
1794
1795fn catf s ulong to void
1796ok = fcat 1 s
1797end
1798
1799note drive build of arm (cand or neg) as a child; prints its transcript; the child's code
1800fn gbarm am view uchar * isn bool to ulong
1801aclr
1802apt tself
1803apt tbuild
1804aps SOMC
1805aps STRN
1806aps SREV
1807sset SX tsl0
1808ss SX SOUT
1809sb SX 47
1810sx SX am
1811aps SX
1812if isn
1813sset SY tnegf
1814sabs SY
1815aps SY
1816end
1817sx SX tbuildf
1818rc = spawnf SX
1819catf SX
1820ret rc
1821end
1822
1823note gtgpu of an arm and gate cmp; returns cmp's code
1824fn grarm am view uchar * to ulong
1825sset SX tsl0
1826ss SX SOUT
1827sb SX 47
1828sx SX am
1829scp SY SX
1830sb SY 47
1831sx SY tgoldb
1832aclr
1833aps SY
1834apt tgtgpu
1835aps SCK
1836aps SMG
1837aps SMX
1838apprm
1839scp SP SX
1840sx SP tout
1841scp SQ SX
1842sx SQ terr0
1843fo = fopf SP 577
1844fe = fopf SQ 577
1845rc = spawn -1 fo fe
1846fcls fo
1847fcls fe
1848sset SW tsp0
1849sx SW am
1850sx SW tgrc
1851sn SW rc
1852sx SW tsp
1853lastln SP tnl0
1854ss SW SM
1855say 1 SW
1856aclr
1857aps SG
1858apt tcmp
1859aps SREF
1860aps SP
1861aps SCK
1862aps SMG
1863aps SPR
1864scp SQ SX
1865sx SQ tcmpx
1866c = spawnf SQ
1867catpre SQ am
1868ret c
1869end
1870
1871note true when OUT/am/commit holds exactly the commit id in slot SREV
1872fn gbid am view uchar * to bool
1873sset SX tsl0
1874ss SX SOUT
1875sb SX 47
1876sx SX am
1877sb SX 47
1878sx SX tcmt
1879ok = fload SX
1880if not ok
1881ret false
1882end
1883trimnl
1884lslot SV 0 get gbn 0
1885ret seqs SV SREV
1886end
1887
1888note drive gate: slots SOMC SOMG STRN SREV SREF SCK SMG SPR SOUT
1889fn dgate to ulong
1890if not hold
1891sayt 1 tnohold
1892ret 3
1893end
1894if there SOUT
1895sset SM texists
1896ss SM SOUT
1897say 2 SM
1898ret 2
1899end
1900ok = mkp SOUT
1901note REV resolves once, through the private repository OUT/src.git, to a full commit id. That
1902note repository's HEAD is pinned to the id and both builds fetch from it, not from TRAIN, so a branch
1903note moved (or a ref deleted) in TRAIN between the builds cannot split them; each build's commit
1904note must still equal the id
1905rc = rslv
1906if ne rc 0
1907ret verdn tbres rc tnl0 4
1908end
1909agit
1910apt tdash
1911aps SZ
1912apt tupref
1913apt tnoderef
1914apt thead
1915aps SSHA
1916rc = spawnf SQ
1917if ne rc 0
1918ret verdn tbres rc tnl0 4
1919end
1920scp STRN SZ
1921scp SREV SSHA
1922sjoin SG SOUT tgateb
1923sset SP tgateom
1924rc = gcomp SOMG SP SG
1925if eq rc 3
1926ret verd tngate 3
1927end
1928if ne rc 0
1929ret verdn tbgate rc tnl0 4
1930end
1931rc = gbarm tcand false
1932if eq rc 3
1933ret verd tndec 3
1934end
1935if ne rc 0
1936ret verdn tbcand rc tnl0 4
1937end
1938if not gbid tcand
1939ret verd tbidc 4
1940end
1941rc = gbarm tnegd true
1942if eq rc 3
1943ret verd tndec 3
1944end
1945if ne rc 0
1946ret verdn tbnegb rc tnl0 4
1947end
1948if not gbid tnegd
1949ret verd tbidn 4
1950end
1951if not rmaxt SREF
1952ret verd tnomx 3
1953end
1954scp SMX SV
1955ok = pld SPR
1956if not ok
1957ret verd tnoprm 4
1958end
1959c = grarm tcand
1960nc = grarm tnegd
1961if eq c 3
1962ret verd tnocmp 3
1963end
1964if ne nc 1
1965ret verdn tbneg nc tbneg2 4
1966end
1967if eq c 0
1968ret verd tpass 0
1969end
1970if eq c 1
1971ret verd tfailv 1
1972end
1973ret verdn tbcmp c tnl0 4
1974end
1975
1976note ---- record
1977
1978fn sutc s ulong to void
1979ns = realns
1980sec = div ulong ns 1000000000
1981rs = rem sec 86400
1982sdate s div sec 86400
1983sn2 s div rs 3600
1984sb s 58
1985sn2 s div rem rs 3600 60
1986sb s 58
1987sn2 s rem rs 60
1988sb s 90
1989end
1990
1991fn sdate s ulong days ulong to void
1992z = add days 719468
1993era = div z 146097
1994doe = sub z mul era 146097
1995a = sub doe div doe 1460
1996a = add a div doe 36524
1997a = sub a div doe 146096
1998yoe = div a 365
1999y = add yoe mul era 400
2000a = mul 365 yoe
2001a = add a div yoe 4
2002a = sub a div yoe 100
2003doy = sub doe a
2004mp = div add mul 5 doy 2 153
2005a = div add mul 153 mp 2 5
2006d = add sub doy a 1
2007m = add mp 3
2008if ge mp 10
2009m = sub mp 9
2010end
2011if le m 2
2012y = add y 1
2013end
2014sn s y
2015sb s 45
2016sn2 s m
2017sb s 45
2018sn2 s d
2019sb s 84
2020end
2021
2022fn shost s ulong to void
2023sclr s
2024sset SP thostf
2025ok = fload SP
2026if not ok
2027ret
2028end
2029for i ulong get gbn 0
2030c = get gb i
2031if or eq c 46 eq c 10
2032ret
2033end
2034sb s c
2035end
2036end
2037
2038note drive record: slots SOMC SOMG STRN SREV SCK SMG SPR SOUT SLAB
2039fn drec to ulong
2040if there SOUT
2041sset SM texists
2042ss SM SOUT
2043say 2 SM
2044ret 2
2045end
2046ok = mkp SOUT
2047aclr
2048apt tself
2049apt tbuild
2050aps SOMC
2051aps STRN
2052aps SREV
2053sjoin SX SOUT tbuild
2054aps SX
2055rc = spawn -1 -1 -1
2056if ne rc 0
2057ret rc
2058end
2059sjoin SG SOUT tgateb
2060sset SP tgateom
2061rc = gcomp SOMG SP SG
2062if ne rc 0
2063ret rc
2064end
2065ok = pld SPR
2066if not ok
2067ret 4
2068end
2069sjoin SX SOUT tbuild
2070sjoin SY SX tgoldb
2071ok = fsha SY SH2
2072sjoin SP SX tcmt
2073ok = fload SP
2074trimnl
2075sset SC2 tsrcp
2076for i ulong get gbn 0
2077sb SC2 get gb i
2078end
2079sjoin SP SOUT tcpuout
2080aclr
2081aps SY
2082apt tgtcpu
2083aps SCK
2084aps SMG
2085apt tmx
2086apprm
2087fo = fopf SP 577
2088rc = spawn -1 fo -1
2089fcls fo
2090if ne rc 0
2091ret rc
2092end
2093shost SE
2094sclr SZ
2095sutc SZ
2096sjoin SP SOUT tcpuout
2097aclr
2098aps SG
2099apt trec
2100aps SP
2101aps SCK
2102aps SMG
2103aps SPR
2104apt tmx
2105apt tfl
2106apt tdr
2107aps SH2
2108aps SC2
2109aps SE
2110aps SZ
2111aps SLAB
2112sjoin SQ SOUT treftmp
2113fo = fopf SQ 577
2114rc = spawn -1 fo -1
2115fcls fo
2116if ne rc 0
2117ret rc
2118end
2119sjoin SR SOUT tref
2120ok = rnm SQ SR
2121sset SM trecok
2122ok = fsha SR SHEX
2123ss SM SHEX
2124sx SM tsp
2125ss SM SR
2126say 1 SM
2127ret 0
2128end
2129
2130note ---- core: tests/gates/run.sh gb10-golden-tokens
2131
2132fn obs k view uchar * v view uchar * q bool to void
2133sset SM tobs
2134sx SM k
2135sx SM tsp
2136if q
2137sx SM tq
2138end
2139sx SM v
2140if q
2141sx SM tq
2142end
2143say 1 SM
2144end
2145
2146fn notrun r view uchar * d ulong to ulong
2147sset SM tnrhdr
2148sx SM r
2149sx SM tcolon
2150ss SM d
2151say 2 SM
2152sset SM tobs
2153sx SM tnrr
2154sx SM tsp
2155sx SM tq
2156sx SM r
2157sx SM tq
2158say 1 SM
2159ret 77
2160end
2161
2162note slot d = the record line value after key t of slot SREF's file
2163fn refval d ulong t view uchar * to bool
2164sclr d
2165ok = fload SREF
2166if not ok
2167ret false
2168end
2169sset SK t
2170p = ulong 0
2171n = get gbn 0
2172while lt p n bound 999999
2173e = leol p
2174if lpre p e SK
2175lslot d add p get gsl SK e
2176ret true
2177end
2178p = add e 1
2179end
2180ret false
2181end
2182
2183fn dcore to ulong
2184sset SREF trefp
2185sabs SREF
2186sset SPR tprp
2187sabs SPR
2188sset SP tlock
2189ok = fload SP
2190sclr SLK
2191for i ulong get gbn 0
2192c = get gb i
2193if and ne c 10 and ne c 32 and ne c 9 ne c 13
2194sb SLK c
2195end
2196end
2197ok = senv STRN tgtrain
2198if ok
2199sjoin SP STRN tbsh
2200ok = there SP
2201end
2202if not ok
2203sset SD ttmw
2204ss SD SLK
2205ret notrun ttm SD
2206end
2207agit
2208apt tdash
2209aps STRN
2210apt tcatf
2211apt tdash_e
2212scp SV SLK
2213sx SV tcommit
2214aps SV
2215rc = spawn -1 -1 -1
2216if ne rc 0
2217sset SD ttuw
2218ss SD SLK
2219ret notrun ttu SD
2220end
2221scp SREV SLK
2222if not senv SGD tgdir
2223if senv SGD tmdir
2224sx SGD tolg
2225else
2226ok = senv SGD thome
2227sx SGD tmodels
2228sx SGD tolg
2229end
2230end
2231ok = refval SV tckk
2232sjoin SCK SGD tnl0
2233ss SCK SV
2234ok = refval SV tmgk
2235sjoin SMG SGD tnl0
2236ss SMG SV
2237if not there SCK
2238ret notrun tmm SCK
2239end
2240if not there SMG
2241ret notrun tmm SMG
2242end
2243ok = senv SOMC taomctr
2244ok = senv SOMG taomcgt
2245sset ST tgcore
2246sn ST ulong getpid
2247ok = mkd ST
2248sjoin SOUT ST tgg
2249ok = fsha SREF SHEX
2250sset SM tobs
2251sx SM tgrec
2252sx SM tsp
2253sx SM tq
2254ss SM SHEX
2255sx SM tq
2256say 1 SM
2257rc = dgate
2258rmrf ST
2259if eq rc 0
2260obs tgpass ttrue false
2261obs tgneg ttrue false
2262ret 0
2263end
2264if eq rc 1
2265obs tgpass tfalse false
2266obs tgneg ttrue false
2267ret 1
2268end
2269if eq rc 3
2270sset SD tgnr3
2271ret notrun tgnr SD
2272end
2273obs tgpass tfalse false
2274obs tgneg tfalse false
2275ret 1
2276end
2277
2278note ---- check: host arms (port of the former check.sh, plus the review-finding arms)
2279
2280fn ctmp d ulong t view uchar * to void
2281sjoin d ST t
2282end
2283
2284fn cfx d ulong t view uchar * to void
2285sset d tfx
2286sx d t
2287sabs d
2288end
2289
2290fn cbad to void
2291put gk 1 1
2292end
2293
2294note first 600 bytes of slot s's file, trailing newlines dropped, appended to SM
2295fn chead s ulong to void
2296ok = fload s
2297if gt get gbn 0 600
2298put gbn 0 600
2299end
2300trimnl
2301for i ulong get gbn 0
2302sb SM get gb i
2303end
2304end
2305
2306note does slot s's file hold a line equal to slot l
2307fn hasln s ulong l ulong to bool
2308ok = fload s
2309if not ok
2310ret false
2311end
2312p = ulong 0
2313n = get gbn 0
2314while lt p n bound 999999
2315e = leol p
2316if lis p e l
2317ret true
2318end
2319p = add e 1
2320end
2321ret false
2322end
2323
2324note run gav into ST/out; judge exit want and (when slot SW is not empty) the line SW
2325fn arm nm view uchar * want ulong to void
2326ctmp SD tcout
2327rc = spawnf SD
2328if ne rc want
2329sset SM tcfail
2330sx SM nm
2331sx SM tcolon
2332sx SM tcex
2333sn SM rc
2334sx SM tcwant
2335sn SM want
2336sx SM tcolon
2337chead SD
2338say 1 SM
2339cbad
2340ret
2341end
2342if gt get gsl SW 0
2343if not hasln SD SW
2344sset SM tcfail
2345sx SM nm
2346sx SM tcnol
2347ss SM SW
2348sx SM tcin
2349chead SD
2350say 1 SM
2351cbad
2352ret
2353end
2354end
2355sset SM tcpass
2356sx SM nm
2357sx SM tcexit
2358sn SM rc
2359if gt get gsl SW 0
2360sx SM tcq1
2361ss SM SW
2362sb SM 39
2363end
2364sx SM tcend
2365say 1 SM
2366end
2367
2368fn pat t view uchar * to void
2369sset SW t
2370end
2371
2372fn cg to void
2373aclr
2374aps SG
2375end
2376
2377fn cF to void
2378aps SF1
2379aps SF2
2380aps SF3
2381end
2382
2383note gate rec FILE F 8|mx ... label
2384fn crec f ulong mx view uchar * lab view uchar * to void
2385cg
2386apt trec
2387aps f
2388cF
2389apt mx
2390apt tfl
2391apt tdr
2392aps SE
2393aps SC2
2394apt tfill
2395apt tfutc
2396apt lab
2397end
2398
2399fn ccmp f ulong to void
2400cg
2401apt tcmp
2402aps SR
2403aps f
2404cF
2405end
2406
2407note fixture transform: gc = xf(mode, a -> b) of slot in's file, saved to ST/outn
2408fn fxo fin ulong outn view uchar * to void
2409put gk 2 fin
2410ctmp SD outn
2411end
2412
2413fn fx mode ulong a view uchar * b view uchar * to void
2414ok = fload get gk 2
2415sset SA a
2416sset SB b
2417sclr SBLK
2418c = xf mode SA SB SBLK
2419ok = fsavc SD
2420end
2421
2422note mutant: gate.om with exactly one line replaced, compiled to ST/nm; true when built
2423fn mutant nm view uchar * a view uchar * b view uchar * to bool
2424sset SP tgateom
2425ok = fload SP
2426sset SA a
2427sset SB b
2428sclr SBLK
2429c = xf 0 SA SB SBLK
2430if ne c 1
2431sset SM tcfail
2432sx SM nm
2433sx SM tcl1
2434sx SM a
2435sx SM tcnu
2436say 1 SM
2437cbad
2438ret false
2439end
2440ctmp SD nm
2441sx SD tdotom
2442ok = fsavc SD
2443ctmp SH2 nm
2444sx SH2 tsrcom
2445rc = gcomp SOMG SD SH2
2446if ne rc 0
2447sset SM tcfail
2448sx SM nm
2449sx SM tcmdb
2450say 1 SM
2451cbad
2452ret false
2453end
2454scp SLST SH2
2455ret true
2456end
2457
2458note a kill is the mutant's own verdict code want; any other exit (spawn failure 1000, signal
2459note 256+n, exec failure 127, an unrelated refusal) is an infrastructure failure, never a kill
2460fn mres nm view uchar * survived bool rc ulong want ulong to void
2461if survived
2462sset SM tcfail
2463sx SM nm
2464sx SM tcsurv
2465say 1 SM
2466cbad
2467ret
2468end
2469if ne rc want
2470sset SM tcfail
2471sx SM nm
2472sx SM tcinfra
2473sn SM rc
2474sx SM tcwant
2475sn SM want
2476sx SM tcend
2477say 1 SM
2478cbad
2479ret
2480end
2481sset SM tcpass
2482sx SM nm
2483sx SM tckill
2484sx SM tcexit
2485sn SM rc
2486sx SM tcend
2487say 1 SM
2488end
2489
2490note mutant gate run: SLST cmp REF f F (file triple from SF1..3), rc
2491fn mcmp f ulong to ulong
2492aclr
2493aps SLST
2494apt tcmp
2495aps SR
2496aps f
2497cF
2498ctmp SD tmout
2499ret spawnf SD
2500end
2501
2502fn ref1 to void
2503note expected record of fixtures/cpu.out, in slot SLST
2504sset SLST tschem
2505sb SLST 10
2506sx SLST tlsyn
2507sb SLST 10
2508sx SLST tckk
2509ok = fsha SF1 SHEX
2510ss SLST SHEX
2511sb SLST 10
2512sx SLST tmgk
2513ok = fsha SF2 SHEX
2514ss SLST SHEX
2515sb SLST 10
2516sx SLST tprk
2517ok = fsha SF3 SHEX
2518ss SLST SHEX
2519sb SLST 10
2520sx SLST tref2
2521ss SLST SE
2522sb SLST 10
2523sx SLST tref3
2524ss SLST SC2
2525sb SLST 10
2526sx SLST tref4
2527end
2528
2529fn sameb a ulong b ulong to bool
2530ok = fload a
2531if not ok
2532ret false
2533end
2534ok = floadc b
2535if not ok
2536ret false
2537end
2538if ne get gbn 0 get gcn 0
2539ret false
2540end
2541for i ulong get gbn 0
2542if ne get gb i get gc i
2543ret false
2544end
2545end
2546ret true
2547end
2548
2549fn cpass t view uchar * to void
2550sset SM tcpass
2551sx SM t
2552say 1 SM
2553end
2554
2555fn cfailm t view uchar * to void
2556sset SM tcfail
2557sx SM t
2558say 1 SM
2559cbad
2560end
2561
2562note the recorder and comparator arms on the synthetic fixtures
2563fn chk1 to void
2564sayt 1 th1
2565ref1
2566ctmp SX tcrefx
2567ok = fsavs SX SLST
2568ctmp SR tref
2569cfx SY tcpuo
2570crec SY t8 tsyn
2571fo = fopf SR 577
2572rc = spawn -1 fo fo
2573fcls fo
2574if and eq rc 0 sameb SR SX
2575cpass tcrr
2576else
2577cfailm tcrrb
2578end
2579fxo SY tamb
2580fx 0 tl1 tl1a
2581ctmp SD tamb
2582crec SD t8 tsyn
2583pat tpamb
2584arm trecamb 5
2585fxo SY tflo
2586fx 0 tl1 tl1b
2587ctmp SD tflo
2588crec SD t8 tsyn
2589pat tpflo
2590arm trecflo 0
2591fxo SY tgar
2592fx 1 tgtec tgteg
2593ctmp SD tgar
2594crec SD t8 tsyn
2595pat tpfmt
2596arm trecgpu 4
2597crec SY t9 tsyn
2598arm trecsh 4
2599fxo SY tord
2600fx 1 tt12 tt13
2601ctmp SD tord
2602crec SD t8 tsyn
2603arm trecso 4
2604ok = fload SY
2605xlast
2606ctmp SD tnogte
2607ok = fsavc SD
2608crec SD t8 tsyn
2609arm trecng 4
2610crec SY t8 tmaybe
2611pat tpbarg
2612arm treclab 2
2613cg
2614apt trec
2615aps SY
2616pat tnl0
2617arm trecuse 2
2618end
2619
2620fn chk2 to void
2621sayt 1 th2
2622cfx SZ tgm
2623ccmp SZ
2624pat tpm1
2625arm tcm1 0
2626ccmp SZ
2627pat tpm2
2628arm tcm2 0
2629fxo SZ tdiv
2630fx 1 tt13x tt13y
2631ctmp SD tdiv
2632ccmp SD
2633pat tpdiv
2634arm tcdiv 1
2635ok = fload SZ
2636sset SA tt04
2637sset SB tnl0
2638sclr SH2
2639c = xf 2 SA SB SH2
2640cback
2641sset SA tt05
2642c = xf 2 SA SB SH2
2643cback
2644sset SA tg214
2645sset SB tg212
2646c = xf 1 SA SB SH2
2647ctmp SD tshort
2648ok = fsavc SD
2649ccmp SD
2650pat tpshort
2651arm tcshort 1
2652fxo SZ tdrift
2653fx 1 tt02 tt02d
2654ctmp SD tdrift
2655ccmp SD
2656pat tpdrift
2657arm tcdrift 1
2658ctmp SD tck2
2659sset SV tck2t
2660ok = fsavs SD SV
2661end
2662
2663fn chk3 to void
2664ctmp SD tck2
2665scp SH2 SF1
2666scp SF1 SD
2667ccmp SZ
2668scp SF1 SH2
2669pat tpnck
2670arm tcock 3
2671scp SH2 SF2
2672scp SF2 SD
2673ccmp SZ
2674scp SF2 SH2
2675pat tpnmg
2676arm tcomg 3
2677scp SH2 SF3
2678scp SF3 SD
2679ccmp SZ
2680scp SF3 SH2
2681pat tpnpr
2682arm tcopr 3
2683ok = fload SZ
2684sset SA tt1
2685sset SB tnl0
2686sclr SY
2687c = xf 2 SA SB SY
2688cback
2689sset SA tg214
2690sset SB tg16
2691c = xf 1 SA SB SY
2692ctmp SD tone0
2693ok = fsavc SD
2694ccmp SD
2695pat tpnp
2696arm tccount 3
2697cfx SY tcpuo
2698ccmp SY
2699pat tpfmt
2700arm tccpu 4
2701fxo SR tbadref
2702fx 0 trdg trdgg
2703ctmp SD tbadref
2704cg
2705apt tcmp
2706aps SD
2707aps SZ
2708cF
2709arm tcbadref 4
2710fxo SR tlenref
2711fx 0 tp15 tp14
2712ctmp SD tlenref
2713cg
2714apt tcmp
2715aps SD
2716aps SZ
2717cF
2718arm tclen 4
2719cg
2720apt tcmp
2721aps SR
2722pat tnl0
2723arm tcuse 2
2724end
2725
2726note review finding 2: the record header and row bounds
2727fn chk4 to void
2728sayt 1 th4
2729cfx SZ tgm
2730pat tpfmt
2731fxo SR tf2a
2732fx 0 tp15 tp13
2733ok = fload SD
2734sset SA tl15
2735sset SB tl13
2736sclr SY
2737c = xf 0 SA SB SY
2738cback
2739sset SA tm15
2740sset SB tm13
2741c = xf 0 SA SB SY
2742ctmp SD tf2a
2743ok = fsavc SD
2744cg
2745apt tcmp
2746aps SD
2747aps SZ
2748cF
2749arm tcrmin 4
2750fxo SR tf2b
2751fx 0 tm06 tm06b
2752ctmp SD tf2b
2753cg
2754apt tcmp
2755aps SD
2756aps SZ
2757cF
2758arm tcfloor 4
2759fxo SR tf2c
2760fx 0 tmx8 tmx0
2761ctmp SD tf2c
2762cg
2763apt tcmp
2764aps SD
2765aps SZ
2766cF
2767arm tcmx0 4
2768fxo SR tf2d
2769fx 0 tmx8 tmx5
2770ctmp SD tf2d
2771cg
2772apt tcmp
2773aps SD
2774aps SZ
2775cF
2776arm tcmx5 4
2777fxo SR tf2e
2778fx 0 tmx8 tmx4097
2779ctmp SD tf2e
2780cg
2781apt tcmp
2782aps SD
2783aps SZ
2784cF
2785arm tcmxbig 4
2786fxo SR tf2f
2787fx 0 tdr0a tdr0b
2788ctmp SD tf2f
2789cg
2790apt tcmp
2791aps SD
2792aps SZ
2793cF
2794arm tcdr0 4
2795fxo SR tf2g
2796fx 0 tfl0a tfl0b
2797ctmp SD tf2g
2798cg
2799apt tcmp
2800aps SD
2801aps SZ
2802cF
2803arm tcfl0 4
2804end
2805
2806fn chk5 to void
2807sayt 1 th5
2808if mutant tm1 tm1a tm1b
2809ctmp SD tdiv
2810rc = mcmp SD
2811mres tm1 eq rc 1 rc 0
2812end
2813if mutant tm2 tm2a tm2b
2814ctmp SD tdrift
2815rc = mcmp SD
2816mres tm2 eq rc 1 rc 0
2817end
2818if mutant tm3 tm3a tm3b
2819ctmp SD tck2
2820scp SH2 SF1
2821scp SF1 SD
2822cfx SD tgm
2823rc = mcmp SD
2824scp SF1 SH2
2825mres tm3 eq rc 3 rc 0
2826end
2827if mutant tm4 tm4a tm4b
2828cg
2829scp SG SLST
2830cfx SY tcpuo
2831crec SY t8 tsyn
2832ctmp SG tgateb
2833ctmp SD tmout
2834fo = fopf SD 577
2835rc = spawn -1 fo -1
2836fcls fo
2837ctmp SX tcrefx
2838mres tm4 sameb SD SX rc 0
2839end
2840if mutant tm5 tm5a tm5b
2841ctmp SD tshort
2842rc = mcmp SD
2843ctmp SD tmout
2844pat tpshort
2845mres tm5 hasln SD SW rc 1
2846end
2847if mutant tm6 tm6a tm6b
2848ctmp SD tf2b
2849aclr
2850aps SLST
2851apt tcmp
2852aps SD
2853cfx SY tgm
2854aps SY
2855cF
2856ctmp SD tmout
2857rc = spawnf SD
2858mres tm6 eq rc 4 rc 0
2859end
2860if mutant tm7 tm7a tm7b
2861ctmp SD tf2a
2862aclr
2863aps SLST
2864apt tcmp
2865aps SD
2866cfx SY tgm
2867aps SY
2868cF
2869ctmp SD tmout
2870rc = spawnf SD
2871mres tm7 eq rc 4 rc 0
2872end
2873end
2874
2875note the b0/b1 line comparison: count of differing line pairs; slot SW = b1's differing line
2876note slot SW = gc bytes a..b
2877fn lslotc a ulong b ulong to void
2878sclr SW
2879for i ulong sub b a
2880sb SW get gc add a i
2881end
2882end
2883
2884fn lsame p ulong e ulong q ulong f ulong to bool
2885if ne sub e p sub f q
2886ret false
2887end
2888for i ulong sub e p
2889if ne get gb add p i get gc add q i
2890ret false
2891end
2892end
2893ret true
2894end
2895
2896fn ldiff to ulong
2897p = ulong 0
2898q = ulong 0
2899d = ulong 0
2900while and lt p get gbn 0 lt q get gcn 0 bound 999999
2901e = leol p
2902f = q
2903while lt f get gcn 0 bound 999999
2904if eq get gc f 10
2905break
2906end
2907f = add f 1
2908end
2909if not lsame p e q f
2910d = add d 1
2911lslotc q f
2912end
2913p = add e 1
2914q = add f 1
2915end
2916if or lt p get gbn 0 lt q get gcn 0
2917d = add d 1000
2918end
2919ret d
2920end
2921
2922note self build: drive build OMC TRAIN REV ST/out [NEG slot]
2923fn cbld omc ulong trn ulong rev view uchar * ng ulong to void
2924aclr
2925apt tself
2926apt tbuild
2927aps omc
2928aps trn
2929apt rev
2930aps SOUT
2931if gt get gsl ng 0
2932aps ng
2933end
2934end
2935
2936fn ccount s ulong t view uchar * to ulong
2937ok = fload s
2938sset SA t
2939sclr SY
2940ret xf 0 SA SA SY
2941end
2942
2943fn shaof d ulong dir view uchar * f view uchar * to void
2944ctmp SP dir
2945sb SP 47
2946sx SP f
2947sclr d
2948ok = fsha SP d
2949end
2950
2951note slot d = the commit id rev names in repository slot s (no replace refs); false on failure
2952fn revof s ulong rv view uchar * d ulong to bool
2953agit
2954apt tdash
2955aps s
2956apt trevp
2957apt tverify
2958apt rv
2959ctmp SD trvo
2960fo = fopf SD 577
2961rc = spawn -1 fo -1
2962fcls fo
2963ok = fload SD
2964trimnl
2965sclr d
2966if or ne rc 0 ne get gbn 0 40
2967ret false
2968end
2969lslot d 0 40
2970ret true
2971end
2972
2973fn chk6 to void
2974sayt 1 th6
2975sclr SNEG
2976ctmp SOUT tb0
2977cbld SOMC STRN thead SNEG
2978pat tnl0
2979arm tbdec 0
2980ctmp SP tb0
2981sb SP 47
2982sx SP tgold
2983a = ccount SP toggm
2984b = ccount SP tmain
2985if and eq a 1 eq b 1
2986cpass tbone
2987else
2988cfailm tbone
2989end
2990sset SNEG tnegf
2991sabs SNEG
2992ctmp SOUT tb1
2993cbld SOMC STRN thead SNEG
2994arm tbnegc 0
2995ok = fload SP
2996ctmp SQ tb1
2997sb SQ 47
2998sx SQ tgold
2999ok = floadc SQ
3000d = ldiff
3001if and eq d 1 seqt SW tnegl
3002sset SM tcpass
3003sx SM tnegok
3004ss SM SW
3005sx SM tcq2
3006say 1 SM
3007else
3008sset SM tcfail
3009sx SM tnegbad
3010sn SM d
3011sx SM tcolon
3012ss SM SW
3013say 1 SM
3014cbad
3015end
3016shaof SH2 tb0 tgoldb
3017shaof SHEX tb1 tgoldb
3018if seqs SH2 SHEX
3019cfailm tnegsame
3020else
3021cpass tnegdiff
3022end
3023ctmp SNEG ttwo
3024sset SV ttwot
3025ok = fsavs SNEG SV
3026ctmp SOUT tb2
3027cbld SOMC STRN thead SNEG
3028pat tpchg2
3029arm tbwrong 4
3030sset SV ttrue0
3031sclr SNEG
3032ctmp SOUT tb3
3033cbld SV STRN thead SNEG
3034pat tnl0
3035arm tbother 3
3036ctmp SOUT tb6
3037cbld SOMC STRN tzrev SNEG
3038arm tbrev 1
3039aclr
3040apt tself
3041apt tgate
3042aps STRN
3043apt thead
3044aps SR
3045cF
3046ctmp SD tg0
3047aps SD
3048pat tnohold
3049arm tgnohold 3
3050end
3051
3052note review finding 1: the build is the commit, never the working tree
3053fn chk7 to void
3054sayt 1 th7
3055ctmp SX ttmd
3056agit
3057apt tclone
3058apt tq0
3059apt tnohl
3060aps STRN
3061aps SX
3062pat tnl0
3063arm tclonea 0
3064sjoin SP SX tgrpath
3065fd = fopf SP 1025
3066w = write fd ttamp 0 len ttamp
3067fcls fd
3068agit
3069apt tdash
3070aps SX
3071apt tupidx
3072apt tskip
3073apt tmodel
3074arm tskipa 0
3075sjoin SP SX tmodel
3076fd = fopf SP 1025
3077w = write fd ttamp 0 len ttamp
3078fcls fd
3079ctmp SOUT tb4
3080cbld SOMC SX thead SNEG
3081arm tbwt 0
3082shaof SH2 tb0 tgold
3083shaof SHEX tb4 tgold
3084if seqs SH2 SHEX
3085sset SM tcpass
3086sx SM twtok
3087ss SM SHEX
3088sx SM tcend
3089say 1 SM
3090else
3091cfailm twtbad
3092end
3093agit
3094apt tdash
3095aps SX
3096apt tdc
3097apt tun
3098apt tdc
3099apt tue
3100apt tcmt
3101apt tq0
3102apt tdasha
3103apt tdashm
3104apt ttamper
3105arm tcommita 0
3106ctmp SOUT tb5
3107cbld SOMC SX thead SNEG
3108arm tbcm 0
3109shaof SHEX tb5 tgold
3110if seqs SH2 SHEX
3111cfailm tcmbad
3112else
3113cpass tcmok
3114end
3115note review finding (e19cafd0 local read): a replace ref must not swap the archived tree
3116agit
3117apt tdash
3118aps SX
3119apt trepl
3120apt thead1
3121apt thead
3122arm treplA 0
3123ctmp SOUT tb7
3124cbld SOMC SX thead1 SNEG
3125arm tbrp 0
3126shaof SHEX tb7 tgold
3127if seqs SH2 SHEX
3128cpass trpok
3129else
3130cfailm trpbad
3131end
3132note review finding 1 (27da864e local read): TRAIN's info/grafts and info/attributes must not select
3133note the commit or shape the snapshot. U = an empty commit on the tamper T; HEAD~1 is T (the b5 source),
3134note and the graft U -> HEAD~2 would make HEAD~1 name the clean commit instead
3135shaof SY tb5 tgold
3136agit
3137apt tdash
3138aps SX
3139apt tdc
3140apt tun
3141apt tdc
3142apt tue
3143apt tcmt
3144apt tq0
3145apt tallowe
3146apt tdashm
3147apt ttamper
3148arm tgrbase 0
3149if not revof SX thead SZ
3150cfailm tfixbad
3151ret
3152end
3153if not revof SX thead2 SLK
3154cfailm tfixbad
3155ret
3156end
3157sclr SV
3158ss SV SZ
3159sb SV 32
3160ss SV SLK
3161sb SV 10
3162sjoin SP SX tgrf
3163ok = fsavs SP SV
3164ctmp SOUT tb8
3165cbld SOMC SX thead1 SNEG
3166arm tbgr 0
3167shaof SHEX tb8 tgold
3168if seqs SY SHEX
3169cpass tgrok
3170else
3171cfailm tgrbad
3172end
3173sjoin SP SX tgrf
3174rmf SP
3175sset SV tgrpath
3176sx SV texig
3177sjoin SP SX tatf
3178ok = fsavs SP SV
3179ctmp SOUT tb9
3180cbld SOMC SX thead1 SNEG
3181arm tbat 0
3182shaof SHEX tb9 tgold
3183if seqs SY SHEX
3184cpass tatok
3185else
3186cfailm tatbad
3187end
3188end
3189
3190note review finding 2 (27da864e local read): the gate resolves REV once. Fixture: branch gmove at a
3191note commit whose build.sh first moves gmove one commit back, so every build moves the branch
3192fn chk8 to void
3193sayt 1 th8
3194ctmp SX ttg
3195agit
3196apt tclone
3197apt tq0
3198apt tnohl
3199aps STRN
3200aps SX
3201pat tnl0
3202arm tclonea 0
3203agit
3204apt tdash
3205aps SX
3206apt tco
3207apt tq0
3208apt tdb
3209apt tgmv
3210arm tgfx1 0
3211sjoin SP SX tbsh
3212ok = fload SP
3213if not ok
3214cfailm tfixbad
3215ret
3216end
3217sset SV tmvl1
3218ss SV SX
3219sx SV tmvl2
3220fd = fopf SP 577
3221say fd SV
3222ok = wgb fd
3223fcls fd
3224agit
3225apt tdash
3226aps SX
3227apt tdc
3228apt tun
3229apt tdc
3230apt tue
3231apt tcmt
3232apt tq0
3233apt tdasha
3234apt tdashm
3235apt ttamper
3236arm tgfx2 0
3237if not revof SX tgmv SY
3238cfailm tfixbad
3239ret
3240end
3241note the gate child claims the hold only so its build stage runs; REF is absent, so the gate stops
3242note at NOT_RUN (no max_tokens) before any GPU program can start
3243ctmp SOUT tgout
3244ctmp SREF tnoref
3245aclr
3246apt tenv
3247apt theld1
3248sset SV tomctr
3249sb SV 61
3250ss SV SOMC
3251aps SV
3252sset SV tomcgt
3253sb SV 61
3254ss SV SOMG
3255aps SV
3256sset SV tprocp
3257sn SV ulong getpid
3258sx SV texe
3259aps SV
3260apt tgate
3261aps SX
3262apt tgmv
3263aps SREF
3264aps SF1
3265aps SF2
3266aps SF3
3267aps SOUT
3268pat tgnomx
3269arm tgfa 3
3270pat tnl0
3271scp SREV SY
3272ok1 = gbid tcand
3273ok2 = gbid tnegd
3274if and ok1 ok2
3275cpass tgfok
3276else
3277cfailm tgfbad
3278end
3279ctmp SX ttg
3280ok = revof SX tgmv SZ
3281if and ok not seqs SZ SY
3282cpass tgmok
3283else
3284cfailm tgmbad
3285end
3286end
3287
3288fn dcheck to ulong
3289put gk 1 0
3290sset SP tgateom
3291if not there SP
3292sayt 2 tnoroot
3293ret 2
3294end
3295ok = senv SOMG tomcgt
3296sabs SOMG
3297sset ST tgchk
3298sn ST ulong getpid
3299ok = mkd ST
3300ctmp SG tgateb
3301sset SP tgateom
3302rc = gcomp SOMG SP SG
3303if ne rc 0
3304rmrf ST
3305ret rc
3306end
3307cfx SF1 tfck
3308cfx SF2 tfmg
3309cfx SF3 tfpr
3310sset SE tnl0
3311for i ulong 64
3312sb SE 101
3313end
3314sset SC2 tfsrc
3315chk1
3316chk2
3317chk3
3318chk4
3319chk5
3320tr = senv STRN ttrainv
3321om = senv SOMC tomctr
3322if and tr om
3323sabs STRN
3324sabs SOMC
3325sclr SNEG
3326chk6
3327chk7
3328chk8
3329else
3330sayt 1 tcnor
3331end
3332rmrf ST
3333if eq get gk 1 0
3334sayt 1 tcgood
3335ret 0
3336end
3337sayt 1 tcbad
3338ret 1
3339end
3340
3341note ---- main
3342
3343fn argabs s ulong i ulong to void
3344ok = sarg s i
3345if not ok
3346sayt 2 tuse
3347exit 2
3348end
3349sabs s
3350end
3351
3352fn main to int
3353na = ulong argcnt
3354if lt na 2
3355sayt 2 tuse
3356ret 2
3357end
3358ok = sarg SM 1
3359sset SP tgateom
3360if not there SP
3361sayt 2 tnoroot
3362ret 2
3363end
3364if seqt SM tbuild
3365if or lt na 6 gt na 7
3366sayt 2 tuse
3367ret 2
3368end
3369argabs SOMC 2
3370argabs STRN 3
3371ok = sarg SREV 4
3372argabs SOUT 5
3373sclr SNEG
3374if eq na 7
3375argabs SNEG 6
3376end
3377ret int dbuild
3378end
3379if seqt SM trecord
3380if or lt na 8 gt na 9
3381sayt 2 tuse
3382ret 2
3383end
3384argabs STRN 2
3385ok = sarg SREV 3
3386argabs SCK 4
3387argabs SMG 5
3388argabs SPR 6
3389argabs SOUT 7
3390sset SLAB treal
3391if eq na 9
3392ok = sarg SLAB 8
3393end
3394ok = senv SOMC tomctr
3395sabs SOMC
3396ok = senv SOMG tomcgt
3397sabs SOMG
3398ret int drec
3399end
3400if seqt SM tgate
3401if ne na 9
3402sayt 2 tuse
3403ret 2
3404end
3405argabs STRN 2
3406ok = sarg SREV 3
3407argabs SREF 4
3408argabs SCK 5
3409argabs SMG 6
3410argabs SPR 7
3411argabs SOUT 8
3412ok = senv SOMC tomctr
3413sabs SOMC
3414ok = senv SOMG tomcgt
3415sabs SOMG
3416ret int dgate
3417end
3418if seqt SM tcore
3419ret int dcore
3420end
3421if seqt SM tcheck
3422ret int dcheck
3423end
3424sayt 2 tuse
3425ret 2
3426end