nx_galx_search_index.nx
buildroot/runtime/nx_galx_search_index.nx
about
nx_galx_search_index.nx -- SOVEREIGN search-index builder. For each ingested image it reads the PNG's
metadata prefix, harvests the tEXt + uncompressed-iTXt VALUES (prompt / negative_prompt / model / sampler
/ ...), lowercases + sanitizes them into one searchable line "cid<TAB>text", and APPENDS it to
knowledge/status/galx_search.tsv. The daemon's /api/list?q= substring-scans that file. FORK-PER-IMAGE so
each PNG read's mmap is reclaimed on exit; each child does ONE atomic O_APPEND write (<4096 bytes) so any
number of parallel workers can append to the same file with no merge step and no interleaving.
Only a 256KB prefix is read (PNG tEXt/iTXt sit before the big IDAT) -> ~16x less NAS I/O than full read.
Usage: nx_galx_search_index <start> <count>. license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.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
| 11 | const SI_MAGIC_100000: i64 = 100000 |
| 12 | const SI_MAGIC_1000000000: i64 = 1000000000 |
| 13 | const SI_MAGIC_2048: i64 = 2048 |
| 15 | const SI_READ: i64 = 262144 // bytes of each PNG to scan (metadata is pre-IDAT) |
| 16 | const SI_TEXTCAP: i64 = 3000 // cap searchable text so cid+tab+text+nl < 4096 (atomic append) |
| 17 | const SI_OUT: *u8 = "knowledge/status/galx_search.tsv" as *u8 |
functions
| 19 | func si_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 24 | func si_n(v: i64) -> i64 { nxi_out(v); return 0 } |
| 25 | func si_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ if s[i]>=(48 as u8){ if s[i]<=(57 as u8){ v=v*10+((s[i]-(48 as u8)) as i64) } } i=i+1 } return v } called by 1: main |
| 26 | func si_be32(b: *u8, o: i64) -> i64 { return ((b[o] as i64)<<24)|((b[o+1] as i64)<<16)|((b[o+2] as i64)<<8)|(b[o+3] as i64) } called by 1: si_extract |
| 27 | func si_low(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } if c == 9 { return 32 } if c == 10 { return 32 } if c == 13 { return 32 } return c } called by 1: si_put |
| 30 | func si_put(out: *u8, o: i64, ch: i64) -> i64 { if o < SI_TEXTCAP { out[o] = si_low(ch) as u8; return o + 1 } return o } |
| 33 | func si_extract(png: *u8, n: i64, out: *u8) -> i64 |
| 93 | func si_one(cid: *u8, path: *u8) -> i64 |
| 117 | func main(argc: i64, argv: *i64) -> i64 |