code wiki / (root) / nx_sqlite_rows.nx

nx_sqlite_rows.nx

buildroot/runtime/nx_sqlite_rows.nx

46181 B1112 linesdepth 6pulls 7 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_canon_cid.nx nx_seg_store.nx nx_sqlite_rows.nx

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

main sqr_puts sys_write sqr_eq sqr_selftest sys_mmap sys_unlinkat sqr_cat sqr_udec sqr_open sys_mmap ↻ sys_map_file sys_openat_rd sys_lseek sys_close sqr_be16 sqr_tooth sqr_puts ↻ sqr_puts ↻ sqr_master_find sqr_page sqr_be16 ↻ sqr_master_find ↻ sqr_be32 sys_mmap ↻ sqr_assemble sys_mmap ↻ sqr_varint sys_munmap sqr_be32 ↻ sqr_page ↻ sqr_decode sys_mmap ↻ sqr_varint ↻ sqr_stsize sys_munmap ↻ sqr_len sqr_sint sys_munmap ↻ sqr_ctx_new

structs

none

consts

31const SQR_MAGIC_2047: i64 = 2047
32const SQR_MAGIC_4503599627370495: i64 = 4503599627370495
33const SQR_MAGIC_4503599627370496: i64 = 4503599627370496
34const SQR_MAGIC_1075: i64 = 1075
35const SQR_MAGIC_1048576: i64 = 1048576
36const SQR_MAGIC_65000: i64 = 65000
37const SQR_MAGIC_21329: i64 = 21329
38const SQR_MAGIC_65536: i64 = 65536
39const SQR_MAGIC_1024: i64 = 1024
40const SQR_MAGIC_4096: i64 = 4096
41const SQR_MAGIC_20000: i64 = 20000
43const SQR_MAXCOL: i64 = 256
44const SQR_ROWCAP: i64 = 8388608
45const SQR_ARENA: i64 = 8388608
46const SQR_NAMES: i64 = 65536
47const SQR_WCAP: i64 = 134217728
48const SQR_LINE: i64 = 8388608
51const CX_MODE: i64 = 0
52const CX_ROWS: i64 = 1
53const CX_MAX: i64 = 2
54const CX_DB: i64 = 3
55const CX_PS: i64 = 4
56const CX_USE: i64 = 5
57const CX_PAY: i64 = 6
58const CX_OFFS: i64 = 7
59const CX_LENS: i64 = 8
60const CX_TYPS: i64 = 9
61const CX_NCOL: i64 = 10
62const CX_NAMB: i64 = 11
63const CX_NAMO: i64 = 12
64const CX_W: i64 = 13
65const CX_TAB: i64 = 14
66const CX_KEYS: i64 = 15
67const CX_VALS: i64 = 16
68const CX_AREN: i64 = 17
69const CX_REC: i64 = 18
70const CX_KBUF: i64 = 19
71const CX_ERR: i64 = 20
72const CX_LINE: i64 = 21
73const CX_MINR: i64 = 22
74const CX_MAXR: i64 = 23
75const CX_ALIA: i64 = 24
77const CX_CAPID: i64 = 25
78const CX_CAPCOL: i64 = 26
79const CX_CAPP: i64 = 27
80const CX_CAPL: i64 = 28
81const CX_CAPT: i64 = 29
82const CX_CAPV: i64 = 30
85const CX_PFX: i64 = 31
86const CX_SEGN: i64 = 32
93const CX_SKIP: i64 = 33
94const CX_SEEN: i64 = 34
95const SQR_FLUSH: i64 = 100663296 // flush a batch past 96MiB (writer cap is 128MiB)

functions

97func 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 }
98func sqr_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
99func 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 }
100func sqr_ch(d: *u8, o: i64, c: i64) -> i64 { d[o] = c as u8; return o + 1 }
101func sqr_eq(a: *u8, b: *u8) -> i64
called by 2: sqr_selftestmain
110func sqr_udec(d: *u8, o: i64, v: i64) -> i64
126func sqr_sdec(d: *u8, o: i64, v: i64) -> i64
called by 1: sqr_row calls 1: sqr_udec
130func sqr_hex(d: *u8, o: i64, v: i64) -> i64
called by 1: sqr_emit_f64
144func sqr_atoi(s: *u8) -> i64
called by 1: main
154func sqr_be16(p: *u8, o: i64) -> i64 { let a: i64 = p[o]; let b: i64 = p[o + 1]; return (a << 8) | b }
155func sqr_be32(p: *u8, o: i64) -> i64
159func sqr_varint(p: *u8, o: i64, lenout: *i64) -> i64
173func sqr_stsize(st: i64) -> i64
called by 1: sqr_decode
192func sqr_sint(p: *u8, o: i64, n: i64) -> i64
206func sqr_page(db: *u8, ps: i64, pgno: i64) -> *u8 { let base: i64 = db as i64; return (base + (pgno - 1) * ps) as *u8 }
209func sqr_f64_milli(bits: i64, okbox: *i64) -> i64
called by 1: sqr_emit_f64
232func sqr_emit_f64(d: *u8, o: i64, bits: i64) -> i64
250func sqr_assemble(db: *u8, ps: i64, usable: i64, pg: *u8, coff: i64, out: *u8, cap: i64, ridbox: *i64) -> i64
293func sqr_decode(pay: *u8, plen: i64, offs: *i64, lens: *i64, typs: *i64) -> i64
321func sqr_master_find(db: *u8, ps: i64, usable: i64, pgno: i64, want: *u8, sqlbuf: *u8, sqllen: *i64) -> i64
396func sqr_master_list(db: *u8, ps: i64, usable: i64, pgno: i64, names: *u8, npos: *i64, noff: *i64, roots: *i64, cnt: *i64) -> i64
456func sqr_upch(c: i64) -> i64 { if c >= 97 { if c <= 122 { return c - 32 } } return c }
called by 1: sqr_hasword
458func sqr_hasword(sql: *u8, s: i64, e: i64, w: *u8) -> i64
called by 1: sqr_parse_cols calls 2: sqr_lensqr_upch
470func sqr_isname(c: i64) -> i64
called by 1: sqr_parse_cols
478func sqr_parse_cols(sql: *u8, sqllen: i64, names: *u8, noff: *i64, aliasbox: *i64) -> i64
558func sqr_r32(p: *u8, o: i64) -> i64
562func sqr_rec_field(rec: *u8, reclen: i64, key: *u8, outp: *i64, outl: *i64) -> i64
called by 1: sqr_selftest calls 2: sqr_lensqr_r32
586func sqr_rec_dump(rec: *u8, reclen: i64) -> i64
617func sqr_row(ctx: *i64, rowid: i64, nrec: i64) -> i64
746func sqr_walk(ctx: *i64, pgno: i64) -> i64
803func sqr_open(path: *u8, dbbox: *i64, psbox: *i64, usebox: *i64) -> i64
816func sqr_ctx_new() -> *i64
called by 2: sqr_selftestmain calls 1: sys_mmap
838func sqr_tooth(name: *u8, ok: i64, pass: *i64) -> i64
called by 1: sqr_selftest calls 1: sqr_puts
843func sqr_selftest() -> i64
986func main(argc: i64, argv: *i64) -> i64