code wiki / _hdl_build / nx_queue_drain.nx
nx_queue_drain.nx
buildroot/runtime/_hdl_build/nx_queue_drain.nx
about
nx_queue_drain.nx -- THE ANTI-PUBLISHER-DEATH SPINE: decide + disposition every queued gap so the queue
DRAINS, never "clogs and dies." Operator 2026-07-04: "we need THEM to DECIDE and get these things FIXED till
they are trusted like you are -- i can't have the nishi publisher situation where the queue clogs and dies."
GROUNDED (researcher): dead-letter queue (a failed item gets a FAILED disposition, is NEVER silently dropped/
stuck -- drain_deadletter.raw) + Little's law (if arrival-rate > service-rate, depth -> infinity = the death;
so we MEASURE fill-vs-drain and ALARM -- drain_littleslaw.raw). COMPOSES the proven anti-clog primitives:
nx_eval_queue (the work items + the new _key/_status/_close enumeration) + the hostop_watchdog pattern
(heartbeat so a hung drainer is RESTARTED, not silently dead).
THE GUARANTEE (why it can't clog + die): (1) EVERY OPEN item gets a DISPOSITION each pass -- routed to its
owner (a council proposal for high-blast; auto-close for done-evidence) or DEAD-LETTERED with a reason if it
cannot be processed. Nothing stays silently OPEN forever. (2) The drainer HEARTBEATS -> a watchdog relaunches
it if it hangs. (3) A HEALTH census reports remaining/dead-lettered + ALARMS if remaining only grows (fill >
drain) -- the publisher-death DETECTOR that was missing. HONEST: it DECIDES + ROUTES + tracks every item; it
does not claim to auto-FIX arbitrary gaps (targeted synthesis is the team's open arc) -- unfixable-here items
are dead-lettered + ESCALATED (visible), the trust-building transparency. license_tier: ORIGINAL
genealogy_id: international-research-sources/{dead_letter_queue,littles_law} + operator-2026-07-04-queue-death
lineage_id: nishi_queue_drain_v1 expect_exit: 0
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nxnx_eval_queue.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
| 24 | const QD_HEARTBEAT: *u8 = "knowledge/status/queue_drain.hb\x00" // watchdog-monitored liveness beat |
| 25 | const QD_HEALTH: *u8 = "knowledge/status/queue_health.log\x00" // fill/drain/alarm signal (UI + monitor) |
| 26 | const QD_MAX_PASS: i64 = 4096 // JPL bounded loop (never unbounded) |
functions
| 28 | func qd_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 33 | func qd_putn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 34 | func qd_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: qd_field |
| 35 | func qd_eq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } |
| 38 | func qd_beat() -> i64 |
| 51 | func qd_disposition(status: *u8) -> *u8 |
| 59 | func qd_field(fd: i64, key: *u8, num: i64) -> i64 |
| 68 | func qd_health_line(depth: i64, disp: i64, inrev: i64, dead: i64, stuck: i64, alarm: i64) -> i64 |
| 85 | func main() -> i64 |