code wiki / _hdl_build / nx_yt_nsolve_gate.nx

nx_yt_nsolve_gate.nx source

↩ module page · 64 lines · 4584 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" 11 12func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" 13" as *u8); return ok } 14func gsl(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 15func 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 } 16 17func main() -> i64 { 18 gw("yt-nsolve SOVEREIGN gate (extract n-fn from base.js-shape -> run via our engine -> transformed n)\n" as *u8) 19 var pass: i64 = 0 20 var ttl: i64 = 0 21 22 // a base.js-shaped fixture: an assignment-form n-function buried in noise, with an OBJECT LITERAL after it 23 // and a "}{" STRING LITERAL inside its body (both are brace-balancer traps). The transform uses only ops our 24 // engine is proven to run: split("")/reverse/splice/index-swap/join(""). 25 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 26 let bl: i64 = gsl(base) 27 let out: *u8 = sys_mmap(4096) 28 let script: *u8 = sys_mmap(65536) 29 30 // N1: the function name is located (assignment form) 31 let isd: *i64 = sys_mmap(8) as *i64 32 let start: i64 = ns_find_fn_start(base, bl, "Wua" as *u8, 3, isd) 33 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)) 34 35 // N2: the built script is self-contained + brace-balancing stopped at the fn's own } (NOT past into `more`) 36 let sl: i64 = ns_build_script(base, bl, "Wua" as *u8, 3, "abcdef" as *u8, 6, script, 65536) 37 var n2: i64 = 0 38 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 } } } } 39 ttl=ttl+1; pass=pass+grow("N2 script self-contained, balancer stopped at fn's } (no 'more')\x00" as *u8, n2) 40 41 // N3: RUN it -> "abcdef" transforms to "cdba" (reverse->fedcba, splice(0,2)->dcba, swap[0][1]->cdba) 42 let r3: i64 = ns_solve(base, bl, "Wua" as *u8, 3, "abcdef" as *u8, 6, out, 4096) 43 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))) 44 45 // N4: a DIFFERENT arg -> different correct output ("12345"->reverse 54321->splice 321->swap 231) 46 let r4: i64 = ns_solve(base, bl, "Wua" as *u8, 3, "12345" as *u8, 5, out, 4096) 47 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))) 48 49 // N5: DECLARATION form `function Nde(a){...}` also extracts + runs ("abc"->reverse->"cba") 50 let base2: *u8 = "q;function Nde(a){var b=a.split(\"\");b.reverse();return b.join(\"\")}q" as *u8 51 let r5: i64 = ns_solve(base2, gsl(base2), "Nde" as *u8, 3, "abc" as *u8, 3, out, 4096) 52 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))) 53 54 // N6: string-awareness proof -- the "}{" inside the body did not truncate (the transform after it ran) 55 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) 56 57 // N7: unknown function name fails gracefully (-1), no crash 58 let r7: i64 = ns_solve(base, bl, "Nope" as *u8, 4, "abcdef" as *u8, 6, out, 4096) 59 ttl=ttl+1; pass=pass+grow("N7 unknown fn name -> graceful -1\x00" as *u8, (r7 == (0 - 1)) as i64) 60 61 gw("pass=" as *u8); gn(pass); gw("/" as *u8); gn(ttl); gw("\n" as *u8) 62 if pass == ttl { gw("verdict=GREEN (n-throttle solver: extract base.js fn -> run on our engine -> transformed n; fast-download unlock is computable, sovereignly)\n" as *u8); sys_exit(0); return 0 } 63 gw("verdict=RED\n" as *u8); sys_exit(1); return 1 64}