code wiki / _hdl_build / nx_yt_nsolve_gate.nx
nx_yt_nsolve_gate.nx source
↩ module page · 72 lines · 4964 B
1import "nx_gate_gn.nx"
2import "nx_gate_base.nx"
3// nx_yt_nsolve_gate.nx -- proves the n-throttle SOLVER end-to-end on a base.js-shaped fixture (no live YouTube):
4// EXTRACT the named n-function (brace-balanced + string-aware: an object literal AFTER it and a "}{" literal
5// INSIDE it must not fool the balancer) -> BUILD a runnable script -> RUN through our JS engine -> the transformed
6// n. Different args produce different correct outputs (real compute, not a lookup). Declaration form works too;
7// an unknown name fails gracefully. license_tier: ORIGINAL expect_exit: 0
8import "nx_syscalls.nx"
9import "nx_media_signal.nx"
10import "nx_yt_nsolve.nx"
11import "nx_gate_verdict.nx"
12
13func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
14" as *u8); return ok }
15func gsl(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
16func streq(a: *u8, al: i64, b: *u8) -> i64 { if al != gsl(b) { return 0 } var i: i64=0; while i<al { if (a[i]&0xff) != (b[i]&0xff) { return 0 } i=i+1 } return 1 }
17
18func main() -> i64 {
19 gw("yt-nsolve SOVEREIGN gate (extract n-fn from base.js-shape -> run via our engine -> transformed n)\n" as *u8)
20 var pass: i64 = 0
21 var ttl: i64 = 0
22
23 // a base.js-shaped fixture: an assignment-form n-function buried in noise, with an OBJECT LITERAL after it
24 // and a "}{" STRING LITERAL inside its body (both are brace-balancer traps). The transform uses only ops our
25 // engine is proven to run: split("")/reverse/splice/index-swap/join("").
26 let base: *u8 = "zz;var g=7;Wua=function(a){var b=a.split(\"\");b.reverse();var s=\"}{\";b.splice(0,2);var c=b[0];b[0]=b[1];b[1]=c;return b.join(\"\")};var more={x:1,y:2};tail" as *u8
27 let bl: i64 = gsl(base)
28 let out: *u8 = sys_mmap(4096)
29 let script: *u8 = sys_mmap(65536)
30
31 // N1: the function name is located (assignment form)
32 let isd: *i64 = sys_mmap(8) as *i64
33 let start: i64 = ns_find_fn_start(base, bl, "Wua" as *u8, 3, isd)
34 ttl=ttl+1; pass=pass+grow("N1 locate n-fn 'Wua' (assignment form)\x00" as *u8, ((start >= 0)) as i64 * ((isd[0] == 0) as i64))
35
36 // N2: the built script is self-contained + brace-balancing stopped at the fn's own } (NOT past into `more`)
37 let sl: i64 = ns_build_script(base, bl, "Wua" as *u8, 3, "abcdef" as *u8, 6, script, 65536)
38 var n2: i64 = 0
39 if sl > 0 { if xt_has(script, sl, "var Wua=function" as *u8) == 1 { if xt_has(script, sl, "Wua(\"abcdef\")" as *u8) == 1 { if xt_has(script, sl, "more" as *u8) == 0 { n2 = 1 } } } }
40 ttl=ttl+1; pass=pass+grow("N2 script self-contained, balancer stopped at fn's } (no 'more')\x00" as *u8, n2)
41
42 // N3: RUN it -> "abcdef" transforms to "cdba" (reverse->fedcba, splice(0,2)->dcba, swap[0][1]->cdba)
43 let r3: i64 = ns_solve(base, bl, "Wua" as *u8, 3, "abcdef" as *u8, 6, out, 4096)
44 ttl=ttl+1; pass=pass+grow("N3 solve('abcdef') = 'cdba' (real transform via engine)\x00" as *u8, ((r3 == 4)) as i64 * (streq(out, r3, "cdba" as *u8)))
45
46 // N4: a DIFFERENT arg -> different correct output ("12345"->reverse 54321->splice 321->swap 231)
47 let r4: i64 = ns_solve(base, bl, "Wua" as *u8, 3, "12345" as *u8, 5, out, 4096)
48 ttl=ttl+1; pass=pass+grow("N4 solve('12345') = '231' (arg-dependent = real compute)\x00" as *u8, ((r4 == 3)) as i64 * (streq(out, r4, "231" as *u8)))
49
50 // N5: DECLARATION form `function Nde(a){...}` also extracts + runs ("abc"->reverse->"cba")
51 let base2: *u8 = "q;function Nde(a){var b=a.split(\"\");b.reverse();return b.join(\"\")}q" as *u8
52 let r5: i64 = ns_solve(base2, gsl(base2), "Nde" as *u8, 3, "abc" as *u8, 3, out, 4096)
53 ttl=ttl+1; pass=pass+grow("N5 declaration-form solve('abc') = 'cba'\x00" as *u8, ((r5 == 3)) as i64 * (streq(out, r5, "cba" as *u8)))
54
55 // N6: string-awareness proof -- the "}{" inside the body did not truncate (the transform after it ran)
56 ttl=ttl+1; pass=pass+grow("N6 inner \"}{\" literal did not truncate the body (N3 ran to join)\x00" as *u8, (r3 == 4) as i64)
57
58 // N7: unknown function name fails gracefully (-1), no crash
59 let r7: i64 = ns_solve(base, bl, "Nope" as *u8, 4, "abcdef" as *u8, 6, out, 4096)
60 ttl=ttl+1; pass=pass+grow("N7 unknown fn name -> graceful -1\x00" as *u8, (r7 == (0 - 1)) as i64)
61
62 gw("pass=" as *u8); gn(pass); gw("/" as *u8); gn(ttl); gw("\n" as *u8)
63 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
64 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
65 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
66 let ctr__dry: *i64 = gv_ctr()
67 ctr__dry[0] = pass
68 ctr__dry[1] = ttl
69 let rc__dry: i64 = gv_verdict("YT-NSOLVE-GATE" as *u8, ctr__dry, "n-throttle solver: extract base.js fn -> run on our engine -> transformed n; fast-download unlock is computable, sovereignly)" as *u8)
70 sys_exit(rc__dry)
71 return rc__dry
72}