code wiki / _hdl_build / nx_claude_harvest_usage_t76.nx
nx_claude_harvest_usage_t76.nx
buildroot/runtime/_hdl_build/nx_claude_harvest_usage_t76.nx
about
nx_claude_harvest.nx -- CLAUDE TRANSCRIPT HARVESTER + OUTSIDE-GAUGE (miner-sota lane F964/F973, 2026-07-23).
PORTABLE organ (gen-image pattern: runs where the transcripts live -- laptop WSL today, NAS, any host):
parses Claude Code transcript JSONL into sovereign actlog frames, bulk-ingests staged frames into a
journal (validated, marker-idempotent), and derives the outside_permil gauge (nishi vs outside tool
split) that MUST FALL as capabilities move inside (MG00 baseline 651, 2026-07-23).
Composes nx_sovjson_lib (sj_*) -- no helper dup (D001 discipline). State derived; journals append-only
(O_APPEND, conflict-free, ws_sync lineage). No hw writes (Rule 26).
frames <transcript.jsonl> <ws> <outjournal> -> parse transcript, append actlog frames; HARVEST OK
ingest <framesfile> <journal> -> validated bulk append, idempotent by marker frame
gauge <journal> [days] -> JSON outside_permil (0 days = all frames)
beat <chbeat.conf> -> DM1 session->NAS capture beat (devmgmt rung, 2026-08-20):
walk EVERY transcript under root (all depths, getdents
looped until 0), ch_delta each against a per-transcript
byte HWM, split the fresh frames into ts-day PIECES sized
under the MCP body cliff, ingest each piece (ch_ingest,
marker-idempotent) into per-day journals -- the local twin
always, the NAS landing via the forked wire when push=1.
Pieces are the chunk unit AND the ingest unit, so the
pipeline is resumable at every stage with no append
primitive over the wire. Counters partition and SUM;
unknown head-types bucket UNKNOWN with a named worklist.
selftest <scratch-prefix> -> gate T1..T8 + beat teeth (unique per-run scratch names)
SSOT for this source is buildroot/runtime/_hdl_build/ on the NAS; the laptop nxc2 tree is a build twin
(synced per edit, video-lane pattern) because the beat RUNS WHERE THE TRANSCRIPTS LIVE (laptop WSL).
license_tier: ORIGINAL
dependencies 7 imports · 0 importers
imports: nx_sovjson_lib.nxnx_json.nxnx_sha256.nxnx_syscalls.nxnx_gate_verdict.nxnx_tool_run.nxnx_mccabe_lib.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 CH_MAGIC_146097: i64 = 146097 |
| 34 | const CH_MAGIC_719468: i64 = 719468 |
| 35 | const CH_MAGIC_86400: i64 = 86400 |
| 36 | const CH_MAGIC_3600: i64 = 3600 |
| 37 | const CH_MAGIC_1784764900: i64 = 1784764900 |
| 38 | const CH_MAGIC_1784764901: i64 = 1784764901 |
| 39 | const CH_MAGIC_1784764803: i64 = 1784764803 |
| 41 | const CH_WIN: i64 = 67108864 |
| 42 | const CH_JWIN: i64 = 4194304 |
| 43 | const CH_OUT: i64 = 65536 |
| 44 | const CH_LINE: i64 = 4096 |
| 45 | const CH_NAME_MAX: i64 = 120 |
| 46 | const CH_NAME_SCAN: i64 = 400 |
| 47 | const CH_MODE_644: i64 = 420 |
| 49 | const CH_AH_MAXPATHS: i64 = 8192 |
| 50 | const CH_AH_PATHCELL: i64 = 512 |
| 51 | const CH_AH_MAXSESS: i64 = 1024 |
| 52 | const CH_AH_SESSCELL: i64 = 64 |
| 53 | const CH_AH_CTRS: i64 = 32 |
| 54 | const CH_AH_SPINE: *u8 = "knowledge/status/mccabe.spine" |
| 55 | const CH_AH_STATUS: *u8 = "knowledge/status/author_health.status" |
| 56 | const CH_AH_TREE: *u8 = "buildroot/runtime/" |
| 57 | const CH_AH_RC_UNOBS: i64 = 3 |
| 58 | const CH_AH_RC_NOPATH: i64 = 4 |
| 59 | const CH_AH_FRAMES: i64 = 0 |
| 60 | const CH_AH_PATHFRAMES: i64 = 1 |
| 61 | const CH_AH_UNIQUE: i64 = 2 |
| 62 | const CH_AH_INTREE: i64 = 3 |
| 63 | const CH_AH_OUTSIDE: i64 = 4 |
| 64 | const CH_AH_FIRSTTS: i64 = 5 |
| 65 | const CH_AH_SESSIONS: i64 = 6 |
| 66 | const CH_AH_FILES: i64 = 7 |
| 67 | const CH_AH_FUNCS: i64 = 8 |
| 68 | const CH_AH_SUMVG: i64 = 9 |
| 69 | const CH_AH_ABOVE: i64 = 10 |
| 70 | const CH_AH_DFILES: i64 = 11 |
| 71 | const CH_AH_DFUNCS: i64 = 12 |
| 72 | const CH_AH_DABOVE: i64 = 13 |
| 73 | const CH_AH_DTS: i64 = 14 |
| 74 | const CH_AH_UNREAD: i64 = 15 |
| 75 | const CH_AH_OVERFLOW: i64 = 16 |
| 76 | const CH_AH_FIX_TS: i64 = 1788600000 |
| 77 | const CH_AH_FIX_DFILES: i64 = 10 |
| 78 | const CH_AH_FIX_DFUNCS: i64 = 20 |
| 79 | const CH_AH_FIX_DABOVE: i64 = 3 |
| 80 | const CH_CH_D0: i64 = 48 |
| 81 | const CH_CH_D9: i64 = 57 |
| 82 | const CH_DEC: i64 = 10 |
| 85 | const CH_BT_DIRWIN: i64 = 65536 // getdents64 batch buffer -- LOOPED until 0, never a listing cap |
| 86 | const CH_BT_PATHMAX: i64 = 512 // one path cell; longest real transcript path measured ~120 B, 4x headroom |
| 87 | const CH_BT_MAXFILES: i64 = 16384 // walk table capacity (837 files measured 2026-08-20); hitting it REFUSES loudly |
| 88 | const CH_BT_MAXDIRS: i64 = 4096 |
| 89 | const CH_BT_ARENA: i64 = 8388608 // path arena = CH_BT_MAXFILES * CH_BT_PATHMAX exactly |
| 90 | const CH_BT_TYPEMAX: i64 = 64 // distinct head-type slots; overflow announces FLOOR-NOT-TOTAL |
| 91 | const CH_BT_DAYMAX: i64 = 128 // distinct ts-days per run (backfill spans ~60); overflow REFUSES loudly |
| 92 | const CH_BT_DAYCELL: i64 = 16 // one day-name cell: YYYYMMDD (8) or tszero (6) + NUL, padded |
| 93 | const CH_MCP_BODY_CLIFF: i64 = 65536 // measured: the MCP write body silently drops beyond ~64 KiB |
| 94 | const CH_BT_CTRS: i64 = 32 // bcx slot count (map at ch_beat) |
| 95 | const CH_MODE_755: i64 = 493 // rwxr-xr-x for the beat's own state/spool/journal dirs |
| 96 | const CH_MAGIC_1460: i64 = 1460 // 4*365 (Hinnant civil-from-days) |
| 97 | const CH_MAGIC_36524: i64 = 36524 // 100*365 + 24 (Hinnant) |
| 98 | const CH_MAGIC_146096: i64 = 146096 // CH_MAGIC_146097 - 1 (Hinnant) |
| 219 | const CH_PATH_SCAN: i64 = 4096 // one transcript line can carry the write's CONTENT before its path key; the frame line is CH_LINE anyway |
| 220 | const CH_PATH_MAX: i64 = 512 |
| 221 | const CH_CH_BSL: i64 = 92 |
| 222 | const CH_WK_NONE: i64 = 0 |
| 223 | const CH_WK_ARGV: i64 = 1 |
| 224 | const CH_WK_FILEPATH: i64 = 2 |
| 524 | const CH_WS_MAX: i64 = 4096 |
| 787 | const CH_CLS_MAX: i64 = 512 // distinct outside tool names tracked (transcript tool names measured ~60 distinct) |
| 788 | const CH_CLS_NAME: i64 = 64 // one name cell; longest builtin tool name measured well under this |
| 789 | const CH_CLS_SHOW: i64 = 12 // JSON shows this many, the rest fold into other |
| 790 | const CH_CLS_JSHOW: i64 = 6 // the journal row shows this many, the rest fold into other |
| 1860 | const CH_MK_MAX: i64 = 64 |
| 1861 | const CH_CONF_WIN: i64 = 65536 |
| 1862 | const CH_TXTWIN: i64 = 262144 |
| 3344 | const CHU_SAFE:i64=9007199254740991 // exact JSON integer interoperability limit |
| 3345 | const CHU_ROW:i64=21 // mask, kind, six identity spans, six counters, epoch |
functions
| 100 | func ch_read(path: *u8, buf: *u8, cap: i64) -> i64 called by 8: ch_framesch_ingestch_bootgaugech_proposech_selftestch_conf_load+2 calls 3: sys_openat_rdsys_readsys_close |
| 110 | func ch_find_from(q: *u8, from: i64, endlim: i64, lit: *u8) -> i64 |
| 128 | func ch_find(q: *u8, n: i64, lit: *u8) -> i64 |
| 133 | func ch_starts(q: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 142 | func ch_digits(q: *u8, s: i64, e: i64) -> i64 |
| 149 | func ch_epoch_ymdhms(y: i64, mo: i64, d: i64, h: i64, mi: i64, s: i64) -> i64 called by 1: ch_iso_epoch |
| 161 | func ch_iso_epoch(q: *u8, s: i64, lim: i64) -> i64 |
| 187 | func ch_frame_write(fd: i64, ln: *u8, ts: i64, ws: *u8, tool: *u8, verb: *u8, outcome: *u8, note: *u8) -> i64 |
| 204 | func ch_frame_append(path: *u8, ts: i64, ws: *u8, tool: *u8, verb: *u8, outcome: *u8, note: *u8) -> i64 |
| 225 | func ch_tool_writer_kind(nm: *u8) -> i64 |
| 233 | func ch_json_str_copy(buf: *u8, k0: i64, le: i64, pb: *u8, cap: i64) -> i64 called by 1: ch_tool_path |
| 250 | func ch_tool_path(buf: *u8, np: i64, le: i64, kind: i64, pb: *u8) -> i64 |
| 272 | func ch_frame_note(buf: *u8, np: i64, le: i64, nm: *u8, verb: *u8, pb: *u8, nb: *u8) -> *u8 |
| 285 | func ch_frames(tpath: *u8, ws: *u8, outj: *u8, tcx: *i64) -> i64 called by 2: ch_selftestmain calls 9: sys_mmapch_readsys_openat_appendsj_lech_find_fromch_iso_epoch+3 |
| 347 | func ch_hwm_read(path: *u8) -> i64 |
| 359 | func ch_hwm_write(path: *u8, v: i64) -> i64 |
| 369 | func ch_delta(tpath: *u8, ws: *u8, outj: *u8, hwmpath: *u8, hcx: *i64) -> i64 called by 3: ch_selftestch_beatmain calls 12: sys_mmapsys_map_filech_hwm_readsys_munmapsys_openat_appendsj_le+6 |
| 448 | func ch_ingest(fpath: *u8, jpath: *u8, mcx: *i64) -> i64 |
| 503 | func ch_nishi_tool(q: *u8, s: i64, e: i64) -> i64 |
| 510 | func ch_key(d: *u8, o: i64, name: *u8) -> i64 |
| 525 | func ch_bg_intern(q: *u8, cs: i64, ce: i64, wss: *i64, wse: *i64, np: *i64) -> i64 called by 1: ch_bootgauge |
| 542 | func ch_bootgauge(journal: *u8, k: i64, d: *u8) -> i64 |
| 619 | func ch_gauge_calc(jpath: *u8, days: i64, g: *i64) -> i64 |
| 686 | func ch_gauge_json(jpath: *u8, days: i64, d: *u8) -> i64 |
| 734 | func ch_page(jpath: *u8, outp: *u8, days: i64) -> i64 |
| 791 | func ch_classes_calc(jpath: *u8, names: *u8, counts: *i64, c: *i64) -> i64 called by 2: ch_classes_jsonch_journal calls 7: sys_mmapsys_read_filesj_lesj_colch_digitsch_starts+1 |
| 843 | func ch_classes_top(counts: *i64, used: *i64, ncls: i64) -> i64 called by 1: ch_classes_cat |
| 849 | func ch_classes_cat(d: *u8, o0: i64, names: *u8, counts: *i64, ncls: i64, show: i64, outside: i64) -> i64 |
| 873 | func ch_classes_json(jpath: *u8, d: *u8) -> i64 called by 2: ch_classesch_selftest calls 6: sys_mmapch_classes_calcch_keysj_catnsj_catch_classes_cat |
| 901 | func ch_classes(jpath: *u8, d: *u8) -> i64 { return ch_classes_json(jpath, d) } |
| 907 | func ch_journal(jpath: *u8, planpath: *u8, rung: *u8) -> i64 called by 2: ch_selftestmain calls 12: sys_mmapch_gauge_calcsys_now_realtime_secsys_read_filesj_catsj_catn+6 |
| 966 | func ch_allow_path(name: *u8, outp: *u8) -> i64 { return sj_allow_path(name, outp) } |
| 967 | func ch_propose(jpath: *u8, ipath: *u8, thr: i64, filer: *u8, cout: *u8, colen: *i64) -> i64 |
| 1005 | func ch_selftest(prefix: *u8) -> i64 |
| 1866 | func ch_run_of(q: *u8, s: i64, e: i64, g: *u8) -> i64 |
| 1895 | func ch_conf_load(path: *u8, cbuf: *u8, mk: *i64, sc: *i64) -> i64 |
| 1942 | func ch_isalpha(c: u8) -> i64 called by 1: ch_rank_text |
| 1951 | func ch_rank_text(q: *u8, s: i64, e: i64, cbuf: *u8, mk: *i64, sc: *i64) -> i64 |
| 1981 | func ch_learn(tpath: *u8, ws: *u8, outp: *u8, confp: *u8, cx: *i64) -> i64 called by 2: ch_selftestmain calls 12: sys_mmapch_conf_loadch_readsys_openat_appendsj_lech_find_from+6 |
| 2110 | func ch_bt_zeq(a: *u8, b: *u8) -> i64 |
| 2115 | func ch_bt_ends(s: *u8, sfx: *u8) -> i64 |
| 2121 | func ch_bt_le16(b: *u8, off: i64) -> i64 { return (b[off] as i64) + (b[off+1] as i64) * 256 } called by 1: ch_bt_stat |
| 2122 | func ch_bt_le64(b: *u8, off: i64) -> i64 called by 1: ch_bt_stat |
| 2132 | func ch_bt_stat(path: *u8, sb: *u8, k: *i64) -> i64 |
| 2146 | func ch_bt_walk(root: *u8, sfx: *u8, ar: *u8, fo: *i64, wcx: *i64) -> i64 called by 2: ch_selftestch_beat calls 11: sys_mmapsj_vlensj_catsys_openat_rdsys_getdents64dirent_reclen+5 |
| 2230 | func ch_bt_day(ts: i64, d: *u8) -> i64 |
| 2256 | func ch_bt_kv(cbuf: *u8, i: i64, le: i64, key: *u8) -> i64 |
| 2265 | func ch_bt_conf(path: *u8, cbuf: *u8, off: *i64, iv: *i64, kt: *i64, kcx: *i64) -> i64 |
| 2357 | func ch_bt_census(tpath: *u8, from: i64, to: i64, cbuf: *u8, kt: *i64, kn: i64, ua: *u8, uo: *i64, ucx: *i64, ccx: *i64) -> i64 |
| 2424 | func ch_bt_path2(out: *u8, a: *u8, b: *u8) -> i64 |
| 2432 | func ch_bt_base(path: *u8) -> *u8 |
| 2438 | func ch_bt_stem(path: *u8, out: *u8) -> i64 |
| 2448 | func ch_bt_hwmpath(state: *u8, rel: *u8, out: *u8) -> i64 |
| 2466 | func ch_bt_lines(path: *u8) -> i64 |
| 2482 | func ch_bt_int_after(b: *u8, n: i64, key: *u8) -> i64 |
| 2501 | func ch_bt_parse_sha(b: *u8, n: i64, out: *u8) -> i64 |
| 2524 | func ch_bt_wire(wire: *u8, script: *u8, tool: *u8, cap: *u8, a1: *u8, a2: *u8, a3: *u8, a4: *u8, tmo: i64, cout: *u8, colen: *i64) -> i64 |
| 2538 | func ch_bt_flushp(spool: *u8, day: *u8, stamp: i64, seq: i64, cell: *u8, clen: i64) -> i64 |
| 2564 | func ch_bt_split(rawpath: *u8, spool: *u8, stamp: i64, piece_raw: i64, dcx: *i64) -> i64 |
| 2643 | func ch_bt_pieceday(pbase: *u8, db: *u8) -> i64 |
| 2674 | func ch_bt_pushreason(wrote_ok: i64, okr: i64, same: i64) -> *u8 |
| 2686 | func ch_bt_push1(ppath: *u8, cbuf: *u8, off: *i64, iv: *i64, pjr: *u8, bcx: *i64) -> i64 called by 1: ch_beat calls 16: ch_bt_basesys_mmapch_bt_linesch_bt_piecedaysj_cattr_run_capture_to+10 |
| 2788 | func ch_beat(confpath: *u8, bcx: *i64) -> i64 called by 2: ch_selftestmain calls 25: sys_mmapch_bt_confsj_putssys_mkdirsys_now_realtime_usch_bt_walk+19 |
| 3129 | func ch_ah_prefix(p: *u8, pre: *u8) -> i64 called by 1: ce_author_health |
| 3135 | func ch_ah_field_n(buf: *u8, i: i64, le: i64, want: i64, out: *u8, cap: i64) -> i64 called by 1: ce_author_health |
| 3159 | func ch_ah_find(tab: *u8, n: i64, cell: i64, p: *u8) -> i64 |
| 3168 | func ch_ah_lastline(buf: *u8, n: i64) -> i64 |
| 3176 | func ch_ah_num(buf: *u8, p0: i64, to: i64) -> i64 |
| 3188 | func ch_ah_field(buf: *u8, from: i64, to: i64, key: *u8) -> i64 |
| 3193 | func ce_author_health(jpath: *u8, pre: *u8, spine: *u8, cx: *i64, ob: *u8) -> i64 |
| 3346 | func chu_uint(q:*u8,s:i64,n:i64)->i64 |
| 3352 | func chu_key(t:*NxJsonTok,ctx:i64)->i64 |
| 3377 | func chu_value(t:*NxJsonTok,ctx:i64,r:*i64,depth:i64)->i64 |
| 3426 | func chu_row(t:*NxJsonTok,q:*u8,n:i64,r:*i64)->i64 |
| 3452 | func chu_span_same(q:*u8,a:*i64,b:*i64,slot:i64)->i64 called by 1: chu_totals |
| 3457 | func chu_totals(q:*u8,n:i64,from:i64,to:i64,table:*i64,t:*NxJsonTok,r:*i64,c:*i64)->i64 |
| 3494 | func chu_emit(path:*u8,digest:*u8,state:*u8,rc:i64,extent:i64,start:i64,end:i64,head:i64,tail:i64,from:i64,to:i64,c:*i64)->i64 |
| 3530 | func ch_usage_window(path:*u8,from:i64,to:i64,start:i64,end:i64)->i64 |
| 3587 | func main(argc: i64, argv: *i64) -> i64 |