code wiki / _hdl_build / nx_collision_watchdog.nx

nx_collision_watchdog.nx

buildroot/runtime/_hdl_build/nx_collision_watchdog.nx

12120 B239 linesdepth 4pulls 6 transitivereach 1 importersview sourcekind tooltopic collision
docsdependenciesstructsconstsfunctions

about

nx_collision_watchdog.nx -- WMS-M3: the COLLISION / REGRESSION / FLOATER WATCHDOG. module: nishi-core.control_plane.collision_watchdog capability: CORE_COMPUTE (a reusable self-monitoring scan capability) THE POINT: git is passive history; this is the LIVE OS for the work itself. The data-plane substrate (WMS-R0 atomic framed-append, R1 registry SSOT, R2 reflog, RES-R6 journal) made the channels never-tear. This organ is the WATCHDOG that READS those channels and the genealogy and the known-issue catalogue, then RAISES + ROUTES three failure classes that the OLD torn-write substrate could not reliably surface: (1) TORN WRITES -- framing violations in any status log (MUST be 0 post-R0; a non-zero count means a write somewhere bypassed the locked fa_appendz discipline). (2) RED GATES / REGRESSIONS -- a "verdict=RED" line in an evidence log (a gate flipped red). (3) FLOATING CAPABILITIES -- an organ that cannot trace UP to the spore (genealogy twin of a floating queue row): an untraced node whose parents are "-" but it is NOT the spore. Reuses rt_load+rt_trace (does NOT re-implement genealogy). Each raised issue is ROUTED via ki_recall (recall-or-red / no-unseen-repeat): a SEEN signature is recognized + named (id != UNKNOWN); a genuinely novel one stays honest UNKNOWN. Every alert/evidence write goes through the MANDATORY locked atomic fa_appendz (one assembled buffer -> one locked write, the cn_emit_red discipline) -- NEVER a sequence of sys_write (that is the torn-line bug we killed). REUSE (registries-before-building): fa_cat/fa_catn/fa_appendz (nx_framed_append, WMS-R0b), ki_recall + KI_HIT/KI_UNKNOWN (nx_known_issue_store, recall), rt_load/rt_trace/rt_find + RT_* (nx_root_trace, genealogy). The torn-detect per-line head/tail invariant is the migration-gate idiom, lifted to scan ARBITRARY channels (head/tail are DATA params, not hardcoded to NOTES). ADDITIVE-ONLY: this organ READS existing logs/stores; it modifies no working organ. Sovereign: only the named nx organs + raw syscalls -- no gcc/openssl/node/python. license_tier: ORIGINAL

dependencies 4 imports · 1 importers

nx_framed_append.nx nx_known_issue_store.nx nx_root_trace.nx nx_syscalls.nx nx_collision_watchdog.nx nx_collision_watchdog_gate.nx

imports: nx_framed_append.nxnx_known_issue_store.nxnx_root_trace.nxnx_syscalls.nx

imported by: nx_collision_watchdog_gate.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main cw_w sys_write sys_mmap cw_scan_torn_file sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close cw_count_torn fa_len cw_slice_count cw_wn sys_mmap ↻ sys_write ↻ cw_scan_red_file sys_mmap ↻ sys_read_file ↻ cw_count_red cw_slice_count ↻ cw_scan_floating sys_mmap ↻ rt_load sys_mmap ↻ sys_openat_rd ↻ sys_read ↻ sys_close ↻ rt_id_at rt_par_at cw_count_floating rt_trace rt_streq rt_id_at ↻ sys_mmap ↻ rt_par_at ↻ rt_has_dot rt_find

structs

none

consts

33const CW_MAGIC_1024: i64 = 1024
35const CW_REC_CAP: i64 = 512 // bounded alert/evidence record size
36const CW_ALERT_LOG: *u8 = "knowledge/status/watchdog_alerts.log"

functions

46func cw_slice_count(hay: *u8, a: i64, b: i64, pat: *u8, pl: i64) -> i64
61func cw_count_torn(buf: *u8, n: i64, head: *u8, tail: *u8) -> i64
84func cw_scan_torn_file(path: *u8, head: *u8, tail: *u8) -> i64
97func cw_count_red(buf: *u8, n: i64, last_red: *u8) -> i64
called by 2: cw_scan_red_filemain calls 1: cw_slice_count
119func cw_scan_red_file(path: *u8, last_red: *u8) -> i64
134func cw_count_floating(idbase: i64, parbase: i64, n: i64, spore: *u8, traced: *i64) -> i64
153func cw_scan_floating(path: *u8, spore: *u8) -> i64
169func cw_route(prefix: *u8, diag: *u8, dlen: i64, outid: *u8, outrem: *u8, outstat: *u8) -> i64
called by 1: main calls 1: ki_recall
192func cw_emit_alert(path: *u8, epoch: i64, kind: *u8, subject: *u8, count: i64, routed_id: *u8) -> i64
209func cw_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
210func cw_wn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
223func main() -> i64