nx_bright_reasoned_import.nx
buildroot/runtime/nx_bright_reasoned_import.nx
about
nx_bright_reasoned_import.nx -- REFEREE-REPLAY IMPORTER for a published reasoned-query set (search R0l, 2026-09-16).
A query reasoner's authors publish their rewrites as ONE JSON object keyed by the ORIGINAL BRIGHT query text with
the rewrite as the value (TongSearch-QR ships one file per model, MIT). This organ matches that object, split by
split, against the estate's own BEIR-shaped queries.tsv rows (written by nx_bright_prep, whose cells have every
tab, newline and carriage return replaced by a space) and writes <root>/<split>/<outname> rows `id TAB text`:
the alternate query file nx_beir_eval takes as `queries=<outname>`, which it scores as a REFEREE REPLAY and never
writes to the leaderboard (a query another model wrote is not the estate's system). Two modes: `reason` (the
rewrite alone is the query, the BRIGHT reasoning-query protocol the paper's Table 1 uses) and `concat` (the
original query, one space, the rewrite). The JSON decoder flattens \n \t \r to a space so a decoded key compares
BYTE-EQUAL to the prep organ's cell, encodes \uXXXX (surrogate pairs included) through the estate's utf8 encoder
and passes raw UTF-8 through untouched. It REFUSES (exit 1, nothing renamed into place) when any split row has no
rewrite, naming every missing id: a partial replay scores a different query set than the one it claims. Counts
print as a partition (rows = matched + missed) beside the JSON pair count, and keys reused across splits are
counted separately, because BRIGHT's two theoremqa splits share question texts, so a text-keyed set is SMALLER
than the row count by construction and the two numbers must not be read as a mismatch.
argv: <reasoned.json> <bright-root> <outname> [reason|concat] (the twelve splits are nx_beir_eval's)
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 full match, 1 refused (named), 2 usage
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_utf8.nx
imported by: nx_bright_reasoned_import_gate.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 21 | const RI_OK: i64 = 0 |
| 22 | const RI_REFUSED: i64 = 1 |
| 23 | const RI_USAGE: i64 = 2 |
| 24 | const RI_STDOUT: i64 = 1 |
| 25 | const RI_PATH_CAP: i64 = 1024 |
| 26 | const RI_BYTE: i64 = 255 |
| 27 | const RI_TAB: i64 = 9 |
| 28 | const RI_NL: i64 = 10 |
| 29 | const RI_CR: i64 = 13 |
| 30 | const RI_SPACE: i64 = 32 |
| 31 | const RI_QUOTE: i64 = 34 |
| 32 | const RI_COMMA: i64 = 44 |
| 33 | const RI_COLON: i64 = 58 |
| 34 | const RI_LBRACE: i64 = 123 |
| 35 | const RI_RBRACE: i64 = 125 |
| 36 | const RI_BACKSLASH: i64 = 92 |
| 37 | const RI_ESC_B: i64 = 98 |
| 38 | const RI_ESC_F: i64 = 102 |
| 39 | const RI_ESC_N: i64 = 110 |
| 40 | const RI_ESC_R: i64 = 114 |
| 41 | const RI_ESC_T: i64 = 116 |
| 42 | const RI_ESC_U: i64 = 117 |
| 43 | const RI_CTL_BS: i64 = 8 |
| 44 | const RI_CTL_FF: i64 = 12 |
| 45 | const RI_SUR_HI_LO: i64 = 0xD800 |
| 46 | const RI_SUR_HI_HI: i64 = 0xDBFF |
| 47 | const RI_SUR_LO_LO: i64 = 0xDC00 |
| 48 | const RI_SUR_LO_HI: i64 = 0xDFFF |
| 49 | const RI_SUR_SHIFT: i64 = 10 |
| 50 | const RI_SUR_BASE: i64 = 0x10000 |
| 51 | const RI_HEX_DIGITS: i64 = 4 |
| 52 | const RI_UTF8_MAX: i64 = 4 |
| 53 | const RI_BOM_LEN: i64 = 3 |
| 54 | const RI_BOM_0: i64 = 0xEF |
| 55 | const RI_BOM_1: i64 = 0xBB |
| 56 | const RI_BOM_2: i64 = 0xBF |
| 57 | const RI_NUM_CAP: i64 = 24 |
| 58 | const RI_CELL: i64 = 8 |
| 59 | const RI_SPLITS: i64 = 12 |
| 60 | const RI_ARENA_SLACK: i64 = 16 |
| 61 | const RI_MODE_COUNT: i64 = 0 |
| 62 | const RI_MODE_DECODE: i64 = 1 |
| 63 | const RI_NONE: i64 = 0 - 1 |
| 64 | const RI_SLASH: *u8 = "/" |
| 65 | const RI_TMP: *u8 = ".tmp" |
| 66 | const RI_F_QUERIES: *u8 = "/queries.tsv" |
| 67 | const RI_WORD_REASON: *u8 = "reason" |
| 68 | const RI_WORD_CONCAT: *u8 = "concat" |
functions
| 71 | func ri_slen(s: *u8) -> i64 { var n: i64 = 0; while ((s[n] as i64) & RI_BYTE) != 0 { n = n + 1 } return n } |
| 72 | func ri_puts(s: *u8) -> i64 { let n: i64 = ri_slen(s); if n > 0 { sys_write(RI_STDOUT, s, n) } return 0 } |
| 73 | func ri_putn(v: i64) -> i64 |
| 86 | func ri_memeq(a: *u8, b: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { if a[i] != b[i] { return 0 } i = i + 1 } return 1 } |
| 87 | func ri_streq(a: *u8, b: *u8) -> i64 { let n: i64 = ri_slen(a); if n != ri_slen(b) { return 0 } return ri_memeq(a, b, n) } |
| 89 | func ri_cat(dst: *u8, off: i64, s: *u8, cap: i64) -> i64 |
| 98 | func ri_path(dst: *u8, root: *u8, split: *u8, tail: *u8) -> i64 |
| 108 | func ri_split(i: i64) -> *u8 |
| 124 | func ri_is_ws(c: i64) -> i64 { if c == RI_SPACE { return 1 } if c == RI_TAB { return 1 } if c == RI_NL { return 1 } if c == RI_CR { return 1 } return 0 } called by 1: ri_skip_ws |
| 125 | func ri_skip_ws(raw: *u8, n: i64, at: i64) -> i64 { var i: i64 = at; while i < n { if ri_is_ws((raw[i] as i64) & RI_BYTE) == 0 { return i } i = i + 1 } return i } |
| 126 | func ri_hex(c: i64) -> i64 called by 1: ri_hex4 |
| 133 | func ri_hex4(raw: *u8, n: i64, at: i64) -> i64 |
| 147 | func ri_skip_string(raw: *u8, n: i64, at: i64) -> i64 called by 1: ri_walk |
| 159 | func ri_decode_string(raw: *u8, n: i64, at: i64, out: *u8, op: *i64) -> i64 |
| 216 | func ri_walk(raw: *u8, n: i64, mode: i64, koff: *i64, klen: *i64, voff: *i64, vlen: *i64, arena: *u8, ap: *i64) -> i64 |
| 275 | func ri_find(text: *u8, tl: i64, arena: *u8, koff: *i64, klen: *i64, pairs: i64) -> i64 |
| 285 | func ri_decide(missed: i64, unreadable: i64) -> i64 |
| 290 | func ri_write_all(fd: i64, buf: *u8, n: i64) -> i64 |
| 300 | func ri_stage_split(root: *u8, split: *u8, outname: *u8, concat: i64, arena: *u8, alen: i64, koff: *i64, klen: *i64, voff: *i64, vlen: *i64, used: *i64, pairs: i64, st: *i64, tmpp: *u8, outp: *u8) -> i64 |
| 370 | func main(argc: i64, argv: *i64) -> i64 |