code wiki / _hdl_build / nx_ctxcost.nx
nx_ctxcost.nx
buildroot/runtime/_hdl_build/nx_ctxcost.nx
about
nx_ctxcost.nx -- CONTEXT-COST ADVISOR (operator 2026-07-21: 'make nishi SEE the cost if it can, flag to
you what we should do as you work a workstream'). MEASURED real usage 2026-07-21: 96pct of spend at
>150k context; 71pct from nishi MCP results that STAY in context re-read every turn. So: given the
current context_pct (relayed from the Claude Code usage banner -- nishi can't read live context, so the
caller feeds the number it CAN see), advise CONTINUE / COMPACT-SOON / COMPACT-NOW from data-driven
thresholds in ctxbudget- (rule-11, tune without code). Reminds of the cheap-reboot: /clear then
nx_seat boot = ~1KB (state lives in planes). Composes nx_sovjson_lib (sj_*) = OO, 5th base consumer.
advise <context_pct> [ws] [ctxbudgetprefix] -> verdict JSON | selftest [tmpbase]
ctxbudget- row = id threshold_pct verdict action reason (5-col policy plane; pick highest thr <= pct).
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 5 imports · 0 importers
imports: nx_sovjson_lib.nxnx_store_seed_lib.nxnx_seg_store.nxnx_gate_verdict.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
| 17 | const CC_CAP: i64 = 1048576 |
| 18 | const CC_OUT: i64 = 8192 |
| 19 | const CC_SPAN: i64 = 16 |
| 20 | const CC_USAGE: i64 = 2 |
functions
| 22 | func cc_advise(pct: i64, ws: *u8, prefix: *u8, out: *u8) -> i64 |
| 73 | func cc_selftest(base: *u8) -> i64 |
| 115 | func main(argc: i64, argv: *i64) -> i64 |