code wiki / (root) / nx_bright_reasoned_import.nx

nx_bright_reasoned_import.nx

buildroot/runtime/nx_bright_reasoned_import.nx

22048 B450 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind tooltopic bright
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_utf8.nx nx_bright_reasoned_import.nx nx_bright_reasoned_import_gate.nx

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

main ri_puts ri_slen sys_write ri_streq ri_slen ↻ ri_memeq 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 ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close ri_walk ri_skip_ws ri_is_ws ri_skip_string ri_decode_string sys_mmap ↻ ri_hex4 ri_hex utf8_encode_one ri_putn sys_mmap ↻

structs

none

consts

21const RI_OK: i64 = 0
22const RI_REFUSED: i64 = 1
23const RI_USAGE: i64 = 2
24const RI_STDOUT: i64 = 1
25const RI_PATH_CAP: i64 = 1024
26const RI_BYTE: i64 = 255
27const RI_TAB: i64 = 9
28const RI_NL: i64 = 10
29const RI_CR: i64 = 13
30const RI_SPACE: i64 = 32
31const RI_QUOTE: i64 = 34
32const RI_COMMA: i64 = 44
33const RI_COLON: i64 = 58
34const RI_LBRACE: i64 = 123
35const RI_RBRACE: i64 = 125
36const RI_BACKSLASH: i64 = 92
37const RI_ESC_B: i64 = 98
38const RI_ESC_F: i64 = 102
39const RI_ESC_N: i64 = 110
40const RI_ESC_R: i64 = 114
41const RI_ESC_T: i64 = 116
42const RI_ESC_U: i64 = 117
43const RI_CTL_BS: i64 = 8
44const RI_CTL_FF: i64 = 12
45const RI_SUR_HI_LO: i64 = 0xD800
46const RI_SUR_HI_HI: i64 = 0xDBFF
47const RI_SUR_LO_LO: i64 = 0xDC00
48const RI_SUR_LO_HI: i64 = 0xDFFF
49const RI_SUR_SHIFT: i64 = 10
50const RI_SUR_BASE: i64 = 0x10000
51const RI_HEX_DIGITS: i64 = 4
52const RI_UTF8_MAX: i64 = 4
53const RI_BOM_LEN: i64 = 3
54const RI_BOM_0: i64 = 0xEF
55const RI_BOM_1: i64 = 0xBB
56const RI_BOM_2: i64 = 0xBF
57const RI_NUM_CAP: i64 = 24
58const RI_CELL: i64 = 8
59const RI_SPLITS: i64 = 12
60const RI_ARENA_SLACK: i64 = 16
61const RI_MODE_COUNT: i64 = 0
62const RI_MODE_DECODE: i64 = 1
63const RI_NONE: i64 = 0 - 1
64const RI_SLASH: *u8 = "/"
65const RI_TMP: *u8 = ".tmp"
66const RI_F_QUERIES: *u8 = "/queries.tsv"
67const RI_WORD_REASON: *u8 = "reason"
68const RI_WORD_CONCAT: *u8 = "concat"

functions

71func ri_slen(s: *u8) -> i64 { var n: i64 = 0; while ((s[n] as i64) & RI_BYTE) != 0 { n = n + 1 } return n }
72func ri_puts(s: *u8) -> i64 { let n: i64 = ri_slen(s); if n > 0 { sys_write(RI_STDOUT, s, n) } return 0 }
called by 2: ri_stage_splitmain calls 2: ri_slensys_write
73func ri_putn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
86func 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 }
87func 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) }
called by 2: mainmain calls 2: ri_slenri_memeq
89func ri_cat(dst: *u8, off: i64, s: *u8, cap: i64) -> i64
called by 2: ri_pathri_stage_split calls 1: ri_slen
98func ri_path(dst: *u8, root: *u8, split: *u8, tail: *u8) -> i64
called by 1: ri_stage_split calls 1: ri_cat
108func ri_split(i: i64) -> *u8
called by 2: mainmain
124func 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
125func 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 }
called by 1: ri_walk calls 1: ri_is_ws
126func ri_hex(c: i64) -> i64
called by 1: ri_hex4
133func ri_hex4(raw: *u8, n: i64, at: i64) -> i64
called by 1: ri_decode_string calls 1: ri_hex
147func ri_skip_string(raw: *u8, n: i64, at: i64) -> i64
called by 1: ri_walk
159func ri_decode_string(raw: *u8, n: i64, at: i64, out: *u8, op: *i64) -> i64
216func ri_walk(raw: *u8, n: i64, mode: i64, koff: *i64, klen: *i64, voff: *i64, vlen: *i64, arena: *u8, ap: *i64) -> i64
275func ri_find(text: *u8, tl: i64, arena: *u8, koff: *i64, klen: *i64, pairs: i64) -> i64
called by 2: ri_stage_splitmain calls 1: ri_memeq
285func ri_decide(missed: i64, unreadable: i64) -> i64
called by 2: mainmain
290func ri_write_all(fd: i64, buf: *u8, n: i64) -> i64
called by 1: ri_stage_split calls 1: sys_write
300func 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
370func main(argc: i64, argv: *i64) -> i64