code wiki / (root) / nx_compare_regen.nx

nx_compare_regen.nx

buildroot/runtime/nx_compare_regen.nx

91078 B1415 linesdepth 8pulls 31 transitivereach 1 importersview sourcekind tooltopic compare
docsdependenciesstructsconstsfunctions

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

nx_tool_run.nx nx_compare_receipt_lib.nx nx_compare_scope_lib.nx nx_symdecl_lib.nx nx_estate_path.nx nx_forkfresh_lib.nx nx_compare_feed_lib.nx nx_catalog_lib.nx nx_ioadmit_lib.nx nx_heavyio_lib.nx nx_compare_regen.nx nx_compare_regen_gate_t138.nx

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

main w cscope_roster_count cscope_name_char rg_scope_len cscope_validate_name cscope_name_char ↻ rg_scope_bounds rg_scope_len ↻ w ↻ ep_anchor sys_openat_rd sys_close sys_chdir sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ ioa_measure sys_mmap ↻ rm_read sys_openat_rd ↻ sys_read sys_close ↻ ioa_ncpu rm_field rm_slen sys_munmap ioa_spawn_budget

structs

none

consts

34const 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
35const 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
36const RG_PROGRESS_BYTES: i64 = 512
37const 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)
38const RG_HTML_MIN_BYTES: i64 = 2000 // a validity FLOOR, not a buffer: shorter than this is not a page
39const RG_DEBTSTATE_BYTES: i64 = 65536 // debtstate accumulator; every write clamps on oo < ocap
40const RG_GETDENTS_BYTES: i64 = 65536 // ONE getdents64 transfer -- the caller loops until it returns 0
41const RG_CHILD_CAPTURE_BYTES: i64 = 262144 // a forked tool's stdout, size unknowable in advance
114const RG_RADAR_LIAR_MARK: *u8 = " LIAR-KILL:"
115const RG_RADAR_VERDICT_MARK: *u8 = "NX-SWCOMPARE-GAPMAP "
116const RG_ECHO_INDENT: *u8 = " "
143const RG_PUBJRNL: *u8 = "../knowledge/status/comparepub.jrnl"
148const RG_WATCHROW_OVERHEAD: i64 = 14
164const RG_LEASE_NAME: *u8 = "compare-regen"
165const RG_LEASE_TTL_S: *u8 = "900" // nx_lease takes the ttl as text; DERIVED from the measured worst run 811 s + margin
166const RG_LEASE_CAP: i64 = 4096
167const RG_EXIT_BUSY: i64 = 3 // nx_lease's own BUSY exit, relayed unchanged so a caller learns one code
168const RG_EXIT_STORM: i64 = 4 // the build gate's QUEUE exit, relayed unchanged for the same reason
169const RG_LEASE_ELF: *u8 = "../nx_lease.elf" // CWD is the build root; the promoted lease organ lives at its parent
537const RG_ORGAN_ROSTER: *u8 = "knowledge/compare/organ.roster"
538const RG_ORGAN_ELF_PREFIX: *u8 = "../"
539const RG_ORGAN_ELF_SUFFIX: *u8 = ".elf"
540const RG_ORGAN_PATH_SLACK: i64 = 16
677const RG_FORK_MATRIX: i64 = 0
678const RG_FORK_SOTA: i64 = 1
679const RG_FORK_HUB: i64 = 2
682const RG_SELFCAT_STATUS_BYTES: i64 = 4096
683const RG_FORK_BOARD: i64 = 3
684const RG_FORKS: i64 = 4 // the DENOMINATOR: every generator this organ forks from _offc/
685const RG_PROMOTED_PREFIX: *u8 = "../" // CWD is the build root; /api/promote installs FLAT at its parent
686const RG_FORKFRESH_STATUS: *u8 = "../knowledge/status/compare_forkfresh.status"
687const RG_FORKSTATUS_BYTES: i64 = 4096 // derived from RG_FORKS rows plus a header, not guessed
688const RG_ELF_SUFFIX_LEN: i64 = 4
917const RG_SCOPE_PATH_BYTES: i64 = 600
943const RG_EXPORT_ABSENT_RC: i64 = 2

functions

43func 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 }
44func wn(fd: i64, v: i64) -> i64
50func 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 }
61func rg_write_atomic(path: *u8, buf: *u8, n: i64) -> i64
75func rg_scaffold(droot: *u8, dom: *u8) -> i64
called by 1: main calls 1: scopy
85func rg_run(elf: *u8, a1: *u8, a2: *u8, out: *u8, cap: i64, outlen: *i64) -> i64
117func rg_echo_marked_line(mark: *u8) -> i64
called by 1: main calls 1: w
149func rgr_num(b:*u8,off:i64,v:i64)->i64 {return rgr_decimal(b,off,v)}
172func rg_lease_run(verb: *u8, out: *u8) -> i64
called by 2: rg_lease_releasemain calls 1: tr_run_capture
187func rg_lease_release() -> i64
called by 1: main calls 1: rg_lease_run
198func rg_emit_receipted(elf: *u8, a1: *u8, mode: *u8, firstbyte: i64, minbytes: i64, target: *u8, out: *u8, cap: i64, journal:*u8) -> i64
245func 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)}
called by 1: main calls 1: rg_emit_receipted
258func rg_watchlist(droot: *u8) -> i64
431func rg_debtstate(dom: *u8, buf: *u8, cap: i64, out: *u8, ocap: i64) -> i64
507func rgc_inlist(lst: *u8, ln: i64, name: *u8) -> i64
called by 1: rg_census
543func rgc_organ_of(lst: *u8, ln: i64, name: *u8, out: *u8) -> i64
called by 1: rg_census
570func rg_census(droot: *u8) -> i64
called by 1: main calls 5: wrgc_inlistrgc_organ_ofscopywn
702func rg_forkpath(idx: i64) -> *u8
710func rg_forkname(idx: i64, out: *u8) -> i64
733func rg_forkstatus() -> i64
759func rg_forkcheck() -> i64
863func rg_selfcatalog() -> i64
918func rg_scope_len(s: *u8) -> i64
called by 2: rg_scope_boundsmain
924func rg_scope_bounds(droot: *u8, selected_len: i64) -> i64
called by 1: main calls 2: rg_scope_lenw
944func rg_export(elf: *u8, dom: *u8, dir: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 3: tr_run_capturewwn
961func rg_progress(dom: *u8, done: i64, pubs: i64, fails: i64) -> i64
973func rg_scope_list(name: *u8, n: i64) -> *u8
called by 1: main calls 1: scopy
980func rg_scope_receipt(droot: *u8, domain: *u8, pubs: i64, fails: i64) -> i64
1002func rg_published_count(successful:i64)->i64 {return successful+g_rg_published_incomplete}
called by 2: mainmain
1003func rg_exit_verdict(fails:i64)->i64
called by 2: mainmain calls 1: w
1009func main(argc: i64, argv: *i64) -> i64