code wiki / _hdl_build / nx_browser_js_census.nx
nx_browser_js_census.nx source
↩ module page · 144 lines · 11855 B
1// nx_browser_js_census.nx -- RESEARCH-GROUNDED scorecard + build-ladder for the Nishi browser's
2// JS-EXECUTION rung (operator 2026-07-06: "keep going on the nishi browser ... works for user AND search
3// AND researcher ... really use nishi researcher to get it state of the art on what you called out").
4// MECHANICAL: each JS-capability row RUNS a real snippet through the gated engine (js_run_source) -- a
5// present capability RUNS (rc=0), an absent one ERRORS (rc=1) NAMING its build organ. Self-flips when the
6// rung lands (like nx_browser_os_census). Grounded vs the banked SOTA refs (knowledge/fetched/br_*).
7// State threaded via args (NishiLang has no mutable module globals): hfd = HTML fd, st = *i64 tallies
8// [0]=have [1]=gap [2]=broken. license_tier: ORIGINAL
9import "nx_js_eval.nx"
10
11func bw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
12func bn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m } let t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let o: *u8=sys_mmap(24); var q: i64=k-1; var x: i64=0; while q>=0 { o[x]=t[q]; x=x+1; q=q-1 } sys_write(1,o,x); return 0 }
13func cslen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
14func cexists(p: *u8) -> i64 { let fd: i64 = sys_openat_rd(p); if fd >= 0 { sys_close(fd); return 1 } return 0 }
15func cprobe(s: *u8) -> i64 { let out: *i64 = sys_mmap(16) as *i64; return js_run_source(s, cslen(s), out) }
16
17// HTML fragment -> fd (no buffer, no mutable globals)
18func hw(fd: i64, s: *u8) -> i64 { sys_write(fd, s, cslen(s)); return 0 }
19func hwn(fd: i64, v: i64) -> i64 { if v==0 { sys_write(fd,"0" as *u8,1); return 0 } var m: i64=v; if m<0 { sys_write(fd,"-" as *u8,1); m=0-m } let t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let o: *u8=sys_mmap(24); var q: i64=k-1; var x: i64=0; while q>=0 { o[x]=t[q]; x=x+1; q=q-1 } sys_write(fd,o,x); return 0 }
20
21// JS-EXECUTION row: run snippet; present=1 -> must RUN (rc0); present=0 -> must ERROR (rc1) naming its organ.
22func jsrow(fd: i64, st: *i64, name: *u8, snippet: *u8, mustrun: i64, organ: *u8) -> i64 {
23 let rc: i64 = cprobe(snippet) // SELF-CLASSIFYING: 0 = ran (HAVE), 1 = errored (GAP). Flips when a rung lands.
24 bw(" "); bw(name)
25 hw(fd, "<tr><td>" as *u8); hw(fd, name); hw(fd, "</td><td>" as *u8)
26 if rc == 0 {
27 st[0] = st[0] + 1
28 bw(" HAVE (runs)\n" as *u8)
29 hw(fd, "<b class=h>HAVE</b></td><td>runs: <code>" as *u8); hw(fd, snippet); hw(fd, "</code></td>" as *u8)
30 } else {
31 st[1] = st[1] + 1
32 bw(" GAP -> "); bw(organ); bw("\n" as *u8)
33 hw(fd, "<b class=g>GAP</b></td><td>errors; build <code>" as *u8); hw(fd, organ); hw(fd, "</code></td>" as *u8)
34 }
35 // core rows MUST run: a core capability that errors = a real ENGINE REGRESSION = RED (liar-kill).
36 if mustrun == 1 { if rc != 0 { bw(" !! CORE REGRESSION\n" as *u8); st[2] = 1; hw(fd, "<td class=g>REGRESSION</td>" as *u8) } else { hw(fd, "<td class=h>ok</td>" as *u8) } }
37 else { hw(fd, "<td>-</td>" as *u8) }
38 hw(fd, "</tr>\n" as *u8)
39 return rc
40}
41
42// CITED row (capability proven by an existing gate/organ; evid file must exist). kind: 1=HAVE 0=GAP.
43func citerow(fd: i64, st: *i64, name: *u8, kind: i64, evid_path: *u8, note: *u8) -> i64 {
44 let ex: i64 = cexists(evid_path)
45 bw(" "); bw(name)
46 if kind == 1 { bw(" HAVE" as *u8); st[0]=st[0]+1 } else { bw(" GAP" as *u8); st[1]=st[1]+1 }
47 if ex == 0 { bw(" !! EVIDENCE-MISSING "); bw(evid_path); st[2]=1 }
48 bw("\n" as *u8)
49 hw(fd, "<tr><td>" as *u8); hw(fd, name); hw(fd, "</td><td>" as *u8)
50 if ex == 1 { if kind==1 { hw(fd,"<b class=h>HAVE</b>" as *u8) } else { hw(fd,"<b class=g>GAP</b>" as *u8) } }
51 else { hw(fd, "<b class=g>EVID-MISSING</b>" as *u8) }
52 hw(fd, "</td><td>" as *u8); hw(fd, note); hw(fd, "</td><td>" as *u8); hw(fd, evid_path); hw(fd, "</td></tr>\n" as *u8)
53 return ex
54}
55
56func main(argc: i64, argv: *i64) -> i64 {
57 bw("=== nx_browser_js_census: Nishi browser JS-execution rung vs SOTA (mechanical) ===\n" as *u8)
58 let st: *i64 = sys_mmap(64) as *i64 // [0]=have [1]=gap [2]=broken (mmap zeroed)
59
60 // research grounding (sovereign nx_research_fetch banked these)
61 var research: i64 = 0
62 if cexists("knowledge/fetched/br_eventloop" as *u8) == 1 { research = research + 1 }
63 if cexists("knowledge/fetched/br_engine" as *u8) == 1 { research = research + 1 }
64 if cexists("knowledge/fetched/br_jsengine" as *u8) == 1 { research = research + 1 }
65 if cexists("knowledge/fetched/br_headless" as *u8) == 1 { research = research + 1 }
66 if cexists("knowledge/fetched/br_spa" as *u8) == 1 { research = research + 1 }
67 if cexists("knowledge/fetched/br_dom" as *u8) == 1 { research = research + 1 }
68 if cexists("knowledge/fetched/br_xhr" as *u8) == 1 { research = research + 1 }
69 bw("research grounding: "); bn(research); bw("/7 SOTA refs banked (br_*)\n" as *u8)
70
71 let fd: i64 = sys_openat_wr("knowledge/status/browser_js_census.html" as *u8, 0x1A4)
72 hw(fd, "<!doctype html><meta charset=utf-8><title>Nishi Browser JS-Execution Census</title>" as *u8)
73 hw(fd, "<style>body{font:15px system-ui;margin:2rem;max-width:62rem}table{border-collapse:collapse;width:100%;margin:1rem 0}td{border:1px solid #ddd;padding:6px 9px}.h{color:#0a7d33}.g{color:#b00}code{background:#f3f3f3;padding:1px 4px}h1{font-size:1.5rem}</style>" as *u8)
74 hw(fd, "<h1>Nishi Browser \xe2\x80\x94 JS-Execution Rung vs SOTA</h1><p>Mechanical: each JS row RUNS a real snippet through the gated engine. Grounded vs " as *u8)
75 hwn(fd, research); hw(fd, "/7 banked SOTA refs (br_*). Self-flips when a rung lands.</p>\n" as *u8)
76
77 bw("\n-- JS CORE (present: must RUN) --\n" as *u8)
78 hw(fd, "<h2>JS core engine (present \xe2\x80\x94 runs today)</h2><table>\n" as *u8)
79 jsrow(fd, st, "arithmetic/precedence" as *u8, "1+2*3" as *u8, 1, "-" as *u8)
80 jsrow(fd, st, "functions+call" as *u8, "(function(x){return x+1})(5)" as *u8, 1, "-" as *u8)
81 jsrow(fd, st, "lexical closures" as *u8, "(function(x){return function(){return x}})(7)()" as *u8, 1, "-" as *u8)
82 jsrow(fd, st, "arrays+index" as *u8, "[1,2,3].length" as *u8, 1, "-" as *u8)
83 jsrow(fd, st, "array methods+arrows" as *u8, "[1,2,3].map(x=>x*2)[2]" as *u8, 1, "-" as *u8)
84 jsrow(fd, st, "callbacks (forEach)" as *u8, "var s=0;[4,5,6].forEach(x=>{s=s+x});s" as *u8, 1, "-" as *u8)
85 jsrow(fd, st, "Math builtin" as *u8, "Math.max(3,9,2)" as *u8, 1, "-" as *u8)
86 hw(fd, "</table>\n" as *u8)
87
88 bw("\n-- ASYNC / NETWORK / BOM (the called-out gap: must ERROR today) --\n" as *u8)
89 hw(fd, "<h2>Async / Network / BOM rung (the gap \xe2\x80\x94 the SPA-hydration path)</h2><table>\n" as *u8)
90 jsrow(fd, st, "event-loop: setTimeout" as *u8, "setTimeout(function(){},0)" as *u8, 0, "nx_js_event_loop" as *u8)
91 jsrow(fd, st, "microtask: queueMicrotask" as *u8, "queueMicrotask(function(){})" as *u8, 0, "nx_js_event_loop" as *u8)
92 jsrow(fd, st, "Promise" as *u8, "Promise.resolve(1)" as *u8, 0, "nx_js_promise" as *u8)
93 jsrow(fd, st, "fetch()" as *u8, "fetch(1)" as *u8, 0, "nx_js_fetch" as *u8)
94 jsrow(fd, st, "XMLHttpRequest" as *u8, "XMLHttpRequest()" as *u8, 0, "nx_js_xhr" as *u8)
95 jsrow(fd, st, "BOM: window" as *u8, "window.location" as *u8, 0, "nx_js_bom" as *u8)
96 jsrow(fd, st, "BOM: navigator" as *u8, "navigator.userAgent" as *u8, 0, "nx_js_bom" as *u8)
97 jsrow(fd, st, "BOM: location" as *u8, "location.href" as *u8, 0, "nx_js_bom" as *u8)
98 jsrow(fd, st, "history.pushState" as *u8, "history.pushState(1,2,3)" as *u8, 0, "nx_js_bom" as *u8)
99 jsrow(fd, st, "requestAnimationFrame" as *u8, "requestAnimationFrame(function(){})" as *u8, 0, "nx_js_event_loop" as *u8)
100 hw(fd, "</table>\n" as *u8)
101
102 bw("\n-- DOM read/write/events (present via DOM-mode gate) --\n" as *u8)
103 hw(fd, "<h2>DOM + events (present \xe2\x80\x94 gated in DOM mode)</h2><table>\n" as *u8)
104 citerow(fd, st, "DOM read (querySelector/getElementById)" as *u8, 1, "runtime/nx_js_eval.nx" as *u8, "BI_DOC_QUERY_SELECTOR / _GET_BY_ID" as *u8)
105 citerow(fd, st, "DOM write (createElement/appendChild)" as *u8, 1, "runtime/nx_js_eval.nx" as *u8, "BI_DOC_CREATE_ELEMENT / _APPEND_CHILD" as *u8)
106 citerow(fd, st, "events (addEventListener/click)" as *u8, 1, "runtime/nx_js_eval.nx" as *u8, "BI_EL_ADD_LISTENER / _CLICK" as *u8)
107 citerow(fd, st, "JS->render seam" as *u8, 1, "runtime/_hdl_build/nx_js_render_gate.nx" as *u8, "renders JS-walled pages" as *u8)
108 hw(fd, "</table>\n" as *u8)
109
110 bw("\n-- CONSUMERS (user / search / researcher) --\n" as *u8)
111 hw(fd, "<h2>Consumers \xe2\x80\x94 does it serve each?</h2><table>\n" as *u8)
112 citerow(fd, st, "USER: interactive render (Linux/Win/NishiOS)" as *u8, 1, "runtime/_hdl_build/nx_browser_render.nx" as *u8, "GUI + NishiOS surfaces" as *u8)
113 citerow(fd, st, "SEARCH: crawler runs page JS" as *u8, 1, "runtime/_hdl_build/nx_web_crawl_step.nx" as *u8, "HYDRATES inline-script pages via js_render_page (nx_bulk_index too) -> gated end-to-end" as *u8)
114 citerow(fd, st, "RESEARCHER: fetch runs page JS" as *u8, 0, "runtime/nx_research_fetch.nx" as *u8, "default fetch stays raw (blast radius); JS-aware via nx_js_headless_render organ" as *u8)
115 hw(fd, "</table>\n" as *u8)
116
117 bw("\n-- CROSS-PLATFORM targets --\n" as *u8)
118 hw(fd, "<h2>Cross-platform user targets</h2><table>\n" as *u8)
119 citerow(fd, st, "Linux" as *u8, 1, "runtime/_hdl_build/nx_browser_render.nx" as *u8, "X11 render + fetch" as *u8)
120 citerow(fd, st, "Windows" as *u8, 1, "runtime/nx_pe_compile_win_gui.nx" as *u8, "native PE GUI" as *u8)
121 citerow(fd, st, "NishiOS" as *u8, 1, "runtime/_hdl_build/nx_nishios_net_wire.nx" as *u8, "boots + fetches on real internet" as *u8)
122 citerow(fd, st, "macOS" as *u8, 0, "runtime/nx_js_eval.nx" as *u8, "build nx_macho_compile_gui (Mach-O + Cocoa)" as *u8)
123 citerow(fd, st, "Android" as *u8, 0, "runtime/nx_js_eval.nx" as *u8, "build nx_apk_compile_gui (aarch64 .so in APK)" as *u8)
124 citerow(fd, st, "iOS / Safari OS" as *u8, 0, "runtime/nx_js_eval.nx" as *u8, "build nx_ios_compile_gui (arm64 Mach-O)" as *u8)
125 hw(fd, "</table>\n" as *u8)
126
127 let total: i64 = st[0] + st[1]
128 var permille: i64 = 0
129 if total > 0 { permille = (st[0] * 1000) / total }
130 bw("\n=== SCORE: HAVE="); bn(st[0]); bw(" GAP="); bn(st[1]); bw(" -> "); bn(permille); bw("permille ===\n" as *u8)
131 hw(fd, "<h2>Score</h2><p>HAVE " as *u8); hwn(fd, st[0]); hw(fd, " \xc2\xb7 GAP " as *u8); hwn(fd, st[1]); hw(fd, " \xe2\x86\x92 <b>" as *u8); hwn(fd, permille); hw(fd, "permille</b>. The gap is the async/network/BOM rung = the SPA-hydration path. Build ladder: <code>nx_js_event_loop</code> (foundation) \xe2\x86\x92 <code>nx_js_promise</code> \xe2\x86\x92 <code>nx_js_fetch</code> \xe2\x86\x92 <code>nx_js_bom</code> \xe2\x86\x92 <code>nx_js_headless_render</code> (wire search + researcher).</p>\n" as *u8)
132
133 // liar-kill self-check
134 if cprobe("1+1" as *u8) != 0 { st[2] = 1; bw("SELFCHECK FAIL: 1+1 did not run\n" as *u8) }
135 if cprobe("@#$%^" as *u8) != 1 { st[2] = 1; bw("SELFCHECK FAIL: garbage did not error\n" as *u8) }
136 if research < 5 { st[2] = 1; bw("VERDICT RED: research grounding < 5\n" as *u8) }
137
138 if st[2] == 1 { bw("=== VERDICT: RED (census integrity broken) ===\n" as *u8); hw(fd, "<p class=g><b>VERDICT: RED</b></p>" as *u8) }
139 else { bw("=== VERDICT: GREEN (mechanical, grounded, self-flipping) ===\n" as *u8); hw(fd, "<p class=h><b>VERDICT: GREEN</b> \xe2\x80\x94 mechanical + grounded + self-flipping.</p>" as *u8) }
140 if fd >= 0 { sys_close(fd) }
141 bw("wrote knowledge/status/browser_js_census.html\n" as *u8)
142 if st[2] == 1 { return 1 }
143 return 0
144}