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

183343 B3762 linesdepth 6pulls 15 transitivereach 0 importersview sourcekind tooltopic claude
docsdependenciesstructsconstsfunctions

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

nx_sovjson_lib.nx nx_json.nx nx_sha256.nx nx_syscalls.nx nx_gate_verdict.nx nx_tool_run.nx nx_mccabe_lib.nx nx_claude_harvest_usage_t76.nx

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

main sj_lit_eq sj_vlen sj_puts sys_write ch_usage_window sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sj_vlen ↻ chu_emit sys_mmap ↻ sj_cat sj_catn sys_mmap ↻ sj_vlen ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real sys_write ↻ sys_munmap sys_munmap ↻ sys_openat_rd sys_lseek sys_close nx_json_new sys_mmap ↻ sys_read

structs

none

consts

33const CH_MAGIC_146097: i64 = 146097
34const CH_MAGIC_719468: i64 = 719468
35const CH_MAGIC_86400: i64 = 86400
36const CH_MAGIC_3600: i64 = 3600
37const CH_MAGIC_1784764900: i64 = 1784764900
38const CH_MAGIC_1784764901: i64 = 1784764901
39const CH_MAGIC_1784764803: i64 = 1784764803
41const CH_WIN: i64 = 67108864
42const CH_JWIN: i64 = 4194304
43const CH_OUT: i64 = 65536
44const CH_LINE: i64 = 4096
45const CH_NAME_MAX: i64 = 120
46const CH_NAME_SCAN: i64 = 400
47const CH_MODE_644: i64 = 420
49const CH_AH_MAXPATHS: i64 = 8192
50const CH_AH_PATHCELL: i64 = 512
51const CH_AH_MAXSESS: i64 = 1024
52const CH_AH_SESSCELL: i64 = 64
53const CH_AH_CTRS: i64 = 32
54const CH_AH_SPINE: *u8 = "knowledge/status/mccabe.spine"
55const CH_AH_STATUS: *u8 = "knowledge/status/author_health.status"
56const CH_AH_TREE: *u8 = "buildroot/runtime/"
57const CH_AH_RC_UNOBS: i64 = 3
58const CH_AH_RC_NOPATH: i64 = 4
59const CH_AH_FRAMES: i64 = 0
60const CH_AH_PATHFRAMES: i64 = 1
61const CH_AH_UNIQUE: i64 = 2
62const CH_AH_INTREE: i64 = 3
63const CH_AH_OUTSIDE: i64 = 4
64const CH_AH_FIRSTTS: i64 = 5
65const CH_AH_SESSIONS: i64 = 6
66const CH_AH_FILES: i64 = 7
67const CH_AH_FUNCS: i64 = 8
68const CH_AH_SUMVG: i64 = 9
69const CH_AH_ABOVE: i64 = 10
70const CH_AH_DFILES: i64 = 11
71const CH_AH_DFUNCS: i64 = 12
72const CH_AH_DABOVE: i64 = 13
73const CH_AH_DTS: i64 = 14
74const CH_AH_UNREAD: i64 = 15
75const CH_AH_OVERFLOW: i64 = 16
76const CH_AH_FIX_TS: i64 = 1788600000
77const CH_AH_FIX_DFILES: i64 = 10
78const CH_AH_FIX_DFUNCS: i64 = 20
79const CH_AH_FIX_DABOVE: i64 = 3
80const CH_CH_D0: i64 = 48
81const CH_CH_D9: i64 = 57
82const CH_DEC: i64 = 10
85const CH_BT_DIRWIN: i64 = 65536 // getdents64 batch buffer -- LOOPED until 0, never a listing cap
86const CH_BT_PATHMAX: i64 = 512 // one path cell; longest real transcript path measured ~120 B, 4x headroom
87const CH_BT_MAXFILES: i64 = 16384 // walk table capacity (837 files measured 2026-08-20); hitting it REFUSES loudly
88const CH_BT_MAXDIRS: i64 = 4096
89const CH_BT_ARENA: i64 = 8388608 // path arena = CH_BT_MAXFILES * CH_BT_PATHMAX exactly
90const CH_BT_TYPEMAX: i64 = 64 // distinct head-type slots; overflow announces FLOOR-NOT-TOTAL
91const CH_BT_DAYMAX: i64 = 128 // distinct ts-days per run (backfill spans ~60); overflow REFUSES loudly
92const CH_BT_DAYCELL: i64 = 16 // one day-name cell: YYYYMMDD (8) or tszero (6) + NUL, padded
93const CH_MCP_BODY_CLIFF: i64 = 65536 // measured: the MCP write body silently drops beyond ~64 KiB
94const CH_BT_CTRS: i64 = 32 // bcx slot count (map at ch_beat)
95const CH_MODE_755: i64 = 493 // rwxr-xr-x for the beat's own state/spool/journal dirs
96const CH_MAGIC_1460: i64 = 1460 // 4*365 (Hinnant civil-from-days)
97const CH_MAGIC_36524: i64 = 36524 // 100*365 + 24 (Hinnant)
98const CH_MAGIC_146096: i64 = 146096 // CH_MAGIC_146097 - 1 (Hinnant)
219const 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
220const CH_PATH_MAX: i64 = 512
221const CH_CH_BSL: i64 = 92
222const CH_WK_NONE: i64 = 0
223const CH_WK_ARGV: i64 = 1
224const CH_WK_FILEPATH: i64 = 2
524const CH_WS_MAX: i64 = 4096
787const CH_CLS_MAX: i64 = 512 // distinct outside tool names tracked (transcript tool names measured ~60 distinct)
788const CH_CLS_NAME: i64 = 64 // one name cell; longest builtin tool name measured well under this
789const CH_CLS_SHOW: i64 = 12 // JSON shows this many, the rest fold into other
790const CH_CLS_JSHOW: i64 = 6 // the journal row shows this many, the rest fold into other
1860const CH_MK_MAX: i64 = 64
1861const CH_CONF_WIN: i64 = 65536
1862const CH_TXTWIN: i64 = 262144
3344const CHU_SAFE:i64=9007199254740991 // exact JSON integer interoperability limit
3345const CHU_ROW:i64=21 // mask, kind, six identity spans, six counters, epoch

functions

100func ch_read(path: *u8, buf: *u8, cap: i64) -> i64
110func ch_find_from(q: *u8, from: i64, endlim: i64, lit: *u8) -> i64
128func ch_find(q: *u8, n: i64, lit: *u8) -> i64
133func ch_starts(q: *u8, s: i64, e: i64, lit: *u8) -> i64
142func ch_digits(q: *u8, s: i64, e: i64) -> i64
149func ch_epoch_ymdhms(y: i64, mo: i64, d: i64, h: i64, mi: i64, s: i64) -> i64
called by 1: ch_iso_epoch
161func ch_iso_epoch(q: *u8, s: i64, lim: i64) -> i64
187func ch_frame_write(fd: i64, ln: *u8, ts: i64, ws: *u8, tool: *u8, verb: *u8, outcome: *u8, note: *u8) -> i64
204func ch_frame_append(path: *u8, ts: i64, ws: *u8, tool: *u8, verb: *u8, outcome: *u8, note: *u8) -> i64
225func ch_tool_writer_kind(nm: *u8) -> i64
called by 1: ch_frame_note calls 2: sj_vlensj_lit_eq
233func ch_json_str_copy(buf: *u8, k0: i64, le: i64, pb: *u8, cap: i64) -> i64
called by 1: ch_tool_path
250func ch_tool_path(buf: *u8, np: i64, le: i64, kind: i64, pb: *u8) -> i64
272func ch_frame_note(buf: *u8, np: i64, le: i64, nm: *u8, verb: *u8, pb: *u8, nb: *u8) -> *u8
285func ch_frames(tpath: *u8, ws: *u8, outj: *u8, tcx: *i64) -> i64
347func ch_hwm_read(path: *u8) -> i64
359func ch_hwm_write(path: *u8, v: i64) -> i64
369func ch_delta(tpath: *u8, ws: *u8, outj: *u8, hwmpath: *u8, hcx: *i64) -> i64
448func ch_ingest(fpath: *u8, jpath: *u8, mcx: *i64) -> i64
503func ch_nishi_tool(q: *u8, s: i64, e: i64) -> i64
510func ch_key(d: *u8, o: i64, name: *u8) -> i64
525func ch_bg_intern(q: *u8, cs: i64, ce: i64, wss: *i64, wse: *i64, np: *i64) -> i64
called by 1: ch_bootgauge
542func ch_bootgauge(journal: *u8, k: i64, d: *u8) -> i64
619func ch_gauge_calc(jpath: *u8, days: i64, g: *i64) -> i64
686func ch_gauge_json(jpath: *u8, days: i64, d: *u8) -> i64
734func ch_page(jpath: *u8, outp: *u8, days: i64) -> i64
791func ch_classes_calc(jpath: *u8, names: *u8, counts: *i64, c: *i64) -> i64
843func ch_classes_top(counts: *i64, used: *i64, ncls: i64) -> i64
called by 1: ch_classes_cat
849func ch_classes_cat(d: *u8, o0: i64, names: *u8, counts: *i64, ncls: i64, show: i64, outside: i64) -> i64
873func ch_classes_json(jpath: *u8, d: *u8) -> i64
901func ch_classes(jpath: *u8, d: *u8) -> i64 { return ch_classes_json(jpath, d) }
called by 1: main calls 1: ch_classes_json
907func ch_journal(jpath: *u8, planpath: *u8, rung: *u8) -> i64
966func ch_allow_path(name: *u8, outp: *u8) -> i64 { return sj_allow_path(name, outp) }
called by 2: ch_proposech_selftest calls 1: sj_allow_path
967func ch_propose(jpath: *u8, ipath: *u8, thr: i64, filer: *u8, cout: *u8, colen: *i64) -> i64
1005func ch_selftest(prefix: *u8) -> i64
1866func ch_run_of(q: *u8, s: i64, e: i64, g: *u8) -> i64
called by 1: ch_rank_text calls 1: sj_vlen
1895func ch_conf_load(path: *u8, cbuf: *u8, mk: *i64, sc: *i64) -> i64
1942func ch_isalpha(c: u8) -> i64
called by 1: ch_rank_text
1951func ch_rank_text(q: *u8, s: i64, e: i64, cbuf: *u8, mk: *i64, sc: *i64) -> i64
1981func ch_learn(tpath: *u8, ws: *u8, outp: *u8, confp: *u8, cx: *i64) -> i64
2110func ch_bt_zeq(a: *u8, b: *u8) -> i64
2115func ch_bt_ends(s: *u8, sfx: *u8) -> i64
called by 1: ch_bt_walk calls 2: sj_vlensj_lit_eq
2121func 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
2122func ch_bt_le64(b: *u8, off: i64) -> i64
called by 1: ch_bt_stat
2132func ch_bt_stat(path: *u8, sb: *u8, k: *i64) -> i64
2146func ch_bt_walk(root: *u8, sfx: *u8, ar: *u8, fo: *i64, wcx: *i64) -> i64
2230func ch_bt_day(ts: i64, d: *u8) -> i64
called by 1: ch_bt_split calls 1: sj_cat
2256func ch_bt_kv(cbuf: *u8, i: i64, le: i64, key: *u8) -> i64
called by 1: ch_bt_conf calls 2: ch_startssj_vlen
2265func ch_bt_conf(path: *u8, cbuf: *u8, off: *i64, iv: *i64, kt: *i64, kcx: *i64) -> i64
2357func ch_bt_census(tpath: *u8, from: i64, to: i64, cbuf: *u8, kt: *i64, kn: i64, ua: *u8, uo: *i64, ucx: *i64, ccx: *i64) -> i64
2424func ch_bt_path2(out: *u8, a: *u8, b: *u8) -> i64
called by 1: ch_beat calls 1: sj_cat
2432func ch_bt_base(path: *u8) -> *u8
2438func ch_bt_stem(path: *u8, out: *u8) -> i64
called by 1: ch_beat calls 2: ch_bt_basesj_vlen
2448func ch_bt_hwmpath(state: *u8, rel: *u8, out: *u8) -> i64
called by 1: ch_beat calls 1: sj_cat
2466func ch_bt_lines(path: *u8) -> i64
2482func ch_bt_int_after(b: *u8, n: i64, key: *u8) -> i64
2501func ch_bt_parse_sha(b: *u8, n: i64, out: *u8) -> i64
2524func 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
2538func ch_bt_flushp(spool: *u8, day: *u8, stamp: i64, seq: i64, cell: *u8, clen: i64) -> i64
2564func ch_bt_split(rawpath: *u8, spool: *u8, stamp: i64, piece_raw: i64, dcx: *i64) -> i64
2643func ch_bt_pieceday(pbase: *u8, db: *u8) -> i64
2674func ch_bt_pushreason(wrote_ok: i64, okr: i64, same: i64) -> *u8
2686func ch_bt_push1(ppath: *u8, cbuf: *u8, off: *i64, iv: *i64, pjr: *u8, bcx: *i64) -> i64
2788func ch_beat(confpath: *u8, bcx: *i64) -> i64
3129func ch_ah_prefix(p: *u8, pre: *u8) -> i64
called by 1: ce_author_health
3135func ch_ah_field_n(buf: *u8, i: i64, le: i64, want: i64, out: *u8, cap: i64) -> i64
called by 1: ce_author_health
3159func ch_ah_find(tab: *u8, n: i64, cell: i64, p: *u8) -> i64
called by 1: ce_author_health calls 2: sj_lit_eqsj_vlen
3168func ch_ah_lastline(buf: *u8, n: i64) -> i64
called by 1: ce_author_health calls 1: sj_le
3176func ch_ah_num(buf: *u8, p0: i64, to: i64) -> i64
3188func ch_ah_field(buf: *u8, from: i64, to: i64, key: *u8) -> i64
3193func ce_author_health(jpath: *u8, pre: *u8, spine: *u8, cx: *i64, ob: *u8) -> i64
3346func chu_uint(q:*u8,s:i64,n:i64)->i64
3352func chu_key(t:*NxJsonTok,ctx:i64)->i64
called by 1: chu_value calls 1: sj_lit_eq
3377func chu_value(t:*NxJsonTok,ctx:i64,r:*i64,depth:i64)->i64
3426func chu_row(t:*NxJsonTok,q:*u8,n:i64,r:*i64)->i64
3452func chu_span_same(q:*u8,a:*i64,b:*i64,slot:i64)->i64
called by 1: chu_totals
3457func chu_totals(q:*u8,n:i64,from:i64,to:i64,table:*i64,t:*NxJsonTok,r:*i64,c:*i64)->i64
3494func 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
3530func ch_usage_window(path:*u8,from:i64,to:i64,start:i64,end:i64)->i64
3587func main(argc: i64, argv: *i64) -> i64