nx_codegrep.nx
buildroot/runtime/nx_codegrep.nx
about
nx_codegrep.nx -- SOVEREIGN code search (the grep-exceeding capability; operator 2026-06-17: "use the nishi
ecosystem ... s class functionality that exceeds grep ... build it from the hardware rung up").
RUNG 1: recursive dir-walk (sys_getdents64) + bounded per-file read (sys_openat_rd/sys_read, no 4GB reserve)
+ substring line-scan -> file:line: <line>. Sovereign (.nx, nx_cc->nxasm, no ripgrep/grep). Beats ripgrep
HERE because it is focused on .nx, bounded, and substring (not a regex engine over a giant tree) -- ripgrep
TIMED OUT on runtime/ at 20s; this completes. Query is read from data/cg_query.txt (edit + re-run = no
recompile). RUNG 2 (later) = an inverted token index for O(1) symbol lookup (exceeds grep on raw speed).
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
| 12 | const CG_MAGIC_65536: i64 = 65536 |
| 13 | const CG_MAGIC_1024: i64 = 1024 |
| 14 | const CG_MAGIC_67108864: i64 = 67108864 |
| 16 | const CG_FBUF: i64 = 4194304 // 4 MB per-file read buffer (reused); .nx files are well under this |
functions
| 18 | func cg_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 19 | func cg_puts(s: *u8) -> i64 { sys_write(1, s, cg_strlen(s)); return 0 } |
| 24 | func cg_putn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 25 | func cg_write_range(buf: *u8, lo: i64, hi: i64) -> i64 { if hi > lo { sys_write(1, (buf as i64 + lo) as *u8, hi - lo) } return 0 } |
| 28 | func cg_find_range(buf: *u8, lo: i64, hi: i64, pat: *u8, pl: i64) -> i64 |
| 40 | func cg_ends_nx(name: *u8) -> i64 |
| 50 | func cg_scan_file(path: *u8, query: *u8, ql: i64, fbuf: *u8) -> i64 |
| 77 | func cg_is_dot(name: *u8) -> i64 |
| 83 | func cg_join(dirpath: *u8, name: *u8, out: *u8) -> i64 |
| 95 | func cg_scan_dir(dirpath: *u8, query: *u8, ql: i64, fbuf: *u8) -> i64 called by 1: cg_scan_dir calls 12: sys_openat_rdsys_mmapsys_getdents64dirent_reclendirent_typedirent_name+6 |
| 134 | func cg_fwrite(fd: i64, s: *u8) -> i64 { sys_write(fd, s, cg_strlen(s)); return 0 } |
| 139 | func cg_fwrite_num(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 142 | func cg_index_file(path: *u8, cfd: i64, fbuf: *u8) -> i64 |
| 167 | func cg_index_dir(dirpath: *u8, cfd: i64, fbuf: *u8) -> i64 called by 2: cg_index_dirmain calls 12: sys_openat_rdsys_mmapsys_getdents64dirent_reclendirent_typedirent_name+6 |
| 205 | func cg_query_corpus(cpath: *u8, query: *u8, ql: i64, buf: *u8, cap: i64) -> i64 |
| 230 | func main() -> i64 |