code wiki / (root) / nx_srcdiff.nx

nx_srcdiff.nx

buildroot/runtime/nx_srcdiff.nx

22636 B445 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_srcdiff.nx -- IS A DIRECTION MERGE SAFE, OR DOES THIS NEED A UNION? The per-file decision organ. WHY IT EXISTS. The estate's banked law is that A DIVERGENCE'S DIRECTION IS A PER-FILE MEASUREMENT, NEVER A PER-TREE POLICY -- and the 2026-08-03 lane proved it the hard way: BOTH of that session's directional hypotheses INVERTED once someone actually body-diffed the files ("NAS strict superset" hid the laptop's richer state; "local larger => NAS revert" was a missing leak fix). So every convergence needs one question answered first: does adopting one side LOSE anything? That question was being answered ad-hoc, by hand, outside the estate -- four separate times in the 2026-08-06 session alone, in a laptop shell no other seat can run. An analysis that gates a DESTRUCTIVE act and lives only in one operator's scrollback is not a capability the fleet has. WHAT IT REPORTS, and the verdict IS the decision: IDENTICAL -- same line multiset (!!ORDER may still differ; byte identity is nx_filehash's job) A-SUPERSET -- B's lines all appear in A. Adopting A loses NOTHING: a DIRECTION merge is safe. B-SUPERSET -- the mirror. BIDIRECTIONAL -- both sides hold lines the other lacks. A direction merge DESTROYS WORK; UNION. This is exactly the shape that decided the real cases: nx_syscalls.nx came back A-SUPERSET (the only delta was 5 sys_munmap doc lines) so a direction was correct; the 4 same-size gate/quality files came back A-SUPERSET too, with every "laptop-only" line being the SUPERSEDED original of a line the other side replaced -- which a surplus report shows and a size screen cannot. !!A LINE MULTISET IS NOT BYTE IDENTITY. Reordering, and CR-only differences, do not show up as surplus. CR counts are reported per side BECAUSE they are the classic invisible delta (a 2026-08-03 convergence found 742 stray CRs that git's autocrlf hid while a byte gate counted every one). Use nx_filehash/nx_treehash for identity; use THIS to decide which way to merge. DIALECT: plain-if, <=6 params, consts above use. Tables are mmap'd through static POINTERS -- a BSS static ARRAY silently crashes the module at startup (banked gotcha). license_tier: ORIGINAL expect_exit: 0 No hw writes (Rule 26).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_srcdiff.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 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 ↻ sd_puts sys_write ↻ sys_exit ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close sd_load sd_add sd_hash sd_streq sd_get sd_hash ↻ sd_streq ↻ sd_emit sd_sample sd_puts ↻ sd_putn sys_write ↻ sd_puts ↻ sys_openat_wr

structs

none

consts

32const SD_SLOTS: i64 = 131072 // power of two; a 1000-line file loads at <1% -- headroom is cheap
33const SD_MASK: i64 = 131071
34const SD_OUTBUF: i64 = 4194304
35const SD_NUMBUF: i64 = 64
36const SD_FNV_OFF: i64 = 1469598103934665603
37const SD_FNV_PRIME: i64 = 1099511628211
38const SD_SAMPLE_CAP: i64 = 25 // stdout sample; the FULL surplus list always goes to [outfile]
39const SD_SURCAP: i64 = 4096 // surplus lines retained per side for the pairing measurement
40const SD_PAIR_PERMIL: i64 = 700 // token-containment bar for a one-to-one modification pair
41const SD_LF: i64 = 10
42const SD_CR: i64 = 13

functions

56func sd_puts(s: *u8) -> i64
called by 3: sd_putnsd_samplemain calls 1: sys_write
62func sd_putn(v: i64) -> i64
called by 2: sd_samplemain calls 2: sys_writesd_puts
73func sd_streq(a: *u8, b: *u8) -> i64
called by 2: sd_addsd_get
84func sd_hash(s: *u8) -> i64
called by 2: sd_addsd_get
96func sd_add(keys: *i64, counts: *i64, line: *u8) -> i64
called by 1: sd_load calls 2: sd_hashsd_streq
111func sd_get(keys: *i64, counts: *i64, line: *u8) -> i64
called by 1: main calls 2: sd_hashsd_streq
121func sd_emit(tag: *u8, n: i64, line: *u8) -> i64
called by 1: main
145func sd_sample(tag: *u8, n: i64, line: *u8) -> i64
called by 1: main calls 2: sd_putssd_putn
158func sd_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
177func sd_is_sp(c: i64) -> i64
called by 1: sd_contain
184func sd_has_sub(hay: *u8, b: *u8, bs: i64, bl: i64) -> i64
called by 1: sd_contain calls 1: sd_len
199func sd_contain(a: *u8, b: *u8) -> i64
called by 1: main calls 3: sd_lensd_is_spsd_has_sub
233func sd_load(buf: *u8, n: i64, keys: *i64, counts: *i64, cslot: i64, lslot: i64) -> i64
called by 1: main calls 1: sd_add
270func main(argc: i64, argv: *i64) -> i64