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 / helix / ollm_factory / strand4_attr.om

775 lines · 12773 bytes Raw Blame History
1om2
2note SPDX-License-Identifier: Apache-2.0
3note seed/helix/ollm_factory/strand4_attr.om:
4note Pure seeded OM-2 4-Strand Fault Attribution Engine, Dual-View NUL-Delimited
5note Trace Extractor, Minimum Batch-Floor Guard, Four-Wall RSI + BFT Quorum Promotion
6note Gate, and Post-Cycle Scaling Decision Rule (Sections 4, 5, and 6).
7
8global saInBuf uchar 65536
9global saOutBuf uchar 131072
10global saLine uchar 1024
11global saTok uchar 128
12global saTaskId uchar 128
13global saFam uchar 128
14global saPathA uchar 256
15global saPathB uchar 256
16global saComp ulong 4
17global saPass ulong 4
18global saHash ulong 4
19global saErr ulong 4
20global saOutPos ulong 1
21global saStats ulong 8
22global saPArg ulong 16
23global saTmpA uchar 16384
24global saTmpB uchar 16384
25global saTmpC uchar 16384
26
27text saModeAttr "attribute"
28text saModeExtr "extract"
29text saModeProm "promote"
30text saModeDec "decide"
31text saModeSelf "selfcheck"
32
33text saClsUnan "UNANIMOUS_PASS"
34text saClsGap "BUILDER_STRAND_GAP"
35text saClsSyn "OM2_SYNTAX_GAP"
36text saClsLogic "ARCHITECT_LOGIC_FLAW"
37text saClsUnder "UNDERSPECIFIED_PLAN"
38text saClsMixed "MIXED_COMPILE_FAIL"
39
40text saActGold "HARVEST_GOLD_DUAL_VIEW"
41text saActGap "HARVEST_GOLD_AND_ROUTE_S4_REPAIR"
42text saActSyn "ROUTE_BEST_ERR_TO_S4_REPAIR"
43text saActLogic "FLAG_DEFECTIVE_PLAN_REQUEUE_Q36"
44text saActUnder "REQUEUE_Q36_STRICT_DECOMPOSE"
45text saActMixed "ROUTE_FAIL_TO_S4_REPAIR"
46
47text saHdrAttr "task_id\tfamily\tfault_class\taction\twinning_strand\tfailing_mask\tbest_err\n"
48text saNotePfx "note "
49text saPlanPfx "note ARCH_PLAN: "
50text saNl "\n"
51
52text saSumA "STRAND4_ATTR SUMMARY tasks="
53text saSumB " unanimous="
54text saSumC " builder_gap="
55text saSumD " syntax_gap="
56text saSumE " arch_logic="
57text saSumF " underspec="
58text saSumG " mixed="
59
60text saPrProm "FOUR_WALL_BFT strand="
61text saPrVerP " verdict=PROMOTE\n"
62text saPrVerFl " verdict=SKIP_BELOW_BATCH_FLOOR\n"
63text saPrVerW1 " verdict=WALL1_INTEGRITY_REJECT\n"
64text saPrVerW2 " verdict=REJECT_OVERFIT_KEEP_P1\n"
65text saPrVerW3 " verdict=WALL3_LEAKAGE_REJECT\n"
66text saPrVerW4 " verdict=WALL4_QUARANTINE_STRAND\n"
67
68text saDecCont "SCALING_RULE DECISION=CONTINUE_SCALING_STRANDS\n"
69text saDecWide "SCALING_RULE DECISION=WIDEN_LOOPED_CORE\n"
70
71text saExtrOk "DUAL_VIEW_EXTRACT PASS direct_bytes="
72text saExtrOk2 " align_bytes="
73
74text saSelfOk "STRAND4_ATTR SELFCHECK PASS fault_matrix=6/6 dual_view_nul=1 batch_floor=1 four_wall_bft=6/6 scaling_rule=2/2\n"
75text saUsage "usage: strand4_attr <attribute in out | extract orig plan code direct align | promote ... | decide ... | selfcheck>\n"
76
77fn saWrt1 s view uchar * to void
78r = write 1 s 0 len s
79end
80
81fn saWrt2 s view uchar * to void
82r = write 2 s 0 len s
83end
84
85fn saNum1 v ulong to void
86b = new uchar 24 0
87p = ulong 24
88x = v
89while true bound 24
90p = sub p 1
91put b p uchar add 48 rem x 10
92x = div x 10
93if eq x 0
94break
95end
96end
97r = write 1 b p sub 24 p
98end
99
100fn saEqBuf a view uchar * al ulong b view uchar * to bool
101if ne al len b
102ret false
103end
104for i ulong al bound 256
105if ne get a i get b i
106ret false
107end
108end
109ret true
110end
111
112fn saParseUlong a view uchar * al ulong to ulong
113v = ulong 0
114for i ulong al bound 32
115c = get a i
116if and ge c 48 le c 57
117v = add mul v 10 ulong sub c 48
118end
119end
120ret v
121end
122
123fn saParseTok al ulong to ulong
124v = ulong 0
125for i ulong al bound 32
126c = get saTok i
127if and ge c 48 le c 57
128v = add mul v 10 ulong sub c 48
129end
130end
131ret v
132end
133
134fn saArgUlong idx ulong to ulong
135b = new uchar 32 0
136if le ulong argcnt idx
137ret 0
138end
139lr = argread idx b 0 32
140if le lr 0
141ret 0
142end
143ret saParseUlong b ulong lr
144end
145
146fn saOutReset to void
147put saOutPos 0 0
148end
149
150fn saOutByte c uchar to void
151p = get saOutPos 0
152if lt p 131070
153put saOutBuf p c
154put saOutPos 0 add p 1
155end
156end
157
158fn saOutStr s view uchar * to void
159for i ulong len s bound 512
160saOutByte get s i
161end
162end
163
164fn saOutFld which ulong n ulong to void
165if eq which 0
166for i ulong n bound 128
167saOutByte get saTaskId i
168end
169ret
170end
171for i ulong n bound 128
172saOutByte get saFam i
173end
174end
175
176fn saOutNum v ulong to void
177b = new uchar 24 0
178p = ulong 24
179x = v
180while true bound 24
181p = sub p 1
182put b p uchar add 48 rem x 10
183x = div x 10
184if eq x 0
185break
186end
187end
188while lt p 24 bound 24
189saOutByte get b p
190p = add p 1
191end
192end
193
194fn saReadInFile plen ulong to ulong
195fd = fopen saPathA 0 plen 0 0
196if lt fd 0
197ret 0
198end
199tot = ulong 0
200while lt tot 65536 bound 256
201r = read int fd saInBuf tot sub 65536 tot
202if le r 0
203break
204end
205tot = add tot ulong r
206end
207z = fclose int fd
208ret tot
209end
210
211fn saReadTmpFile which ulong plen ulong to ulong
212fd = fopen saPathA 0 plen 0 0
213if lt fd 0
214ret 0
215end
216tot = ulong 0
217while lt tot 16384 bound 256
218r = long 0
219if eq which 0
220r = read int fd saTmpA tot sub 16384 tot
221else
222if eq which 1
223r = read int fd saTmpB tot sub 16384 tot
224else
225r = read int fd saTmpC tot sub 16384 tot
226end
227end
228if le r 0
229break
230end
231tot = add tot ulong r
232end
233z = fclose int fd
234ret tot
235end
236
237fn saWriteOutFile plen ulong to bool
238fd = fopen saPathB 0 plen 577 420
239if lt fd 0
240ret false
241end
242n = get saOutPos 0
243off = ulong 0
244while lt off n bound 256
245w = write int fd saOutBuf off sub n off
246if le w 0
247z = fclose int fd
248ret false
249end
250off = add off ulong w
251end
252z = fclose int fd
253ret true
254end
255
256fn saClassify4 to ulong
257ccnt = ulong 0
258pcnt = ulong 0
259for s ulong 4
260if ne get saComp s 0
261ccnt = add ccnt 1
262end
263if ne get saPass s 0
264pcnt = add pcnt 1
265end
266end
267if eq pcnt 4
268ret 0
269end
270if gt pcnt 0
271ret 1
272end
273if eq ccnt 0
274ret 2
275end
276if eq ccnt 4
277h0 = get saHash 0
278same = true
279for s ulong 3
280if ne get saHash add s 1 h0
281same = false
282end
283end
284if same
285ret 3
286end
287ret 4
288end
289ret 5
290end
291
292fn saWinStrand to ulong
293for s ulong 4
294if ne get saPass s 0
295ret add s 1
296end
297end
298ret 0
299end
300
301fn saFailMask to ulong
302m = ulong 0
303for s ulong 4
304if eq get saPass s 0
305m = or m shl ulong 1 s
306end
307end
308ret m
309end
310
311fn saBestErr to ulong
312for s ulong 4
313e = get saErr s
314if ne e 0
315ret e
316end
317end
318ret 0
319end
320
321fn saSplitTabTo llen ulong k ulong which ulong to ulong
322cur = ulong 0
323p = ulong 0
324for i ulong llen bound 1024
325c = get saLine i
326if eq c 9
327cur = add cur 1
328if gt cur k
329break
330end
331else
332if eq cur k
333if lt p 128
334if eq which 0
335put saTaskId p c
336else
337if eq which 1
338put saFam p c
339else
340put saTok p c
341end
342end
343p = add p 1
344end
345end
346end
347end
348ret p
349end
350
351fn saOutClass cls ulong to void
352if eq cls 0
353saOutStr saClsUnan
354saOutByte 9
355saOutStr saActGold
356ret
357end
358if eq cls 1
359saOutStr saClsGap
360saOutByte 9
361saOutStr saActGap
362ret
363end
364if eq cls 2
365saOutStr saClsSyn
366saOutByte 9
367saOutStr saActSyn
368ret
369end
370if eq cls 3
371saOutStr saClsLogic
372saOutByte 9
373saOutStr saActLogic
374ret
375end
376if eq cls 4
377saOutStr saClsUnder
378saOutByte 9
379saOutStr saActUnder
380ret
381end
382saOutStr saClsMixed
383saOutByte 9
384saOutStr saActMixed
385end
386
387fn saRunAttribute inLen ulong outLen ulong to int
388nbytes = saReadInFile inLen
389if eq nbytes 0
390ret 2
391end
392for i ulong 8
393put saStats i 0
394end
395saOutReset
396saOutStr saHdrAttr
397pos = ulong 0
398while lt pos nbytes bound 2048
399llen = ulong 0
400while lt pos nbytes bound 1024
401c = get saInBuf pos
402pos = add pos 1
403if eq c 10
404break
405end
406if and ne c 13 lt llen 1020
407put saLine llen c
408llen = add llen 1
409end
410end
411if eq llen 0
412continue
413end
414if eq get saLine 0 35
415continue
416end
417tidLen = saSplitTabTo llen 0 0
418famLen = saSplitTabTo llen 1 1
419if or eq tidLen 0 eq famLen 0
420continue
421end
422t2l = saSplitTabTo llen 2 2
423if eq t2l 0
424continue
425end
426c0 = get saTok 0
427if or lt c0 48 gt c0 57
428continue
429end
430for s ulong 4
431base = add 2 mul s 4
432tl = saSplitTabTo llen base 2
433put saComp s saParseTok tl
434tl = saSplitTabTo llen add base 1 2
435put saPass s saParseTok tl
436tl = saSplitTabTo llen add base 2 2
437put saHash s saParseTok tl
438tl = saSplitTabTo llen add base 3 2
439put saErr s saParseTok tl
440end
441cls = saClassify4
442put saStats 7 add get saStats 7 1
443put saStats cls add get saStats cls 1
444saOutFld 0 tidLen
445saOutByte 9
446saOutFld 1 famLen
447saOutByte 9
448saOutClass cls
449saOutByte 9
450saOutNum saWinStrand
451saOutByte 9
452saOutNum saFailMask
453saOutByte 9
454saOutNum saBestErr
455saOutByte 10
456end
457if not saWriteOutFile outLen
458ret 3
459end
460saWrt1 saSumA
461saNum1 get saStats 7
462saWrt1 saSumB
463saNum1 get saStats 0
464saWrt1 saSumC
465saNum1 get saStats 1
466saWrt1 saSumD
467saNum1 get saStats 2
468saWrt1 saSumE
469saNum1 get saStats 3
470saWrt1 saSumF
471saNum1 get saStats 4
472saWrt1 saSumG
473saNum1 get saStats 5
474saWrt1 saNl
475ret 0
476end
477
478fn saRunExtract to int
479if lt argcnt 7
480ret 2
481end
482l1 = argread 2 saPathA 0 256
483if le l1 0
484ret 2
485end
486nOrig = saReadTmpFile 0 ulong l1
487l2 = argread 3 saPathA 0 256
488if le l2 0
489ret 2
490end
491nPlan = saReadTmpFile 1 ulong l2
492l3 = argread 4 saPathA 0 256
493if le l3 0
494ret 2
495end
496nCode = saReadTmpFile 2 ulong l3
497if or eq nOrig 0 or eq nPlan 0 eq nCode 0
498ret 3
499end
500l4 = argread 5 saPathB 0 256
501if le l4 0
502ret 2
503end
504saOutReset
505saOutStr saNotePfx
506for i ulong nOrig bound 16384
507c = get saTmpA i
508if and ne c 10 ne c 13
509saOutByte c
510end
511end
512saOutByte 10
513for i ulong nCode bound 16384
514saOutByte get saTmpC i
515end
516if ne get saTmpC sub nCode 1 10
517saOutByte 10
518end
519saOutByte 0
520dirBytes = get saOutPos 0
521if not saWriteOutFile ulong l4
522ret 4
523end
524l5 = argread 6 saPathB 0 256
525if le l5 0
526ret 2
527end
528saOutReset
529saOutStr saPlanPfx
530for i ulong nPlan bound 16384
531c = get saTmpB i
532if and ne c 10 ne c 13
533saOutByte c
534end
535end
536saOutByte 10
537for i ulong nCode bound 16384
538saOutByte get saTmpC i
539end
540if ne get saTmpC sub nCode 1 10
541saOutByte 10
542end
543saOutByte 0
544alnBytes = get saOutPos 0
545if not saWriteOutFile ulong l5
546ret 5
547end
548saWrt1 saExtrOk
549saNum1 dirBytes
550saWrt1 saExtrOk2
551saNum1 alnBytes
552saWrt1 saNl
553ret 0
554end
555
556fn saEvalPromote traces ulong minFl ulong w1Ok ulong t60 ulong t61 ulong t62 ulong to ulong
557if lt traces minFl
558ret 10
559end
560if or eq w1Ok 0 or ne t60 60 or ne t61 61 ne t62 62
561ret 11
562end
563ret 0
564end
565
566fn saEvalWalls234 baseH ulong candH ulong maxDr ulong seenD ulong baseP ulong candP ulong to ulong
567if gt candH add baseH maxDr
568ret 12
569end
570if ne seenD 0
571ret 13
572end
573if lt candP baseP
574ret 14
575end
576ret 0
577end
578
579fn saRunPromote to int
580if lt argcnt 17
581ret 2
582end
583for i ulong 15
584put saPArg i saArgUlong add i 2
585end
586rc = saEvalPromote get saPArg 1 get saPArg 2 get saPArg 3 get saPArg 4 get saPArg 5 get saPArg 6
587if eq rc 0
588rc = saEvalWalls234 get saPArg 7 get saPArg 8 get saPArg 9 get saPArg 10 get saPArg 11 get saPArg 12
589end
590if and eq rc 0 or ne get saPArg 13 0 ne get saPArg 14 0
591rc = 14
592end
593saWrt1 saPrProm
594saNum1 get saPArg 0
595if eq rc 0
596saWrt1 saPrVerP
597ret 0
598end
599if eq rc 10
600saWrt1 saPrVerFl
601ret 10
602end
603if eq rc 11
604saWrt1 saPrVerW1
605ret 11
606end
607if eq rc 12
608saWrt1 saPrVerW2
609ret 12
610end
611if eq rc 13
612saWrt1 saPrVerW3
613ret 13
614end
615saWrt1 saPrVerW4
616ret 14
617end
618
619fn saEvalScaling c1P ulong c2P ulong baseP ulong c2H ulong baseH ulong k32FailPct ulong to ulong
620if le c2P baseP
621if or ge k32FailPct 80 gt c2H add baseH 150
622ret 1
623end
624end
625if and le c2P c1P gt c2H add baseH 150
626ret 1
627end
628ret 0
629end
630
631fn saRunDecide to int
632if lt argcnt 8
633ret 2
634end
635c1P = saArgUlong 2
636c2P = saArgUlong 3
637baseP = saArgUlong 4
638c2H = saArgUlong 5
639baseH = saArgUlong 6
640k32F = saArgUlong 7
641d = saEvalScaling c1P c2P baseP c2H baseH k32F
642if eq d 0
643saWrt1 saDecCont
644ret 0
645end
646saWrt1 saDecWide
647ret 1
648end
649
650fn saSetStrand s ulong c ulong p ulong h ulong e ulong to void
651put saComp s c
652put saPass s p
653put saHash s h
654put saErr s e
655end
656
657fn saSelfCheck to int
658for s ulong 4
659saSetStrand s 1 1 777 0
660end
661if ne saClassify4 0
662ret 20
663end
664saSetStrand 0 1 1 777 0
665saSetStrand 1 1 0 111 0
666saSetStrand 2 0 0 0 7
667saSetStrand 3 1 1 777 0
668if ne saClassify4 1
669ret 21
670end
671if ne saWinStrand 1
672ret 22
673end
674if ne saFailMask 6
675ret 23
676end
677saSetStrand 0 0 0 0 7
678saSetStrand 1 0 0 0 16
679saSetStrand 2 0 0 0 12
680saSetStrand 3 0 0 0 7
681if ne saClassify4 2
682ret 24
683end
684if ne saBestErr 7
685ret 25
686end
687for s ulong 4
688saSetStrand s 1 0 99999 0
689end
690if ne saClassify4 3
691ret 26
692end
693saSetStrand 0 1 0 1001 0
694saSetStrand 1 1 0 2002 0
695saSetStrand 2 1 0 3003 0
696saSetStrand 3 1 0 4004 0
697if ne saClassify4 4
698ret 27
699end
700saSetStrand 0 1 0 1001 0
701saSetStrand 1 0 0 0 16
702saSetStrand 2 1 0 2002 0
703saSetStrand 3 0 0 0 7
704if ne saClassify4 5
705ret 28
706end
707if ne saEvalPromote 16 64 1 60 61 62 10
708ret 29
709end
710if ne saEvalPromote 80 64 1 60 61 0 11
711ret 30
712end
713if ne saEvalPromote 80 64 1 60 61 62 0
714ret 31
715end
716if ne saEvalWalls234 3061 3206 150 0 6 8 0
717ret 32
718end
719if ne saEvalWalls234 3206 4829 150 0 6 6 12
720ret 33
721end
722if ne saEvalWalls234 3061 3128 150 1 6 9 13
723ret 34
724end
725if ne saEvalWalls234 3061 3128 150 0 6 5 14
726ret 35
727end
728if ne saEvalScaling 9 14 6 3140 3128 35 0
729ret 36
730end
731if ne saEvalScaling 6 6 6 3310 3128 85 1
732ret 37
733end
734saWrt1 saSelfOk
735ret 0
736end
737
738fn main to int
739a1 = new uchar 64 0
740if lt argcnt 2
741saWrt2 saUsage
742ret 2
743end
744l1r = argread 1 a1 0 64
745if le l1r 0
746ret 2
747end
748l1 = ulong l1r
749if saEqBuf a1 l1 saModeSelf
750ret saSelfCheck
751end
752if saEqBuf a1 l1 saModeAttr
753if lt argcnt 4
754saWrt2 saUsage
755ret 2
756end
757l2r = argread 2 saPathA 0 256
758l3r = argread 3 saPathB 0 256
759if or le l2r 0 le l3r 0
760ret 2
761end
762ret saRunAttribute ulong l2r ulong l3r
763end
764if saEqBuf a1 l1 saModeExtr
765ret saRunExtract
766end
767if saEqBuf a1 l1 saModeProm
768ret saRunPromote
769end
770if saEqBuf a1 l1 saModeDec
771ret saRunDecide
772end
773saWrt2 saUsage
774ret 2
775end