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
omega-mv / si / aien-harness / harness.om
| 1 | om2 |
| 2 | note si/aien-harness/harness.om: Change-management schema validator, workflow engine, and eval reliability gate. |
| 3 | note Faithful pure-Omega conversion of aien-harness (src/lib.rs, schemas/*.json, evals.json, workflows.json) |
| 4 | note plus strict 6-word verdict vocabulary, multi-run flakiness detection, and fail-closed gate decisions. |
| 5 | note Input protocol on stdin (one record per line; # comments and blank lines ignored): |
| 6 | note schema <engineering_fix|harness_change|research_handoff|python_result> |
| 7 | note field <key> <value> |
| 8 | note text <body text checked by slop_gate> |
| 9 | note workflow <workflow_type> <from_state> <to_state> |
| 10 | note eval <eval_name> <PASS|FAIL|NOT_RUN|BLOCKED_HARDWARE|BLOCKED_OPERATOR|MISSING_IMPLEMENTATION> |
| 11 | note Exit codes: 0 = GATE PASS, 1 = GATE FAIL (fail-closed refusal), 2 = I/O error or unknown/missing schema. |
| 12 | |
| 13 | global inbuf uchar 32768 |
| 14 | global rdbuf uchar 4096 |
| 15 | global decbuf uchar 32 |
| 16 | global fldcnt ulong 16 |
| 17 | global evalnames uchar 4096 |
| 18 | global evallens ulong 64 |
| 19 | global evalfirst ulong 64 |
| 20 | global evalflaky ulong 64 |
| 21 | global st ulong 20 |
| 22 | |
| 23 | note st indices |
| 24 | const s_inlen ulong 0 |
| 25 | const s_schema ulong 1 |
| 26 | const s_badprop ulong 2 |
| 27 | const s_badlen ulong 3 |
| 28 | const s_missfld ulong 4 |
| 29 | const s_slop ulong 5 |
| 30 | const s_badwf ulong 6 |
| 31 | const s_runs ulong 7 |
| 32 | const s_passruns ulong 8 |
| 33 | const s_nonpass ulong 9 |
| 34 | const s_badverd ulong 10 |
| 35 | const s_flaky ulong 11 |
| 36 | const s_evalcnt ulong 12 |
| 37 | const s_badline ulong 13 |
| 38 | |
| 39 | note Schema IDs |
| 40 | const sch_none ulong 0 |
| 41 | const sch_eng ulong 1 |
| 42 | const sch_hc ulong 2 |
| 43 | const sch_res ulong 3 |
| 44 | const sch_py ulong 4 |
| 45 | |
| 46 | note Verdict codes (0 = INVALID) |
| 47 | const v_inv ulong 0 |
| 48 | const v_pass ulong 1 |
| 49 | const v_fail ulong 2 |
| 50 | const v_notrun ulong 3 |
| 51 | const v_bhw ulong 4 |
| 52 | const v_bop ulong 5 |
| 53 | const v_miss ulong 6 |
| 54 | |
| 55 | note Line prefixes |
| 56 | text p_schema "schema " |
| 57 | text p_field "field " |
| 58 | text p_text "text " |
| 59 | text p_wf "workflow " |
| 60 | text p_eval "eval " |
| 61 | |
| 62 | note Schema names |
| 63 | text sn_eng "engineering_fix" |
| 64 | text sn_hc "harness_change" |
| 65 | text sn_res "research_handoff" |
| 66 | text sn_py "python_result" |
| 67 | text sn_pywf "python_pipeline" |
| 68 | |
| 69 | note Field keys |
| 70 | text fk_bug "bug" |
| 71 | text fk_repro "reproduction_steps" |
| 72 | text fk_fev "failure_evidence" |
| 73 | text fk_rtest "regression_test" |
| 74 | text fk_diff "diff_summary" |
| 75 | text fk_ret "retest_evidence" |
| 76 | text fk_chg "change" |
| 77 | text fk_why "why" |
| 78 | text fk_rep "replay_report" |
| 79 | text fk_evr "eval_results" |
| 80 | text fk_rbk "rollback" |
| 81 | text fk_q "question" |
| 82 | text fk_clm "claims" |
| 83 | text fk_src "sources" |
| 84 | text fk_oq "open_questions" |
| 85 | text fk_goal "goal" |
| 86 | text fk_code "code" |
| 87 | text fk_out "stdout" |
| 88 | text fk_ok "ok" |
| 89 | text fk_ev "evidence" |
| 90 | |
| 91 | note Verdict vocabulary (exact 6 words) |
| 92 | text vv_pass "PASS" |
| 93 | text vv_fail "FAIL" |
| 94 | text vv_notrun "NOT_RUN" |
| 95 | text vv_bhw "BLOCKED_HARDWARE" |
| 96 | text vv_bop "BLOCKED_OPERATOR" |
| 97 | text vv_miss "MISSING_IMPLEMENTATION" |
| 98 | |
| 99 | note Workflow state names |
| 100 | text ws_repro "reproduce" |
| 101 | text ws_rfail "regression_fail" |
| 102 | text ws_impl "implement" |
| 103 | text ws_retest "retest" |
| 104 | text ws_rev "review" |
| 105 | text ws_done "done" |
| 106 | text ws_col "collect" |
| 107 | text ws_val "validate" |
| 108 | text ws_esrc "eval_sources" |
| 109 | text ws_del "deliver" |
| 110 | text ws_prop "propose" |
| 111 | text ws_rply "replay" |
| 112 | text ws_app "apply" |
| 113 | text ws_ver "verify" |
| 114 | text ws_wr "write" |
| 115 | text ws_run "run" |
| 116 | text ws_eval "eval" |
| 117 | text ws_rem "remember" |
| 118 | text ws_ref "refine" |
| 119 | |
| 120 | note Slop gate forbidden phrases (evals.json) |
| 121 | text sl_01 "this is the part where" |
| 122 | text sl_02 "the part everyone's missing" |
| 123 | text sl_03 "the part everyone is missing" |
| 124 | text sl_04 "in today's fast-paced" |
| 125 | text sl_05 "game-changer" |
| 126 | text sl_06 "delve into" |
| 127 | text sl_07 "unlock the power" |
| 128 | text sl_08 "at the end of the day" |
| 129 | text sl_09 "it is important to note" |
| 130 | text sl_10 "in conclusion," |
| 131 | text sl_not "not " |
| 132 | text sl_its "it's " |
| 133 | text sl_itis "it is " |
| 134 | |
| 135 | note Output messages |
| 136 | text m_pass1 "GATE PASS runs=" |
| 137 | text m_pass2 " evals=" |
| 138 | text m_fail1 "GATE FAIL schema_err=" |
| 139 | text m_fail2 " slop=" |
| 140 | text m_fail3 " wf_err=" |
| 141 | text m_fail4 " bad_verdict=" |
| 142 | text m_fail5 " flaky=" |
| 143 | text m_fail6 " nonpass=" |
| 144 | text m_fail7 " runs=" |
| 145 | text m_bad_sch "harness: missing or unknown schema\n" |
| 146 | text m_io "harness: failed to read stdin\n" |
| 147 | text t_nl "\n" |
| 148 | |
| 149 | fn write_all fd int src view uchar * off ulong n ulong to void |
| 150 | p = ulong 0 |
| 151 | while lt p n bound 4096 |
| 152 | k = write fd src add off p sub n p |
| 153 | if le k 0 |
| 154 | exit 2 |
| 155 | end |
| 156 | p = add p ulong k |
| 157 | end |
| 158 | end |
| 159 | |
| 160 | fn wstr fd int s view uchar * to void |
| 161 | write_all fd s 0 len s |
| 162 | end |
| 163 | |
| 164 | fn wdec fd int v ulong to void |
| 165 | i = ulong 32 |
| 166 | n = v |
| 167 | while true bound 24 |
| 168 | i = sub i 1 |
| 169 | put decbuf i uchar add rem n 10 48 |
| 170 | n = div n 10 |
| 171 | if eq n 0 |
| 172 | break |
| 173 | end |
| 174 | end |
| 175 | p = i |
| 176 | while lt p 32 bound 32 |
| 177 | k = write fd decbuf p sub 32 p |
| 178 | if le k 0 |
| 179 | exit 2 |
| 180 | end |
| 181 | p = add p ulong k |
| 182 | end |
| 183 | end |
| 184 | |
| 185 | fn to_lower c uchar to uchar |
| 186 | if and ge c 65 le c 90 |
| 187 | ret add c 32 |
| 188 | end |
| 189 | ret c |
| 190 | end |
| 191 | |
| 192 | fn is_word_ch c uchar to bool |
| 193 | if and ge c 48 le c 57 |
| 194 | ret true |
| 195 | end |
| 196 | if and ge c 65 le c 90 |
| 197 | ret true |
| 198 | end |
| 199 | if and ge c 97 le c 122 |
| 200 | ret true |
| 201 | end |
| 202 | ret or eq c 95 eq c 45 |
| 203 | end |
| 204 | |
| 205 | fn in_eq off ulong n ulong lit view uchar * to bool |
| 206 | if ne n len lit |
| 207 | ret false |
| 208 | end |
| 209 | i = ulong 0 |
| 210 | while lt i n bound 256 |
| 211 | if ne get inbuf add off i get lit i |
| 212 | ret false |
| 213 | end |
| 214 | i = add i 1 |
| 215 | end |
| 216 | ret true |
| 217 | end |
| 218 | |
| 219 | fn in_starts off ulong lim ulong pfx view uchar * to bool |
| 220 | pl = len pfx |
| 221 | if gt add off pl lim |
| 222 | ret false |
| 223 | end |
| 224 | i = ulong 0 |
| 225 | while lt i pl bound 256 |
| 226 | if ne get inbuf add off i get pfx i |
| 227 | ret false |
| 228 | end |
| 229 | i = add i 1 |
| 230 | end |
| 231 | ret true |
| 232 | end |
| 233 | |
| 234 | fn in_starts_ci off ulong lim ulong pat view uchar * to bool |
| 235 | pl = len pat |
| 236 | if gt add off pl lim |
| 237 | ret false |
| 238 | end |
| 239 | i = ulong 0 |
| 240 | while lt i pl bound 256 |
| 241 | if ne to_lower get inbuf add off i to_lower get pat i |
| 242 | ret false |
| 243 | end |
| 244 | i = add i 1 |
| 245 | end |
| 246 | ret true |
| 247 | end |
| 248 | |
| 249 | fn in_contains_ci off ulong lim ulong pat view uchar * to bool |
| 250 | pl = len pat |
| 251 | if lt sub lim off pl |
| 252 | ret false |
| 253 | end |
| 254 | endp = add sub lim pl 1 |
| 255 | p = off |
| 256 | while lt p endp bound 4096 |
| 257 | if in_starts_ci p lim pat |
| 258 | ret true |
| 259 | end |
| 260 | p = add p 1 |
| 261 | end |
| 262 | ret false |
| 263 | end |
| 264 | |
| 265 | fn find_sp pos ulong lim ulong to ulong |
| 266 | p = pos |
| 267 | while lt p lim bound 4096 |
| 268 | if eq get inbuf p 32 |
| 269 | ret p |
| 270 | end |
| 271 | p = add p 1 |
| 272 | end |
| 273 | ret lim |
| 274 | end |
| 275 | |
| 276 | note Antithesis detector: \bnot <word/space chars>, (it's|it is) |
| 277 | fn has_antithesis off ulong lim ulong to bool |
| 278 | p = off |
| 279 | while lt p lim bound 4096 |
| 280 | ok_wb = true |
| 281 | if gt p off |
| 282 | if is_word_ch get inbuf sub p 1 |
| 283 | ok_wb = false |
| 284 | end |
| 285 | end |
| 286 | if and ok_wb in_starts_ci p lim sl_not |
| 287 | q = add p 4 |
| 288 | saw_w = false |
| 289 | while lt q lim bound 128 |
| 290 | c = get inbuf q |
| 291 | if eq c 44 |
| 292 | if saw_w |
| 293 | r = add q 1 |
| 294 | while lt r lim bound 16 |
| 295 | if ne get inbuf r 32 |
| 296 | break |
| 297 | end |
| 298 | r = add r 1 |
| 299 | end |
| 300 | if or in_starts_ci r lim sl_its in_starts_ci r lim sl_itis |
| 301 | ret true |
| 302 | end |
| 303 | end |
| 304 | break |
| 305 | end |
| 306 | if is_word_ch c |
| 307 | saw_w = true |
| 308 | else |
| 309 | if ne c 32 |
| 310 | break |
| 311 | end |
| 312 | end |
| 313 | q = add q 1 |
| 314 | end |
| 315 | end |
| 316 | p = add p 1 |
| 317 | end |
| 318 | ret false |
| 319 | end |
| 320 | |
| 321 | fn check_slop off ulong lim ulong to bool |
| 322 | if in_contains_ci off lim sl_01 |
| 323 | ret true |
| 324 | end |
| 325 | if in_contains_ci off lim sl_02 |
| 326 | ret true |
| 327 | end |
| 328 | if in_contains_ci off lim sl_03 |
| 329 | ret true |
| 330 | end |
| 331 | if in_contains_ci off lim sl_04 |
| 332 | ret true |
| 333 | end |
| 334 | if in_contains_ci off lim sl_05 |
| 335 | ret true |
| 336 | end |
| 337 | if in_contains_ci off lim sl_06 |
| 338 | ret true |
| 339 | end |
| 340 | if in_contains_ci off lim sl_07 |
| 341 | ret true |
| 342 | end |
| 343 | if in_contains_ci off lim sl_08 |
| 344 | ret true |
| 345 | end |
| 346 | if in_contains_ci off lim sl_09 |
| 347 | ret true |
| 348 | end |
| 349 | if in_contains_ci off lim sl_10 |
| 350 | ret true |
| 351 | end |
| 352 | ret has_antithesis off lim |
| 353 | end |
| 354 | |
| 355 | fn parse_verdict off ulong n ulong to ulong |
| 356 | if in_eq off n vv_pass |
| 357 | ret v_pass |
| 358 | end |
| 359 | if in_eq off n vv_fail |
| 360 | ret v_fail |
| 361 | end |
| 362 | if in_eq off n vv_notrun |
| 363 | ret v_notrun |
| 364 | end |
| 365 | if in_eq off n vv_bhw |
| 366 | ret v_bhw |
| 367 | end |
| 368 | if in_eq off n vv_bop |
| 369 | ret v_bop |
| 370 | end |
| 371 | if in_eq off n vv_miss |
| 372 | ret v_miss |
| 373 | end |
| 374 | ret v_inv |
| 375 | end |
| 376 | |
| 377 | fn eval_name_eq idx ulong off ulong n ulong to bool |
| 378 | if ne get evallens idx n |
| 379 | ret false |
| 380 | end |
| 381 | base = mul idx 64 |
| 382 | i = ulong 0 |
| 383 | while lt i n bound 64 |
| 384 | if ne get evalnames add base i get inbuf add off i |
| 385 | ret false |
| 386 | end |
| 387 | i = add i 1 |
| 388 | end |
| 389 | ret true |
| 390 | end |
| 391 | |
| 392 | fn record_eval_run noff ulong nlen ulong vcode ulong to void |
| 393 | put st s_runs add get st s_runs 1 |
| 394 | if eq vcode v_inv |
| 395 | put st s_badverd add get st s_badverd 1 |
| 396 | ret |
| 397 | end |
| 398 | if eq vcode v_pass |
| 399 | put st s_passruns add get st s_passruns 1 |
| 400 | else |
| 401 | put st s_nonpass add get st s_nonpass 1 |
| 402 | end |
| 403 | clen = nlen |
| 404 | if gt clen 64 |
| 405 | clen = ulong 64 |
| 406 | end |
| 407 | cnt = get st s_evalcnt |
| 408 | idx = ulong 0 |
| 409 | while lt idx cnt bound 64 |
| 410 | if eval_name_eq idx noff clen |
| 411 | if ne get evalfirst idx vcode |
| 412 | if eq get evalflaky idx 0 |
| 413 | put evalflaky idx 1 |
| 414 | put st s_flaky add get st s_flaky 1 |
| 415 | end |
| 416 | end |
| 417 | ret |
| 418 | end |
| 419 | idx = add idx 1 |
| 420 | end |
| 421 | if lt cnt 64 |
| 422 | base = mul cnt 64 |
| 423 | i = ulong 0 |
| 424 | while lt i clen bound 64 |
| 425 | put evalnames add base i get inbuf add noff i |
| 426 | i = add i 1 |
| 427 | end |
| 428 | put evallens cnt clen |
| 429 | put evalfirst cnt vcode |
| 430 | put evalflaky cnt 0 |
| 431 | put st s_evalcnt add cnt 1 |
| 432 | end |
| 433 | end |
| 434 | |
| 435 | fn wf_eng_ok fo ulong fnl ulong to_o ulong tn ulong to bool |
| 436 | if in_eq fo fnl ws_repro |
| 437 | ret in_eq to_o tn ws_rfail |
| 438 | end |
| 439 | if in_eq fo fnl ws_rfail |
| 440 | ret in_eq to_o tn ws_impl |
| 441 | end |
| 442 | if in_eq fo fnl ws_impl |
| 443 | ret in_eq to_o tn ws_retest |
| 444 | end |
| 445 | if in_eq fo fnl ws_retest |
| 446 | ret or in_eq to_o tn ws_rev in_eq to_o tn ws_impl |
| 447 | end |
| 448 | if in_eq fo fnl ws_rev |
| 449 | ret or in_eq to_o tn ws_done in_eq to_o tn ws_impl |
| 450 | end |
| 451 | ret false |
| 452 | end |
| 453 | |
| 454 | fn wf_res_ok fo ulong fnl ulong to_o ulong tn ulong to bool |
| 455 | if in_eq fo fnl ws_col |
| 456 | ret in_eq to_o tn ws_val |
| 457 | end |
| 458 | if in_eq fo fnl ws_val |
| 459 | ret or in_eq to_o tn ws_esrc in_eq to_o tn ws_col |
| 460 | end |
| 461 | if in_eq fo fnl ws_esrc |
| 462 | ret or in_eq to_o tn ws_del in_eq to_o tn ws_col |
| 463 | end |
| 464 | if in_eq fo fnl ws_del |
| 465 | ret in_eq to_o tn ws_done |
| 466 | end |
| 467 | ret false |
| 468 | end |
| 469 | |
| 470 | fn wf_hc_ok fo ulong fnl ulong to_o ulong tn ulong to bool |
| 471 | if in_eq fo fnl ws_prop |
| 472 | ret in_eq to_o tn ws_rply |
| 473 | end |
| 474 | if in_eq fo fnl ws_rply |
| 475 | ret or in_eq to_o tn ws_app in_eq to_o tn ws_prop |
| 476 | end |
| 477 | if in_eq fo fnl ws_app |
| 478 | ret in_eq to_o tn ws_ver |
| 479 | end |
| 480 | if in_eq fo fnl ws_ver |
| 481 | ret or in_eq to_o tn ws_done in_eq to_o tn ws_prop |
| 482 | end |
| 483 | ret false |
| 484 | end |
| 485 | |
| 486 | fn wf_py_ok fo ulong fnl ulong to_o ulong tn ulong to bool |
| 487 | if in_eq fo fnl ws_wr |
| 488 | ret in_eq to_o tn ws_run |
| 489 | end |
| 490 | if in_eq fo fnl ws_run |
| 491 | ret in_eq to_o tn ws_eval |
| 492 | end |
| 493 | if in_eq fo fnl ws_eval |
| 494 | ret or in_eq to_o tn ws_del in_eq to_o tn ws_rem |
| 495 | end |
| 496 | if in_eq fo fnl ws_rem |
| 497 | ret in_eq to_o tn ws_ref |
| 498 | end |
| 499 | if in_eq fo fnl ws_ref |
| 500 | ret in_eq to_o tn ws_run |
| 501 | end |
| 502 | if in_eq fo fnl ws_del |
| 503 | ret in_eq to_o tn ws_done |
| 504 | end |
| 505 | ret false |
| 506 | end |
| 507 | |
| 508 | fn check_wf_line ls ulong lim ulong to void |
| 509 | p1 = add ls 9 |
| 510 | s1 = find_sp p1 lim |
| 511 | if ge s1 lim |
| 512 | put st s_badwf add get st s_badwf 1 |
| 513 | ret |
| 514 | end |
| 515 | p2 = add s1 1 |
| 516 | s2 = find_sp p2 lim |
| 517 | if ge s2 lim |
| 518 | put st s_badwf add get st s_badwf 1 |
| 519 | ret |
| 520 | end |
| 521 | p3 = add s2 1 |
| 522 | ok = false |
| 523 | if in_eq p1 sub s1 p1 sn_eng |
| 524 | ok = wf_eng_ok p2 sub s2 p2 p3 sub lim p3 |
| 525 | else |
| 526 | if in_eq p1 sub s1 p1 sn_res |
| 527 | ok = wf_res_ok p2 sub s2 p2 p3 sub lim p3 |
| 528 | else |
| 529 | if in_eq p1 sub s1 p1 sn_hc |
| 530 | ok = wf_hc_ok p2 sub s2 p2 p3 sub lim p3 |
| 531 | else |
| 532 | if in_eq p1 sub s1 p1 sn_pywf |
| 533 | ok = wf_py_ok p2 sub s2 p2 p3 sub lim p3 |
| 534 | end |
| 535 | end |
| 536 | end |
| 537 | end |
| 538 | if not ok |
| 539 | put st s_badwf add get st s_badwf 1 |
| 540 | end |
| 541 | end |
| 542 | |
| 543 | fn apply_field_eng ko ulong kl ulong vl ulong to void |
| 544 | slot = ulong 99 |
| 545 | minl = ulong 0 |
| 546 | if in_eq ko kl fk_bug |
| 547 | slot = ulong 0 |
| 548 | minl = ulong 8 |
| 549 | else |
| 550 | if in_eq ko kl fk_repro |
| 551 | slot = ulong 1 |
| 552 | minl = ulong 4 |
| 553 | else |
| 554 | if in_eq ko kl fk_fev |
| 555 | slot = ulong 2 |
| 556 | minl = ulong 8 |
| 557 | else |
| 558 | if in_eq ko kl fk_rtest |
| 559 | slot = ulong 3 |
| 560 | minl = ulong 4 |
| 561 | else |
| 562 | if in_eq ko kl fk_diff |
| 563 | slot = ulong 4 |
| 564 | minl = ulong 8 |
| 565 | else |
| 566 | if in_eq ko kl fk_ret |
| 567 | slot = ulong 5 |
| 568 | minl = ulong 8 |
| 569 | end |
| 570 | end |
| 571 | end |
| 572 | end |
| 573 | end |
| 574 | end |
| 575 | if eq slot 99 |
| 576 | put st s_badprop add get st s_badprop 1 |
| 577 | ret |
| 578 | end |
| 579 | if lt vl minl |
| 580 | put st s_badlen add get st s_badlen 1 |
| 581 | ret |
| 582 | end |
| 583 | put fldcnt slot add get fldcnt slot 1 |
| 584 | end |
| 585 | |
| 586 | fn apply_field_hc ko ulong kl ulong vl ulong to void |
| 587 | slot = ulong 99 |
| 588 | minl = ulong 0 |
| 589 | if in_eq ko kl fk_chg |
| 590 | slot = ulong 0 |
| 591 | minl = ulong 8 |
| 592 | else |
| 593 | if in_eq ko kl fk_why |
| 594 | slot = ulong 1 |
| 595 | minl = ulong 8 |
| 596 | else |
| 597 | if in_eq ko kl fk_rep |
| 598 | slot = ulong 2 |
| 599 | minl = ulong 8 |
| 600 | else |
| 601 | if in_eq ko kl fk_evr |
| 602 | slot = ulong 3 |
| 603 | minl = ulong 4 |
| 604 | else |
| 605 | if in_eq ko kl fk_rbk |
| 606 | slot = ulong 4 |
| 607 | minl = ulong 8 |
| 608 | end |
| 609 | end |
| 610 | end |
| 611 | end |
| 612 | end |
| 613 | if eq slot 99 |
| 614 | put st s_badprop add get st s_badprop 1 |
| 615 | ret |
| 616 | end |
| 617 | if lt vl minl |
| 618 | put st s_badlen add get st s_badlen 1 |
| 619 | ret |
| 620 | end |
| 621 | put fldcnt slot add get fldcnt slot 1 |
| 622 | end |
| 623 | |
| 624 | fn apply_field_res ko ulong kl ulong vl ulong to void |
| 625 | slot = ulong 99 |
| 626 | minl = ulong 0 |
| 627 | if in_eq ko kl fk_q |
| 628 | slot = ulong 0 |
| 629 | minl = ulong 8 |
| 630 | else |
| 631 | if in_eq ko kl fk_clm |
| 632 | slot = ulong 1 |
| 633 | minl = ulong 12 |
| 634 | else |
| 635 | if in_eq ko kl fk_src |
| 636 | slot = ulong 2 |
| 637 | minl = ulong 8 |
| 638 | else |
| 639 | if in_eq ko kl fk_oq |
| 640 | slot = ulong 3 |
| 641 | minl = ulong 0 |
| 642 | end |
| 643 | end |
| 644 | end |
| 645 | end |
| 646 | if eq slot 99 |
| 647 | put st s_badprop add get st s_badprop 1 |
| 648 | ret |
| 649 | end |
| 650 | if lt vl minl |
| 651 | put st s_badlen add get st s_badlen 1 |
| 652 | ret |
| 653 | end |
| 654 | put fldcnt slot add get fldcnt slot 1 |
| 655 | end |
| 656 | |
| 657 | fn apply_field_py ko ulong kl ulong vl ulong to void |
| 658 | slot = ulong 99 |
| 659 | minl = ulong 0 |
| 660 | if in_eq ko kl fk_goal |
| 661 | slot = ulong 0 |
| 662 | minl = ulong 4 |
| 663 | else |
| 664 | if in_eq ko kl fk_code |
| 665 | slot = ulong 1 |
| 666 | minl = ulong 4 |
| 667 | else |
| 668 | if in_eq ko kl fk_out |
| 669 | slot = ulong 2 |
| 670 | minl = ulong 0 |
| 671 | else |
| 672 | if in_eq ko kl fk_ok |
| 673 | slot = ulong 3 |
| 674 | minl = ulong 2 |
| 675 | else |
| 676 | if in_eq ko kl fk_ev |
| 677 | slot = ulong 4 |
| 678 | minl = ulong 2 |
| 679 | end |
| 680 | end |
| 681 | end |
| 682 | end |
| 683 | end |
| 684 | if eq slot 99 |
| 685 | put st s_badprop add get st s_badprop 1 |
| 686 | ret |
| 687 | end |
| 688 | if lt vl minl |
| 689 | put st s_badlen add get st s_badlen 1 |
| 690 | ret |
| 691 | end |
| 692 | put fldcnt slot add get fldcnt slot 1 |
| 693 | end |
| 694 | |
| 695 | fn handle_field_line ls ulong lim ulong to void |
| 696 | ko = add ls 6 |
| 697 | sp = find_sp ko lim |
| 698 | kl = sub sp ko |
| 699 | vo = sp |
| 700 | if lt sp lim |
| 701 | vo = add sp 1 |
| 702 | end |
| 703 | vl = sub lim vo |
| 704 | sid = get st s_schema |
| 705 | if eq sid sch_eng |
| 706 | apply_field_eng ko kl vl |
| 707 | else |
| 708 | if eq sid sch_hc |
| 709 | apply_field_hc ko kl vl |
| 710 | else |
| 711 | if eq sid sch_res |
| 712 | apply_field_res ko kl vl |
| 713 | else |
| 714 | if eq sid sch_py |
| 715 | apply_field_py ko kl vl |
| 716 | else |
| 717 | put st s_badprop add get st s_badprop 1 |
| 718 | end |
| 719 | end |
| 720 | end |
| 721 | end |
| 722 | end |
| 723 | |
| 724 | fn handle_eval_line ls ulong lim ulong to void |
| 725 | p1 = add ls 5 |
| 726 | sp = find_sp p1 lim |
| 727 | if or eq sp p1 ge sp lim |
| 728 | put st s_badverd add get st s_badverd 1 |
| 729 | ret |
| 730 | end |
| 731 | p2 = add sp 1 |
| 732 | vc = parse_verdict p2 sub lim p2 |
| 733 | record_eval_run p1 sub sp p1 vc |
| 734 | end |
| 735 | |
| 736 | fn evaluate_loaded to int |
| 737 | tot = get st s_inlen |
| 738 | for i ulong 14 |
| 739 | if ne i s_inlen |
| 740 | put st i 0 |
| 741 | end |
| 742 | end |
| 743 | for j ulong 16 |
| 744 | put fldcnt j 0 |
| 745 | end |
| 746 | pos = ulong 0 |
| 747 | while lt pos tot bound 32768 |
| 748 | ls = pos |
| 749 | while lt pos tot bound 32768 |
| 750 | if eq get inbuf pos 10 |
| 751 | break |
| 752 | end |
| 753 | pos = add pos 1 |
| 754 | end |
| 755 | ll = sub pos ls |
| 756 | if gt ll 0 |
| 757 | if ne get inbuf ls 35 |
| 758 | if in_starts ls pos p_schema |
| 759 | so = add ls 7 |
| 760 | sl = sub pos so |
| 761 | if in_eq so sl sn_eng |
| 762 | put st s_schema sch_eng |
| 763 | else |
| 764 | if in_eq so sl sn_hc |
| 765 | put st s_schema sch_hc |
| 766 | else |
| 767 | if in_eq so sl sn_res |
| 768 | put st s_schema sch_res |
| 769 | else |
| 770 | if in_eq so sl sn_py |
| 771 | put st s_schema sch_py |
| 772 | else |
| 773 | put st s_schema sch_none |
| 774 | put st s_badline add get st s_badline 1 |
| 775 | end |
| 776 | end |
| 777 | end |
| 778 | end |
| 779 | else |
| 780 | if in_starts ls pos p_field |
| 781 | handle_field_line ls pos |
| 782 | else |
| 783 | if in_starts ls pos p_text |
| 784 | if check_slop add ls 5 pos |
| 785 | put st s_slop add get st s_slop 1 |
| 786 | end |
| 787 | else |
| 788 | if in_starts ls pos p_wf |
| 789 | check_wf_line ls pos |
| 790 | else |
| 791 | if in_starts ls pos p_eval |
| 792 | handle_eval_line ls pos |
| 793 | else |
| 794 | put st s_badline add get st s_badline 1 |
| 795 | end |
| 796 | end |
| 797 | end |
| 798 | end |
| 799 | end |
| 800 | end |
| 801 | end |
| 802 | if lt pos tot |
| 803 | pos = add pos 1 |
| 804 | end |
| 805 | end |
| 806 | sid = get st s_schema |
| 807 | if or eq sid sch_none gt get st s_badline 0 |
| 808 | ret 2 |
| 809 | end |
| 810 | req = ulong 0 |
| 811 | if eq sid sch_eng |
| 812 | req = ulong 6 |
| 813 | else |
| 814 | if eq sid sch_hc |
| 815 | req = ulong 5 |
| 816 | else |
| 817 | if eq sid sch_res |
| 818 | req = ulong 4 |
| 819 | else |
| 820 | req = ulong 5 |
| 821 | end |
| 822 | end |
| 823 | end |
| 824 | i = ulong 0 |
| 825 | while lt i req bound 8 |
| 826 | if eq get fldcnt i 0 |
| 827 | put st s_missfld add get st s_missfld 1 |
| 828 | end |
| 829 | i = add i 1 |
| 830 | end |
| 831 | sch_err = add add get st s_missfld get st s_badprop get st s_badlen |
| 832 | if gt sch_err 0 |
| 833 | ret 1 |
| 834 | end |
| 835 | if gt get st s_slop 0 |
| 836 | ret 1 |
| 837 | end |
| 838 | if gt get st s_badwf 0 |
| 839 | ret 1 |
| 840 | end |
| 841 | if eq get st s_runs 0 |
| 842 | ret 1 |
| 843 | end |
| 844 | if gt get st s_badverd 0 |
| 845 | ret 1 |
| 846 | end |
| 847 | if gt get st s_flaky 0 |
| 848 | ret 1 |
| 849 | end |
| 850 | if gt get st s_nonpass 0 |
| 851 | ret 1 |
| 852 | end |
| 853 | ret 0 |
| 854 | end |
| 855 | |
| 856 | fn read_stdin to bool |
| 857 | tot = ulong 0 |
| 858 | while true bound 256 |
| 859 | k = read 0 rdbuf 0 4096 |
| 860 | if lt k 0 |
| 861 | ret false |
| 862 | end |
| 863 | if eq k 0 |
| 864 | break |
| 865 | end |
| 866 | kn = ulong k |
| 867 | i = ulong 0 |
| 868 | while lt i kn bound 4096 |
| 869 | c = get rdbuf i |
| 870 | if ne c 13 |
| 871 | if ge tot 32768 |
| 872 | ret false |
| 873 | end |
| 874 | put inbuf tot c |
| 875 | tot = add tot 1 |
| 876 | end |
| 877 | i = add i 1 |
| 878 | end |
| 879 | end |
| 880 | put st s_inlen tot |
| 881 | ret true |
| 882 | end |
| 883 | |
| 884 | fn main to int |
| 885 | if not read_stdin |
| 886 | wstr 2 m_io |
| 887 | ret 2 |
| 888 | end |
| 889 | rc = evaluate_loaded |
| 890 | if eq rc 2 |
| 891 | wstr 2 m_bad_sch |
| 892 | ret 2 |
| 893 | end |
| 894 | if eq rc 0 |
| 895 | wstr 1 m_pass1 |
| 896 | wdec 1 get st s_runs |
| 897 | wstr 1 m_pass2 |
| 898 | wdec 1 get st s_evalcnt |
| 899 | wstr 1 t_nl |
| 900 | ret 0 |
| 901 | end |
| 902 | sch_err = add add get st s_missfld get st s_badprop get st s_badlen |
| 903 | wstr 1 m_fail1 |
| 904 | wdec 1 sch_err |
| 905 | wstr 1 m_fail2 |
| 906 | wdec 1 get st s_slop |
| 907 | wstr 1 m_fail3 |
| 908 | wdec 1 get st s_badwf |
| 909 | wstr 1 m_fail4 |
| 910 | wdec 1 get st s_badverd |
| 911 | wstr 1 m_fail5 |
| 912 | wdec 1 get st s_flaky |
| 913 | wstr 1 m_fail6 |
| 914 | wdec 1 get st s_nonpass |
| 915 | wstr 1 m_fail7 |
| 916 | wdec 1 get st s_runs |
| 917 | wstr 1 t_nl |
| 918 | ret 1 |
| 919 | end |