code wiki / (root) / nx_contentdiff.nx

nx_contentdiff.nx

buildroot/runtime/nx_contentdiff.nx

15029 B287 linesdepth 5pulls 6 transitivereach 11 importersview sourcekind tooltopic contentdiff
docsdependenciesstructsconstsfunctions

about

nx_contentdiff.nx -- THE PROMOTE RULER. Answers one question: does the candidate binary still contain everything the LIVE binary contains? WHY (debts 1785452162, 1785526315, 1785526809): the ecosystem has ~703 deployed organs awaiting a rebuild, and the gate guarding that queue was BYTE SIZE. Size is uninformative IN BOTH DIRECTIONS, proven twice by measurement: SHRINK is not regression -- 16 live organs had LARGER .prev files, yet the smaller live binaries were string SUPERSETS (lost_from_live=0). Restoring the bigger ones would have BEEN the regression. GROWTH is not improvement -- nx_law_warden rebuilt GREW 161951 -> 186696 bytes while losing three whole detectors (laws_measured 11 -> 8, enforced_permil 1000 -> 727). A gate keyed on bytes is therefore wrong about half the time and cannot tell you which half. THE RULER: printable content. Every printable run of >= CD_MINLEN bytes in the LIVE binary must still be findable somewhere in the candidate. Anything missing is capability the rebuild would DESTROY. Searching the candidate's RAW BYTES (not a re-extracted string set) is deliberate and stricter: a string that survived but got tokenized differently still counts as present, so a MISS is a real miss. ★2026-08-06 -- THE RULER MOVED OUT, THE ORACLE STAYED. This organ had NO DEPLOYED BINARY and no registry row, so the check it specifies had never actually run anywhere: debt 1785531571 asked for it to be wired into /api/promote and nothing could be, because the measure lived inside this main() with nothing importable to wire. It now lives in nx_contentdiff_lib (cdl_lost) and is called BOTH here and by the staging guard inside md_promote_staged. This file keeps its exact output contract; it simply no longer owns a private copy of the arithmetic. FAIL-CLOSED: unreadable input is RED, never "clean". Verdict GREEN iff lost_from_live == 0. NOT DEDUPED, and it says so in the output: runs are counted as encountered, so the counts are occurrence counts and lost>0 is the signal -- declaring that beats a silent, prettier number. THE ORACLE SPENDS THE FULL BUDGET (every run, whole run) -- it runs to completion and can afford it. nx_contentdiff <live-elf> <candidate-elf> [all|positive-display-limit] Optional display depth changes evidence visibility only; counts and verdict remain shared. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 3 imports · 6 importers

nx_syscalls.nx nx_gate_verdict.nx nx_contentdiff_lib.nx nx_contentdiff.nx nx_adopt_observation_candidate_t31 nx_adoptgate.nx nx_adoptgate_review_candidate_t371 nx_adoptgate_typed_candidate_t310. nx_contentdiff_cli_gate_t295.nx nx_contentdiff_display_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_contentdiff_lib.nx

imported by: nx_adopt_observation_candidate_t313.nxnx_adoptgate.nxnx_adoptgate_review_candidate_t371.nxnx_adoptgate_typed_candidate_t310.nxnx_contentdiff_cli_gate_t295.nxnx_contentdiff_display_gate.nx

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

main gv_puts sys_write cd_display_arg cd_structured_paths cd_structured_paths_result sys_map_file sys_openat_rd sys_lseek sys_close cd_structured_error gv_puts ↻ gv_num sys_mmap nxa_die nxa_lock_take nxa_lock_give nxa_report_overrun sys_write ↻ sys_munmap sys_munmap_direct gv_puts ↻ cds_init sys_mmap_try sys_mmap_try ↻ cds_measure cds_elf nx_elf_get_u16_le nx_elf_get_u64_le nx_elf_get_u32_le cds_sectionless nx_elf_get_u64_le ↻ nx_elf_get_u16_le ↻ cds_span nx_elf_get_u32_le ↻ cds_span ↻ nx_elf_get_u32_le ↻ cdl_bytes_eq cds_line cds_span ↻

structs

185struct NxCdDisplay {total:i64,shown:i64,source:i64,ident:i64,section:i64,other:i64}

consts

38const CD_CAP: i64 = 4194304
39const CD_MINLEN: i64 = 6
40const CD_SHOW: i64 = 8
41const CD_SHOW_ALL: i64 = 0 - 1
42const CD_SHOW_BAD: i64 = 0 - 2
43const CD_DECIMAL_BASE: i64 = 10
44const CD_I64_MAX: i64 = 9223372036854775807
45const CD_DIGIT_ZERO: i64 = 48
46const CD_DIGIT_NINE: i64 = 57
186const CD_STRUCT_ALL:i64=0
187const CD_STRUCT_OTHER:i64=1
188const CD_STRUCT_SOURCE:i64=2

functions

49func cd_display_arg(p: *u8) -> i64
called by 3: mainmainmain
65func cd_slurp(path: *u8, buf: *u8, cap: i64) -> i64
90func cd_show_other(a: *u8, an: i64, b: *u8, bn: i64) -> i64
called by 1: main calls 1: cd_show_other_limit
93func cd_show_other_limit(a: *u8, an: i64, b: *u8, bn: i64, limit: i64) -> i64
123func cd_show_gained(a: *u8, an: i64, b: *u8, bn: i64) -> i64
126func cd_show_gained_limit(a: *u8, an: i64, b: *u8, bn: i64, limit: i64) -> i64
151func cd_show_lost(a: *u8, an: i64, b: *u8, bn: i64) -> i64
called by 1: main calls 1: cd_show_lost_limit
154func cd_show_lost_limit(a: *u8, an: i64, b: *u8, bn: i64, limit: i64) -> i64
175func cd_display_summary(label: *u8, shown: i64, total: i64) -> i64
189func cd_structured_names(a:*NxCdStructured,b:*NxCdStructured,label:*u8,mode:i64,limit:i64,out:*NxCdDisplay)->i64
212func cd_structured_error(state:i64,reason:*u8)->i64
217func cd_structured_paths(livep:*u8,candp:*u8,display:i64)->i64
called by 2: mainmain calls 1: cd_structured_paths_result
222func cd_structured_paths_result(livep:*u8,candp:*u8,display:i64,measured:*NxCdResult)->i64
278func main(argc:i64,argv:*i64)->i64