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/seed/node/README.md # 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 / seed / node / README.md` 2168 lines · 153739 bytes Raw Blame History Rendered 1 # Omega Node shared-memory transport, epoch pool, worker supervision, scheduling, authority, journal, coding workflow, operator view and release 2 3 This is the first implementation component of [Omega Node](https://github.com/aien-dev/omega-harness/issues/205). 4 It provides a bounded, single-publisher artifact log for trusted forked Omega 5 processes. Runtime consumers can share artifact storage and wake only interested 6 workers. The existing `seed/agent/agent.om` is the coding-agent consumer to evaluate 7 for integration; this change does not replace its model or tool dispatcher. 8 9 Source fragments, concatenated in this order before one program with `fn main`: 10 11 | Fragment | Adds | 12 | --- | --- | 13 | `transport.om` | one arena: 64 immutable records, topic scan, eventfd hints, stop flag (#1055) | 14 | `pool.om` | K arenas reused by epoch, reader holds, fail-closed rollover (DRA-286) | 15 | `super.om` | forked workers, death detection, reaping, creator-loss detection, bounded stop (DRA-286) | 16 | `sched.om` | subscriptions, dependency wake-ups, bounded admission and review, job loss handling (DRA-287); resource requests and the selection policy (P-DRA-14) | 17 | `seed/authority/action.om` | the existing action records the authority layer commits through | 18 | `journal.om` | durable journal of every authority transition, fencing, restart recovery (DRA-289) | 19 | `auth.om` | typed proposals, one commit owner, cancellation of real child tools, operator controls (DRA-288) | 20 | `gram.om` | the round40 repair grammar, shared by the tool and the creator (DRA-290) | 21 | `code.om` | the coding workflow: own-model turns, typed tool jobs, review (DRA-290) | 22 23 Two child programs serve the workflow as tools: `infer.om` (one model turn 24 against a local `ollm serve`) and `tool.om` (read, check, replace inside one 25 root). The component is not yet connected to the live hive. The operator 26 view and Spark qualification remain implementation work (DRA-291, DRA-292). The 27 [Linear project](https://linear.app/drake-stapleton/project/omega-node-shared-memory-hive-runtime-`37058a1eac4b`) 28 tracks that integration. This is a component contract, not a whole-system master plan. 29 30 For the disposable Unix socket control probe and its native stalled-client latency check, see [probe/README.md](probe/README.md). 31 32 ## Build and check 33 34 Use a Linux AArch64 host and the existing approved seeded compiler. Record its 35 hash independently before rebuilding. The source baseline used here is 36 ``7caba0c0094628b384abf8961a33bd95ae9412cc``, with `seed/out/omc` SHA-256 37 ``5f90edea61bac241398df5036990d899361a5acd9decb37954ce088ec0f6f6df``. 38 39 `transport-gate.om` is the exact byte concatenation of `transport.om` followed by 40 `transport-test.om`. No separators, headers or substitutions are inserted. Verify 41 that correspondence before compiling, and stop if any command fails: 42 43 ```sh 44 mkdir -p build/node 45 cat seed/node/transport.om seed/node/transport-test.om > build/node/composed.om 46 cmp build/node/composed.om seed/node/transport-gate.om 47 sha256sum seed/out/omc 48 seed/out/omc < seed/node/transport-gate.om > build/node/transport-gate 49 readelf -h build/node/transport-gate 50 chmod +x build/node/transport-gate 51 timeout 30 build/node/transport-gate 52 ``` 53 54 Expected: `PASS node transport`, exit 0. A failed compile, signal, timeout or trap 55 is not a passing refusal test. The test forks real OS processes, uses anonymous 56 shared mappings and eventfds, and opens no GPU, model endpoint or network socket. 57 Use a disposable checkout. The standard `crumb-verify`, `evidence-immutable` and 58 `zero-disk-secrets` gates also apply. The native seed gate remains required before 59 qualification; an emulated component pass does not replace it. 60 61 For an explicitly labelled emulated development check on x86, run the existing 62 AArch64 compiler and its accepted ELF output through `qemu-aarch64-static`: 63 64 ```sh 65 qemu-aarch64-static seed/out/omc < seed/node/transport-gate.om > build/node/transport-gate 66 readelf -h build/node/transport-gate 67 chmod +x build/node/transport-gate 68 timeout 30 qemu-aarch64-static build/node/transport-gate 69 ``` 70 71 ## Contract and ownership 72 73 `transport.om` is a source fragment. Concatenate it before one consumer containing 74 `fn main`. It adds no compiler word or hidden runtime dependency. 75 76 | Function | Contract | 77 | --- | --- | 78 | `node_new` | Positive mapping handle, or negative OS error. Call before fork. Records creator PID. | 79 | `node_publish h topics src n` | Creator only; copies up to 4096 bytes from a fixed 4096-byte view. Returns new version or negative refusal. Nonzero 64-bit topic mask. | 80 | `node_next h cursor topics` | Next matching version greater than cursor; zero if none currently published; negative refusal on invalid input. | 81 | `node_read h version dst` | Copies immutable bytes to a fixed 4096-byte destination; returns length. Bytes beyond that length are unchanged. | 82 | `node_stop h` | Creator sets a sticky stop flag. Does not itself wake blocked workers or cancel external effects. | 83 | `node_notify fd` | Adds a wake hint to one nonblocking eventfd; zero on success or saturation, negative error otherwise. | 84 | `node_drain fd` | Consumes a coalesced hint; an already empty descriptor is harmless. | 85 | `node_wait h wake stop interval` | Waits on distinct nonnegative descriptors. Returns 2 for stop, 1 for work hint, 0 for timeout, negative error otherwise. Interval is nanoseconds; negative means infinite. | 86 | `node_reset h epoch` | Creator only. Drops the published count to zero, clears every record version, clears stop and records `epoch` (nonzero) at header offset 40. Only `pool.om` calls it, after proving no reader holds the arena. | 87 | `node_epoch h` | The epoch recorded by the last `node_reset`; zero for a fresh arena. | 88 89 All handles must be live handles from `node_new`, and descriptors must remain 90 owned and open throughout the call. Invalid mapping handles trap in the compiler 91 runtime. These API checks do not turn writable shared memory into an isolation 92 boundary. Only trusted transport code receives the mapping. Untrusted tool 93 processes must use validated proposals through the existing authority owner. 94 95 Transport refusal codes are local to this API. Eventfd and polling helpers return 96 Linux-style negative errors. Record APIs return the refusal meanings documented 97 in the source; callers must interpret the result in the context of the operation. 98 99 The creator PID check catches accidental publication or stop from a forked worker. 100 It is not authentication, crash fencing or PID-reuse protection. A supervisor must 101 retire the entire arena and its workers if the publisher dies. Never hand an old 102 arena to a replacement publisher. Authority generations belong in the integrating 103 runtime, not in an assertion that a PID is a capability. 104 105 ## Publication and wake-up order 106 107 The creator writes payload and immutable record metadata, publishes the record 108 version, then publishes the latest version. `mapset` and `mapget` use the existing 109 compiler's fenced aligned accesses. A reader first observes the published count, 110 then validates the selected record version before accessing its bytes. Readers 111 never race a rewrite of a published payload. 112 113 After publishing, notify each subscribed worker through its own eventfd. Sharing 114 one eventfd among workers would distribute wake-ups instead of broadcasting them. 115 To stop, call `node_stop`, then notify every worker's separate control eventfd. 116 `node_wait` gives stop priority when work and control are both ready. A caller 117 must also check stop between bounded work units and validate authority again 118 before committing effects. 119 120 A consumer scans relevant published versions, processes them, advances its cursor, 121 then waits. On wake, scan again even if notifications have coalesced. Publication 122 between the scan and wait leaves an eventfd hint pending. Publication concurrent 123 with draining is covered by the scan after the drain. Signals may be stale; 124 they never encode an artifact count or transfer authority. An eventfd error must 125 be handled by the supervisor; it does not undo an already committed publication. 126 127 `node_wait` returns EINTR to the caller, which can recompute a monotonic deadline. 128 The eventfd helpers bound interruption retries and return the last interruption 129 if exhausted. A positive wait result does not promise that the worker will be 130 scheduled within a deadline. Cancellation of running model/tool work is separate. 131 132 ## Capacity and lifetime 133 134 The arena holds 64 immutable records. Full publication returns -2 without 135 overwriting old data. Inside one epoch nothing is recycled. Drop mappings only 136 after all readers finish; unmap each process's handle or terminate that process. 137 Fork inherits the arena; exec does not. 138 139 Reuse across epochs is `pool.om`'s job (next section): it resets an arena only 140 after the current epoch has moved past it and no worker holds it. 141 142 MODELED layout, checked with Wolfram Language: 143 `{4096+64*(64+4096), Mod[64+4096,64]}` returned `{270336, 0}`. 144 The first value is arena bytes; the second checks slot-stride alignment. Header 145 words at offsets 0, 8, 16, 24, 32 and 40 hold magic, ABI, count, stop, creator PID 146 and epoch. 147 Record slots start at 4096 with stride 4160; version, length and topic mask are 148 at slot offsets 0, 8 and 16, followed by payload at offset 64. These are ordinary 149 CPU mappings, with no GPU-coherence or cross-machine shared-memory claim. 150 151 ## Acceptance and negative controls 152 153 The gate checks malformed versions/lengths, nonzero topics, header and record 154 corruption, retained old data at capacity, worker publication refusal, notification 155 coalescing, stop priority, and both consumers' selected payloads byte for byte. 156 Both workers are forked before publication. Their acknowledgements and exits are 157 checked. Failure cleanup signals and reaps only the exact created child PIDs. 158 159 Generate each control in a disposable copy of `transport.om`, append the unchanged 160 test, compile successfully, and run with the same timeout: 161 162 | Change in transport source | Expected gate exit | 163 | --- | --- | 164 | Mapping mode `NBYTES 3 33` to `NBYTES 3 34` | 87 (child verification failure) | 165 | Each `if ne mapget h off 8 v` to `if false` | 33 (record-version refusal lost) | 166 | `if ne and mapget h add off 16 8 topics 0` to `if true` | 21 (topic filter lost) | 167 | Each `ret 2` to `ret 1` | 55 (stop no longer distinguished from work) | 168 | Each creator comparison `if ne mapget h 32 8 ulong getpid` to `if false` | 87 (child detects unauthorized publication accepted) | 169 170 These controls check observable protocol behavior. Emulation does not establish 171 weak-memory correctness on physical ARM hardware. The abstract Lean model in 172 omega-harness PR 206 does not prove this implementation or its memory ordering. 173 174 ## Epoch pool and worker supervision (DRA-286) 175 176 Status: IMPLEMENTED in `pool.om` and `super.om`. Exercised by `pool-gate.om` and 177 the negative controls below on native Linux AArch64. Evidence and pins are in the 178 DRA-286 pull request. Not connected to the live hive. 179 180 ### Build and check 181 182 `pool-gate.om` is the exact byte concatenation of `transport.om`, `pool.om`, 183 `super.om` and `pool-test.om`: 184 185 ```sh 186 cat seed/node/transport.om seed/node/pool.om seed/node/super.om seed/node/pool-test.om > build/node/pool-composed.om 187 cmp build/node/pool-composed.om seed/node/pool-gate.om 188 seed/out/omc < seed/node/pool-gate.om > build/node/pool-gate 189 chmod +x build/node/pool-gate 190 timeout 120 build/node/pool-gate # all phases, ends "PASS node pool" 191 timeout 90 build/node/pool-gate stress # concurrent stress phase only 192 ``` 193 194 The gate forks real processes, uses anonymous shared mappings, pipes and 195 eventfds, sends SIGKILL only to the exact PIDs it created, and opens no GPU, 196 model endpoint or socket. It needs about 3 s, most of it the stalled worker's 197 2 s stop deadline. 198 199 ### Pool contract 200 201 `pool_new K W` maps K arenas (1..8) and one 4096-byte control page before any 202 fork, so every worker inherits the same shared memory. Arena 0 opens epoch 1. 203 Epoch numbers only grow; an arena is reused for a later epoch, never an epoch 204 number. 205 206 | Function | Contract | 207 | --- | --- | 208 | `pool_new k w` | Control handle, -7 for K outside 1..8 or W outside 1..64, or a mapping errno (all mappings made so far are dropped). | 209 | `pool_acquire c w` | Worker w holds the current epoch: returns that arena, -1 stopped, -5 invalid, -7 bad worker, -8 the epoch moved 16 times running. | 210 | `pool_hold c w e` | The step `pool_acquire` repeats: store hold e, read the epoch again, refuse -8 if it moved. Every refusal clears the hold. | 211 | `pool_release c w` | Clears hold w. The old arena must not be read afterwards. | 212 | `pool_roll c` | Creator only. Opens epoch E+1 in a free arena or one whose older epoch no worker holds, then publishes E+1. -9 when every other arena is held: nothing changes (fail closed). -1 once stopped, -6 from a non-creator. | 213 | `pool_pick c`, `pool_reuse c i n` | The two steps of `pool_roll`, separate so the gate can interleave them with a worker. | 214 | `pool_publish c topics src n` | Creator: publish to the current epoch; when that arena is full, roll once and publish there. | 215 | `pool_current c`, `pool_epoch c` | Current arena handle and epoch. | 216 | `pool_stop c`, `pool_stopped c` | Sticky stop flag on the control page; creator only. | 217 | `pool_setw c w pid state`, `pool_clear c w` | Creator bookkeeping: worker PID and state (1 live, 2 reaped), and clearing a reaped worker's hold. | 218 | `pool_free c` | Drop this process's mappings of the pool. | 219 220 Control page u64 words: 0 magic, 8 ABI, 16 current epoch, 24 stop, 32 creator 221 PID, 40 K, 48 W, 64+8k arena handle, 128+8k arena epoch (0 while free or being 222 reset), 256+8w hold of worker w, 768+8w worker PID, 1280+8w worker state. 223 224 Writers: the creator writes the epoch, the arena table and every arena record. 225 Worker w writes only hold word w while it lives. The creator clears hold w only 226 after it has reaped worker w, so a dead worker's hold never blocks reuse forever 227 and a live worker's hold is never cleared under it. 228 229 Reclamation is epoch-based. A worker stores its hold, then reads the current 230 epoch again; the creator publishes the new epoch before it scans holds. `mapset` 231 and `mapget` each put `DSB SY` on both sides of their access, so either the scan 232 sees the hold or the worker's second read sees the move and it retries. An arena 233 is reset only when its epoch is older than the current one and unheld. A held 234 older epoch therefore stays complete and unchanged for as long as it is held, 235 while newer epochs are published in other arenas. 236 237 ### Supervision contract 238 239 | Function | Contract | 240 | --- | --- | 241 | `sup_init c` | Creator: one creator life pipe and wake, stop and ack eventfds for each of W slots. On failure everything it opened is closed. | 242 | `sup_spawn c w` | Creator: fork worker w. 0 in the child, the PID in the creator, -16 if slot w is live, -7 bad slot, or an errno. | 243 | `sup_wwait c w interval` | Worker: 3 creator gone, 2 stop, 1 wake hint (drained; rescan state), 0 timeout, or an errno. Creator loss outranks stop, stop outranks work. | 244 | `sup_ack w`, `sup_wake w`, `sup_take fd` | Post an ack, post a wake hint, read and reset an eventfd counter. | 245 | `sup_poll c interval`, `sup_pollx c interval acks` | Creator: wait for deaths and, unless `acks` is false, acks (left pending for `sup_take`). Reap every worker whose life pipe hung up. Returns the number reaped, or the first reap or poll error. | 246 | `sup_reap c w` | Creator: reap the exact PID (SIGKILL after about 1 s if it has not exited), then close its life pipe, clear its hold and mark it reaped. A `waitpid` error releases nothing. | 247 | `sup_stop c interval` | Creator: set stop, post every live worker's stop eventfd, and reap until all exit or the interval ends. That wait ignores acks, so a pending ack cannot turn it into a spin that kills before the deadline. Then SIGKILL and reap the rest. Returns how many were killed. | 248 | `sup_live c`, `sup_closeall` | Live worker count; close every descriptor this module opened. | 249 250 Death is detected without scanning PIDs. Each worker alone holds the write end 251 of its close-on-exec life pipe: the creator closes its copy right after the 252 fork, so later workers never inherit it. The worker's exit hangs up the 253 creator's read end. In the other direction, each child closes the creator's 254 life-pipe write end at once, so creator death hangs up every worker's read end 255 and `sup_wwait` returns 3. Workers must not `exec` themselves: exec closes the 256 life pipe and is treated as death. Tools started by a worker should fork first. 257 258 ### Negative controls 259 260 Each control is a one-line change to a disposable copy, composed with the 261 unchanged other fragments and test, compiled and run with the same timeout: 262 263 | Change | Expected exit | 264 | --- | --- | 265 | `pool.om`: `pool_held`'s `ret true` to `ret false` (holds ignored) | 28; with `stress`, 129, 130 or 133 | 266 | `transport.om`: delete `r = mapset h 16 8 0` in `node_reset` (count kept) | 34 | 267 | `super.om`: delete `r = pool_clear c w` (dead worker keeps its hold) | 74 | 268 | `super.om`: delete every `r = killpid int` line (no kill escalation) | 84 | 269 | `super.om`: delete `r = fclose get swpar 1` (child keeps creator end) | 99 | 270 | `super.om`: `if ne get p 22 0` to `if false` (creator loss ignored) | 99 | 271 | `pool.om`: delete `r = mapset c hw 8 e` (hold never stored) | 24; with `stress`, 129, 130 or 133 | 272 | `super.om`: delete `r = fclose wr` (creator keeps a worker's life end) | 72 | 273 | `pool.om`: `if ne mapget c 16 8 e` to `if false` (no epoch recheck) | 144 | 274 | `super.om`: `sup_stop` waits with `acks` true (pending ack spins the wait) | 90 | 275 276 The recheck control is deterministic because the gate runs the protocol steps 277 in the losing order (`pool_hold` after `pool_roll` and `pool_pick`). The same 278 mutant under the timing-dependent `stress` phase exited 0 in 5 of 5 probes: 279 the window needs two rolls inside one announce, so stress alone does not prove 280 the recheck. 281 282 ## Cooperative scheduling (DRA-287) 283 284 Status: IMPLEMENTED in `sched.om`, exercised by `sched-gate.om` and the 285 controls below on native Linux AArch64. Evidence is in the DRA-287 pull request. 286 287 ```sh 288 cat seed/node/transport.om seed/node/pool.om seed/node/super.om seed/node/sched.om seed/node/sched-test.om > build/node/sched-composed.om 289 cmp build/node/sched-composed.om seed/node/sched-gate.om 290 seed/out/omc < seed/node/sched-gate.om > build/node/sched-gate 291 chmod +x build/node/sched-gate 292 timeout 120 build/node/sched-gate # all phases; prints idle and wake figures, ends "PASS node sched" 293 timeout 60 build/node/sched-gate idle # the idle and wake phase only 294 ``` 295 296 ### Model 297 298 One creator owns admission, assignment, collection and review. Workers write 299 only their own cell. No step waits for every worker, so a slow or dead worker 300 holds only its own job. 301 302 A job moves through these states: 1 waiting for a dependency topic, 2 ready, 303 3 running on one worker, 4 in review, then free. A job can also become 6 304 UNKNOWN: its worker died mid-job and the job is not marked safe to rerun. 305 Admitted work (states 1 to 3) and work in review (4) have separate limits. 306 `sched_admit` refuses with -2 at the admission limit; nothing is queued behind 307 the refusal. When review is full, a finished worker keeps its result and gets 308 no new job, so assignment stops instead of dropping work. 309 310 Scheduling page cell of worker w (128 bytes at 128w). Creator words: 0 assigned 311 seq, 8 job id, 16 input epoch, 24 input version (`node_count`), 32 interest 312 topics, 40 wake stamp. Worker words: 64 done seq, 72 outcome, 80 wakes, 313 88 last wake latency, 96 largest wake latency. Result bytes go in a 314 4096-byte outbox per worker. The worker writes them and the outcome before its 315 done seq. The creator writes a worker word (done seq) only after reaping that 316 worker, to retire its assignment. 317 318 Wake-ups are hints. The creator publishes or assigns first and posts the wake 319 second. The worker's wait drains the hint, then the worker re-reads its cell 320 and rescans before it waits again. A post that lands after the drain leaves the 321 eventfd readable, so the next wait returns at once: no wake-up is lost, and 322 several posts coalesce into one wake. 323 324 | Function | Contract | 325 | --- | --- | 326 | `sched_new c a rl` | Creator, before fork: map the scheduling page and outboxes; admission limit a and review limit rl, each 1..64. | 327 | `sched_admit id deps flags` | Slot, or -2 at the admission limit. deps 0: ready now; otherwise waiting for a publication whose topics meet deps. flags bit 0: safe to rerun after worker death. | 328 | `sched_want w topics` | Creator: publications meeting `topics` wake worker w. | 329 | `sched_publish c topics src n` | `pool_publish`, then waiting jobs whose deps meet topics become ready, subscribed live workers are woken, and ready jobs are dispatched. | 330 | `sched_step c interval` | Creator loop: wait for an ack or death, take acks, retire reaped workers' jobs (`sched_lost`), collect, dispatch. | 331 | `sched_dispatch c`, `sched_collect c` | Assign ready jobs to idle live workers; move finished results into review while there is room. | 332 | `sched_lost c w` | After a reap: a rerunnable job is ready again (attempt + 1); any other job becomes UNKNOWN and is never run again. A finished result is still collected. | 333 | `sched_review j`, `sched_settle j` | Accept a reviewed result (returns its outcome) or release an UNKNOWN job whose outcome was settled elsewhere. Effects are committed by `auth.om` (DRA-288); review only releases the job. | 334 | `sched_pause c on` | Pause (no job is assigned) or resume and dispatch. Returns the number dispatched. | 335 | `sched_cancel j` | 1 waiting or ready job freed, 2 running (the caller must tell its worker), 3 already in review, 4 UNKNOWN, -3 no such job. | 336 | `sched_stop c interval` | `sup_stop`, then retire every reaped worker's job. | 337 | `sched_wjob w`, `sched_wdone w q outcome src n`, `sched_wwait c w interval`, `sched_wscan c w` | Worker side: the pending assignment, the finish report (result, then outcome, then done seq, then ack), a wait that records wake latency, and a scan of subscribed versions in the held epoch. | 338 339 A worker's scan cursor follows the current epoch. If an epoch it never held is 340 reclaimed, the worker never receives the versions published in it. Consumers 341 that need every version must be assigned work rather than relying on 342 subscriptions alone. 343 344 ### Acceptance and controls 345 346 The gate covers the following phases: 347 - Irrelevant topics wake nobody. 348 - 30 relevant publications reach two subscribers in full; a lazy subscriber needs exactly 2 wakes. 349 - Six fast jobs finish and are reviewed while a slow job still runs. 350 - Admission refuses the 9th job and review holds at 2. 351 - A dependency topic starts a waiting job and another topic does not. 352 - Two workers are killed mid-job. The rerunnable job runs again elsewhere (attempt 2); the other becomes UNKNOWN. 353 - Stop under load: 8 admitted and 3 running jobs; everything finishes in under 1 s with 3 UNKNOWN and 5 still ready. 354 - Idle CPU and wake-ups: 355 - Two idle workers and the creator use at most 2 clock ticks while the creator waits 2 s. 356 - In 200 publication rounds, each worker wakes exactly once per round. 357 358 | Change | Expected exit | 359 | --- | --- | 360 | `sched.om`: `if ne and sc_cell w 32 topics 0` to `if true` (interest ignored) | 16 | 361 | `sched.om`: delete the `sc_wake w` after `sc_set w 0 q` (no wake on assignment) | 34 | 362 | `sched.om`: `if ge sched_count 4 4 get sclim 1` to `if false` (review unbounded) | 50 | 363 | `sched.om`: `if ge sched_count 1 3 get sclim 0` to `if false` (admission unbounded) | 48 | 364 | `sched.om`: `put sjst j 6` to `put sjst j 2` (UNKNOWN job rerun) | 83 | 365 | `sched.om`: delete `sc_set w 64 get scseq w` (dead worker's assignment not retired) | 92 | 366 | `sched.om`: `put sjst j 1` to `put sjst j 2` (dependencies ignored) | 68 | 367 | `super.om`: `iv = interval` to `iv = long 0`, run with `idle` (workers spin) | 138 | 368 369 ## Resource-aware selection (P-DRA-14) 370 371 Owner: the adaptive scheduling lane, [P-DRA-14](https://linear.app/drake-stapleton/project/aien-adaptive-scheduling-feasible-work-and-fair-progress-`f20e588c68cd`) 372 (DRA-395 to DRA-399). It owns selection policy, fairness, reservation and 373 ranking in `sched.om` and `schedpol-test.om`; transport, pool, supervision, 374 authority, journal and the workflow stay with their DRA-286..290 owners. 375 There is one scheduler: these are policies of `sched_dispatch`, not a second 376 dispatcher. 377 378 Status: IMPLEMENTED: resource requests, capacity admission and policy 0, FIFO 379 head-of-line, which reproduces the stop rule of the reference pump (DRA-395); 380 policy 1, fair fitting with reservation, admission tickets and leases, the 381 default (DRA-396); policy 2, goal-aware ranking with coalesced rescoring and 382 versioned proposals (DRA-397). The head-of-line regression fails under policy 383 0 and passes under policies 1 and 2. 384 385 ```sh 386 cat seed/node/transport.om seed/node/pool.om seed/node/super.om seed/node/sched.om seed/node/schedpol-test.om > build/node/schedpol-composed.om 387 cmp build/node/schedpol-composed.om seed/node/schedpol-gate.om 388 seed/out/omc < seed/node/schedpol-gate.om > build/node/schedpol-gate 389 chmod +x build/node/schedpol-gate 390 timeout 300 build/node/schedpol-gate # policy 1: exit 0 391 timeout 300 build/node/schedpol-gate goal # policy 2: exit 0 392 timeout 300 build/node/schedpol-gate fifo # policy 0: exit 11, the blocked head 393 timeout 300 build/node/schedpol-gate noreserve # no reservation: exit 61, starvation 394 ``` 395 396 ### Reference pump and ownership 397 398 aien-dev/aien-sovereign-core-mv at ``dffdbd195edcbe1ec3bd2fa255355b15c530f31e``, 399 `crates/spark-harness/src/scheduler/core.rs` (blob ``32c3f431b58c``) `Core::pump` 400 fills a bounded ready queue in task-id order (lines 584-596), then dispatches 401 from its head while `PermitPool::try_acquire` succeeds (598-602); the first 402 head that does not fit ends the pump. A request over the limits is refused at 403 registration (`ExceedsCapacity`, 654-655 with `permits.rs` 51-54). 404 405 That pump is reference-only, not deployed and not yet superseded: 406 - `scheduler/mod.rs` (blob ``001db62c4f4a``) says it is opt-in (`ProvisionalConfig::enabled` false by default) and that no spark-harness API or MCP tool uses it. 407 - Its only consumer in that repository is the optional `aien-runtime` feature `provisional-prep` and that crate's tests. 408 - The installed `~/.local/bin/spark-harness` on the Spark (sha256 ``9fe2941155ca`…`, built 2026-09-18) offers `test`, `mcp`, `validate` and `eval` and contains no provisional-scheduler code; no spark-harness process runs. 409 410 `sched.om` becomes the forward owner when this stack merges and DRA-292 411 deploys it. Until then neither scheduler dispatches live hive work. 412 413 Call graph of the Omega side (one creator calls everything): 414 415 | Entry | Callers | 416 | --- | --- | 417 | `sched_dispatch` | `sched_step` (`code.om` `cw_drive`, tests), `sched_publish` (`code.om` `cw_issue`), `sched_pause` (`auth_pause`) | 418 | `sched_admit`, `sched_admitr` | `jn_admit` (`journal.om`, from `cw_issue`), the readmission in `jn_recover` | 419 | `sched_collect`, `sched_lost` | `sched_step`, `sched_stop` | 420 | `sched_cancel`, `sched_review` | `auth_cancel`, `jn_release` | 421 | `sched_wjob`, `sched_wdone` | the worker loops (`code.om` `cw_worker`, `cw_job`) | 422 423 The coding workflow keeps one inference in flight itself (`cw_plan`), always 424 starting with the lowest-numbered objective that needs a turn, above the 425 scheduler, which sees every job as one worker and no resource. 426 427 ### Resources and policy 0 428 429 A request is one ulong of four 16-bit counts: kind 0 CPU slots, 1 memory MiB, 430 2 inference slots, 3 caller-defined. Capacities default to 65535 of each, so 431 callers that declare nothing (`sched_admit`) always pass their own fit check 432 and are never refused for resources; under policy 0 they can still wait 433 behind a resource-blocked head. A job takes its whole need when it is 434 assigned and gives it back when its worker reports done (even while its 435 result waits for review room) or is reaped. Every job also needs one idle 436 live worker. A capacity is never set below the current use or below one 437 admitted job's need. 438 439 One behaviour changes for every caller: DRA-287 assigned ready jobs in slot 440 order, which is an accident of which slot was free; selection now follows a 441 policy. Phase F below is the case that differs: a job admitted first into a 442 lower slot but made ready later by a publication used to be assigned first; 443 under policy 0 the job that became ready first is. No consumer in this 444 directory depends on slot order (the DRA-287, DRA-288, DRA-289 gates and the 445 DRA-290 unit checks pass unchanged). 446 447 Policy 0 serves the ready job that became ready first, if it fits; when it 448 does not, nothing is assigned. That is the stop rule of the reference pump 449 (598-602): a head that does not fit holds back every later job. Its queue is 450 not reproduced. The pump batches newly eligible tasks in task-id order into 451 a queue of `queue_capacity`, so an eligible task can be left outside it 452 (scenario b of the Rust reproduction); here every admitted job is in the 453 table and ready order is the order of becoming ready. The bounded-queue 454 exclusion is therefore evidenced for Rust only. 455 456 | Function | Contract | 457 | --- | --- | 458 | `sched_admitr id deps flags req` | `sched_admit` with a resource request; -8 when a kind exceeds its capacity (counted, never queued). | 459 | `sched_cap caps` | Set every capacity; -8 and no change when a kind would fall below its use or below one admitted job's need. | 460 | `sched_policy p win db by ttl` | Policy 0, 1 or 2, candidate window 1..64 slots, dispatch budget 1..64 per event, bypass budget 1..65535, ticket lifetime 1..`1000000` dispatch events; -7 out of range. | 461 | `sched_stat i` | Counters 0..15 (10 tickets issued, 11 tickets lapsed, 12 leases overdue), capacity 16..19, use 20..23, policy words 24..31 (policy, window, budget, bypass budget, cursor, reserved slot + 1, tickets held, ticket lifetime), goal counters 32..40 (DRA-397). | 462 463 Admission order (`sjarr`) and ready order (`sjrdy`) are logical counters, so 464 selection never reads the clock. 465 466 ### Regression and controls 467 468 `schedpol-test.om` checks after every creator step that each kind's use is at 469 most its capacity and equals the needs of the running jobs that hold it, and 470 that every running job whose worker has not reported done holds its need. 471 472 | Phase | Scenario | Exit when it fails | 473 | --- | --- | --- | 474 | C | requests over CPU, memory or inference capacity refused (-8) and counted; lowering a capacity below an admitted need, or below the use of two running jobs that each fit it alone, refused with nothing changed | 30..41, 130..134 | 475 | D | 12 jobs with mixed needs on 3 workers, capacity 4 CPU, 1024 MiB, 1 inference: each runs once, all resources free at the end | 42..48 | 476 | V | review limit 1: both 1-CPU jobs finish, one result waits for review room, yet both CPUs are free and a 2-CPU job runs | 120..126 | 477 | F | order between a job admitted first but made ready later by a publication (x) and one ready earlier (y): policy 0 serves y (ready order), policy 1 serves x (admission age) | 50..57 | 478 | A | blocked head: a (3 CPU) runs, b (2 CPU) cannot fit, c (1 CPU) fits | 11 with the witness line | 479 | B | a second head-of-line case after the pump's queue-of-two scenario: a runs, b and d (2 CPU) wait, e (1 CPU) fits | 21 with the witness line | 480 481 A and B do not fail on a timeout alone. When the fitting job has not run 482 within 400 ms, the test checks, with no step in between, that a is running 483 and unfinished and holds its need, that the head is ready and does not fit, 484 that the job behind it is ready and fits, that a live worker is idle and that 485 dispatch stopped at the head; then it prints the witness and the phase 486 returns 11 (21). Both phases always run; the first failure is the exit. 487 Under policy 0 (`fifo`) the gate passes C, D, V and F and exits 11: 488 489 ``` 490 schedpol hol witness head=20050 fits_behind=30050 free_cpu=1 idle_worker=1 hol_stops=40 491 schedpol hol witness head=20050 fits_behind=50050 free_cpu=1 idle_worker=1 hol_stops=40 492 ``` 493 494 This is the block the Rust pump shows; its reproduction (test source, 495 command, output) is kept in `evidence/node-schedpol/rust-reference.*.json`. 496 497 | Change to `sched.om` | Expected exit | 498 | --- | --- | 499 | `if not sp_feas req` to `if false` (impossible requests admitted) | 31 | 500 | the `lt sp_need caps k get suse k` check of `sched_cap` made `if false` (capacity below use accepted) | 131 | 501 | `sp_take j` deleted from `sp_start` (running jobs hold nothing) | 130 | 502 | `sp_give j` deleted from `sched_collect` (resources never returned) | 133 | 503 | `sp_give j` moved after the review-room check in `sched_collect` (release waits for review) | 122 | 504 | `if gt sp_need req k a` to `if false` in `sp_fits` (capacity ignored) | 44 | 505 | `sp_ready j` in `sched_publish` to `put sjst j 2` (ready order not stamped; a policy-0 property, run with `fifo`) | 54 | 506 507 ### Policy 1: fair fitting with reservation (DRA-396) 508 509 Policy 1 is the default; policy 0 stays as the FIFO baseline for the 510 DRA-399 comparison. Both are arms of one `sched_dispatch`. 511 512 Each pick reads the reserved slot, if any, and otherwise scans at most 513 `win` slots (default 64) from a cursor that persists across picks and 514 dispatch events. After every window scan the cursor moves on by `win`, so 515 consecutive scans cover consecutive windows, also when one event picks 516 several times, and every slot is examined within ceil(64/`win`) window 517 scans. A pick that takes the reserved job scans no window. Among 518 the examined ready jobs the pick takes the one admitted first (`sjarr`: 519 unique, so no ties) that fits. At most `db` jobs are assigned per event. 520 After each event one pass over the table counts bypasses and picks a 521 reservation (64 maintenance reads). Waiting age is the admission 522 order, kept when a rerunnable job goes back to ready after its worker died. 523 Under policy 1 phase F serves the job admitted first. 524 525 A ready job admitted before the youngest job assigned in an event was 526 bypassed once. With no reservation, the oldest ready job at the bypass 527 budget `by` (default 4) is reserved. The reserved job is offered first; 528 while it does not fit, every other pick may use, of each kind, only the free 529 capacity beyond what the reserved job needs. Of each kind, 530 min(free, reserved need) therefore never falls, and the reserved job runs as 531 soon as running work has released enough. Assignment or cancellation of the 532 reserved job ends the reservation. 533 534 Liveness rests on these assumptions: every running job ends (completes, or 535 its lease is enforced by the authority); at least one worker stays live; 536 results in review are eventually reviewed, so a worker holding a finished 537 result while review is full is eventually freed (phase Z shows the reserved 538 job waiting on review, then running); dispatch is eventually unpaused and 539 keeps getting opportunities while ready jobs remain (every `sched_step` 540 collects, then dispatches, so the creator loop must keep stepping, also 541 after a window scan that found nothing and with no running job left to 542 release anything); a job that is safe to rerun is not lost to worker deaths 543 forever (each attempt ending is not enough: some attempt must settle); no 544 request exceeds capacity (refused at admission, -8). Under them a reserved 545 job runs once the jobs running at its reservation have finished and a 546 worker is free, and each ready job is examined within ceil(64/`win`) window 547 scans. There is one reservation at a time, and it goes to the oldest job at 548 the bypass budget. A job at the budget therefore waits only for the 549 reservations of jobs admitted before it, a finite set; later arrivals never 550 take the reservation first. Workers are not a resource kind: the reserved 551 job is offered first at every pick, so it takes the first idle worker once 552 it fits. This is an argument from the source under the stated assumptions; 553 the phases exercise the supplied finite workloads (phase S among them) and 554 are not a proof for arbitrary workloads. 555 556 Admission tickets. Room is the smaller of the admission headroom and the free 557 table slots: a job in review or UNKNOWN keeps its slot, so a table full of 558 unreviewed results refuses admission even below the limit. `sched_room id` 559 refuses without room and gives the refused caller a ticket. While tickets 560 are held only the first holder may enter, whatever the room; a new caller 561 takes a ticket behind them. `sched_admitr` asks it; so does `jn_admit`, 562 after its duplicate check and before it journals ADMIT, and a true answer 563 guarantees the slot (one creator, no other admission in between). Every 564 ask by a ticket holder renews its ticket, whether it is refused or told 565 yes (a caller with room and no ticket gets none). A ticket not asked about 566 for more than `ttl` dispatch events (default 1000) lapses: asked at event 567 e, it survives while e + `ttl` is at least the current event count. A 568 caller that went away therefore blocks later holders for at most `ttl` 569 events; a paused dispatch counts no events, so that block lasts until 570 dispatch resumes. At most 64 tickets are held, and a caller refused with 571 the line full holds none. 572 573 Leases. `sched_lease j ns` gives a waiting or ready job a lease counted from 574 its next assignment; on a running job it replaces the lease, measured from 575 now. `ns` is at most 2^50 ns (about 13 days; Wolfram 576 `UnitConvert[Quantity[2^50,"Nanoseconds"],"Days"]` -> 13.03 days): a larger 577 value is refused (-7) and nothing changes. The monotonic clock is below 578 2^63, so every deadline, clock plus `ns`, stays below 2^63 + 2^50 < 2^64: 579 it never wraps into the past or onto 0, the no-deadline value. Assignment 580 and reassignment use the stored, already checked duration. 581 `sched_overdue` reports a running job past its lease whose worker has not 582 reported done, once. The authority then cancels or kills it, and the release 583 follows from the worker's report or the reap. The lease is a clock reading 584 used for reporting only; selection reads logical counters. 585 586 | Function | Contract | 587 | --- | --- | 588 | `sched_room id` | May id be admitted now: room is min(admission headroom, free slots); while tickets are held only the first holder may enter. A refused caller gets or keeps a ticket; every ask by a holder renews its ticket. | 589 | `sched_lease j ns` | Lease for a waiting, ready or running job, from its next assignment (running: from now); 0 removes it; -3 for a slot not waiting, ready or running; -7 for ns above 2^50; a refusal changes nothing. | 590 | `sched_overdue` | Slot of a running, unfinished job past its lease, reported once; 64 when none. | 591 592 `schedpol-gate` takes one optional argument: `fifo` runs every phase under 593 policy 0, `noreserve` sets the bypass budget to 65535 (no reservation in 594 practice). Each step also checks the bounds since the last step. An event 595 makes at most one pick more than it assigns, so candidate reads are at most 596 (assigned + events) × (`win` + 1), the reserved probe included, × (`win` + 2) 597 under policy 2 (one proposal probe per pick), or × 64 under policy 0, exit 9; 598 maintenance reads at most 64 per event, exit 14; the 599 cursor moved by exactly `win` per window scan (mod 64), exit 15. The cursor 600 check is the traversal witness. It runs at every step of every phase and 601 around the dispatches that publication (phase F) and resume (phase Z) cause 602 outside a step. These checks read the scheduler's own counters, so they 603 bound the work the counters record; they are not an independent trace of 604 which slots were read. 605 606 | Phase | Scenario | Exit when it fails | 607 | --- | --- | --- | 608 | S | three workers, 4 CPU; 1-CPU jobs start staggered and each one finishing is replaced, so the CPUs are never all free at once; big (4 CPU) arrives: it is reserved and runs | 61 never ran (the `noreserve` control), 62..66 | 609 | Q | admission limit 2: X then Y refused hold tickets; with room for one, Y is refused and X admitted; Y enters later; a ticket not asked about lapses, so a new caller enters | 70..80 | 610 | L | 200 ms lease on a 3 s job not safe to rerun: the deadline is at least 200 ms after admission and the report comes at or after it, once; worker killed, job UNKNOWN, CPU free. A rerunnable job killed the same way keeps its admission age and completes | 81..89, 140..145 | 611 | R | the reserved job is cancelled: freed with no effect, reservation cleared | 90..97 | 612 | W | window 4, budget 2, two workers (an event may pick twice), 12 ready jobs in slots 0..11: every pick reads at most 5 slots, every scan moves the cursor on by 4, and all 12 run | 9, 15, 101..103 | 613 | T | limit 3 held by two short jobs and one waiting on a topic nobody publishes, three ticket holders; with exactly two openings the second holder and a new caller are refused, the first two holders enter in order; the waiting job is cancelled, and with three openings the new caller (now a holder) waits for the holder ahead | 104..109 | 614 | X | every slot holds a job in review, admission limit not reached: a new caller is refused and holds a ticket; one review frees one slot, which goes to the first holder | 190..194 | 615 | Z | review limit 1 and full; a reserved job is ready at every step for 600 ms while the workers hold finished results, and all CPU is free at the end of that interval; reviewing lets it run | 195..199 | 616 | M | lease bounds: 2^50 + 1 and 2^64 - 1 refused (-7) on a waiting and on a running job with lease and deadline unchanged; 2^50 accepted on both, the running job's deadline ahead of the clock and nothing overdue; a running renewal to 2^49 puts the deadline between clock + 2^49 read just before and just after the call; the job completes | 200..207 | 617 | N | admission limit 1, ticket lifetime 2: X, refused at event e, asks at e + 1 and is told yes; at e + 3 its renewed ticket still holds and newcomer Y is refused; at e + 4 it lapses (one lapse) and Y is admitted | 210..212 | 618 | U | four idle workers, dispatch budget 2, six ready 1-CPU jobs on 4 CPU: one dispatch assigns exactly 2; all six complete | 220, 221 | 619 620 Phases S to U run after A and B, so under `fifo` the gate stops at 11. 621 `journal-gate` case 17 checks `jn_admit` at the admission limit: a duplicate 622 id is refused as a duplicate and takes no ticket (185..188). Case 18 checks 623 a full table below the limit: 64 jobs put in UNKNOWN directly (synthetic 624 occupancy, the state a worker loss leaves a job not safe to rerun in; 625 nothing is spawned and no recovery runs). A new id is refused with a 626 ticket, the journal does not grow, and the independent journal reader finds 627 no ADMIT for it; after one slot is settled the same id is admitted and 628 journaled once (189..192). These were cases 16 and 17 with checks 170..177 629 before this branch moved onto omega-node's DRA-292 head, whose RESULT case 630 holds number 16 and checks 170..184. 631 632 | Change | Expected exit (derived from the check it trips) | 633 | --- | --- | 634 | cursor never moves (`put scpol 4 …` deleted from `sp_fair`) | 15: the first window scan in W leaves the cursor where it was | 635 | cursor moves by 1 instead of `win` (`rem add cur win 64` to `rem add cur 1 64`) | 15 | 636 | tickets ignored (`if eq get scpol 6 0` to `if true` in `sched_room`) | 75 | 637 | holders below the room may enter (`if eq t 0` to `if lt t room`) | 105 | 638 | room ignores free slots (`if lt fs room` to `if false`) | 191 | 639 | no hold-back for the reserved job (`rq = get sjneed rj` to `rq = ulong 0`) | 61 | 640 | never reserve (`put scpol 5 add o 1` deleted) | 61 | 641 | lease never reported (`if ge now d` to `if false`) | 82 | 642 | lease reported 100 ms early (`if ge now d` to `if ge add now `100000000` d`) | 83 | 643 | cancel keeps the reservation | 94 | 644 | window ignored (`for i ulong win` to `for i ulong 64` in `sp_fair`) | 9 | 645 | tickets never lapse | 80 | 646 | `jn_admit` asks for room before the duplicate check (`journal.om`) | 185 (`journal-gate`) | 647 | `jn_admit` skips the room check (`journal.om`) | 188 (`journal-gate`): case 17 journals ADMIT for the refused id, so its later admission is refused as a duplicate | 648 | the same, with case 17 not run | 190 (`journal-gate`): case 18's refused admission grows the journal | 649 | FIFO counts 3 per slot read (`sp_fifo`), run with `fifo` | 9: the first FIFO pick reads more than 64 per pick allows | 650 | lease duration unbounded (the 2^50 check deleted from `sched_lease`) | 200: 2^50 + 1 is accepted on waiting job w | 651 | lease stored before the bound check | 200: the refusal returns -7 but w's lease is no longer 0 | 652 | running renewal is a no-op (the `if eq s 3` deadline block deleted from `sched_lease`) | 206: the deadline stays near assignment + 2^50, above clock + 2^49 | 653 | a successful ask does not renew the head holder's ticket | 211: X's ticket lapses at e + 3 and newcomer Y is admitted | 654 | dispatch budget ignored (`for i ulong get scpol 2` to `for i ulong 64`) | 220: one dispatch assigns 4 | 655 656 ### Policy 2: goal-aware ranking and replanning (DRA-397) 657 658 Policy 2 is policy 1 with a different order among the examined jobs that 659 fit. The reservation, the hold-back, feasibility and the bypass budget come 660 first, unchanged, so ranking cannot starve old work: a job ranked low is 661 bypassed, reaches the bypass budget and is reserved like under policy 1. 662 Authority checks stay where they are (`sched_pause`, `auth.om`). Policy 1 663 stays the default until DRA-399's matched comparison shows otherwise. 664 665 Inputs: `sched_goal j pro est unc` declares, for a waiting or ready job, the 666 topics its completion will publish (`pro`), its work estimate in ms (`est`, 667 declared, or derived by the caller from its own measurements) and that 668 estimate's uncertainty in ms (`unc`, recorded, not used to rank). They are 669 estimates: they order ready jobs and nothing else. Nothing is learned. 670 671 Key, in order: larger unblock value, smaller estimate, older admission 672 (`sjarr`, unique, so there are no ties). The unblock value of a ready job, 673 in jobs, is the number of waiting jobs whose deps meet its declared topics 674 (depth 1) plus the waiting jobs whose deps meet the topics those declare 675 (depth 2), each counted once. Lookahead stops at depth 2: at most 128 slot 676 reads per job scored plus 64 per rescoring (the pass that finds ready 677 jobs), counted in `sched_stat 38` and checked at every step (exit 8). A 678 proposal adds one candidate read per pick, so under policy 2 a pick reads 679 at most `win` + 2 slots (exit 9). 680 681 Replanning. Every committed change that can alter a value bumps the graph 682 version: a job becomes ready (admission, publication, rerun after a worker 683 death), a waiting job is admitted, a waiting or ready job is cancelled, a 684 declaration changes. While the version is not exhausted, values are 685 recomputed only at a policy-2 ranking pass whose version differs from the 686 last scoring, once however many bumps came before it. Bumps therefore 687 coalesce and none is lost, because the version is a counter, not a flag. A 688 pick that takes the reserved job ranks nothing and scores nothing. 689 Completions, failures, resource releases and lease expiry replan without 690 rescoring: every step collects, then dispatches with the current values, and 691 none of those events changes a value. No step waits for other workers and no 692 model is called. 693 694 Proposals. `sched_propose id v` lets an outside planner or an operator put 695 the ready job whose id is `id` first, computed at graph version `v` 696 (`sched_version`). The proposal names the job, not its table slot. It is 697 refused until the scheduler has an incarnation and once its version is 698 exhausted (-6), when `v` is not current (-9, counted stale), when no ready 699 job or more than one has that id (-3) or when the job does not fit beside 700 the reservation (-8). It is used once, at the next pick, after the 701 reservation, and only if the version is still `v` and not exhausted, the 702 job is still ready and it still fits; otherwise it is dropped and counted 703 stale. Within one scheduler every admission, cancellation of a waiting or 704 ready job and readiness bumps the version, so a job that leaves the ready 705 state and a new occupant of its slot are both seen. Across schedulers the 706 version carries the incarnation: `sched_incarnate n` (once, after 707 `sched_new`, n in 1..2^24 - 1, distinct per scheduler; DRA-398 uses the 708 journal fence) makes the version n × 2^40 plus the bumps since. The last 709 scoring stays below that, so jobs admitted or declared before a late 710 incarnation are rescored at the next ranking pass. 711 The bump that would reach 2^40 does not carry into the next incarnation's 712 range: the version stays and is exhausted, proposals are refused for the 713 rest of that scheduler and every ranking pass rescores, since the version no 714 longer tells whether the inputs moved. 715 716 | Function | Contract | 717 | --- | --- | 718 | `sched_goal j pro est unc` | Declare topics, estimate (ms) and its uncertainty (ms) for a waiting or ready job; 0 or -3. | 719 | `sched_version` | The graph version. It moves on admission, a job becoming ready, cancellation and `sched_goal`, and on nothing else (not on completions, releases, lease expiry, `sched_cap` or `sched_policy`); it versions the inputs of ranking and proposals, not the whole scheduler state. | 720 | `sched_incarnate n` | Set the incarnation (1..2^24 - 1), once: the version becomes n × 2^40, a pending proposal is dropped, values are rescored at the next ranking pass and proposals are accepted; 0, or -7 (out of range, already set, or exhausted). | 721 | `sched_propose id v` | Propose the ready job with id `id` at version v; 0, -6 no incarnation or exhausted, -9 stale, -3 no ready job or more than one has that id, -8 does not fit beside the reservation, -7 not policy 2. | 722 | `sched_stat 32..41` | Rescorings, jobs scored, version bumps, proposals accepted, stale, refused, value slot reads, proposals used; 40 the graph version; 41 the proposal state (0 no incarnation, 1 accepting, 2 exhausted). | 723 724 `schedpol-gate goal` runs every phase under policy 2 (exit 0). Phases G, H, 725 P, I, R2, X, L and K set policy 2 themselves and run after W in the default and 726 `goal` modes; the `fifo` and `noreserve` controls stop at their earlier 727 expected failures (11 and 61), so they never reach these phases. Every 728 dispatch a phase causes outside a creator step (resume, publication) is 729 bracketed by the same step bounds. 730 731 | Phase | Scenario | Exit when it fails | 732 | --- | --- | --- | 733 | G | one worker, bypass budget 4, ten jobs admitted while paused: x (value 0), z (unblocks d: 1), a (unblocks b, which unblocks c: 2), f (unblocks g1..g3: 3); decisions made before each finished job publishes. Order f a z b x d c g1 g2 g3: useful work first, x reserved after four bypasses. Run twice: identical decisions | 150, 151 first run, 152 second | 734 | H | four graph changes while paused, one rescoring at the first pick; a completion with nothing published, no rescoring; a publication readying two jobs, one rescoring; cancelling a waiting job is one change | 160..166 | 735 | P | a stale proposal is refused and counted; one naming an id with no ready job is refused; a current one is used over a higher-ranked job; one made stale by a later change is rejected at use and counted; -7 outside policy 2 | 170..178 | 736 | I | scheduler 1 (incarnation 1) hands out a version for job a in slot 0; scheduler 2 (incarnation 2) puts job b in slot 0 with as many bumps: the old version is stale, a's id names no job, b's proposal is accepted, incarnation 0 is refused | 184, 185 | 737 | R2 | 5 CPU, bypass budget 1: with B (4 CPU) reserved, x (2 CPU) is refused beside it; cancelling B clears the reservation and x is accepted; an event with no idle worker reserves B2 and keeps the proposal; at the next pick x no longer fits beside B2, so the proposal is dropped and counted stale and x stays ready; once B2 fits, y (1 CPU) is accepted beside it and at the next event B2 runs first, then y is used, and x, bypassed by y, becomes the reservation | 186..189, 179 | 738 | X | no incarnation: a proposal is refused; a second incarnation is refused; after the first a proposal is accepted and used. At the last revision of incarnation 5 a proposal is accepted, the next bump exhausts the version instead of reaching incarnation 6, proposals are refused, the pending one is dropped at use and every pick rescores. Two ready jobs sharing an id: a proposal naming it is refused | 120..127 | 739 | L | one worker, paused: an older unrelated job, a younger producer declaring a topic and a job waiting on it are admitted and declared, then the scheduler incarnates; at resume the producer runs | 128 | 740 | K | the key on two slots: value before estimate before age; outside policy 2 age only | 180..183 | 741 742 | Change to `sched.om` | Expected exit (derived from the check it trips) | 743 | --- | --- | 744 | goal off (`if goal` to `if false` in `sp_better`) | 151: x runs first | 745 | depth 2 ignored (its count never incremented in `sp_value`) | 151: a and z tie, z older runs second | 746 | rescore every pick (version check removed in `sp_rescore`) | 162 | 747 | becoming ready does not bump (`sp_bump` removed from `sp_ready`) | 151: b keeps value 0, x runs fourth | 748 | waiting admission does not bump | 160 | 749 | cancellation does not bump | 165 | 750 | proposal version unchecked at `sched_propose` | 170 | 751 | proposal version unchecked at use (`sp_proposal`) | 176 | 752 | estimate ignored in the key | 181 | 753 | incarnation ignored (`sched_incarnate` leaves the version at 0) | 184: both schedulers reach version 1, so the old version is current | 754 | proposal fit not rechecked at use (`sp_proposal`) | 189: x is used beside B2 | 755 | proposals accepted without an incarnation (state check removed in `sched_propose`) | 120 | 756 | incarnation set twice (once check removed in `sched_incarnate`) | 121 | 757 | version carries into the next incarnation (saturation removed in `sp_bump`) | 123: the version moves to 6 × 2^40 | 758 | exhausted version not checked at use (`sp_proposal`) | 125: the pending proposal still names the stuck version and is used | 759 | exhausted version trusted by `sp_rescore` | 126: the second pick does not rescore | 760 | an id shared by two ready jobs accepted (`sched_propose` takes the last) | 127 | 761 | incarnation marks the values scored (`sched_incarnate` sets the last scoring to the new version) | 128: the values stay 0, so the key falls to the estimate and the unrelated job (no estimate) runs | 762 763 ### Receipt driver (schedrcpt.om) 764 765 `schedrcpt.om` produces the scheduler-policy receipts. It is a seeded Omega 766 program: `json.om` is appended for the JSON reader, and the SHA-256 functions 767 are copied from `om/sha256/sha256-om2.om` (lines 21-317 at `7f4e1a44`). Build it 768 with the in-tree compiler: 769 770 ``` 771 mkdir -p build/node 772 cat seed/node/schedrcpt.om seed/json/json.om | seed/out/omc > build/node/schedrcpt 773 chmod 755 build/node/schedrcpt 774 ``` 775 776 With omc `5f90edea` this gives a driver binary of sha256 ``ece552af`...`, the 777 `script.binary_sha256` in every receipt under `evidence/node-schedpol/` written 778 since the driver replaced the Python one. 779 780 The case files are in `seed/node/schedrcpt-cases/`, one per issue: 781 `cases-395n.json` (DRA-395) through `cases-399n.json` (DRA-399). Each receipt 782 embeds the case file it ran (`script.cases`) and its sha256 783 (`script.cases_sha256`). The receipts of the stack's current heads name these 784 files' hashes; older receipts in `evidence/node-schedpol/` ran earlier 785 versions of the cases, which they carry in full. To rerun a receipt, check out 786 the commit it names into a clean worktree and run, from that worktree's root: 787 788 ``` 789 DRIVER_TREE/build/node/schedrcpt DRIVER_TREE/seed/node/schedrcpt-cases/cases-398n.json evidence/node-schedpol --write 790 ``` 791 792 Run it from the root of the checkout under test. That checkout may differ from 793 the one holding the driver: 794 795 ``` 796 DRIVER_TREE/build/node/schedrcpt CASES.json OUTDIR_REL [--write] 797 ``` 798 799 The driver finds its source, `DRIVER_TREE/seed/node/schedrcpt.om`, from 800 argv[0], so the path must end in `build/node/schedrcpt`. It refuses before 801 compiling anything in three cases: 802 803 - **Dirty tree:** `git status --porcelain` shows a change outside `build/`. 804 Exit 3. 805 - **Bad mutation:** a mutation names a file that is not one of the case's 806 fragments, or its pattern does not occur exactly once. Exit 4. 807 - **Gate mismatch:** a gate case without mutations is not the exact 808 concatenation of its `compose` list. Exit 5. 809 810 Otherwise the driver creates `build/node` in the checkout under test (the 811 build step above; gates keep their journals and work directories below it, 812 and `jn_open` creates only the last directory of its path), compiles each 813 case, runs it `repeat` times and prints one line per case: `PASS|FAIL CASE 814 expect=N got=CODE`, or `FAIL CASE expect=N compile=E` when the case does not 815 compile. It then writes the receipt and exits with 0 if every case passed and 816 1 if any failed. Usage and I/O errors exit 2, as does a failure to create 817 `build/node`. 818 819 - With `--write`, the receipt goes to `OUTDIR_REL/receipt..json`; the 820 driver refuses to overwrite an existing file and prints the path. 821 - Without `--write`, it goes to `/tmp/sched-receipt-.json`. 822 823 The case-file format, the checks and the receipt layout follow the earlier 824 Python driver `receipt.py` (kept outside this repository, in the sched lane's 825 hand-off folder). That driver produced the DRA-395/396 and DRA-397 r1 826 receipts; this program replaces it. The Python driver is kept only as an 827 ORACLE for cross-checks and is not part of the build or receipt path. The 828 receipt differs from the Python driver's output in these ways: 829 830 - **Script fields:** `script.path` is `seed/node/schedrcpt.om`, and 831 `script.binary_sha256` records the driver binary. 832 - **Numbers:** numbers copied from the case file keep their written form, so 833 `2.50` stays `2.50` where Python writes `2.5`. 834 - **Output tails:** `stdout` (4000) and `stderr` (2000) are measured in bytes, 835 and the cut moves forward to a UTF-8 boundary. Python counts characters 836 after decoding. 837 - **Process handling:** a gate runs with stdin on `/dev/null` in its own 838 process group. That group is killed at the timeout and again after the gate 839 exits. 840 - **Work directory:** `/tmp/schedrcpt-` is removed at the end and on 841 every refusal. 842 - **Build directory:** the driver creates `build/node` in the checkout under 843 test; the Python driver did not. 844 - **Compile failures:** the driver prints a `FAIL ... compile=E` line; the 845 Python driver printed nothing for such a case, though both count it as a 846 FAIL. 847 848 Limits; exceeding any of them exits 2: 849 850 | Item | Limit | 851 | --- | --- | 852 | Case file | 983039 bytes | 853 | Each composed source, fragment and the receipt | 16 MiB | 854 | Entries in each list | 2048 | 855 | Each string | 64 KiB | 856 | `repeat` | 65536 | 857 | Strings held at once (case values, output tails) | 65536 strings, 4 MiB in total | 858 859 If the driver itself is killed (SIGTERM or SIGKILL), the gate running at that 860 moment keeps running in its own process group, and the work directory stays. 861 Kill that group (`pkill -f /tmp/schedrcpt-/`) and remove the directory. 862 The driver cannot clean up itself: seeded Omega has no host word for 863 `sigaction` or `prctl(PR_SET_PDEATHSIG)`. Proposed extension: a host word 864 `pdeathsig sig` (prctl option 1), called in the forked child before 865 `execprog`, so the kernel signals each gate when the driver dies. Observed on 866 2026-11-07, when a DRA-398 receipt run was stopped by hand. 867 868 ## Proposals, authority and cancellation (DRA-288) 869 870 Status: IMPLEMENTED in `auth.om`, exercised by `auth-gate.om` and the controls 871 below on native Linux AArch64, with real forked workers running real child 872 tools (`/bin/sh`). Evidence is in the DRA-288 pull request. 873 874 ```sh 875 cat seed/node/transport.om seed/node/pool.om seed/node/super.om seed/node/sched.om seed/authority/action.om seed/node/journal.om seed/node/auth.om seed/node/auth-test.om > build/node/auth-composed.om 876 cmp build/node/auth-composed.om seed/node/auth-gate.om 877 seed/out/omc < seed/node/auth-gate.om > build/node/auth-gate 878 chmod +x build/node/auth-gate 879 timeout 120 build/node/auth-gate # ends "PASS node authority" 880 ``` 881 882 ### Model 883 884 A worker proposes; the creator alone decides and commits. Every effect is one 885 action record of `seed/authority/action.om`, keyed by its operation identity: 886 `actstart` when the creator grants it, `actrecon` with the worker's reported 887 outcome, `actlost` when the worker dies with it in flight. A performed 888 operation is never started again, and an UNKNOWN one is never retried (verdict 889 7); `actstart` enforces both, and the attempt limit (verdict 8). 890 891 A proposal (words 0..15 of the worker's 4096-byte proposal page) is typed 892 (version 1, kind 1) and carries the job id and assignment seq, the worker 893 slot and incarnation, the input epoch and version it read, the authority 894 generation it holds, the 4-word operation identity and the effect class 895 (1 external effect, 2 none). The creator refuses it, in this order, when it 896 is malformed (1), not the worker's current assignment (2), from another 897 incarnation of the slot (3), stale (4: the input differs from the assignment, 898 the epoch was rolled, or a newer version was published on one of the job's 899 dependency topics), under a revoked generation (5), or for a job being 900 cancelled (6). A refused job finishes with outcome 16 + verdict. 901 902 A granted tool runs as the leader of its own process group (both sides call 903 `setpgid`), stdin on `/dev/null`, output into the proposal page from byte 128. 904 Cancellation of its job, authority revocation, stop or creator loss make the 905 worker SIGKILL the whole group. The outcome comes from the wait status alone: 906 a tool that exited is performed (2), even if a cancel raced its exit; a killed 907 tool with an external effect is UNKNOWN (0); a killed class 2 tool is not 908 performed (1). Group members left behind are killed either way. If the worker 909 dies, the creator kills the tool group named in the worker's cell and records 910 the action UNKNOWN. 911 912 Control reaches a worker through its own control eventfd, in addition to the 913 wake and stop eventfds, so a worker waiting for a decision or running a tool 914 handles it at once. Each control carries a seq the worker acknowledges, with 915 the paused flag it saw. Pause stops both assignment and decisions; running 916 tools go on. Revocation moves the generation on: pending proposals under the 917 old one are refused, running granted tools are cancelled, and a report already 918 made is still recorded as made. 919 920 Control page cell of worker w (128 bytes at 128w). Creator words: 0 control 921 seq, 8 cancel target (assignment seq), 16 decided proposal seq, 24 verdict, 922 32 generation at the decision. Worker words: 64 control ack, 72 proposal seq, 923 80 report seq, 88 outcome, 96 tool wait status, 104 paused as seen, 112 tool 924 process group, 120 tool output bytes. Words 8192 and 8200 mirror the 925 generation and the paused flag. 926 927 | Function | Contract | 928 | --- | --- | 929 | `auth_new c`, `auth_free` | Creator, after `sup_init` and before any spawn: map the control and proposal pages and one control eventfd per slot; generation 1. | 930 | `auth_spawn c w` | `sup_spawn` with a new incarnation of slot w. | 931 | `auth_step c` | After `sched_step`: record reports, close the actions of reaped workers (`actlost`, tool group killed), decide pending proposals unless paused. | 932 | `auth_revoke c`, `auth_pause c on`, `auth_cancel c j` | The operator controls: new generation; pause or resume; cancel a job (`sched_cancel`, then the worker's control for a running one). | 933 | `auth_act op i`, `auth_cell w off`, `auth_wout w dst` | Read an action record word, a control cell word, a worker's tool output. | 934 | `auth_propose w q op class`, `auth_wdecide c w q interval` | Worker: propose, then wait for the verdict while handling control. | 935 | `auth_wtool c w q pk pn class`, `auth_wreport w q outcome` | Worker: run the granted tool (packed argv as `execprog`), report its outcome. | 936 | `auth_wwait c w x interval`, `auth_wctl w` | Worker wait on wake, stop, creator loss, control and optionally fd x; the control handler (ack, paused, cancel target). | 937 938 Limits: without an open journal (the DRA-288 gate) action records live in 939 creator memory only; `journal.om` makes them durable (DRA-289). Between a worker's death and the 940 creator's `auth_step` the tool's group id could in principle be reused; the 941 window is one creator step. At most 64 action records are live. 942 943 ### Acceptance and controls 944 945 Job id = kind × 1000 + operation number. The gate covers the following 946 phases: 947 - A: a granted operation runs once and is performed; the same operation in a new job is refused (7) and its tool does not run again. 948 - B: a proposal is refused as stale (4) after a newer version on its dependency topic or an epoch roll; a newer version on another topic does not make it stale. 949 - C: forged incarnation, job id and version are refused (3, 2, 1) and no tool runs. 950 - D: revocation before the decision refuses (5). Revocation during a tool kills its grandchild and records UNKNOWN; the operation is then refused (7). Revocation after the tool reported still records performed. 951 - E: cancel before start frees the job with no action record. Cancel during a tool kills its grandchild and records UNKNOWN. Cancel in review changes nothing. A cancel 200 ms after the tool's own process exited, while its grandchild still held the output, records performed and still kills the grandchild. 952 - F: a worker killed mid-tool: the creator kills the tool's group and the action and job are UNKNOWN. 953 - G: pause is acknowledged by every worker within 1 s; while paused a pending proposal stays undecided and a ready job is not assigned; resume performs both. 954 955 | Change | Expected exit | 956 | --- | --- | 957 | `auth.om`: delete both `setpgid` calls (no process group) | 58 | 958 | `auth.om`: `r = killpid neg int pid 9` to `r = killpid int pid 9` (direct kill only) | 58 | 959 | `auth.om`: a killed tool always reports UNKNOWN (`if k` / `ret 0` before `ret au_outcome st class`) | 85 | 960 | `auth.om`: `ret ne node_next h au_pw w 7 t 0` to `ret false` (newer input ignored) | 27 | 961 | `auth.om`: `if ne au_pw w 8 get augen 0` compares the proposal with itself (generation ignored) | 52 | 962 | `auth.om`: `if ne au_pw w 5 get auinc w` compares the proposal with itself (incarnation ignored) | 40 | 963 | `auth.om`: in `au_commit`, `k = au_find op` to `k = neg long 1` (duplicate performed) | 17 | 964 | `auth.om`: delete `au_ctl w au_cell w 16` in `auth_revoke` (running tools not cancelled) | 55 | 965 | `auth.om`: delete `au_ctl w sc_cell w 0` in `auth_cancel` (worker never told) | 75 | 966 | `auth.om`: delete `x = killpid neg int p 9` in `au_lost` (dead worker's tool left running) | 96 | 967 | `auth.om`: decide proposals while paused | 120 | 968 | `sched.om`: `if ne get scpause 0 0` to `if false` (assign while paused) | 121 | 969 970 ## Durable journal and restart recovery (DRA-289) 971 972 Status: IMPLEMENTED in `journal.om` and `auth.om`, exercised by 973 `journal-gate.om` and the controls below on native Linux AArch64: a conductor 974 forks real creators (with real workers and `/bin/sh` tools), crashes them at 975 every boundary and restarts them. Evidence is in the DRA-289 pull request. 976 977 ```sh 978 cat seed/node/transport.om seed/node/pool.om seed/node/super.om seed/node/sched.om seed/authority/action.om seed/node/journal.om seed/node/auth.om seed/node/journal-test.om > build/node/journal-composed.om 979 cmp build/node/journal-composed.om seed/node/journal-gate.om 980 seed/out/omc < seed/node/journal-gate.om > build/node/journal-gate 981 chmod +x build/node/journal-gate 982 rm -rf build/node/jt 983 timeout 120 build/node/journal-gate # ends "PASS node journal"; uses build/node/jt 984 ``` 985 986 ### Journal 987 988 `DIR/journal` is a 64-byte header and then 128-byte records, little endian 989 64-bit words. Header: magic, format version 2 (1 in a journal a format-1 build 990 created, kept unchanged; see Compatibility), record size 128, the 4-word 991 objective identity, FNV-1a 64 of words 0..6. Record: type, seq (1, 2, 3, ... 992 without gaps), fence, 12 payload words, FNV-1a 64 of words 0..14. 993 994 | Type | Payload | Appended by | 995 | --- | --- | --- | 996 | 1 OPEN | pid, authority generation, scheduler policy version (`SPVER`; 0 in a format-1 incarnation) | `jn_open`, every creator incarnation | 997 | 2 ADMIT | job id, dependency topics, flags, resource request, table slot | `jn_admitr` (`jn_admit` with no request), before `sched_admits` | 998 | 3 START | operation identity, class, job id, attempt, generation | `au_decide`, after `actstart`, before the grant is published | 999 | 4 DONE | operation identity, outcome, job id, how (1 reported, 2 worker lost, 3 in flight at restart, 4 key present, 5 key absent, 6 no external effect) | `au_record`, `au_lost`, recovery | 1000 | 5 RELEASE | job id, outcome (300 cancelled) | `jn_release`, before `sched_review`; `auth_cancel` | 1001 | 6 REVOKE | new generation | `auth_revoke` | 1002 | 7 PAUSE | 1 paused, 0 resumed | `auth_pause` | 1003 | 8 CANCEL | job id | `auth_cancel`, before the worker is told | 1004 | 9 OPER | command id, op, target, 4 arguments, view version it was acknowledged at (DRA-291) | `jn_oper` | 1005 | 10 RESULT | objective index, result (1 PASS, else the failure), model turns (DRA-292) | the result the objective ended with, at most one per objective | 1006 | 11 POLICY | policy, window, dispatch budget, bypass budget, ticket lifetime, capacities: the whole setting, the last one wins | `jn_policy`, `jn_cap`, before `sched_policy`, `sched_cap` | 1007 | 12 GOAL | job id, topics, estimate ms, uncertainty ms | `jn_goal`, before `sched_goal` | 1008 | 13 FAIR | dispatch event, assigned slot bitmap, bypassed slot bitmap, cursor, reserved slot + 1 | `jn_drain`, from `sched.om`'s replay ring | 1009 | 14 FORMAT | the format this journal continues in (2) | `jn_load`, once, before the first format-2 OPEN of a version-1 file | 1010 1011 Order: the in-memory tables first check the transition (a refused one is 1012 never written), then the record is written with `pwrite` and made durable 1013 with `fdatasync`, and only then does anything act on it or publish it: a 1014 grant reaches the worker after its START is durable, a job is reviewed after 1015 its RELEASE is durable, and a job is not released while its operation's DONE 1016 is not durable. A write or sync failure marks the journal failed and every 1017 later append is refused (30), so the creator never acts on a transition that 1018 might not be durable. A new journal's directory entry is synced 1019 (`jn_dsync`). 1020 1021 Fencing: `DIR/lock` is held with `flock(LOCK_EX)` for the creator's life. It 1022 is opened close-on-exec, so tools never inherit it; forked workers do, so a 1023 new creator cannot open the journal until every worker of the old one has 1024 exited (refused with 20 after the wait). Each open appends OPEN with the next 1025 fence number and every record carries the fence of the creator that wrote it, 1026 so each incarnation's records are attributable. The pid lock in 1027 `seed/authority/lock.om` was not reused: it reclaims stale locks by pid, which 1028 races, and has a fixed path. 1029 1030 Torn tail: a partial last record, or a last full record whose checksum or seq 1031 is wrong, was never acknowledged and is cut off (`ftruncate` plus sync). A bad 1032 record before the last one is corruption: the open is refused (23) and the 1033 file is not changed. 1034 1035 Compatibility: a header whose magic, version, record size or checksum differs 1036 is refused (21), never reinterpreted; a different objective identity is 1037 refused (22). Version 1, written by the format-1 build (git `79894168`, before 1038 DRA-398) that DRA-292's release acceptance runs forward, is continued, not 1039 refused: its incarnations' OPENs carry 0 in word 5, their ADMITs are replayed 1040 with request 0 into the lowest slot no unreleased job holds (a CANCEL does 1041 not free the slot, a RELEASE does; a job admitted while none is free is 1042 refused, 25), and a POLICY, GOAL or FAIR among them is refused (25). This is a 1043 deterministic mapping for replay, not a reconstruction of the slots the old 1044 build used. The header stays as written; the first format-2 creator appends 1045 FORMAT (14) under the last fence and then its OPEN with `SPVER`. The 1046 format-1 reader refuses type 14 as unknown (24), so it cannot roll the file 1047 back over format-2 records. Refused (33): a format-1 OPEN after FORMAT or in a 1048 version-2 file, an OPEN with `SPVER` in a version-1 file before FORMAT, a 1049 FORMAT anywhere else. An OPEN whose scheduler policy version differs from 1050 this build's `SPVER` is refused (33): the recorded FAIR decisions belong to 1051 another selection rule. A future format must change the version. 1052 1053 ### Recovery 1054 1055 `jn_open` reads the journal into the recovery tables; `auth_recover` (after 1056 `sched_new` and `auth_new`, before spawning workers) settles and readmits: 1057 - A START with no DONE was in flight at the crash. Class 3 (an idempotent effect whose key `DIR/k.` the effect itself creates atomically, for example with `ln`) is decided by the key: present is performed, absent is not performed and the job runs again. Class 2 (no external effect) is not performed. Class 1 is UNKNOWN and is never run again. Each gets a DONE. 1058 - An admitted job not yet released: a performed or UNKNOWN last operation releases it with that outcome; a cancelled job is released as cancelled; any other job is admitted again, in admission order, into the table slot its ADMIT recorded, with its dependency topics, resource request, bypass count (from the FAIR records) and declared goal (GOAL). 1059 - Before that, the scheduler's incarnation is set to the fence (`sched_incarnate`, so a proposal made for an earlier creator is stale) and the last POLICY is applied (capacities, then policy); after it, the cursor, the dispatch event count and the reservation (moved to the reserved job's slot) of the last FAIR are restored (`sched_frestore`), and only then is the replay ring attached. 1060 - The action records (state, attempt, generation), the authority generation (above every journaled one) and the pause state are restored, so a performed or UNKNOWN operation is refused if proposed again and a paused objective stays paused. 1061 - A restart that finds nothing in flight adds only its OPEN. 1062 1063 A crash between START and publishing the grant leaves a class 1 operation 1064 UNKNOWN even though its tool never ran. That is the pessimistic side: an 1065 effect is never repeated without proof that it did not happen. 1066 1067 | Function | Contract | 1068 | --- | --- | 1069 | `jn_open dir dn obj ms`, `jn_close` | Creator: take the lock (wait up to ms), create or check the header, cut a torn tail, read every record, append OPEN; release. | 1070 | `auth_recover c` | Settle, release or readmit, restore authority and pause. | 1071 | `jn_admitr id deps flags req`, `jn_admit id deps flags`, `jn_release j` | Durable admission (with or without a resource request) and release around `sched_admits` and `sched_review`. | 1072 | `jn_policy p win db by ttl`, `jn_cap req`, `jn_goal j pro est unc` | Durable policy, capacities and goal declaration: POLICY or GOAL written first, then `sched_policy`, `sched_cap`, `sched_goal`; -5 when the journal refuses (nothing changed). | 1073 | `jn_drain` | Write `sched.om`'s replay ring as FAIR records (also first thing in every append and in `auth_step`), so a dispatch decision is durable before any transition that follows it. | 1074 | `jn_known id`, `jn_done_j id`, `jn_jout id`, `jn_stat i`, `jn_fence`, `jn_gen`, `jn_act k i` | Recovered state. | 1075 1076 Limits: no checkpoint or compaction yet; recovery replays the whole journal 1077 and the tables hold 64 operations and 256 jobs. Inputs published to the pool 1078 are not journaled, so a recovered job reads whatever its dependency topics 1079 hold after the restart. The key of a class 3 effect must be created by the 1080 effect itself, atomically and last. Scheduling state not restored: reservation 1081 tickets (a recovered reservation starts a new ticket), policy 0's ready order 1082 (`sjrdy`: recovered ready jobs are stamped in admission order) and proposals 1083 (they are stale after a restart by the incarnation). The incarnation is the 1084 fence itself: a fence past 2^24 - 1 fails recovery (31) instead of reusing 1085 an earlier incarnation. Dependency readiness is restored: a publication 1086 that makes waiting jobs ready leaves a readiness record, and a job it made 1087 ready is ready again after recovery. 1088 1089 Replay is exact at drained points: after a successful `jn_drain`, which runs 1090 first in every journal append and in every `auth_step`. Decisions and 1091 readiness wait in the volatile ring until then. For authority-mediated 1092 actions, the dispatch decision is drained durably before START and before 1093 the action grant; assignment, worker wakeup and the worker's work before 1094 its grant may happen before that drain. A 1095 publication's readiness is not durable when `sched_publish` returns: a crash 1096 before the next drain loses it, and the published artifact with it (the pool 1097 is not journaled either), so recovery is as if the publication had not 1098 happened: a job waiting on it waits until it is published again. A crash inside a dispatch event 1099 recovers that event's cursor, reservation and the bypass counts of the jobs 1100 it did not assign, and the jobs it assigned are admitted again with bypass 1101 count 0. The dispatch event count is restored to the last journaled 1102 decision's; events that changed nothing leave no record. The count stamps 1103 replay records, so later records still follow the last durable one, and it 1104 ages admission tickets; tickets are not restored, so every ticket after a 1105 recovery is aged from the restored count. 1106 1107 ### Acceptance and controls 1108 1109 The gate runs, each in a fresh `build/node/jt`, and checks with its own 1110 reader (header, checksums, contiguous seq, fences, START/DONE pairing, one 1111 RELEASE per job, sink lines, keys): 1112 - 0 baseline: a class 1 and a class 3 job each performed once. 1113 - 1 crash after ADMIT: the admitted job is readmitted, the other admitted; both performed once. 1114 - 2 crash after START, before the grant: class 1 UNKNOWN, its tool never ran; two more restarts add only OPEN records. 1115 - 3 the same for class 3: key absent, run again (attempt 2), performed once. 1116 - 4, 5 crash after the tool reported, before DONE: class 1 UNKNOWN with the effect once; class 3 performed by its key. 1117 - 6, 7 crash after DONE, and after RELEASE: released once, nothing run again. 1118 - 8 crash in the middle of writing DONE (60 bytes on disk): the tail is cut, UNKNOWN. 1119 - 9, 10 SIGKILL of the creator while a slow tool runs: the workers kill it; class 3 runs again and performs once, class 1 is UNKNOWN with no effect. 1120 - 11 a second creator while the first runs is fenced (20) and changes nothing. 1121 - 12 another objective (22), another format version (3, 21), a corrupt middle record (23): refused, journal unchanged. 1122 - 15 a paused objective stays paused across a restart until resumed. 1123 - 19 a version-1 journal as the format-1 build writes it: continued (193), the format-1 jobs in the lowest free slots with request 0 (194), header unchanged with FORMAT under the last fence then OPEN with `SPVER` (195), FORMAT written once (196), recovery admits the jobs into those slots (197); misplaced FORMAT or OPEN refused (198, 33), a GOAL in a format-1 incarnation refused (199, 25), a 65th live format-1 job refused (200, 25), each with the file unchanged. 1124 1125 | Change | Expected exit | 1126 | --- | --- | 1127 | `journal.om`: cut any bad record as a torn tail (`if true`) | 157 | 1128 | `journal.om`: in `jn_settle`, class 1 in flight becomes not performed (replayed) | 33 | 1129 | `journal.om`: in `jn_settle`, class 3 not probed | 43 | 1130 | `journal.om`: `jn_probe` always reports the key absent | 66 | 1131 | `auth.om`: the reported outcome is not journaled | 10 | 1132 | `journal.om`: no `flock` (no fencing) | 141 | 1133 | `journal.om`: `jn_recover` skips `jn_settle` (the restart never releases the job) | 35 | 1134 | `journal.om`: objective check removed | 151 | 1135 | `journal.om`: version and record-size check removed | 154 | 1136 | `auth.om`: `auth_recover` does not restore pause | 161 | 1137 1138 ### Durable scheduling policy and deterministic replay (DRA-398) 1139 1140 Status: IMPLEMENTED in `sched.om`, `journal.om` and `auth.om`, exercised by 1141 `replay-gate.om` on native Linux AArch64 (evidence in the DRA-398 pull 1142 request). Not wired into `tests/gates/` (that needs an operator); the receipt 1143 runs it. 1144 1145 ```sh 1146 cat seed/node/transport.om seed/node/pool.om seed/node/super.om seed/node/sched.om seed/authority/action.om seed/node/journal.om seed/node/auth.om seed/node/replay-test.om > build/node/replay-composed.om 1147 cmp build/node/replay-composed.om seed/node/replay-gate.om 1148 seed/out/omc < seed/node/replay-gate.om > build/node/replay-gate 1149 chmod +x build/node/replay-gate 1150 timeout 180 build/node/replay-gate # ends "PASS node replay"; uses build/node/rpa, rpb 1151 ``` 1152 1153 Every input of a selection decision is journaled before it acts: the request 1154 and table slot with ADMIT, the policy words and capacities (POLICY), the goal 1155 declarations (GOAL). The decisions themselves are recorded as they are made: 1156 each dispatch event that assigns a job or moves the reservation puts one 1157 record (event, assigned and bypassed slot bitmaps, cursor, reserved slot) in 1158 `sched.om`'s 64-record replay ring, and so does each publication that makes 1159 waiting jobs ready (a readiness record: the current event, no assigned or 1160 bypassed slot, the slots made ready). `jn_drain` writes the ring as FAIR 1161 records before any other record and at every `auth_step`, so no later 1162 transition is durable before the decision or readiness that preceded it. 1163 Dispatch and publication refuse to run while the ring is full (counter 15; 1164 publication returns -105 with nothing published), so nothing is lost to a 1165 journal that cannot keep up. A window scan that assigned nothing moves only 1166 the cursor; `jn_drain` writes one FAIR with empty bitmaps for it when the 1167 cursor or the reservation differs from the last FAIR. 1168 1169 Replay refuses (25) any record that contradicts the tables, and nothing 1170 changes: an ADMIT into a slot another unreleased job holds; a FAIR that both 1171 decides (assigns or bypasses) and makes ready, the first FAIR of a journal 1172 included; a decision FAIR that does not follow the last event (a readiness 1173 record may share it); a cursor outside the table; a slot both assigned and 1174 bypassed; an assigned, bypassed or reserved slot that does not hold a live 1175 ready job (live: admitted, not released, not cancelled; ready: no deps, or 1176 made ready by an earlier readiness record); a slot made ready that does not 1177 hold a live waiting job; a reservation on a job the same record assigned. 1178 Recovery then readmits each 1179 unfinished job into its recorded slot (never another), makes it ready again 1180 if a publication had, and restores its bypass count and goal. Any of these 1181 the scheduler refuses, and a reservation that does not name a ready job, 1182 fails the recovery (31). 1183 1184 The gate runs four cases (policy 1 and 2, crash after 3 and after 6 of 10 1185 dispatch events) and four special checks: 1186 - R, a reference creator, runs all events on journal a; C runs the first k on journal b and dies; C2 recovers journal b and runs the rest. Before event 1 the creator publishes the topic job 7001 waits on, so 7001 is ready by publication across the crash. C2's state right after recovery equals R's after event k (cursor, reserved job, slots, ids and bypass counts of ready jobs, needs, estimates, uncertainties and topics of every unfinished job, policy words with the ticket lifetime 777, capacities, bypass sum, job 7001's state and bypass count), and C plus C2 make the same decisions as R, event by event. C3 recovers journal b once more and equals R's final state. Each case also proves it tests something: a bypass count, a nonzero cursor and job 7001 ready at the boundary, a reservation during the run, a final cursor different from the boundary's. 1187 - Mid-event crash: C' dies right after a dispatch and its PAUSE record, before the creator collects or releases the jobs it assigned (the replay workers are not stopped from finishing them). C2' has that event's cursor and reservation and the bypass counts of the jobs it did not assign; the jobs it assigned are ready again. 1188 - Records refused: a FAIR that repeats the last event, a FAIR naming a free slot, an OPEN written under another `SPVER`, an ADMIT into a held slot (23), a FAIR assigning and bypassing one slot (24), a FAIR assigning a waiting job (26), a readiness record for a ready job (27; a valid one at the last event is accepted), a FAIR reserving a cancelled job (25), a first FAIR that both assigns and readies (28: refused, nothing changes). 1189 - Failed journal: revoke, pause, cancel, admission, policy, capacities and goal each return their refusal and change nothing; a full ring stops dispatch (44) and publication (47). 1190 - Fence range (29): recovery refuses fence 2^24 + 1, which a 24-bit mask would fold onto incarnation 1, and leaves the scheduler unincarnated; fence 2^24 - 1 is then accepted. 1191 1192 `code.om` (omega-node's, BOARD note): the inference cancel hook checks `auth_cancel`'s result before converting it, so a refusing journal leaves the job running and the hook armed (it retries); restart cleanup exits 57 when it cannot cancel a job the last creator left waiting or ready (55 before the move onto omega-node's DRA-292 head, where DRA-291 uses 55 for a view that cannot start). `code-test unit` covers the hook with a refusing journal. `journal-test.om` cases 17 and 18 (16 and 17 before that move) journal the CANCEL and RELEASE (17) and the RELEASE (18) that their synthetic frees used to skip, which the held-slot refusal now requires. 1193 1194 | Change | Expected exit (derived from the check it trips) | 1195 | --- | --- | 1196 | `journal.om`: ADMIT records request 0 | 53: the needs fold differs at the boundary | 1197 | `journal.om`: POLICY words not restored | 53 | 1198 | `journal.om`: capacities not restored | 53: `sched_new`'s 65535 per kind, the capacities word differs | 1199 | `journal.om`: readmission takes the lowest free slot instead of the recorded one | 20: the reserved job moves from recorded slot 2 to slot 0; C2's first dispatch assigns slot 0, free in the journal, its FAIR is refused and the PAUSE after it fails (53 derived before review r2) | 1200 | `journal.om`: FAIR bypass counts not replayed | 53 | 1201 | `sched.om`: `sched_frestore` leaves the cursor at 0 | 53 | 1202 | `journal.om`: POLICY restored with ticket lifetime 1000 instead of the recorded 777 | 53: the policy word differs | 1203 | `sched.om`: publication journals no readiness record | 53: C2 readmits 7001 waiting, R has it ready at the boundary | 1204 | `journal.om`: a replayed readiness record does not make the job ready again | 53: as above | 1205 | `journal.om`: GOAL not restored | 73: policy 2, the waiting job's declaration | 1206 | `journal.om`: GOAL restored without its uncertainty | 73 | 1207 | `sched.om`: recovery keeps the event count at 0 | 20: C2's first FAIR is stamped at or before the last journaled event; its next record is refused and the PAUSE fails | 1208 | `journal.om`: `jn_append` does not drain first | 93: the mid-event FAIR is lost | 1209 | `journal.om`: `jn_recover` does not attach the ring | 53: R and C journal no FAIR either, so C2 recovers cursor 0 and 7001 waiting (derived 56 before review r1) | 1210 | `journal.om`: only a journal with no FAIR attaches the ring | 56: C2's decisions are never journaled, C3 differs | 1211 | `journal.om`: a FAIR repeating an event accepted | 96 | 1212 | `journal.om`: a FAIR naming a free slot accepted | 96: the replay traps (index out of bounds) | 1213 | `journal.om`: ADMIT into a held slot accepted | 23 | 1214 | `journal.om`: a FAIR assigning and bypassing one slot accepted | 24 | 1215 | `journal.om`: a FAIR assigning a waiting job accepted | 26 | 1216 | `journal.om`: a readiness record for a ready job accepted | 27 | 1217 | `journal.om`: a FAIR reserving a cancelled job accepted | 25 | 1218 | `journal.om`: OPEN's `SPVER` not checked | 98 | 1219 | `auth.om`: revoke ignores a refused REVOKE | 40 | 1220 | `auth.om`: pause ignores a refused PAUSE | 41 | 1221 | `auth.om`: cancel ignores a refused CANCEL | 42 | 1222 | `sched.om`: dispatch ignores a full ring | 44 | 1223 | `sched.om`: publication ignores a full ring | 44: the readiness record is written past the ring and traps (103) in the ring child, which the parent reports as 44 | 1224 | `journal.om`: the shape check below the first-record exception (the r1 code) | 28 | 1225 | `journal.om`: recovery masks the fence to 24 bits (the r1 code) | 29: 2^24 + 1 becomes incarnation 1 and is accepted | 1226 | `code.om`: the cancel hook converts `auth_cancel`'s result before checking it (the r1 code) | 105 (`code-test unit`): -5 traps the conversion (CAST) | 1227 | `journal.om`: a format-1 ADMIT keeps its recorded slot | 193 | 1228 | `journal.om`: the header accepts version 2 only (the code before the move onto DRA-292) | 193; also fails DRA-292's `release-accept fake … journal` (`journal-forward-old-to-new`, rc 51) | 1229 | `journal.om`: `jn_load` never writes FORMAT | 193 (the `SPVER` OPEN is refused, 33) | 1230 | `journal.om`: FORMAT written under the new fence | 195 | 1231 | `journal.om`: an OPEN with `SPVER` accepted before FORMAT | 198 | 1232 | `journal.om`: a format-1 OPEN accepted after FORMAT | 198 | 1233 | `journal.om`: FORMAT accepted anywhere | 198 | 1234 | `journal.om`: POLICY, GOAL or FAIR accepted in a format-1 incarnation | 199 | 1235 1236 ### Policy comparison on real workers (DRA-399) 1237 1238 `bench-test.om` runs the same pinned workloads under four arms: policy 0 1239 (FIFO), 1 (fair fitting, the default), 2 (goal-aware) and arm 3, policy 2 1240 given the true durations as estimates. Arm 3 is an ORACLE upper bound, not 1241 a policy result. The workers are real forked processes on the host's wall 1242 clock. A worker sleeps for the milliseconds in the low four decimal digits 1243 of its job id, then reports the outcome id + 1. The creator loop is 1244 `sched_step` with the dispatch timed. After every step and every 1245 publication it samples the job table, reviews finished jobs and publishes 1246 what each declared. Every arm sees the same jobs, requests, durations, 1247 declarations, workers (2) and capacities (4 CPU). Each job declares its 1248 topics with `sched_goal`. Its declared estimate is the duration times 1/2, 1249 1, 3/2 or 2, chosen by a fixed hash of its id, with the estimate itself as 1250 the declared uncertainty, so policy 2 is never told the duration. Only arm 1251 3 declares the true duration. 1252 1253 ```sh 1254 cat seed/node/transport.om seed/node/pool.om seed/node/super.om seed/node/sched.om seed/node/bench-test.om > build/node/bench-composed.om 1255 cmp build/node/bench-composed.om seed/node/bench-gate.om 1256 seed/out/omc < seed/node/bench-gate.om > build/node/bench-gate && chmod +x build/node/bench-gate 1257 build/node/bench-gate > bench.txt # 120 runs (6 scenarios x 4 arms x 5), ends "PASS node bench" 1258 ``` 1259 1260 | Scenario | Workload | 1261 | --- | --- | 1262 | 1 blocked head | h (2 CPU, 600 ms), then H (4 CPU, 300 ms), then six 1-CPU jobs of 200 ms | 1263 | 2 long chain | eight 1-CPU fillers of 300 ms, then a chain of six 150 ms jobs, each waiting on the topic the previous one publishes | 1264 | 3 fan-out | six 1-CPU fillers of 300 ms, then a 100 ms root publishing a topic six 200 ms jobs wait on | 1265 | 4 sustained arrivals | 24 jobs of 100..400 ms needing 1..3 CPU, four every 150 ms | 1266 | 5 queue pressure | 30 jobs of 100..300 ms needing 1..2 CPU offered at once against an admission limit of 8 (tickets) | 1267 | 6 worker failure | 12 rerunnable jobs of 150..450 ms needing 1..3 CPU; worker 0 is SIGKILLed 250 ms in while busy and not replaced | 1268 1269 Each run prints `bench S P R` followed by these fields: 1270 - **makespan:** from the first admission to the last review; 1271 - **idle eligible capacity:** the integral over time of min(idle live workers, ready jobs that fit the free capacity), in worker-microseconds; 1272 - **dispatch time:** nanoseconds inside `sched_dispatch` from the creator loop (dispatches inside publication and resume are not timed), and the number of those calls; 1273 - **scheduler counters:** events, candidate reads, maintenance reads, value reads; 1274 - **reworked jobs:** jobs that returned to ready after starting; 1275 - **reservations:** those made, and those that were contested; 1276 - **verified jobs:** jobs reviewed with the expected outcome; 1277 - **VmHWM:** the creator's peak resident memory; 1278 - **waits:** ready to started, in microseconds. There is one value for each start whose job was sampled ready at least once, so a job that a rework returns to ready contributes again. 1279 1280 A wait is measured at the sample after the step that dispatched the job, so its resolution is one creator step (at most 1 ms of polling plus the sampling). A job that becomes ready and starts within a single creator step or publication is never sampled ready and gets no value: its wait is below that resolution. The number of such starts is the jobs plus the reworks minus the waits printed. The statistics count each of them as a wait of 0. 1281 1282 Every run checks: 1283 - the capacity invariant (exit 70); 1284 - that a new reservation goes to the oldest ready job at the bypass budget (71); 1285 - that every job is reviewed once with its expected outcome within 20 s (72); 1286 - setup (73..77). 1287 1288 Statistics are computed with Wolfram from the raw lines; the queries are quoted with the results. 1289 1290 #### Results, 2026-11-07 (MEASURED on a synthetic workload; not speed evidence) 1291 1292 There are two runs of the same binary: bench-gate sha256 ``8bd6c1a7`…`, built at `bd57beaa` with omc `5f90edea`. Both ran under `flock pool-8-9.lock taskset -c 8-9 nice -n 10`; core 9 is the X925 timing core. 1293 - **Receipt `evidence/node-schedpol/receipt.`323ef72e`….json`** (`schedrcpt.om`, cases-399): bench-gate PASS, and mutants 70/71/72 killed. The receipt keeps only the last 4000 bytes of stdout (repetition 4), so it is not the source of the statistics. 1294 - **Rerun for the statistics**, 11:52:14Z to 11:57:19Z, exit 0, 120 lines, `PASS node bench`. The raw output is filed as `bench.`8f28e6a5`….txt` with `bench.`8f28e6a5`….meta.json` (commit, binary, command, times, load), in `~/handoffs/hive/sched/bench399/` next to `stats.wl`, `stats.tsv` and `relative.tsv`. 1295 1296 The load average was 11 to 13. `live-cpu` (core 0) sampled from 11:54:00Z to 11:57:20Z: 2 of 21 samples had a foreign running thread on 8/9, none of them the bench's. The first 106 s were not sampled. 1297 1298 Medians over 5 repetitions, with makespan in ms, idle eligible capacity in worker-ms and dispatch time in ns per call. Waits (ms) pool every start of the 5 repetitions. 1299 1300 Two wait columns are given, because the zero rule was defined after the output had been seen: 1301 - **wait (0 rule):** unsampled starts (the "unsampled" column) count as 0; 1302 - **sampled:** recorded waits only. 1303 1304 They differ only where there are unsampled starts. p95 is Wolfram's default `Quantile[w, 95/100]` (inverse empirical CDF). 1305 1306 | S | Arm | Makespan (min..max) | Idle | ns/dispatch | Rework | Reservations (contested) | Starts / unsampled | Wait median, p95, max (0 rule) | Sampled median, p95 | 1307 | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | 1308 | 1 | FIFO | 1506.9 (1504.1..1507.6) | 601.3 | 305.7 | 0 | 0 | 40 / 0 | 1002.8, 1305.8, 1306.9 | same | 1309 | 1 | fair | 1305.7 (1303.5..1329.3) | 200.4 | 319.1 | 0 | 4 (0) | 40 / 0 | 501.4, 1104.8, 1105.0 | same | 1310 | 1 | goal | 1504.3 (1305.4..1508.1) | 0.04 | 341.2 | 0 | 7 (2) | 40 / 0 | 401.5, 1006.4, 1307.0 | same | 1311 | 1 | ORACLE | 1506.4 (1505.0..1507.7) | 0.03 | 364.2 | 0 | 8 (4) | 40 / 0 | 301.7, 1205.3, 1307.1 | same | 1312 | 2 | FIFO | 2108.1 (2106.9..2155.1) | 0.02 | 240.3 | 0 | 0 | 70 / 25 | 150.5, 1203.7, 1238.4 | 602.3, 1204.0 | 1313 | 2 | fair | 2109.4 (2107.5..2110.6) | 0.02 | 296.0 | 0 | 0 | 70 / 25 | 150.4, 1204.8, 1206.3 | 602.3, 1205.3 | 1314 | 2 | goal | 1807.7 (1805.4..1811.7) | 0.03 | 315.7 | 0 | 24 (14) | 70 / 10 | 376.1, 1205.7, 1206.7 | 451.8, 1205.7 | 1315 | 2 | ORACLE | 1807.2 (1806.1..1807.7) | 0.02 | 295.9 | 0 | 12 (8) | 70 / 5 | 300.3, 1205.6, 1206.7 | 301.4, 1205.6 | 1316 | 3 | FIFO | 1606.7 (1606.4..1610.9) | 0.02 | 222.8 | 0 | 0 | 65 / 10 | 300.7, 902.8, 903.5 | 301.7, 903.1 | 1317 | 3 | fair | 1606.7 (1606.0..1609.7) | 0.02 | 288.2 | 0 | 0 | 65 / 10 | 301.1, 902.8, 904.2 | 301.6, 903.5 | 1318 | 3 | goal | 1606.1 (1605.3..1606.6) | 0.02 | 337.8 | 0 | 25 (10) | 65 / 0 | 602.4, 1304.5, 1304.9 | same | 1319 | 3 | ORACLE | 1605.5 (1604.0..1610.3) | 0.02 | 332.0 | 0 | 20 (15) | 65 / 0 | 602.1, 1303.8, 1306.9 | same | 1320 | 4 | FIFO | 4016.6 (4013.9..4017.5) | 1807.2 | 281.5 | 0 | 0 | 120 / 0 | 1431.0, 2764.3, 3065.4 | same | 1321 | 4 | fair | 3514.9 (3414.1..3517.2) | 202.1 | 319.2 | 0 | 5 (0) | 120 / 0 | 981.0, 2461.3, 2564.9 | same | 1322 | 4 | goal | 3613.5 (3612.3..3715.2) | 594.9 | 347.7 | 0 | 42 (13) | 120 / 0 | 856.4, 2560.6, 2710.9 | same | 1323 | 4 | ORACLE | 3616.5 (3614.9..3622.1) | 110.3 | 329.1 | 0 | 45 (22) | 120 / 0 | 752.4, 2413.1, 2669.8 | same | 1324 | 5 | FIFO | 3012.6 (3011.7..3014.0) | 0.02 | 263.5 | 0 | 0 | 150 / 0 | 601.4, 602.7, 603.8 | same | 1325 | 5 | fair | 3012.7 (3011.5..3013.8) | 0.04 | 304.3 | 0 | 0 | 150 / 0 | 601.3, 602.6, 602.9 | same | 1326 | 5 | goal | 3013.3 (3011.4..3014.0) | 0.03 | 328.8 | 0 | 50 (5) | 150 / 0 | 399.7, 1103.0, 1109.0 | same | 1327 | 5 | ORACLE | 3013.7 (3011.5..3020.8) | 0.04 | 316.5 | 0 | 40 (0) | 150 / 0 | 502.2, 1003.6, 1004.4 | same | 1328 | 6 | FIFO | 3465.1 (3463.3..3466.2) | 301.1 | 222.2 | 5 | 0 | 65 / 0 | 1305.7, 2861.3, 2863.5 | same | 1329 | 6 | fair | 3466.2 (3463.4..3467.1) | 0.02 | 247.8 | 5 | 0 | 65 / 0 | 1205.3, 3213.0, 3216.0 | same | 1330 | 6 | goal | 3618.3 (3367.0..3664.3) | 0.02 | 283.2 | 5 | 19 (9) | 65 / 0 | 1255.4, 3159.8, 3213.8 | same | 1331 | 6 | ORACLE | 3464.6 (3464.2..3479.5) | 0.02 | 243.8 | 5 | 16 (6) | 65 / 0 | 1004.4, 3013.6, 3027.5 | same | 1332 1333 In every run all jobs were reviewed with the expected outcome, and the creator's VmHWM was at most 416 KB. Scenario 6's one rework per run is the job running on the killed worker. 1334 1335 Median makespan relative to FIFO (`Round[100 (m[[s, p]]/m[[s, 1]] - 1), 0.1]`): 1336 1337 | Scenario | Fair | Goal-aware | ORACLE | 1338 | --- | --- | --- | --- | 1339 | 1 blocked head | −13.4 % | −0.2 % | 0 % | 1340 | 2 long chain | +0.1 % | −14.2 % | −14.3 % | 1341 | 3 fan-out | 0 % | 0 % | −0.1 % | 1342 | 4 sustained arrivals | −12.5 % | −10.0 % | −10.0 % | 1343 | 5 queue pressure | 0 % | 0 % | 0 % | 1344 | 6 worker failure | 0 % | +4.4 % | 0 % | 1345 1346 What these traces show, within their limits (sleep workers, 2 workers, 5 repetitions, one host): 1347 - **Fair fitting (policy 1, the default).** It removes most of FIFO's idle eligible capacity in the blocked-head and sustained-arrival scenarios (601 to 200 and 1807 to 202 worker-ms) and shortens them by 13.4 % and 12.5 %. Their median waits fall from 1003 to 501 ms and from 1431 to 981 ms. It never lengthens a makespan by more than 0.1 %. 1348 - **Goal-aware (policy 2).** 1349 - It is the only policy that shortens the long chain (−14.2 %), matching the ORACLE arm. 1350 - In fan-out its median wait rises from 301 to 602 ms at an unchanged makespan. 1351 - Under queue pressure its median wait falls from 601 to 400 ms but its p95 rises from 603 to 1103 ms. 1352 - In worker failure its median makespan is 4.4 % longer, with a 3367..3664 ms spread across repetitions. 1353 - In the blocked head its 5 makespans spread from 1305 to 1508 ms. 1354 - **Dispatch cost.** It is 222 to 364 ns per call in every arm; policy 2 costs more per call than FIFO in every scenario. 1355 1356 The live workflow ran policy 1 only, so no live comparison exists between the arms. 1357 1358 ## Local inference and the coding workflow (DRA-290) 1359 1360 Status: IMPLEMENTED in `infer.om`, `tool.om`, `gram.om` and `code.om`, 1361 exercised on native Linux AArch64 by `code-test.om`, the round40 replay 1362 `tests/tool-replay.om` (seeded Omega; it replaced `tests/tool-replay.py` with 1363 the same check lines, summary and exit status), the tool controls and live runs 1364 of the own Omega model (round40 checkpoint served by aien-train `ollm serve`, 1365 DRA-119, inside a private network namespace). Evidence is in the DRA-290 pull 1366 request. Not QUALIFIED on the Spark and not DEPLOYED. 1367 1368 All six are OM-2 programs (`printf 'om2\n'` before the sources): 1369 1370 ```sh 1371 L="seed/node/transport.om seed/node/pool.om seed/node/super.om seed/node/sched.om seed/authority/action.om seed/node/journal.om seed/node/auth.om" 1372 { printf 'om2\n'; cat seed/json/json.om seed/json/jsonw.om seed/net/http.om seed/net/notls.om seed/node/infer.om; } | seed/out/omc > build/node/infer 1373 { printf 'om2\n'; cat seed/agent/path.om seed/node/gram.om seed/node/tool.om; } | seed/out/omc > build/node/tool 1374 { printf 'om2\n'; cat seed/net/http.om seed/net/notls.om $L seed/node/view.om seed/node/gram.om seed/node/code.om seed/node/code-main.om; } | seed/out/omc > build/node/code-main 1375 { printf 'om2\n'; cat seed/net/http.om seed/net/notls.om $L seed/node/view.om seed/node/gram.om seed/node/code.om seed/node/code-test.om; } | seed/out/omc > build/node/code-test 1376 { printf 'om2\n'; cat seed/json/json.om seed/node/tests/drv.om seed/node/tests/tool-replay.om; } | seed/out/omc > build/node/tool-replay 1377 { printf 'om2\n'; cat seed/json/json.om seed/node/tests/drv.om seed/node/tests/drv-test.om; } | seed/out/omc > build/node/drv-test 1378 chmod +x build/node/infer build/node/tool build/node/code-main build/node/code-test build/node/tool-replay build/node/drv-test 1379 build/node/code-test unit build/node/cu # "code checks=60 fail=0", exit 0 1380 build/node/drv-test /tmp/dvt # "DRV-TEST pass=40 fail=0 not_run=0", exit 0 1381 build/node/tool-replay build/node/tool OMC40 ROUND40 build/node/replay # "TOOL-REPLAY runs=108 pass=108 fail=0 actions=417", exit 0 1382 ``` 1383 1384 A failed compile leaves an empty output file that exits 0 when run; check 1385 omc's exit status. `OMC40` is the compiler the round40 model was trained and 1386 evaluated with (sha256 ``2c82480596bb`…`, omega-mv ``e5b32567``; on the Spark 1387 `~/work/omega-node-e5b3/seed/out/omc`): its error text is part of the prompt, 1388 so the check tool must use it. `ROUND40` is the round40 run directory holding 1389 `repair.py` and `final-selected.json`. 1390 1391 ### Test drivers 1392 1393 The drivers are seeded Omega built by this checkout's `seed/out/omc`; no 1394 system program is executed. `tool-replay` runs only TOOL (with OMC as its 1395 argument), with stderr to `/dev/null`; `drv-test` runs only its own binary as 1396 the child; `view-accept` runs only BUILD's `code-main` or `code-test`, `op` 1397 and `fake-serve` (the node runs BUILD's `infer` and `tool`); `view-prep` runs 1398 nothing. 1399 1400 `tool-replay TOOL OMC ROUND40 OUTDIR` replays every recorded round40 run 1401 through TOOL in `OUTDIR/` and checks that each rebuilt `repair.py` 1402 prompt equals the next recorded prompt byte for byte. It prints a `MISMATCH` 1403 line (with `want` and `got` in Python repr) or an `ERROR` line per failing step, 1404 then `TOOL-REPLAY runs=R pass=P fail=F actions=A`. It exits 0 when no run 1405 failed, 1 otherwise, and 2 for bad usage or an unreadable fixture. Unlike the 1406 Python driver, it fails a run instead of crashing on a malformed fixture field, 1407 a tool timeout or a malformed `OMNT1` record, and it refuses a job id that is 1408 empty, `.`, `..` or holds `/`. The file header lists its buffer limits. 1409 1410 `tests/drv.om` is the driver library both share (prefix `dv`, composed after 1411 `seed/json/json.om`): 1412 1413 | Group | Functions | 1414 | --- | --- | 1415 | results | `dv_pass`, `dv_fail`, `dv_nrun NAME DETAIL` print `PASS\|FAIL\|NOT_RUN NAME[ DETAIL]` and count; `dv_count KIND` | 1416 | output, formatting | `dv_out`, `dv_err`; `dv_cat`, `dv_byte`, `dv_fmtu`, `dv_fmtl` append at an offset and return the new end | 1417 | bytes | `dv_eq`, `dv_at`, `dv_find`, `dv_atou` (`dvnone` = not a number) | 1418 | arguments | `dv_argc`, `dv_arg I BUF` (length, -22 no such argument, -105 buffer too short) | 1419 | files | `dv_slurp` (-27 does not fit), `dv_spit`, `dv_apnd`, `dv_isdir`, `dv_mkdirp`, `dv_rmrf` (no symbolic link followed), `dv_join` and `dv_dirn` (`os.path.join`, `os.path.dirname`) | 1420 | processes | `dv_pkinit`, `dv_pkadd` build a packed argv; `dv_spawn PK OUT ERR` runs it in its own process group (exit 126 files, 127 exec; when OUT and ERR name the same file both streams share one descriptor), `dv_spawna PK OUT` the same with both streams appended to OUT, `dv_spawnio PK IN OUT ERR` with three descriptors the caller already opened (126 for a negative or failed one), `dv_exec` the child side of the first two; `dv_poll`, `dv_reap`, `dv_wait PID DEADLINE` (-110 after killing the group), `dv_kill`, `dv_killg`; status is the exit code or 256 + signal | 1421 | ports | `dv_port`: a free 127.0.0.1 port, never 18091 or 18300 | 1422 | JSON | `dv_jload` (file to tape), `dv_jkey` (the last duplicate wins), `dv_jidx`, `dv_jlen`, `dv_jisl`, `dv_jnum`, `dv_jstr` (UTF-8, surrogate pairs joined), `dv_jsteq` | 1423 1424 `drv-test SCRATCHDIR` checks these functions in `SCRATCHDIR/drv-test.d` 1425 (removed before and after) and prints `DRV-TEST pass=P fail=F not_run=N`; it 1426 exits 1 on any failure, 2 for bad usage. A `drv.om` whose `dv_dirn` keeps a 1427 repeated separator and whose status drops the 256 for a signal gives `FAIL 1428 drv.dirn`, `FAIL drv.kill-reap` and exit 1; one whose `dv_spawna` opens OUT 1429 without append gives `FAIL drv.spawn-append`; one whose `dv_spawn` opens ERR 1430 again when it names OUT's file (`if not dv_eq fo fe` made `if true`) gives 1431 `FAIL drv.spawn-shared` (`DRV-TEST pass=39 fail=1`). 1432 1433 `tests/nodedrv.om` (prefix `nd`, composed after `drv.om`) holds what the 1434 DRA-291 drivers share: the fixture (`nd_prep`: broken files, objective lines, 1435 `expect.json` and fake-serve's map from the round40 runs), node and 1436 fake-serve processes (`nd_fake`, `nd_node`, `nd_poll`, `nd_fin`, `nd_sig`, 1437 `nd_reap`, `nd_clean`), `omnode-op` calls with their JSON answers (`nd_view`, 1438 `nd_viewd`, `nd_cmd`, `nd_fresh`, `nd_tk`, `nd_ti`, `nd_status`, `nd_dj`), 1439 output lines (`nd_outl`, `nd_hasl`, `nd_hasp`, `nd_pfxl`, `nd_lastl`), the 1440 journal (`nd_jstart`) and the listening check (`nd_lsn`, from 1441 `/proc/net/tcp` and `/proc/net/tcp6`). Its header documents the path slots 1442 and limits. 1443 1444 ### Qualification runner 1445 1446 `tests/qual.om` replaces the out-of-repo DRA-292 qualification shell conductor. 1447 It composes with SHA-256 and the driver library, invokes only this checkout's 1448 `seed/out/omc` for builds, and ignores the ambient `OMC` variable. Run from the 1449 checkout root, under the operator-approved CPU-pool wrapper, with a fresh 1450 evidence directory outside the source tree: 1451 1452 ``` 1453 { printf 'om2\n'; cat om/tls/sha2.om seed/json/json.om seed/node/tests/drv.om seed/node/tests/qual.om; } | ~/work/omega-node-run.sh env -u OMC nice -n 19 seed/out/omc > build/node/qual 1454 { printf 'om2\n'; cat om/tls/sha2.om seed/node/release.om; } | ~/work/omega-node-run.sh env -u OMC nice -n 19 seed/out/omc > build/node/release 1455 { printf 'om2\n'; cat seed/json/json.om seed/node/tests/drv.om seed/node/tests/tool-replay.om; } | ~/work/omega-node-run.sh env -u OMC nice -n 19 seed/out/omc > build/node/tool-replay 1456 chmod +x build/node/qual build/node/release build/node/tool-replay 1457 env -u OMC ~/work/omega-node-run.sh build/node/qual /tmp/node-qualification 1458 ``` 1459 1460 Do not execute a compiler's output when that compilation failed. `HOME` locates 1461 `work/omega-node-e5b3/seed/out/omc`, `handoffs/tool-omega-`20261104`/round40`, and 1462 `.elan/toolchains/leanprover--lean4---v4.35.0/bin/lean`. The 108-run tool replay requires the original Round40 selection. The view and release scenarios use the four recorded control cases from this checkout. The round40 compiler is 1463 an input to tool-adapter checks, never the compiler of the qualification driver 1464 or the Node programs. `build/node/release` and `build/node/tool-replay` must 1465 already exist. Optional seeded `build/node/view-accept` and 1466 `build/node/release-accept` are invoked directly; when absent, acceptance and 1467 every corresponding mutant are `NOT_RUN`, never silently run by Python. Mutant 1468 mutation and compilation still run and fail independently if invalid. 1469 1470 The conductor writes `platform.txt`, `hashes.txt`, `results.txt`, compiler 1471 diagnostics, program outputs and binary hashes. It checks gate composition, 1472 build reproducibility, the old ``79894168`` reader, code/view/release/journal 1473 mutants, tool replay and controls, the agent check, and the Lean RESULT model. 1474 Mutation replaces whole lines (with optional function scope); the Lean mutant 1475 replaces its exact proposition substring. A missing mutation is a failure. 1476 Source hashes and clean git status are checked again at the end. Exit 0 means 1477 every check passed; exit 1 means one or more failures; exit 3 means no failure 1478 but one or more `NOT_RUN` (a skipped step is never reported as a pass; the shell 1479 conductor it replaces always exited 0); exit 2 means the conductor could not 1480 prepare/read/write its inputs or evidence. `NOT_RUN` is preserved in the 1481 results and receipt. 1482 `platform.txt` records both the hexadecimal affinity mask and `Cpus_allowed_list`. 1483 Evidence from a dirty worktree cannot be promoted to a clean receipt. 1484 1485 SHA-256, copying, composition, mutation, process deadlines, process discovery, 1486 result parsing and evidence writing are seeded Omega. The retained host tools 1487 are read-only git 2.43.0 (`rev-parse`, `status`, `ls-files`, and per-file 1488 `git show `79894168`:PATH`, not `tar`), Lean 4.35.0 as a proof oracle, 1489 GNU coreutils 9.4 `uname` for platform identification and `nice` for CPU 1490 priority, and Python 3.12.3 solely for `seed/agent/tests/check.py`. The agent 1491 driver's Omega successor is tracked in omega-mv#1071; its result explicitly 1492 says it is still a Python driver. The slow-compiler adversarial fixture is also 1493 seeded Omega (a sleeping child and parent, killed by the tool adapter's deadline). 1494 No GPU or live model service is opened; there is no crumb-verification stage. 1495 1496 The additive `drv.om` helper `dv_spawnio PK FI FO FE` accepts an already-packed 1497 argv and three open descriptors. It creates a child process group; the caller 1498 retains and closes the descriptors. `dv_spawn PK OUT ERR` now shares one output 1499 file offset when `OUT` and `ERR` name the same path. Both still return the child 1500 PID (or fork error), with child exits 126 for descriptor setup and 127 for exec. 1501 1502 ### Receipts 1503 1504 `tests/receipt.om` is the evidence receipt writer, the seeded Omega replacement 1505 for the out-of-repo `omega-node-receipt.py` (prefix `rc`, composed after 1506 `drv.om`). Build it with this checkout's compiler: 1507 1508 ``` 1509 { printf 'om2\n'; cat seed/json/json.om seed/json/jsonw.om om/tls/sha2.om \ 1510 seed/node/tests/drv.om seed/node/tests/receipt.om; } > /tmp/receipt.full.om 1511 seed/out/omc < /tmp/receipt.full.om > receipt 1512 ``` 1513 1514 `receipt EV REPO SUB ISSUE SCRIPT [EXECUTION]` reads `EV/platform.txt`, 1515 `EV/hashes.txt`, `EV/results.txt`, `EV/NAME.out` and `EV/NAME.sha` for every 1516 `PASS NAME compile=0 …` check line, and the last existing of 1517 `EV/repeat-stress.txt` and `EV/repeat-idle.txt` for a `PASS NAME-repeat P/R` 1518 line. It writes the receipt to `REPO/evidence/SUB/receipt..json`, where 1519 the hash is the sha256 of the file's bytes. The file is created exclusively, 1520 with mode 0644. The program then prints the path. The record has the Python 1521 writer's keys in the Python writer's order: `issue`, `source_commit`, 1522 `source_tree`, `platform`, `cpu_affinity_mask_hex`, `execution`, 1523 `timestamp_utc`, `independent_review` (false), `native_aarch64` (`NOT_RUN` when 1524 a results line is NOT_RUN, else `PASS`), `executed_verdict`, `not_run`, 1525 `spark_gate_judge`, `live_hive`, `script`, `hashes`, `checks`, `results`, then 1526 `repeat` (null or one object) or `repeats` (a list). 1527 1528 It refuses, with exit 1 and the Python message on stderr, in these cases: 1529 1530 - `platform.txt` holds no `head H tree T dirty=0` 1531 (`refused: evidence run was not on a clean tree`). 1532 - A results line is FAIL, including `FAIL count N` with N not 0 1533 (`refused: results contain FAIL: LINE`). 1534 - The target already exists (`refused: exists PATH`). 1535 1536 It also exits 1 for an unreadable or symbolically linked input, a file over its 1537 buffer, invalid UTF-8 or a JSON writer refusal. It exits 2 for bad usage: fewer 1538 than 5 arguments, or an argument over 4096 bytes. The Python writer raises 1539 there. 1540 1541 The limits are: 1542 1543 - `platform.txt`: 65536 bytes. 1544 - `hashes.txt`: 262144 bytes. 1545 - `results.txt`: 524288 bytes. 1546 - Each `.out`, `.sha` and repeat file: 983040 bytes. 1547 - The JSON: 2 MiB. 1548 - Each path: 4095 bytes. 1549 1550 It differs from the Python writer in these ways: 1551 1552 - The JSON is compact, not indented, and ends with a newline. Non-ASCII text is 1553 written as raw UTF-8, not as `\uXXXX` escapes. The parsed values are equal, 1554 but the file name differs because it hashes different bytes. 1555 - `\w`, `\d` and whitespace are ASCII only. A byte of 0x80 or above counts as a 1556 word byte in a FAIL or NOT_RUN prefix, so such a prefix fails closed. 1557 - The timestamp is truncated to microseconds. 1558 - The FAIL scan runs before any `.out` file is read. 1559 1560 ### Programs 1561 1562 `omnode-code INFER TOOL OMC ROOT WORK JDIR PORT VIEW OBJ...` runs 1..4 objectives 1563 `KIND,K,N,A,PATH,TASK` (KIND `add`, `mul` or `loop`) against the files under 1564 ROOT, with the journal in JDIR and compile scratch in `WORK/o`. The creator 1565 holds every objective's state and alone decides; two workers run the granted 1566 jobs, each job one child process in its own process group (`auth_wtool`): 1567 1568 | Job | Child | Input (packed argv published on the objective's topic) | 1569 | --- | --- | --- | 1570 | 1 inference | `infer PORT 160 900 PROMPT` | the prompt of `repair.py` for the current state | 1571 | 2 read | `tool read ROOT PATH` | | 1572 | 3 check, 5 review | `tool check ROOT PATH WORK/o OMC KIND K N A` | | 1573 | 4 replace | `tool replace ROOT PATH OLD NEW` | old and new as the model gave them | 1574 1575 `infer` (exit 2 usage, 3 prompt, 4 connect, 5 deadline, 6 HTTP status, 7 1576 malformed response, 8 busy) connects only to 127.0.0.1, refuses port 18091, 1577 and posts one greedy, non-streamed `/v1/completions` request (aien-train 1578 #76). The server takes one request at a time and keeps generating a few 1579 seconds after a cancelled client is gone, so a 503 is asked again every 1580 second within the deadline; exit 8 means busy until under 2 s were left. 1581 Its record `OMNI1 kind fin ptok ctok plen olen nlen tlen` is followed by 1582 path, old, new and the raw model text; kind 9 is text that is not a protocol 1583 action. No other provider exists: there is no remote or fallback path, so 1584 offline-local is the only mode. 1585 1586 `tool` returns `OMNT1 status olen clen`, the observation and the file. Paths 1587 pass `agpathok` (`seed/agent/path.om`, shared with omagent) and a final 1588 symbolic link is refused; replace writes a temporary file, syncs, renames and 1589 syncs the directory; check follows `repair.py compile_test` with the test 1590 programs run under `execpure`, 10 s for omc and 2 s per test, killing the 1591 whole process group on timeout. 1592 1593 Policy (as `repair.py jobs_run`): at most 7 model turns; read_file only when 1594 unread, omega_check only when read or edited, replace_text only when failed, 1595 `Tests passed.` only when the last check passed, `File not found.` only when 1596 the read found nothing; the path must be the objective's. Before a replace is 1597 granted, the creator checks that old occurs exactly once in the source the 1598 model was shown and that the result stays in the repair grammar (`gr_src`). 1599 Every record is checked against its header lengths and the 3968-byte output 1600 page. A check must return exactly the source the creator holds, a replace 1601 exactly the candidate it computed. `Tests passed.` starts a review job, a 1602 fresh check of the saved file, and only its pass is a PASS. Anything else 1603 ends the objective as FAIL with its reason; nothing is retried or repaired. 1604 1605 | Result | Meaning | 1606 | --- | --- | 1607 | 1 | PASS | 1608 | 10, 11 | action not valid in its state; wrong path | 1609 | 12 | 7 turns used | 1610 | 13 | edit refused (old not exactly once, result outside the grammar, or the tool refused it) | 1611 | 14 | `Tests passed.` without a passing check | 1612 | 15 | the file checked or saved differs from the workflow's source or candidate, or the review (the fresh check of the saved file after `Tests passed.`) did not pass, which includes a test run killed at the tool's 2 s wall clock | 1613 | 16, 17 | inference or tool exited nonzero (no fallback) | 1614 | 18 | malformed record | 1615 | 19 | cancelled (operator `auth_cancel`, or the authority's cancel verdict) | 1616 | 20 | prompt over 3800 bytes | 1617 | 21 | outcome UNKNOWN (a worker or child lost) | 1618 | 22, 23 | job input lost; refused by the authority | 1619 1620 Output: `CWP i turn n` and `CWR i turn n` lines, each followed by n bytes 1621 (the prompt; the model text) and a newline; `CWE i job event value` job 1622 events (1 issued, 2 model action kind, 3 tool status, 4 outcome word, 5 1623 cancel); 1624 `CWO i PASS|FAIL result turns`; `CWSUM pass= fail=`. Exit 0 when 1625 every objective passed, 1 otherwise, 2 usage, 62 out of time, 30 + a journal 1626 refusal (50..57), 30 + a restart-recovery refusal (54..62: 24/25 refused 1627 record, 27 I/O, 28 write, 29 sync, 30 journal failed earlier, 31 the scheduler 1628 refused a restore: the incarnation, the capacities or policy, a job admitted 1629 again, or the last FAIR; 32 action record not restored), 50..56 a setup failure (pool, 1630 supervisor, scheduler, authority, worker spawn, view page, view process), 57 a 1631 restart cleanup that could not cancel a job the last creator left waiting or 1632 ready (the journal refused its CANCEL, or the RELEASE after a cancel that freed 1633 it). The ranges overlap, and 62 is also out of time, so every journal, 1634 recovery, setup or cleanup exit first writes `code-main: CAUSE, exit N` on 1635 stderr (out of time writes none; it ends with `CWSUM` on stdout); a journal 1636 directory over 100 bytes, for example, gives `code-main: journal refused 1637 (...), exit 56`. 1638 1639 Restart: the journal's objective identity is the objective arguments' FNV-1a 1640 64. On a restart `auth_recover` settles what the last creator left (an 1641 in-flight replace is UNKNOWN and never rerun); the creator cancels recovered 1642 jobs that still wait for input (pool contents are not journaled), and each 1643 objective resumes from the durable file in state unread with its performed 1644 model turns counted against its 7 and its job ids continuing. 1645 1646 Limits: one inference at a time (one local server); 64 action records per 1647 creator process bound a run to about 4 objectives; lines are split on `\n` 1648 only, so a `\r` makes a line fall outside the grammar where Python's 1649 `splitlines` would split it. 1650 1651 ### Acceptance and controls 1652 1653 `code-test unit` (60 checks, no child process) feeds crafted model and tool 1654 records to the creator: the round40 prompts byte for byte; every action in 1655 every state; wrong path; old text absent, twice, many times; an edit outside 1656 the grammar; `Tests passed.` unverified or after an edit; `File not found.` 1657 when not missing; header and length faults; tool content that differs from 1658 the source or candidate; outcome words for exit 4, 5 and 8, a killed child, 1659 cancellation, UNKNOWN and a lost input; the turn limit; an over-long prompt; 1660 a full admission queue (DRA-291: a refused inference waits for its next turn, 1661 a refused tool job ends the objective 23, both counted); the inference cancel 1662 hook's handling of `auth_cancel`'s result (DRA-398, 2 checks). 1663 `code-test cancel MS ...` is `omnode-code` with objective 0's first inference 1664 cancelled through `auth_cancel` after MS milliseconds. 1665 1666 | Change to `code.om` | Expected exit | 1667 | --- | --- | 1668 | path not compared | 154 | 1669 | old text not required exactly once | 103 (trap) | 1670 | grammar of the result not checked | 162 | 1671 | `Tests passed.` accepted unverified | 168 | 1672 | checked content not compared | 181 | 1673 | child exit status ignored | 192 | 1674 | 8 turns allowed | 202 | 1675 | saved content not compared | 186 | 1676 | `File not found.` accepted in any state | 171 | 1677 | replace accepted in any state | 157 | 1678 | goal text changed | 151 | 1679 | record length not checked against the page | 174 | 1680 | cancelled read as UNKNOWN | 197 | 1681 | missing file read as read | 178 | 1682 | prompt limit raised to 4000 | 203 | 1683 | refused tool job left waiting (DRA-291) | 208 (check 58) | 1684 1685 ### Live coding workflow under the durable scheduler (DRA-399) 1686 1687 `live-test.om` runs the coding workflow above for real on native Linux 1688 AArch64: `ollm serve` with the own round40 model, `code-main`, `code-test`, 1689 `tool` and `infer`. The scheduler is the journal v2 one with the default 1690 policy that `sched_new` sets (policy 1). The driver only starts the programs 1691 and checks what they did; it implements none of their logic. It replaces the 1692 DRA-290 shell and Python harness (`inner.sh`, `crash.sh`, `prep.py`, `cmp.py`, 1693 `jread.py`). 1694 1695 ```sh 1696 { printf 'om2\n'; cat seed/json/json.om om/tls/sha2.om seed/node/live-test.om; } \ 1697 | seed/out/omc > build/node/live-test # omc exit status must be 0 1698 bwrap --dev-bind / / --unshare-net --die-with-parent -- \ 1699 build/node/live-test BASE NODE OLLM MODELDIR OMC40 SEL [serve=0] [parts=fcr] 1700 ``` 1701 1702 - **Paths.** All paths are absolute, and BASE must not exist yet. 1703 - NODE holds `infer`, `tool`, `code-main` and `code-test`. 1704 - MODELDIR holds `model.ck` and `merges.bin`. 1705 - OMC40 is the compiler the objectives are checked with (omega-mv `e5b32567`). 1706 - SEL is round40's `final-selected.json`. 1707 - **Server.** The model server listens on 127.0.0.1:18399, inside the network namespace. 1708 - **Operator view.** `code-main` and `code-test cancel` get VIEW `0` (no view; DRA-291 added that argument after PORT). The runs f to f4 below predate it and passed no VIEW. 1709 - **Negative control.** `serve=0` starts no server. 1710 - **Parts.** `parts=` selects the full run (f), the cancellation (c) and the crash and restart (r). A part left out is `NOT_RUN`. 1711 - **Exit status.** 0 only when every check passed, 1 otherwise, 2 for a usage error. 1712 - **Output.** One `PASS|FAIL|NOT_RUN name detail` line per check, then `LIVE checks N pass P fail F not_run R`. The checks are backed by these evidence lines: 1713 - `HASH`: sha256 and size of every pinned input, every node program and the driver itself (`/proc/self/exe`). 1714 - `SEL`: the four round40 rows used. 1715 - `PREP`: the prepared objective files. 1716 - `SERVE`: server pid and readiness. 1717 - `RUN`: program exit and milliseconds. 1718 - `REVIEW`, `SNAP`. 1719 - `JOP`: one line per journaled operation. 1720 1721 Objectives: the four round40 loop rows `item76666` (logic fault), 1722 `item83423` (missing file), `item82342` (syntax fault) and `item85188` 1723 (correct already). Each row's broken file is written into `root/jobs` and 1724 compared byte for byte with the selection's `broken` text. Each scenario 1725 (`BASE/full`, `BASE/cancel`, `BASE/crash`) has its own root, work 1726 directory, journal and server. 1727 1728 | Check | Passes when | 1729 | --- | --- | 1730 | prereq-hashes | model, merges, ollm, the objectives' compiler and the selection match their pinned sha256; every node program is hashed | 1731 | selection | the four rows parse from SEL and their broken files are prepared | 1732 | full-workflow | `code-main` with all four objectives exits 0 with `CWSUM pass=4 fail=0` and every `CWO i PASS 1`; no node process remains 15 s later and the server's process group is gone | 1733 | full-journal | the journal reads back intact: every OPEN under SPVER 3, fences increasing, no POLICY record (the default policy was never changed), one OPEN, every operation started exactly once and done, nothing open, objective identity `OMNC`, 4, issue 290 | 1734 | round40-transcript | every `CWP` prompt and every `CWR` model reply equals round40's recorded turn byte for byte, in order, and each objective took round40's number of turns (5, 2, 5, 3) | 1735 | review-outputs | an independent `tool check` (OMC40) of each objective's final file: the three files equal the selection's correct text and give `Tests passed.`; the missing-file objective's file is still absent and gives `File not found.` | 1736 | cancel-mid-inference | `code-test cancel 20000` on objective 0 exits 1 with `CWO 0 FAIL 19` after one cancel event, the server logs the dropped request as `C 499`, no node process remains and the server group is gone | 1737 | cancel-journal | the journal checks above with one objective, plus at least one CANCEL record | 1738 | crash-restart | run 1 of objective 0 is SIGKILLed (status 137) while an `infer` child is running the first inference after the replace landed. Only the creator is killed; its workers and the inference are left to the node's own cleanup, and no node process may remain 15 s later. The file on disk is then the correct text. Run 2 restarts on the same root, work and journal and must exit 0 with `CWO 0 PASS`, leaving nothing behind | 1739 | crash-journal | the journal checks above with two OPENs, plus at least one operation settled by the restart (`auth_recover`) | 1740 | no-leak | at the end no process whose program is under NODE remains | 1741 1742 bwrap shares the host's process namespace, so the NODE process count sees every process on the host whose program lies under NODE. Keep monitors and other tools out of NODE. In the first DRA-399 full run, the core sampler lived in `build/node`, and that alone failed full-workflow and no-leak. 1743 1744 `live-cpu.om` is the core-contamination sampler that goes with these runs. Every 10 s it reads `/proc/*/task/*/stat` (read-only) until the file STOP exists. It prints one line per sample: `CPU cwo run89 own foreign `, followed by ` pid/tid:comm` for each foreign thread. 1745 1746 - `run89` counts threads in state R whose last processor (stat field 39) is 8 or 9. 1747 - `own` counts those whose program is under OWNDIR (a directory prefix ending in `/`; the 2026-11-07 runs used `/tmp/wtlive/build/node/`) or is exactly OLLM, the pinned ollm. Both are arguments, so no machine path is compiled in; the 2026-11-07 binary ``5b638039`…` had both compiled in and took two arguments. 1748 - `cwo` counts the `CWO ` lines in WATCH, which marks the objective boundaries. 1749 1750 ```sh 1751 { printf 'om2\n'; cat seed/node/live-cpu.om; } | seed/out/omc > build/lt399/live-cpu 1752 taskset -c 0 nice -n 19 build/lt399/live-cpu PART/end.txt PART/run//run.out OWNDIR OLLM > PART/cpu.log 1753 ``` 1754 1755 #### Results, 2026-11-07 (EXERCISED; not QUALIFIED) 1756 1757 All runs were on native AArch64, CPU only (spark-b87b, Linux 7.0.0-1019-nvidia). Each ran under `flock pool-8-9.lock taskset -c 8-9 nice -n 10 bwrap --unshare-net`. Core 9 is the X925 timing core. 1758 1759 Run directory: `~/handoffs/hive/sched/live399/20261107T085509Z//`, holding `cmd.sh`, `live.out`, `live.rc`, `cpu.log`, `ps-ollm.txt` and the scenario's `run/`. 1760 1761 Hashes (`HASH` lines; full list in `start.txt` and `start-addendum.txt`): 1762 - Node programs at `aa2abf84`: infer `8cc5fb30`…, tool `a1bdecb0`…, code-main `7a1c14c0`…, code-test `1b270fba`…. 1763 - Compilers: in-tree omc `5f90edea`…, and the objectives' compiler `2c824805`… (omega-mv `e5b32567`). 1764 - Model inputs: ollm `f99fce9f`…, model.ck `7c7b5b52`…, merges.bin `73a29baf`…, and the round40 selection `2017a902`…. 1765 - Drivers: live-test `1b30b1de`… before the slot fix and `25c9a30a`… after it; live-cpu `5b638039`…. 1766 1767 | Part | live-test | Checks pass/fail/not_run | Result | 1768 | --- | --- | --- | --- | 1769 | neg (`serve=0`, c) | `1b30b1de` | 3/2/6 | cancel-mid-inference and cancel-journal FAIL with no server, as required | 1770 | f | `1b30b1de` | 5/2/4 | FAIL. The sampler ran from `build/node`, which failed no-leak and full-workflow. code-main exited 0 with `CWSUM pass=4 fail=0` in `1790389` ms. full-journal, transcript and review PASS. | 1771 | c | `1b30b1de` | 5/0/6 | PASS: `CWO 0 FAIL 19` at 20049 ms, server `C 499`, 7 journal records with 1 CANCEL | 1772 | r | `1b30b1de` | 5/0/6 | PASS. Run 1 was SIGKILLed (137) during the first inference after the replace, and the file on disk was correct. Run 2 exited 0 with `CWO 0 PASS 1 6` in 244394 ms. Journal: 80 records, 2 OPENs, 13 operations each started once, 1 settled by the restart. | 1773 | f2 | `1b30b1de` | 6/1/4 | FAIL from the driver slot collision (CWSUM count in lcw 60 = objective 3's CWE slot; 18 `CWE 3` lines read as 19). code-main exited 0 with `CWSUM pass=4 fail=0` in `1645009` ms. full-journal (174 records), transcript, review and no-leak PASS. | 1774 | f3 | `25c9a30a` | 3/4/4 | FAIL. code-main hit its fixed 3600 s deadline (exit 62, `3600078` ms) with o0 and o1 PASS (5 and 2 turns, as in round40) and o2 and o3 unfinished, so journal, transcript and review fail as consequences. no-leak PASS. | 1775 | c2 | `25c9a30a` | 5/0/6 | PASS: `CWO 0 FAIL 19` at 20090 ms, server `C 499`, 7 journal records with 1 CANCEL | 1776 | r2 | `25c9a30a` | 5/0/6 | PASS, on a contended host. Run 1 was SIGKILLed (137) during the first inference after the replace, and the file on disk was correct. Run 2 issued no second replace and exited 0 with o0 PASS in 590011 ms. Journal: 80 records, 2 OPENs, 13 operations each started once, 1 settled by the restart. | 1777 | f4 | `25c9a30a` | 7/0/4 | PASS, in the quiet slot granted by Manager cycle 24 (13:56:50Z-14:21:48Z, pool-8-9, no spark-window). The start check inside the lock passed: load1 9.64, and no ollm/train process running (ownmodel's eval was stopped). code-main exited 0 with `CWSUM pass=4 fail=0`, o0..o3 PASS in 5/2/5/3 turns. full-journal: 174 records, 29 operations each started once, 0 bad. Transcript, review and no-leak PASS. Partly contended: ownmodel's eval ran 13:58:31Z-14:00:29Z, resumed on a false END line from my script, then re-paused. The sampler found a foreign thread on 8/9 in 10 of 150 samples: brief runnable threads of host processes, none ollm or train (listed under Contamination). Not shown in the table: an earlier launch at 13:56:12Z was refused at once ("BASE must not exist": the driver script had created BASE) and ran no inference. Its record is kept; attempt 1 at 12:15:29Z was NOT_RUN (load 10.45, 4 ollm processes). | 1778 1779 Each part exits 1 whenever a check is NOT_RUN (`lt_end`), so the check table, not the exit status, is the verdict. 1780 1781 f4 is the fixed driver's first full four-objective run to end (CWSUM 4/0). 1782 1783 **Contamination.** `live-cpu` takes one sample every 10 s and counts the samples in which a foreign thread was running on core 8 or 9. Data lines only; the closing `CPU done samples N` line is not a sample: 1784 - f: 7 of 106 samples. The sampler started at 09:08:31Z, about 12 minutes after f did (08:56:00Z), so the start of f was not sampled. 1785 - c: none in 4 samples. 1786 - r: 7 of 73 samples (4 of them `grep`). 1787 - f2: 22 of 155 samples (11 of them `grep`). 1788 - f3: 95 of 349 samples (46 of them `grep`). The `grep` threads came from many pids and cannot be attributed after the fact; the others included `kcompactd0`, `git`, `python3` and `kswapd0`. 1789 - c2: 5 of 5 samples (4 of them `grep`). 1790 - r2: 51 of 185 samples (9 of them `grep`). 1791 - f4: 10 of 150 samples, each a briefly runnable thread of a host process, some of them long-lived daemons: `mi-scavenger` and `agent-archive` twice each; `tailscaled`, `tokio-rt-worker`, `pi-fs-worker`, `python`, `omp`, `git` and `find` once each (one sample held both `tailscaled` and `mi-scavenger`). None was ollm or train. 1792 1793 The sampler ran on core 5 for f, c and the start of r, and on core 0 from 09:35:59Z (partway through r) onward. The `cpu.NOTE` files record the core-0 use as unapproved; the Manager approved it in cycle 16 (BOARD 2026-11-07T11:19:33Z). 1794 1795 f3, c2 and r2 ran on a contended host, and f4 on a partly contended one (ownmodel's eval 13:58:31Z-14:00:29Z; load1 9.64 at the start and 17.59 at the end). Their wall times are recorded but are not measurements of the workflow. 1796 1797 f3's turns took 2 to 5 times longer than f2's at equal token counts (for example 644695 ms against 279335). ollm stayed alone on core 9, the load average was 22 on 20 cores, and other lanes' ollm serve, train and gtrain processes were running on other cores (`f3/NOTE`, `ps-ollm.txt`). Shared memory bandwidth is the likely cause, but it was not measured. 1798 1799 These timings are not speed evidence. 1800 1801 **Against DRA-290's harness** (same programs, model and objectives): 1802 1803 | Run | DRA-290 | This run | 1804 | --- | --- | --- | 1805 | full | exit 0 in `1632430` ms | exit 0 in `1790389` ms (f), `1645009` ms (f2) and `1492808` ms (f4, partly contended); f3 hit the 3600 s deadline (contended) | 1806 | cancel | `C 499 … 22072` | 20049 ms (c) and 20090 ms (c2) | 1807 | crash run 2 | 295826 ms | 244394 ms (r) and 590011 ms (r2, contended) | 1808 1809 **Limits:** 1810 - One server, CPU only. 1811 - DEPLOYED.json's runtime_sha256 `926c30fa`… does not match the ollm used here (`f99fce9f`…), so this is not the deployed runtime (DRA-292). 1812 - Only policy 1 ran live. The FIFO and goal-aware live arms are NOT_RUN. 1813 1814 ## Operator view and commands (DRA-291) 1815 1816 Status: IMPLEMENTED in `view.om`, `op.om` and `code.om` (with OPER records in 1817 `journal.om`), exercised on native Linux AArch64 by `tests/view-accept.om`, 1818 which drives the real `omnode-code` and `omnode-infer` through `omnode-op` 1819 only, against `tests/fake-serve.om`, a server that answers with the recorded 1820 round40 model turns. Not QUALIFIED on the Spark and not DEPLOYED. 1821 1822 ```sh 1823 { printf 'om2\n'; cat seed/net/http.om seed/net/notls.om seed/node/op.om; } | seed/out/omc > build/node/op 1824 { printf 'om2\n'; cat seed/net/http.om seed/net/notls.om seed/node/tests/fake-serve.om; } | seed/out/omc > build/node/fake-serve 1825 chmod +x build/node/op build/node/fake-serve 1826 D="seed/json/json.om seed/node/tests/drv.om seed/node/tests/nodedrv.om" 1827 { printf 'om2\n'; cat $D seed/node/tests/view-prep.om; } | seed/out/omc > build/node/view-prep 1828 { printf 'om2\n'; cat $D seed/node/tests/view-accept.om; } | seed/out/omc > build/node/view-accept 1829 chmod +x build/node/view-prep build/node/view-accept 1830 build/node/view-accept $PWD/build/node OMC40 ROUND40 build/node/accept # VIEWSUM pass=46 fail=0, exit 0 1831 ``` 1832 1833 ### Model 1834 1835 The creator alone holds and changes state. Before its workers start it maps 1836 one shared page (32768 bytes, `vw_new`) and, when VIEW is not 0, forks the 1837 view process (`vw_spawn`): an `.om` HTTP server on 127.0.0.1 built on 1838 `seed/net/http.om`. The view process only reads the page and posts commands 1839 into its mailbox; it drops the creator's life-pipe write end and the journal 1840 descriptors, and exits when the creator sets the stop word or is gone (its 1841 parent pid changes). Workers never see it. 1842 1843 Every creator loop writes a snapshot under a seqlock and appends one event 1844 per change to a ring of 256 events; the version counts the events of this 1845 incarnation, and the incarnation is the journal's fence. Event types: 1 job 1846 (what, id, value; the same values as the `CWE` lines), 2 objective result, 1847 3 command, 4 pause, 5 worker, 6 admission refused, 7 uncertain effect. 1848 1849 | Request | Answer | 1850 | --- | --- | 1851 | `GET /view` | snapshot: authority (generation, paused, journal seq and failure, fence, version of the last pause change), queue (waiting, ready, running, review, unknown, limit, review limit, admissions refused), commands (committed, refused, last id), workers (pid, incarnation, control acknowledged, paused), uncertain job ids, objectives (kind, K, N, A, state, turns, budget, phase, job in flight, result, version of the last change, redirect and cancel pending, next job seq), limits | 1852 | `GET /view?since=S&inc=I` | delta `[version, type, target, x, a, b]` for every event after S when I is this incarnation and the ring still holds them; otherwise a snapshot (a client resyncs from it) | 1853 | `POST /cmd?id=&op=&target=&inc=&ver=&a=&b=&c=&d=` | acknowledgement `{id, status, version, journal_seq, incarnation}` | 1854 | `GET /health` | `{"ok":true}` | 1855 1856 Polling, not streaming: one request per connection keeps the single-threaded 1857 view process answering commands while a client is slow or gone. 1858 1859 ### Commands 1860 1861 Ops: 1 pause, 2 resume, 3 cancel objective, 4 set its turn budget to a 1862 (0..7), 5 redirect it to kind a (1..3), K b, N c, A d (each 0..99). 1863 `omnode-op PORT cmd ID OP TARGET INC VER [A..D]` posts one; `ID` is the 1864 operator's command id, `INC`/`VER` the incarnation and version of the view 1865 the decision was made on. 1866 1867 | Status | HTTP | When | 1868 | --- | --- | --- | 1869 | committed | 200 | durable in the journal and acted on | 1870 | duplicate | 200 | the id was committed before (also by an earlier incarnation); the original version is returned, nothing runs again | 1871 | stale | 409 | another incarnation, or the target changed after VER (the pause state for 1 and 2, the objective for 3..5) | 1872 | invalid | 400 | unknown op or target, out-of-range argument, a finished objective, pausing when paused | 1873 | refused | 500 | the journal refused the record | 1874 | busy | 503 | another command is posted and not yet taken | 1875 | pending | 504 | no acknowledgement in 5 s: post the same id again | 1876 1877 The creator takes one command per loop. Pause and resume go through 1878 `auth_pause` (which journals PAUSE and tells every worker), then OPER is 1879 appended and synced; the objective commands append OPER first and then act: 1880 cancel ends the objective with 19 at once when nothing is in flight, else 1881 its job is cancelled through `auth_cancel` and the objective ends 19 when 1882 the job's result arrives; redirect sets the goal and starts over from 1883 unread the same way; budget takes effect at the next turn (out of turns 1884 ends 12). A committed command's acknowledgement carries the version of its 1885 own command event. At a restart the OPER table is replayed in order after 1886 the objectives resume (pause comes back from the PAUSE record), so a 1887 cancelled objective stays cancelled and a budget or goal stays set. 1888 1889 At the admission limit only inferences are refused: a tool job is issued 1890 after its objective's previous job left the queue, so it takes that job's 1891 place. A refused inference is asked for again at the next turn; a tool job 1892 the authority refuses anyway ends its objective with 23 instead of leaving 1893 it waiting unseen. The view counts the refusals. 1894 1895 An effect whose worker died while the job was assigned is shown at once as 1896 uncertain (snapshot and event 7) and its objective ends 21. The scheduler 1897 cannot tell whether the tool started; the next incarnation's recovery 1898 settles it from the journal: a START without a DONE stays UNKNOWN for good 1899 (and stays listed), no START proves the effect never ran (the job is 1900 cancelled and no longer listed). 1901 1902 ### Acceptance and controls 1903 1904 `view-accept BUILD OMC ROUND40 OUTDIR [SCENARIO...]` (46 checks; scenario 1905 names select a subset; exit 0 when nothing failed, 1 otherwise, 2 for usage) 1906 prepares each scenario in `OUTDIR/` (`cmds` for commands) with 1907 `nd_prep` (also available alone as `view-prep ROUND40 BASE ID[,ID...] 1908 [WRONG]`, whose output is byte-identical to the Python original it replaces) 1909 and prints answers in its details as the compact JSON `omnode-op` printed. It 1910 runs nine scenarios, each a real 1911 `omnode-code` (or `omnode-code-test overload LIMIT` / `uncertain`, the same 1912 program with a test hook) and the fake server: the full four-objective run 1913 followed only through deltas across a 1.5 s disconnect (no version gaps; the 1914 job events equal the `CWE` lines); resync to a snapshot for another 1915 incarnation or an impossible `since`; stale, invalid, other-incarnation, 1916 committed and duplicate commands (a duplicate pause carries the pause's 1917 original version, though the pause moved the view on before its ack); pause 1918 holding grants for 4 s and resume; 1919 cancel and redirect of an objective whose inference is in flight; a budget 1920 of 2 turns; admission limit 1 with refusals visible, a command committed and 1921 the run completing; a worker killed while assigned a replace; the creator 1922 killed with SIGKILL (the view exits with it, the next incarnation replays 1923 both commands, answers the old id as duplicate with its original version, 1924 and old clients resync). `omnode-op` usage errors exit 2. 1925 1926 Each change below is built into its own copy of the programs and run on one 1927 scenario; the named check must fail. The same copy with no change runs every 1928 scenario first and must pass all of them, else the mutant runs are void. 1929 1930 | Change | Check that fails | 1931 | --- | --- | 1932 | staleness not checked | `cmd-stale-409` | 1933 | committed ids not looked up | `cmd-duplicate-ack` | 1934 | OPER not replayed at restart | `crash-oper-replayed` | 1935 | no uncertain event | `uncertain-event` | 1936 | delta starts one event late | `resync-delta-from-0` | 1937 | incarnation not checked | `cmd-other-incarnation` | 1938 | pause recorded but not applied | `cmd-paused-holds` | 1939 | redirect ignored when the cancelled job returns | `redirect-run-passes` | 1940 | budget ignored | `budget-ends-12` | 1941 | refusals not counted | `overload-refusals-visible` | 1942 | acknowledgement carries the version current after acting | `cmd-pause-duplicate-version` | 1943 | view process outlives its creator | `crash-view-exits-with-creator` | 1944 1945 ## Release lifecycle and durable results (DRA-292) 1946 1947 Status: IMPLEMENTED in `release.om` (the lifecycle program `release`), 1948 `journal.om` (RESULT records), `code.om`, `auth.om` and `op.om`; exercised on 1949 native Linux AArch64 by `tests/release-accept.om` in `fake` mode, which answers with the 1950 recorded round40 turns only. The same driver in `live` mode runs every 1951 scenario against the own model (aien-train `ollm serve`, or `gserve` on the 1952 GB10 inside an authorized window); a fake run is host regression, not model 1953 qualification. Not QUALIFIED and not DEPLOYED. 1954 1955 ```sh 1956 # from the checkout root: release compiles itself first, then the six programs 1957 { printf 'om2\n'; cat om/tls/sha2.om seed/node/release.om; } | seed/out/omc > build/node/release 1958 chmod +x build/node/release 1959 build/node/release build build/node # BUILD_OK name bytes sha256, six programs 1960 { printf 'om2\n'; cat om/tls/sha2.om seed/json/json.om seed/node/tests/drv.om seed/node/tests/nodedrv.om \ 1961 seed/node/tests/release-accept.om; } | seed/out/omc > build/node/release-accept 1962 chmod +x build/node/release-accept 1963 build/node/release-accept fake $PWD/build/node OLDBIN OMC40 ROUND40 /tmp/rel [SCENARIO...] 1964 OLLM=/abs/path/ollm VERB=serve CK=... MERGES=... PORT=18294 \ 1965 build/node/release-accept live $PWD/build/node OLDBIN OMC40 ROUND40 /tmp/rel 1966 ``` 1967 1968 The acceptance driver runs `BUILD/release`, so BUILD must hold it. BUILD, 1969 OLDBIN, OMC40, ROUND40 and OUT are absolute paths. Keep OUT short: the node's 1970 `jn_open` refuses a journal directory longer than 100 bytes (error 26; the 1971 node exits 56 with `code-main: journal refused (...), exit 56` on stderr), and the deepest one the driver uses is 1972 `OUT/compat/journal`. The scenarios are `full lifecycle restart conflict 1973 worker uncertain cancel commands down authority journal memory`; naming none 1974 runs all twelve. 1975 1976 OLDBIN holds `infer`, `tool` and `code-main` built from the DRA-290 tree 1977 (git `79894168`), the reader before OPER and RESULT. 1978 1979 ### Lifecycle 1980 1981 `release` (`release.om` composed after `om/tls/sha2.om` for SHA-256) is the 1982 whole lifecycle; no shell remains. Errors are one `release: MESSAGE` line on 1983 stderr with exit 2 for usage, an unknown command or port 18091, 3 for a 1984 process in the wrong state, 1 for any other failure. 1985 1986 | Command | Effect | 1987 | --- | --- | 1988 | `build OUT` | from the checkout root (refuses, 2, without `seed/out/omc`): compose and compile the six programs with this checkout's `seed/out/omc`; two builds are byte-identical | 1989 | `serve STATE PORT OLLM VERB CK MERGES` | start the own-model server; waits for its PORT line | 1990 | `start STATE BIN OMC PORT VIEW` | start `omnode-code` on STATE (`root/`, `work/`, `journal/`, `objs.txt`); BIN must be a directory; refuses (3) while `node.pid` is alive | 1991 | `health STATE` | the model's `GET /health` and the node's view; 0 when both answer | 1992 | `stop STATE` | pause (op 1), wait until nothing runs or is in review (at most 900 s), SIGTERM; `view-at-stop.json` | 1993 | `restore STATE` | start again on the same journal (incarnation + 1), then resume (op 2); reports the first view whose `journal_seq` has reached the resume ack's (the creator publishes its snapshot after the commit), up to 5 s, else exits 1 | 1994 | `unserve STATE` | stop the model server | 1995 | `snapshot STATE SNAP` | copy `root/`, `work/` and `journal/` into SNAP (each must not exist there); refuses (3) while `node.pid` is alive | 1996 | `rollback STATE SNAP` | replace STATE's `root/`, `work/` and `journal/` with SNAP's copies (all three must exist first); refuses (3) while `node.pid` is alive | 1997 1998 `snapshot` and `rollback` copy directories, regular files (bytes, permission 1999 bits, each file synced) and symbolic links (as links, never followed); any 2000 other file type, or a tree deeper than 64, fails (1) naming the directory and 2001 the errno. They print `snapshot SNAP files F dirs D links L bytes B` (or 2002 `rollback STATE ...`). 2003 2004 Every program `release` starts gets an empty environment and no PATH search 2005 (`execprog`): OLLM, BIN and OMC are paths. Host tools it runs that are not 2006 compiled by `build`: the own-model server OLLM (serve) and `seed/out/omc` 2007 (build). It needs no `sh`, `date`, `sha256sum`, `grep`, `cp` or `tail`. 2008 2009 The journal's lock is the one active authority: a second `omnode-code` on 2010 the same journal exits 50 (30 + 20, fenced) and changes nothing. 2011 2012 Cutover: `stop`, `snapshot`, `restore` with the new BIN. Reversal: `stop`, 2013 `rollback`, `start` with the old BIN. A reader refuses record types newer 2014 than it knows (24, exit 54) before writing anything, so the DRA-290 build 2015 refuses a journal that holds OPER (9) or RESULT (10) and leaves it 2016 unchanged; rolling back therefore needs the snapshot taken before the new 2017 build ran. `journal-rollback-from-snapshot` runs exactly this through 2018 `release snapshot` and `release rollback`. 2019 2020 ### Durable results 2021 2022 When an objective ends, `cw_end` appends RESULT (type 10: word 3 the 2023 objective, 4 the result, 5 its turns) before the result is printed. On a 2024 restart an objective with a RESULT is reported again (`CWO` with the same 2025 result and turns) and never resumed: a failure is final, as in DRA-290, 2026 and an objective that ended UNKNOWN (21) cannot issue its effect again. The 2027 journal refuses a second RESULT for an objective, result 0 and an index 2028 past 63 (25) before writing. If the journal refuses the result, the creator emits no completion for that objective, stops admission and exits 58 after cleanup. Recovery uses the committed journal. 2029 2030 An inference worker that dies while it holds a job: inference is class 2 2031 (no external effect), so `au_lost` records it not performed (DONE how 6), 2032 as recovery does at a restart, and the objective asks again; only class 1 2033 and 3 effects stay UNKNOWN. The uncertain-effect test hook kills a worker 2034 only after the job's START is durable: a job is assigned before its 2035 worker's proposal is decided and journaled, and the first acceptance run 2036 killed one holding ADMIT only. That window depends on worker timing, so no 2037 mutant of the guard is killed deterministically; `uncertain-start-durable` 2038 fails whenever it is hit. 2039 2040 ### Acceptance and controls 2041 2042 `release-accept.om` runs twelve scenarios on the real programs: the full 2043 four-objective run (prompts and model texts equal the recording, one START 2044 per operation, independent review, results durable across a rerun with no 2045 model request), the lifecycle (start, health, stop with jobs ready, restore, 2046 finish), the creator killed after a replace (no second effect), a conflicting 2047 write after the read (15, the other write kept), a dead inference worker 2048 (rerun), an uncertain replace (21, final after restart), cancel of a running 2049 inference, stale, burst and duplicate commands, the server down (16), a 2050 second authority, journal compatibility in both directions, and address-space 2051 caps. Each prints MEASURED latency and seconds; the memory scenario prints 2052 MEASURED `memory-peak-kB` (VmHWM and VmPeak of `code-main`, `infer` and 2053 `tool`, sampled from `/proc` every 5 ms) and fails `memory-peak-measured` 2054 when no `code-main` sample was read. `memory-caps-fail-closed-then-pass` 2055 runs that same one-objective job again under the `prlimit` host word 2056 (keyword 235, RLIMIT_AS): half the measured `code-main` VmPeak, then that 2057 peak, then double, up to 32 times the peak. A smaller cap fails closed only 2058 with an explicit result: one `CWO 0 FAIL` line matching the journaled RESULT and exit 1, or a `code-main` 2059 refusal exit 50 to 57 with its cause line for that exit on stderr 2060 (`code-main: WHAT, exit R` with R equal to the exit). A pass is 2061 one `CWO 0 PASS` line, exit 0 and a consistent journal. The result code and turn count on either line must exactly match the sole RESULT for objective zero. A missing RESULT, a conflicting exit or trailing output on the result line fails the trial. A signal 2062 death that leaves no journal and nothing on stderr is treated as the kernel 2063 refusing the exec under the cap (it cannot be told apart from a death after 2064 the exec but before the node wrote anything) and is reported (`c=2`) and not counted 2065 either way. A signal death after the node started (a journal or stderr 2066 exists) is a crash and fails the check. A harness 2067 failure (exit 97, 126 or 127, an output that cannot be read, a wait error), a 2068 journal that is torn, unreadable or has more than one start, or any other 2069 end fails the check. The check passes when one cap passes after at least one 2070 explicit smaller-cap failure, and only after the uncapped run passed; each 2071 trial shows the cap, rc, CWO lines (`n`), class (`c`: 0 explicit fail, 1 2072 pass, 2 refused at exec, 3 bad), journal state (`j`: 0 none, 1 consistent, 2 2073 other) and starts (`s`). Each trial waits at most three times the uncapped 2074 run, measured from before the node starts; a trial past that deadline 2075 (`rc=-110`) fails the check. On this host the cap that first passes is not 2076 the node's own memory need: `tool` runs each test program through 2077 `execpure` (`seed/omc/omc.om`), which sets RLIMIT_AS to its own fixed 2078 ceiling. Under an inherited cap below that ceiling the raise is refused. At 2079 the lowest caps the compile step itself cannot run, and `code-main` ends 2080 `CWO 0 FAIL 17` (tool failed). At the caps above those the test program's 2081 exec fails (exit 121), the tool reports that exit as the program's result, 2082 the next prompt differs from the recorded one, and in fake mode the 2083 recording has no answer for it, so `code-main` ends `CWO 0 FAIL 16` 2084 (inference failed): a recording miss, not the node noticing a memory 2085 problem. So the explicit fails come from caps below execpure's ceiling, the 2086 passing cap is the first step at or above it, and when 32 times the 2087 `code-main` peak stays below it the check fails whatever the node does. The 2088 check shows that under a cap at which its tools cannot run the run ends in an 2089 explicit FAIL, and that the node completes under a cap that leaves its tools 2090 their ceiling. It does not read the job file, so it does not show that a 2091 failing run leaves that file unchanged, and it does not measure how much 2092 memory the node needs. 2093 The one-job stand-in does not exercise the more-than-one-start guard or a 2094 trial that ends with an exit other than 1 after its single `CWO` line: those 2095 are guards in the check, not cases observed on this host. 2096 The host run uses a one-job stand-in for the round40 recording, which is not 2097 at the path qual reads: 2098 `seed/node/tests/ra40/final-selected.json`, a small 2099 loop repair (id 76666) whose answers were constructed from the node's own 2100 prompts on this build. It serves only the memory scenario; with it as 2101 ROUND40 every other scenario fails fixture preparation. The driver prints 2102 `PASS|FAIL|NOT_RUN NAME DETAIL` per check and `RELSUM pass=P fail=F 2103 not_run=N mode=MODE`; a node output it needs that is missing, unreadable or 2104 over capacity fails the next check, naming it. 2105 2106 A resumed objective reads the file it edited before the restart. The four-case 2107 fixture includes two recorded Spark model turns for that continuation in 2108 `restart.map`. The restart, journal-forward and journal-rollback completion 2109 checks exercise them. With a fixture lacking those turns, an unrecorded prompt 2110 is reported as NOT_RUN. Live mode requires the model to complete the task. The driver exits 0 only 2111 when every check passed, 3 when none failed but some were NOT_RUN, 1 when 2112 one failed. 2113 2114 Mutants, each one line, run once against the scenario named (outputs under a 2115 short OUT): 2116 2117 | Change | Check that fails | 2118 | --- | --- | 2119 | RESULT not journaled (`code.om`: `x = jn_result i r cw_g i 7` → `x = ulong 0`) | `full-results-durable` (`CWO 0 FAIL 16 7`) | 2120 | journaled RESULT not reported at restart (`code.om`: `if ne jn_res i 0` → `if false`) | `full-results-durable` | 2121 | lost inference left UNKNOWN (`auth.om`: the class-2 test in `au_lost` → `if false`) | `worker-death-rerun` (`CWO 0 FAIL 23 1`), `worker-death-turns-equal-recorded` | 2122 | rollback leaves the new journal out (`release.om` `rl_rollb`: `rl_cp1 3 2 rljour` → `x = ulong 0`) | `journal-rollback-from-snapshot` (`opens=1`) | 2123 | second RESULT accepted (journal.om) | journal gate case 16 (exit 173) | 2124 | second RESULT accepted (Lean model) | `second_refused`, `apply_keeps` no longer prove | 2125 2126 `proofs/Result.lean` models `jn_rapply`, the restart decision of `cw_run` and 2127 `au_lost` in Lean 4 core (checked with Lean 4.35.0; every theorem depends on 2128 `propext` only): an applied RESULT is never replaced, a second one for the 2129 objective is refused, every later replay keeps it so the objective is never 2130 resumed, and only a class-2 lost action is recorded not performed. The proof 2131 covers the model; its correspondence to the `.om` code is by reading. 2132 2133 The [four recorded operator-control cases](tests/recorded-control/README.md) reproduce the original prepared objectives, expected turns and fake-server map for host checks. 2134 2135 ### Release gate 2136 2137 `tests/release-gate.om` checks in Omega that `release stop` makes a durable 2138 pause before it drains and stops the node. It is composed after the JSON 2139 reader and the driver library and needs a release build (`release build`): 2140 2141 ``` 2142 { printf 'om2\n'; cat seed/json/json.om seed/node/tests/drv.om seed/node/tests/release-gate.om; } | seed/out/omc > release-gate 2143 release-gate BUILD OMC40 OUT 2144 ``` 2145 2146 BUILD, OMC40 and OUT are absolute. The gate removes and recreates 2147 `OUT/release-gate.d` and keeps it afterwards. It holds the state with two 2148 objectives and an empty root, an empty fake-serve map, so every model request 2149 gets 404 after 4000 ms and the objective ends 16, and the start and stop output. 2150 The gate starts `fake-serve` and then runs `release start`. It waits for the 2151 first `CWE` job event in `run.out`, while objective 0's inference is in flight 2152 and objective 1 has not run yet. Then it runs `release stop` and checks: 2153 2154 | Check | Passes when | 2155 | --- | --- | 2156 | `stop-rc` | the stop exits 0 (the detail shows its first stderr line) | 2157 | `stop-journal-pause` | the journal holds a PAUSE with word 3 = 1, then an OPER of op 1 and no START after it | 2158 | `stop-view-paused` | `view-at-stop.json` has `authority.paused` 1 and `queue.running` 0 | 2159 | `stop-node-gone` | the pid in `node.pid` no longer exists | 2160 2161 It prints `PASS|FAIL NAME DETAIL` for each check, then `RELGATE pass=P fail=F`. 2162 It exits 0 when nothing failed, 1 when a check failed, and 2 for bad usage. At 2163 the end it sends SIGKILL to the node's process group and to `fake-serve`. On the 2164 real build all four checks pass in about 4 s. The mutant control is a `stop` 2165 that skips the pause (`if ne rl_post rlone 0` replaced by `if false`). Against 2166 it the gate fails `stop-rc` (`release: the node exited while stopping`), 2167 `stop-journal-pause` (`pause_at=none`) and `stop-view-paused` 2168 (`view-at-stop.json` missing, -2), and exits 1.