code wiki / (root) / nx_coach_markers_gate.nx

nx_coach_markers_gate.nx source

↩ module page · 80 lines · 4439 B

1// nx_coach_markers_gate.nx -- executed proof of the coach wire (nx_coach_markers). Synthetic NXMK marker sets 2// (types 1=dead-air 2=scene-cut 3=high-motion 4=rhythm) over a 10s clip prove the coaching summary + focus + 3// the trim-list, and that an inverted posture escalates the focus to form/safety. expect_exit: 0 4import "nx_syscalls.nx" 5import "nx_coach_markers.nx" 6 7func gp(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return sys_write(1, s, n) } 8func gn(v: i64) -> i64 { 9 let bb: *u8 = sys_mmap(28); var m: i64 = v 10 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 11 let t: *u8 = sys_mmap(28); var k: i64 = 0 12 if m == 0 { t[0] = 48 as u8; k = 1 } 13 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 14 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } 15 return sys_write(1, bb, k) 16} 17 18func main(argc: i64, argv: *i64) -> i64 { 19 var pass: i64 = 0 20 let D: i64 = 10000 // 10s clip 21 let mt: *i64 = sys_mmap(8 * 16) as *i64 22 let ms: *i64 = sys_mmap(8 * 16) as *i64 23 let me: *i64 = sys_mmap(8 * 16) as *i64 24 let out: *i64 = sys_mmap(8 * 16) as *i64 25 let ts: *i64 = sys_mmap(8 * 16) as *i64 26 let te: *i64 = sys_mmap(8 * 16) as *i64 27 28 // K1 QUIET: two dead-air segments 0-4000 & 6000-9000 (7000ms = 70% quiet -> label 0). posture upright (0). 29 mt[0] = 1; ms[0] = 0; me[0] = 4000 30 mt[1] = 1; ms[1] = 6000; me[1] = 9000 31 var f1: i64 = coach_summary(mt, ms, me, 2, D, 0, out) 32 if out[0] == 0 { if out[1] == 2 { if out[2] == 7000 { if f1 == 0 { 33 pass = pass + 1; gp("K1 quiet -> label0, deadair 2 segs 7000ms, focus TRIM(0) OK\n" as *u8) 34 } } } } 35 if out[0] != 0 { gp("K1 FAIL label=" as *u8); gn(out[0]); gp(" da=" as *u8); gn(out[1]); gp(" ms=" as *u8); gn(out[2]); gp(" focus=" as *u8); gn(f1); gp("\n" as *u8) } 36 37 // K2 TRIMLIST: the exact dead-air spans -> 2 = (0,4000),(6000,9000). 38 var nt: i64 = coach_trimlist(mt, ms, me, 2, ts, te, 16) 39 if nt == 2 { if ts[0] == 0 { if te[0] == 4000 { if ts[1] == 6000 { if te[1] == 9000 { 40 pass = pass + 1; gp("K2 trim-list 2 spans (0-4000)(6000-9000) OK\n" as *u8) 41 } } } } } 42 if nt != 2 { gp("K2 FAIL nt=" as *u8); gn(nt); gp("\n" as *u8) } 43 44 // K3 RHYTHMIC: one rhythm segment 0-3000 (30% >= 25 -> label 2). posture upright. 45 mt[0] = 4; ms[0] = 0; me[0] = 3000 46 var f3: i64 = coach_summary(mt, ms, me, 1, D, 0, out) 47 if out[0] == 2 { if out[4] == 1 { if f3 == 2 { 48 pass = pass + 1; gp("K3 rhythmic -> label2, rhythm 1 seg, focus RHYTHM(2) OK\n" as *u8) 49 } } } 50 if out[0] != 2 { gp("K3 FAIL label=" as *u8); gn(out[0]); gp(" rh=" as *u8); gn(out[4]); gp(" focus=" as *u8); gn(f3); gp("\n" as *u8) } 51 52 // K4 ACTIVE: one high-motion segment 0-5000 (50% >= 40 -> label 1). 53 mt[0] = 3; ms[0] = 0; me[0] = 5000 54 var f4: i64 = coach_summary(mt, ms, me, 1, D, 0, out) 55 if out[0] == 1 { if out[3] == 1 { if f4 == 1 { 56 pass = pass + 1; gp("K4 active -> label1, motion 1 seg, focus ENERGY(1) OK\n" as *u8) 57 } } } 58 if out[0] != 1 { gp("K4 FAIL label=" as *u8); gn(out[0]); gp(" mo=" as *u8); gn(out[3]); gp(" focus=" as *u8); gn(f4); gp("\n" as *u8) } 59 60 // K5 SCENE-HEAVY: 5 scene cuts (sd = 5*60000/10000 = 30 >= 12 -> label 3). 61 var i: i64 = 0; while i < 5 { mt[i] = 2; ms[i] = 1000 + i * 1500; me[i] = 1000 + i * 1500; i = i + 1 } 62 var f5: i64 = coach_summary(mt, ms, me, 5, D, 0, out) 63 if out[0] == 3 { if out[5] == 5 { if f5 == 3 { 64 pass = pass + 1; gp("K5 scene-heavy -> label3, 5 cuts, focus STEADY(3) OK\n" as *u8) 65 } } } 66 if out[0] != 3 { gp("K5 FAIL label=" as *u8); gn(out[0]); gp(" cuts=" as *u8); gn(out[5]); gp(" focus=" as *u8); gn(f5); gp("\n" as *u8) } 67 68 // K6 POSTURE ESCALATION: same active clip but posture INVERTED (2) -> focus overrides to FORM/SAFETY (5). 69 mt[0] = 3; ms[0] = 0; me[0] = 5000 70 var f6: i64 = coach_summary(mt, ms, me, 1, D, 2, out) 71 if out[6] == 2 { if f6 == 5 { 72 pass = pass + 1; gp("K6 inverted posture -> focus FORM/SAFETY(5) overrides content OK\n" as *u8) 73 } } 74 if f6 != 5 { gp("K6 FAIL posture=" as *u8); gn(out[6]); gp(" focus=" as *u8); gn(f6); gp("\n" as *u8) } 75 76 gp("COACH-MARKERS-GATE pass=" as *u8); gn(pass); gp("/6\n" as *u8) 77 if pass == 6 { gp("COACH-MARKERS-GATE GREEN 6/6 (summary + trim-list + focus + posture-escalation, actionable)\n" as *u8); sys_exit(0) } 78 sys_exit(1) 79 return 0 80}