code wiki / _hdl_build / nx_orchestrate.nx
nx_orchestrate.nx
buildroot/runtime/_hdl_build/nx_orchestrate.nx
about
nx_orchestrate.nx -- auto lane (eats debt seq163). WAIT-FOR-OPENING QUEUE: sessions QUEUE actions blocked
by a sibling's in-flight work instead of colliding. Each knowledge/store/deployq- row =
id | title | precondition | status | planid | note
precondition = a CHECKABLE predicate, now COMPOUND-capable (v2, 2026-07-20 -- for safe mgmt deploys that
must fire only when the fix is STAGED *and* mgmt is CALM):
exists:<path> | contains:<path>:<needle> -- single, OR
headroom:[<floor_mb>[:<max_centiload>]] -- the box has build headroom NOW (2026-08-18): forks
nx_build_admit check [floor] [max]; satisfied iff it GRANTS (exit 0). QUEUE/DENY-MEM/
unreadable-proc all WAIT -- a guard that cannot measure must not fire (fail-closed). This is
the wait-for-opening absorber nx_build_admit's own header says its QUEUE verdict was designed
for, and that /api/build's REFUSED-LOAD ("nothing is queued for you anywhere") had never
been given: a queued build row `headroom: -> plan build-<target>` now fires on the poller
pass after the opening appears, instead of a human re-issuing it by hand.
<pred> && <pred> -- AND of two (BOTH must hold to fire)
(e.g. exists:nx_mgmt_api.elf.new && contains:knowledge/status/api_contract.log:VERDICT=GREEN).
This POLLER (cron */5, non-blocking) evaluates every `queued` row: satisfied -> FIRE the row's plan via
nx_plan_run (reusing its allowlist+pinned-arg security WHOLESALE -- an action is a pre-seeded plan-
workflow, never arbitrary exec) and re-put the row status=fired-rc<N>; unsatisfied -> WAIT (logged, no
dead thread, no clobber). SOTA: Temporal durable await-condition, sovereign. Never-brick: fires only plans.
nx_orchestrate run [qprefix] [outlog]
ENVELOPE v4 (2026-08-29): scan UNCAPPED -- the v3 cap counted SCANNED lines, so 63 dead history rows
at the plane head exhausted it and every queued row past index 63 was silently unreachable (measured
live: 135 queued rows, fired=0 on every pass, first queued row at plane index exactly 64). A CAP MUST
BOUND WORK, NOT SCAN: evaluations of queued rows cap at OC_EVAL_CAP, fires at OC_FIRE_CAP, overflow is
COUNTED AND PRINTED (deferred= / fire_deferred=), never dropped in silence. ONE pass at a time (flock;
a slow pass makes the next refuse rather than double-fire rows still marked queued).
exit: 0 ran (counts printed, or PASS-ALREADY-RUNNING) | 4 queue unreadable | 2 usage.
license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 1 importers
imports: nx_tool_run.nx
imported by: nx_orchestrate_owner_gate_t49.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 30 | const K_MAGIC_30000: i64 = 30000 |
| 31 | const K_MAGIC_262144: i64 = 262144 |
| 32 | const K_MAGIC_262160: i64 = 262160 |
| 33 | const K_MAGIC_65536: i64 = 65536 |
| 34 | const K_MAGIC_32768: i64 = 32768 |
| 35 | const K_MAGIC_65535: i64 = 65535 |
| 42 | const OC_EVAL_CAP: i64 = 64 |
| 43 | const OC_FIRE_CAP: i64 = 4 |
| 44 | const OC_FIRE_TIMEOUT_MS: i64 = 600000 |
| 45 | const OC_LOCK: *u8 = "knowledge/status/orchestrate.lock" |
| 83 | const OC_ADMIT: *u8 = "/volume1/homes/elderwesto/nishihost/nx_build_admit.elf" |
| 84 | const OC_ADMIT_TIMEOUT_MS: i64 = 10000 |
| 198 | const OC_LOAD_TIMEOUT_MS: i64 = 120000 // nx_store_put load: 2x the worst fsync convoy measured (~60 s), well under one cron interval |
| 199 | const OC_LIVE_CAP: i64 = 4096 |
functions
| 47 | func oc_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } called by 1: main |
| 48 | func oc_b(rep: *u8, pos: i64, s: *u8) -> i64 { var p: i64 = pos; var i: i64 = 0; while s[i] != (0 as u8) { if p < K_MAGIC_30000 { rep[p] = s[i]; p = p + 1 } i = i + 1 } return p } called by 1: main |
| 49 | func oc_bn(rep: *u8, pos: i64, v: i64) -> i64 { var p: i64 = pos; var m: i64 = v; if m < 0 { if p < K_MAGIC_30000 { rep[p] = 45 as u8; p = p + 1 } m = 0 - m } let t: *u8 = sys_mmap(28); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { if p < K_MAGIC_30000 { rep[p] = t[k - 1 - i]; p = p + 1 } i = i + 1 } return p } called by 1: main |
| 50 | func oc_reads(path: *u8, buf: *u8, cap: i64) -> i64 called by 1: oc_eval |
| 59 | func oc_has(buf: *u8, s: i64, e: i64, pat: *u8) -> i64 |
| 73 | func oc_cpz(dst: *u8, cap: i64, buf: *u8, s: i64, e: i64) -> i64 called by 1: main |
| 85 | func oc_pre(s: *u8, pre: *u8) -> i64 called by 1: oc_eval |
| 91 | func oc_eval(pred: *u8, fpath: *u8, fneedle: *u8, fbuf: *u8) -> i64 |
| 153 | func oc_eval_pre(fpre: *u8, fpath: *u8, fneedle: *u8, fbuf: *u8, lbuf: *u8, rbuf: *u8) -> i64 |
| 186 | func oc_runner_refused(cap: *u8, n: i64) -> i64 |
| 200 | func oc_dec(v: i64, out: *u8) -> i64 called by 1: main |
| 213 | func oc_live(outlog: *u8, a: *u8, b: *u8, c: *u8, d: *u8) -> i64 called by 1: main |
| 233 | func main(argc: i64, argv: *i64) -> i64 |