code wiki / _hdl_build / nx_novel_close.nx
nx_novel_close.nx
buildroot/runtime/_hdl_build/nx_novel_close.nx
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
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
structs
| none |
consts
| 47 | const Q_MAGIC_262144: i64 = 262144 |
| 48 | const Q_MAGIC_65536: i64 = 65536 |
| 49 | const Q_MAGIC_4096: i64 = 4096 |
| 51 | const Q_CAP: i64 = 1048576 |
| 52 | const MAXCAND: i64 = 64 |
functions
| 54 | func 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 } |
| 59 | func nc_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 60 | func nc_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 63 | func nc_unlink(path: *u8) -> i64 { return __syscall(263, AT_FDCWD, path, 0, 0, 0, 0) } called by 1: nc_referee |
| 65 | func nc_read(path: *u8, buf: *u8, cap: i64) -> i64 called by 8: nc_refereenc_referee_runnc_referee_depsnc_referee_filenc_write_closenc_process+2 calls 1: sys_read |
| 75 | func nc_exists(path: *u8) -> i64 |
| 82 | func nc_write_all(fd: i64, buf: *u8, len: i64) -> i64 |
| 89 | func nc_copy(src: *u8, dst: *u8) -> i64 |
| 105 | func nc_contains(buf: *u8, n: i64, needle: *u8) -> i64 |
| 120 | func nc_at(buf: *u8, n: i64, i: i64, pat: *u8, pl: i64) -> i64 |
| 128 | func nc_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 134 | func nc_path_d(dst: *u8, name: *u8) -> i64 |
| 137 | func nc_path_t(dst: *u8, name: *u8) -> i64 |
| 146 | func nc_referee(name: *u8, spec: *u8, green: *u8) -> i64 |
| 212 | func nc_referee_run(organ: *u8, green: *u8) -> i64 |
| 243 | func nc_field_eq(buf: *u8, fstart: i64, line_end: i64, s: *u8, sl: i64) -> i64 called by 1: nc_referee_deps |
| 258 | func nc_dep_has_token(buf: *u8, dep_off: i64, line_end: i64, id: *u8, idl: i64) -> i64 called by 1: nc_referee_deps |
| 290 | func nc_referee_deps(id: *u8, qpath: *u8) -> i64 |
| 336 | func nc_referee_file(path: *u8, anchor: *u8) -> i64 |
| 347 | func nc_find_novel(buf: *u8, n: i64, id: *u8, line_start: *i64) -> i64 |
| 379 | func nc_status_off(buf: *u8, n: i64, line_start: i64) -> i64 called by 1: nc_write_close |
| 393 | func nc_write_close(qpath: *u8, id: *u8) -> i64 |
| 415 | func nc_process(qpath: *u8, ids: *i64, specs: *i64, names: *i64, greens: *i64, called by 2: nc_selftestmain calls 12: nc_readnc_find_novelnc_lennc_referee_runnc_referee_depsnc_referee_file+6 |
| 472 | func nc_load_candidates(ids: *i64, specs: *i64, names: *i64, greens: *i64) -> i64 |
| 522 | func nc_write_scratch_queue(path: *u8, status_line: *u8) -> i64 |
| 533 | func nc_ensure_auto_builder() -> i64 |
| 551 | func nc_selftest() -> i64 called by 1: main calls 10: nc_ensure_auto_buildernc_existsnc_copync_write_scratch_queuenc_processnc_read+4 |
| 697 | func main(argc: i64, argv: *i64) -> i64 |