code wiki / _hdl_build / nx_seat.nx

nx_seat.nx

buildroot/runtime/_hdl_build/nx_seat.nx

75434 B1544 linesdepth 5pulls 9 transitivereach 0 importersview sourcekind tooltopic seat
docsdependenciesstructsconstsfunctions

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

nx_sovjson_lib.nx nx_store_seed_lib.nx nx_seg_store.nx nx_gate_verdict.nx nx_tool_run.nx nx_syscalls.nx nx_seat.nx

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

main st_werr sj_werr sys_write sys_exit st_lit_eq sj_lit_eq st_vlen sj_vlen sys_mmap st_boot sys_mmap ↻ st_read sys_openat_rd sys_lseek sys_read sys_close sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real st_cat sj_cat st_catn sj_catn sys_mmap ↻ st_cat_esc sj_cat_esc st_vlen ↻ st_last_ts_lit sys_mmap ↻ st_le sj_le st_col sj_col st_lit_eq ↻ st_atoi_span sj_atoi_span st_has sys_mmap ↻ st_le ↻

structs

none

consts

33const ST_FORK_TIMEOUT_MS: i64 = 30000
34const ST_MAGIC_4096: i64 = 4096
35const ST_MAGIC_86400: i64 = 86400
36const ST_MAGIC_4092: i64 = 4092
37const ST_MAGIC_8192: i64 = 8192
38const ST_MAGIC_8188: i64 = 8188
39const ST_MAGIC_3600: i64 = 3600
40const ST_MAGIC_1024: i64 = 1024
41const ST_MAGIC_9000: i64 = 9000
42const ST_MAGIC_90000: i64 = 90000
43const ST_MAGIC_65536: i64 = 65536
45const ST_CAP: i64 = 1048576
46const ST_OUTCAP: i64 = 4096
47const ST_OUTBUF: i64 = 8192
48const ST_SEEK_SET: i64 = 0
49const ST_SEEK_END: i64 = 2
50const ST_TAB: i64 = 9
51const ST_NL: i64 = 10
52const ST_STDERR: i64 = 2
53const ST_SPAN: i64 = 16
54const ST_EXIT_USAGE: i64 = 2
55const ST_ACTIVE_MAX: i64 = 8
56const ST_FRONT_MAX: i64 = 5
57const ST_ROW_ESC: i64 = 240
58const ST_NOTE_ESC: i64 = 160
59const ST_WS_ESC: i64 = 40
60const ST_TITLE_ESC: i64 = 60
61const ST_STALE_SEC: i64 = 7200
62const ST_MODE_RW: i64 = 0x1a4
63const ST_ST_FRAMES: i64 = 300

functions

66func st_puts(s: *u8) -> i64 { return sj_puts(s) }
called by 1: main calls 1: sj_puts
67func st_werr(s: *u8) -> i64 { return sj_werr(s) }
called by 1: main calls 1: sj_werr
68func st_vlen(s: *u8) -> i64 { return sj_vlen(s) }
69func st_cat(d: *u8, o: i64, s: *u8) -> i64 { return sj_cat(d, o, s) }
70func st_catn(d: *u8, o: i64, v: i64) -> i64 { return sj_catn(d, o, v) }
71func 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) }
72func 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
73func st_atoi_span(q: *u8, s: i64, e: i64) -> i64 { return sj_atoi_span(q, s, e) }
74func st_le(q: *u8, i: i64, n: i64) -> i64 { return sj_le(q, i, n) }
75func st_col(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64 { return sj_col(q, ls, le, c, out) }
88func st_cap_of(buf: *u8, off: i64, len: i64, cs: *i64) -> i64
called by 1: st_boot
113func st_lit_eq(q: *u8, s: i64, e: i64, lit: *u8) -> i64 { return sj_lit_eq(q, s, e, lit) }
114func st_span_eq(q: *u8, s1: i64, e1: i64, s2: i64, e2: i64) -> i64
120func st_contains(q: *u8, n: i64, lit: *u8) -> i64 { return sj_span_has(q, 0, n, lit) }
called by 1: st_selftest calls 1: sj_span_has
122func st_read(path: *u8, buf: *u8, cap: i64, sizep: *i64) -> i64
150func st_meter_append(logpath: *u8, seat: *u8, sess: i64, outk: i64, cread: i64, ccre: i64, note: *u8) -> i64
183func st_has(q: *u8, n: i64, verb: *u8, ws: *u8) -> i64
196func st_first_kick(q: *u8, upto: i64, ws_s: i64, ws_e: i64) -> i64
209func st_last_ts_lit(q: *u8, n: i64, ws: *u8) -> i64
223func st_last_ts_span(q: *u8, n: i64, ws_s: i64, ws_e: i64) -> i64
239func st_last_brief(q: *u8, n: i64, ws: *u8, fs: *i64) -> i64
265func st_topdebt(dp: *u8, dbuf: *u8, fs: *i64) -> i64
299func st_frontier_status(fbuf: *u8, fn: i64, ids: i64, ide: i64) -> i64
318func st_deps_block_count(fbuf: *u8, fn: i64, ds: i64, de: i64) -> i64
called by 1: st_ready calls 1: st_frontier_status
343func st_ready(lane: *u8, maxn: i64, fp: *u8, out: *u8) -> i64
442func st_has_span_done(q: *u8, n: i64, ws_s: i64, ws_e: i64) -> i64
459func st_starts(q: *u8, s: i64, e: i64, lit: *u8) -> i64
called by 1: st_shift
468func st_shift(days: i64, ml: *u8, jr: *u8, out: *u8) -> i64
582func st_boot(ws: *u8, jr: *u8, dp: *u8, fp: *u8, ml: *u8, out: *u8) -> i64
772func st_frame(jr: *u8, ts: i64, verb: *u8, ws: *u8, actor: *u8, note: *u8) -> i64
798func st_cframe(cjr: *u8, ts: i64, verb: *u8, res: *u8, actor: *u8, ttl: i64, note: *u8) -> i64
828func st_do_brief(ws: *u8, actor: *u8, note: *u8, wj: *u8, out: *u8) -> i64
851func st_claims_run(verb: *u8, cj: *u8, ws: *u8, actor: *u8, ttl: i64, note: *u8, cout: *u8, ccap: i64, colen: *i64) -> i64
871func st_do_checkin(ws: *u8, actor: *u8, ttl: i64, note: *u8, cj: *u8, wj: *u8, out: *u8) -> i64
902func st_jpathish(s: *u8) -> i64
called by 1: st_co_argshift
917func st_co_argshift(a4: *u8, a5: *u8, nout: *i64) -> i64
929func st_claims_state(cj: *u8, ws: *u8, cout: *u8, ccap: i64, colen: *i64) -> i64
948func st_do_checkout(ws: *u8, actor: *u8, note: *u8, cj: *u8, wj: *u8, out: *u8) -> i64
1011func st_tagval(q: *u8, ls: i64, le: i64, tag: *u8, out: *i64) -> i64
called by 2: st_do_checkoutst_do_reap calls 1: st_vlen
1031func st_reap_run(cj: *u8, actor: *u8, note: *u8, cout: *u8, ccap: i64, colen: *i64) -> i64
1043func st_do_reap(actor: *u8, note: *u8, cj: *u8, wj: *u8, out: *u8) -> i64
1092func st_selftest(base: *u8) -> i64
1382func main(argc: i64, argv: *i64) -> i64