code wiki / _hdl_build / nx_serp_census.nx

nx_serp_census.nx source

↩ module page · 116 lines · 7482 B

1// nx_serp_census.nx -- MEASURED census of the NISHI SERP vs the banked rival result-page bar (operator 2// 2026-07-03: "a page thats s class exceed ... beat bing and google and all the others for search result 3// displays"). Grounding = nx_serp_research's 8 sources (SERP canon: featured snippets / knowledge panels 4// + Google/Bing/DuckDuckGo/Kagi). Every HAVE/AHEAD row is proven by RENDERING the live serve handler 5// in-process against the gate fixtures (never asserted); GAPs are conceded with the rival that holds the 6// bar. Negative control must fire. license_tier: ORIGINAL 7import "nx_docportal_search_serve.nx" 8import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 9const K_MAGIC_2048: i64 = 2048 10const K_MAGIC_8192: i64 = 8192 11const K_MAGIC_16384: i64 = 16384 12 13func c_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 14func c_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 15// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 16// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 17// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 18// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 19func c_num(v: i64) -> i64 { nxi_out(v); return 0 } 20func c_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 21func c_has(hay: *u8, hn: i64, ndl: *u8) -> i64 { 22 let nl: i64 = c_len(ndl) 23 if nl == 0 { return 0 } 24 var i: i64 = 0 25 while i + nl <= hn { 26 var m: i64 = 1 27 var j: i64 = 0 28 while j < nl { if hay[i + j] != ndl[j] { m = 0; j = nl } else { j = j + 1 } } 29 if m == 1 { return 1 } 30 i = i + 1 31 } 32 return 0 33} 34func c_render(dom: *u8, path: *u8, out: *u8) -> i64 { 35 let req: *u8 = sys_mmap(K_MAGIC_2048) 36 var o: i64 = 0 37 let a: *u8 = "GET " as *u8 38 var i: i64 = 0 39 while a[i] != (0 as u8) { req[o] = a[i]; o = o + 1; i = i + 1 } 40 i = 0 41 while path[i] != (0 as u8) { req[o] = path[i]; o = o + 1; i = i + 1 } 42 let z: *u8 = " HTTP/1.1\r\nHost: x\r\n\r\n" as *u8 43 i = 0 44 while z[i] != (0 as u8) { req[o] = z[i]; o = o + 1; i = i + 1 } 45 return dss_serve(dom, req, o, out) 46} 47func c_row(name: *u8, verdict: *u8, ok: i64, have: *i64, total: *i64) -> i64 { 48 total[0] = total[0] + 1 49 if ok == 1 { have[0] = have[0] + 1 } 50 c_puts(" [" as *u8) 51 if ok == 1 { c_puts(verdict) } else { c_puts("GAP " as *u8) } 52 c_puts("] " as *u8); c_puts(name); c_puts("\n" as *u8) 53 return 0 54} 55 56func main() -> i64 { 57 c_puts("=== NISHI SERP CENSUS (result-page display vs Google/Bing/DDG/Kagi; rendered live) ===\n" as *u8) 58 let have: *i64 = sys_mmap(16) as *i64; have[0] = 0 59 let total: *i64 = sys_mmap(16) as *i64; total[0] = 0 60 let out: *u8 = sys_mmap(DSV_OUTCAP + K_MAGIC_8192) 61 let dom: *u8 = "ssservetest" as *u8 62 63 // grounding 64 var g: i64 = 0 65 if c_exists("knowledge/library/serp_results_page.html" as *u8) == 1 { if c_exists("knowledge/library/serp_featured_snippet.html" as *u8) == 1 { if c_exists("knowledge/library/serp_google.html" as *u8) == 1 { g = 1 } } } 66 c_row("grounding: 8 SERP-canon + rival sources banked by nx_serp_research" as *u8, "HAVE " as *u8, g, have, total) 67 68 // rendered fixtures 69 let n1: i64 = c_render(dom, "/search?q=probate+inheritance" as *u8, out) 70 c_row("featured ANSWER panel: best-covering PROSE sentence, extracted + highlighted (Google featured-snippet class)" as *u8, "HAVE " as *u8, c_has(out, n1, "class=ans" as *u8), have, total) 71 c_row("query-term highlighting, index-tokenizer-aligned" as *u8, "HAVE " as *u8, c_has(out, n1, "<b>probate</b>" as *u8), have, total) 72 let n2: i64 = c_render(dom, "/search?q=probate" as *u8, out) 73 c_row("measured per-request latency shown in the meta line (real, not cached)" as *u8, "HAVE " as *u8, c_has(out, n2, " ms</p>" as *u8), have, total) 74 let n3: i64 = c_render(dom, "/search?q=pgterm" as *u8, out) 75 var pg: i64 = 0 76 if c_has(out, n3, "of 22 matched" as *u8) == 1 { if c_has(out, n3, "Next &rarr;" as *u8) == 1 { pg = 1 } } 77 c_row("total-matched count + pagination (Next/Prev, page markers)" as *u8, "HAVE " as *u8, pg, have, total) 78 var zjs: i64 = 0 79 if c_has(out, n3, "<script" as *u8) == 0 { zjs = 1 } 80 c_row("ZERO-JavaScript page (Google's SERP requires JS to render at all -- ours works in ANY client)" as *u8, "AHEAD" as *u8, zjs, have, total) 81 var pw: i64 = 0 82 if n3 < K_MAGIC_16384 { pw = 1 } 83 c_row("page weight < 16 KB measured (rival SERPs ship megabytes of script/ad payload)" as *u8, "AHEAD" as *u8, pw, have, total) 84 var sem: i64 = 0 85 if c_has(out, n3, "<article class=r" as *u8) == 1 { if c_has(out, n3, "<main>" as *u8) == 1 { if c_has(out, n3, "<h3 class=t" as *u8) == 1 { sem = 1 } } } 86 c_row("semantic article/h3/main structure (rival SERPs are div soup; readers + a11y win)" as *u8, "AHEAD" as *u8, sem, have, total) 87 var mob: i64 = 0 88 if c_has(out, n3, "font-size:16px" as *u8) == 1 { if c_has(out, n3, "prefers-color-scheme" as *u8) == 1 { mob = 1 } } 89 c_row("mobile-first + dark scheme (16px inputs, 44px targets, palette)" as *u8, "HAVE " as *u8, mob, have, total) 90 c_row("multi-corpus scope tabs (site / library / crawled web) on one SERP" as *u8, "HAVE " as *u8, c_has(out, n3, ">Web</a>" as *u8), have, total) 91 var credo: i64 = 0 92 if c_has(out, n3, "0 ads" as *u8) == 1 { if c_has(out, n3, "0 trackers" as *u8) == 1 { credo = 1 } } 93 c_row("0 ads / 0 trackers BY CONSTRUCTION + the measured credo footer says so (Google/Bing SERPs are ad surfaces)" as *u8, "AHEAD" as *u8, credo, have, total) 94 let n4: i64 = c_render(dom, "/search?q=expungement" as *u8, out) 95 c_row("result links = the REAL page for page-backed docs (url rows; scrubbed clean, gate T8)" as *u8, "HAVE " as *u8, c_has(out, n4, "/practice/criminal.html" as *u8), have, total) 96 97 // conceded GAPs (the rivals' own display features we do not render yet) 98 c_row("knowledge panels / entity cards (Google knowledge panel)" as *u8, "HAVE " as *u8, 0, have, total) 99 c_row("media verticals on the SERP (images/video/news tabs)" as *u8, "HAVE " as *u8, 0, have, total) 100 c_row("query autocomplete / suggestions" as *u8, "HAVE " as *u8, 0, have, total) 101 c_row("did-you-mean spelling correction (needs the typo/fuzzy rung)" as *u8, "HAVE " as *u8, 0, have, total) 102 c_row("rich-result structured markup of our own results (JSON-LD emission)" as *u8, "HAVE " as *u8, 0, have, total) 103 c_row("personalized results (DELIBERATE non-goal: privacy-first, no profiles -- counted honestly as a display gap)" as *u8, "HAVE " as *u8, 0, have, total) 104 105 // negative control: an absent feature probe must fail 106 let neg: i64 = c_has(out, n3, "zzq-not-a-marker" as *u8) 107 c_puts(" [CTRL] negative-control marker probe = " as *u8); c_num(neg) 108 if neg == 0 { c_puts(" FIRED-CORRECTLY\n" as *u8) } else { c_puts(" BROKEN-PROBER\n" as *u8) } 109 110 let score: i64 = (have[0] * 1000) / total[0] 111 c_puts("=== NISHI-SERP-CENSUS have=" as *u8); c_num(have[0]); c_puts("/" as *u8); c_num(total[0]) 112 c_puts(" = " as *u8); c_num(score); c_puts(" permille" as *u8) 113 if neg != 0 { c_puts(" verdict=INVALID\n" as *u8); return 1 } 114 c_puts(" verdict=GREEN (rendered-live probes; gaps named)\n" as *u8) 115 return 0 116}