interplane.Get Omega
Read in your language

omega-mission

Omega Mission: seeded-Omega mission orchestrator (hash-chained journal, tiered command checks). Host-tested; live dispatch not yet run.

Brought by drakestapleton

branch main Branches Tags History

omega-mission / mission.om

825 lines · 12032 bytes Raw Blame History
1note omega-mission, pure seeded Omega; compose after seed/trace/sha256.om.
2global mb uchar 1024
3global mn ulong 1
4global mo ulong 13
5global ml ulong 13
6global eb uchar 1024
7global en ulong 1
8global jb uchar 4096
9global jn ulong 1
10global jo ulong 6
11global jl ulong 6
12global prev uchar 64
13global saved uchar 131072
14global slen ulong 128
15global states ulong 128
16global count ulong 1
17global chosen ulong 1
18global args uchar 16384
19global alen ulong 32
20global temp uchar 131072
21global tn ulong 1
22text hx "0123456789abcdef"
23text zero "0000000000000000000000000000000000000000000000000000000000000000"
24text err "mission: refused (usage=2 policy=3 evidence=4 chain=5 io=6)\n"
25text stnames "PROPOSED CLAIMED RUNNING READY VERIFIED MERGED FAILED"
26text t_ro "read-only"
27text t_edit "local-edit"
28text t_build "build-run"
29text t_lease "lease"
30text s_none "none"
31text s_gpu "gb10"
32text s_lease "spark-window-exclusive"
33fn die code int to void
34x = write 2 err 0 len err
35exit code
36end
37fn argload to void
38if gt argcnt 32
39die 2
40end
41for i ulong ulong argcnt
42r = argread i args mul i 512 512
43if lt r 0
44die 2
45end
46put alen i ulong r
47end
48end
49fn aeq i ulong s view uchar * to bool
50if ne get alen i len s
51ret false
52end
53for z ulong len s
54if ne get args add mul i 512 z get s z
55ret false
56end
57end
58ret true
59end
60fn meq i ulong s view uchar * to bool
61if ne get ml i len s
62ret false
63end
64for z ulong len s
65if ne get mb add get mo i z get s z
66ret false
67end
68end
69ret true
70end
71fn fieldsame a ulong b ulong to bool
72if ne get ml a get ml b
73ret false
74end
75for z ulong get ml a
76if ne get mb add get mo a z get mb add get mo b z
77ret false
78end
79end
80ret true
81end
82note Identities compare ASCII case-insensitively, so Reviewer and reviewer are one actor.
83fn lowc c uchar to uchar
84if and ge c 65 le c 90
85ret uchar add c 32
86end
87ret c
88end
89fn idsame a ulong b ulong to bool
90if ne get ml a get ml b
91ret false
92end
93for z ulong get ml a
94x = lowc get mb add get mo a z
95y = lowc get mb add get mo b z
96if ne x y
97ret false
98end
99end
100ret true
101end
102fn idchar c uchar to bool
103if and ge c 65 le c 90
104ret true
105end
106if and ge c 97 le c 122
107ret true
108end
109if and ge c 48 le c 57
110ret true
111end
112ret or eq c 45 or eq c 46 eq c 95
113end
114fn hexval c uchar to ulong
115if and ge c 48 le c 57
116ret ulong sub c 48
117end
118if and ge c 97 le c 102
119ret ulong sub c 87
120end
121die 5
122ret 0
123end
124fn msplits to void
125p = ulong 0
126q = ulong 0
127for i ulong get mn 0
128c = get mb i
129if or lt c 32 gt c 126
130die 2
131end
132if or eq c 34 eq c 92
133die 2
134end
135if eq c 124
136if or ge q 12 eq i p
137die 2
138end
139put mo q p
140put ml q sub i p
141q = add q 1
142p = add i 1
143end
144end
145if or ne q 12 eq p get mn 0
146die 2
147end
148put mo 12 p
149put ml 12 sub get mn 0 p
150end
151fn tier to ulong
152if meq 8 t_ro
153ret 0
154end
155if meq 8 t_edit
156ret 1
157end
158if meq 8 t_build
159ret 2
160end
161if meq 8 t_lease
162ret 3
163end
164die 2
165ret 0
166end
167fn cores to void
168p = get mo 5
169lim = add p get ml 5
170lo = ulong 0
171v = ulong 0
172digits = ulong 0
173range = false
174while le p lim bound 1024
175c = uchar 44
176if lt p lim
177c = get mb p
178end
179if and ge c 48 le c 57
180v = add mul v 10 ulong sub c 48
181if gt v 255
182die 2
183end
184digits = add digits 1
185else
186if eq digits 0
187die 2
188end
189if eq c 45
190if range
191die 2
192end
193lo = v
194range = true
195else
196if ne c 44
197die 2
198end
199if not range
200lo = v
201end
202if gt lo v
203die 2
204end
205while le lo v bound 256
206if or eq lo 3 or eq lo 7 eq lo 15
207die 2
208end
209lo = add lo 1
210end
211range = false
212end
213v = 0
214digits = 0
215end
216p = add p 1
217end
218end
219note Command tokens are checked without executing them.
220global cb uchar 2048
221global cn ulong 1
222global co ulong 64
223global cl ulong 64
224global nc ulong 1
225fn ceq i ulong s view uchar * to bool
226if ge i get nc 0
227ret false
228end
229if ne get cl i len s
230ret false
231end
232for z ulong len s
233if ne get cb add get co i z get s z
234ret false
235end
236end
237ret true
238end
239fn cmdparse to void
240put nc 0 0
241p = ulong 0
242while lt p get cn 0 bound 2048
243if eq get cb p 32
244p = add p 1
245continue
246end
247beg = p
248while lt p get cn 0 bound 2048
249c = get cb p
250if eq c 32
251break
252end
253if not or idchar c or eq c 47 or eq c 61 or eq c 44 eq c 58
254die 3
255end
256p = add p 1
257end
258n = get nc 0
259if ge n 64
260die 3
261end
262put co n beg
263put cl n sub p beg
264put nc 0 add n 1
265end
266if eq get nc 0 0
267die 3
268end
269end
270text c_git "git"
271text c_rad "rad"
272text c_gh "gh"
273text c_push "push"
274text c_merge "merge"
275text c_sh "sh"
276text c_status "status"
277text c_diff "diff"
278text c_log "log"
279text c_show "show"
280text c_cat "cat"
281text c_pwd "pwd"
282text c_mkdir "mkdir"
283text c_touch "touch"
284text c_omc "omc"
285text c_miss "mission"
286text c_verify "verify"
287text c_plan "plan"
288text c_spark "spark-window"
289text c_open "open"
290text c_gb "--gb10"
291text c_excl "exclusive"
292text c_quiet "--quiet"
293text c_lflag "--lease"
294text c_wait "--wait"
295note Read/edit operands stay inside the slice planned paths: relative, no dot-dot, no option.
296fn slicearg i ulong to void
297b = get co i
298n = get cl i
299c0 = get cb b
300if or eq c0 45 eq c0 47
301die 3
302end
303for z ulong n
304if eq get cb add b z 46
305if lt add z 1 n
306if eq get cb add add b z 1 46
307die 3
308end
309end
310end
311end
312if not inpaths b n
313die 3
314end
315end
316fn inpaths b ulong n ulong to bool
317p = get mo 4
318lim = add p get ml 4
319st = p
320while le p lim bound 1025
321sep = eq p lim
322if not sep
323sep = eq get mb p 44
324end
325if sep
326if pathpre b n st sub p st
327ret true
328end
329st = add p 1
330end
331p = add p 1
332end
333ret false
334end
335fn pathpre b ulong n ulong st ulong pk ulong to bool
336note Operand is a plan path or lies below one; a plan path of dot is the whole repo.
337if eq pk 1
338if eq get mb st 46
339ret true
340end
341end
342if lt n pk
343ret false
344end
345for z ulong pk
346if ne get cb add b z get mb add st z
347ret false
348end
349end
350if eq n pk
351ret true
352end
353if eq get mb add st sub pk 1 47
354ret true
355end
356ret eq get cb add b pk 47
357end
358fn relexec i ulong to void
359note Token i names a repository-relative file: no PATH lookup, option, absolute path or dot-dot.
360b = get co i
361n = get cl i
362c0 = get cb b
363if or eq c0 45 eq c0 47
364die 3
365end
366slash = false
367for z ulong n
368c = get cb add b z
369if eq c 47
370slash = true
371end
372if eq c 46
373if lt add z 1 n
374if eq get cb add add b z 1 46
375die 3
376end
377end
378end
379end
380if eq i 0
381if not slash
382die 3
383end
384end
385end
386note spark-window LEASE_MAX is 20 minutes for exclusive windows; admit only decimal 1..20.
387fn leaseok to bool
388n = get cl 8
389p = get co 8
390a = get cb p
391if eq n 1
392ret and ge a 49 le a 57
393end
394if ne n 2
395ret false
396end
397b = get cb add p 1
398if eq a 49
399ret and ge b 48 le b 57
400end
401ret and eq a 50 eq b 48
402end
403fn cmdpolicy lvl ulong to void
404cmdparse
405for i ulong get nc 0
406if or ceq i c_push ceq i c_merge
407die 3
408end
409end
410note Acceptance argv is verifier metadata, not worker execution permission. It is
411note mission verify/status/plan, bare omc, or a repository-relative script or executable.
412if eq lvl 99
413if ceq 0 c_omc
414if ne get nc 0 1
415die 3
416end
417ret
418end
419if ceq 0 c_miss
420if ne get nc 0 3
421die 3
422end
423if or ceq 1 c_verify or ceq 1 c_status ceq 1 c_plan
424ret
425end
426die 3
427end
428first = ulong 0
429if ceq 0 c_sh
430if lt get nc 0 2
431die 3
432end
433first = 1
434end
435relexec first
436ret
437end
438if ceq 0 c_git
439if ne get nc 0 2
440die 3
441end
442if or ceq 1 c_status or ceq 1 c_diff or ceq 1 c_log ceq 1 c_show
443ret
444end
445die 3
446end
447if or ceq 0 c_rad ceq 0 c_gh
448die 3
449end
450if ceq 0 c_pwd
451if ne get nc 0 1
452die 3
453end
454ret
455end
456if ceq 0 c_cat
457if ne get nc 0 2
458die 3
459end
460slicearg 1
461ret
462end
463if ge lvl 1
464if or ceq 0 c_mkdir ceq 0 c_touch
465if ne get nc 0 2
466die 3
467end
468slicearg 1
469ret
470end
471end
472if ge lvl 2
473if ceq 0 c_omc
474if ne get nc 0 1
475die 3
476end
477ret
478end
479if ceq 0 c_miss
480if ne get nc 0 3
481die 3
482end
483if or ceq 1 c_verify or ceq 1 c_status ceq 1 c_plan
484ret
485end
486die 3
487end
488end
489if ceq 0 c_spark
490if and ceq 1 c_status eq get nc 0 2
491ret
492end
493if eq lvl 3
494note A slice planned without a GPU never opens a GPU window.
495if meq 6 s_none
496die 3
497end
498if ne get nc 0 10
499die 3
500end
501if not and ceq 1 c_open ceq 3 c_gb
502die 3
503end
504if not and ceq 4 c_excl ceq 5 c_quiet
505die 3
506end
507if not and ceq 6 s_none ceq 7 c_lflag
508die 3
509end
510if not ceq 9 c_wait
511die 3
512end
513if not leaseok
514die 3
515end
516ret
517end
518end
519die 3
520end
521fn mcommand fld ulong lvl ulong to void
522put cn 0 get ml fld
523for i ulong get ml fld
524put cb i get mb add get mo fld i
525end
526cmdpolicy lvl
527end
528fn isgit p ulong to bool
529if ne get mb p 46
530ret false
531end
532if ne get mb add p 1 103
533ret false
534end
535if ne get mb add p 2 105
536ret false
537end
538ret eq get mb add p 3 116
539end
540fn nogit to void
541note Plan paths never name the repository metadata directory .git as a segment.
542o = get mo 4
543l = get ml 4
544for i ulong l
545st = eq i 0
546if not st
547pc = get mb add o sub i 1
548st = or eq pc 44 eq pc 47
549end
550if st
551if le add i 4 l
552if isgit add o i
553e = add i 4
554if eq e l
555die 3
556end
557c = get mb add o e
558if or eq c 44 eq c 47
559die 3
560end
561end
562end
563end
564end
565end
566fn validate to void
567msplits
568for f ulong 4
569for i ulong get ml f
570if not idchar get mb add get mo f i
571die 2
572end
573end
574end
575if idsame 1 2
576die 2
577end
578for i ulong get ml 4
579c = get mb add get mo 4 i
580if not or idchar c or eq c 47 eq c 44
581die 2
582end
583if eq c 44
584if or eq i 0 eq add i 1 get ml 4
585die 2
586end
587next = get mb add add get mo 4 i 1
588if or eq next 44 eq next 47
589die 2
590end
591end
592if eq c 46
593if lt add i 1 get ml 4
594if eq get mb add add get mo 4 i 1 46
595die 2
596end
597end
598end
599end
600if eq get mb get mo 4 47
601die 2
602end
603nogit
604cores
605lvl = tier
606if meq 6 s_none
607if not meq 7 s_none
608die 2
609end
610else
611if not and meq 6 s_gpu meq 7 s_lease
612die 2
613end
614if ne lvl 3
615die 2
616end
617end
618if ne get ml 9 40
619die 2
620end
621for i ulong 40
622c = get mb add get mo 9 i
623if not or and ge c 48 le c 57 and ge c 97 le c 102
624die 2
625end
626end
627if fieldsame 10 11
628die 2
629end
630mcommand 10 99
631mcommand 11 99
632mcommand 12 lvl
633end
634note IO helpers keep file reads bounded and reject one extra byte.
635fn loadfile ai ulong to void
636fd = fopen args mul ai 512 get alen ai 131072 0
637if lt fd 0
638die 6
639end
640put tn 0 0
641while lt get tn 0 131072 bound 131072
642r = read int fd temp get tn 0 sub 131072 get tn 0
643if lt r 0
644die 6
645end
646if eq r 0
647break
648end
649put tn 0 add get tn 0 ulong r
650end
651x = fclose int fd
652if eq get tn 0 131072
653die 2
654end
655end
656fn emit s view uchar * to void
657i = ulong 0
658while lt i len s bound 131072
659r = write 1 s i sub len s i
660if le r 0
661die 6
662end
663i = add i ulong r
664end
665end
666text jq0 "{\"id\":\""
667text jq1 "\",\"owner\":\""
668text jq2 "\",\"verifier\":\""
669text jq3 "\",\"repo\":\""
670text jq4 "\",\"paths\":\""
671text jq5 "\",\"cores\":\""
672text jq6 "\",\"gpu\":\""
673text jq7 "\",\"lease\":\""
674text jq8 "\",\"tier\":\""
675text jq9 "\",\"head\":\""
676text jq10 "\",\"acceptance\":\""
677text jq11 "\",\"negative\":\""
678text jq12 "\",\"command\":\""
679text jq13 "\"}\n"
680text jsstate "\",\"state\":\""
681text state1 "PROPOSED"
682text state2 "CLAIMED"
683text state3 "RUNNING"
684text state4 "READY"
685text state5 "VERIFIED"
686text state6 "MERGED"
687text state7 "FAILED"
688fn fieldout f ulong to void
689x = write 1 mb get mo f get ml f
690if ne x long get ml f
691die 6
692end
693end
694fn stateout n ulong to void
695if eq n 1
696emit state1
697end
698if eq n 2
699emit state2
700end
701if eq n 3
702emit state3
703end
704if eq n 4
705emit state4
706end
707if eq n 5
708emit state5
709end
710if eq n 6
711emit state6
712end
713if eq n 7
714emit state7
715end
716end
717fn planout to void
718emit jq0
719fieldout 0
720emit jq1
721fieldout 1
722emit jq2
723fieldout 2
724emit jq3
725fieldout 3
726emit jq4
727fieldout 4
728emit jq5
729fieldout 5
730emit jq6
731fieldout 6
732emit jq7
733fieldout 7
734emit jq8
735fieldout 8
736emit jq9
737fieldout 9
738emit jq10
739fieldout 10
740emit jq11
741fieldout 11
742emit jq12
743fieldout 12
744emit jq13
745end
746fn findslot to ulong
747for s ulong get count 0
748p = mul s 1024
749same = true
750for i ulong get ml 0
751if ne get saved add p i get mb i
752same = false
753end
754end
755if ne get saved add p get ml 0 124
756same = false
757end
758if same
759ret s
760end
761end
762ret 128
763end
764fn savem s ulong to void
765for i ulong get mn 0
766put saved add mul s 1024 i get mb i
767end
768put slen s get mn 0
769end
770fn restore s ulong to void
771put mn 0 get slen s
772for i ulong get mn 0
773put mb i get saved add mul s 1024 i
774end
775msplits
776end
777fn addplan to void
778validate
779if ne findslot 128
780die 2
781end
782s = get count 0
783if ge s 128
784die 2
785end
786savem s
787put count 0 add s 1
788end
789fn loadplan ai ulong to void
790loadfile ai
791put mn 0 0
792for i ulong get tn 0
793c = get temp i
794if eq c 10
795if eq get mn 0 0
796die 2
797end
798addplan
799put mn 0 0
800else
801if ge get mn 0 1023
802die 2
803end
804put mb get mn 0 c
805put mn 0 add get mn 0 1
806end
807end
808if or ne get mn 0 0 eq get count 0 0
809die 2
810end
811end
812fn target s ulong ai ulong to bool
813if ge s get count 0
814ret false
815end
816n = get alen ai
817for i ulong n
818a = get args add mul ai 512 i
819b = get saved add mul s 1024 i
820if ne a b
821ret false
822end
823end
824ret eq get saved add mul s 1024 n 124
825end