code wiki / _hdl_build / nx_analyst_serve.nx

nx_analyst_serve.nx

buildroot/runtime/_hdl_build/nx_analyst_serve.nx

3306 B41 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind servicetopic analyst
docsdependenciesstructsconstsfunctions

about

nx_analyst_serve.nx -- SERVE-WRAPPER making the ANALYST role's capability MCP-callable (operator 2026-07-10). The library-role pattern (2nd instance, after nx_arbiter_serve): nx_analyst is a pure-integer LIBRARY (an_closure_fails/ an_children_sum, no main); this wrapper IMPORTS it + EXERCISES the core capability -- a traced cost-ledger that must CLOSE arithmetically (children sum to parent) and whose UNEXPLAINED RESIDUAL is named (where margin-stacking hides). Self-test: a valid ledger CLOSES (0 fails); a broken ledger is FLAGGED (>0 fails) -> the analyst discriminates. Clean exit 0 + JSON verdict so nishi_crew dispatches `analyst analyze`. Import ONLY nx_analyst.nx (brings nx_syscalls; a 2nd direct import = the double-import rc=6 trap). JSON trick: asv_w2 converts ' -> ". license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_analyst.nx nx_analyst_serve.nx

imports: nx_analyst.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main an_closure_fails an_is_leaf an_children_sum an_closure_ppm an_children_sum ↻ asv_w2 asv_bit asv_wn

structs

none

consts

9const K_MAGIC_10000: i64 = 10000
10const K_MAGIC_6000: i64 = 6000
11const K_MAGIC_4000: i64 = 4000
12const K_MAGIC_3000: i64 = 3000

functions

14func asv_raw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
15func asv_w2(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){ if s[n]==(39 as u8) { let q: *u8=sys_mmap(1); q[0]=34 as u8; sys_write(1,q,1) } else { sys_write(1,(s as i64+n) as *u8,1) } n=n+1 } return 0 }
called by 1: main
16func asv_bit(b: i64) -> i64 { let d: *u8=sys_mmap(1); d[0]=(48+b) as u8; sys_write(1,d,1); return 0 }
called by 1: main
17func asv_wn(v: i64) -> i64 { var m: i64=v; let t: *u8=sys_mmap(24); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let o: *u8=sys_mmap(24); var w: i64=0; var q: i64=k-1; while q>=0{o[w]=t[q];w=w+1;q=q-1} sys_write(1,o,w); return 0 }
called by 1: main
19func main() -> i64