code wiki / (root) / nx_kinddedupe.nx

nx_kinddedupe.nx

buildroot/runtime/nx_kinddedupe.nx

11109 B235 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_kinddedupe.nx -- keep-first prune of AGREEING duplicate data rows in organ_kind.conf (2026-08-29). license_tier: ORIGINAL No hw writes (Rule 26). nx_kinddedupe plan [conf] -> measure only: prints every would-drop row, the partition, verdict nx_kinddedupe apply [conf] -> temp+rename rewrite dropping ONLY later exact same-name-same-kind data rows; comments, blanks, order and first occurrences untouched EXIT: 0 CLEAN-OR-PRUNED | 1 CONFLICT-REFUSED | 2 usage | 3 UNOBSERVABLE (unreadable conf, failed write) WHY A CONFLICT REFUSES INSTEAD OF RESOLVING: the reader is first-match-wins (nx_organkind ok_kind_of returns on the first whole-field name match), so a name carrying two DIFFERENT kinds is decided by LINE ORDER -- nx_organkind_gate neg-control-T20 proves the order IS the answer. A pruner that picked a winner would silently adjudicate a question that needs evidence. It refuses and names both rows. WHY AN ORGAN AND NOT A CLIENT EDIT: the SSOT carries law in its UTF-8 comments; a client-side rewrite republishes a transport RENDERING of those bytes (the transcription hazard, measured 2026-08-28 on the CLAUDE.md recovery). This organ reads the real bytes and DELETES WHOLE LINES ONLY -- it never rewrites a byte it keeps. Referee = nx_organkind_gate before/after: T22 agreeing_dups -> 0 with rows falling by exactly the drop count, CONFLICTING_NAMES stays 0, T23 whole-file, T24 headroom grows by the pruned bytes. The partition (bytes_kept + bytes_dropped == bytes_in) is asserted IN the organ, not beside it.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_kinddedupe.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main kd_w sys_write kd_streq 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 ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close kd_line_end kd_is_ws kd_memeq kd_wseg sys_mmap ↻ sys_write ↻ kd_wn kd_w ↻ sys_mmap ↻ sys_write ↻ kd_cat sys_openat_wr sys_write ↻ sys_close ↻

structs

none

consts

22const KD_EXIT_OK: i64 = 0
23const KD_EXIT_CONFLICT: i64 = 1
24const KD_EXIT_USAGE: i64 = 2
25const KD_EXIT_UNOBS: i64 = 3
26const KD_CONF_DEFAULT: *u8 = "knowledge/status/organ_kind.conf"
27const KD_TMP_SUFFIX: *u8 = ".kdtmp"
28const KD_SLOT: i64 = 8
29const KD_ROW_FIELDS: i64 = 4 // name_off, name_len, kind_off, kind_len per seen row
30const KD_HASH_BYTE: i64 = 35 // the comment marker byte, constructed numerically (lexer law: never in a literal)
31const KD_NL: i64 = 10
32const KD_SP: i64 = 32
33const KD_TAB: i64 = 9

functions

35func kd_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: kd_wnmain calls 1: sys_write
36func kd_wb(b: *u8, n: i64) -> i64 { sys_write(1, b, n); return 0 }
calls 1: sys_write
37func kd_wn(v: i64) -> i64
called by 1: main calls 3: kd_wsys_mmapsys_write
50func kd_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
called by 1: main
51func kd_memeq(a: *u8, ao: i64, b: *u8, bo: i64, n: i64) -> i64
called by 1: main
56func kd_cat(dst: *u8, at: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { dst[at + n] = s[n]; n = n + 1 } dst[at + n] = 0 as u8; return at + n }
called by 1: main
57func kd_wseg(buf: *u8, off: i64, n: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
67func kd_line_end(buf: *u8, i: i64, len: i64) -> i64
called by 1: main
75func kd_is_ws(c: u8) -> i64 { if c == (KD_SP as u8) { return 1 } if c == (KD_TAB as u8) { return 1 } return 0 }
called by 1: main
77func main(argc: i64, argv: *i64) -> i64