code wiki / (root) / nx_dedup_audit.nx

nx_dedup_audit.nx

buildroot/runtime/nx_dedup_audit.nx

14638 B417 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

syscalls.nx runtime.nx nx_axioms.nx nx_dirent.nx nx_fcntl.nx nx_dedup_audit.nx

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

main dedup_walk_runtime nx_openat strlen nx_dirent_read nx_dirent_iter nx_dirent_name_len dedup_name_matches dedup_byte_copy dedup_strdup dedup_byte_copy ↻ dedup_process_file sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close dedup_at_func_start dedup_extract_funcname dedup_starts_with dedup_is_alnum_us dedup_byte_copy ↻ dedup_compute_stem dedup_strdup ↻ println strlen ↻ dedup_emit_cluster streq strlen ↻ strneq print strlen ↻ print_i64 itoa println ↻ print ↻ print_i64 ↻

structs

41struct DedupRecord

consts

36const NX_DEDUP_MAX_RECORDS: i64 = 8000
37const NX_DEDUP_MAX_STR: i64 = 96
38const NX_DEDUP_RECORD_BYTES: i64 = 24
39const NX_DEDUP_DIR_BUF: i64 = 16384

functions

49func dedup_byte_copy(dst: *u8, src: *u8, n: i64) -> i64
59func dedup_strdup(s: *u8, n: i64) -> *u8
65func dedup_is_alnum_us(c: i64) -> i64
73func dedup_starts_with(buf: *u8, off: i64, len: i64, pat: *u8) -> i64
88func dedup_name_matches(name: *u8, name_len: i64) -> i64
called by 1: dedup_walk_runtime
118func dedup_module_from_filename(name: *u8, name_len: i64, out_buf: *u8) -> i64
135func dedup_at_func_start(buf: *u8, off: i64, len: i64) -> i64
called by 1: dedup_process_file
158func dedup_extract_funcname(buf: *u8, off: i64, len: i64, out_name: *u8) -> i64
208func dedup_compute_stem(name: *u8, name_len: i64,
called by 1: dedup_process_file
239func dedup_process_file(file_path: *u8, file_basename: *u8,
278func dedup_walk_runtime(dir_path: *u8, records: *DedupRecord,
321func dedup_emit_cluster(records: *DedupRecord, n_records: i64,
called by 1: main calls 4: streqprintprint_i64println
367func main(argc: i64, argv: *i64) -> i64