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