nx_sqlite_rows.nx
buildroot/runtime/nx_sqlite_rows.nx
about
nx_sqlite_rows.nx -- SOVEREIGN SQLite ROW READER (rung 2) + seg-store PLANE LANDER.
RUNG 1 (_hdl_build/_sqlite_read_authored.nx) walks the b-tree and decodes sqlite_master, and declares
its own honest limit: "local payload only -- overflow pages not followed yet ... full row/column reads
= rung 2". THIS IS RUNG 2: full row+column reads WITH the overflow-page chain, so any row of any size
comes out byte-exact.
WHY (2026-07-23, F916 re-aimed by the F1010 SOTA reframe): the legacy Elder platform's knowledge lives
in SQLite (content.db 390MB: outfits/poses/locations rule mesh + 200k-row batch_history). It is NOT
ported as a runtime rule engine (measured: prompt words cap at ~85% semantics / 50% geometry / 0%
identity) -- it is MINED AS A DATASET: an L1 semantic prior + a learning corpus + an eval set. This
organ is the sovereign read path for that mine. READ-ONLY: it never writes to the SQLite file.
VERBS
tables <db> list tables: name, rootpage, rows
rows <db> <table> [max] dump rows TSV-ish (NULL=\N, tab/nl/backslash escaped)
plane <db> <table> <store-prefix> land rows into a seg-store plane, ONE segment per table:
key <table>:<rowid> -> canonical NXR1 record (absent field ==
SQL NULL, so NULL survives losslessly), plus <table>:meta
selftest gate, verdict=GREEN|RED
ENVELOPE (declared, never silent): row payload cap 8MiB · <=256 cols · REAL rendered to 3 decimals
(out-of-range -> x<hex>, never a wrong number) · BLOBs emitted raw (embedded NUL truncates a plane
value -- text/int tables are the target; blob-safe values = a later rung) · a table lands in ONE
segment (writer cap 128MiB).
NOTE (DRY): sqr_rec_field duplicates mv_rec_field's NXR1 walk (2nd copy; at a 3rd, extract to a lib).
license_tier: ORIGINAL Read-only, no hw writes (Rule 26).
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_canon_cid.nxnx_seg_store.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
| 31 | const SQR_MAGIC_2047: i64 = 2047 |
| 32 | const SQR_MAGIC_4503599627370495: i64 = 4503599627370495 |
| 33 | const SQR_MAGIC_4503599627370496: i64 = 4503599627370496 |
| 34 | const SQR_MAGIC_1075: i64 = 1075 |
| 35 | const SQR_MAGIC_1048576: i64 = 1048576 |
| 36 | const SQR_MAGIC_65000: i64 = 65000 |
| 37 | const SQR_MAGIC_21329: i64 = 21329 |
| 38 | const SQR_MAGIC_65536: i64 = 65536 |
| 39 | const SQR_MAGIC_1024: i64 = 1024 |
| 40 | const SQR_MAGIC_4096: i64 = 4096 |
| 41 | const SQR_MAGIC_20000: i64 = 20000 |
| 43 | const SQR_MAXCOL: i64 = 256 |
| 44 | const SQR_ROWCAP: i64 = 8388608 |
| 45 | const SQR_ARENA: i64 = 8388608 |
| 46 | const SQR_NAMES: i64 = 65536 |
| 47 | const SQR_WCAP: i64 = 134217728 |
| 48 | const SQR_LINE: i64 = 8388608 |
| 51 | const CX_MODE: i64 = 0 |
| 52 | const CX_ROWS: i64 = 1 |
| 53 | const CX_MAX: i64 = 2 |
| 54 | const CX_DB: i64 = 3 |
| 55 | const CX_PS: i64 = 4 |
| 56 | const CX_USE: i64 = 5 |
| 57 | const CX_PAY: i64 = 6 |
| 58 | const CX_OFFS: i64 = 7 |
| 59 | const CX_LENS: i64 = 8 |
| 60 | const CX_TYPS: i64 = 9 |
| 61 | const CX_NCOL: i64 = 10 |
| 62 | const CX_NAMB: i64 = 11 |
| 63 | const CX_NAMO: i64 = 12 |
| 64 | const CX_W: i64 = 13 |
| 65 | const CX_TAB: i64 = 14 |
| 66 | const CX_KEYS: i64 = 15 |
| 67 | const CX_VALS: i64 = 16 |
| 68 | const CX_AREN: i64 = 17 |
| 69 | const CX_REC: i64 = 18 |
| 70 | const CX_KBUF: i64 = 19 |
| 71 | const CX_ERR: i64 = 20 |
| 72 | const CX_LINE: i64 = 21 |
| 73 | const CX_MINR: i64 = 22 |
| 74 | const CX_MAXR: i64 = 23 |
| 75 | const CX_ALIA: i64 = 24 |
| 77 | const CX_CAPID: i64 = 25 |
| 78 | const CX_CAPCOL: i64 = 26 |
| 79 | const CX_CAPP: i64 = 27 |
| 80 | const CX_CAPL: i64 = 28 |
| 81 | const CX_CAPT: i64 = 29 |
| 82 | const CX_CAPV: i64 = 30 |
| 85 | const CX_PFX: i64 = 31 |
| 86 | const CX_SEGN: i64 = 32 |
| 93 | const CX_SKIP: i64 = 33 |
| 94 | const CX_SEEN: i64 = 34 |
| 95 | const SQR_FLUSH: i64 = 100663296 // flush a batch past 96MiB (writer cap is 128MiB) |
functions
| 97 | func sqr_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 98 | func sqr_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 99 | func sqr_cat(d: *u8, o: i64, s: *u8) -> i64 { var p: i64 = o; var i: i64 = 0; while s[i] != (0 as u8) { d[p] = s[i]; p = p + 1; i = i + 1 } return p } |
| 100 | func sqr_ch(d: *u8, o: i64, c: i64) -> i64 { d[o] = c as u8; return o + 1 } |
| 101 | func sqr_eq(a: *u8, b: *u8) -> i64 |
| 110 | func sqr_udec(d: *u8, o: i64, v: i64) -> i64 |
| 126 | func sqr_sdec(d: *u8, o: i64, v: i64) -> i64 |
| 130 | func sqr_hex(d: *u8, o: i64, v: i64) -> i64 called by 1: sqr_emit_f64 |
| 144 | func sqr_atoi(s: *u8) -> i64 called by 1: main |
| 154 | func sqr_be16(p: *u8, o: i64) -> i64 { let a: i64 = p[o]; let b: i64 = p[o + 1]; return (a << 8) | b } |
| 155 | func sqr_be32(p: *u8, o: i64) -> i64 |
| 159 | func sqr_varint(p: *u8, o: i64, lenout: *i64) -> i64 |
| 173 | func sqr_stsize(st: i64) -> i64 called by 1: sqr_decode |
| 192 | func sqr_sint(p: *u8, o: i64, n: i64) -> i64 |
| 206 | func sqr_page(db: *u8, ps: i64, pgno: i64) -> *u8 { let base: i64 = db as i64; return (base + (pgno - 1) * ps) as *u8 } |
| 209 | func sqr_f64_milli(bits: i64, okbox: *i64) -> i64 called by 1: sqr_emit_f64 |
| 232 | func sqr_emit_f64(d: *u8, o: i64, bits: i64) -> i64 |
| 250 | func sqr_assemble(db: *u8, ps: i64, usable: i64, pg: *u8, coff: i64, out: *u8, cap: i64, ridbox: *i64) -> i64 called by 3: sqr_master_findsqr_master_listsqr_walk calls 5: sys_mmapsqr_varintsys_munmapsqr_be32sqr_page |
| 293 | func sqr_decode(pay: *u8, plen: i64, offs: *i64, lens: *i64, typs: *i64) -> i64 |
| 321 | func sqr_master_find(db: *u8, ps: i64, usable: i64, pgno: i64, want: *u8, sqlbuf: *u8, sqllen: *i64) -> i64 called by 3: sqr_master_findsqr_selftestmain calls 10: sqr_pagesqr_be16sqr_master_findsqr_be32sys_mmapsqr_assemble+4 |
| 396 | func sqr_master_list(db: *u8, ps: i64, usable: i64, pgno: i64, names: *u8, npos: *i64, noff: *i64, roots: *i64, cnt: *i64) -> i64 called by 2: sqr_master_listmain calls 9: sqr_pagesqr_be16sqr_master_listsqr_be32sys_mmapsqr_assemble+3 |
| 456 | func sqr_upch(c: i64) -> i64 { if c >= 97 { if c <= 122 { return c - 32 } } return c } called by 1: sqr_hasword |
| 458 | func sqr_hasword(sql: *u8, s: i64, e: i64, w: *u8) -> i64 |
| 470 | func sqr_isname(c: i64) -> i64 called by 1: sqr_parse_cols |
| 478 | func sqr_parse_cols(sql: *u8, sqllen: i64, names: *u8, noff: *i64, aliasbox: *i64) -> i64 |
| 558 | func sqr_r32(p: *u8, o: i64) -> i64 |
| 562 | func sqr_rec_field(rec: *u8, reclen: i64, key: *u8, outp: *i64, outl: *i64) -> i64 |
| 586 | func sqr_rec_dump(rec: *u8, reclen: i64) -> i64 |
| 617 | func sqr_row(ctx: *i64, rowid: i64, nrec: i64) -> i64 |
| 746 | func sqr_walk(ctx: *i64, pgno: i64) -> i64 called by 3: sqr_walksqr_selftestmain calls 9: sqr_pagesqr_be16sqr_walksqr_be32sys_mmapsqr_assemble+3 |
| 803 | func sqr_open(path: *u8, dbbox: *i64, psbox: *i64, usebox: *i64) -> i64 |
| 816 | func sqr_ctx_new() -> *i64 |
| 838 | func sqr_tooth(name: *u8, ok: i64, pass: *i64) -> i64 |
| 843 | func sqr_selftest() -> i64 |
| 986 | func main(argc: i64, argv: *i64) -> i64 |