code wiki / _hdl_build / nx_novel_close.nx

nx_novel_close.nx

buildroot/runtime/_hdl_build/nx_novel_close.nx

35495 B748 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_novel_close.nx -- the INDEPENDENT REFEREE that CLOSES genuinely-built NOVEL queue rows that nx_reconcile refuses to touch (NOVEL is never auto-flipped by design: novel work is judged after the visit). A NOVEL row whose deliverable is really built+gated cannot otherwise close, so its dependents stay FLOATING in nx_capability_ladder. This organ adjudicates each candidate MECHANICALLY -- it does NOT trust the row's stored ||MARK. Referee check per candidate (an auto_builder-emitted deliverable): DELETE the deliverable .nx + _test.nx -> re-run nx_auto_builder from its build-spec -> assert ALL of: (a) BOTH files RE-EMITTED, (b) builder exit==0 AND stdout carries the candidate's green marker "AUTO-BUILD GREEN: <name> shape=<N> KAT green", (c) line 1 of the re-emitted primary .nx carries "AUTHORED BY THE NISHI BUILDER" (proves author=organ, not a hand-written false-green). Only ALL-PASS closes the row. A stale/hand-written deliverable cannot survive deletion -> strongest no-false-green probe. The organ is NOT the builder, so there is NO self-grade: it re-runs the team's own auto_builder and reads the verdict. NOVEL is 5 bytes, DONE is 4 -> closing SHRINKS the line by 1 byte, so this is a LENGTH-CHANGING line REWRITE (reconcile only does same-length 4-byte in-place patches). We read the whole file, and for a referee-PASSED candidate row scoped by (field1==id AND field6=="NOVEL") emit the prefix, write "DONE", then the rest from after "NOVEL" (skip 5 src bytes, write 4). NEVER global-replace "NOVEL" (other rows' descriptions contain it); field6 is located by tab position. BAKED SELF-TEST runs FIRST on a SCRATCH scenario (control_pos via the proven erf pipeline MUST close; control_neg via a non-existent spec MUST NOT close); any mismatch -> print RED + nonzero exit, real queue UNTOUCHED. Proves it cannot false-close (sibling of nx_capability_ladder / nx_epic_rollup baked controls). argv[1] = queue-path override (scratch queue for dry-run; no side effects beyond that named file -- like reconcile's is_live guard). No-arg => LIVE: operates on knowledge/registry/assignment_queue.tsv (the only run that writes the real queue) and writes a .bak first. SOVEREIGN ONLY (nx_cc->nxasm, no gcc/python/qemu). Additive/history-sacred: the log is append-only; referee deletions are repaired by the re-emit (verified) or restored from backup on FAIL. The referee execs /tmp/nx_auto_builder.sov.elf, so the wrapper must build nx_auto_builder into /tmp in the SAME shell session. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_registry_lock.nx nx_itoa_lib.nx nx_novel_close.nx

imports: nx_registry_lock.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nc_selftest nc_ensure_auto_builder nc_exists sys_fork sys_openat_wr sys_dup3 sys_execve sys_wait4 nc_exists ↻ nc_copy sys_read sys_openat_wr ↻ nc_write_all nc_write_scratch_queue sys_openat_wr ↻ nc_w nc_process nc_read sys_read ↻ nc_find_novel nc_len nc_at nc_len ↻ nc_referee_run sys_fork ↻ sys_openat_wr ↻ sys_dup3 ↻ sys_execve ↻ sys_wait4 ↻ nc_read ↻ nc_contains nc_len ↻ nc_referee_deps nc_read ↻ nc_len ↻ nc_dep_has_token nc_field_eq nc_referee_file nc_read ↻

structs

none

consts

47const Q_MAGIC_262144: i64 = 262144
48const Q_MAGIC_65536: i64 = 65536
49const Q_MAGIC_4096: i64 = 4096
51const Q_CAP: i64 = 1048576
52const MAXCAND: i64 = 64

functions

54func nc_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 }
59func nc_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 2: nc_selftestmain calls 1: nxi_fd
60func nc_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
65func nc_read(path: *u8, buf: *u8, cap: i64) -> i64
75func nc_exists(path: *u8) -> i64
82func nc_write_all(fd: i64, buf: *u8, len: i64) -> i64
89func nc_copy(src: *u8, dst: *u8) -> i64
105func nc_contains(buf: *u8, n: i64, needle: *u8) -> i64
120func nc_at(buf: *u8, n: i64, i: i64, pat: *u8, pl: i64) -> i64
128func nc_cat(dst: *u8, off: i64, s: *u8) -> i64
134func nc_path_d(dst: *u8, name: *u8) -> i64
called by 1: nc_referee calls 1: nc_cat
137func nc_path_t(dst: *u8, name: *u8) -> i64
called by 1: nc_referee calls 1: nc_cat
146func nc_referee(name: *u8, spec: *u8, green: *u8) -> i64
212func nc_referee_run(organ: *u8, green: *u8) -> i64
243func nc_field_eq(buf: *u8, fstart: i64, line_end: i64, s: *u8, sl: i64) -> i64
called by 1: nc_referee_deps
258func nc_dep_has_token(buf: *u8, dep_off: i64, line_end: i64, id: *u8, idl: i64) -> i64
called by 1: nc_referee_deps
290func nc_referee_deps(id: *u8, qpath: *u8) -> i64
336func nc_referee_file(path: *u8, anchor: *u8) -> i64
called by 1: nc_process calls 2: nc_readnc_contains
347func nc_find_novel(buf: *u8, n: i64, id: *u8, line_start: *i64) -> i64
379func nc_status_off(buf: *u8, n: i64, line_start: i64) -> i64
called by 1: nc_write_close
393func nc_write_close(qpath: *u8, id: *u8) -> i64
415func nc_process(qpath: *u8, ids: *i64, specs: *i64, names: *i64, greens: *i64,
472func nc_load_candidates(ids: *i64, specs: *i64, names: *i64, greens: *i64) -> i64
called by 1: main calls 1: nc_read
522func nc_write_scratch_queue(path: *u8, status_line: *u8) -> i64
called by 1: nc_selftest calls 2: sys_openat_wrnc_w
533func nc_ensure_auto_builder() -> i64
551func nc_selftest() -> i64
697func main(argc: i64, argv: *i64) -> i64