nx_compare_regen.nx
buildroot/runtime/nx_compare_regen.nx
about
nx_compare_regen.nx -- ON-NAS regeneration of the whole Nishi Compare publish surface (operator 2026-07-09:
"no frozen snapshots"). Re-MEASURES every matrix domain against the synced source tree (buildroot/runtime),
GATE-CHECKED: for each artifact the generator's liar-kill gate must exit 0 FIRST -- a RED measurement is NEVER
published (fail-closed). Then emits json+html per domain + the hub index json/html + the in-code OpenAPI, and
hot-swaps each into the LIVE docroot via write-.new + sys_renameat (atomic; a concurrent reader never tears).
Because nx_compare_serve reads the SAME docroot files, MCP tools/call and public REST update together, single
source. argv: [1]=buildroot dir (default "buildroot"), [2]=docroot prefix (default "../sites/nishifamily/compare/",
i.e. the live docroot relative to buildroot). The MCP allowlist row PINS these args (caller argv ignored) so a
tools/call caller cannot redirect writes. Targets must already exist (this regenerates, never scaffolds).
license_tier: ORIGINAL expect_exit: 0
dependencies 10 imports · 1 importers
imports: nx_tool_run.nxnx_compare_receipt_lib.nxnx_compare_scope_lib.nxnx_symdecl_lib.nxnx_estate_path.nxnx_forkfresh_lib.nxnx_compare_feed_lib.nxnx_catalog_lib.nxnx_ioadmit_lib.nxnx_heavyio_lib.nx
imported by: nx_compare_regen_gate_t138.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 34 | const RG_EMIT_CAPTURE_BYTES: i64 = 1048576 // the DIAGNOSTIC copy reserve only (the bytes a GATE RED prints back): since 2026-09-15 every generator page is captured into an OWNED buffer that grows to the page (tr_run_capture_owned, no ceiling), so no number here can cut a page off again. History: this was 1 MiB and SIGPIPE-killed the gameengine emitter the day its page passed 1 MiB (the run read "rc nonzero" while the OLD page stayed published); it was raised to 64 MiB the same day, which only moved the guess. The guess is gone; the gameengine page (1179928 B) is the standing witness that a page larger than this reserve publishes whole |
| 35 | const RG_EMIT_TIMEOUT_MS: i64 = 0 // the owned capture's timeout: 0 is the explicit opt-out (unbounded), the contract the legacy tr_run_capture already had |
| 36 | const RG_PROGRESS_BYTES: i64 = 512 |
| 37 | const RG_PROGRESS_STATUS: *u8 = "../knowledge/status/compare_regen.progress" // truncate-written BEFORE every domain and once at the end: a live run moves it, a dead one does not -- the job lane writes no partial output for the whole run, and a present .claim beside an absent .out read exactly like a dead job (operator, 2026-09-15) |
| 38 | const RG_HTML_MIN_BYTES: i64 = 2000 // a validity FLOOR, not a buffer: shorter than this is not a page |
| 39 | const RG_DEBTSTATE_BYTES: i64 = 65536 // debtstate accumulator; every write clamps on oo < ocap |
| 40 | const RG_GETDENTS_BYTES: i64 = 65536 // ONE getdents64 transfer -- the caller loops until it returns 0 |
| 41 | const RG_CHILD_CAPTURE_BYTES: i64 = 262144 // a forked tool's stdout, size unknowable in advance |
| 114 | const RG_RADAR_LIAR_MARK: *u8 = " LIAR-KILL:" |
| 115 | const RG_RADAR_VERDICT_MARK: *u8 = "NX-SWCOMPARE-GAPMAP " |
| 116 | const RG_ECHO_INDENT: *u8 = " " |
| 143 | const RG_PUBJRNL: *u8 = "../knowledge/status/comparepub.jrnl" |
| 148 | const RG_WATCHROW_OVERHEAD: i64 = 14 |
| 164 | const RG_LEASE_NAME: *u8 = "compare-regen" |
| 165 | const RG_LEASE_TTL_S: *u8 = "900" // nx_lease takes the ttl as text; DERIVED from the measured worst run 811 s + margin |
| 166 | const RG_LEASE_CAP: i64 = 4096 |
| 167 | const RG_EXIT_BUSY: i64 = 3 // nx_lease's own BUSY exit, relayed unchanged so a caller learns one code |
| 168 | const RG_EXIT_STORM: i64 = 4 // the build gate's QUEUE exit, relayed unchanged for the same reason |
| 169 | const RG_LEASE_ELF: *u8 = "../nx_lease.elf" // CWD is the build root; the promoted lease organ lives at its parent |
| 537 | const RG_ORGAN_ROSTER: *u8 = "knowledge/compare/organ.roster" |
| 538 | const RG_ORGAN_ELF_PREFIX: *u8 = "../" |
| 539 | const RG_ORGAN_ELF_SUFFIX: *u8 = ".elf" |
| 540 | const RG_ORGAN_PATH_SLACK: i64 = 16 |
| 677 | const RG_FORK_MATRIX: i64 = 0 |
| 678 | const RG_FORK_SOTA: i64 = 1 |
| 679 | const RG_FORK_HUB: i64 = 2 |
| 682 | const RG_SELFCAT_STATUS_BYTES: i64 = 4096 |
| 683 | const RG_FORK_BOARD: i64 = 3 |
| 684 | const RG_FORKS: i64 = 4 // the DENOMINATOR: every generator this organ forks from _offc/ |
| 685 | const RG_PROMOTED_PREFIX: *u8 = "../" // CWD is the build root; /api/promote installs FLAT at its parent |
| 686 | const RG_FORKFRESH_STATUS: *u8 = "../knowledge/status/compare_forkfresh.status" |
| 687 | const RG_FORKSTATUS_BYTES: i64 = 4096 // derived from RG_FORKS rows plus a header, not guessed |
| 688 | const RG_ELF_SUFFIX_LEN: i64 = 4 |
| 917 | const RG_SCOPE_PATH_BYTES: i64 = 600 |
| 943 | const RG_EXPORT_ABSENT_RC: i64 = 2 |
functions
| 43 | func 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 } |
| 44 | func wn(fd: i64, v: i64) -> i64 |
| 50 | func scopy(dst: *u8, doff: i64, src: *u8) -> i64 { var i: i64 = 0; while src[i] != (0 as u8) { dst[doff+i] = src[i]; i = i + 1 } return doff + i } |
| 61 | func rg_write_atomic(path: *u8, buf: *u8, n: i64) -> i64 |
| 75 | func rg_scaffold(droot: *u8, dom: *u8) -> i64 |
| 85 | func rg_run(elf: *u8, a1: *u8, a2: *u8, out: *u8, cap: i64, outlen: *i64) -> i64 |
| 117 | func rg_echo_marked_line(mark: *u8) -> i64 |
| 149 | func rgr_num(b:*u8,off:i64,v:i64)->i64 {return rgr_decimal(b,off,v)} |
| 172 | func rg_lease_run(verb: *u8, out: *u8) -> i64 |
| 187 | func rg_lease_release() -> i64 |
| 198 | func rg_emit_receipted(elf: *u8, a1: *u8, mode: *u8, firstbyte: i64, minbytes: i64, target: *u8, out: *u8, cap: i64, journal:*u8) -> i64 |
| 245 | func rg_emit(elf:*u8,a1:*u8,mode:*u8,firstbyte:i64,minbytes:i64,target:*u8,out:*u8,cap:i64)->i64 {return rg_emit_receipted(elf,a1,mode,firstbyte,minbytes,target,out,cap,RG_PUBJRNL)} |
| 258 | func rg_watchlist(droot: *u8) -> i64 |
| 431 | func rg_debtstate(dom: *u8, buf: *u8, cap: i64, out: *u8, ocap: i64) -> i64 |
| 507 | func rgc_inlist(lst: *u8, ln: i64, name: *u8) -> i64 called by 1: rg_census |
| 543 | func rgc_organ_of(lst: *u8, ln: i64, name: *u8, out: *u8) -> i64 called by 1: rg_census |
| 570 | func rg_census(droot: *u8) -> i64 |
| 702 | func rg_forkpath(idx: i64) -> *u8 |
| 710 | func rg_forkname(idx: i64, out: *u8) -> i64 |
| 733 | func rg_forkstatus() -> i64 |
| 759 | func rg_forkcheck() -> i64 |
| 863 | func rg_selfcatalog() -> i64 |
| 918 | func rg_scope_len(s: *u8) -> i64 |
| 924 | func rg_scope_bounds(droot: *u8, selected_len: i64) -> i64 |
| 944 | func rg_export(elf: *u8, dom: *u8, dir: *u8, out: *u8, cap: i64) -> i64 |
| 961 | func rg_progress(dom: *u8, done: i64, pubs: i64, fails: i64) -> i64 |
| 973 | func rg_scope_list(name: *u8, n: i64) -> *u8 |
| 980 | func rg_scope_receipt(droot: *u8, domain: *u8, pubs: i64, fails: i64) -> i64 |
| 1002 | func rg_published_count(successful:i64)->i64 {return successful+g_rg_published_incomplete} |
| 1003 | func rg_exit_verdict(fails:i64)->i64 |
| 1009 | func main(argc: i64, argv: *i64) -> i64 |