code wiki / _hdl_build / nx_orchestrate.nx

nx_orchestrate.nx

buildroot/runtime/_hdl_build/nx_orchestrate.nx

24799 B421 linesdepth 5pulls 5 transitivereach 1 importersview sourcekind tooltopic orchestrate
docsdependenciesstructsconstsfunctions

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

nx_tool_run.nx nx_orchestrate.nx nx_orchestrate_owner_gate_t49.nx

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

main oc_w oc_dec oc_live tr_run_capture_to tr_run_capture_tr tr_run_capture_core tr_run_capture_core_owned tr_run_capture_core_eviden sys_mmap_shared tr_clock_ms sys_munmap sys_pipe2 sys_fork sys_close sys_default_signal sys_bind_parent_lifetime sys_exit sys_setpgid tr_capture_redirect sys_chdir sys_close_inherited sys_execve tr_exec_failed tr_watchdog_start tr_capture_stop tr_reap tr_evidence_wait tr_drain_until_owned tr_observe_exit nx_kill wait_status_rc oc_b oc_bn oc_cpz oc_eval_pre oc_eval oc_pre tr_run_capture_to ↻ oc_reads

structs

none

consts

30const K_MAGIC_30000: i64 = 30000
31const K_MAGIC_262144: i64 = 262144
32const K_MAGIC_262160: i64 = 262160
33const K_MAGIC_65536: i64 = 65536
34const K_MAGIC_32768: i64 = 32768
35const K_MAGIC_65535: i64 = 65535
42const OC_EVAL_CAP: i64 = 64
43const OC_FIRE_CAP: i64 = 4
44const OC_FIRE_TIMEOUT_MS: i64 = 600000
45const OC_LOCK: *u8 = "knowledge/status/orchestrate.lock"
83const OC_ADMIT: *u8 = "/volume1/homes/elderwesto/nishihost/nx_build_admit.elf"
84const OC_ADMIT_TIMEOUT_MS: i64 = 10000
198const OC_LOAD_TIMEOUT_MS: i64 = 120000 // nx_store_put load: 2x the worst fsync convoy measured (~60 s), well under one cron interval
199const OC_LIVE_CAP: i64 = 4096

functions

47func 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
48func 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
49func 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
50func oc_reads(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: oc_eval
59func oc_has(buf: *u8, s: i64, e: i64, pat: *u8) -> i64
73func oc_cpz(dst: *u8, cap: i64, buf: *u8, s: i64, e: i64) -> i64
called by 1: main
85func oc_pre(s: *u8, pre: *u8) -> i64
called by 1: oc_eval
91func oc_eval(pred: *u8, fpath: *u8, fneedle: *u8, fbuf: *u8) -> i64
153func oc_eval_pre(fpre: *u8, fpath: *u8, fneedle: *u8, fbuf: *u8, lbuf: *u8, rbuf: *u8) -> i64
called by 1: main calls 1: oc_eval
186func oc_runner_refused(cap: *u8, n: i64) -> i64
called by 1: main calls 1: oc_has
200func oc_dec(v: i64, out: *u8) -> i64
called by 1: main
213func oc_live(outlog: *u8, a: *u8, b: *u8, c: *u8, d: *u8) -> i64
called by 1: main
233func main(argc: i64, argv: *i64) -> i64