nx_dedup_audit.nx
buildroot/runtime/nx_dedup_audit.nx
about
nx_dedup_audit.nx -- pure-NishiLang substrate duplicate-primitive auditor.
Walks a runtime directory (default: the cwd or argv[1]), parses every
nx_*.nx file (excluding _test.nx), extracts every `func nx_...`
declaration, computes a stem by stripping the module prefix, and
emits JSONL clusters (stem appears in >= 2 files).
All work in pure NishiLang -- directory iteration via sys_getdents64
(through nx_dirent.nx), file read via sys_read_file, output via
sys_write (through runtime.nx::println). Zero shell-tool calls.
Output format (stdout, one line per cluster):
{"stem":"<stem>","count":N,"members":[{"name":"...","file":"..."},...]}
genealogy_id: baker_1995_clone_detection + smith_2009_code_clones
+ roy_cordy_2007_clone_taxonomy
lineage_id: function_name_stem_grouping + equivalence_class_partition
axioms: NX_AX_REL_REFLEXIVITY (stem(a) = stem(a))
+ NX_AX_REL_SYMMETRY (stem(a)=stem(b) -> stem(b)=stem(a))
+ NX_AX_REL_TRANSITIVITY (a~b, b~c -> a~c)
together: equivalence relation on function-stems, so
clusters are well-defined disjoint classes.
dependencies 5 imports · 0 importers
imports: syscalls.nxruntime.nxnx_axioms.nxnx_dirent.nxnx_fcntl.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 41 | struct DedupRecord |
consts
| 36 | const NX_DEDUP_MAX_RECORDS: i64 = 8000 |
| 37 | const NX_DEDUP_MAX_STR: i64 = 96 |
| 38 | const NX_DEDUP_RECORD_BYTES: i64 = 24 |
| 39 | const NX_DEDUP_DIR_BUF: i64 = 16384 |
functions
| 49 | func dedup_byte_copy(dst: *u8, src: *u8, n: i64) -> i64 |
| 59 | func dedup_strdup(s: *u8, n: i64) -> *u8 |
| 65 | func dedup_is_alnum_us(c: i64) -> i64 called by 1: dedup_extract_funcname |
| 73 | func dedup_starts_with(buf: *u8, off: i64, len: i64, pat: *u8) -> i64 called by 1: dedup_extract_funcname |
| 88 | func dedup_name_matches(name: *u8, name_len: i64) -> i64 called by 1: dedup_walk_runtime |
| 118 | func dedup_module_from_filename(name: *u8, name_len: i64, out_buf: *u8) -> i64 |
| 135 | func dedup_at_func_start(buf: *u8, off: i64, len: i64) -> i64 called by 1: dedup_process_file |
| 158 | func dedup_extract_funcname(buf: *u8, off: i64, len: i64, out_name: *u8) -> i64 |
| 208 | func dedup_compute_stem(name: *u8, name_len: i64, called by 1: dedup_process_file |
| 239 | func dedup_process_file(file_path: *u8, file_basename: *u8, |
| 278 | func dedup_walk_runtime(dir_path: *u8, records: *DedupRecord, called by 1: main calls 9: nx_openatstrlennx_dirent_readnx_dirent_iternx_dirent_name_lendedup_name_matches+3 |
| 321 | func dedup_emit_cluster(records: *DedupRecord, n_records: i64, |
| 367 | func main(argc: i64, argv: *i64) -> i64 |