interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / native / omegese45 / hive / hive.om

1380 lines · 21701 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note OE45 hive driver (aien-train #45, demo lane). One bounded episode:
3note validated goal G -> core decode -> act A -> Aienet-0 microjob -> R -> rep P.
4note Build: cat native/omegese45/vocab.om native/omegese45/msg.om
5note native/omegese45/mjr1.om native/omegese45/hive/hive.om | omc
6note Usage: hive CONF, run with the case directory as the current directory.
7note CONF holds 15 lines, one value each, in this order:
8note 0 RUN 1 SERVE 2 KEYS 3 PINS 4 WKEYS 5 WPINS 6 WSTATE 7 RECOMP
9note 8 RECSHA 9 ADDR 10 CORE 11 CKPT 12 MODE (U|G) 13 VERIFIER hex
10note 14 ACCEPT timeout seconds.
11note Case directory: goal.oe45 (one G line) in; episode.oe45 (append-only
12note journal, oe45 v1), dispatch.log, hive.log, facts.tsv, disp/, out/, logs/.
13note The journal holds profile lines only. An A job line is the intent and is
14note synced before its dispatch; its R line is synced after. A restart rescans
15note the journal; an A job without R is reconciled with --retry, so the worker
16note returns its cached receipt instead of executing a second time.
17note Exits: 0 episode complete (P journaled, facts.tsv written); 61 usage or
18note config; 62 binding refused before dispatch; 63 decode failed after one
19note guided repair, or checkpoint refused; 64 journal, goal or policy guard;
20note 65 driver I/O or spawn failure; 66 unmapped aienet0-run exit or an
21note inconsistent VERIFIED/MJR1; 69 bundle payload differs from the lowered A.
22
23const ohnw ulong 89
24const ohncf ulong 15
25text ohw "run bundle --listen --keys --pins --out --recompute --recompute-sha256 --resend --accept-timeout --m --k --n --seed --connect --state --connect-timeout --retry decode episode.oe45 facts.tsv dispatch.log hive.log /dev/null disp out logs goal.oe45 intent outcome res ok refused fail end transport replay budget worker receipt recomp verdict io .an0b .mjr1 .fact .out .err serve bind - VERIFIED REFUSED WORKER AN0_REPLAY AN0_OVER_BUDGET MJB_OVER_BUDGET dag_id= reconcile repair G oe45 v1 job attempt m k n seed exit class code dag_id mjr1_sha256 mjr1_outcome verifier 30 done rc= hive: decoded dispatch retry new lower HIVE_DONE journal torn refuse"
26
27const ohxrun ulong 0
28const ohxbund ulong 1
29const ohxlist ulong 2
30const ohxkeys ulong 3
31const ohxpins ulong 4
32const ohxout ulong 5
33const ohxrec ulong 6
34const ohxrecs ulong 7
35const ohxresnd ulong 8
36const ohxacct ulong 9
37const ohxm ulong 10
38const ohxconn ulong 14
39const ohxstate ulong 15
40const ohxcto ulong 16
41const ohxretry ulong 17
42const ohxdec ulong 18
43const ohxep ulong 19
44const ohxfacts ulong 20
45const ohxdlog ulong 21
46const ohxhlog ulong 22
47const ohxnull ulong 23
48const ohxdisp ulong 24
49const ohxodir ulong 25
50const ohxlogs ulong 26
51const ohxgoal ulong 27
52const ohxint ulong 28
53const ohxoutc ulong 29
54const ohxres ulong 30
55const ohxok ulong 31
56const ohxrefd ulong 32
57const ohxfail ulong 33
58const ohxend ulong 34
59const ohxtrans ulong 35
60const ohxrepl ulong 36
61const ohxbudg ulong 37
62const ohxwork ulong 38
63const ohxrcpt ulong 39
64const ohxrcmp ulong 40
65const ohxverd ulong 41
66const ohxio ulong 42
67const ohxan0b ulong 43
68const ohxmjr1 ulong 44
69const ohxfact ulong 45
70const ohxsout ulong 46
71const ohxserr ulong 47
72const ohxserve ulong 48
73const ohxbind ulong 49
74const ohxdash ulong 50
75const ohxverif ulong 51
76const ohxworkr ulong 53
77const ohxa0rep ulong 54
78const ohxa0bud ulong 55
79const ohxmjbud ulong 56
80const ohxdagid ulong 57
81const ohxrecon ulong 58
82const ohxrepr ulong 59
83const ohxg ulong 60
84const ohxhdr ulong 63
85const ohxcto30 ulong 76
86const ohxdone ulong 77
87const ohxrceq ulong 78
88const ohxhive ulong 79
89const ohxdecd ulong 80
90const ohxdsp ulong 81
91const ohxnew ulong 83
92const ohxlower ulong 84
93const ohxhdone ulong 85
94const ohxjour ulong 86
95const ohxtorn ulong 87
96const ohxrefu ulong 88
97
98note Configuration slots.
99const ohcrun ulong 0
100const ohcserve ulong 1
101const ohckeys ulong 2
102const ohcpins ulong 3
103const ohcwkeys ulong 4
104const ohcwpins ulong 5
105const ohcwst ulong 6
106const ohcrec ulong 7
107const ohcrecs ulong 8
108const ohcaddr ulong 9
109const ohccore ulong 10
110const ohcckpt ulong 11
111const ohcmode ulong 12
112const ohcverif ulong 13
113const ohcacct ulong 14
114
115note Driver state slots in ohv.
116const ohspid ulong 0
117const ohsseq ulong 1
118const ohslast ulong 2
119const ohsjob ulong 3
120const ohsatt ulong 4
121const ohstr ulong 5
122const ohsnmod ulong 6
123const ohsnal ulong 7
124const ohsnf ulong 8
125const ohsdag ulong 9
126const ohssha ulong 10
127const ohsjobs ulong 11
128const ohsout ulong 12
129const ohsdecs ulong 13
130const ohscls ulong 14
131const ohscode ulong 15
132
133note Last journal kinds kept in ohv[ohslast].
134const ohkg ulong 1
135const ohkajob ulong 2
136const ohkr ulong 3
137const ohkp ulong 4
138const ohkaref ulong 5
139
140global ohwo ulong 96
141global ohwl ulong 96
142global ohcf uchar 8192
143global ohco ulong 16
144global ohcl ulong 16
145global ohb uchar 65536
146global ohbn ulong 1
147global oht uchar 4096
148global ohtn ulong 1
149global ohd uchar 4096
150global ohdn ulong 1
151global ohpk uchar 4096
152global ohpv ulong 2
153global oho uchar 512
154global ohe uchar 512
155global ohio ulong 2
156global ohst uchar 8
157global ohsb uchar 128
158global ohal uchar 512
159global ohv ulong 32
160global ohfj ulong 16
161global ohdag uchar 64
162global ohsha uchar 64
163
164note Split ohw into word offsets and lengths.
165fn ohwinit to void
166p = ulong 0
167for i ulong ohnw
168put ohwo i p
169s = p
170while lt p len ohw bound 4096
171if eq get ohw p 32
172break
173end
174p = add p 1
175end
176put ohwl i sub p s
177p = add p 1
178end
179end
180
181fn ohtclr to void
182put ohtn 0 0
183end
184
185fn ohtc c uchar to void
186n = get ohtn 0
187if ge n len oht
188exit 65
189end
190put oht n c
191put ohtn 0 add n 1
192end
193
194fn ohtw w ulong to void
195o = get ohwo w
196for j ulong get ohwl w
197ohtc get ohw add o j
198end
199end
200
201fn ohtk i ulong to void
202o = get ohco i
203for j ulong get ohcl i
204ohtc get ohcf add o j
205end
206end
207
208fn ohtd v ulong to void
209dg = new uchar 20 0
210x = v
211c = ulong 0
212while true bound 21
213put dg c uchar rem x 10
214c = add c 1
215x = div x 10
216if eq x 0
217break
218end
219end
220for j ulong c
221ohtc add 48 get dg sub sub c 1 j
222end
223end
224
225note Append ohb[o..o+n).
226fn ohtb o ulong n ulong to void
227for j ulong n
228ohtc get ohb add o j
229end
230end
231
232fn ohtdag to void
233if eq get ohv ohsdag 1
234for j ulong 64
235ohtc get ohdag j
236end
237else
238ohtw ohxdash
239end
240end
241
242fn ohtsha to void
243if eq get ohv ohssha 1
244for j ulong 64
245ohtc get ohsha j
246end
247else
248ohtw ohxdash
249end
250end
251
252note Copy the builder into the data, stdout-path, stderr-path or ocin buffers.
253fn ohtod to void
254n = get ohtn 0
255for j ulong n
256put ohd j get oht j
257end
258put ohdn 0 n
259end
260
261fn ohtoo to void
262n = get ohtn 0
263if gt n len oho
264exit 65
265end
266for j ulong n
267put oho j get oht j
268end
269put ohio 0 n
270end
271
272fn ohtoe to void
273n = get ohtn 0
274if gt n len ohe
275exit 65
276end
277for j ulong n
278put ohe j get oht j
279end
280put ohio 1 n
281end
282
283fn ohtoin to ulong
284n = get ohtn 0
285for j ulong n
286put ocin j get oht j
287end
288ret n
289end
290
291fn ohotot to void
292ohtclr
293for j ulong get ohio 0
294ohtc get oho j
295end
296end
297
298fn ohetot to void
299ohtclr
300for j ulong get ohio 1
301ohtc get ohe j
302end
303end
304
305note Packed argument list for execprog: u16 count, then u16 length + bytes.
306fn ohpkclr to void
307put ohpv 0 0
308put ohpv 1 2
309end
310
311fn ohpkt to void
312c = get ohpv 0
313p = get ohpv 1
314n = get ohtn 0
315if or ge c 64 gt add add p 2 n len ohpk
316exit 65
317end
318put ohpk p uchar and n 255
319put ohpk add p 1 uchar shr n 8
320for j ulong n
321put ohpk add add p 2 j get oht j
322end
323put ohpv 0 add c 1
324put ohpv 1 add add p 2 n
325end
326
327fn ohpkfin to ulong
328c = get ohpv 0
329put ohpk 0 uchar and c 255
330put ohpk 1 uchar shr c 8
331ret get ohpv 1
332end
333
334fn ohpw w ulong to void
335ohtclr
336ohtw w
337ohpkt
338end
339
340fn ohpkk i ulong to void
341ohtclr
342ohtk i
343ohpkt
344end
345
346fn ohpd v ulong to void
347ohtclr
348ohtd v
349ohpkt
350end
351
352note Read the file named by the builder into ohb. Returns bytes or -errno.
353fn ohrdf to long
354fd = fopen oht 0 get ohtn 0 0 0
355if lt fd 0
356ret fd
357end
358t = ulong 0
359fin = false
360while and lt t len ohb not fin bound 70000
361r = read int fd ohb t sub len ohb t
362if lt r 0
363c = fclose int fd
364ret r
365end
366if eq r 0
367fin = true
368end
369t = add t ulong r
370end
371c = fclose int fd
372put ohbn 0 t
373if not fin
374ret neg long 27
375end
376ret long t
377end
378
379note Write ohd to the file named by the builder with open flags fl, then fsync.
380fn ohwrd fl int to void
381fd = fopen oht 0 get ohtn 0 fl 420
382if lt fd 0
383exit 65
384end
385n = get ohdn 0
386t = ulong 0
387while lt t n bound 5000
388w = write int fd ohd t sub n t
389if le w 0
390exit 65
391end
392t = add t ulong w
393end
394s = fsync int fd
395if lt s 0
396exit 65
397end
398c = fclose int fd
399end
400
401note Copy ohb[0..n) into ohd.
402fn ohbtod n ulong to void
403if gt n len ohd
404exit 65
405end
406for j ulong n
407put ohd j get ohb j
408end
409put ohdn 0 n
410end
411
412note Builder holds a line without LF: append it to stdout and hive.log.
413fn ohlog to void
414ohtc 10
415ohtod
416n = get ohdn 0
417t = ulong 0
418while lt t n bound 5000
419w = write 1 ohd t sub n t
420if le w 0
421exit 65
422end
423t = add t ulong w
424end
425ohtclr
426ohtw ohxhlog
427ohwrd 1089
428end
429
430note Builder holds a line without LF: append it to the named log file w.
431fn ohappw w ulong to void
432ohtc 10
433ohtod
434ohtclr
435ohtw w
436ohwrd 1089
437end
438
439fn ohhead w ulong to void
440ohtclr
441ohtw ohxhive
442ohtc 32
443ohtw w
444end
445
446note Per-spawn stdout and stderr files: logs/<driverpid>-<seq>-<tag>.out|.err
447fn ohsetio tag ulong to void
448q = get ohv ohsseq
449put ohv ohsseq add q 1
450ohtclr
451ohtw ohxlogs
452ohtc 47
453ohtd get ohv ohspid
454ohtc 45
455ohtd q
456ohtc 45
457ohtw tag
458b = get ohtn 0
459ohtw ohxsout
460ohtoo
461put ohtn 0 b
462ohtw ohxserr
463ohtoe
464end
465
466note Fork and exec the packed list with an empty environment; stdin from
467note /dev/null, stdout and stderr into the ohsetio files. Returns the pid.
468fn ohspawn to long
469pn = ohpkfin
470pid = fork
471if lt pid 0
472exit 65
473end
474if eq pid 0
475ohtclr
476ohtw ohxnull
477f0 = fopen oht 0 get ohtn 0 0 0
478f1 = fopen oho 0 get ohio 0 577 420
479f2 = fopen ohe 0 get ohio 1 577 420
480if or or lt f0 0 lt f1 0 lt f2 0
481exit 65
482end
483d0 = dupfd int f0 0 0
484d1 = dupfd int f1 1 0
485d2 = dupfd int f2 2 0
486c0 = fclose int f0
487c1 = fclose int f1
488c2 = fclose int f2
489e = execprog ohpk 0 pn
490exit 65
491end
492ret pid
493end
494
495note Wait for pid; exit code, or 128 + signal.
496fn ohwait pid long to long
497r = waitpid int pid ohst 0 4 0
498while eq r neg long 4 bound 1000
499r = waitpid int pid ohst 0 4 0
500end
501if lt r 0
502exit 65
503end
504s = uint get ohst 0
505s = or s shl uint get ohst 1 8
506s = or s shl uint get ohst 2 16
507s = or s shl uint get ohst 3 24
508if eq and s 127 0
509ret long and shr s 8 255
510end
511ret add long and s 127 128
512end
513
514fn ohconf to void
515if ne argcnt 2
516exit 61
517end
518r = argread 1 oht 0 4096
519if lt r 1
520exit 61
521end
522put ohtn 0 ulong r
523k = ohrdf
524if or lt k 1 gt k 8192
525exit 61
526end
527n = ulong k
528i = ulong 0
529s = ulong 0
530for p ulong n
531c = get ohb p
532put ohcf p c
533if eq c 10
534if or ge i ohncf eq p s
535exit 61
536end
537put ohco i s
538put ohcl i sub p s
539i = add i 1
540s = add p 1
541end
542end
543if or ne i ohncf ne s n
544exit 61
545end
546end
547
548fn ohmkdir w ulong to void
549ohtclr
550ohtw w
551r = makedir oht 0 get ohtn 0 493
552if and lt r 0 ne r neg long 17
553exit 65
554end
555end
556
557note Sync the case directory so a new journal name survives a crash.
558fn ohsyncd to void
559ohtclr
560ohtc 46
561fd = fopen oht 0 1 0 0
562if lt fd 0
563exit 65
564end
565s = fsync int fd
566c = fclose int fd
567if lt s 0
568exit 65
569end
570end
571
572note Create episode.oe45 = "oe45 v1" + G from goal.oe45 if it does not exist.
573fn ohinitj to void
574ohtclr
575ohtw ohxep
576s = stat oht 0 get ohtn 0 ohsb 0 128
577if ge s 0
578ret
579end
580ohtclr
581ohtw ohxgoal
582k = ohrdf
583if lt k 2
584exit 64
585end
586n = ulong k
587for p ulong sub n 1
588if eq get ohb p 10
589exit 64
590end
591end
592if ne get ohb sub n 1 10
593exit 64
594end
595ohtclr
596ohtb 0 sub n 1
597g = ohtoin
598r = ocsetgl g
599if lt r 0
600exit 64
601end
602ohtclr
603ohtw 61
604ohtc 32
605ohtw 62
606ohtc 10
607ohtb 0 n
608ohtod
609ohtclr
610ohtw ohxep
611ohwrd 193
612ohsyncd
613end
614
615note v1.3 episode shape, checked both while replaying and before journaling/dispatch.
616note Refuse is the first and only A; its P must be refused bound. P needs an A.
617fn ohorder k ulong to void
618last = get ohv ohslast
619if eq k 2
620if and ne last ohkg ne last ohkr
621exit 64
622end
623if and eq get ocids 1 9 ne last ohkg
624exit 64
625end
626end
627if eq k 4
628if and ne last ohkr ne last ohkaref
629exit 64
630end
631if eq last ohkaref
632if or ne get ocids 1 11 ne get ocids 2 13
633exit 64
634end
635end
636end
637end
638
639note Classify one journal line held in ocin[0..l) and update the state.
640fn ohline l ulong to void
641last = get ohv ohslast
642if eq last 0
643r = ocsetgl l
644if lt r 0
645exit 64
646end
647put ohv ohsjobs 1
648if eq get ocgv 0 7
649put ohv ohsjobs 2
650end
651put ohv ohslast ohkg
652ret
653end
654k = ocvline l 0
655if or lt k 0 eq k 1
656exit 64
657end
658ohorder ulong k
659if eq k 2
660put ohv ohsnmod add get ohv ohsnmod 1
661if eq get ocids 1 9
662put ohv ohslast ohkaref
663ret
664end
665a = add get ohv ohsatt 1
666put ohv ohsatt a
667f = get ohv ohsnf
668if ge f 8
669exit 64
670end
671put ohfj mul f 2 get ohv ohsjob
672put ohfj add mul f 2 1 a
673put ohv ohsnf add f 1
674if gt l len ohal
675exit 64
676end
677for j ulong l
678put ohal j get ocin j
679end
680put ohv ohsnal l
681put ohv ohslast ohkajob
682ret
683end
684if eq k 3
685if ne last ohkajob
686exit 64
687end
688put ohv ohslast ohkr
689put ohv ohstr 0
690if eq get ocids 1 10
691put ohv ohsjob add get ohv ohsjob 1
692put ohv ohsatt 0
693ret
694end
695if eq get ocids 2 17
696put ohv ohstr 1
697end
698ret
699end
700put ohv ohsnmod add get ohv ohsnmod 1
701put ohv ohslast ohkp
702end
703
704note Drop a torn (unterminated) journal tail; keep everything up to the last LF.
705fn ohtorn n ulong to ulong
706q = n
707while gt q 0 bound 70000
708if eq get ohb sub q 1 10
709break
710end
711q = sub q 1
712end
713ohtclr
714ohtw ohxep
715fd = fopen oht 0 get ohtn 0 1 0
716if lt fd 0
717exit 65
718end
719r = ftrunc int fd long q
720s = fsync int fd
721c = fclose int fd
722if or lt r 0 lt s 0
723exit 65
724end
725ohhead ohxtorn
726ohtc 32
727ohtd sub n q
728ohlog
729ret q
730end
731
732note Rebuild the episode state from the journal.
733fn ohscan to void
734ohtclr
735ohtw ohxep
736k = ohrdf
737if lt k 8
738exit 64
739end
740n = ulong k
741if ne get ohb sub n 1 10
742n = ohtorn n
743end
744ohtclr
745ohtw 61
746ohtc 32
747ohtw 62
748for j ulong 7
749if ne get ohb j get oht j
750exit 64
751end
752end
753if ne get ohb 7 10
754exit 64
755end
756put ohv ohslast 0
757put ohv ohsjob 1
758put ohv ohsatt 0
759put ohv ohstr 0
760put ohv ohsnmod 0
761put ohv ohsnf 0
762p = ulong 8
763while lt p n bound 256
764e = p
765while ne get ohb e 10 bound 4096
766e = add e 1
767end
768l = sub e p
769if gt l len ocin
770exit 64
771end
772for j ulong l
773put ocin j get ohb add p j
774end
775ohline l
776p = add e 1
777end
778if eq get ohv ohslast 0
779exit 64
780end
781end
782
783note Run the core once; returns the validated model line length in ocin, or 0.
784fn ohdec1 g bool to ulong
785put ohv ohsdecs add get ohv ohsdecs 1
786if gt get ohv ohsdecs 16
787exit 64
788end
789ohpkclr
790ohpkk ohccore
791ohpw ohxdec
792ohpkk ohcckpt
793if g
794ohpw ohxg
795else
796ohpkk ohcmode
797end
798ohpw ohxep
799ohsetio ohxdec
800pid = ohspawn
801e = ohwait pid
802ohhead ohxdecd
803ohtc 32
804ohtw ohxrceq
805ohtd ulong e
806ohlog
807if or eq e 51 eq e 52
808exit 63
809end
810if ne e 0
811ret 0
812end
813ohotot
814k = ohrdf
815if lt k 2
816ret 0
817end
818n = ulong k
819for p ulong sub n 1
820if eq get ohb p 10
821ret 0
822end
823end
824if ne get ohb sub n 1 10
825ret 0
826end
827ohtclr
828ohtb 0 sub n 1
829m = ohtoin
830v = ocvline m 5
831if lt v 0
832ret 0
833end
834ret m
835end
836
837note Decode in the configured mode; on an invalid line or rc, one guided repair
838note in mode G. The repair is logged in hive.log, never in the journal.
839fn ohdecode to ulong
840m = ohdec1 false
841if gt m 0
842ret m
843end
844ohhead ohxrepr
845ohlog
846m = ohdec1 true
847if gt m 0
848ret m
849end
850exit 63
851end
852
853fn ohbpath j ulong to void
854ohtclr
855ohtw ohxdisp
856ohtc 47
857ohtc 106
858ohtd j
859ohtw ohxan0b
860end
861
862fn ohbe b ulong n ulong to ulong
863v = ulong 0
864for i ulong n
865v = add shl v 8 ulong get ohb add b i
866end
867ret v
868end
869
870note Ensure disp/j<j>.an0b exists and its payload equals the lowered A (oclv).
871fn ohbund j ulong to void
872ohbpath j
873s = stat oht 0 get ohtn 0 ohsb 0 128
874if lt s 0
875ohpkclr
876ohpkk ohcrun
877ohpw ohxbund
878ohpw ohxkeys
879ohpkk ohckeys
880ohpw ohxout
881ohbpath j
882ohpkt
883for i ulong 4
884ohpw add ohxm i
885ohpd get oclv i
886end
887ohsetio ohxbund
888pid = ohspawn
889e = ohwait pid
890if ne e 0
891ohhead ohxbund
892ohtc 32
893ohtw ohxrceq
894ohtd ulong e
895ohlog
896exit 65
897end
898ohhead ohxnew
899ohtc 32
900ohbpath j
901ohlog
902end
903ohbpath j
904k = ohrdf
905if lt k 124
906exit 69
907end
908ok = and eq get ohb 6 0 eq get ohb 7 15
909ok = and ok eq get ohb 109 1
910ok = and ok eq ohbe 110 2 get oclv 0
911ok = and ok eq ohbe 112 2 get oclv 1
912ok = and ok eq ohbe 114 2 get oclv 2
913ok = and ok eq ohbe 116 8 get oclv 3
914if not ok
915ohhead ohxlower
916ohlog
917exit 69
918end
919end
920
921fn ohishex p ulong to bool
922if gt add p 64 get ohbn 0
923ret false
924end
925for j ulong 64
926c = get ohb add p j
927if not or and ge c 48 le c 57 and ge c 97 le c 102
928ret false
929end
930end
931ret true
932end
933
934note Does ohb[p..] start with word w?
935fn ohat p ulong w ulong to bool
936o = get ohwo w
937l = get ohwl w
938if gt add p l get ohbn 0
939ret false
940end
941for j ulong l
942x = get ohb add p j
943if ne x get ohw add o j
944ret false
945end
946end
947ret true
948end
949
950note Position just after the first word w in ohb[0..ohbn), or -1.
951fn ohfind w ulong to long
952n = get ohbn 0
953for p ulong n
954if ohat p w
955ret long add p get ohwl w
956end
957end
958ret neg long 1
959end
960
961note Is ohb[p..] exactly word w, followed by space, LF or the end?
962fn ohmatch p ulong w ulong to bool
963if not ohat p w
964ret false
965end
966l = get ohwl w
967n = get ohbn 0
968if eq add p l n
969ret true
970end
971c = get ohb add p l
972ret or eq c 32 eq c 10
973end
974
975note dag_id from the aienet0-run stderr file.
976fn ohgdag to void
977put ohv ohsdag 0
978ohetot
979k = ohrdf
980if lt k 0
981exit 65
982end
983q = ohfind ohxdagid
984if lt q 0
985ret
986end
987p = ulong q
988if not ohishex p
989ret
990end
991for j ulong 64
992put ohdag j get ohb add p j
993end
994put ohv ohsdag 1
995end
996
997note Exit 0: VERIFIED <dag> <sha> <path> must name the same dag; MJR1 outcome 1.
998fn ohgver to void
999ohotot
1000k = ohrdf
1001if lt k 0
1002exit 65
1003end
1004q = ohfind ohxverif
1005if or lt q 0 ne get ohv ohsdag 1
1006exit 66
1007end
1008p = add ulong q 1
1009if or not ohishex p not ohishex add p 65
1010exit 66
1011end
1012for j ulong 64
1013if ne get ohb add p j get ohdag j
1014exit 66
1015end
1016put ohsha j get ohb add add p 65 j
1017end
1018put ohv ohssha 1
1019ohtclr
1020ohtw ohxodir
1021ohtc 47
1022ohtdag
1023ohtw ohxmjr1
1024n = get ohtn 0
1025for j ulong n
1026put ocpath j get oht j
1027end
1028r = ocmjrf n
1029if ne r 1
1030exit 66
1031end
1032put ohv ohsout 1
1033end
1034
1035note Exit 11: the refusal tag is the word after "REFUSED WORKER " on stdout.
1036fn ohgtag to ulong
1037ohotot
1038k = ohrdf
1039if lt k 0
1040exit 65
1041end
1042q = ohfind ohxworkr
1043if lt q 0
1044ret ohxwork
1045end
1046p = add ulong q 1
1047if ohmatch p ohxa0rep
1048ret ohxrepl
1049end
1050if or ohmatch p ohxa0bud ohmatch p ohxmjbud
1051ret ohxbudg
1052end
1053ret ohxwork
1054end
1055
1056note aienet0-run exit -> R class and code words.
1057fn ohmap e long to void
1058put ohv ohscode ohxdash
1059put ohv ohscls ohxfail
1060if eq e 0
1061ohgver
1062put ohv ohscls ohxok
1063ret
1064end
1065if eq e 11
1066put ohv ohscls ohxrefd
1067put ohv ohscode ohgtag
1068ret
1069end
1070if eq e 10
1071put ohv ohscode ohxtrans
1072ret
1073end
1074if eq e 12
1075put ohv ohscode ohxrcpt
1076ret
1077end
1078if eq e 13
1079put ohv ohscode ohxrcmp
1080ret
1081end
1082if eq e 14
1083put ohv ohscode ohxverd
1084ret
1085end
1086if eq e 15
1087put ohv ohscode ohxio
1088ret
1089end
1090ohhead ohxrceq
1091ohtd ulong e
1092ohlog
1093exit 66
1094end
1095
1096note disp/j<j>a<a>.fact: one facts.tsv row for this dispatch.
1097fn ohfact j ulong a ulong e long to void
1098ohtclr
1099ohtd j
1100ohtc 9
1101ohtd a
1102for i ulong 4
1103ohtc 9
1104ohtd get oclv i
1105end
1106ohtc 9
1107ohtd ulong e
1108ohtc 9
1109ohtw get ohv ohscls
1110ohtc 9
1111ohtw get ohv ohscode
1112ohtc 9
1113ohtdag
1114ohtc 9
1115ohtsha
1116ohtc 9
1117if eq e 0
1118ohtd get ohv ohsout
1119ohtc 9
1120ohtk ohcverif
1121else
1122ohtw ohxdash
1123ohtc 9
1124ohtw ohxdash
1125end
1126ohtc 10
1127ohtod
1128ohtclr
1129ohtw ohxdisp
1130ohtc 47
1131ohtc 106
1132ohtd j
1133ohtc 97
1134ohtd a
1135ohtw ohxfact
1136ohwrd 577
1137end
1138
1139note Journal R after self-validating it against the R grammar.
1140fn ohjres to void
1141ohtclr
1142ohtw ohxres
1143ohtc 32
1144ohtw get ohv ohscls
1145if ne get ohv ohscode ohxdash
1146ohtc 32
1147ohtw get ohv ohscode
1148end
1149ohtc 32
1150ohtw ohxend
1151m = ohtoin
1152v = ocvline m 3
1153if ne v 3
1154exit 64
1155end
1156ohappw ohxep
1157end
1158
1159fn ohspsrv rt ulong to long
1160ohpkclr
1161ohpkk ohcserve
1162ohpw ohxconn
1163ohpkk ohcaddr
1164ohpw ohxkeys
1165ohpkk ohcwkeys
1166ohpw ohxpins
1167ohpkk ohcwpins
1168ohpw ohxstate
1169ohpkk ohcwst
1170ohpw ohxcto
1171ohpw ohxcto30
1172if eq rt 1
1173ohpw ohxretry
1174end
1175ohsetio ohxserve
1176ret ohspawn
1177end
1178
1179fn ohsprun j ulong to long
1180ohpkclr
1181ohpkk ohcrun
1182ohpw ohxrun
1183ohpw ohxlist
1184ohpkk ohcaddr
1185ohpw ohxkeys
1186ohpkk ohckeys
1187ohpw ohxpins
1188ohpkk ohcpins
1189ohpw ohxout
1190ohpw ohxodir
1191ohpw ohxrec
1192ohpkk ohcrec
1193ohpw ohxrecs
1194ohpkk ohcrecs
1195ohpw ohxresnd
1196ohbpath j
1197ohpkt
1198ohpw ohxacct
1199ohpkk ohcacct
1200ohsetio ohxrun
1201ret ohspawn
1202end
1203
1204note One dispatch of job j, attempt a (oclv holds the lowered A).
1205fn ohdisp j ulong a ulong rt ulong to void
1206ohbund j
1207ohtclr
1208ohtw ohxint
1209ohtc 32
1210ohtd j
1211ohtc 32
1212ohtd a
1213ohtc 32
1214ohtw ohxretry
1215ohtc 61
1216ohtd rt
1217ohtc 32
1218ohtw ohxdisp
1219ohtc 47
1220ohtc 106
1221ohtd j
1222ohtw ohxan0b
1223put ohv ohsdag 0
1224ohappw ohxdlog
1225wp = ohspsrv rt
1226rp = ohsprun j
1227e = ohwait rp
1228we = ohwait wp
1229put ohv ohssha 0
1230put ohv ohsout 0
1231ohgdag
1232ohmap e
1233ohfact j a e
1234ohjres
1235ohtclr
1236ohtw ohxoutc
1237ohtc 32
1238ohtd j
1239ohtc 32
1240ohtd a
1241ohtc 32
1242ohtd ulong e
1243ohtc 32
1244ohtdag
1245ohtc 32
1246ohtw ohxserve
1247ohtc 61
1248ohtd ulong we
1249ohappw ohxdlog
1250end
1251
1252note Reconcile an A job journaled without its R (interrupted dispatch).
1253fn ohrecon to void
1254n = get ohv ohsnal
1255for j ulong n
1256put ocin j get ohal j
1257end
1258r = oclowerl n
1259if ne r 0
1260exit 64
1261end
1262ohhead ohxrecon
1263ohtc 32
1264ohtd get ohv ohsjob
1265ohtc 32
1266ohtd get ohv ohsatt
1267ohlog
1268ohdisp get ohv ohsjob get ohv ohsatt 1
1269end
1270
1271note A validated model line is in ocin[0..n): journal it, dispatching an A job.
1272fn ohstep n ulong to void
1273ohorder get ocids 0
1274if eq get ocids 0 2
1275if eq get ocids 1 8
1276j = get ohv ohsjob
1277a = get ohv ohsatt
1278if or ge a 2 and gt a 0 eq get ohv ohstr 0
1279ohhead ohxrefu
1280ohlog
1281exit 64
1282end
1283b = ocbindl n j
1284if or eq b 41 eq b 42
1285ohhead ohxbind
1286ohtc 32
1287ohtd ulong b
1288ohlog
1289exit 62
1290end
1291if ne b 0
1292exit 64
1293end
1294r = oclowerl n
1295if ne r 0
1296exit 64
1297end
1298rt = get ohv ohstr
1299ohtclr
1300for i ulong n
1301ohtc get ocin i
1302end
1303ohappw ohxep
1304ohdisp j add a 1 rt
1305ret
1306end
1307end
1308ohtclr
1309for i ulong n
1310ohtc get ocin i
1311end
1312ohappw ohxep
1313end
1314
1315fn ohfacts to void
1316ohtclr
1317for i ulong 13
1318if gt i 0
1319ohtc 9
1320end
1321ohtw add ohxhdr i
1322end
1323ohtc 10
1324ohtod
1325ohtclr
1326ohtw ohxfacts
1327ohwrd 577
1328for f ulong get ohv ohsnf
1329j = get ohfj mul f 2
1330a = get ohfj add mul f 2 1
1331ohtclr
1332ohtw ohxdisp
1333ohtc 47
1334ohtc 106
1335ohtd j
1336ohtc 97
1337ohtd a
1338ohtw ohxfact
1339k = ohrdf
1340if lt k 1
1341exit 65
1342end
1343ohbtod ulong k
1344ohtclr
1345ohtw ohxfacts
1346ohwrd 1089
1347end
1348end
1349
1350fn main to int
1351ohwinit
1352put ohv ohspid ulong getpid
1353ohconf
1354ohmkdir ohxdisp
1355ohmkdir ohxodir
1356ohmkdir ohxlogs
1357ohinitj
1358for it ulong 40
1359ohscan
1360last = get ohv ohslast
1361if eq last ohkp
1362ohfacts
1363ohhead ohxhdone
1364ohtc 32
1365ohtd get ohv ohsnf
1366ohlog
1367ret 0
1368end
1369if eq last ohkajob
1370ohrecon
1371else
1372if ge get ohv ohsnmod 10
1373exit 64
1374end
1375n = ohdecode
1376ohstep n
1377end
1378end
1379exit 64
1380end