code wiki / _hdl_build / nx_collision_watchdog.nx
nx_collision_watchdog.nx
buildroot/runtime/_hdl_build/nx_collision_watchdog.nx
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
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
structs
| none |
consts
| 33 | const CW_MAGIC_1024: i64 = 1024 |
| 35 | const CW_REC_CAP: i64 = 512 // bounded alert/evidence record size |
| 36 | const CW_ALERT_LOG: *u8 = "knowledge/status/watchdog_alerts.log" |
functions
| 46 | func cw_slice_count(hay: *u8, a: i64, b: i64, pat: *u8, pl: i64) -> i64 |
| 61 | func cw_count_torn(buf: *u8, n: i64, head: *u8, tail: *u8) -> i64 |
| 84 | func cw_scan_torn_file(path: *u8, head: *u8, tail: *u8) -> i64 |
| 97 | func cw_count_red(buf: *u8, n: i64, last_red: *u8) -> i64 |
| 119 | func cw_scan_red_file(path: *u8, last_red: *u8) -> i64 |
| 134 | func cw_count_floating(idbase: i64, parbase: i64, n: i64, spore: *u8, traced: *i64) -> i64 |
| 153 | func cw_scan_floating(path: *u8, spore: *u8) -> i64 |
| 169 | func cw_route(prefix: *u8, diag: *u8, dlen: i64, outid: *u8, outrem: *u8, outstat: *u8) -> i64 |
| 192 | func cw_emit_alert(path: *u8, epoch: i64, kind: *u8, subject: *u8, count: i64, routed_id: *u8) -> i64 |
| 209 | func 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 } |
| 210 | func cw_wn(v: i64) -> i64 |
| 223 | func main() -> i64 |