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 / train / omega-llm / tools / wdrive / wrun.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note wrun.om (DRA-187, lane wsp): arm runner. Composed after wbuild.om (its main renamed wbmain): |
| 3 | note OMC=omc wbuild OUT/wrun tools/omegallm/wdrive/wbuild.om@wbmain tools/omegallm/wdrive/wrun.om |
| 4 | note Usage: wrun ARMS OUTDIR |
| 5 | note ARMS is plain text, one arm per line: NAME SPLIT MODE [ck=PATH] K L I A ... (blank lines and |
| 6 | note lines starting with # are skipped). MODE is gen or probe; hooks are groups of four decimals, at |
| 7 | note most 64 groups, passed through to wprobe, which judges them. Every line is checked before any arm runs. |
| 8 | note For each arm whose OUTDIR/NAME.out does not exist it takes the pool lock LOCK (flock(2) exclusive, |
| 9 | note polled every 10 ms for at most 7200 s, as `flock -w 7200 -o` did; a timeout counts as exit status |
| 10 | note 1 and prints LOCK_TIMEOUT LOCK on stderr) and runs, with an empty environment and without the |
| 11 | note lock descriptor, |
| 12 | note /usr/bin/taskset -c POOL /usr/bin/nice -n 10 WPROBE gen CK MERGES 64 REC hooks |
| 13 | note (probe: WPROBE probe CK MERGES REC hooks) |
| 14 | note An arm with more than 48 hook words (execprog's 64 records less the 13 above) has them written to |
| 15 | note OUTDIR/NAME.hooks, one line, and passed as the single last argument @OUTDIR/NAME.hooks (wprobe |
| 16 | note with @PATH hooks, wprobe.om after 72d3377). |
| 17 | note with stdout to OUTDIR/NAME.out.tmp, renamed to NAME.out on exit status 0 and to NAME.out.failed |
| 18 | note otherwise, then appends to OUTDIR/runs.log and prints |
| 19 | note RUN NAME SPLIT MODE RC WALL_MS START_UNIX_MS CK_SHA256 WPROBE_SHA256 OUT_SHA256 hooks... |
| 20 | note (OUT_SHA256 is of NAME.out or NAME.out.failed). An existing NAME.out prints SKIP NAME. |
| 21 | note Environment: HOME (required), POOL (default 19), LOCK (default HOME/handoffs/hive/queen/pool-POOL.lock), |
| 22 | note WPROBE (default HOME/work/wsp/build/wprobe), CK (default HOME/.local/share/omega-tool-model/round40/ |
| 23 | note model.ck), MERGES (default beside it, merges.bin), SPLITS (default HOME/work/wsp/aien-train/evidence/ |
| 24 | note OMEGALLM/wsp-dra187-20261107/splits); REC is SPLITS/SPLIT.rec. |
| 25 | note Exits: 0 every run arm exited 0, 1 some arm failed, 2 usage or a bad ARMS line (stderr names the |
| 26 | note line), 70 I/O. Scoring is not part of wrun. |
| 27 | |
| 28 | note string slots (wdz, see wbuild.om): 0 HOME, 1 POOL, 2 LOCK, 3 WPROBE, 4 SPLITS, 5 CK, 6 MERGES, |
| 29 | note 7 OUTDIR |
| 30 | note wrtk: last token start, end. wrar: the parsed arm: 0 1 name, 2 3 split, 4 mode (1 gen, 2 probe), |
| 31 | note 5 6 ck=PATH value (6 is 0 when absent), 7 position of the first hook, 8 hook count, 9 content end |
| 32 | global wrtk ulong 2 |
| 33 | global wrar ulong 10 |
| 34 | global wrfail ulong 1 |
| 35 | text wrtwp "WPROBE" |
| 36 | text wrtck "CK" |
| 37 | text wrtmrg "MERGES" |
| 38 | text wrtspl "SPLITS" |
| 39 | text wrdwp "/work/wsp/build/wprobe" |
| 40 | text wrdck "/.local/share/omega-tool-model/round40/model.ck" |
| 41 | text wrdmrg "/.local/share/omega-tool-model/round40/merges.bin" |
| 42 | text wrdspl "/work/wsp/aien-train/evidence/OMEGALLM/wsp-dra187-20261107/splits" |
| 43 | text wrtgen "gen" |
| 44 | text wrtprb "probe" |
| 45 | text wrtcke "ck=" |
| 46 | text wrtout ".out" |
| 47 | text wrttmp ".out.tmp" |
| 48 | text wrtfld ".out.failed" |
| 49 | text wrthk ".hooks" |
| 50 | text wrtrec ".rec" |
| 51 | text wrtlog "/runs.log" |
| 52 | text wrt64 "64" |
| 53 | text wrtrun "RUN " |
| 54 | text wrtskip "SKIP " |
| 55 | text wrtbad "BAD_ARM line " |
| 56 | text wrtnl "\n" |
| 57 | text wrtuse "usage: wrun ARMS OUTDIR (ARMS lines: NAME SPLIT gen|probe [ck=PATH] K L I A ...)\n" |
| 58 | |
| 59 | fn wrusage to void |
| 60 | wdoclr |
| 61 | wdot wrtuse |
| 62 | wdoflush 2 |
| 63 | exit 2 |
| 64 | end |
| 65 | |
| 66 | fn wrsetup to void |
| 67 | wdzpool |
| 68 | wdzenv wrtwp 3 wrdwp |
| 69 | wdzenv wrtspl 4 wrdspl |
| 70 | wdzenv wrtck 5 wrdck |
| 71 | wdzenv wrtmrg 6 wrdmrg |
| 72 | wdpclr |
| 73 | wdpa 2 |
| 74 | wdzsave 7 |
| 75 | end |
| 76 | |
| 77 | fn wrspace c ulong to bool |
| 78 | ret or or eq c 32 eq c 9 eq c 13 |
| 79 | end |
| 80 | |
| 81 | note next token of wdsrc[p, e) into wrtk; false when none |
| 82 | fn wrnext p ulong e ulong to bool |
| 83 | i = p |
| 84 | while lt i e bound 999999 |
| 85 | if not wrspace ulong get wdsrc i |
| 86 | break |
| 87 | end |
| 88 | i = add i 1 |
| 89 | end |
| 90 | if ge i e |
| 91 | ret false |
| 92 | end |
| 93 | j = i |
| 94 | while lt j e bound 999999 |
| 95 | if wrspace ulong get wdsrc j |
| 96 | break |
| 97 | end |
| 98 | j = add j 1 |
| 99 | end |
| 100 | put wrtk 0 i |
| 101 | put wrtk 1 j |
| 102 | ret true |
| 103 | end |
| 104 | |
| 105 | note a name: 1..200 bytes of A-Z a-z 0-9 . _ - +, not starting with . |
| 106 | fn wrisname s ulong e ulong to bool |
| 107 | if or eq s e gt sub e s 200 |
| 108 | ret false |
| 109 | end |
| 110 | if eq get wdsrc s 46 |
| 111 | ret false |
| 112 | end |
| 113 | for i ulong sub e s |
| 114 | c = ulong get wdsrc add s i |
| 115 | a = or and ge c 65 le c 90 and ge c 97 le c 122 |
| 116 | d = and ge c 48 le c 57 |
| 117 | p = or or eq c 46 eq c 95 or eq c 45 eq c 43 |
| 118 | if not or or a d p |
| 119 | ret false |
| 120 | end |
| 121 | end |
| 122 | ret true |
| 123 | end |
| 124 | |
| 125 | fn wrisnum s ulong e ulong to bool |
| 126 | if or eq s e gt sub e s 20 |
| 127 | ret false |
| 128 | end |
| 129 | for i ulong sub e s |
| 130 | c = ulong get wdsrc add s i |
| 131 | if or lt c 48 gt c 57 |
| 132 | ret false |
| 133 | end |
| 134 | end |
| 135 | ret true |
| 136 | end |
| 137 | |
| 138 | note parse the line content wdsrc[s, e) into wrar: 0 blank or comment, 1 arm, 2 bad |
| 139 | fn wrparse s ulong e ulong to ulong |
| 140 | put wrar 9 e |
| 141 | if not wrnext s e |
| 142 | ret 0 |
| 143 | end |
| 144 | if eq get wdsrc get wrtk 0 35 |
| 145 | ret 0 |
| 146 | end |
| 147 | put wrar 0 get wrtk 0 |
| 148 | put wrar 1 get wrtk 1 |
| 149 | if not wrisname get wrtk 0 get wrtk 1 |
| 150 | ret 2 |
| 151 | end |
| 152 | if not wrnext get wrtk 1 e |
| 153 | ret 2 |
| 154 | end |
| 155 | put wrar 2 get wrtk 0 |
| 156 | put wrar 3 get wrtk 1 |
| 157 | if not wrisname get wrtk 0 get wrtk 1 |
| 158 | ret 2 |
| 159 | end |
| 160 | if not wrnext get wrtk 1 e |
| 161 | ret 2 |
| 162 | end |
| 163 | m = sub get wrtk 1 get wrtk 0 |
| 164 | put wrar 4 0 |
| 165 | if wbeq get wrtk 0 m wrtgen false |
| 166 | put wrar 4 1 |
| 167 | end |
| 168 | if wbeq get wrtk 0 m wrtprb false |
| 169 | put wrar 4 2 |
| 170 | end |
| 171 | if eq get wrar 4 0 |
| 172 | ret 2 |
| 173 | end |
| 174 | ret wrhooks e |
| 175 | end |
| 176 | |
| 177 | note the optional ck=PATH and the hooks after the mode token |
| 178 | fn wrhooks e ulong to ulong |
| 179 | p = get wrtk 1 |
| 180 | put wrar 6 0 |
| 181 | if wrnext p e |
| 182 | m = sub get wrtk 1 get wrtk 0 |
| 183 | if and wbeq get wrtk 0 m wrtcke true gt m 3 |
| 184 | put wrar 5 add get wrtk 0 3 |
| 185 | put wrar 6 get wrtk 1 |
| 186 | p = get wrtk 1 |
| 187 | end |
| 188 | end |
| 189 | put wrar 7 p |
| 190 | k = ulong 0 |
| 191 | while wrnext p e bound 999999 |
| 192 | if not wrisnum get wrtk 0 get wrtk 1 |
| 193 | ret 2 |
| 194 | end |
| 195 | k = add k 1 |
| 196 | p = get wrtk 1 |
| 197 | end |
| 198 | note at most 64 groups (wprobe's cap). execprog takes 64 records and gen uses 13 before the hooks, |
| 199 | note so more than 48 words go through OUTDIR/NAME.hooks and wprobe's last argument @PATH |
| 200 | if or ne rem k 4 0 gt k 256 |
| 201 | ret 2 |
| 202 | end |
| 203 | put wrar 8 k |
| 204 | ret 1 |
| 205 | end |
| 206 | |
| 207 | note OUTDIR/NAME followed by t |
| 208 | fn wrpout t view uchar * to void |
| 209 | wdpclr |
| 210 | wdzp 7 |
| 211 | wdpc 47 |
| 212 | wdpb get wrar 0 sub get wrar 1 get wrar 0 |
| 213 | wdpt t |
| 214 | end |
| 215 | |
| 216 | fn wrpck to void |
| 217 | wdpclr |
| 218 | if gt get wrar 6 0 |
| 219 | wdpb get wrar 5 sub get wrar 6 get wrar 5 |
| 220 | else |
| 221 | wdzp 5 |
| 222 | end |
| 223 | end |
| 224 | |
| 225 | fn wrcmd to void |
| 226 | wdkpre |
| 227 | wdpclr |
| 228 | wdzp 3 |
| 229 | wdkp |
| 230 | if eq get wrar 4 1 |
| 231 | wdkt wrtgen |
| 232 | else |
| 233 | wdkt wrtprb |
| 234 | end |
| 235 | wrpck |
| 236 | wdkp |
| 237 | wdpclr |
| 238 | wdzp 6 |
| 239 | wdkp |
| 240 | if eq get wrar 4 1 |
| 241 | wdkt wrt64 |
| 242 | end |
| 243 | wdpclr |
| 244 | wdzp 4 |
| 245 | wdpc 47 |
| 246 | wdpb get wrar 2 sub get wrar 3 get wrar 2 |
| 247 | wdpt wrtrec |
| 248 | wdkp |
| 249 | if gt get wrar 8 48 |
| 250 | wdpclr |
| 251 | wdpc 64 |
| 252 | wdzp 7 |
| 253 | wdpc 47 |
| 254 | wdpb get wrar 0 sub get wrar 1 get wrar 0 |
| 255 | wdpt wrthk |
| 256 | wdkp |
| 257 | ret |
| 258 | end |
| 259 | p = get wrar 7 |
| 260 | e = get wrar 9 |
| 261 | while wrnext p e bound 999999 |
| 262 | wdpclr |
| 263 | wdpb get wrtk 0 sub get wrtk 1 get wrtk 0 |
| 264 | wdkp |
| 265 | p = get wrtk 1 |
| 266 | end |
| 267 | end |
| 268 | |
| 269 | note OUTDIR/NAME.hooks: the arm's hook words, one line |
| 270 | fn wrhookfile to void |
| 271 | wrpout wrthk |
| 272 | fd = wdopen 577 438 |
| 273 | if lt fd 0 |
| 274 | exit 70 |
| 275 | end |
| 276 | wdoclr |
| 277 | wrhookout |
| 278 | wdot wrtnl |
| 279 | wdowr fd |
| 280 | c = fclose fd |
| 281 | if ne c 0 |
| 282 | exit 70 |
| 283 | end |
| 284 | wdoclr |
| 285 | end |
| 286 | |
| 287 | note append wdsrc[s, e) to the output line |
| 288 | fn wrob s ulong e ulong to void |
| 289 | for j ulong sub e s |
| 290 | wdoc ulong get wdsrc add s j |
| 291 | end |
| 292 | end |
| 293 | |
| 294 | fn wrshaline to void |
| 295 | if not wdfsha |
| 296 | exit 70 |
| 297 | end |
| 298 | wdohex |
| 299 | wdoc 32 |
| 300 | end |
| 301 | |
| 302 | note run the parsed arm |
| 303 | fn wrarm to void |
| 304 | wrpout wrtout |
| 305 | if wdexists |
| 306 | wdoclr |
| 307 | wdot wrtskip |
| 308 | wrob get wrar 0 get wrar 1 |
| 309 | wdot wrtnl |
| 310 | wdoflush 1 |
| 311 | ret |
| 312 | end |
| 313 | if gt get wrar 8 48 |
| 314 | wrhookfile |
| 315 | end |
| 316 | wrpout wrttmp |
| 317 | fo = wdopen 577 438 |
| 318 | if lt fo 0 |
| 319 | exit 70 |
| 320 | end |
| 321 | wrcmd |
| 322 | s0 = realns |
| 323 | m0 = monons |
| 324 | rc = wdpoolrun -1 fo -1 |
| 325 | c = fclose fo |
| 326 | m1 = monons |
| 327 | wdkclr |
| 328 | wrpout wrttmp |
| 329 | wdkp |
| 330 | if eq rc 0 |
| 331 | wrpout wrtout |
| 332 | else |
| 333 | wrpout wrtfld |
| 334 | put wrfail 0 1 |
| 335 | end |
| 336 | wdkp |
| 337 | wdrename |
| 338 | wrline rc div ulong sub m1 m0 1000000 div ulong s0 1000000 |
| 339 | end |
| 340 | |
| 341 | note the RUN line, to stdout and to OUTDIR/runs.log |
| 342 | fn wrline rc long wall ulong st ulong to void |
| 343 | wdoclr |
| 344 | wdot wrtrun |
| 345 | wrob get wrar 0 get wrar 1 |
| 346 | wdoc 32 |
| 347 | wrob get wrar 2 get wrar 3 |
| 348 | wdoc 32 |
| 349 | if eq get wrar 4 1 |
| 350 | wdot wrtgen |
| 351 | else |
| 352 | wdot wrtprb |
| 353 | end |
| 354 | wdoc 32 |
| 355 | wdod ulong rc |
| 356 | wdoc 32 |
| 357 | wdod wall |
| 358 | wdoc 32 |
| 359 | wdod st |
| 360 | wdoc 32 |
| 361 | wrpck |
| 362 | wrshaline |
| 363 | wdpclr |
| 364 | wdzp 3 |
| 365 | wrshaline |
| 366 | if eq rc 0 |
| 367 | wrpout wrtout |
| 368 | else |
| 369 | wrpout wrtfld |
| 370 | end |
| 371 | if not wdfsha |
| 372 | exit 70 |
| 373 | end |
| 374 | wdohex |
| 375 | wrhookout |
| 376 | wdot wrtnl |
| 377 | wdpclr |
| 378 | wdzp 7 |
| 379 | wdpt wrtlog |
| 380 | fd = wdopen 1089 438 |
| 381 | if lt fd 0 |
| 382 | exit 70 |
| 383 | end |
| 384 | wdowr fd |
| 385 | c = fclose fd |
| 386 | wdoflush 1 |
| 387 | end |
| 388 | |
| 389 | fn wrhookout to void |
| 390 | p = get wrar 7 |
| 391 | e = get wrar 9 |
| 392 | while wrnext p e bound 999999 |
| 393 | wdoc 32 |
| 394 | wrob get wrtk 0 get wrtk 1 |
| 395 | p = get wrtk 1 |
| 396 | end |
| 397 | end |
| 398 | |
| 399 | note pass 0 checks every line, pass 1 runs the arms |
| 400 | fn wrpass pass ulong to void |
| 401 | n = get wdsn 0 |
| 402 | s = ulong 0 |
| 403 | ln = ulong 1 |
| 404 | while lt s n bound 999999 |
| 405 | e = wbeol s n |
| 406 | r = wrparse s add s wbcl s e |
| 407 | if eq r 2 |
| 408 | wdoclr |
| 409 | wdot wrtbad |
| 410 | wdod ln |
| 411 | wdot wrtnl |
| 412 | wdoflush 2 |
| 413 | exit 2 |
| 414 | end |
| 415 | if and eq r 1 eq pass 1 |
| 416 | wrarm |
| 417 | end |
| 418 | s = e |
| 419 | ln = add ln 1 |
| 420 | end |
| 421 | end |
| 422 | |
| 423 | fn main to int |
| 424 | if ne argcnt 3 |
| 425 | wrusage |
| 426 | end |
| 427 | wrsetup |
| 428 | wdpclr |
| 429 | wdpa 1 |
| 430 | r = wdload |
| 431 | if lt r 0 |
| 432 | exit 70 |
| 433 | end |
| 434 | wdpclr |
| 435 | wdzp 7 |
| 436 | m = makedir wdp 0 get wdpn 0 509 |
| 437 | wrpass 0 |
| 438 | wrpass 1 |
| 439 | ret int get wrfail 0 |
| 440 | end |