interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / device-window

1e24af5 device-window: report a lost closer; document refusal order, timing gap and preflight scope (DRA-441 review N1, N2, N4, N5) Drake Stapleton committed 2026-11-17
..
README.md7288
compare.py25554
race.om10033

README.md

Device-window controls (CPU only)

Two programs run the GB10 device window: tools/run-device-window.sh and its Omega successor tools/run-device-window.om (Linear DRA-441). The shell script stays until one device window under a queen-scheduled lease, run by the Omega program, matches the shell script's rows (evidence/device-window/L939-w3); it is removed in the same change that files that window's evidence. Both controls below run on the CPU, open no GPU, never call the real spark-window and need no lease.

Compiler

The Omega programs here (race.om, tools/run-device-window.om) are built with omega-mv main seed/out/omc, sha256 34d611ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3 (omega-mv 50feb135; unchanged through e8fcdc01, 2026-11-16).

printf '%s  %s\n' 34d611ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3 "$OMC" | sha256sum --check --strict
mkdir -p build
"$OMC" < tools/run-device-window.om > build/run-device-window && chmod +x build/run-device-window
"$OMC" < tests/device-window/race.om > build/race && chmod +x build/race

build/run-device-window finds the repository as the parent of its own directory, so keep it in build/.

compare.py: the successor against the shell script

python3 tests/device-window/compare.py tools/run-device-window.sh build/run-device-window build/cmp
# COMPARE PASS cases=N, exit 0

build/cmp must not exist; remove it afterwards. The cases are listed in main() of compare.py; the first eight are the refusal controls: refuse-no-ledger (no --ledger), refuse-ledger-needs-id (--ledger without an id), refuse-ledger-chars (a/b), refuse-unknown-arg (--bogus), refuse-pairs-not-integer (5x), refuse-pairs-lt-5 (4), refuse-dry-cvd-unset (a dry-run with CUDA_VISIBLE_DEVICES unset) and refuse-dry-in-window (a dry-run inside SPARK_WINDOW). Then come the other refusals (CUDA_VISIBLE_DEVICES=0 among them), complete and incomplete dry-run plans, and device mode against a fake spark-window that runs every row on the CPU: a passing window, failing rows, an existing evidence directory, a failed open, a missing cubin directory and missing inputs. Each of these compares exit status, stdout, stderr and the whole evidence directory. The fake tree root is a git repository with a modified tracked file, and one conformance result file is over 64 KiB.

Four cases kill a run while a window is held on the fake chip: device-signal-closes sends SIGTERM to the whole process group (both programs close the window by its id); device-parent-term and device-parent-kill kill only the driver (SIGTERM, then kill -9) while the row keeps running. The window must not be closed before the row exits: on SIGTERM both programs close after the row; on kill -9 the shell script never closes (the lease runs out) and the successor closes after the row. device-kill-in-open kills only the driver (kill -9) while spark-window open is still running: the shell script never closes that window; the successor's closer reads the id from the open itself and closes the window after the open exits, and no row runs. om-closer-gone runs the successor only and kills its closer (kill -9) while a row runs: nothing can close the window then, and the successor must say so, naming the window, on stderr and in window.txt, and close nothing.

refuse-dry-cvd-huge and refuse-dry-in-window-huge give the dry-run refusals a 5000-byte value, which both programs quote whole. om-refuse-env-* run the successor only: an environment entry over 65535 bytes, or an environment too large for the execprog packet, is refused with exit 3 before anything is printed, opened or created.

Negative controls (evidence/device-window/DRA-441/gates.sh runs them and expects exit 1): a mutant of the successor that ignores the result of the evidence-directory mkdir gives COMPARE FAIL; a mutant whose rows do not hold the closer's hold pipe fails device-parent-kill (the window is closed while the row still runs); a mutant whose closer takes a lost driver as "nothing to close" fails device-parent-term and device-parent-kill (device-kill-in-open still passes under it: there the closer takes the id from the open's own output, not from the driver).

Deliberate differences, listed in the header of tools/run-device-window.om: script_sha256 is the hash of the binary; children run as /usr/bin/env -i -- <environment> CMD because execenv takes at most 64 entries and 4096 bytes (the environment on spark-b87b had 78 entries and 4796 bytes on 2026-11-16); a closer process replaces the shell's trap, so a signal ends the program by that signal where the shell exited 130, a kill -9 of the driver still closes the window once its rows have exited, and a row's standard input is the closer's hold pipe; NN-*.out.sha256 is in bytewise order; --pairs without a value, a value above 2^63-1, an unset HOME, a window id that is not 1..4095 bytes of [A-Za-z0-9._-] and a value output over 64 KiB are refused with their own lines.

race.om: the evidence directory is created once

race.om checks the evidence-directory step (DRA-105, finding F5 of the DRA-106 audit refresh). Evidence is additions only: a run under a ledger id that already has a directory must refuse, and two runs started at the same moment with the same new ledger id must not both get past that step. Both programs create evidence/device-window/<ledger> with one mkdir (no -p), which either creates the directory or fails, so exactly one of two concurrent runs gets it.

Each trial, in a scratch tree holding a copy of the program:

  1. Two device-mode runs with the same new ledger id start together (both block on one pipe until the driver writes to it). Pass: one exits 2 with a REFUSE: line, the other exits 1 without one.
  2. The directory holds an empty rc.txt, a window.txt and no row log.
  3. A third device-mode run on the same id exits 2 with REFUSE: and leaves rc.txt and window.txt the same size.
  4. A dry-run on the same id prints EXISTS and exits 1.

No run reaches a window call. SPARK_WINDOW=NEGCTL-none skips the open, CUBIN_DIR names a missing directory so the run that got the directory stops at the cubin copy (exit 1) before the first row, and the runs get only PATH=/usr/bin:/bin, where there is no spark-window.

A program whose name ends in .sh is run with /bin/sh; anything else is copied to tools/run-device-window in the scratch tree and run directly.

build/race build/run-device-window build/race-om 100    # RACE PASS, exit 0
build/race tools/run-device-window.sh build/race-sh 100 # RACE PASS, exit 0

SCRATCH must not exist; remove it afterwards. Usage errors exit 2.

Negative controls: the script at 07f276fc checked [ ! -e "$out" ] and then ran mkdir -p "$out". Both runs of a pair passed the check in 69 of 100 trials of the logged fresh-clone run on spark-b87b (97 of 100 in an earlier working-tree run): RACE FAIL, exit 1. A mutant of the shell fix that uses mkdir -p fails every trial, and its sequential check too. Log: evidence/device-window/race-F5.log. A mutant of the successor that ignores the result of its mkdir fails every trial in the same way.