code wiki / _hdl_build / nx_seat.nx
nx_seat.nx
buildroot/runtime/_hdl_build/nx_seat.nx
about
nx_seat.nx -- THE AGENT-SEAT token-engine organ (seat-system S0+S3, 2026-07-20).
MISSION (operator): move Claude's token lift INTO the ecosystem. Measured 12-session baseline:
cache_read 920.8M tok vs output 6.1M -- fat tool results re-read every turn dominate cost.
So: boot = ONE call, HARD-CAPPED <=4096B digest (vs ~40K-token memory-file boot); the substrate
is digested SERVER-SIDE and only the decision surface reaches a seat's context window.
nx_seat boot <ws> [journal] [debtprefix] [frontierprefix] [meterlog] -> capped JSON digest
nx_seat meter <seat> <sessions> <out_tok> <cread_tok> <ccreate_tok> <note> [logpath]
-> ONE O_APPEND TSV row to knowledge/status/token_efficiency.log (conflict-free, S3)
nx_seat meterlog [n] [logpath] -> last n metering rows (tail-window, declared)
nx_seat shift [days] [meterlog] [ws.jrnl] -> ENGINE-SHIFT SCOREBOARD (F831): claude-vs-local
seat-class aggregates + DONE-closures in window -> tokens-per-closed-rung, capped JSON
nx_seat reap [actor] [note] [claims.jrnl] [ws.jrnl] -> F214 ORPHAN REAP: forks the nx_claims
organ's reap verb (releases ONLY provably-EXPIRED claims, age>ttl by the claim's OWN
ttl -- the wrapper NEVER decides expiry itself) then appends one ORPHAN-REAPED audit
frame per reaped ws to the ws journal (who/when/why); idempotent, additive-only
nx_seat selftest [tmpbase] -> gv-lib gate T1..T6 incl SCALE tooth (300-frame journal
-> output still <=4096B; fixture gates prove correctness NEVER scale -- ark v1 lesson)
SCALE-LAW: every read is tail-windowed with the true size DECLARED in output (journal_bytes vs
window_bytes); output budget declared as budget_bytes. AUTHORITY: nx_ws_cycle next remains the
scoped debt gate; boot is the recon DIGEST and says so in its output (no drift, no dup gate).
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 6 imports · 0 importers
imports: nx_sovjson_lib.nxnx_store_seed_lib.nxnx_seg_store.nxnx_gate_verdict.nxnx_tool_run.nxnx_syscalls.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
| 33 | const ST_FORK_TIMEOUT_MS: i64 = 30000 |
| 34 | const ST_MAGIC_4096: i64 = 4096 |
| 35 | const ST_MAGIC_86400: i64 = 86400 |
| 36 | const ST_MAGIC_4092: i64 = 4092 |
| 37 | const ST_MAGIC_8192: i64 = 8192 |
| 38 | const ST_MAGIC_8188: i64 = 8188 |
| 39 | const ST_MAGIC_3600: i64 = 3600 |
| 40 | const ST_MAGIC_1024: i64 = 1024 |
| 41 | const ST_MAGIC_9000: i64 = 9000 |
| 42 | const ST_MAGIC_90000: i64 = 90000 |
| 43 | const ST_MAGIC_65536: i64 = 65536 |
| 45 | const ST_CAP: i64 = 1048576 |
| 46 | const ST_OUTCAP: i64 = 4096 |
| 47 | const ST_OUTBUF: i64 = 8192 |
| 48 | const ST_SEEK_SET: i64 = 0 |
| 49 | const ST_SEEK_END: i64 = 2 |
| 50 | const ST_TAB: i64 = 9 |
| 51 | const ST_NL: i64 = 10 |
| 52 | const ST_STDERR: i64 = 2 |
| 53 | const ST_SPAN: i64 = 16 |
| 54 | const ST_EXIT_USAGE: i64 = 2 |
| 55 | const ST_ACTIVE_MAX: i64 = 8 |
| 56 | const ST_FRONT_MAX: i64 = 5 |
| 57 | const ST_ROW_ESC: i64 = 240 |
| 58 | const ST_NOTE_ESC: i64 = 160 |
| 59 | const ST_WS_ESC: i64 = 40 |
| 60 | const ST_TITLE_ESC: i64 = 60 |
| 61 | const ST_STALE_SEC: i64 = 7200 |
| 62 | const ST_MODE_RW: i64 = 0x1a4 |
| 63 | const ST_ST_FRAMES: i64 = 300 |
functions
| 66 | func st_puts(s: *u8) -> i64 { return sj_puts(s) } |
| 67 | func st_werr(s: *u8) -> i64 { return sj_werr(s) } |
| 68 | func st_vlen(s: *u8) -> i64 { return sj_vlen(s) } |
| 69 | func st_cat(d: *u8, o: i64, s: *u8) -> i64 { return sj_cat(d, o, s) } |
| 70 | func st_catn(d: *u8, o: i64, v: i64) -> i64 { return sj_catn(d, o, v) } |
| 71 | func st_cat_esc(d: *u8, o: i64, q: *u8, s: i64, e: i64, maxn: i64) -> i64 { return sj_cat_esc(d, o, q, s, e, maxn) } |
| 72 | func st_atoi_z(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v } called by 1: main |
| 73 | func st_atoi_span(q: *u8, s: i64, e: i64) -> i64 { return sj_atoi_span(q, s, e) } called by 6: st_last_ts_litst_last_ts_spanst_last_briefst_topdebtst_readyst_shift calls 1: sj_atoi_span |
| 74 | func st_le(q: *u8, i: i64, n: i64) -> i64 { return sj_le(q, i, n) } called by 14: st_hasst_first_kickst_last_ts_litst_last_ts_spanst_last_briefst_topdebt+8 calls 1: sj_le |
| 75 | func st_col(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64 { return sj_col(q, ls, le, c, out) } called by 11: st_hasst_first_kickst_last_ts_litst_last_ts_spanst_last_briefst_topdebt+5 calls 1: sj_col |
| 88 | func st_cap_of(buf: *u8, off: i64, len: i64, cs: *i64) -> i64 called by 1: st_boot |
| 113 | func st_lit_eq(q: *u8, s: i64, e: i64, lit: *u8) -> i64 { return sj_lit_eq(q, s, e, lit) } |
| 114 | func st_span_eq(q: *u8, s1: i64, e1: i64, s2: i64, e2: i64) -> i64 |
| 120 | func st_contains(q: *u8, n: i64, lit: *u8) -> i64 { return sj_span_has(q, 0, n, lit) } |
| 122 | func st_read(path: *u8, buf: *u8, cap: i64, sizep: *i64) -> i64 |
| 150 | func st_meter_append(logpath: *u8, seat: *u8, sess: i64, outk: i64, cread: i64, ccre: i64, note: *u8) -> i64 called by 2: st_selftestmain calls 6: sys_mmapst_catnsys_now_realtime_secsys_openat_appendsys_writesys_close |
| 183 | func st_has(q: *u8, n: i64, verb: *u8, ws: *u8) -> i64 |
| 196 | func st_first_kick(q: *u8, upto: i64, ws_s: i64, ws_e: i64) -> i64 |
| 209 | func st_last_ts_lit(q: *u8, n: i64, ws: *u8) -> i64 |
| 223 | func st_last_ts_span(q: *u8, n: i64, ws_s: i64, ws_e: i64) -> i64 |
| 239 | func st_last_brief(q: *u8, n: i64, ws: *u8, fs: *i64) -> i64 |
| 265 | func st_topdebt(dp: *u8, dbuf: *u8, fs: *i64) -> i64 |
| 299 | func st_frontier_status(fbuf: *u8, fn: i64, ids: i64, ide: i64) -> i64 |
| 318 | func st_deps_block_count(fbuf: *u8, fn: i64, ds: i64, de: i64) -> i64 |
| 343 | func st_ready(lane: *u8, maxn: i64, fp: *u8, out: *u8) -> i64 |
| 442 | func st_has_span_done(q: *u8, n: i64, ws_s: i64, ws_e: i64) -> i64 |
| 459 | func st_starts(q: *u8, s: i64, e: i64, lit: *u8) -> i64 called by 1: st_shift |
| 468 | func st_shift(days: i64, ml: *u8, jr: *u8, out: *u8) -> i64 |
| 582 | func st_boot(ws: *u8, jr: *u8, dp: *u8, fp: *u8, ml: *u8, out: *u8) -> i64 called by 2: st_selftestmain calls 19: sys_mmapst_readsys_now_realtime_secst_catst_catnst_cat_esc+13 |
| 772 | func st_frame(jr: *u8, ts: i64, verb: *u8, ws: *u8, actor: *u8, note: *u8) -> i64 |
| 798 | func st_cframe(cjr: *u8, ts: i64, verb: *u8, res: *u8, actor: *u8, ttl: i64, note: *u8) -> i64 |
| 828 | func st_do_brief(ws: *u8, actor: *u8, note: *u8, wj: *u8, out: *u8) -> i64 |
| 851 | func st_claims_run(verb: *u8, cj: *u8, ws: *u8, actor: *u8, ttl: i64, note: *u8, cout: *u8, ccap: i64, colen: *i64) -> i64 |
| 871 | func st_do_checkin(ws: *u8, actor: *u8, ttl: i64, note: *u8, cj: *u8, wj: *u8, out: *u8) -> i64 |
| 902 | func st_jpathish(s: *u8) -> i64 called by 1: st_co_argshift |
| 917 | func st_co_argshift(a4: *u8, a5: *u8, nout: *i64) -> i64 |
| 929 | func st_claims_state(cj: *u8, ws: *u8, cout: *u8, ccap: i64, colen: *i64) -> i64 |
| 948 | func st_do_checkout(ws: *u8, actor: *u8, note: *u8, cj: *u8, wj: *u8, out: *u8) -> i64 called by 2: st_selftestmain calls 15: st_framesys_now_realtime_secsys_openat_rdst_catst_cat_escst_vlen+9 |
| 1011 | func st_tagval(q: *u8, ls: i64, le: i64, tag: *u8, out: *i64) -> i64 |
| 1031 | func st_reap_run(cj: *u8, actor: *u8, note: *u8, cout: *u8, ccap: i64, colen: *i64) -> i64 |
| 1043 | func st_do_reap(actor: *u8, note: *u8, cj: *u8, wj: *u8, out: *u8) -> i64 |
| 1092 | func st_selftest(base: *u8) -> i64 |
| 1382 | func main(argc: i64, argv: *i64) -> i64 |