code wiki / _hdl_build / nx_cap_exists.nx

nx_cap_exists.nx

buildroot/runtime/_hdl_build/nx_cap_exists.nx

7394 B132 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic cap
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_cap_exists.nx nx_cap_guard_gate.nx nx_engineer_wire_sclass.nx nx_engineer_wire_sclass_gate.nx

imports: nx_syscalls.nx

imported by: nx_cap_guard_gate.nxnx_engineer_wire_sclass.nxnx_engineer_wire_sclass_gate.nx

structs

none

consts

9const K_MAGIC_131072: i64 = 131072
10const K_MAGIC_16000: i64 = 16000
11const K_MAGIC_1024: i64 = 1024

functions

13func 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
14func ce_lc(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c }
17func ce_append(src: *u8, slen: i64, name: *u8, surf: *u8, soffp: *i64) -> i64
called by 1: ce_scan calls 2: ce_lcce_is_nc
37func ce_scan(dir: *u8, surf: *u8, soffp: *i64, foff: *i64, fnames: *u8, fnoff: *i64, nfp: *i64, maxf: i64, rbuf: *u8) -> i64
72func cap_index(surf: *u8, soffp: *i64, foff: *i64, fnames: *u8, fnoff: *i64, rbuf: *u8) -> i64
called by 2: mainmain calls 2: sys_mmapce_scan
80func ce_seg_has(surf: *u8, a: i64, b: i64, q: *u8, ql: i64) -> i64
called by 1: ce_score calls 1: ce_lc
85func ce_score(surf: *u8, foff: *i64, i: i64, qwords: *u8, qoff: *i64, nq: i64, fnames: *u8, fnoff: *i64) -> i64
called by 1: cap_query calls 1: ce_seg_has
95func 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
96func ce_is_stop(qw: *u8, a: i64, l: i64) -> i64
called by 1: ce_tok calls 1: ce_wstreq
105func ce_tok(query: *u8, qwords: *u8, qoff: *i64) -> i64
called by 1: cap_query calls 2: ce_is_stopce_lc
117func cap_query(query: *u8, surf: *u8, foff: *i64, nf: i64, fnames: *u8, fnoff: *i64, scorep: *i64) -> i64
126func cap_guard(query: *u8, surf: *u8, foff: *i64, nf: i64, fnames: *u8, fnoff: *i64, out_best: *i64) -> i64