code wiki / _hdl_build / nx_cap_exists.nx
nx_cap_exists.nx
buildroot/runtime/_hdl_build/nx_cap_exists.nx
about
nx_cap_exists.nx -- LIB: the Nishi builder's "does this already exist?" anti-duplicate guard (importable).
Operator: "make it not possible to build duplicates without a check ... a does this already exist capability."
The builder (and Claude) call this BEFORE authoring an organ: `cap_index(ctx)` once builds an index of the whole
organ tree (every `.nx` filename = the nx_<capability> surface, 12k+ organs, fast: getdents only, no body reads),
then `cap_guard(query) -> 1 REFUSE (a matching capability EXISTS) | 0 ALLOW (novel)`. Filename-weighted, stopword-
filtered so only DOMAIN words score. NEVER-BRICK (#26): read-only scan + in-memory index, zero writes to the tree.
API: alloc the buffers, `cap_index(...)` -> NF, then `cap_query(q,...)/cap_guard(q,...)`. license_tier: ORIGINAL
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_cap_guard_gate.nxnx_engineer_wire_sclass.nxnx_engineer_wire_sclass_gate.nx
structs
| none |
consts
| 9 | const K_MAGIC_131072: i64 = 131072 |
| 10 | const K_MAGIC_16000: i64 = 16000 |
| 11 | const K_MAGIC_1024: i64 = 1024 |
functions
| 13 | func ce_is_nc(c: i64) -> i64 { if c>=97 { if c<=122 {return 1} } if c>=65 { if c<=90 {return 1} } if c>=48 { if c<=57 {return 1} } if c==95 {return 1} return 0 } called by 1: ce_append |
| 14 | func ce_lc(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c } |
| 17 | func ce_append(src: *u8, slen: i64, name: *u8, surf: *u8, soffp: *i64) -> i64 |
| 37 | func ce_scan(dir: *u8, surf: *u8, soffp: *i64, foff: *i64, fnames: *u8, fnoff: *i64, nfp: *i64, maxf: i64, rbuf: *u8) -> i64 called by 1: cap_index calls 7: sys_openat_rdsys_mmapsys_getdents64dirent_reclendirent_namece_append+1 |
| 72 | func cap_index(surf: *u8, soffp: *i64, foff: *i64, fnames: *u8, fnoff: *i64, rbuf: *u8) -> i64 |
| 80 | func ce_seg_has(surf: *u8, a: i64, b: i64, q: *u8, ql: i64) -> i64 |
| 85 | func ce_score(surf: *u8, foff: *i64, i: i64, qwords: *u8, qoff: *i64, nq: i64, fnames: *u8, fnoff: *i64) -> i64 |
| 95 | func ce_wstreq(qw: *u8, a: i64, l: i64, lit: *u8) -> i64 { var i: i64=0; while i<l { if lit[i]==(0 as u8) {return 0} if qw[a+i]!=lit[i] {return 0} i=i+1 } if lit[l]!=(0 as u8) {return 0} return 1 } called by 1: ce_is_stop |
| 96 | func ce_is_stop(qw: *u8, a: i64, l: i64) -> i64 |
| 105 | func ce_tok(query: *u8, qwords: *u8, qoff: *i64) -> i64 |
| 117 | func cap_query(query: *u8, surf: *u8, foff: *i64, nf: i64, fnames: *u8, fnoff: *i64, scorep: *i64) -> i64 |
| 126 | func cap_guard(query: *u8, surf: *u8, foff: *i64, nf: i64, fnames: *u8, fnoff: *i64, out_best: *i64) -> i64 |