code wiki / _hdl_build / nx_triage.nx
nx_triage.nx
buildroot/runtime/_hdl_build/nx_triage.nx
about
nx_triage.nx -- SOVEREIGN AUTO-TRIAGE ROUTER (ws=ws-intel7, 2026-07-20).
The ROUTER TIER of the operator's dual-LLM PM architecture, built sovereign: a fast
classifier reads NEW nx_pm_intake requests, scores each against the ecosystem's OWN live
lane signals (data-driven routing table -- rule 11, never hardcoded), and either
AUTO-ADVANCES a high-confidence request NEW -> TRIAGED (writes a TRIAGE frame), or
ESCALATES it (leaves it NEW for the orchestrator tier: an LLM seat or the operator).
That escalation gate IS the router->orchestrator handoff from the blueprint. Being
DETERMINISTIC is the sovereign exceed over a probabilistic small-LLM router: identical
input always yields an identical verdict, gate-proven (T5), and never fabricates a lane
it cannot evidence (T3/T4 -- score 0 => escalate, never a guess).
The K3-mu / small-LLM classifier is a DROP-IN UPGRADE of the scoring function: same
journal, same TRIAGE-frame contract, same confidence gate (W032's remaining half).
Routing table row: <lane>\t<owner>\t<kw1,kw2,...> ('#' comment lines skipped)
Intake frame (nx_pm_intake contract): <ts>\t<VERB>\t<id>\t<actor>\t<text>
SCALE LAW: windowed reads + declared envelope (window_bytes/truncated/routes_capped);
scan is O(requests x lanes x keywords x textlen), bounded by the declared window.
license_tier: ORIGINAL No hw writes (Rule 26).
route <intake_journal> <lanes_config> -> JSON proposals (READ-ONLY)
run <intake_journal> <lanes_config> <actor> -> auto-triage HIGH, JSON summary
selftest <scratch-journal> -> gate T1..T8 (caller pre-cleans)
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.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
| 23 | const TR_MAGIC_4096: i64 = 4096 |
| 24 | const TR_MAGIC_2000: i64 = 2000 |
| 25 | const TR_MAGIC_4095: i64 = 4095 |
| 26 | const TR_MAGIC_1024: i64 = 1024 |
| 27 | const TR_MAGIC_5001: i64 = 5001 |
| 28 | const TR_MAGIC_5002: i64 = 5002 |
| 29 | const TR_MAGIC_5003: i64 = 5003 |
| 30 | const TR_MAGIC_5004: i64 = 5004 |
| 32 | const TR_WIN: i64 = 4194304 |
| 33 | const TR_CFG: i64 = 262144 |
| 34 | const TR_OUT: i64 = 262144 |
| 35 | const TR_SOFT: i64 = 49152 |
| 36 | const TR_LC: i64 = 4096 |
| 37 | const TR_NOTE: i64 = 512 |
| 38 | const TR_TEXT_MAX: i64 = 300 |
| 39 | const TR_NAME_MAX: i64 = 120 |
| 42 | const TR_MIN_SCORE: i64 = 2 |
| 43 | const TR_MARGIN: i64 = 2 |
| 46 | const TR_MIN_SAMPLES: i64 = 5 |
| 47 | const TR_STALE_ESC: i64 = 172800 |
functions
| 49 | func tr_cat(d: *u8, o: i64, s: *u8) -> i64 { var p: i64=o; var i: i64=0; while s[i]!=(0 as u8){ d[p]=s[i]; p=p+1; i=i+1 } return p } |
| 50 | func tr_catn(d: *u8, o: i64, v: i64) -> i64 |
| 62 | func tr_vlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 63 | func tr_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 73 | func tr_append(journal: *u8, ts: i64, verb: *u8, id: i64, actor: *u8, note: *u8) -> i64 called by 2: tr_runtr_selftest calls 7: sys_now_realtime_secsys_mmaptr_catntr_catsys_openat_appendsys_write+1 |
| 103 | func tr_le(q: *u8, i: i64, n: i64) -> i64 |
| 109 | func tr_col(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64 |
| 125 | func tr_lit_eq(q: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 131 | func tr_atoi(q: *u8, s: i64, e: i64) -> i64 |
| 138 | func tr_has_id(q: *u8, n: i64, verb: *u8, idv: i64) -> i64 |
| 151 | func tr_is_new(q: *u8, n: i64, idv: i64) -> i64 |
| 157 | func tr_id_first(q: *u8, upto: i64, idv: i64) -> i64 |
| 172 | func tr_lc_copy(q: *u8, s: i64, e: i64, lc: *u8) -> i64 |
| 189 | func tr_has_kw(lc: *u8, tl: i64, cfg: *u8, ks: i64, ke: i64) -> i64 called by 1: tr_score_lane |
| 203 | func tr_score_lane(lc: *u8, tl: i64, cfg: *u8, ls: i64, le: i64) -> i64 |
| 220 | func tr_route_one(cfg: *u8, cn: i64, lc: *u8, tl: i64, out: *i64) -> i64 |
| 240 | func tr_conf(best: i64, second: i64) -> i64 |
| 247 | func tr_conf_name(c: i64) -> *u8 called by 1: tr_route_json |
| 260 | func tr_find_span(q: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 274 | func tr_span_in_span(q: *u8, aS: i64, aE: i64, bS: i64, bE: i64) -> i64 called by 1: tr_eval |
| 289 | func tr_routed_lane(q: *u8, n: i64, idv: i64, out: *i64) -> i64 |
| 306 | func tr_eval(q: *u8, n: i64, now: i64, stale_sec: i64, ex: *i64) -> i64 |
| 346 | func tr_jesc(d: *u8, o: i64, q: *u8, s: i64, e: i64, maxb: i64) -> i64 called by 1: tr_route_json |
| 360 | func tr_key(d: *u8, o: i64, name: *u8) -> i64 |
| 370 | func tr_qlit(d: *u8, o: i64, s: *u8) -> i64 |
| 378 | func tr_text_span(q: *u8, n: i64, verb: *u8, idv: i64, out: *i64) -> i64 called by 5: tr_routed_lanetr_evaltr_route_jsontr_runtr_selftest calls 5: sys_mmaptr_letr_coltr_lit_eqtr_atoi |
| 398 | func tr_build_note(nb: *u8, cfg: *u8, lane_s: i64, lane_e: i64, own_s: i64, own_e: i64, score: i64) -> i64 |
| 413 | func tr_route_json(q: *u8, n: i64, cfg: *u8, cn: i64, jp: *u8, cp: *u8, truncated: i64, d: *u8) -> i64 |
| 570 | func tr_run(journal: *u8, q: *u8, n: i64, cfg: *u8, cn: i64, actor: *u8) -> i64 |
| 606 | func tr_find(d: *u8, dn: i64, lit: *u8) -> i64 |
| 620 | func tr_mkcfgpath(dst: *u8, src: *u8) -> i64 |
| 627 | func tr_write_file(path: *u8, body: *u8) -> i64 |
| 636 | func tr_count_new(q: *u8, n: i64) -> i64 |
| 655 | func tr_selftest(journal: *u8) -> i64 |
| 738 | func main(argc: i64, argv: *i64) -> i64 |