code wiki / _hdl_build / nx_workstream_audit_gate.nx
nx_workstream_audit_gate.nx
buildroot/runtime/_hdl_build/nx_workstream_audit_gate.nx
about
nx_workstream_audit_gate.nx -- THE REFEREE for WMS-R4 (the boot-time completeness/crash audit).
Structural twin of nx_workstream_registry_gate: that proves the registry is an internally-complete
SSOT; THIS proves the registry is EXTERNALLY complete -- cross-checked against the real filesystem
(memory .md + code .nx) and the assignment_queue, so a lost/moved/never-registered workstream is
reported LOUDLY (orphan / untracked / unregistered) rather than silently dropped on crash recovery.
HERMETIC: the gate seeds its OWN test store (knowledge/store/wsaudit-) with controlled fixtures
(NOT production claims) AND builds tiny fixture dirs under knowledge/store/wsaudit_fix/{mem,code}/
so the FS walk runs over CONTROLLED data (a real DATA-driven walk, not one hardcoded branch).
Assertions (flat pass-tally, avoids the LM-002 deep-nested-if landmine):
T1 clean-store no-orphan : every fixture row's mem/code link resolves -> ws_audit_orphans_p==0
T2 orphan caught : one fixture row's memory_link points at a .md that was NOT created
-> orphans>=1 AND that id in orphan_out
T3 untracked NEG-CONTROL : a .nx organ dropped in wsaudit_fix/code/ with NO matching code_link
in the registry -> ws_audit_untracked_p>=1 AND its basename reported.
THE mandatory neg-control: a hidden workstream present in code but
absent from the registry is CAUGHT.
T4 no-false-positive : a fully-registered fixture organ (its basename IS a code_link) is
NOT in untracked_out (proves T3 isn't a constant non-zero).
T5 unregistered caught : a hermetic queue fixture row id T-PROSE-ONLY not in the registry ->
ws_audit_unregistered_p>=1 with that id reported; a registered id NOT.
T6 production roll-up : against the live ws- prefix + real memory/runtime/queue,
ws_audit_complete_r4_p runs and PRINTS orphan/untracked/unregistered
counts; GREEN-gate invariant = production ORPHANS==0 (the lost-things
invariant, using the basename-resolving code check so the path-shifted
links nx_geo/nx_drv_proto_emit/nx_root_trace do NOT false-orphan).
GREEN only if T1..T6 all hold. Evidence -> knowledge/status/workstream_audit_gate.log.
license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_workstream_audit.nxnx_workstream_store.nxnx_seg_store.nxnx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 34 | const WAG_LOG: *u8 = "knowledge/status/workstream_audit_gate.log" |
| 35 | const WSAUDIT_PREFIX: *u8 = "knowledge/store/wsaudit-" |
| 36 | const FIX_ROOT: *u8 = "knowledge/store/wsaudit_fix" |
| 37 | const FIX_MEM: *u8 = "knowledge/store/wsaudit_fix/mem/" // ends '/' |
| 38 | const FIX_CODE: *u8 = "knowledge/store/wsaudit_fix/code/" // ends '/' |
| 39 | const FIX_QUEUE: *u8 = "knowledge/store/wsaudit_fix/queue.tsv" |
functions
| 41 | func wag_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } |
| 42 | func wag_n(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48 as u8;k=1}; while m>0 {t[k]=(48+(m%10)) as u8; m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(fd, bb, k); return 0 } |
| 43 | func wag_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 45 | func wag_streq(a: *u8, b: *u8) -> i64 called by 1: wag_in_list |
| 52 | func wag_row(fd: i64, name: *u8, pass: i64) -> i64 |
| 59 | func wag_streq_store(key: *u8, val: *u8) -> i64 |
| 73 | func wag_seed_one(key: *u8, val: *u8) -> i64 |
| 82 | func wag_write_file(path: *u8, body: *u8) -> i64 |
| 91 | func wag_in_list(out: *i64, cnt: i64, tok: *u8) -> i64 |
| 97 | func main() -> i64 |