code wiki / _hdl_build / nx_kind.nx
nx_kind.nx
buildroot/runtime/_hdl_build/nx_kind.nx
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
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
structs
| none |
consts
| 28 | const KD_MAGIC_65536: i64 = 65536 |
| 29 | const KD_MAGIC_1600: i64 = 1600 |
| 30 | const KD_MAGIC_262144: i64 = 262144 |
| 31 | const KD_MAGIC_1350: i64 = 1350 |
| 32 | const KD_MAGIC_1300: i64 = 1300 |
| 33 | const KD_MAGIC_1430: i64 = 1430 |
| 34 | const KD_MAGIC_1100: i64 = 1100 |
| 36 | const KD_CAP: i64 = 33554432 |
| 37 | const KD_SCAP: i64 = 262144 |
| 38 | const KD_MAXTRI: i64 = 400000 |
| 39 | const KD_MAXBAND: i64 = 256 |
| 40 | const KD_BINS: i64 = 128 |
| 41 | const KD_GAP: i64 = 2 |
| 42 | const KD_MAXTAX: i64 = 32 |
| 43 | const KD_MAXRULE: i64 = 256 |
| 44 | const KD_NAMECAP: i64 = 32 |
| 45 | const KD_M8388607: i64 = 8388607 |
| 46 | const KD_M8388608: i64 = 8388608 |
| 47 | const KD_BIG: i64 = 4611686018427387903 |
| 48 | const KD_TAB: i64 = 9 |
| 49 | const KD_NL: i64 = 10 |
functions
| 51 | func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 52 | func 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 } |
| 53 | func 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 } |
| 54 | func 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 |
| 55 | func kd_f32q(w: i64) -> i64 called by 1: kd_load |
| 69 | func kd_refuse(reason: *u8) -> i64 { hw("KIND REFUSED: " as *u8); hw(reason); hw("\n" as *u8); return 0 } |
| 71 | func kd_load(path: *u8, vx: *i64) -> i64 |
| 100 | func kd_readfile(path: *u8, buf: *u8, cap: i64) -> i64 |
| 118 | func kd_clusters(occ: *i64) -> i64 called by 1: kd_sig |
| 135 | func kd_width(occ: *i64) -> i64 called by 1: kd_sig |
| 150 | func kd_sig(vx: *i64, nt: i64, nband: i64, sa: i64, ca: i64, wlo: i64, whi: i64) -> i64 |
| 245 | func kd_eol(b: *u8, n: i64, i: i64) -> i64 called by 1: kd_run |
| 251 | func kd_cols(b: *u8, ls: i64, le: i64, col: *i64, maxc: i64) -> i64 called by 1: kd_run |
| 271 | func kd_int(b: *u8, a: i64, e: i64) -> i64 called by 1: kd_run |
| 284 | func kd_same(b: *u8, a: i64, e: i64, lit: *u8) -> i64 called by 1: kd_run |
| 292 | func kd_streq(b: *u8, a1: i64, e1: i64, a2: i64, e2: i64) -> i64 called by 1: kd_run |
| 299 | func kd_run(meshp: *u8, sb: *u8, sn: i64, nband: i64) -> i64 |
| 420 | func kd_encf(v: i64, scale: i64) -> i64 called by 1: kd_tri |
| 435 | func 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 } |
| 436 | func 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 |
| 444 | func kd_box(b: *u8, off: i64, xlo: i64, xhi: i64, ylo: i64, yhi: i64, zlo: i64, zhi: i64) -> i64 |
| 460 | func kd_hdr(b: *u8, ntri: i64) -> i64 |
| 470 | func kd_save(path: *u8, b: *u8, ntri: i64) -> i64 |
| 479 | func kd_fix_blob(path: *u8) -> i64 |
| 485 | func kd_fix_human(path: *u8) -> i64 |
| 500 | func kd_fix_quad(path: *u8) -> i64 |
| 513 | func kd_wr(path: *u8, s: *u8) -> i64 |
| 522 | func kd_selftest() -> i64 |
| 543 | func main(argc: i64, argv: *i64) -> i64 |