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 / seed / build / release.om

1880 lines · 33638 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note seed/build/release.om: Pure seeded-Omega Build, Release, UXL & Automation Coordinator.
3note Replaces Makefile/shell/Python delivery glue:
4note om-release check-locks [ROOT] verify omc pin, *.lock 40-hex commits, and zero-disk-secrets
5note om-release check-paths [ROOT] pure-Omega replacement for tools/uxl/windows_paths.py
6note om-release layers [SCRATCH] compile and run all 8 SI pure-Omega layer units-gate.om suites
7note om-release uxl [SCRATCH] pure-Omega UXL delivery verification (host, level1 65 files, SPIR-V, Xe)
8note om-release package OUTDIR VERSION build & package pure-Omega toolchain + SHA256SUMS + manifests
9note om-release verify OUTDIR fail-closed re-hash verification of RELEASE-MANIFEST.tsv & SHA256SUMS
10note Zero shell, zero Python.
11note Build: cat seed/build/common.om seed/build/release.om | seed/out/omc > build/om-release
12
13text rl_usage "usage: om-release check-locks [ROOT] | check-paths [ROOT] | layers [SCRATCH] | uxl [SCRATCH] | package OUTDIR VERSION | verify OUTDIR\n"
14text rl_c_locks "check-locks"
15text rl_c_paths "check-paths"
16text rl_c_layers "layers"
17text rl_c_uxl "uxl"
18text rl_c_pkg "package"
19text rl_c_ver "verify"
20
21text rl_omc "seed/out/omc"
22text rl_omcsha "seed/out/omc.sha256"
23text rl_s0hex "seed/rung0/seed0.hex"
24text rl_l_phys "physics.lock"
25text rl_l_aien "aienos.lock"
26text rl_l_arg "argus.lock"
27text rl_l_br "om/omega-bridge.lock"
28text rl_defscr "build/om-release-work"
29text rl_pass_lk1 "PASS check-locks: omc="
30text rl_pass_lk2 " locks=4 secrets=0\n"
31text rl_fail_lk "FAIL check-locks: "
32text rl_e_omc "omc digest mismatch or missing seed/out/omc.sha256\n"
33text rl_e_lock "malformed lockfile: "
34text rl_e_sec "plaintext .env secret file found: "
35text rl_env_dot ".env"
36text rl_env_ex ".env.example"
37text rl_env_tp ".env.template"
38text rl_d_git ".git"
39text rl_d_bld "build"
40text rl_d_ev "evidence"
41
42note Windows path check strings
43text rl_wp_0 "windows-paths: 0 findings ("
44text rl_wp_f "windows-paths: FINDING "
45text rl_wp_end " paths)\n"
46text rl_wp_cnt1 "windows-paths: "
47text rl_wp_cnt2 " findings ("
48text rl_r_trail "trailing-dot-or-space "
49text rl_r_char "forbidden-character "
50text rl_r_res "reserved-name "
51text rl_r_case "case-collision "
52text rl_res_con "con"
53text rl_res_prn "prn"
54text rl_res_aux "aux"
55text rl_res_nul "nul"
56
57note Layer gate strings
58text rl_ngsha "seed/ng/sha256.om"
59text rl_om2l "om2\n"
60text rl_ly_0 "gpu"
61text rl_ly_1 "aienux"
62text rl_ly_2 "apps"
63text rl_ly_3 "bridge"
64text rl_ly_4 "core"
65text rl_ly_5 "protocol"
66text rl_ly_6 "si"
67text rl_ly_7 "train"
68text rl_ly_suf "/units-gate.om"
69text rl_ly_pass "PASS layer "
70text rl_ly_fail "FAIL layer "
71text rl_ly_sum1 "LAYERS pass="
72text rl_ly_sum2 " fail="
73
74note UXL strings
75text rl_l1_dir "tools/uxl/level1/"
76text rl_l1_json "tools/uxl/level1/SHA256.json"
77text rl_uxl_s1 "PASS uxl-stage1 host+pin+paths\n"
78text rl_uxl_f1 "FAIL uxl-stage1 host+pin+paths\n"
79text rl_uxl_s2 "PASS uxl-stage2 level1 files="
80text rl_uxl_f2 "FAIL uxl-stage2 level1 mismatch: "
81text rl_uxl_s3 "PASS uxl-stage3 spirv-check\n"
82text rl_uxl_f3 "FAIL uxl-stage3 spirv-check\n"
83text rl_uxl_s4 "PASS uxl-stage4 rmsnorm cl+vk\n"
84text rl_uxl_f4 "FAIL uxl-stage4 rmsnorm\n"
85text rl_uxl_s5 "PASS uxl-stage5 opencl+vulkan kernels\n"
86text rl_uxl_f5 "FAIL uxl-stage5 opencl+vulkan kernels\n"
87text rl_uxl_s6 "PASS uxl-stage6 intel-xe\n"
88text rl_uxl_f6 "FAIL uxl-stage6 intel-xe\n"
89text rl_uxl_sum1 "UXL-OMEGA pass="
90text rl_uxl_sum2 " fail="
91text rl_gpuc_bin "/om-gpucoord"
92text rl_gpuc_src "/om-gpucoord.om"
93text rl_gpuc_out "/gpuc.out"
94text rl_srun "spirv-run"
95text rl_schk "spirv-check"
96text rl_ixe "intel-gate"
97text rl_k_rms "rmsnorm"
98text rl_k_vadd "vadd"
99text rl_k_fsum "fsum16"
100text rl_k_gemm "gemm16"
101text rl_e_cl "cl"
102text rl_e_vk "vk"
103text rl_sha_rms "144c89820d5d005af741dfcace8f9882bae481d72f1745aef36b5014cbaadb46"
104text rl_sha_vadd "72d0c1b2928779e83518f0b4c7d101d933cf89f210cd4627e138c33c9ce9b6a6"
105text rl_sha_fsum "6a6de93787e333d506d50996589af3e025c16b9bfc7c9493e1af34578e076290"
106text rl_sha_gemm "d1e02b7d8dd06cd84ee45294b0525000cf7c61e6f6fa32bfa81d3719e47a6987"
107
108note Package & Verify strings
109text rl_src_com "seed/build/common.om"
110text rl_src_bir "seed/build/birth.om"
111text rl_src_uni "seed/build/units.om"
112text rl_src_tls "seed/build/tlsbuild.om"
113text rl_src_efi "seed/build/sparkefi.om"
114text rl_src_gpu "seed/build/gpucoord.om"
115text rl_src_rel "seed/build/release.om"
116text rl_d_bin "/bin"
117text rl_d_seed "/seed"
118text rl_r_omc "bin/omc"
119text rl_r_bir "bin/om-birth"
120text rl_r_uni "bin/om-units"
121text rl_r_tls "bin/om-tlsbuild"
122text rl_r_efi "bin/om-sparkefi"
123text rl_r_gpu "bin/om-gpucoord"
124text rl_r_rel "bin/om-release"
125text rl_r_s0 "seed/seed0.hex"
126text rl_r_sha "seed/omc.sha256"
127text rl_f_sums "/SHA256SUMS"
128text rl_f_man "/RELEASE-MANIFEST.tsv"
129text rl_f_json "/release-manifest.json"
130text rl_man_hdr "path\tbytes\tsha256\n"
131text rl_sp2 " "
132text rl_tab "\t"
133text rl_j_1 "{\n \"schema\": \"omega-release-v1\",\n \"version\": \""
134text rl_j_2 "\",\n \"omc_sha256\": \""
135text rl_j_3 "\",\n \"artifacts\": [\n"
136text rl_j_a1 " {\"path\": \""
137text rl_j_a2 "\", \"bytes\": "
138text rl_j_a3 ", \"sha256\": \""
139text rl_j_a4 "\"}"
140text rl_j_cm ",\n"
141text rl_j_end "\n ]\n}\n"
142text rl_pkg_ok1 "RELEASE PACKAGE PASS version="
143text rl_pkg_ok2 " artifacts=9 out="
144text rl_pkg_bad "RELEASE PACKAGE FAIL\n"
145text rl_ver_ok "RELEASE VERIFY PASS artifacts="
146text rl_ver_bad "RELEASE VERIFY FAIL: "
147text rl_ver_e1 "missing or unreadable RELEASE-MANIFEST.tsv\n"
148text rl_ver_e2 "bad header or malformed row\n"
149text rl_ver_e3 "unsafe or duplicate path\n"
150text rl_ver_e4 "size or sha256 mismatch: "
151text rl_ver_e5 "empty manifest\n"
152text rl_ver_e6 "SHA256SUMS mismatch\n"
153
154global rl_root uchar 4096
155global rl_rootl ulong 1
156global rl_scr uchar 4096
157global rl_scrl ulong 1
158global rl_out uchar 4096
159global rl_outl ulong 1
160global rl_ver uchar 256
161global rl_verl ulong 1
162global rl_omchex uchar 64
163global rl_findings ulong 1
164global rl_paths ulong 1
165global rl_secrets ulong 1
166global rl_dstack uchar *
167global rl_dso ulong 1
168global rl_sibs uchar *
169global rl_sibn ulong 1
170global rl_sibc ulong 1
171global rl_siboff ulong 4096
172global rl_siblen ulong 4096
173global rl_l1buf uchar *
174global rl_l1n ulong 1
175global rl_man uchar *
176global rl_mann ulong 1
177global rl_sums uchar *
178global rl_sumsn ulong 1
179global rl_json uchar *
180global rl_jsonn ulong 1
181global rl_seen uchar *
182global rl_seenn ulong 1
183global rl_pkg_idx ulong 1
184
185fn rl_pa_root rel view uchar * to void
186cb_pa_clr
187rl = get rl_rootl 0
188if gt rl 0
189for i ulong rl bound 4096
190cb_pa_ch get rl_root i
191end
192cb_pa_ch 47
193end
194cb_pa_tx rel
195end
196
197fn rl_check_hex_line allow_comments bool to bool
198n = get cb_n 0
199i = ulong 0
200found = ulong 0
201while lt i n bound 9223372036854775807
202e = i
203while lt e n bound 9223372036854775807
204if eq get cb_rb e 10
205break
206end
207e = add e 1
208end
209ll = sub e i
210if allow_comments
211if or eq ll 0 eq get cb_rb i 35
212i = add e 1
213continue
214end
215end
216if ne ll 40
217ret false
218end
219for j ulong 40
220if not cb_is_hex get cb_rb add i j
221ret false
222end
223end
224found = add found 1
225if gt found 1
226ret false
227end
228i = add e 1
229end
230ret eq found 1
231end
232
233fn rl_check_one_lock rel view uchar * allow_c bool to bool
234rl_pa_root rel
235if not cb_read_pa
236cb_err rl_fail_lk
237cb_err rl_e_lock
238cb_err rel
239cb_err cb_nl
240ret false
241end
242if not rl_check_hex_line allow_c
243cb_err rl_fail_lk
244cb_err rl_e_lock
245cb_err rel
246cb_err cb_nl
247ret false
248end
249ret true
250end
251
252fn rl_is_lower_eq buf_off ulong blen ulong t view uchar * to bool
253if ne blen len t
254ret false
255end
256for j ulong blen bound 256
257c = get cb_dent add buf_off j
258if and ge c 65 le c 90
259c = add c 32
260end
261if ne c get t j
262ret false
263end
264end
265ret true
266end
267
268fn rl_name_is_secret off ulong nlen ulong to bool
269if lt nlen 4
270ret false
271end
272if ne get cb_dent off 46
273ret false
274end
275if ne get cb_dent add off 1 101
276ret false
277end
278if ne get cb_dent add off 2 110
279ret false
280end
281if ne get cb_dent add off 3 118
282ret false
283end
284if eq nlen 4
285ret true
286end
287if ne get cb_dent add off 4 46
288ret false
289end
290if rl_is_lower_eq off nlen rl_env_ex
291ret false
292end
293if rl_is_lower_eq off nlen rl_env_tp
294ret false
295end
296ret true
297end
298
299fn rl_dent_nlen ns ulong lim ulong to ulong
300nl = ulong 0
301while lt add ns nl lim bound 256
302if eq get cb_dent add ns nl 0
303break
304end
305nl = add nl 1
306end
307ret nl
308end
309
310fn rl_dstack_push ns ulong nl ulong to void
311so = get rl_dso 0
312need = add add so nl 2
313if gt need len rl_dstack
314cap = len rl_dstack
315if eq cap 0
316cap = 65536
317end
318while lt cap need bound 64
319cap = mul cap 2
320end
321z0 = enlarge rl_dstack cap
322end
323put rl_dstack so uchar and nl 255
324put rl_dstack add so 1 uchar shr nl 8
325for j ulong nl bound 256
326put rl_dstack add add so 2 j get cb_dent add ns j
327end
328put rl_dso 0 need
329end
330
331fn rl_pa_append_dstack cur ulong nl ulong base_len ulong to void
332put cb_n 3 base_len
333if gt base_len 0
334cb_pa_ch 47
335end
336for j ulong nl bound 256
337cb_pa_ch get rl_dstack add add cur 2 j
338end
339end
340
341fn rl_sec_ent dt uchar ns ulong nl ulong depth ulong to void
342if and eq nl 1 eq get cb_dent ns 46
343ret
344end
345if and eq nl 2 and eq get cb_dent ns 46 eq get cb_dent add ns 1 46
346ret
347end
348if and eq dt 4 rl_is_lower_eq ns nl rl_d_git
349ret
350end
351if and eq dt 4 and eq depth 0 or rl_is_lower_eq ns nl rl_d_bld rl_is_lower_eq ns nl rl_d_ev
352ret
353end
354if and ne dt 4 rl_name_is_secret ns nl
355cb_err rl_fail_lk
356cb_err rl_e_sec
357cb_wbuf_pa 2
358cb_err cb_slash
359r = write 2 cb_dent ns nl
360cb_err cb_nl
361put rl_secrets 0 add get rl_secrets 0 1
362end
363if eq dt 4
364rl_dstack_push ns nl
365end
366end
367
368fn rl_scan_sec_buf nr ulong depth ulong to void
369pos = ulong 0
370while lt pos nr bound 32768
371rlen = or ulong get cb_dent add pos 16 shl ulong get cb_dent add pos 17 8
372if eq rlen 0
373break
374end
375dt = get cb_dent add pos 18
376ns = add pos 19
377nl = rl_dent_nlen ns add pos rlen
378rl_sec_ent dt ns nl depth
379pos = add pos rlen
380end
381end
382
383fn rl_dstack_u16 cur ulong to ulong
384b0 = ulong get rl_dstack cur
385b1 = ulong get rl_dstack add cur 1
386ret or b0 shl b1 8
387end
388
389fn rl_read_sec_dir depth ulong to bool
390dfd = fopen cb_pa 0 get cb_n 3 540672 0
391if lt dfd 0
392ret false
393end
394while true bound 65536
395nr = getdnts int dfd cb_dent 0 32768
396if le nr 0
397break
398end
399rl_scan_sec_buf ulong nr depth
400end
401z1 = fclose int dfd
402ret true
403end
404
405note Recursive scan for .env secrets (depth bounded by stack, skips .git / build / evidence)
406fn rl_scan_secrets_dir depth ulong to void
407if gt depth 32
408ret
409end
410base_len = get cb_n 3
411start_so = get rl_dso 0
412if not rl_read_sec_dir depth
413ret
414end
415end_so = get rl_dso 0
416cur = start_so
417while lt cur end_so bound 1048576
418nl = rl_dstack_u16 cur
419rl_pa_append_dstack cur nl base_len
420rl_scan_secrets_dir add depth 1
421cur = add add cur 2 nl
422end
423put cb_n 3 base_len
424put rl_dso 0 start_so
425end
426
427fn rl_check_omc_pin to bool
428rl_pa_root rl_omcsha
429if not cb_read_pa
430ret false
431end
432if lt get cb_n 0 64
433ret false
434end
435for j ulong 64
436c = get cb_rb j
437if not cb_is_hex c
438ret false
439end
440put rl_omchex j c
441end
442rl_pa_root rl_omc
443if not cb_sha_file_pa
444ret false
445end
446for j ulong 64
447if ne get cb_shex j get rl_omchex j
448ret false
449end
450end
451ret true
452end
453
454fn rl_cmd_check_locks to int
455if not rl_check_omc_pin
456cb_err rl_fail_lk
457cb_err rl_e_omc
458ret 1
459end
460if not rl_check_one_lock rl_l_phys false
461ret 1
462end
463if not rl_check_one_lock rl_l_aien false
464ret 1
465end
466if not rl_check_one_lock rl_l_arg false
467ret 1
468end
469if not rl_check_one_lock rl_l_br true
470ret 1
471end
472put rl_secrets 0 0
473put rl_dso 0 0
474cb_pa_clr
475if gt get rl_rootl 0 0
476for i ulong get rl_rootl 0 bound 4096
477cb_pa_ch get rl_root i
478end
479else
480cb_pa_ch 46
481end
482rl_scan_secrets_dir 0
483if ne get rl_secrets 0 0
484ret 1
485end
486cb_out rl_pass_lk1
487r = write 1 rl_omchex 0 64
488cb_out rl_pass_lk2
489ret 0
490end
491
492note ---- Pure-Omega replacement for tools/uxl/windows_paths.py ----
493fn rl_is_win_reserved off ulong nlen ulong to bool
494note stem = before first '.'
495sl = nlen
496for j ulong nlen bound 256
497if eq get cb_dent add off j 46
498sl = j
499break
500end
501end
502if eq sl 3
503if or rl_is_lower_eq off 3 rl_res_con or rl_is_lower_eq off 3 rl_res_prn or rl_is_lower_eq off 3 rl_res_aux rl_is_lower_eq off 3 rl_res_nul
504ret true
505end
506end
507if eq sl 4
508c0 = get cb_dent off
509c1 = get cb_dent add off 1
510c2 = get cb_dent add off 2
511c3 = get cb_dent add off 3
512if and ge c0 65 le c0 90
513c0 = add c0 32
514end
515if and ge c1 65 le c1 90
516c1 = add c1 32
517end
518if and ge c2 65 le c2 90
519c2 = add c2 32
520end
521if and ge c3 49 le c3 57
522if and eq c0 99 and eq c1 111 eq c2 109
523ret true
524end
525if and eq c0 108 and eq c1 112 eq c2 116
526ret true
527end
528end
529end
530ret false
531end
532
533fn rl_is_win_badc c uchar to bool
534if lt c 32
535ret true
536end
537if or eq c 60 eq c 62
538ret true
539end
540if or eq c 58 eq c 34
541ret true
542end
543if or eq c 124 eq c 63
544ret true
545end
546ret eq c 42
547end
548
549fn rl_has_win_badc off ulong nlen ulong to bool
550for j ulong nlen bound 256
551if rl_is_win_badc get cb_dent add off j
552ret true
553end
554end
555ret false
556end
557
558fn rl_check_win_name off ulong nlen ulong to void
559note check trailing dot or space
560last = get cb_dent add off sub nlen 1
561if or eq last 32 eq last 46
562cb_out rl_wp_f
563cb_out rl_r_trail
564cb_wbuf_pa 1
565cb_out cb_slash
566r = write 1 cb_dent off nlen
567cb_out cb_nl
568put rl_findings 0 add get rl_findings 0 1
569end
570if rl_has_win_badc off nlen
571cb_out rl_wp_f
572cb_out rl_r_char
573cb_wbuf_pa 1
574cb_out cb_slash
575r = write 1 cb_dent off nlen
576cb_out cb_nl
577put rl_findings 0 add get rl_findings 0 1
578end
579if rl_is_win_reserved off nlen
580cb_out rl_wp_f
581cb_out rl_r_res
582cb_wbuf_pa 1
583cb_out cb_slash
584r = write 1 cb_dent off nlen
585cb_out cb_nl
586put rl_findings 0 add get rl_findings 0 1
587end
588end
589
590fn rl_sib_eq_ci a ulong b ulong to bool
591la = get rl_siblen a
592lb = get rl_siblen b
593if ne la lb
594ret false
595end
596oa = get rl_siboff a
597ob = get rl_siboff b
598for j ulong la bound 256
599ca = get rl_sibs add oa j
600cb = get rl_sibs add ob j
601if and ge ca 65 le ca 90
602ca = add ca 32
603end
604if and ge cb 65 le cb 90
605cb = add cb 32
606end
607if ne ca cb
608ret false
609end
610end
611ret true
612end
613
614fn rl_sib_push ns ulong nl ulong to void
615sc = get rl_sibc 0
616if ge sc 4096
617ret
618end
619sn = get rl_sibn 0
620if gt add sn nl len rl_sibs
621cap = len rl_sibs
622if eq cap 0
623cap = 65536
624end
625while lt cap add sn nl bound 64
626cap = mul cap 2
627end
628z0 = enlarge rl_sibs cap
629end
630put rl_siboff sc sn
631put rl_siblen sc nl
632for j ulong nl bound 256
633put rl_sibs add sn j get cb_dent add ns j
634end
635put rl_sibn 0 add sn nl
636put rl_sibc 0 add sc 1
637end
638
639fn rl_path_ent dt uchar ns ulong nl ulong depth ulong to void
640if and eq nl 1 eq get cb_dent ns 46
641ret
642end
643if and eq nl 2 and eq get cb_dent ns 46 eq get cb_dent add ns 1 46
644ret
645end
646if and eq dt 4 rl_is_lower_eq ns nl rl_d_git
647ret
648end
649if and eq dt 4 and eq depth 0 rl_is_lower_eq ns nl rl_d_bld
650ret
651end
652put rl_paths 0 add get rl_paths 0 1
653rl_check_win_name ns nl
654rl_sib_push ns nl
655if eq dt 4
656rl_dstack_push ns nl
657end
658end
659
660fn rl_check_sibs to void
661sc = get rl_sibc 0
662for a ulong sc bound 4096
663for b ulong a bound 4096
664if rl_sib_eq_ci a b
665cb_out rl_wp_f
666cb_out rl_r_case
667cb_wbuf_pa 1
668cb_out cb_slash
669r1 = write 1 rl_sibs get rl_siboff a get rl_siblen a
670cb_out cb_nl
671put rl_findings 0 add get rl_findings 0 1
672end
673end
674end
675end
676
677fn rl_scan_path_buf nr ulong depth ulong to void
678pos = ulong 0
679while lt pos nr bound 32768
680rlen = or ulong get cb_dent add pos 16 shl ulong get cb_dent add pos 17 8
681if eq rlen 0
682break
683end
684dt = get cb_dent add pos 18
685ns = add pos 19
686nl = rl_dent_nlen ns add pos rlen
687rl_path_ent dt ns nl depth
688pos = add pos rlen
689end
690end
691
692fn rl_read_path_dir depth ulong to bool
693dfd = fopen cb_pa 0 get cb_n 3 540672 0
694if lt dfd 0
695ret false
696end
697put rl_sibn 0 0
698put rl_sibc 0 0
699while true bound 65536
700nr = getdnts int dfd cb_dent 0 32768
701if le nr 0
702break
703end
704rl_scan_path_buf ulong nr depth
705end
706z2 = fclose int dfd
707rl_check_sibs
708ret true
709end
710
711fn rl_scan_paths_dir depth ulong to void
712if gt depth 32
713ret
714end
715base_len = get cb_n 3
716start_so = get rl_dso 0
717if not rl_read_path_dir depth
718ret
719end
720end_so = get rl_dso 0
721cur = start_so
722while lt cur end_so bound 1048576
723nl = rl_dstack_u16 cur
724rl_pa_append_dstack cur nl base_len
725rl_scan_paths_dir add depth 1
726cur = add add cur 2 nl
727end
728put cb_n 3 base_len
729put rl_dso 0 start_so
730end
731
732fn rl_cmd_check_paths to int
733put rl_findings 0 0
734put rl_paths 0 0
735put rl_dso 0 0
736cb_pa_clr
737if gt get rl_rootl 0 0
738for i ulong get rl_rootl 0 bound 4096
739cb_pa_ch get rl_root i
740end
741else
742cb_pa_ch 46
743end
744rl_scan_paths_dir 0
745f = get rl_findings 0
746if eq f 0
747cb_out rl_wp_0
748cb_wnum 1 get rl_paths 0
749cb_out rl_wp_end
750ret 0
751end
752cb_out rl_wp_cnt1
753cb_wnum 1 f
754cb_out rl_wp_cnt2
755cb_wnum 1 get rl_paths 0
756cb_out rl_wp_end
757ret 1
758end
759
760note ---- Layers gate orchestrator ----
761fn rl_run_layer name view uchar * to bool
762cb_wb_clr
763cb_wb_tx rl_om2l
764cb_pa_set rl_ngsha
765if not cb_append_pa_to_wb
766ret false
767end
768cb_pa_set name
769cb_pa_tx rl_ly_suf
770if not cb_append_pa_to_wb
771ret false
772end
773note write gate source in SCRATCH/name.gate.om
774cb_pa_clr
775for i ulong get rl_scrl 0 bound 4096
776cb_pa_ch get rl_scr i
777end
778cb_pa_ch 47
779cb_pa_tx name
780cb_pa_tx rl_src_com
781note actually just use /<name>.om
782cb_pa_clr
783for i ulong get rl_scrl 0 bound 4096
784cb_pa_ch get rl_scr i
785end
786cb_pa_ch 47
787cb_pa_tx name
788cb_pa_ch 46
789cb_pa_ch 111
790cb_pa_ch 109
791if not cb_write_wb_pa 420
792ret false
793end
794note compile gate -> SCRATCH/name.gate
795for i ulong len rl_omc bound 4096
796put cb_pc i get rl_omc i
797end
798cb_pb_clr
799for i ulong get rl_scrl 0 bound 4096
800cb_pb_ch get rl_scr i
801end
802cb_pb_ch 47
803cb_pb_tx name
804cb_pb_ch 46
805cb_pb_ch 98
806if ne cb_run_omc len rl_omc 493 -1 0
807cb_out rl_ly_fail
808cb_out name
809cb_out cb_nl
810ret false
811end
812note run gate: SCRATCH/name.b seed/out/omc SCRATCH/name-w
813cb_av_clr
814cb_av_push_pb
815cb_av_push_tx rl_omc
816cb_pa_clr
817for i ulong get rl_scrl 0 bound 4096
818cb_pa_ch get rl_scr i
819end
820cb_pa_ch 47
821cb_pa_tx name
822cb_pa_ch 45
823cb_pa_ch 119
824cb_av_push_pa
825fo = fopen cb_devnull 0 len cb_devnull 524289 0
826rc = cb_spawn_fds -1 int fo -1 false
827if ne rc 0
828cb_out rl_ly_fail
829cb_out name
830cb_out cb_nl
831ret false
832end
833cb_out rl_ly_pass
834cb_out name
835cb_out cb_nl
836ret true
837end
838
839fn rl_cmd_layers to int
840cb_pa_clr
841for i ulong get rl_scrl 0 bound 4096
842cb_pa_ch get rl_scr i
843end
844if not cb_mkdir_p_pa
845ret 1
846end
847pass = ulong 0
848fail = ulong 0
849if rl_run_layer rl_ly_0
850pass = add pass 1
851else
852fail = add fail 1
853end
854if rl_run_layer rl_ly_1
855pass = add pass 1
856else
857fail = add fail 1
858end
859if rl_run_layer rl_ly_2
860pass = add pass 1
861else
862fail = add fail 1
863end
864if rl_run_layer rl_ly_3
865pass = add pass 1
866else
867fail = add fail 1
868end
869if rl_run_layer rl_ly_4
870pass = add pass 1
871else
872fail = add fail 1
873end
874if rl_run_layer rl_ly_5
875pass = add pass 1
876else
877fail = add fail 1
878end
879if rl_run_layer rl_ly_6
880pass = add pass 1
881else
882fail = add fail 1
883end
884if rl_run_layer rl_ly_7
885pass = add pass 1
886else
887fail = add fail 1
888end
889cb_out rl_ly_sum1
890cb_wnum 1 pass
891cb_out rl_ly_sum2
892cb_wnum 1 fail
893cb_out cb_nl
894if ne fail 0
895ret 1
896end
897ret 0
898end
899
900note ---- Pure-Omega UXL verifier ----
901fn rl_uxl_level1 to bool
902cb_pa_set rl_l1_json
903if not cb_read_pa
904ret false
905end
906n = get cb_n 0
907ze1 = enlarge rl_l1buf n
908if ne ze1 0
909ret false
910end
911for i ulong n bound 9223372036854775807
912put rl_l1buf i get cb_rb i
913end
914put rl_l1n 0 n
915cnt = ulong 0
916i = ulong 0
917while lt i n bound 9223372036854775807
918note find opening quote of key
919while lt i n bound 9223372036854775807
920if eq get rl_l1buf i 34
921break
922end
923i = add i 1
924end
925if ge i n
926break
927end
928ks = add i 1
929ke = ks
930while lt ke n bound 4096
931if eq get rl_l1buf ke 34
932break
933end
934ke = add ke 1
935end
936if ge ke n
937ret false
938end
939note find opening quote of value
940i = add ke 1
941while lt i n bound 4096
942if eq get rl_l1buf i 34
943break
944end
945i = add i 1
946end
947if ge i n
948ret false
949end
950vs = add i 1
951ve = vs
952while lt ve n bound 256
953if eq get rl_l1buf ve 34
954break
955end
956ve = add ve 1
957end
958if ne sub ve vs 64
959ret false
960end
961cb_pa_set rl_l1_dir
962for j ulong sub ke ks bound 4096
963cb_pa_ch get rl_l1buf add ks j
964end
965if not cb_sha_file_pa
966cb_out rl_uxl_f2
967cb_wbuf_pa 1
968cb_out cb_nl
969ret false
970end
971for j ulong 64
972if ne get cb_shex j get rl_l1buf add vs j
973cb_out rl_uxl_f2
974cb_wbuf_pa 1
975cb_out cb_nl
976ret false
977end
978end
979cnt = add cnt 1
980i = add ve 1
981end
982if lt cnt 60
983ret false
984end
985cb_out rl_uxl_s2
986cb_wnum 1 cnt
987cb_out cb_nl
988ret true
989end
990
991fn rl_uxl_spv_row k view uchar * e view uchar * want_sha view uchar * to bool
992cb_av_clr
993cb_pa_clr
994for i ulong get rl_scrl 0 bound 4096
995cb_pa_ch get rl_scr i
996end
997cb_pa_tx rl_gpuc_bin
998cb_av_push_pa
999cb_av_push_tx rl_srun
1000cb_av_push_tx k
1001cb_av_push_tx e
1002cb_pa_clr
1003for i ulong get rl_scrl 0 bound 4096
1004cb_pa_ch get rl_scr i
1005end
1006cb_pa_tx rl_gpuc_out
1007z0 = unlink cb_pa 0 get cb_n 3
1008fo = fopen cb_pa 0 get cb_n 3 524865 420
1009if lt fo 0
1010ret false
1011end
1012if ne cb_spawn_fds -1 int fo -1 false 0
1013ret false
1014end
1015if not cb_file_contains_pa want_sha
1016ret false
1017end
1018ret true
1019end
1020
1021fn rl_cmd_uxl to int
1022cb_pa_clr
1023for i ulong get rl_scrl 0 bound 4096
1024cb_pa_ch get rl_scr i
1025end
1026if not cb_mkdir_p_pa
1027ret 1
1028end
1029pass = ulong 0
1030fail = ulong 0
1031note Stage 1: omc pin + windows paths
1032s1 = true
1033if not rl_check_omc_pin
1034s1 = false
1035end
1036if s1
1037put rl_rootl 0 0
1038if ne rl_cmd_check_paths 0
1039s1 = false
1040end
1041end
1042if s1
1043cb_out rl_uxl_s1
1044pass = add pass 1
1045else
1046cb_out rl_uxl_f1
1047fail = add fail 1
1048end
1049
1050note Stage 2: Level 1 65-file SHA256.json
1051if rl_uxl_level1
1052pass = add pass 1
1053else
1054fail = add fail 1
1055end
1056
1057note Compile gpucoord into SCRATCH/om-gpucoord
1058cb_wb_clr
1059cb_pa_set rl_src_com
1060z0 = cb_append_pa_to_wb
1061cb_pa_set rl_src_gpu
1062z1 = cb_append_pa_to_wb
1063cb_pa_clr
1064for i ulong get rl_scrl 0 bound 4096
1065cb_pa_ch get rl_scr i
1066end
1067cb_pa_tx rl_gpuc_src
1068z2 = cb_write_wb_pa 420
1069for i ulong len rl_omc bound 4096
1070put cb_pc i get rl_omc i
1071end
1072cb_pb_clr
1073for i ulong get rl_scrl 0 bound 4096
1074cb_pb_ch get rl_scr i
1075end
1076cb_pb_tx rl_gpuc_bin
1077if ne cb_run_omc len rl_omc 493 -1 0
1078cb_out rl_uxl_f3
1079ret 1
1080end
1081
1082note Stage 3: spirv-check
1083cb_av_clr
1084cb_av_push_pb
1085cb_av_push_tx rl_schk
1086fo3 = fopen cb_devnull 0 len cb_devnull 524289 0
1087if eq cb_spawn_fds -1 int fo3 -1 false 0
1088cb_out rl_uxl_s3
1089pass = add pass 1
1090else
1091cb_out rl_uxl_f3
1092fail = add fail 1
1093end
1094
1095note Stage 4: rmsnorm cl + vk
1096if and rl_uxl_spv_row rl_k_rms rl_e_cl rl_sha_rms rl_uxl_spv_row rl_k_rms rl_e_vk rl_sha_rms
1097cb_out rl_uxl_s4
1098pass = add pass 1
1099else
1100cb_out rl_uxl_f4
1101fail = add fail 1
1102end
1103
1104note Stage 5: vadd, fsum16, gemm16 cl + vk
1105s5 = true
1106if not rl_uxl_spv_row rl_k_vadd rl_e_cl rl_sha_vadd
1107s5 = false
1108end
1109if not rl_uxl_spv_row rl_k_vadd rl_e_vk rl_sha_vadd
1110s5 = false
1111end
1112if not rl_uxl_spv_row rl_k_fsum rl_e_cl rl_sha_fsum
1113s5 = false
1114end
1115if not rl_uxl_spv_row rl_k_fsum rl_e_vk rl_sha_fsum
1116s5 = false
1117end
1118if not rl_uxl_spv_row rl_k_gemm rl_e_cl rl_sha_gemm
1119s5 = false
1120end
1121if not rl_uxl_spv_row rl_k_gemm rl_e_vk rl_sha_gemm
1122s5 = false
1123end
1124if s5
1125cb_out rl_uxl_s5
1126pass = add pass 1
1127else
1128cb_out rl_uxl_f5
1129fail = add fail 1
1130end
1131
1132note Stage 6: intel-gate
1133cb_av_clr
1134cb_pa_clr
1135for i ulong get rl_scrl 0 bound 4096
1136cb_pa_ch get rl_scr i
1137end
1138cb_pa_tx rl_gpuc_bin
1139cb_av_push_pa
1140cb_av_push_tx rl_ixe
1141fo6 = fopen cb_devnull 0 len cb_devnull 524289 0
1142if eq cb_spawn_fds -1 int fo6 -1 false 0
1143cb_out rl_uxl_s6
1144pass = add pass 1
1145else
1146cb_out rl_uxl_f6
1147fail = add fail 1
1148end
1149
1150cb_out rl_uxl_sum1
1151cb_wnum 1 pass
1152cb_out rl_uxl_sum2
1153cb_wnum 1 fail
1154cb_out cb_nl
1155if ne fail 0
1156ret 1
1157end
1158ret 0
1159end
1160
1161note ---- Package & Verify ----
1162fn rl_man_ch c uchar to void
1163n = get rl_mann 0
1164if ge n len rl_man
1165cap = len rl_man
1166if eq cap 0
1167cap = 16384
1168end
1169z = enlarge rl_man mul cap 2
1170end
1171put rl_man n c
1172put rl_mann 0 add n 1
1173end
1174
1175fn rl_man_tx t view uchar * to void
1176for i ulong len t bound 4096
1177rl_man_ch get t i
1178end
1179end
1180
1181fn rl_man_num v ulong to void
1182x = v
1183i = ulong 32
1184for j ulong 21
1185i = sub i 1
1186put cb_numbuf i uchar add 48 rem x 10
1187x = div x 10
1188if eq x 0
1189break
1190end
1191end
1192for q ulong sub 32 i bound 32
1193rl_man_ch get cb_numbuf add i q
1194end
1195end
1196
1197fn rl_sums_ch c uchar to void
1198n = get rl_sumsn 0
1199if ge n len rl_sums
1200cap = len rl_sums
1201if eq cap 0
1202cap = 16384
1203end
1204z = enlarge rl_sums mul cap 2
1205end
1206put rl_sums n c
1207put rl_sumsn 0 add n 1
1208end
1209
1210fn rl_sums_tx t view uchar * to void
1211for i ulong len t bound 4096
1212rl_sums_ch get t i
1213end
1214end
1215
1216fn rl_json_ch c uchar to void
1217n = get rl_jsonn 0
1218if ge n len rl_json
1219cap = len rl_json
1220if eq cap 0
1221cap = 16384
1222end
1223z = enlarge rl_json mul cap 2
1224end
1225put rl_json n c
1226put rl_jsonn 0 add n 1
1227end
1228
1229fn rl_json_tx t view uchar * to void
1230for i ulong len t bound 4096
1231rl_json_ch get t i
1232end
1233end
1234
1235fn rl_json_num v ulong to void
1236x = v
1237i = ulong 32
1238for j ulong 21
1239i = sub i 1
1240put cb_numbuf i uchar add 48 rem x 10
1241x = div x 10
1242if eq x 0
1243break
1244end
1245end
1246for q ulong sub 32 i bound 32
1247rl_json_ch get cb_numbuf add i q
1248end
1249end
1250
1251fn rl_record_art rel view uchar * to bool
1252cb_pa_clr
1253for i ulong get rl_outl 0 bound 4096
1254cb_pa_ch get rl_out i
1255end
1256cb_pa_ch 47
1257cb_pa_tx rel
1258sz = cb_file_size_pa
1259if lt sz 0
1260ret false
1261end
1262if not cb_sha_file_pa
1263ret false
1264end
1265note TSV row
1266rl_man_tx rel
1267rl_man_tx rl_tab
1268rl_man_num ulong sz
1269rl_man_tx rl_tab
1270for j ulong 64
1271rl_man_ch get cb_shex j
1272end
1273rl_man_ch 10
1274note SHA256SUMS row
1275for j ulong 64
1276rl_sums_ch get cb_shex j
1277end
1278rl_sums_tx rl_sp2
1279rl_sums_tx rel
1280rl_sums_ch 10
1281note JSON row
1282if gt get rl_pkg_idx 0 0
1283rl_json_tx rl_j_cm
1284end
1285rl_json_tx rl_j_a1
1286rl_json_tx rel
1287rl_json_tx rl_j_a2
1288rl_json_num ulong sz
1289rl_json_tx rl_j_a3
1290for j ulong 64
1291rl_json_ch get cb_shex j
1292end
1293rl_json_tx rl_j_a4
1294put rl_pkg_idx 0 add get rl_pkg_idx 0 1
1295ret true
1296end
1297
1298fn rl_build_coord src view uchar * rel_out view uchar * to bool
1299cb_wb_clr
1300cb_pa_set rl_src_com
1301if not cb_append_pa_to_wb
1302ret false
1303end
1304cb_pa_set src
1305if not cb_append_pa_to_wb
1306ret false
1307end
1308cb_pa_clr
1309for i ulong get rl_outl 0 bound 4096
1310cb_pa_ch get rl_out i
1311end
1312cb_pa_tx rl_gpuc_src
1313if not cb_write_wb_pa 420
1314ret false
1315end
1316for i ulong len rl_omc bound 4096
1317put cb_pc i get rl_omc i
1318end
1319cb_pb_clr
1320for i ulong get rl_outl 0 bound 4096
1321cb_pb_ch get rl_out i
1322end
1323cb_pb_ch 47
1324cb_pb_tx rel_out
1325rc = cb_run_omc len rl_omc 493 -1
1326z0 = unlink cb_pa 0 get cb_n 3
1327if ne rc 0
1328ret false
1329end
1330ret rl_record_art rel_out
1331end
1332
1333fn rl_is_ver_ch c uchar to bool
1334if and ge c 48 le c 57
1335ret true
1336end
1337if and ge c 65 le c 90
1338ret true
1339end
1340if and ge c 97 le c 122
1341ret true
1342end
1343if or eq c 46 eq c 45
1344ret true
1345end
1346ret or eq c 95 eq c 43
1347end
1348
1349fn rl_ver_safe to bool
1350n = get rl_verl 0
1351if or eq n 0 gt n 64
1352ret false
1353end
1354for i ulong n bound 64
1355if not rl_is_ver_ch get rl_ver i
1356ret false
1357end
1358end
1359ret true
1360end
1361
1362fn rl_cmd_package to int
1363if not rl_ver_safe
1364cb_err rl_pkg_bad
1365ret 2
1366end
1367put rl_rootl 0 0
1368if ne rl_cmd_check_locks 0
1369cb_err rl_pkg_bad
1370ret 1
1371end
1372cb_pa_clr
1373for i ulong get rl_outl 0 bound 4096
1374cb_pa_ch get rl_out i
1375end
1376cb_pa_tx rl_d_bin
1377if not cb_mkdir_p_pa
1378cb_err rl_pkg_bad
1379ret 1
1380end
1381cb_pa_clr
1382for i ulong get rl_outl 0 bound 4096
1383cb_pa_ch get rl_out i
1384end
1385cb_pa_tx rl_d_seed
1386if not cb_mkdir_p_pa
1387cb_err rl_pkg_bad
1388ret 1
1389end
1390
1391put rl_mann 0 0
1392put rl_sumsn 0 0
1393put rl_jsonn 0 0
1394put rl_pkg_idx 0 0
1395rl_man_tx rl_man_hdr
1396rl_json_tx rl_j_1
1397for i ulong get rl_verl 0 bound 64
1398rl_json_ch get rl_ver i
1399end
1400rl_json_tx rl_j_2
1401for j ulong 64
1402rl_json_ch get rl_omchex j
1403end
1404rl_json_tx rl_j_3
1405
1406note Copy omc, seed0.hex, omc.sha256
1407cb_pa_set rl_omc
1408cb_pb_clr
1409for i ulong get rl_outl 0 bound 4096
1410cb_pb_ch get rl_out i
1411end
1412cb_pb_ch 47
1413cb_pb_tx rl_r_omc
1414if not cb_copy_pa_to_pb 493
1415cb_err rl_pkg_bad
1416ret 1
1417end
1418if not rl_record_art rl_r_omc
1419cb_err rl_pkg_bad
1420ret 1
1421end
1422
1423if not rl_build_coord rl_src_bir rl_r_bir
1424cb_err rl_pkg_bad
1425ret 1
1426end
1427if not rl_build_coord rl_src_uni rl_r_uni
1428cb_err rl_pkg_bad
1429ret 1
1430end
1431if not rl_build_coord rl_src_tls rl_r_tls
1432cb_err rl_pkg_bad
1433ret 1
1434end
1435if not rl_build_coord rl_src_efi rl_r_efi
1436cb_err rl_pkg_bad
1437ret 1
1438end
1439if not rl_build_coord rl_src_gpu rl_r_gpu
1440cb_err rl_pkg_bad
1441ret 1
1442end
1443if not rl_build_coord rl_src_rel rl_r_rel
1444cb_err rl_pkg_bad
1445ret 1
1446end
1447
1448cb_pa_set rl_s0hex
1449cb_pb_clr
1450for i ulong get rl_outl 0 bound 4096
1451cb_pb_ch get rl_out i
1452end
1453cb_pb_ch 47
1454cb_pb_tx rl_r_s0
1455if not cb_copy_pa_to_pb 420
1456cb_err rl_pkg_bad
1457ret 1
1458end
1459if not rl_record_art rl_r_s0
1460cb_err rl_pkg_bad
1461ret 1
1462end
1463
1464cb_pa_set rl_omcsha
1465cb_pb_clr
1466for i ulong get rl_outl 0 bound 4096
1467cb_pb_ch get rl_out i
1468end
1469cb_pb_ch 47
1470cb_pb_tx rl_r_sha
1471if not cb_copy_pa_to_pb 420
1472cb_err rl_pkg_bad
1473ret 1
1474end
1475if not rl_record_art rl_r_sha
1476cb_err rl_pkg_bad
1477ret 1
1478end
1479
1480rl_json_tx rl_j_end
1481
1482note Write RELEASE-MANIFEST.tsv, SHA256SUMS, release-manifest.json
1483cb_wb_clr
1484for i ulong get rl_mann 0 bound 9223372036854775807
1485cb_wb_ch get rl_man i
1486end
1487cb_pa_clr
1488for i ulong get rl_outl 0 bound 4096
1489cb_pa_ch get rl_out i
1490end
1491cb_pa_tx rl_f_man
1492if not cb_write_wb_pa 420
1493cb_err rl_pkg_bad
1494ret 1
1495end
1496
1497cb_wb_clr
1498for i ulong get rl_sumsn 0 bound 9223372036854775807
1499cb_wb_ch get rl_sums i
1500end
1501cb_pa_clr
1502for i ulong get rl_outl 0 bound 4096
1503cb_pa_ch get rl_out i
1504end
1505cb_pa_tx rl_f_sums
1506if not cb_write_wb_pa 420
1507cb_err rl_pkg_bad
1508ret 1
1509end
1510
1511cb_wb_clr
1512for i ulong get rl_jsonn 0 bound 9223372036854775807
1513cb_wb_ch get rl_json i
1514end
1515cb_pa_clr
1516for i ulong get rl_outl 0 bound 4096
1517cb_pa_ch get rl_out i
1518end
1519cb_pa_tx rl_f_json
1520if not cb_write_wb_pa 420
1521cb_err rl_pkg_bad
1522ret 1
1523end
1524
1525cb_out rl_pkg_ok1
1526r1 = write 1 rl_ver 0 get rl_verl 0
1527cb_out rl_pkg_ok2
1528r2 = write 1 rl_out 0 get rl_outl 0
1529cb_out cb_nl
1530ret 0
1531end
1532
1533fn rl_relpath_safe s ulong e ulong to bool
1534if or eq s e gt sub e s 1024
1535ret false
1536end
1537if eq get rl_man s 47
1538ret false
1539end
1540i = s
1541while lt i e bound 4096
1542c = get rl_man i
1543if or lt c 32 gt c 126
1544ret false
1545end
1546if and eq c 46 lt add i 1 e
1547if eq get rl_man add i 1 46
1548ret false
1549end
1550end
1551i = add i 1
1552end
1553ret true
1554end
1555
1556fn rl_seen_eq p ulong s ulong pl ulong to bool
1557for j ulong pl bound 1024
1558if ne get rl_seen add p j get rl_man add s j
1559ret false
1560end
1561end
1562ret true
1563end
1564
1565fn rl_seen_next_nl p ulong sn ulong to ulong
1566q = p
1567while lt q sn bound 1048576
1568if eq get rl_seen q 10
1569break
1570end
1571q = add q 1
1572end
1573ret q
1574end
1575
1576fn rl_seen_add s ulong e ulong to bool
1577pl = sub e s
1578sn = get rl_seenn 0
1579p = ulong 0
1580while lt p sn bound 1048576
1581q = rl_seen_next_nl p sn
1582if eq sub q p pl
1583if rl_seen_eq p s pl
1584ret false
1585end
1586end
1587p = add q 1
1588end
1589need = add add sn pl 1
1590if gt need len rl_seen
1591cap = len rl_seen
1592if eq cap 0
1593cap = 16384
1594end
1595while lt cap need bound 64
1596cap = mul cap 2
1597end
1598z = enlarge rl_seen cap
1599end
1600for j ulong pl bound 1024
1601put rl_seen add sn j get rl_man add s j
1602end
1603put rl_seen add sn pl 10
1604put rl_seenn 0 need
1605ret true
1606end
1607
1608fn rl_find_tab s ulong e ulong to ulong
1609t = s
1610while lt t e bound 4096
1611if eq get rl_man t 9
1612break
1613end
1614t = add t 1
1615end
1616ret t
1617end
1618
1619fn rl_parse_u64_man s ulong e ulong to long
1620if eq s e
1621ret -1
1622end
1623v = ulong 0
1624for k ulong sub e s bound 32
1625c = get rl_man add s k
1626if or lt c 48 gt c 57
1627ret -1
1628end
1629v = add mul v 10 ulong sub c 48
1630end
1631ret long v
1632end
1633
1634fn rl_check_hex_man pos ulong to bool
1635for j ulong 64
1636if ne get cb_shex j get rl_man add pos j
1637ret false
1638end
1639end
1640ret true
1641end
1642
1643fn rl_verify_row i ulong e ulong to bool
1644t1 = rl_find_tab i e
1645if ge t1 e
1646cb_err rl_ver_bad
1647cb_err rl_ver_e2
1648ret false
1649end
1650t2 = rl_find_tab add t1 1 e
1651if ge t2 e
1652cb_err rl_ver_bad
1653cb_err rl_ver_e2
1654ret false
1655end
1656if ne sub sub e t2 1 64
1657cb_err rl_ver_bad
1658cb_err rl_ver_e2
1659ret false
1660end
1661if not rl_relpath_safe i t1
1662cb_err rl_ver_bad
1663cb_err rl_ver_e3
1664ret false
1665end
1666if not rl_seen_add i t1
1667cb_err rl_ver_bad
1668cb_err rl_ver_e3
1669ret false
1670end
1671bval = rl_parse_u64_man add t1 1 t2
1672if lt bval 0
1673cb_err rl_ver_bad
1674cb_err rl_ver_e2
1675ret false
1676end
1677cb_pa_clr
1678for k ulong get rl_outl 0 bound 4096
1679cb_pa_ch get rl_out k
1680end
1681cb_pa_ch 47
1682for k ulong sub t1 i bound 1024
1683cb_pa_ch get rl_man add i k
1684end
1685sz = cb_file_size_pa
1686if ne sz bval
1687cb_err rl_ver_bad
1688cb_err rl_ver_e4
1689cb_wbuf_pa 2
1690cb_err cb_nl
1691ret false
1692end
1693if not cb_sha_file_pa
1694cb_err rl_ver_bad
1695cb_err rl_ver_e4
1696cb_wbuf_pa 2
1697cb_err cb_nl
1698ret false
1699end
1700if not rl_check_hex_man add t2 1
1701cb_err rl_ver_bad
1702cb_err rl_ver_e4
1703cb_wbuf_pa 2
1704cb_err cb_nl
1705ret false
1706end
1707ret true
1708end
1709
1710fn rl_cmd_verify to int
1711cb_pa_clr
1712for i ulong get rl_outl 0 bound 4096
1713cb_pa_ch get rl_out i
1714end
1715cb_pa_tx rl_f_man
1716if not cb_read_pa
1717cb_err rl_ver_bad
1718cb_err rl_ver_e1
1719ret 1
1720end
1721n = get cb_n 0
1722if lt n len rl_man_hdr
1723cb_err rl_ver_bad
1724cb_err rl_ver_e2
1725ret 1
1726end
1727ze2 = enlarge rl_man n
1728if ne ze2 0
1729ret 1
1730end
1731for i ulong n bound 9223372036854775807
1732put rl_man i get cb_rb i
1733end
1734put rl_mann 0 n
1735for j ulong len rl_man_hdr bound 64
1736if ne get rl_man j get rl_man_hdr j
1737cb_err rl_ver_bad
1738cb_err rl_ver_e2
1739ret 1
1740end
1741end
1742put rl_seenn 0 0
1743cnt = ulong 0
1744i = len rl_man_hdr
1745while lt i n bound 9223372036854775807
1746e = i
1747while lt e n bound 9223372036854775807
1748if eq get rl_man e 10
1749break
1750end
1751e = add e 1
1752end
1753if eq i e
1754i = add e 1
1755continue
1756end
1757if not rl_verify_row i e
1758ret 1
1759end
1760cnt = add cnt 1
1761i = add e 1
1762end
1763if eq cnt 0
1764cb_err rl_ver_bad
1765cb_err rl_ver_e5
1766ret 1
1767end
1768cb_out rl_ver_ok
1769cb_wnum 1 cnt
1770cb_out cb_nl
1771ret 0
1772end
1773
1774fn main to int
1775ac = argcnt
1776if lt ac 2
1777cb_err rl_usage
1778ret 2
1779end
1780if not cb_pa_arg 1
1781cb_err rl_usage
1782ret 2
1783end
1784if cb_pa_eq rl_c_locks
1785put rl_rootl 0 0
1786if ge ac 3
1787if cb_pa_arg 2
1788for i ulong get cb_n 3 bound 4096
1789put rl_root i get cb_pa i
1790end
1791put rl_rootl 0 get cb_n 3
1792end
1793end
1794ret rl_cmd_check_locks
1795end
1796if cb_pa_eq rl_c_paths
1797put rl_rootl 0 0
1798if ge ac 3
1799if cb_pa_arg 2
1800for i ulong get cb_n 3 bound 4096
1801put rl_root i get cb_pa i
1802end
1803put rl_rootl 0 get cb_n 3
1804end
1805end
1806ret rl_cmd_check_paths
1807end
1808if cb_pa_eq rl_c_layers
1809if ge ac 3
1810if cb_pa_arg 2
1811for i ulong get cb_n 3 bound 4096
1812put rl_scr i get cb_pa i
1813end
1814put rl_scrl 0 get cb_n 3
1815end
1816else
1817for i ulong len rl_defscr bound 4096
1818put rl_scr i get rl_defscr i
1819end
1820put rl_scrl 0 len rl_defscr
1821end
1822ret rl_cmd_layers
1823end
1824if cb_pa_eq rl_c_uxl
1825if ge ac 3
1826if cb_pa_arg 2
1827for i ulong get cb_n 3 bound 4096
1828put rl_scr i get cb_pa i
1829end
1830put rl_scrl 0 get cb_n 3
1831end
1832else
1833for i ulong len rl_defscr bound 4096
1834put rl_scr i get rl_defscr i
1835end
1836put rl_scrl 0 len rl_defscr
1837end
1838ret rl_cmd_uxl
1839end
1840if cb_pa_eq rl_c_pkg
1841if ne ac 4
1842cb_err rl_usage
1843ret 2
1844end
1845if not cb_pa_arg 2
1846ret 2
1847end
1848for i ulong get cb_n 3 bound 4096
1849put rl_out i get cb_pa i
1850end
1851put rl_outl 0 get cb_n 3
1852if not cb_pa_arg 3
1853ret 2
1854end
1855if gt get cb_n 3 255
1856ret 2
1857end
1858for i ulong get cb_n 3 bound 256
1859put rl_ver i get cb_pa i
1860end
1861put rl_verl 0 get cb_n 3
1862ret rl_cmd_package
1863end
1864if cb_pa_eq rl_c_ver
1865if ne ac 3
1866cb_err rl_usage
1867ret 2
1868end
1869if not cb_pa_arg 2
1870ret 2
1871end
1872for i ulong get cb_n 3 bound 4096
1873put rl_out i get cb_pa i
1874end
1875put rl_outl 0 get cb_n 3
1876ret rl_cmd_verify
1877end
1878cb_err rl_usage
1879ret 2
1880end