code wiki / _hdl_build / nx_ad_banner_exceed_gate.nx
nx_ad_banner_exceed_gate.nx source
↩ module page · 75 lines · 5093 B
1// nx_ad_banner_exceed_gate.nx -- GATE for the MEASURED banner exceed. Prints the scorecard on a REAL banner,
2// then proves the grades are EVIDENCE-DRIVEN (not self-scored): a clean Nishi banner EXCEEDS on the privacy
3// axes; a tracker-laden incumbent-style creative LOSES the exceed (drops to MEASURED) -- the liar-kill; the
4// measurement actually FIRES on planted third-party-JS / fetch / tracker vectors; and the honest BEHIND axis
5// (visual richness) is real (our banner embeds 0 raster images). Sovereign, no gcc/.sh. license_tier: ORIGINAL
6import "nx_ad_banner_exceed.nx"
7import "nx_ad_banner.nx"
8import "nx_ad_serve.nx"
9import "nx_syscalls.nx"
10
11func g_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
12func g_i(v: i64) -> i64 { let t: *u8 = sys_mmap(24); var m: i64 = v; var k: i64 = 0; if m == 0 { t[0]=48 as u8; k=1 } while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let o: *u8=sys_mmap(24); var w: i64=0; var q: i64=k-1; while q>=0 { o[w]=t[q]; w=w+1; q=q-1 } sys_write(1,o,w); return 0 }
13func g_grade(lvl: i64) -> i64 {
14 if lvl == LV_EXCEEDS { g_p("EXCEEDS" as *u8) }
15 if lvl == LV_MEASURED { g_p("MEASURED" as *u8) }
16 if lvl == LV_GATED { g_p("GATED" as *u8) }
17 if lvl == LV_BUILT { g_p("BUILT" as *u8) }
18 return 0
19}
20
21func main(argc: i64, argv: *i64) -> i64 {
22 g_p("=== nx_ad_banner_exceed_gate ===\n" as *u8)
23 var pass: i64 = 0; var tot: i64 = 0
24
25 // ---- measure a REAL clean dynamic banner ----
26 let b: *u8 = sys_mmap(16384)
27 let n: i64 = ab_emit_banner("Andelin & West" as *u8, "Estate planning, done right" as *u8,
28 "Wills, trusts & probate for Utah families." as *u8, "Book a consult" as *u8,
29 "https://andelinwest.com/" as *u8, 728, 90, AB_DYNAMIC, 1, b)
30 let tpjs: i64 = as_has_thirdparty_js(b, n)
31 let fetch: i64 = ex_external_fetch(b, n)
32 let trk: i64 = ex_tracker(b, n)
33 let img: i64 = ex_count(b, n, "<img" as *u8) + ex_count(b, n, "data:image" as *u8)
34 g_p("SCORECARD (real 728x90 dynamic banner, bytes=" as *u8); g_i(n); g_p("):\n" as *u8)
35 g_p(" PRIVACY no-3rd-party-JS nishi=" as *u8); g_i(tpjs); g_p(" inc>=1 -> " as *u8); g_grade(ex_grade_fewer(tpjs,1)); g_p("\n" as *u8)
36 g_p(" SELF-CONTAINED no-fetch nishi=" as *u8); g_i(fetch); g_p(" inc>=1 -> " as *u8); g_grade(ex_grade_fewer(fetch,1)); g_p("\n" as *u8)
37 g_p(" NO-TRACKER nishi=" as *u8); g_i(trk); g_p(" inc>=1 -> " as *u8); g_grade(ex_grade_fewer(trk,1)); g_p("\n" as *u8)
38 g_p(" VISUAL-RICHNESS raster nishi=" as *u8); g_i(img); g_p(" inc>=1 -> BUILT (honest behind)\n" as *u8)
39
40 // ---- T1: clean banner EXCEEDS on all three privacy axes (measured strictly-fewer) ----
41 tot = tot + 1; var ok1: i64 = 1
42 if ex_grade_fewer(tpjs, 1) != LV_EXCEEDS { ok1 = 0 }
43 if ex_grade_fewer(fetch, 1) != LV_EXCEEDS { ok1 = 0 }
44 if ex_grade_fewer(trk, 1) != LV_EXCEEDS { ok1 = 0 }
45 if ok1 == 1 { pass = pass + 1; g_p("PASS T1 clean banner EXCEEDS on privacy/self-contained/no-tracker (measured)\n" as *u8) } else { g_p("FAIL T1\n" as *u8) }
46
47 // ---- T2: LIAR-KILL. A tracker-laden incumbent-style creative LOSES the exceed (-> MEASURED, never EXCEEDS).
48 let dirty: *u8 = "<div><script src='//pagead2.doubleclick.net/gpt.js'></script><img src='//cdn.example/creative.png'><img src='//google-analytics.com/collect/pixel'></div>" as *u8
49 let dn: i64 = as_len(dirty)
50 let d_tpjs: i64 = as_has_thirdparty_js(dirty, dn)
51 let d_fetch: i64 = ex_external_fetch(dirty, dn)
52 let d_trk: i64 = ex_tracker(dirty, dn)
53 tot = tot + 1; var ok2: i64 = 1
54 if ex_grade_fewer(d_tpjs, 1) != LV_MEASURED { ok2 = 0 } // 1 is NOT < 1 -> NOT EXCEEDS
55 if ex_grade_fewer(d_fetch, 1) != LV_MEASURED { ok2 = 0 }
56 if ex_grade_fewer(d_trk, 1) != LV_MEASURED { ok2 = 0 }
57 if ok2 == 1 { pass = pass + 1; g_p("PASS T2 liar-kill: tracker-laden creative loses the exceed (grade=MEASURED, not EXCEEDS)\n" as *u8) } else { g_p("FAIL T2\n" as *u8) }
58
59 // ---- T3: the MEASUREMENT actually fires on the planted vectors (anti-false-green on the measurement) ----
60 tot = tot + 1; var ok3: i64 = 1
61 if d_tpjs != 1 { ok3 = 0 }
62 if d_fetch < 1 { ok3 = 0 }
63 if d_trk < 2 { ok3 = 0 } // doubleclick + google-analytics (+ /pixel)
64 if ok3 == 1 { pass = pass + 1; g_p("PASS T3 measurement detects planted 3rd-party-JS=" as *u8) } else { g_p("FAIL T3\n" as *u8) }
65 if ok3 == 1 { g_i(d_tpjs); g_p(" fetch=" as *u8); g_i(d_fetch); g_p(" tracker=" as *u8); g_i(d_trk); g_p("\n" as *u8) }
66
67 // ---- T4: the honest BEHIND is REAL -- our banner embeds 0 raster images (consistent with the no-fetch exceed) ----
68 tot = tot + 1
69 if img == 0 { pass = pass + 1; g_p("PASS T4 honest behind: 0 raster images embedded (richness gap is real, not hidden)\n" as *u8) } else { g_p("FAIL T4\n" as *u8) }
70
71 g_p("nx_ad_banner_exceed_gate pass=" as *u8); g_i(pass); g_p("/" as *u8); g_i(tot)
72 if pass == tot { g_p(" verdict=GREEN (3 MEASURED exceeds, liar-killed, honest behind)\n" as *u8); return 0 }
73 g_p(" verdict=RED\n" as *u8)
74 return 1
75}