code wiki / _hdl_build / nx_bench_ingest.nx
nx_bench_ingest.nx
buildroot/runtime/_hdl_build/nx_bench_ingest.nx
about
nx_bench_ingest.nx -- THE GENERIC BENCHMARK INGEST (rule 15 DRY; the second half of nx_bench_fetch).
WHY: nx_swebv_ingest and nx_gmmlu_ingest are ~90% the same body -- an escape-aware JSON row walker whose
only real difference is WHICH FIELD NAMES it pulls. Baking field names into source means a new organ per
benchmark, and (per the ~119 *_research_fetch family) every copy inherits the original's latent bugs.
Here the field names are ARGUMENTS, so a new card axis is a DATA row, not a new organ (rule 11).
nx_bench_ingest <rawpath> <first_field> <id_field> <q_field> <opts_csv|-> <a_field> <taskpfx> <goldpfx>
first_field = the FIRST feature of the row object; the row anchor is "row":{"<first_field>":"
opts_csv = e.g. option_a,option_b,option_c,option_d (or `-` for a non-multiple-choice set)
emits taskpfx : id <TAB> question [<TAB> opt]... (NEVER the answer -- contamination split)
goldpfx : id <TAB> answer
Same correctness core as the bespoke organs it replaces: escape-aware value end (terminating '"' = one
preceded by an EVEN run of backslashes, so text containing \" cannot mis-terminate a field), row search
BOUNDED to [row,next-row) so a malformed row cannot steal a sibling's fields, values stored JSON-escaped
verbatim (TAB/NEWLINE-safe by construction), truncations COUNTED not silent, and fail-closed: task==gold
and >0 or NEITHER store is touched.
expect_exit: 0 (GREEN) | 1 RED | 2 usage license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 3 imports · 0 importers
imports: nx_store_seed_lib.nxnx_seg_store.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
| 35 | const BI_FCAP: i64 = 8388608 |
| 36 | const BI_OCAP: i64 = 4194304 |
| 37 | const BI_FIELDCAP: i64 = 16384 |
| 38 | const BI_NDLCAP: i64 = 256 |
| 39 | const BI_SBCAP: i64 = 2048 |
| 40 | const BI_TAB: i64 = 9 |
| 41 | const BI_NL: i64 = 10 |
| 42 | const BI_Q: i64 = 34 |
| 43 | const BI_BSL: i64 = 92 |
| 44 | const BI_COMMA: i64 = 44 |
| 45 | const BI_STDERR: i64 = 2 |
| 46 | const BI_D0: i64 = 48 |
| 47 | const BI_B10: i64 = 10 |
| 48 | const BI_NUMB: i64 = 24 |
| 49 | const BI_EXIT_RED: i64 = 1 |
| 50 | const BI_EXIT_USAGE: i64 = 2 |
| 51 | const BI_ARGC: i64 = 9 |
| 52 | const BI_DASH: i64 = 45 |
functions
| 54 | func bi_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 55 | func bi_werr(s: *u8) -> i64 { sys_write(BI_STDERR, s, bi_slen(s)); return 0 } |
| 56 | func bi_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 70 | func bi_cat(d: *u8, off: i64, s: *u8) -> i64 |
| 76 | func bi_catn(d: *u8, off: i64, v: i64) -> i64 |
| 89 | func bi_needle(dst: *u8, field: *u8) -> i64 |
| 101 | func bi_find(buf: *u8, needle: *u8, from: i64, limit: i64) -> i64 |
| 115 | func bi_vend(buf: *u8, vs: i64, limit: i64) -> i64 called by 1: bi_field |
| 129 | func bi_field(buf: *u8, needle: *u8, from: i64, limit: i64) -> i64 |
| 136 | func bi_t_c(c: i64) -> i64 { if g_to < BI_OCAP - 2 { g_t[g_to] = c as u8; g_to = g_to + 1 } return 0 } |
| 137 | func bi_g_c(c: i64) -> i64 { if g_go < BI_OCAP - 2 { g_g[g_go] = c as u8; g_go = g_go + 1 } return 0 } |
| 138 | func bi_t_slice(buf: *u8, a: i64, b: i64) -> i64 |
| 145 | func bi_g_slice(buf: *u8, a: i64, b: i64) -> i64 called by 1: bi_scan |
| 153 | func bi_t_n(v: i64) -> i64 |
| 164 | func bi_g_n(v: i64) -> i64 |
| 176 | func bi_col(buf: *u8, f: *u8, a: i64, limit: i64) -> i64 |
| 187 | func bi_opts(buf: *u8, csv: *u8, a: i64, limit: i64) -> i64 |
| 212 | func bi_scan(buf: *u8, n: i64, anchor: *u8, idf: *u8, qf: *u8, optcsv: *u8, af: *u8) -> i64 |
| 255 | func main(argc: i64, argv: *i64) -> i64 |