nx_doc_xref_dual_audit_test.nx source
↩ module page · 35 lines · 1220 B
1// nx_doc_xref_dual_audit_test.nx -- substrate-wide multi-namespace
2// broken-ref audit. Validates [[X]] refs against BOTH nxc2/docs/
3// AND .claude/projects/.../memory/ namespaces. A ref is broken
4// only if missing from BOTH.
5
6import "nx_syscalls.nx"
7import "nx_string_ops.nx"
8import "nx_dir.nx"
9import "nx_doc_xref.nx"
10
11func main() -> i64 {
12 let docs_path: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/docs"
13 let docs_path_len: i64 = 39
14 let mem_path: *u8 = "/mnt/c/Users/elder/.claude/projects/C--Users-elder/memory"
15 let mem_path_len: i64 = 57
16
17 // Build memory namespace blob first.
18 let extra_blob: *u8 = sys_mmap(262144) // 256 KiB; ~3000 names
19 let n_extra: i64 = nx_doc_xref_build_names_blob(mem_path, mem_path_len, extra_blob, 262144)
20 if n_extra < 0 { return 5 }
21
22 let counts_buf: *u8 = sys_mmap(64)
23 let counts: *NxDocXrefCounts = counts_buf as *NxDocXrefCounts
24 nx_doc_xref_counts_init(counts)
25
26 let rc: i64 = nx_doc_xref_walk_dir_dual(docs_path, docs_path_len, extra_blob, n_extra, counts)
27 if rc != 0 { return 10 }
28
29 nx_doc_xref_report_stdout(counts)
30
31 if counts.n_docs_scanned < 1 { return 1 }
32 if counts.n_names_indexed < 1 { return 2 }
33
34 return 0
35}