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/tools/pi-drive-27b/omguard_trace.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 / tools / pi-drive-27b / omguard_trace.om` 571 lines ยท 9632 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note tools/pi-drive-27b/omguard_trace.om: Pure OM-1 self-test driver for omguard.om. 3 note Build on AArch64 Linux: 4 note cat tools/pi-drive-27b/omguard.om tools/pi-drive-27b/omguard_trace.om | ./seed/out/omc > omguard_trace 5 note Run: 6 note ./omguard_trace 7 8 text tpass "OMGUARD TEST PASS 8/8\n" 9 text tfail "OMGUARD TEST FAIL\n" 10 11 text s1_0 "note 0xdeadbeef inside note comment is allowed" 12 text s1_1 "fn sq x ulong y ulong to ulong" 13 text s1_2 "acc = ulong 0" 14 text s1_3 "i = ulong 0" 15 text s1_4 "while lt i x bound 64" 16 text s1_5 "if gt y 0" 17 text s1_6 "acc = add acc y" 18 text s1_7 "end" 19 text s1_8 "i = add i 1" 20 text s1_9 "end" 21 text s1_10 "ret acc" 22 text s1_11 "end" 23 24 text s2_0 "fn badhex to ulong" 25 text s2_1 "x = ulong 0x10" 26 text s2_2 "y = ulong 0XFF" 27 28 text s3_0 "fn too7 a ulong b ulong c ulong d ulong e ulong f ulong g ulong to ulong" 29 30 text s4_0 "fn many to ulong" 31 text s4_1 "v0 = ulong 0" 32 text s4_2 "v1 = ulong 1" 33 text s4_3 "v2 = ulong 2" 34 text s4_4 "v3 = ulong 3" 35 text s4_5 "v4 = ulong 4" 36 text s4_6 "v5 = ulong 5" 37 text s4_7 "v6 = ulong 6" 38 text s4_8 "v7 = ulong 7" 39 text s4_9 "v8 = ulong 8" 40 text s4_10 "v9 = ulong 9" 41 text s4_11 "v10 = ulong 10" 42 text s4_12 "v11 = ulong 11" 43 text s4_13 "v12 = ulong 12" 44 text s4_14 "v13 = ulong 13" 45 text s4_15 "v14 = ulong 14" 46 text s4_16 "v15 = ulong 15" 47 text s4_17 "v16 = ulong 16" 48 49 text s5_0 "fn nobnd x ulong to ulong" 50 text s5_1 "while gt x 0" 51 52 text s6_0 "end" 53 text s6_1 "fn outer to ulong" 54 text s6_2 "fn inner to ulong" 55 56 text pchunk0 "system: pure omega om-1 codegen" 57 text pchunk1 "user: write fn sq x ulong to ulong" 58 text pchunk2 "assistant: fn sq x ulong to ulong" 59 text pchunk3 "user: write fn fib n ulong to ulong" 60 61 note Test 1: valid OM-1 function with note 0x comment, while bound, if/end, balanced depth. 62 fn test1 to long 63 oginit 64 i = ulong 0 65 while lt i len s1_0 bound 512 66 put ogline i get s1_0 i 67 i = add i 1 68 end 69 if ne ogcheckline len s1_0 0 70 ret -1 71 end 72 i = ulong 0 73 while lt i len s1_1 bound 512 74 put ogline i get s1_1 i 75 i = add i 1 76 end 77 if ne ogcheckline len s1_1 0 78 ret -2 79 end 80 i = ulong 0 81 while lt i len s1_2 bound 512 82 put ogline i get s1_2 i 83 i = add i 1 84 end 85 if ne ogcheckline len s1_2 0 86 ret -3 87 end 88 i = ulong 0 89 while lt i len s1_3 bound 512 90 put ogline i get s1_3 i 91 i = add i 1 92 end 93 if ne ogcheckline len s1_3 0 94 ret -4 95 end 96 i = ulong 0 97 while lt i len s1_4 bound 512 98 put ogline i get s1_4 i 99 i = add i 1 100 end 101 if ne ogcheckline len s1_4 0 102 ret -5 103 end 104 i = ulong 0 105 while lt i len s1_5 bound 512 106 put ogline i get s1_5 i 107 i = add i 1 108 end 109 if ne ogcheckline len s1_5 0 110 ret -6 111 end 112 i = ulong 0 113 while lt i len s1_6 bound 512 114 put ogline i get s1_6 i 115 i = add i 1 116 end 117 if ne ogcheckline len s1_6 0 118 ret -7 119 end 120 i = ulong 0 121 while lt i len s1_7 bound 512 122 put ogline i get s1_7 i 123 i = add i 1 124 end 125 if ne ogcheckline len s1_7 0 126 ret -8 127 end 128 i = ulong 0 129 while lt i len s1_8 bound 512 130 put ogline i get s1_8 i 131 i = add i 1 132 end 133 if ne ogcheckline len s1_8 0 134 ret -9 135 end 136 i = ulong 0 137 while lt i len s1_9 bound 512 138 put ogline i get s1_9 i 139 i = add i 1 140 end 141 if ne ogcheckline len s1_9 0 142 ret -10 143 end 144 i = ulong 0 145 while lt i len s1_10 bound 512 146 put ogline i get s1_10 i 147 i = add i 1 148 end 149 if ne ogcheckline len s1_10 0 150 ret -11 151 end 152 i = ulong 0 153 while lt i len s1_11 bound 512 154 put ogline i get s1_11 i 155 i = add i 1 156 end 157 if ne ogcheckline len s1_11 0 158 ret -12 159 end 160 if ne ogdepth 0 161 ret -13 162 end 163 if ne oginfn 0 164 ret -14 165 end 166 ret 0 167 end 168 169 note Test 2: hex literal refusal (-1) for both 0x and 0X. 170 fn test2 to long 171 oginit 172 i = ulong 0 173 while lt i len s2_0 bound 512 174 put ogline i get s2_0 i 175 i = add i 1 176 end 177 if ne ogcheckline len s2_0 0 178 ret -1 179 end 180 i = ulong 0 181 while lt i len s2_1 bound 512 182 put ogline i get s2_1 i 183 i = add i 1 184 end 185 if ne ogcheckline len s2_1 -1 186 ret -2 187 end 188 i = ulong 0 189 while lt i len s2_2 bound 512 190 put ogline i get s2_2 i 191 i = add i 1 192 end 193 if ne ogcheckline len s2_2 -1 194 ret -3 195 end 196 ret 0 197 end 198 199 note Test 3: >6 params refusal (-2). 200 fn test3 to long 201 oginit 202 i = ulong 0 203 while lt i len s3_0 bound 512 204 put ogline i get s3_0 i 205 i = add i 1 206 end 207 if ne ogcheckline len s3_0 -2 208 ret -1 209 end 210 ret 0 211 end 212 213 note Test 4: >16 distinct locals refusal (-3), with reassignment allowed. 214 fn test4a to long 215 oginit 216 i = ulong 0 217 while lt i len s4_0 bound 512 218 put ogline i get s4_0 i 219 i = add i 1 220 end 221 if ne ogcheckline len s4_0 0 222 ret -1 223 end 224 i = ulong 0 225 while lt i len s4_1 bound 512 226 put ogline i get s4_1 i 227 i = add i 1 228 end 229 if ne ogcheckline len s4_1 0 230 ret -2 231 end 232 note Reassign v0: must not consume a new register slot. 233 if ne ogcheckline len s4_1 0 234 ret -2 235 end 236 i = ulong 0 237 while lt i len s4_2 bound 512 238 put ogline i get s4_2 i 239 i = add i 1 240 end 241 if ne ogcheckline len s4_2 0 242 ret -3 243 end 244 i = ulong 0 245 while lt i len s4_3 bound 512 246 put ogline i get s4_3 i 247 i = add i 1 248 end 249 if ne ogcheckline len s4_3 0 250 ret -4 251 end 252 i = ulong 0 253 while lt i len s4_4 bound 512 254 put ogline i get s4_4 i 255 i = add i 1 256 end 257 if ne ogcheckline len s4_4 0 258 ret -5 259 end 260 i = ulong 0 261 while lt i len s4_5 bound 512 262 put ogline i get s4_5 i 263 i = add i 1 264 end 265 if ne ogcheckline len s4_5 0 266 ret -6 267 end 268 i = ulong 0 269 while lt i len s4_6 bound 512 270 put ogline i get s4_6 i 271 i = add i 1 272 end 273 if ne ogcheckline len s4_6 0 274 ret -7 275 end 276 i = ulong 0 277 while lt i len s4_7 bound 512 278 put ogline i get s4_7 i 279 i = add i 1 280 end 281 if ne ogcheckline len s4_7 0 282 ret -8 283 end 284 i = ulong 0 285 while lt i len s4_8 bound 512 286 put ogline i get s4_8 i 287 i = add i 1 288 end 289 if ne ogcheckline len s4_8 0 290 ret -9 291 end 292 ret 0 293 end 294 295 fn test4 to long 296 r = test4a 297 if ne r 0 298 ret r 299 end 300 i = ulong 0 301 while lt i len s4_9 bound 512 302 put ogline i get s4_9 i 303 i = add i 1 304 end 305 if ne ogcheckline len s4_9 0 306 ret -10 307 end 308 i = ulong 0 309 while lt i len s4_10 bound 512 310 put ogline i get s4_10 i 311 i = add i 1 312 end 313 if ne ogcheckline len s4_10 0 314 ret -11 315 end 316 i = ulong 0 317 while lt i len s4_11 bound 512 318 put ogline i get s4_11 i 319 i = add i 1 320 end 321 if ne ogcheckline len s4_11 0 322 ret -12 323 end 324 i = ulong 0 325 while lt i len s4_12 bound 512 326 put ogline i get s4_12 i 327 i = add i 1 328 end 329 if ne ogcheckline len s4_12 0 330 ret -13 331 end 332 i = ulong 0 333 while lt i len s4_13 bound 512 334 put ogline i get s4_13 i 335 i = add i 1 336 end 337 if ne ogcheckline len s4_13 0 338 ret -14 339 end 340 i = ulong 0 341 while lt i len s4_14 bound 512 342 put ogline i get s4_14 i 343 i = add i 1 344 end 345 if ne ogcheckline len s4_14 0 346 ret -15 347 end 348 i = ulong 0 349 while lt i len s4_15 bound 512 350 put ogline i get s4_15 i 351 i = add i 1 352 end 353 if ne ogcheckline len s4_15 0 354 ret -16 355 end 356 i = ulong 0 357 while lt i len s4_16 bound 512 358 put ogline i get s4_16 i 359 i = add i 1 360 end 361 if ne ogcheckline len s4_16 0 362 ret -17 363 end 364 if ne ognlocs 16 365 ret -18 366 end 367 i = ulong 0 368 while lt i len s4_17 bound 512 369 put ogline i get s4_17 i 370 i = add i 1 371 end 372 if ne ogcheckline len s4_17 -3 373 ret -19 374 end 375 ret 0 376 end 377 378 note Test 5: while missing bound refusal (-4). 379 fn test5 to long 380 oginit 381 i = ulong 0 382 while lt i len s5_0 bound 512 383 put ogline i get s5_0 i 384 i = add i 1 385 end 386 if ne ogcheckline len s5_0 0 387 ret -1 388 end 389 i = ulong 0 390 while lt i len s5_1 bound 512 391 put ogline i get s5_1 i 392 i = add i 1 393 end 394 if ne ogcheckline len s5_1 -4 395 ret -2 396 end 397 ret 0 398 end 399 400 note Test 6: unbalanced end refusal (-5) and nested fn refusal (-6). 401 fn test6 to long 402 oginit 403 i = ulong 0 404 while lt i len s6_0 bound 512 405 put ogline i get s6_0 i 406 i = add i 1 407 end 408 if ne ogcheckline len s6_0 -5 409 ret -1 410 end 411 i = ulong 0 412 while lt i len s6_1 bound 512 413 put ogline i get s6_1 i 414 i = add i 1 415 end 416 if ne ogcheckline len s6_1 0 417 ret -2 418 end 419 i = ulong 0 420 while lt i len s6_2 bound 512 421 put ogline i get s6_2 i 422 i = add i 1 423 end 424 if ne ogcheckline len s6_2 -6 425 ret -3 426 end 427 ret 0 428 end 429 430 note Test 7: prefix-pool FNV-1a chunk hashing, exact & partial longest-prefix match. 431 fn test7 to long 432 ogpinit 433 i = ulong 0 434 while lt i len pchunk0 bound 512 435 put ogp_buf i get pchunk0 i 436 i = add i 1 437 end 438 h0 = ogphash 0 len pchunk0 439 i = ulong 0 440 while lt i len pchunk1 bound 512 441 put ogp_buf i get pchunk1 i 442 i = add i 1 443 end 444 h1 = ogphash 0 len pchunk1 445 i = ulong 0 446 while lt i len pchunk2 bound 512 447 put ogp_buf i get pchunk2 i 448 i = add i 1 449 end 450 h2 = ogphash 0 len pchunk2 451 i = ulong 0 452 while lt i len pchunk3 bound 512 453 put ogp_buf i get pchunk3 i 454 i = add i 1 455 end 456 h3 = ogphash 0 len pchunk3 457 if eq h0 h1 458 ret -1 459 end 460 note Slot 3: [h0, h1] with state_pa `4096000` 461 put ogp_q 0 h0 462 put ogp_q 1 h1 463 if ne ogpput 3 2 `4096000` 0 464 ret -2 465 end 466 note Slot 7: [h0, h1, h2] with state_pa `8192000` 467 put ogp_q 0 h0 468 put ogp_q 1 h1 469 put ogp_q 2 h2 470 if ne ogpput 7 3 `8192000` 0 471 ret -3 472 end 473 note Exact 3-chunk match must pick slot 7 (len 3, pa `8192000`). 474 put ogp_q 0 h0 475 put ogp_q 1 h1 476 put ogp_q 2 h2 477 if ne ogpmatch 3 7 478 ret -4 479 end 480 if ne ogpmatch_len 3 481 ret -5 482 end 483 if ne ogpmatch_pa `8192000` 484 ret -6 485 end 486 note Partial 2-chunk query [h0, h3]: matches h0 (len 1) on most recent slot 7. 487 put ogp_q 0 h0 488 put ogp_q 1 h3 489 ms = ogpmatch 2 490 if lt ms 0 491 ret -7 492 end 493 if ne ogpmatch_len 1 494 ret -8 495 end 496 note Unmatched query [h3]: must return -1. 497 put ogp_q 0 h3 498 if ne ogpmatch 1 -1 499 ret -9 500 end 501 ret 0 502 end 503 504 note Test 8: prefix-pool full 64-slot fill and LRU eviction. 505 fn test8 to long 506 ogpinit 507 s = ulong 0 508 while lt s OGSLOTS bound 64 509 h = ogphash_tok add 1000 s OGFNVOFF 510 put ogp_q 0 h 511 pa = mul add s 1 65536 512 if ne ogpput s 1 pa 0 513 ret -1 514 end 515 s = add s 1 516 end 517 note Touch slot 0 via ogpmatch so slot 1 becomes the oldest LRU entry. 518 h0 = ogphash_tok 1000 OGFNVOFF 519 put ogp_q 0 h0 520 if ne ogpmatch 1 0 521 ret -2 522 end 523 note Evict must choose slot 1 (oldest untouched) and clear it. 524 v = ogpevict 525 if ne v 1 526 ret -3 527 end 528 if ne get ogp_act 1 0 529 ret -4 530 end 531 note Next evict must choose slot 2. 532 v2 = ogpevict 533 if ne v2 2 534 ret -5 535 end 536 ret 0 537 end 538 539 fn main to int 540 ok = ulong 0 541 if eq test1 0 542 ok = add ok 1 543 end 544 if eq test2 0 545 ok = add ok 1 546 end 547 if eq test3 0 548 ok = add ok 1 549 end 550 if eq test4 0 551 ok = add ok 1 552 end 553 if eq test5 0 554 ok = add ok 1 555 end 556 if eq test6 0 557 ok = add ok 1 558 end 559 if eq test7 0 560 ok = add ok 1 561 end 562 if eq test8 0 563 ok = add ok 1 564 end 565 if eq ok 8 566 k = write 1 tpass 0 len tpass 567 ret 0 568 end 569 k = write 2 tfail 0 len tfail 570 ret 1 571 end