nx_kinddedupe.nx
buildroot/runtime/nx_kinddedupe.nx
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
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
structs
| none |
consts
| 22 | const KD_EXIT_OK: i64 = 0 |
| 23 | const KD_EXIT_CONFLICT: i64 = 1 |
| 24 | const KD_EXIT_USAGE: i64 = 2 |
| 25 | const KD_EXIT_UNOBS: i64 = 3 |
| 26 | const KD_CONF_DEFAULT: *u8 = "knowledge/status/organ_kind.conf" |
| 27 | const KD_TMP_SUFFIX: *u8 = ".kdtmp" |
| 28 | const KD_SLOT: i64 = 8 |
| 29 | const KD_ROW_FIELDS: i64 = 4 // name_off, name_len, kind_off, kind_len per seen row |
| 30 | const KD_HASH_BYTE: i64 = 35 // the comment marker byte, constructed numerically (lexer law: never in a literal) |
| 31 | const KD_NL: i64 = 10 |
| 32 | const KD_SP: i64 = 32 |
| 33 | const KD_TAB: i64 = 9 |
functions
| 35 | func 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 } |
| 36 | func kd_wb(b: *u8, n: i64) -> i64 { sys_write(1, b, n); return 0 } calls 1: sys_write |
| 37 | func kd_wn(v: i64) -> i64 |
| 50 | func 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 |
| 51 | func kd_memeq(a: *u8, ao: i64, b: *u8, bo: i64, n: i64) -> i64 called by 1: main |
| 56 | func 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 |
| 57 | func kd_wseg(buf: *u8, off: i64, n: i64) -> i64 |
| 67 | func kd_line_end(buf: *u8, i: i64, len: i64) -> i64 called by 1: main |
| 75 | func 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 |
| 77 | func main(argc: i64, argv: *i64) -> i64 |