code wiki / _hdl_build / nx_train_triage.nx
nx_train_triage.nx
buildroot/runtime/_hdl_build/nx_train_triage.nx
about
nx_train_triage.nx -- TRAINING-DYNAMICS TRIAGE library (the team organ that handles what
Claude diagnosed BY HAND during T4, 2026-06-10). Reads a machine-readable training report
(TRIAGE-CLASS/TRIAGE-PRED/TRIAGE-ACC/TRIAGE-LOSS rows, emitted by training lanes like
_t4b_closed_loop_authored) and NAMES the failure mode + the gate-proven fix, mechanically.
The five lessons it encodes were each MEASURED on real failed gate runs:
MAJORITY-COLLAPSE per-sample Adam on 88:2 imbalance -> all preds one class (88/149)
POST-CONVERGENCE-BLOWUP constant-lr Adam after convergence: grads->0 => v->0 => mh/eps spike
RARE-CLASS-LOSS unweighted loss loses exactly the smallest classes (util+mon)
PLATEAU uncentered all-positive features froze relu nets across 3 optimizers
CONVERGED-HEALTHY what T4/T4b look like when the lessons are applied
Pure integer math on micro-loss values -- no f32 needed to judge a curve.
RACI: Doctor owns the DIAGNOSIS verb here (names the heal); the Engineer owns the gate.
LAWS: struct-free, flat ifs, no &&/||, loud verdicts. license_tier: ORIGINAL
dependencies 1 imports · 4 importers
imports: nx_syscalls.nx
imported by: nx_train_triage_cli.nxnx_train_triage_gate.nxnx_train_triage_sweep.nxnx_train_triage_sweep_gate.nx
structs
| none |
consts
| 15 | const TT_MAGIC_8192: i64 = 8192 |
| 17 | const TT_HEALTHY: i64 = 0 |
| 18 | const TT_COLLAPSE: i64 = 1 |
| 19 | const TT_BLOWUP: i64 = 2 |
| 20 | const TT_RARE: i64 = 3 |
| 21 | const TT_PLATEAU: i64 = 4 |
| 22 | const TT_UNDIAG: i64 = 5 |
| 23 | const TT_BROKEN: i64 = 6 |
| 24 | const TT_MAXCLS: i64 = 16 |
| 25 | const TT_MAXLOSS: i64 = 512 |
functions
| 27 | func tt_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 28 | func tt_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } |
| 30 | func tt_match(b: *u8, i: i64, n: i64, lit: *u8) -> i64 |
| 39 | func tt_keynum(b: *u8, ls: i64, le: i64, key: *u8) -> i64 |
| 61 | func tt_read(path: *u8, out: *i64) -> i64 |
| 108 | func tt_diagnose(path: *u8) -> i64 |
| 164 | func tt_name(id: i64) -> *u8 |
| 173 | func tt_fix(id: i64) -> *u8 |