code wiki / _hdl_build / nx_kind.nx

nx_kind.nx

buildroot/runtime/_hdl_build/nx_kind.nx

25392 B586 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_kind.nx -- L0 OF THE SEMANTIC LADDER, OMNI EDITION (debts 1785954089 + 1785955711; operator 2026-08-05: "animal, human, humanoid, real, fantasy, natural object, mechanical -- whatever fits the ontological goal"). Successor to nx_bodyparts v1, which COMPILED IN "humanoid" and could therefore only ever recognise one species -- the exact magic-number/spec-as-data violation the estate forbids. A KIND IS A ROW, NOT A FUNCTION. Schemas are predicates over a mesh's structural signature; the organ evaluates a mesh against EVERY registered kind and reports the best match plus WHY each other failed. Adding "quadruped" or "fastener" is an append, never a recompile. SIGNATURE (rig-free, works on any mesh soup): slice along the declared stack axis into bands; in each band build a histogram over the declared cluster axis; count occupied runs (clusters) and the span width. Triangle SPANS are rasterised, not vertices (a coarse box must occupy every band it crosses -- a refusal from an empty measurement is not a refusal from a measurement). SCHEMA ROWS (plane knowledge/store/kind-, tab-separated, key-first; last-wins by convention): <kind> stack <axis 0=x 1=y 2=z> <cluster-axis> -- declares the frame <kind> band <lo> <hi> <minclust> <maxclust> <label> -- lo/hi are per-mille of extent <kind> narrow <lo> <hi> <frac-permil-of-max> <label> -- a waist/neck: a width MINIMUM Unknown verbs are IGNORED ADDITIVELY so new predicate kinds (radial-symmetry, periodicity, genus) can be seeded before this organ learns to test them. nx_kind <mesh.nxmesh> [bands] (schemas from the plane) nx_kind schema <file> <mesh.nxmesh> [bands] (schemas from a file -- offline/selftest) nx_kind selftest license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_store_seed_lib.nx nx_kind.nx

imports: nx_syscalls.nxnx_store_seed_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main kd_selftest kd_fix_blob sys_mmap kd_hdr kd_w32 kd_box kd_tri kd_w32 ↻ kd_encf kd_save kd_w32 ↻ sys_openat_wr sys_write sys_close kd_fix_human sys_mmap ↻ kd_box ↻ kd_hdr ↻ kd_save ↻ kd_fix_quad sys_mmap ↻ kd_box ↻ kd_hdr ↻ kd_save ↻ kd_wr sys_openat_wr ↻ sys_write ↻ sys_close ↻ sys_mmap ↻ kd_readfile sys_openat_rd sys_read sys_close ↻ hw sys_write ↻ kd_run sys_mmap ↻ kd_load sys_openat_rd ↻

structs

none

consts

28const KD_MAGIC_65536: i64 = 65536
29const KD_MAGIC_1600: i64 = 1600
30const KD_MAGIC_262144: i64 = 262144
31const KD_MAGIC_1350: i64 = 1350
32const KD_MAGIC_1300: i64 = 1300
33const KD_MAGIC_1430: i64 = 1430
34const KD_MAGIC_1100: i64 = 1100
36const KD_CAP: i64 = 33554432
37const KD_SCAP: i64 = 262144
38const KD_MAXTRI: i64 = 400000
39const KD_MAXBAND: i64 = 256
40const KD_BINS: i64 = 128
41const KD_GAP: i64 = 2
42const KD_MAXTAX: i64 = 32
43const KD_MAXRULE: i64 = 256
44const KD_NAMECAP: i64 = 32
45const KD_M8388607: i64 = 8388607
46const KD_M8388608: i64 = 8388608
47const KD_BIG: i64 = 4611686018427387903
48const KD_TAB: i64 = 9
49const KD_NL: i64 = 10

functions

51func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
52func pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 }
called by 2: kd_runkd_selftest calls 2: sys_mmapsys_write
53func kd_pr(b: *u8, a: i64, e: i64) -> i64 { if e > a { sys_write(1, ((b as i64)+a) as *u8, e-a) } return 0 }
called by 1: kd_run calls 1: sys_write
54func kd_u32(b: *u8, o: i64) -> i64 { return (b[o] as i64) + ((b[o+1] as i64)<<8) + ((b[o+2] as i64)<<16) + ((b[o+3] as i64)<<24) }
called by 1: kd_load
55func kd_f32q(w: i64) -> i64
called by 1: kd_load
69func kd_refuse(reason: *u8) -> i64 { hw("KIND REFUSED: " as *u8); hw(reason); hw("\n" as *u8); return 0 }
called by 1: kd_run calls 1: hw
71func kd_load(path: *u8, vx: *i64) -> i64
100func kd_readfile(path: *u8, buf: *u8, cap: i64) -> i64
118func kd_clusters(occ: *i64) -> i64
called by 1: kd_sig
135func kd_width(occ: *i64) -> i64
called by 1: kd_sig
150func kd_sig(vx: *i64, nt: i64, nband: i64, sa: i64, ca: i64, wlo: i64, whi: i64) -> i64
called by 1: kd_run calls 3: sys_mmapkd_clusterskd_width
245func kd_eol(b: *u8, n: i64, i: i64) -> i64
called by 1: kd_run
251func kd_cols(b: *u8, ls: i64, le: i64, col: *i64, maxc: i64) -> i64
called by 1: kd_run
271func kd_int(b: *u8, a: i64, e: i64) -> i64
called by 1: kd_run
284func kd_same(b: *u8, a: i64, e: i64, lit: *u8) -> i64
called by 1: kd_run
292func kd_streq(b: *u8, a1: i64, e1: i64, a2: i64, e2: i64) -> i64
called by 1: kd_run
299func kd_run(meshp: *u8, sb: *u8, sn: i64, nband: i64) -> i64
420func kd_encf(v: i64, scale: i64) -> i64
called by 1: kd_tri
435func kd_w32(b: *u8, o: i64, v: i64) -> i64 { b[o]=(v&255) as u8; b[o+1]=((v>>8)&255) as u8; b[o+2]=((v>>16)&255) as u8; b[o+3]=((v>>24)&255) as u8; return 0 }
called by 3: kd_trikd_hdrkd_save
436func kd_tri(b: *u8, off: i64, x0: i64, y0: i64, z0: i64, x1: i64, y1: i64, z1: i64, x2: i64, y2: i64, z2: i64) -> i64
called by 1: kd_box calls 2: kd_w32kd_encf
444func kd_box(b: *u8, off: i64, xlo: i64, xhi: i64, ylo: i64, yhi: i64, zlo: i64, zhi: i64) -> i64
460func kd_hdr(b: *u8, ntri: i64) -> i64
470func kd_save(path: *u8, b: *u8, ntri: i64) -> i64
479func kd_fix_blob(path: *u8) -> i64
485func kd_fix_human(path: *u8) -> i64
500func kd_fix_quad(path: *u8) -> i64
513func kd_wr(path: *u8, s: *u8) -> i64
522func kd_selftest() -> i64
543func main(argc: i64, argv: *i64) -> i64