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 / bridge / babel / src / 70-complete.om

715 lines · 11746 bytes Raw Blame History
1note babel 70-complete: the completion record (policy complete-v1). Its denominator is every walked file,
2note every split item, every entry the walk skipped and every required check (three differential legs per
3note unit that reached the differential, the generated target test where the target has one, and each
4note toolchain the target needs). --complete turns its state into the exit status.
5note State codes in Csv: 1 COMPLETE, 2 PARTIAL, 3 BLOCKED, 4 FAILED (the highest open severity wins).
6global Cpl ulong 1
7global Cmd ulong 1
8global Cden ulong 1
9global Ccov ulong 1
10global Csv ulong 1
11global Cno ulong 1
12global Ccap ulong 1
13note staged strings of one open item: 0 kind, 1 item, 2 name, 3 verdict, 4 reason (pool offset, length)
14global Xo ulong 5
15global Xn ulong 5
16global Cexc ulong 1
17global Xe ulong 1
18text CvExc "EXCLUDED"
19text CpPol "complete-v1"
20text CpS1 "COMPLETE"
21text CpS2 "PARTIAL"
22text CpS3 "BLOCKED"
23text CpS4 "FAILED"
24text CkFile "file"
25text CkSkip "skipped"
26text CkUnit "unit"
27text CkCheck "check"
28text CkTool "toolchain"
29text CvSkip "SKIPPED"
30text CiDot "."
31text CiTst "diff/test.log"
32text CiCap "babel capacity"
33text CrOth "not a source language babel recognises (.c .h .rs .py .go .zig .cpp .cc .cxx .hpp): copied to input/ only, nothing translated"
34text CrEmp "no files were walked: there is nothing to translate"
35text CrSk1 "hidden (dot) entry: not walked, not copied, not translated"
36text CrSk2 "symbolic link: not followed, not copied, not translated"
37text CrSk3 "not a regular file or directory: not copied, not translated"
38text CrSk4 "*.babel output folder: not walked"
39text CrSk5 "directory could not be read: its entries were not walked"
40text CrSk6 "could not be inspected (lstat failed): not walked"
41text CrL0 "differential leg: original C (cc oracle)"
42text CrL1 "differential leg: Omega unit (pinned omc)"
43text CrL2 "differential leg: target "
44text CrLf " failed"
45text CrLn " did not run"
46text CrSep ": "
47text CrTf "generated target test failed (see diff/test.log), exit "
48text CrTn "generated target test did not run (its toolchain is missing)"
49text CrTl " was not found (on PATH, or at the ZIG or GO path given): every check that needs it is NOT_RUN"
50text CrCap "an internal capacity was exceeded (2048 files or skipped entries, 1024 units, 8 MiB pool): items may be missing from this record"
51
52note ---------- the walk over every item ----------
53note mode md: 0 count (Cden, Ccov, Cexc, Csv), 1 report.json open list, 2 REPORT.md open rows,
54note 3 report.json excluded list, 4 REPORT.md excluded rows
55fn cwalk md ulong to void
56put Cmd 0 md
57put Cno 0 0
58if eq md 0
59put Cden 0 0
60put Ccov 0 0
61put Cexc 0 0
62put Csv 0 1
63put Ccap 0 get Cap 0
64end
65if eq get Nf 0 0
66cempty
67end
68for f ulong get Nf 0
69cfile f
70end
71for i ulong get Nsk 0
72cskip i
73end
74for u ulong get Nu 0
75cunit u
76end
77for u ulong get Nu 0
78for k ulong 3
79cleg u k
80end
81end
82ctest
83ctool 0
84s = tslot
85if ne s 0
86ctool s
87end
88if eq get Ccap 0 1
89ccap
90end
91end
92
93note one item with severity sv (0 covered, 1 EXCLUDED, 2 PARTIAL, 3 BLOCKED, 4 FAILED); true when it is to be printed
94fn cbump sv ulong to bool
95md = get Cmd 0
96if eq md 0
97put Cden 0 add get Cden 0 1
98if eq sv 0
99put Ccov 0 add get Ccov 0 1
100end
101if eq sv 1
102put Cexc 0 add get Cexc 0 1
103end
104if gt sv get Csv 0
105put Csv 0 sv
106end
107ret false
108end
109if gt md 2
110ret eq sv 1
111end
112ret gt sv 1
113end
114
115note an EXCLUDED item: kind, item Pl[o, o+n) ("." when empty), manifest entry e1 - 1
116fn cexcl kd view uchar * o ulong n ulong e1 ulong to void
117m = mark
118bs kd
119xput 0 m
120if eq n 0
121bs CiDot
122else
123bpl o n
124end
125xput 1 m
126put Xe 0 sub e1 1
127cemit
128end
129
130note Ob[m, mark) into staged string k (empty: null in JSON, "-" in Markdown)
131fn xput k ulong m ulong to void
132put Xn k sub mark m
133put Xo k psave m sub mark m
134reset m
135end
136
137fn cempty to void
138if not cbump 2
139ret
140end
141m = mark
142bs CkFile
143xput 0 m
144bs CiDot
145xput 1 m
146xput 2 m
147bs VMi
148xput 3 m
149bs CrEmp
150xput 4 m
151cemit
152end
153
154note a walked file is covered when its language is one babel recognises (its content is counted by its
155note units) or when it is the --exclude manifest; EXCLUDED when a manifest entry matched it
156fn cfile f ulong to void
157sv = ulong 0
158if eq get Flg f 0
159sv = ulong 2
160if eq get Mfi 0 add f 1
161sv = ulong 0
162end
163if ne get Fex f 0
164sv = ulong 1
165end
166end
167if not cbump sv
168ret
169end
170if eq sv 1
171cexcl CkFile get F0 f get Fl f get Fex f
172ret
173end
174m = mark
175bs CkFile
176xput 0 m
177bpl get F0 f get Fl f
178xput 1 m
179xput 2 m
180bs VMi
181xput 3 m
182bs CrOth
183xput 4 m
184cemit
185end
186
187fn cskip i ulong to void
188sv = ulong 2
189if eq get Msk 0 add i 1
190sv = ulong 0
191end
192if ne get Skx i 0
193sv = ulong 1
194end
195if not cbump sv
196ret
197end
198if eq sv 1
199cexcl CkSkip get Sk0 i get Skl i get Skx i
200ret
201end
202m = mark
203bs CkSkip
204xput 0 m
205if eq get Skl i 0
206bs CiDot
207else
208bpl get Sk0 i get Skl i
209end
210xput 1 m
211xput 2 m
212bs CvSkip
213xput 3 m
214bskip get Skr i
215xput 4 m
216cemit
217end
218
219fn bskip r ulong to void
220if eq r 1
221bs CrSk1
222ret
223end
224if eq r 2
225bs CrSk2
226ret
227end
228if eq r 3
229bs CrSk3
230ret
231end
232if eq r 4
233bs CrSk4
234ret
235end
236if eq r 5
237bs CrSk5
238ret
239end
240bs CrSk6
241end
242
243note a split item is covered when TRANSLATED or ABSORBED
244fn cunit u ulong to void
245s = get Ust u
246sv = ulong 3
247if eq s 1
248sv = ulong 0
249end
250if eq s 6
251sv = ulong 0
252end
253if eq s 2
254sv = ulong 2
255end
256if eq s 3
257sv = ulong 2
258end
259if eq s 4
260sv = ulong 4
261end
262if not cbump sv
263ret
264end
265m = mark
266bs CkUnit
267xput 0 m
268bloc u
269xput 1 m
270bname u
271xput 2 m
272bverdict u
273xput 3 m
274bpl get Ur0 u get Urn u
275xput 4 m
276cemit
277end
278
279note differential leg k of unit u, required once the unit reached the differential
280fn cleg u ulong k ulong to void
281v = get Ulg add mul u 3 k
282if eq v 0
283ret
284end
285sv = ulong 0
286if eq v 2
287sv = ulong 4
288end
289if eq v 3
290sv = ulong 3
291end
292if not cbump sv
293ret
294end
295m = mark
296bs CkCheck
297xput 0 m
298bloc u
299xput 1 m
300bname u
301xput 2 m
302if eq v 2
303bs VFa
304else
305bs VNr
306end
307xput 3 m
308if eq k 0
309bs CrL0
310end
311if eq k 1
312bs CrL1
313end
314if eq k 2
315bs CrL2
316blang get Lg 0
317end
318if eq v 2
319bs CrLf
320else
321bs CrLn
322end
323if gt get Urn u 0
324bs CrSep
325bpl get Ur0 u get Urn u
326end
327xput 4 m
328cemit
329end
330
331note the generated target test: required for rust and python once any oracle output exists
332fn ctest to void
333g = get Lg 0
334if lt g 2
335ret
336end
337if gt g 3
338ret
339end
340if not anycase
341ret
342end
343t = get Tsr 0
344sv = ulong 0
345if ne t 0
346sv = ulong 4
347if eq t 999
348sv = ulong 3
349end
350end
351if not cbump sv
352ret
353end
354m = mark
355bs CkCheck
356xput 0 m
357bs CiTst
358xput 1 m
359xput 2 m
360if eq sv 4
361bs VFa
362xput 3 m
363bs CrTf
364bu t
365else
366bs VNr
367xput 3 m
368bs CrTn
369end
370xput 4 m
371cemit
372end
373
374note toolchain slot s: required (cc for the oracle, plus the target's own tool)
375fn ctool s ulong to void
376sv = ulong 0
377if eq get Tok s 0
378sv = ulong 3
379end
380if not cbump sv
381ret
382end
383m = mark
384bs CkTool
385xput 0 m
386btool s
387xput 1 m
388xput 2 m
389bs VNr
390xput 3 m
391btool s
392bs CrTl
393xput 4 m
394cemit
395end
396
397fn btool s ulong to void
398if eq s 0
399bs TlNm0
400ret
401end
402if eq s 1
403bs TlNm1
404ret
405end
406if eq s 2
407bs TlNm2
408ret
409end
410if eq s 3
411bs TlNm3
412ret
413end
414if eq s 4
415bs TlNm4
416ret
417end
418bs TlNm5
419end
420
421fn ccap to void
422if not cbump 3
423ret
424end
425m = mark
426bs CkCheck
427xput 0 m
428bs CiCap
429xput 1 m
430xput 2 m
431bs VNr
432xput 3 m
433bs CrCap
434xput 4 m
435cemit
436end
437
438note ---------- output of one open item ----------
439text CjA "\n {\"kind\": \""
440text CjB "\", \"item\": "
441text CjC ", \"name\": "
442text CjD ", \"verdict\": \""
443text CjE "\", \"reason\": "
444text CjF "}"
445
446fn cemit to void
447md = get Cmd 0
448if eq md 1
449cemitj
450ret
451end
452if eq md 3
453cemitx
454ret
455end
456if eq md 4
457cemitxm
458ret
459end
460cemitm
461end
462
463text CxV ", \"verdict\": \"EXCLUDED\", \"reason\": "
464text CxM ", \"matched_by\": "
465text CxL ", \"line\": "
466
467note report.json excluded item: kind, item, verdict, the manifest's reason, entry and line
468fn cemitx to void
469if gt get Cno 0 0
470bc 44
471end
472put Cno 0 add get Cno 0 1
473e = get Xe 0
474bs CjA
475bpl get Xo 0 get Xn 0
476bs CjB
477bjq get Xo 1 get Xn 1
478bs CxV
479bjq get Mr0 e get Mrn e
480bs CxM
481bjq get Me0 e get Men e
482bs CxL
483bu get Mln e
484bs CjF
485end
486
487text CxLn " (line "
488
489note REPORT.md excluded row: | kind | item | EXCLUDED | entry (line N) | reason |
490fn cemitxm to void
491e = get Xe 0
492bs MTl
493bpl get Xo 0 get Xn 0
494bs MTm
495bc 96
496bmd get Xo 1 get Xn 1
497bc 96
498bs MTm
499bs CvExc
500bs MTm
501bc 96
502bmd get Me0 e get Men e
503bc 96
504bs CxLn
505bu get Mln e
506bc 41
507bs MTm
508bmd get Mr0 e get Mrn e
509bs MTn
510end
511
512fn cemitj to void
513if gt get Cno 0 0
514bc 44
515end
516put Cno 0 add get Cno 0 1
517bs CjA
518bpl get Xo 0 get Xn 0
519bs CjB
520bjq get Xo 1 get Xn 1
521bs CjC
522bqnull get Xo 2 get Xn 2
523bs CjD
524bpl get Xo 3 get Xn 3
525bs CjE
526bqnull get Xo 4 get Xn 4
527bs CjF
528end
529
530fn cemitm to void
531bs MTl
532bpl get Xo 0 get Xn 0
533bs MTm
534bc 96
535bmd get Xo 1 get Xn 1
536bc 96
537bs MTm
538if eq get Xn 2 0
539bc 45
540else
541bmd get Xo 2 get Xn 2
542end
543bs MTm
544bpl get Xo 3 get Xn 3
545bs MTm
546bmd get Xo 4 get Xn 4
547bs MTn
548end
549
550note ---------- state, exit status and the three renderings ----------
551fn bstate to void
552s = get Csv 0
553if eq s 1
554bs CpS1
555ret
556end
557if eq s 2
558bs CpS2
559ret
560end
561if eq s 3
562bs CpS3
563ret
564end
565bs CpS4
566end
567
568note --complete: 0 COMPLETE, 1 FAILED, 3 PARTIAL, 4 BLOCKED
569fn cexit to ulong
570s = get Csv 0
571if eq s 1
572ret 0
573end
574if eq s 2
575ret 3
576end
577if eq s 3
578ret 4
579end
580ret 1
581end
582
583text CjH "{\"policy\": \""
584text CjI "\", \"enforced\": "
585text CjT "true"
586text CjFl "false"
587text CjJ ", \"state\": \""
588text CjK "\", \"denominator\": "
589text CjL ", \"covered\": "
590text CjM ", \"open\": ["
591text CjN "\n ]"
592text CjO "]"
593text CjP ", \"excluded_count\": "
594text CjQ ", \"excluded\": ["
595text CjR ", \"manifest\": "
596
597fn cjson to void
598bs CjH
599bs CpPol
600bs CjI
601if eq get Cpl 0 1
602bs CjT
603else
604bs CjFl
605end
606bs CjJ
607bstate
608bs CjK
609bu get Cden 0
610bs CjL
611bu get Ccov 0
612bs CjM
613cwalk 1
614if gt get Cno 0 0
615bs CjN
616else
617bs CjO
618end
619bs CjP
620bu get Cexc 0
621bs CjQ
622cwalk 3
623if gt get Cno 0 0
624bs CjN
625else
626bs CjO
627end
628bs CjR
629exjson
630bc 125
631end
632
633text CmA "\n## Completion\n\nPolicy `complete-v1`"
634text CmB " (enforced: --complete was given, so the exit status follows this state)"
635text CmC " (not enforced: with --complete the exit status follows this state)"
636text CmD ". State: **"
637text CmE "**, "
638text CmF " of "
639text CmG " items covered"
640text CmE2 ", "
641text CmGx " excluded by manifest `"
642text CmGs "` (sha256 "
643text CmGe ")"
644text CmG2 ".\n\nThe denominator counts every walked file, every split item, every entry the walk skipped (hidden entries, symbolic links, other non-regular files, `*.babel` folders, unreadable directories) and every required check: the three differential legs of each unit that reached the differential, the generated target test where the target has one (rust, python), and each toolchain the target needs. An entry matched by the --exclude manifest stays in the denominator as EXCLUDED with the manifest's reason; source files and their split items cannot be excluded. COMPLETE: every item TRANSLATED, ABSORBED or EXCLUDED, nothing else skipped, every check ran and passed. FAILED: any FAIL. BLOCKED: no FAIL, but a required check did not run or a toolchain is missing. PARTIAL: no FAIL and no NOT_RUN, but UNSUPPORTED, MISSING_IMPLEMENTATION or skipped items remain.\n"
645text CmX "\nExcluded by the manifest:\n\n| kind | item | verdict | manifest entry | reason |\n|---|---|---|---|---|\n"
646text CmH "\n| kind | item | name | verdict | reason |\n|---|---|---|---|---|\n"
647text CmI "\nNo open items.\n"
648
649fn cmdsec to void
650bs CmA
651if eq get Cpl 0 1
652bs CmB
653else
654bs CmC
655end
656bs CmD
657bstate
658bs CmE
659bu get Ccov 0
660bs CmF
661bu get Cden 0
662bs CmG
663if gt get Exn 0 0
664bs CmE2
665bu get Cexc 0
666bs CmGx
667bmd get Ex0 0 get Exn 0
668bs CmGs
669exhex 32
670bs CmGe
671end
672bs CmG2
673if eq add get Ccov 0 get Cexc 0 get Cden 0
674bs CmI
675else
676bs CmH
677cwalk 2
678end
679if gt get Cexc 0 0
680bs CmX
681cwalk 4
682end
683end
684
685text CsA " completion "
686text CsB " items covered (policy complete-v1"
687text CsC ", enforced by --complete)\n"
688text CsD "; --complete makes it the exit status)\n"
689text CsE " items covered, "
690text CsF " excluded by manifest "
691text CsG " (policy complete-v1"
692
693fn csline to void
694bs CsA
695bstate
696bc 32
697bc 32
698bu get Ccov 0
699bs CmF
700bu get Cden 0
701if gt get Exn 0 0
702bs CsE
703bu get Cexc 0
704bs CsF
705exhex 4
706bs CsG
707else
708bs CsB
709end
710if eq get Cpl 0 1
711bs CsC
712else
713bs CsD
714end
715end