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 / bench / inference_cost / verify-test.om

639 lines · 11524 bytes Raw Blame History
1om2
2note SPDX-License-Identifier: Apache-2.0
3note Standalone shared-referee interface gate. Compile with om2 header.
4note verify RUN BENCH OMC CHAT OUT release|test
5note Fixed path arrays implement Linux PATH_MAX, not a dataset size limit. Data streams.
6text vxnull "/dev/null"
7text vxerr "verified-examples: refused\n"
8text vxnl "\n"
9text vxshell "/usr/bin/sh"
10text vxpathkey "PATH="
11global vxp uchar 131072
12global vxplen ulong 32
13global vxpacket uchar 65536
14global vxpn ulong 2
15global vxstatus uchar 4
16global vxcounts ulong 12
17global vxshift ulong 1
18global vxenv uchar 4096
19global vxenvn ulong 1
20note Paths: 0 run,1 bench,2 omc,3 chat,4 output,5 driver,6 input,7 stdout,8 stderr,
21note 9 attempt,10 candidate,11 extracted,12 response,13 evaluation work,14 JSONL,15 manifest.
22
23
24text vtt0 "/command.out"
25text vtt1 "/command.err"
26text vtt2 "/usr/bin/cp"
27text vtt3 "/case-"
28text vtt4 "--verify-candidate"
29text vtt5 "VERIFY-TEST unexpected status\n"
30text vtt6 "/bench/inference_cost/tasks/task01/"
31text vtt7 "."
32text vtt8 "om"
33text vtt9 "reference"
34text vtt10 "task01"
35text vtt11 "c"
36text vtt12 "py"
37text vtt13 "rs"
38text vtt14 "mutant"
39text vtt15 "js"
40text vtt16 "task99"
41text vtt17 "../tasks/task01"
42text vtt18 "/candidate-link"
43text vtt19 "/usr/bin/ln"
44text vtt20 "-s"
45text vtt21 "relative-candidate.om"
46text vtt22 "/mutant/bench/inference_cost/driver.sh"
47text vtt23 " [ \"$VERIFIED\" -eq 1 ]"
48text vtt24 " case $vc_task in task[0-9][0-9]) ;; *) die \"invalid task identity\" ;; esac"
49text vtt25 " check_sandbox"
50text vtt26 " :\n"
51text vtt27 "/usr/bin/"
52text vtt28 "/no-bwrap/"
53text vtt29 "/no-bwrap"
54text vtt30 "dirname"
55text vtt31 "sha256sum"
56text vtt32 "awk"
57text vtt33 "timeout"
58text vtt34 "rm"
59text vtt35 "mkdir"
60text vtt36 "sed"
61text vtt37 "cat"
62text vtt38 "find"
63text vtt39 "rmdir"
64text vtt40 "PATH="
65text vtt41 "NOT_RUN: bwrap is not installed"
66text vtt42 "/mutant/bench"
67text vtt43 "/usr/bin/mkdir"
68text vtt44 "-p"
69text vtt45 "/bench/inference_cost"
70text vtt46 "/inference_cost"
71text vtt47 "-a"
72text vtt48 "/mutant/seed/out"
73text vtt49 "/seed/out/omc"
74text vtt50 "/omc"
75text vtt51 "/seed/out/omc.sha256"
76text vtt52 "/omc.sha256"
77text vtt53 "KILLED wrong-candidate guard mutant\n"
78text vtt54 "KILLED task-traversal guard mutant\n"
79text vtt55 "KILLED sandbox-check mutant\n"
80text vtt56 "/bench/inference_cost/driver.sh"
81text vtt57 "/no-bwrap-base"
82text vtt58 "VERIFY-TEST PASS mutants=3\n"
83fn vxfail n int to void
84r = write 2 vxerr 0 len vxerr
85exit n
86end
87fn vxset k ulong a view uchar * to void
88if ge len a 4096
89vxfail 2
90end
91for i ulong len a
92put vxp add mul k 4096 i get a i
93end
94put vxplen k len a
95end
96fn vxcopy k ulong j ulong to void
97ko = mul k 4096
98jo = mul j 4096
99for i ulong get vxplen j
100v = get vxp add jo i
101put vxp add ko i v
102end
103put vxplen k get vxplen j
104end
105fn vxadd k ulong a view uchar * to void
106n = get vxplen k
107if ge add n len a 4096
108vxfail 2
109end
110for i ulong len a
111put vxp add add mul k 4096 n i get a i
112end
113put vxplen k add n len a
114end
115fn vxdecimal k ulong n ulong to void
116b = new uchar 20 0
117p = ulong 20
118v = n
119while true bound 20
120p = sub p 1
121put b p uchar add rem v 10 48
122v = div v 10
123if eq v 0
124break
125end
126end
127vxadd k part b p sub 20 p
128end
129fn vxarg i ulong k ulong to void
130r = argread add i get vxshift 0 vxp mul k 4096 4095
131if lt r 1
132vxfail 2
133end
134put vxplen k ulong r
135end
136fn vxopen k ulong flags int to int
137r = fopen vxp mul k 4096 get vxplen k flags 384
138if lt r 0
139vxfail 3
140end
141ret int r
142end
143fn vxclose fd int to void
144r = fclose fd
145if ne r 0
146vxfail 3
147end
148end
149fn vxwrite fd int a view uchar * to void
150p = ulong 0
151while lt p len a bound 9223372036854775807
152r = write fd a p sub len a p
153if le r 0
154vxfail 3
155end
156p = add p ulong r
157end
158end
159fn vxpkinit to void
160put vxpn 0 2
161put vxpn 1 0
162end
163fn vxpk a view uchar * to void
164n = get vxpn 0
165if gt add add n 2 len a 65536
166vxfail 2
167end
168put vxpacket n uchar and len a 255
169put vxpacket add n 1 uchar shr len a 8
170for i ulong len a
171put vxpacket add add n 2 i get a i
172end
173put vxpn 0 add add n 2 len a
174put vxpn 1 add get vxpn 1 1
175end
176fn vxpkpath k ulong to void
177b = new uchar 4096 0
178n = get vxplen k
179for i ulong n
180put b i get vxp add mul k 4096 i
181end
182vxpk part b 0 n
183end
184fn vxspawn to ulong
185put vxpacket 0 uchar and get vxpn 1 255
186put vxpacket 1 uchar shr get vxpn 1 8
187pid = fork
188if lt pid 0
189vxfail 3
190end
191if eq pid 0
192f0 = vxopen 6 0
193f1 = vxopen 7 577
194f2 = vxopen 8 577
195r0 = dupfd f0 0 0
196r1 = dupfd f1 1 0
197r2 = dupfd f2 2 0
198if or or ne r0 0 ne r1 1 ne r2 2
199exit 126
200end
201r = execenv vxpacket 0 get vxpn 0 vxenv 0 get vxenvn 0
202exit 126
203end
204w = waitpid int pid vxstatus 0 4 0
205if ne w pid
206vxfail 3
207end
208if ne and get vxstatus 0 127 0
209ret add ulong 256 ulong get vxstatus 0
210end
211ret ulong get vxstatus 1
212end
213fn vxequal a view uchar * b view uchar * to bool
214if ne len a len b
215ret false
216end
217for i ulong len a
218if ne get a i get b i
219ret false
220end
221end
222ret true
223end
224note line reader: overlong lines are protocol-invalid; payloads are byte-counted and stream separately.
225fn vxline fd int b edit uchar * to ulong
226one = new uchar 1 0
227n = ulong 0
228while true bound 9223372036854775807
229r = read fd one 0 1
230if lt r 0
231vxfail 3
232end
233if eq r 0
234if eq n 0
235ret 0
236end
237vxfail 2
238end
239if eq get one 0 10
240ret n
241end
242if eq n len b
243vxfail 2
244end
245put b n get one 0
246n = add n 1
247end
248ret 0
249end
250fn vxenvinit to void
251b = new uchar 4096 0
252for i ulong ulong envcnt
253n = envread i b 0 len b
254if ge n 5
255if vxequal part b 0 5 vxpathkey
256if gt n 4090
257vxfail 2
258end
259put vxenv 0 1
260put vxenv 1 0
261put vxenv 2 uchar and ulong n 255
262put vxenv 3 uchar shr ulong n 8
263for j ulong ulong n
264put vxenv add j 4 get b j
265end
266put vxenvn 0 add ulong n 4
267ret
268end
269end
270end
271vxfail 2
272end
273
274note Args: ROOT ABS_WORK. Every new check has a removal mutant.
275text vtpinbad "OMC=/dev/null"
276text vtinvalid "not a program\n"
277text vtbadfile "/refused.om"
278fn vtbadpin to void
279n = get vxenvn 0
280put vxenv 0 2
281put vxenv n uchar len vtpinbad
282put vxenv add n 1 0
283for i ulong len vtpinbad
284put vxenv add add n 2 i get vtpinbad i
285end
286put vxenvn 0 add add n 2 len vtpinbad
287r = vtrun vtt8 vtt10
288vtwant r 3
289vxenvinit
290vtpath 23 vtbadfile
291vtput 23 vtinvalid
292r = vtrun vtt8 vtt10
293vtwant r 1
294end
295fn vtstdout a view uchar * to void
296vxwrite 1 a
297end
298fn vtsetup to void
299vxset 6 vxnull
300vxcopy 7 21
301vxadd 7 vtt0
302vxcopy 8 21
303vxadd 8 vtt1
304end
305fn vtcommand2 cmd view uchar * a ulong b ulong to ulong
306vtsetup
307vxpkinit
308vxpk cmd
309vxpkpath a
310vxpkpath b
311ret vxspawn
312end
313fn vtcopy src ulong dst ulong to void
314r = vtcommand2 vtt2 src dst
315if ne r 0
316vxfail 60
317end
318end
319fn vtput k ulong a view uchar * to void
320fd = vxopen k 577
321vxwrite fd a
322vxclose fd
323end
324fn vtpath k ulong suffix view uchar * to void
325vxcopy k 21
326vxadd k suffix
327end
328fn vtrun lang view uchar * task view uchar * to ulong
329vtsetup
330vtpath 24 vtt3
331vxdecimal 24 get vxcounts 9
332put vxcounts 9 add get vxcounts 9 1
333vxpkinit
334vxpk vxshell
335vxpkpath 22
336vxpk vtt4
337vxpk lang
338vxpk task
339vxpkpath 23
340vxpkpath 24
341ret vxspawn
342end
343fn vtwant actual ulong expected ulong to void
344if ne actual expected
345vtstdout vtt5
346vxfail 61
347end
348put vxcounts 4 add get vxcounts 4 1
349end
350fn vtcontains k ulong needle view uchar * to bool
351b = new uchar 4096 0
352fd = vxopen k 0
353found = false
354while true bound 9223372036854775807
355n = vxline fd b
356if eq n 0
357break
358end
359if ge n len needle
360for i ulong add sub n len needle 1
361if vxequal part b i len needle needle
362found = true
363end
364end
365end
366end
367vxclose fd
368ret found
369end
370fn vtcandidate lang view uchar * kind view uchar * to void
371vxcopy 23 20
372vxadd 23 vtt6
373vxadd 23 kind
374vxadd 23 vtt7
375vxadd 23 lang
376end
377fn vtbase to void
378vtcandidate vtt8 vtt9
379r = vtrun vtt8 vtt10
380vtwant r 0
381vtcandidate vtt11 vtt9
382r = vtrun vtt11 vtt10
383vtwant r 0
384vtcandidate vtt12 vtt9
385r = vtrun vtt12 vtt10
386vtwant r 0
387vtcandidate vtt13 vtt9
388r = vtrun vtt13 vtt10
389vtwant r 0
390vtcandidate vtt8 vtt14
391r = vtrun vtt8 vtt10
392vtwant r 1
393vtcandidate vtt11 vtt14
394r = vtrun vtt11 vtt10
395vtwant r 1
396vtcandidate vtt12 vtt14
397r = vtrun vtt12 vtt10
398vtwant r 1
399vtcandidate vtt13 vtt14
400r = vtrun vtt13 vtt10
401vtwant r 1
402vtcandidate vtt8 vtt9
403r = vtrun vtt15 vtt10
404vtwant r 2
405r = vtrun vtt8 vtt16
406vtwant r 2
407r = vtrun vtt8 vtt17
408vtwant r 2
409vxcopy 25 23
410vtpath 23 vtt18
411vtsetup
412vxpkinit
413vxpk vtt19
414vxpk vtt20
415vxpkpath 25
416vxpkpath 23
417r = vxspawn
418vtwant r 0
419r = vtrun vtt8 vtt10
420vtwant r 2
421vxcopy 23 25
422r = vtrun vtt8 vtt10
423vtwant r 0
424note Reusing the same claimed directory is a refusal (invoke packet a second time).
425r = vxspawn
426vtwant r 2
427vxset 23 vtt21
428r = vtrun vtt8 vtt10
429vtwant r 2
430vtcandidate vtt8 vtt9
431end
432fn vteof fd int to bool
433st = new uchar 128 0
434r = fseek fd 0 1
435if lt r 0
436vxfail 62
437end
438f = fstat fd st 0 128
439if ne f 0
440vxfail 62
441end
442size = ulong 0
443for j ulong 8
444v = ulong get st add j 48
445shift = mul j 8
446size = or size shl v shift
447end
448ret eq ulong r size
449end
450fn vtmutate which ulong to void
451b = new uchar 4096 0
452vtpath 29 vtt22
453fi = vxopen 22 0
454fo = vxopen 29 577
455hits = ulong 0
456while true bound 9223372036854775807
457n = vxline fi b
458if eq n 0
459note Keep blank lines; EOF is distinguished using current offset and fstat below by a byte probe.
460if vteof fi
461break
462end
463end
464match = false
465if eq which 1
466match = vxequal part b 0 n vtt23
467end
468if eq which 2
469match = vxequal part b 0 n vtt24
470end
471if eq which 3
472match = vxequal part b 0 n vtt25
473end
474if match
475vxwrite fo vtt26
476hits = add hits 1
477else
478vxwrite fo part b 0 n
479vxwrite fo vxnl
480end
481end
482vxclose fi
483vxclose fo
484if eq hits 0
485vxfail 62
486end
487end
488fn vtlink name view uchar * to void
489vxset 28 vtt27
490vxadd 28 name
491vtpath 29 vtt28
492vxadd 29 name
493vtsetup
494vxpkinit
495vxpk vtt19
496vxpk vtt20
497vxpkpath 28
498vxpkpath 29
499r = vxspawn
500vtwant r 0
501end
502fn vtnosandbox to bool
503b = new uchar 4096 0
504vtpath 28 vtt29
505mr = makedir vxp mul ulong 28 4096 get vxplen 28 448
506if ne mr 0
507vxfail 63
508end
509vtlink vtt30
510vtlink vtt31
511vtlink vtt32
512vtlink vtt33
513vtlink vtt34
514vtlink vtt35
515vtlink vtt36
516vtlink vtt37
517vtlink vtt38
518vtlink vtt39
519vxset 28 vtt40
520vxcopy 29 21
521vxadd 29 vtt29
522for i ulong get vxplen 29
523put b i get vxp add mul ulong 29 4096 i
524end
525vxadd 28 part b 0 get vxplen 29
526put vxenv 0 1
527put vxenv 1 0
528n = get vxplen 28
529put vxenv 2 uchar and n 255
530put vxenv 3 uchar shr n 8
531for i ulong n
532put vxenv add i 4 get vxp add mul ulong 28 4096 i
533end
534put vxenvn 0 add n 4
535r = vtrun vtt8 vtt10
536if ne r 3
537ret false
538end
539ret vtcontains 7 vtt41
540end
541fn vtmutants to void
542note Copy just the existing referee's dependency closure, not the repository or any private data.
543vtpath 27 vtt42
544vtsetup
545vxpkinit
546vxpk vtt43
547vxpk vtt44
548vxpkpath 27
549r = vxspawn
550vtwant r 0
551vxcopy 28 20
552vxadd 28 vtt45
553vxcopy 29 27
554vxadd 29 vtt46
555vtsetup
556vxpkinit
557vxpk vtt2
558vxpk vtt47
559vxpkpath 28
560vxpkpath 29
561r = vxspawn
562vtwant r 0
563vtpath 27 vtt48
564vtsetup
565vxpkinit
566vxpk vtt43
567vxpk vtt44
568vxpkpath 27
569r = vxspawn
570vtwant r 0
571vxcopy 28 20
572vxadd 28 vtt49
573vxcopy 29 27
574vxadd 29 vtt50
575vtcopy 28 29
576vxcopy 28 20
577vxadd 28 vtt51
578vxcopy 29 27
579vxadd 29 vtt52
580vtcopy 28 29
581vtmutate 1
582vxcopy 30 22
583vxcopy 22 29
584vtcandidate vtt8 vtt14
585r = vtrun vtt8 vtt10
586if eq r 1
587vxfail 64
588end
589vtstdout vtt53
590vxcopy 22 30
591vtmutate 2
592vxcopy 22 29
593vtcandidate vtt8 vtt9
594r = vtrun vtt8 vtt17
595if eq r 2
596vxfail 64
597end
598vtstdout vtt54
599vxcopy 22 30
600vtmutate 3
601vxcopy 22 29
602ok = vtnosandbox
603if ok
604vxfail 64
605end
606vtstdout vtt55
607vxenvinit
608vxcopy 22 30
609end
610fn main to int
611if ne argcnt 3
612vxfail 2
613end
614vxarg 1 20
615vxarg 2 21
616vxenvinit
617r = makedir vxp mul ulong 21 4096 get vxplen 21 448
618if ne r 0
619vxfail 3
620end
621vxcopy 22 20
622vxadd 22 vtt56
623vtbase
624vtbadpin
625vtcandidate vtt8 vtt9
626vtmutants
627vtpath 28 vtt57
628r = makedir vxp mul ulong 28 4096 get vxplen 28 448
629note The second no-bwrap check uses an isolated work root so its fixture cannot be reused.
630vxcopy 31 21
631vxcopy 21 28
632ok = vtnosandbox
633if not ok
634vxfail 65
635end
636vxcopy 21 31
637vtstdout vtt58
638ret 0
639end