code wiki / _hdl_build / nx_oo_extract.nx

nx_oo_extract.nx

buildroot/runtime/_hdl_build/nx_oo_extract.nx

37236 B653 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_oo_extract.nx -- BYTE-PROVEN OO DUP-FUNCTION EXTRACTOR (the real "object-oriented without losing functionality" operation, unblocked by the 2026-07-21 byte-equiv proof). Moves functions that are DUPLICATED byte-identically across N consumers into a shared base lib, repoints each consumer to import it, and COMMITS only if EVERY consumer's rebuild is BYTE-IDENTICAL to before (else REVERTS all). never-brick + rule-13 (originals backed up). Every refusal carries verdict+reason+fix (operator law). argv: <funcname[,funcname...]> <baselib-srcpath> <buildonly-elf> <consumer-srcpath1> [consumer-srcpath2 ...] [--proof=bytes|behave] [--workload=<path>] exit: 0 EXTRACTED | 1 REFUSED(reverted) | 2 usage/precondition | 3 io/build error(reverted) v2 (2026-08-18, the /compare generator dedup): TWO capabilities the single-function v1 could not do. (1) N FUNCTIONS IN ONE PASS. A comma-separated funcname list moves the whole shared set at once with ONE import line and ONE proof cycle. v1 needed N runs and each run left the consumer importing a lib that the NEXT run would rewrite -- and a base lib holding one function is not a base class, it is a shard. (2) BEHAVIOURAL PROOF. `--proof=behave` proves the extraction by the consumer's OUTPUT, not its image: each consumer is run BEFORE and AFTER over every argv line in --workload that names it, and the captured stdout must be byte-identical. Needed because an added `import` line legitimately reorders the compiled image (functions are laid out in source order), so `--proof=bytes` REFUSES a correct extraction; the byte proof stays the default because it is the stronger claim when it holds. Workload format: one line per run, `<consumer-target> <argv1> <argv2> ...`; a consumer with no workload line has NO proof and the run REFUSES (a proof over an empty set is not a proof). A function is extracted only if its body is byte-identical across EVERY consumer; a divergent body is REFUSED by name -- resolve by rename or by making them equal first, never by picking one. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 4 imports · 0 importers

nx_seat_drive_lib.nx nx_seg_store.nx nx_deploy_lib.nx nx_syscalls.nx nx_oo_extract.nx

imports: nx_seat_drive_lib.nxnx_seg_store.nxnx_deploy_lib.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sd_w sys_write sys_exit oe_starts oe_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 ↻ oe_split_names oe_base oe_read sys_openat_rd sys_read sys_close oe_find_func_trim oe_find_func oe_trim_body_end oe_body_uses_consumer_cons oe_isid sd_w ↻ sys_mmap ↻ oe_eq oe_target oe_base ↻ sd_cat oe_build_snap sys_mmap ↻

structs

none

consts

29const OE_CAP: i64 = 2097152
30const OE_MAXC: i64 = 128
31const OE_MAXF: i64 = 64 // functions per extraction (argv[1] list); a REFUSED-by-count if exceeded
32const OE_NAME: i64 = 128 // one function-name slot
33const OE_MAXW: i64 = 256 // workload lines
34const OE_WARGV: i64 = 32 // argv tokens per workload line
35const OE_ABSPATH: i64 = 1024 // an absolute path buffer: start-cwd + /buildroot/_build/<target>.sov.elf

functions

37func oe_read(path: *u8, buf: *u8, cap: i64) -> i64
46func oe_isid(c: i64) -> i64
53func oe_eq(a: *u8, an: i64, b: *u8, bn: i64) -> i64 { if an != bn { return 0 } var i: i64 = 0; while i < an { if a[i] != b[i] { return 0 } i = i + 1 } return 1 }
called by 2: oe_behave_cmpmain
54func oe_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 2: oe_behavemain
55func oe_starts(s: *u8, p: *u8) -> i64 { var i: i64 = 0; while p[i] != (0 as u8) { if s[i] != p[i] { return 0 } i = i + 1 } return 1 }
57func oe_find_func(buf: *u8, n: i64, fname: *u8, out: *i64) -> i64
called by 1: oe_find_func_trim
107func oe_trim_body_end(buf: *u8, out: *i64) -> i64
called by 1: oe_find_func_trim
134func oe_find_func_trim(buf: *u8, n: i64, fname: *u8, out: *i64) -> i64
called by 1: main calls 2: oe_find_funcoe_trim_body_end
140func oe_build_snap(buildelf: *u8, target: *u8, snappath: *u8, buf: *u8) -> i64
166func oe_base(path: *u8, out: *u8) -> i64
called by 2: oe_targetmain
177func oe_target(path: *u8, out: *u8) -> i64
called by 1: main calls 1: oe_base
188func oe_body_uses_consumer_const(body: *u8, bn: i64, src: *u8, sn: i64, fname: *u8, cp: *u8) -> i64
called by 1: main calls 3: oe_isidsd_wsys_mmap
231func oe_import_insert_at(src: *u8, sn: i64) -> i64
called by 1: main calls 1: oe_starts
253func oe_split_names(s: *u8, names: *u8) -> i64
called by 1: main
274func oe_run_in(elf_abs: *u8, av: *i64, na: i64, outfile: *u8, cwd: *u8) -> i64
293func oe_behave(target: *u8, wl: *u8, wn: i64, outprefix: *u8, tokbuf: *u8) -> i64
354func oe_mask_volatile(b: *u8, n: i64, tok: *u8) -> i64
called by 1: oe_behave_cmp
373func oe_behave_cmp(target: *u8, wl: *u8, wn: i64, prefa: *u8, prefb: *u8, ba: *u8, bb: *u8) -> i64
421func main(argc: i64, argv: *i64) -> i64