code wiki / _hdl_build / nx_media_adapt_gate.nx

nx_media_adapt_gate.nx source

↩ module page · 65 lines · 4055 B

1import "nx_gate_gn.nx" 2import "nx_gate_base.nx" 3// nx_media_adapt_gate.nx -- proves the LIVE EXTRACTOR self-heals end-to-end. A page whose ONLY media URL sits 4// on a novel host with no extension + unseeded path (exactly what a site update looks like) is a MISS for the 5// default seeded orchestrator. After the adaptive table LEARNS that host (critic/adversary confirmed it's 6// media), the SAME orchestrator entry point extracts it -- and after persist->fresh-load it STILL extracts. 7// This is the wiring proof: healing isn't a side gadget, it's in the extraction path. license_tier: ORIGINAL expect_exit: 0 8import "nx_syscalls.nx" 9import "nx_media_signal.nx" 10import "nx_media_state.nx" 11import "nx_media_extract.nx" 12import "nx_extract_heal.nx" 13 14func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" 15" as *u8); return ok } 16func gsl(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 17 18func main() -> i64 { 19 gw("media-adapt SOVEREIGN gate (LIVE extractor: miss -> learn -> extracts -> persist -> fresh still extracts)\n" as *u8) 20 var pass: i64 = 0 21 var ttl: i64 = 0 22 let best: *u8 = sys_mmap(4096) 23 let kb: *i64 = sys_mmap(8) as *i64 24 // a page whose only media URL is a novel-host, extension-less stream (a site-update shape) 25 let page: *u8 = "<html><body><script>var s=\"https://cdn-x7.streamhost.net/deliver/vod/abc123\";player.load(s)</script></body></html>" as *u8 26 let plen: i64 = gsl(page) 27 let advurl: *u8 = "streamhost.net/deliver/vod/abc123" as *u8 28 29 // A1: DEFAULT orchestrator (fresh seed) MISSES it -- this is the failure a site change causes 30 let c1: i64 = mx_extract(page, plen, best, 4096, kb) 31 ttl=ttl+1; pass=pass+grow("A1 default orchestrator MISSES novel-host stream (conf 0)\x00" as *u8, (c1 == 0) as i64) 32 33 // A2: LEARN the host into a table, then the SAME entry point (mx_extract_t) EXTRACTS it 34 let t: *i64 = xh_new() 35 xh_seed(t) 36 xh_learn(t, "https://cdn-x7.streamhost.net/deliver/vod/abc123" as *u8, gsl("https://cdn-x7.streamhost.net/deliver/vod/abc123" as *u8), XT_DIRECT) 37 let c2: i64 = mx_extract_t(page, plen, best, 4096, kb, t) 38 var a2: i64 = 0 39 if c2 > 0 { if kb[0] == XT_DIRECT { if xt_has(best, gsl(best), advurl) == 1 { a2 = 1 } } } 40 ttl=ttl+1; pass=pass+grow("A2 after learn, live extractor RETURNS the stream (DIRECT)\x00" as *u8, a2) 41 42 // A3: persist -> FRESH load -> the SAME page still extracts (durable heal in the extraction path) 43 let path: *u8 = "/tmp/xh_live.tbl" as *u8 44 xh_save(t, path) 45 let t2: *i64 = xh_new() 46 let loaded: i64 = xh_load(t2, path) 47 let c3: i64 = mx_extract_t(page, plen, best, 4096, kb, t2) 48 var a3: i64 = 0 49 if loaded > 0 { if c3 > 0 { if kb[0] == XT_DIRECT { if xt_has(best, gsl(best), advurl) == 1 { a3 = 1 } } } } 50 ttl=ttl+1; pass=pass+grow("A3 persist->fresh-load: SAME page still extracts (durable)\x00" as *u8, a3) 51 52 // A4: an unrelated-host page is still a miss with the healed table (no over-generalization in the extractor) 53 let other: *u8 = "<script>var s=\"https://cdn.unrelated.net/thing/xyz\"</script>" as *u8 54 let c4: i64 = mx_extract_t(other, gsl(other), best, 4096, kb, t2) 55 ttl=ttl+1; pass=pass+grow("A4 unrelated-host page still MISS after heal (no over-generalize)\x00" as *u8, (c4 == 0) as i64) 56 57 // A5: seeded knowledge still works through the healed table (a plain .m3u8 page) 58 let hpage: *u8 = "<script>var u=\"https://c/master.m3u8\"</script>" as *u8 59 let c5: i64 = mx_extract_t(hpage, gsl(hpage), best, 4096, kb, t2) 60 ttl=ttl+1; pass=pass+grow("A5 seeded .m3u8 still extracts (HLS) via healed table\x00" as *u8, ((c5 > 0)) as i64 * ((kb[0] == XT_HLS) as i64)) 61 62 gw("pass=" as *u8); gn(pass); gw("/" as *u8); gn(ttl); gw("\n" as *u8) 63 if pass == ttl { gw("verdict=GREEN (the extraction path itself adapts: a learned pattern turns a miss into a real extraction, durably)\n" as *u8); sys_exit(0); return 0 } 64 gw("verdict=RED\n" as *u8); sys_exit(1); return 1 65}