code wiki / _hdl_build / nx_workstream_audit.nx

nx_workstream_audit.nx

buildroot/runtime/_hdl_build/nx_workstream_audit.nx

17668 B364 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind librarytopic workstream
docsdependenciesstructsconstsfunctions

about

nx_workstream_audit.nx -- WMS-R4 LIB: the BOOT-TIME COMPLETENESS / CRASH AUDIT. WMS-R1 (nx_workstream_store) proves INTERNAL consistency: every id in ws:ids has a retrievable seg-store segment with a real empire. R4 proves EXTERNAL completeness -- it cross-checks the registry against the FILESYSTEM (memory .md files + code .nx organs) and the assignment_queue, turning silently-lost workstreams into three LOUD verdicts (the crash-recovery durability proof): orphan -- a registry row whose memory_link / code_link does NOT resolve to a real file (the registry points at a lost/moved artifact). untracked -- a real .nx code organ that NO registry row's code_link references (code exists with no registry entry -- the hidden-workstream case = R4's neg-control hook). unregistered -- a queue id (assignment_queue col0) that ws_get_p == WS_UNKNOWN (prose/queue-only, never registered). COMPOSITION (anti-reinvention, rule 15): registry reads come from nx_workstream_store (ws_manifest_p / ws_get_p / ws_field) read-only; the FS walk reuses the struct-free raw-offset getdents64 idiom + dirent_reclen/dirent_type/dirent_name + dotlike-skip + last-'.' extension scan PROVEN in nx_nas_book_census (the NxDirent struct path crashes signal-11 under nx_cc_sovereign -- LANDMINE avoided; we use nx_syscalls.nx ONLY). memory + code + queue are FLAT scans, so no work-stack is needed -- a single depth-1 getdents64 loop (simpler than the census tree walk). CRITICAL drvfs caveat (nx_nas_book_census line 277): getdents64 returns DT_UNKNOWN(0) for regular files on WSL drvfs -- so the file candidate test accepts dtype 8 (DT_REG) AND 0 (DT_UNKNOWN). CRITICAL code_link path-shift hazard (verified): seed code_links like "runtime/nx_geo.nx" / "runtime/nx_drv_proto_emit.nx" / "runtime/nx_root_trace.nx" do NOT exist at those literal paths -- the files live in runtime/_hdl_build/. A naive "literal path missing -> orphan" check would emit ~3 FALSE orphans. So the code-existence check MIRRORS harness resolution: try the literal link, else fall back to the basename under runtime/ then runtime/_hdl_build/. A "-" link = intentionally none (not an orphan). Sovereign: imports only nx_workstream_store (R1 store, read-only) + nx_seg_store + nx_syscalls. Additive-only: this LIB does NOT modify R1's store. license_tier: ORIGINAL

dependencies 3 imports · 1 importers

nx_workstream_store.nx nx_seg_store.nx nx_syscalls.nx nx_workstream_audit.nx nx_workstream_audit_gate.nx

imports: nx_workstream_store.nxnx_seg_store.nxnx_syscalls.nx

imported by: nx_workstream_audit_gate.nx

structs

none

consts

36const WA_MAGIC_4096: i64 = 4096
37const WA_MAGIC_1024: i64 = 1024
38const WA_MAGIC_1048640: i64 = 1048640
39const WA_MAGIC_1048576: i64 = 1048576
42const WA_MEM_DIR: *u8 = "/mnt/c/Users/elder/.claude/projects/C--Users-elder/memory/"
43const WA_QUEUE: *u8 = "knowledge/registry/assignment_queue.tsv"
44const WA_CODE_DIR_A: *u8 = "runtime/"
45const WA_CODE_DIR_B: *u8 = "runtime/_hdl_build/"
46const WA_FLD_MEMORY: i64 = 4
47const WA_FLD_CODE: i64 = 5
48const WA_ITER_CAP: i64 = 200000 // hard bound on getdents records scanned (JPL rule 2)

functions

51func wa_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: wa_basenamewa_is_nx
53func wa_streq(a: *u8, b: *u8) -> i64
61func wa_basename(path: *u8) -> *u8
70func wa_path_exists(path: *u8) -> i64
79func wa_join(dir: *u8, name: *u8, out: *u8) -> i64
116func ws_audit_orphans_p(prefix: *u8, mem_dir: *u8, orphan_out: *i64, cap: i64) -> i64
172func wa_is_nx(name: *u8) -> i64
called by 1: ws_audit_untracked_p calls 1: wa_slen
184func ws_audit_untracked_p(prefix: *u8, code_dir: *u8, untracked_out: *i64, cap: i64) -> i64
290func ws_audit_unregistered_p(prefix: *u8, queue_path: *u8, unreg_out: *i64, cap: i64) -> i64
354func ws_audit_complete_r4_p(prefix: *u8, mem_dir: *u8, code_dir: *u8, queue_path: *u8) -> i64