nx_swapmotion_tool_register.nx source
↩ module page · 69 lines · 5610 B
1// nx_swapmotion_tool_register.nx -- register the MOTION capability (S3 shipped) into the sovereign tool registry
2// so BOTH the synthetic human (Elara) AND the game/DnD systems can DISCOVER + eventually invoke it (operator
3// 2026-07-05: "add these capabilities as APIs ... to do what they want aka if they want to do a dance move ...
4// to show it in a video"). DISCOVERY only (the registry is what /api/tools + /mcp tools/list serve); making it
5// RUNNABLE over /mcp stays a separate fail-closed allowlist step. Idempotent readback-verified. license_tier: ORIGINAL
6// expect_exit: 0
7import "nx_tool_registry.nx"
8
9func mr_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
10func mr_putn(v: i64) -> i64 {
11 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
12 var m: i64 = v; if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
13 let d: *u8 = sys_mmap(24); var k: i64 = 0
14 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
15 // write-once: buffer HOISTED (was a per-char sys_mmap(1) inside the loop = mmap-in-loop leak-by-construction)
16 let o: *u8 = sys_mmap(24); var i: i64 = 0
17 while i < k { o[i] = d[k - 1 - i]; i = i + 1 }
18 sys_write(1, o, k)
19 return 0
20}
21func mr_reg1(name: *u8, desc: *u8, invoke: *u8, status: *u8) -> i64 {
22 let w: i64 = tool_register(name, desc, invoke, status)
23 let p: *i64 = sys_mmap(8) as *i64
24 let l: *i64 = sys_mmap(8) as *i64
25 let g: i64 = tool_get(name, p, l)
26 mr_puts(" "); mr_puts(name); mr_puts(" put-rc="); mr_putn(w); mr_puts(" readback=")
27 if g == 1 { if l[0] > 0 { mr_puts("OK len="); mr_putn(l[0]); mr_puts("\n"); return 1 } }
28 mr_puts("MISSING -- REGISTER FAILED\n")
29 return 0
30}
31
32func main() -> i64 {
33 mr_puts("=== nx_swapmotion_tool_register -- motion capability into the discovery registry ===\n")
34 var ok: i64 = 0
35 ok = ok + mr_reg1("move_library" as *u8,
36 "named-move library + parametric generator (move-as-data: wave/cheer/sway/kick/lookaround/armcircle; vocabulary grows by adding a recipe)" as *u8,
37 "organ nx_movelib: move_id_of(prompt) -> move_gen(base,id) -> move_pose_at(move,skeleton,t) interpolated keyframes" as *u8,
38 "GREEN v0 (nx_motion_video_gate; parametric, not neural -- text-to-motion MDM-class is the deep rung)" as *u8)
39 ok = ok + mr_reg1("motion_video" as *u8,
40 "build a MOVE (a dance/gesture) and SHOW it in a video: move -> FK on the rig -> render frames -> sovereign animated PNG" as *u8,
41 "organ nx_motion_video (rig_build + move_gen + rig_draw per frame + nx_apng) -> knowledge/nx_motion_<move>.png (browser-playable APNG)" as *u8,
42 "GREEN v0 (nx_motion_video_gate 4/4: valid APNG + motion + articulation + distinct moves; mannequin figure, photoreal-skin = deep rung)" as *u8)
43 ok = ok + mr_reg1("asset_variant" as *u8,
44 "reuse ONE synthetic base (person/wolf/goblin) -> MANY variants via SWAP SLOTS {species, head, ears, tail, build} -- the DnD/game bestiary diversity model" as *u8,
45 "organ nx_assetvariant: av_build(base, sp, hv, ev, tv, buildpct) fills the SDF base; renders on the production shader; feeds nx_meshgen for game meshes" as *u8,
46 "GREEN v0 (nx_assetvariant_gate 4/4: 12/12 distinct, head-slot-only swap visible; parametric geometry -- image-space neural swap = S5)" as *u8)
47 ok = ok + mr_reg1("text2motion" as *u8,
48 "TEXT-CONDITIONED motion: a sentence -> LEARNED perceptron encoder -> motion class -> generated tokens -> rig -> video (the MotionGPT headline)" as *u8,
49 "organ nx_text2motion: t2m_train (perceptron) + t2m_encode(caption) -> class -> nx_motion_neural VQ tokens -> decode -> APNG" as *u8,
50 "GREEN v0 NEURAL (nx_text2motion_gate 4/4: held-out 6/6 vs untrained 1/6 = GENERALIZES; sovereign no-LLM-load; ceiling = perceptron/BoW/bigram vs transformer/mocap)" as *u8)
51 ok = ok + mr_reg1("creature_motion" as *u8,
52 "swap + motion UNIFIED: a swapped creature (horns/ears/tail) performs a move with the slots BONE-ANCHORED (they animate with it)" as *u8,
53 "organ nx_creature_motion: creaturepose_fill(base, sk, hv, ev, tv, build) per frame -> render -> APNG" as *u8,
54 "GREEN v0 (nx_creature_motion_gate 4/4: 43 parts, slots present, bone-anchored)" as *u8)
55 ok = ok + mr_reg1("quadruped_motion" as *u8,
56 "ANIMALS move: an 18-joint QUADRUPED rig + diagonal walk gait drives the bestiary wolf -> video" as *u8,
57 "organ nx_quadruped: quad_build(sk) + quad_gait_pose(sk, t, swing) + quadpose_fill(base, sk) -> render -> APNG" as *u8,
58 "GREEN v0 (nx_wolf_walk_gate 4/4: diagonal gait proven mechanically dxFL/dxFR opposed)" as *u8)
59 ok = ok + mr_reg1("mesh_export" as *u8,
60 "export any bestiary variant as a WATERTIGHT game asset: STL (print) or OBJ+smooth-normals (Blender/Unity/Godot)" as *u8,
61 "organs nx_meshgen (surface nets -> STL) + nx_obj_export (write_obj +per-vertex normals); knowledge/synth_<v>.{stl,obj}" as *u8,
62 "GREEN v0 (nx_variant_mesh_gate 3/3 + nx_obj_export_gate 2/2: 6 variants, closed-manifold, distinct)" as *u8)
63
64 mr_puts("registered+readback "); mr_putn(ok); mr_puts(" / 7\n")
65 mr_puts("NOTE: local SSOT registry (knowledge/toolreg-). LIVE NAS registry flip + any runnable-over-/mcp\n")
66 mr_puts(" allowlist row = separate operator-gated deploy steps. NEURAL IMAGE swap (face/clothes/hair) = S5, not built.\n")
67 if ok == 7 { mr_puts("verdict=GREEN (7 synth capabilities discoverable by Elara + the game systems)\n"); sys_exit(0); return 0 }
68 mr_puts("verdict=RED\n"); sys_exit(1); return 1
69}