code wiki / _hdl_build / nx_triage.nx

nx_triage.nx

buildroot/runtime/_hdl_build/nx_triage.nx

37275 B927 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic triage
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_verdict.nx nx_triage.nx

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

main gv_puts sys_write sys_exit tr_vlen tr_lit_eq tr_selftest gv_ctr sys_mmap gv_head gv_puts ↻ sys_mmap ↻ tr_mkcfgpath tr_cat tr_read sys_openat_rd sys_read sys_close tr_count_new sys_mmap ↻ tr_le tr_col tr_lit_eq ↻ tr_atoi tr_id_first sys_mmap ↻ tr_le ↻ tr_col ↻ tr_lit_eq ↻ tr_atoi ↻ tr_is_new tr_has_id sys_mmap ↻ tr_le ↻ tr_col ↻ tr_lit_eq ↻ tr_atoi ↻ gv_check gv_puts ↻ tr_write_file

structs

none

consts

23const TR_MAGIC_4096: i64 = 4096
24const TR_MAGIC_2000: i64 = 2000
25const TR_MAGIC_4095: i64 = 4095
26const TR_MAGIC_1024: i64 = 1024
27const TR_MAGIC_5001: i64 = 5001
28const TR_MAGIC_5002: i64 = 5002
29const TR_MAGIC_5003: i64 = 5003
30const TR_MAGIC_5004: i64 = 5004
32const TR_WIN: i64 = 4194304
33const TR_CFG: i64 = 262144
34const TR_OUT: i64 = 262144
35const TR_SOFT: i64 = 49152
36const TR_LC: i64 = 4096
37const TR_NOTE: i64 = 512
38const TR_TEXT_MAX: i64 = 300
39const TR_NAME_MAX: i64 = 120
42const TR_MIN_SCORE: i64 = 2
43const TR_MARGIN: i64 = 2
46const TR_MIN_SAMPLES: i64 = 5
47const TR_STALE_ESC: i64 = 172800

functions

49func 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 }
50func tr_catn(d: *u8, o: i64, v: i64) -> i64
62func tr_vlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
63func tr_read(path: *u8, buf: *u8, cap: i64) -> i64
73func tr_append(journal: *u8, ts: i64, verb: *u8, id: i64, actor: *u8, note: *u8) -> i64
103func tr_le(q: *u8, i: i64, n: i64) -> i64
109func tr_col(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64
125func tr_lit_eq(q: *u8, s: i64, e: i64, lit: *u8) -> i64
131func tr_atoi(q: *u8, s: i64, e: i64) -> i64
138func tr_has_id(q: *u8, n: i64, verb: *u8, idv: i64) -> i64
151func tr_is_new(q: *u8, n: i64, idv: i64) -> i64
157func tr_id_first(q: *u8, upto: i64, idv: i64) -> i64
172func tr_lc_copy(q: *u8, s: i64, e: i64, lc: *u8) -> i64
189func tr_has_kw(lc: *u8, tl: i64, cfg: *u8, ks: i64, ke: i64) -> i64
called by 1: tr_score_lane
203func tr_score_lane(lc: *u8, tl: i64, cfg: *u8, ls: i64, le: i64) -> i64
220func tr_route_one(cfg: *u8, cn: i64, lc: *u8, tl: i64, out: *i64) -> i64
240func tr_conf(best: i64, second: i64) -> i64
247func tr_conf_name(c: i64) -> *u8
called by 1: tr_route_json
260func tr_find_span(q: *u8, s: i64, e: i64, lit: *u8) -> i64
called by 1: tr_routed_lane calls 1: tr_vlen
274func tr_span_in_span(q: *u8, aS: i64, aE: i64, bS: i64, bE: i64) -> i64
called by 1: tr_eval
289func tr_routed_lane(q: *u8, n: i64, idv: i64, out: *i64) -> i64
306func tr_eval(q: *u8, n: i64, now: i64, stale_sec: i64, ex: *i64) -> i64
346func tr_jesc(d: *u8, o: i64, q: *u8, s: i64, e: i64, maxb: i64) -> i64
called by 1: tr_route_json
360func tr_key(d: *u8, o: i64, name: *u8) -> i64
called by 2: tr_route_jsonmain calls 1: tr_cat
370func tr_qlit(d: *u8, o: i64, s: *u8) -> i64
called by 2: tr_route_jsonmain calls 1: tr_cat
378func tr_text_span(q: *u8, n: i64, verb: *u8, idv: i64, out: *i64) -> i64
398func tr_build_note(nb: *u8, cfg: *u8, lane_s: i64, lane_e: i64, own_s: i64, own_e: i64, score: i64) -> i64
called by 1: tr_run calls 2: tr_cattr_catn
413func tr_route_json(q: *u8, n: i64, cfg: *u8, cn: i64, jp: *u8, cp: *u8, truncated: i64, d: *u8) -> i64
570func tr_run(journal: *u8, q: *u8, n: i64, cfg: *u8, cn: i64, actor: *u8) -> i64
606func tr_find(d: *u8, dn: i64, lit: *u8) -> i64
called by 1: tr_selftest calls 1: tr_vlen
620func tr_mkcfgpath(dst: *u8, src: *u8) -> i64
called by 1: tr_selftest calls 1: tr_cat
627func tr_write_file(path: *u8, body: *u8) -> i64
636func tr_count_new(q: *u8, n: i64) -> i64
655func tr_selftest(journal: *u8) -> i64
738func main(argc: i64, argv: *i64) -> i64