code wiki / _hdl_build / nx_wfcost_outcomes_t144.nx

nx_wfcost_outcomes_t144.nx

buildroot/runtime/_hdl_build/nx_wfcost_outcomes_t144.nx

62223 B1233 linesdepth 7pulls 24 transitivereach 1 importersview sourcekind librarytopic wfcost
docsdependenciesstructsconstsfunctions

about

nx_wfcost.nx -- WORKFLOW-EPISODE TOKEN COST (Lane I, common-task hardening loop, 2026-08-20). Operator: "grow our capabilities into repeatable high value little to no token capabilities". Ranking hardening candidates needs the REAL cost of what we already do repeatedly. The estate had the three halves and never joined them: nx_actlog mines recurring tool:verb support, nx_eff_lib measures transcript tokens PER DAY, and nx_tokroi's uses_per_day is a DECLARED assumption. This organ joins them: per-INVOCATION-PAIR measured token cost over the FULL transcript population. THE CORRECTION THIS ORGAN CARRIES (measured 2026-08-20, and it is why the join could not be trusted before): one assistant MESSAGE is written to the transcript as SEVERAL JSONL LINES -- one per content block (thinking, tool_use, text) -- and EVERY one of those lines repeats the SAME usage object verbatim. nx_eff_lib::es_tr_tokens dedups the two usage copies WITHIN a line (message.usage and the iterations[] echo -- that half is correct and gated by its T20) but counts once PER LINE, so a message with N content blocks is counted N times. Measured over the 12 largest transcripts: 43,372 assistant lines carry only 22,234 distinct message ids => the per-line method overstates by ~1.95x. This organ dedups by message.id through a real hash set and PRINTS BOTH TOTALS side by side so the correction is proven by the run, never asserted (two counters of one population = free audit). Dedup is a SET, not a previous-id compare: 12 of 22,234 ids reappear NON-consecutively, so the cheap compare would silently overcount those. gauge [trdir] -> corrected(msgid-deduped) vs perline totals + overcount permil + envelope mine [trdir] [minsup] -> recurring invocation PAIRS >= minsup with exact total measured tokens selftest -> gv_verdict gate, named neg-controls, runtime fixtures RANKING QUANTITY IS THE EXACT TOTAL, NOT A MEDIAN: total = the sum of every episode's measured cost, carried exactly. A median would need a second pass plus per-episode retention; mean and max are printed and LABELLED as such, and no median is claimed. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 5 imports · 1 importers

nx_syscalls.nx nx_gate_verdict.nx nx_claude_harvest.nx nx_comparestale_lib.nx nx_store_seed_lib.nx nx_wfcost_outcomes_t144.nx nx_wfcost_outcomes_gate_t144.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_claude_harvest.nxnx_comparestale_lib.nxnx_store_seed_lib.nx

imported by: nx_wfcost_outcomes_gate_t144.nx

structs

none

consts

30const WF_TR_DEF: *u8 = "/mnt/c/Users/elder/.claude/projects/C--Users-elder"
32const WF_NL: i64 = 10
33const WF_QUOTE: i64 = 34
34const WF_SLASH: i64 = 47
35const WF_ZERO: i64 = 48
36const WF_NINE: i64 = 57
40const WF_W_IN: i64 = 10
41const WF_W_OUT: i64 = 50
42const WF_W_CR: i64 = 1
43const WF_W_CW: i64 = 12
44const WF_W_DIV: i64 = 10
46const WF_MID_SLOTS: i64 = 4194304
47const WF_MID_MASK: i64 = 4194303
49const WF_ID_SLOTS: i64 = 262144
50const WF_ID_MASK: i64 = 262143
51const WF_IDS_MAX: i64 = 32768
52const WF_ARENA: i64 = 8388608
53const WF_LABEL_MAX: i64 = 96
55const WF_BG_SLOTS: i64 = 1048576
56const WF_BG_MASK: i64 = 1048575
58const WF_MSG_MAX: i64 = 262144
59const WF_INV_MAX: i64 = 262144
61const WF_E_FILES: i64 = 0
62const WF_E_BYTES: i64 = 1
63const WF_E_LINES: i64 = 2
64const WF_E_MSGS: i64 = 3
65const WF_E_DUPLINES: i64 = 4
66const WF_E_INVS: i64 = 5
67const WF_E_UNREAD: i64 = 6
68const WF_E_MSGCAP: i64 = 7
69const WF_E_INVCAP: i64 = 8
70const WF_E_IDCAP: i64 = 9
71const WF_E_BGCAP: i64 = 10
72const WF_E_PAIRS: i64 = 11
73const WF_E_SLOTS: i64 = 16
75const WF_T_IN: i64 = 0
76const WF_T_OUT: i64 = 1
77const WF_T_CR: i64 = 2
78const WF_T_CW: i64 = 3
79const WF_T_PIN: i64 = 4
80const WF_T_POUT: i64 = 5
81const WF_T_PCR: i64 = 6
82const WF_T_PCW: i64 = 7
83const WF_T_SLOTS: i64 = 8
84const WF_STAT_BUF: i64 = 256
85const WF_DIRENT_BUF: i64 = 65536
86const WF_PATH_BUF: i64 = 4096
87const WF_GETDENTS: i64 = 217
88const WF_RECLEN_OFF: i64 = 16
89const WF_NAME_OFF: i64 = 19
90const WF_TOP_DEF: i64 = 40
91const WF_PERMIL: i64 = 1000
92const WF_MODE_755: i64 = 493
93const WF_MODE_644: i64 = 420
94const WF_TSV_TAB: i64 = 9
95const WF_DAYSEC: i64 = 86400
96const WF_E_MINTS: i64 = 12
97const WF_E_MAXTS: i64 = 13
98const WF_E_FRAMES: i64 = 14
99const WF_CHBEAT_DEF: *u8 = "knowledge/status/chbeat"
860const WFJ_COLS:i64=16
861const WFJ_STATS:i64=25
1194const WFJ_CONFIG_COLS:i64=7
1195const WFJ_CONFIG_PREFIX:*u8="knowledge/store/wfcost-evaluations-"

functions

101func wf_len(s: *u8) -> i64
106func wf_eq(a: *u8, b: *u8) -> i64
117func wf_atoi(s: *u8) -> i64
128func wf_find_in(b: *u8, a: i64, e: i64, needle: *u8) -> i64
142func wf_num_at(b: *u8, e: i64, p: i64) -> i64
157func wf_hash(b: *u8, a: i64, e: i64) -> i64
171func wf_set_add(tab: *i64, h: i64) -> i64
184func wf_intern(tab: *i64, offs: *i64, arena: *u8, st: *i64, b: *u8, a: i64, e: i64) -> i64
215func wf_pair_add(bg: *i64, key: i64, tok: i64, env: *i64) -> i64
242func wf_is_jsonl(name: *u8) -> i64
254func wf_scan_file(path: *u8, mids: *i64, idtab: *i64, idoffs: *i64, arena: *u8, ist: *i64, bg: *i64, msgtok: *i64, invid: *i64, invmsg: *i64, env: *i64, tok: *i64) -> i64
372func wf_walk(dir: *u8, mids: *i64, idtab: *i64, idoffs: *i64, arena: *u8, ist: *i64, bg: *i64, msgtok: *i64, invid: *i64, invmsg: *i64, env: *i64, tok: *i64) -> i64
403func wf_emit_env(env: *i64, tok: *i64) -> i64
431func wf_gauge(dir: *u8) -> i64
473func wf_mine(dir: *u8, minsup: i64, top: i64) -> i64
557func wf_is_jrnl(name: *u8) -> i64
567func wf_frames_file(path: *u8, idtab: *i64, idoffs: *i64, arena: *u8, ist: *i64, bg: *i64, env: *i64) -> i64
626func wf_frames(dir: *u8, minsup: i64, top: i64) -> i64
724func wf_selftest() -> i64
803func main(argc: i64, argv: *i64) -> i64
867func wfj_span_eq(a:*u8,s:i64,n:i64,b:*u8,t:i64,m:i64)->i64
870func wfj_lit(q:*u8,f:*i64,col:i64,s:*u8)->i64{return wfj_span_eq(q,f[col*2],f[col*2+1],s,0,cd_len(s))}
871func wfj_fields_n(q:*u8,s:i64,e:i64,f:*i64,cols:i64)->i64
884func wfj_fields(q:*u8,s:i64,e:i64,f:*i64)->i64{return wfj_fields_n(q,s,e,f,WFJ_COLS)}
885func wfj_hash(q:*u8,f:*i64,col:i64)->i64
889func wfj_copy(q:*u8,f:*i64,col:i64,out:*u8)->i64
892func wfj_role(q:*u8,f:*i64)->i64
897func wfj_validate(q:*u8,f:*i64)->i64
912func wfj_evidence(q:*u8,f:*i64)->i64
931func wfj_join(raw:*u8,table:*i64,count:i64,from:i64,to:i64,digest:*u8,bindings:*u8,n:i64,stats:*i64,usage:*i64)->i64
1002func wfj_read(path:*u8,limit:i64,result:*i64)->*u8
1020func wfj_digest(raw:*u8,n:i64,hex:*u8)->i64
1031func wfj_plane_range(prefix:*u8,cols:i64,extra:i64,meta:*i64)->*u8
1078func wfj_plane(prefix:*u8,cols:i64,meta:*i64)->*u8{return wfj_plane_range(prefix,cols,0,meta)}
1082func wfj_retain_bindings(path:*u8,rows:*u8,n:i64)->i64
1096func wfj_null(j:*JsonWriter,key:*u8)->i64 {let rc:i64=json_emit_key(j,key,cd_len(key));return rc|json_emit_null(j)}
1097func wfj_report(stage:*u8,code:i64,digest:*u8,from:i64,to:i64,plane:*u8,pm:*i64,s:*i64,u:*i64,c:*i64,config_id:*u8,config_sha:*u8,binding_sha:*u8,snapshot:*u8,snapshot_rc:i64)->i64
1153func wfj_command_context(argc:i64,argv:*i64,config_id:*u8,config_sha:*u8)->i64
1189func wfj_command(argc:i64,argv:*i64)->i64{return wfj_command_context(argc,argv,0 as *u8,0 as *u8)}
1196func wfj_config_command(argc:i64,argv:*i64)->i64