code wiki / wiki / nx_wiki_article.nx

nx_wiki_article.nx source

↩ module page · 305 lines · 46837 B

1// nx_wiki_article.nx -- Gitea x Wikipedia component articles for the Nishi wiki. 2// 3// Each "component" (crawler, X25519, ranking math, the wiki engine itself, 4// ...) gets a rich, RESEARCHED + BENCHMARKED article that doubles as a repo 5// view: overview, the math/algorithm, how-it-works, LOCAL vs GLOBAL 6// functionality, the real files (Gitea-style), the measured benchmark, the 7// research citations, and a PARTNERSHIP WORKLOG -- the durable record of 8// human<->Claude work on that item (what was built: the math, the crypto, 9// the specific thing). The worklog is the spine of the "trigger Claude 10// partnership work" loop: work on a component appends a worklog entry 11// documenting its local + global functionality. 12// 13// SOVEREIGN: all NishiLang, rendered by the wiki engine, served by the Nishi 14// daemon. No shell, no TSV, no external lib (operator mandate; see 15// feedback-sovereign-medium-not-shell-tsv). Reuses the wiki render 16// primitives (legacy header ships table CSS; write_z / write_byte / footer). 17// 18// COMPOSED BY: wiki/nx_wiki_routes (dynamic /wiki/component/<slug>) and 19// bin/nx_sites_daemon (renders each article once at startup 20// into a hoisted buffer; served verbatim, constant memory). 21// 22// TLS RECORD BUDGET: the live sites daemon sends one TLS 1.3 record 23// (<=16384 plaintext), so each article response is kept under ~15 KB. 24// 25// Status: V1. 2026-05-29. 26 27import "nx_syscalls.nx" 28import "wiki/nx_wiki_doc_render.nx" 29 30// ===== Sealed verdict surface ================================================= 31const NX_ART_OK: i64 = 0 32const NX_ART_OVERFLOW: i64 = 2900 33 34// ===== Sizing (M7) ================================================= 35const NX_ART_RENDER_CAP: i64 = 131072 // 128 KB render scratch 36const NX_ART_SCRATCH_CAP: i64 = 4096 37const NX_ART_STRLEN_CAP: i64 = 65536 38const NX_ART_PUTZ_CAP: i64 = 1048576 39 40// ===== HTTP-wrap helpers (raw buffer; no NxWikiDocCtx) ================================================= 41func nx_art_strlen(s: *u8) -> i64 { 42 if (s as i64) == 0 { return 0 } 43 var n: i64 = 0 44 while n < NX_ART_STRLEN_CAP { 45 if s[n] == (0 as u8) { return n } 46 n = n + 1 47 } 48 return NX_ART_STRLEN_CAP 49} 50 51func nx_art_put_z(dst: *u8, off: *i64, cap: i64, s: *u8) -> i64 { 52 if (s as i64) == 0 { return 0 - NX_ART_OVERFLOW } 53 var n: i64 = 0 54 while n < NX_ART_PUTZ_CAP { 55 if s[n] == (0 as u8) { 56 if off[0] + n > cap { return 0 - NX_ART_OVERFLOW } 57 var i: i64 = 0 58 while i < n { dst[off[0] + i] = s[i]; i = i + 1 } 59 off[0] = off[0] + n 60 return NX_ART_OK 61 } 62 n = n + 1 63 } 64 return 0 - NX_ART_OVERFLOW 65} 66 67// ===== Slug match (bounded) ================================================= 68func nx_art_slug_eq(slug: *u8, slug_n: i64, target: *u8) -> i64 { 69 let tn: i64 = nx_art_strlen(target) 70 if slug_n != tn { return 0 } 71 var i: i64 = 0 72 while i < slug_n { 73 if i >= NX_ART_STRLEN_CAP { return 0 } 74 if slug[i] != target[i] { return 0 } 75 i = i + 1 76 } 77 return 1 78} 79 80// ===== Section helpers (compress the article bodies; each checks rc) ================================================= 81func nx_aw_h2(ctx: *NxWikiDocCtx, title: *u8) -> i64 { 82 var rc: i64 = nx_wiki_doc_write_z(ctx, "<h2>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 83 rc = nx_wiki_doc_write_z(ctx, title); if rc != NX_WIKI_DOC_OK { return rc } 84 return nx_wiki_doc_write_z(ctx, "</h2>" as *u8) 85} 86 87// Trigger-partnership panel + worklog table opener shared by every article. 88func nx_aw_partnership_panel(ctx: *NxWikiDocCtx, slug: *u8) -> i64 { 89 var rc: i64 = nx_wiki_doc_write_z(ctx, "<h2>Trigger Claude partnership work</h2><div class=\"normative\"><p>This article is a <strong>live partnership surface</strong>. Submit a task below; it is appended to the sovereign <a href=\"/wiki/queue\">work queue</a> (an append-only Nishi journal), and a Claude session drains it &mdash; logging what it built (the math, the crypto, the specific thing) with both its <em>local</em> functionality (this module) and its <em>global</em> functionality (its role in the stack).</p>" as *u8) 90 if rc != NX_WIKI_DOC_OK { return rc } 91 rc = nx_wiki_doc_write_z(ctx, "<form method=\"POST\" action=\"/wiki/request\"><input type=\"hidden\" name=\"slug\" value=\"" as *u8) 92 if rc != NX_WIKI_DOC_OK { return rc } 93 rc = nx_wiki_doc_write_z(ctx, slug) 94 if rc != NX_WIKI_DOC_OK { return rc } 95 rc = nx_wiki_doc_write_z(ctx, "\"><p>Task: <input name=\"task\" size=\"52\" placeholder=\"e.g. wire the live crawl front-half\"> <button type=\"submit\">Request work</button></p></form><p class=\"status\">See the live <a href=\"/wiki/queue\">partnership work queue &rarr;</a></p></div>" as *u8) 96 if rc != NX_WIKI_DOC_OK { return rc } 97 return NX_ART_OK 98} 99 100// ===== Article: the WIKI ENGINE itself (dogfood -- documents this system) ================================================= 101func nx_article_wiki_engine(ctx: *NxWikiDocCtx) -> i64 { 102 var rc: i64 = 0 103 rc = nx_wiki_doc_write_z(ctx, "<h1>Wiki Engine</h1><p class=\"status\">component: wiki &middot; layer: ecosystem &middot; sovereignty A+ &middot; this page is rendered by the very engine it documents</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 104 105 rc = nx_wiki_doc_write_z(ctx, "<h2>Overview</h2><p>The Nishi wiki engine is a sovereign, bits-up living-doc + repo platform &mdash; Wikipedia crossed with Gitea &mdash; written entirely in NishiLang and served by the multi-vhost TLS&nbsp;1.3 daemon with <strong>no nginx, no OpenSSL, no libc</strong>. It renders component articles (this page), a live distance-to-S-class scorecard, and a per-article partnership worklog. The medium embodies the message: a page whose job is to prove the sovereign stack is itself served entirely by that stack.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 106 107 rc = nx_wiki_doc_write_z(ctx, "<h2>Math / Algorithm</h2><p>The render path is a CommonMark-subset parser (block + inline) plus structural rendering: <code>[[wikilink]]</code> resolution, a NISHIDOC section TOC, and the page-format chrome. Search over docs uses an FNV-1a hashed inverted index.</p><pre>FNV-1a (32-bit): h = 2166136261\n for each byte b: h = (h XOR b) * 16777619 (mod 2^32)\nrender: src -[wikilink preprocess]-> scratch -[markdown_block+inline]-> HTML\n</pre>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 108 109 rc = nx_wiki_doc_write_z(ctx, "<h2>How it works</h2><p>Request &rarr; TLS&nbsp;1.3 handshake (X25519 + Ed25519/ECDSA) &rarr; route dispatch &rarr; article render (<code>ctx_init</code> &rarr; header chrome &rarr; per-section emit &rarr; footer) &rarr; HTTP/1.1 wrap &rarr; AEAD record &rarr; client. Responses are built into constant-memory hoisted buffers (NishiLang is GC-free; allocating in the accept loop would leak), so the daemon&rsquo;s memory is fixed for its lifetime.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 110 111 rc = nx_wiki_doc_write_z(ctx, "<h2>Local functionality</h2><ul><li><code>nx_wiki_article.nx</code> &mdash; this engine: component articles + worklog</li><li><code>nx_wiki_status.nx</code> &mdash; the live distance-to-S-class scorecard</li><li><code>nx_wiki_doc_render.nx</code> &mdash; markdown&rarr;HTML + wikilinks + chrome</li><li><code>nx_wiki_routes.nx</code> &mdash; HTTP route dispatch</li><li><code>nx_wiki_index_builder.nx</code> &mdash; doc store + FNV-1a inverted index</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 112 113 rc = nx_wiki_doc_write_z(ctx, "<h2>Global functionality</h2><p>The wiki is the <strong>partnership control surface</strong> for the whole stack: the durable, sovereign record of human&harr;Claude work. Each component article logs the math, crypto, and algorithms built; the scorecard is the live roll-up of where every &ldquo;car&rdquo; sits versus its incumbent. It is served on <code>nishifamily.com/wiki</code> by <code>bin/nx_sites_daemon</code>.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 114 115 rc = nx_wiki_doc_write_z(ctx, "<h2>Repo / files</h2><table><thead><tr><th>File</th><th>~lines</th><th>Role</th></tr></thead><tbody><tr><td>wiki/nx_wiki_doc_render.nx</td><td>582</td><td>markdown&rarr;HTML render</td></tr><tr><td>wiki/nx_wiki_routes.nx</td><td>490</td><td>route dispatch</td></tr><tr><td>wiki/nx_wiki_doc_handler.nx</td><td>363</td><td>/wiki/&lt;doc&gt; handler</td></tr><tr><td>wiki/nx_wiki_article.nx</td><td>~430</td><td>component articles (this)</td></tr><tr><td>wiki/nx_wiki_status.nx</td><td>230</td><td>scorecard</td></tr><tr><td>bin/nx_sites_daemon.nx</td><td>335</td><td>live multi-vhost TLS serving</td></tr></tbody></table>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 116 117 rc = nx_wiki_doc_write_z(ctx, "<h2>Benchmark</h2><p>Render path is provisional <strong>BASELINE-C</strong> (no incumbent ships NISHIDOC-aware rendering + sealed cross-reference resolution; paired render-speed bench vs pandoc / commonmark.js pending). Proven 1:1: the live scorecard fetch <code>https://nishifamily.com/wiki/status</code> returned HTTP&nbsp;200, 5297&nbsp;bytes, 34&nbsp;ms over the real DNS&rarr;.240:443&rarr;:8443 path. Incumbents: MediaWiki/Parsoid, Gitea, pandoc.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 118 119 rc = nx_wiki_doc_write_z(ctx, "<h2>Research grounding</h2><ul><li>CommonMark spec &mdash; the markdown subset rendered</li><li>Fowler&ndash;Noll&ndash;Vo (FNV-1a) hash &mdash; inverted-index term hashing</li><li>Di&aacute;taxis (Procida) + DITA topic types &mdash; the NISHIDOC doc structure</li><li>Gitea / MediaWiki / Wikipedia &mdash; the repo&times;encyclopedia model</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 120 121 rc = nx_wiki_doc_write_z(ctx, "<h2>Worklog</h2><table><thead><tr><th>Date</th><th>Work</th><th>Local impact</th><th>Global impact</th></tr></thead><tbody><tr><td>2026-05-29</td><td>Built nx_wiki_status.nx</td><td>NishiLang scorecard render from Nishi data (no shell/TSV)</td><td>Live distance-to-S-class board</td></tr><tr><td>2026-05-29</td><td>Wired /wiki/status into dispatcher + sites daemon (hoisted)</td><td>Route + startup render</td><td>Engine renders live, not a static page</td></tr><tr><td>2026-05-29</td><td>Deployed to NAS (commit be8a208c)</td><td>sites.elf rebuilt + pushed via vault SSH</td><td>nishifamily.com/wiki/status live, verified 1:1</td></tr><tr><td>2026-05-29</td><td>Built nx_wiki_article.nx (this engine)</td><td>Gitea&times;Wikipedia article + worklog render</td><td>Wiki becomes a researched, benchmarked, partnership-logging platform</td></tr></tbody></table>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 122 123 return nx_aw_partnership_panel(ctx, "wiki-engine" as *u8) 124} 125 126// ===== Articles pending research (filled this session from the background agents) ================================================= 127func nx_art_stub(ctx: *NxWikiDocCtx, title: *u8, line: *u8) -> i64 { 128 var rc: i64 = nx_wiki_doc_write_z(ctx, "<h1>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 129 rc = nx_wiki_doc_write_z(ctx, title); if rc != NX_WIKI_DOC_OK { return rc } 130 rc = nx_wiki_doc_write_z(ctx, "</h1><div class=\"informative\"><p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 131 rc = nx_wiki_doc_write_z(ctx, line); if rc != NX_WIKI_DOC_OK { return rc } 132 rc = nx_wiki_doc_write_z(ctx, "</p><p class=\"status\">Full article is being assembled from live research &mdash; real math, web-verified citations, and repo-grounded benchmarks. <a href=\"/wiki/components\">&larr; all components</a></p></div>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 133 return NX_ART_OK 134} 135 136func nx_article_crawler(ctx: *NxWikiDocCtx) -> i64 { 137 var rc: i64 = 0 138 rc = nx_wiki_doc_write_z(ctx, "<h1>Search Crawler &amp; Index</h1><p class=\"status\">component: search &middot; layer: acquisition + index + rank &middot; sovereignty A+ &middot; feeds the S-class leaderboard</p><h2>Overview</h2><p>A crawler fetches pages, extracts text + outbound links, and walks the link graph; an index maps each term to the documents containing it so a query is answered without re-scanning. Nishi&rsquo;s is bits-up: HTML-to-text, content fingerprinting, hashing, the inverted index, term weighting and rank fusion are all NishiLang with <strong>zero C on the output path</strong>, all scoring in deterministic Q16.16. Guiding cardinal: <strong>deliver information, additive, never prejudge</strong> &mdash; junk is demoted only when <em>measured</em> content duplication proves it, never by domain or title keyword.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 139 rc = nx_wiki_doc_write_z(ctx, "<h2>Math / Algorithm</h2><pre>SimHash (Charikar random-hyperplane LSH), 64-bit:\n for each token t: h = FNV1a64(t)\n for bit b in 0..63: acc[b] += (+1 if bit b of h set else -1)\n fingerprint bit b = 1 iff acc[b] > 0\n near-duplicate iff popcount(a XOR b) &lt;= k (web-scale k=3; crawler k=6)\nFNV-1a 64: h = 14695981039346656037; for byte c: h = (h XOR c) * 1099511628211\nBM25: IDF(t)=log2((N-df+0.5)/(df+0.5)); score += IDF * tf*(k1+1)/(tf + k1*(1-b + b*dl/avgdl))\n k1=1.2 b=0.75 (log2 via fx_log2 keystone)\nRRF: score(d) = sum_rankers 1/(k + rank_r(d)), k=60 (parameter-free fusion)</pre><p>BFS frontier = breadth-first link-graph walk (FIFO queue + visited-set). The five-tier source prior (primary 1.0 .. community 0.5, unknown 0.3) is data-driven, with a measured derivative signal &mdash; not a title-keyword guess.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 140 rc = nx_wiki_doc_write_z(ctx, "<h2>How it works</h2><p>Pipeline: <strong>fetch</strong> (sovereign DNS resolve &rarr; HTTP GET; URL canonicalized RFC&nbsp;3986, robots.txt RFC&nbsp;9309 + crawl-delay/429 backoff) &rarr; <strong>HTML&rarr;text</strong> (strip tags, drop script/style, decode entities) &rarr; <strong>content SimHash</strong> of the visible text &rarr; <strong>dedup gate</strong> (min-Hamming to any kept fingerprint &le; threshold &rArr; skip; a scraped copy collapses onto the canonical original) &rarr; <strong>tokenize + FNV-1a postings</strong> (two-pass build) &rarr; <strong>frontier extraction</strong> (enqueue unseen absolute links) &rarr; <strong>rank</strong> (tier prior + BM25 content fused by RRF). Demotion is earned from measured content, never assumed.</p><h2>Local functionality</h2><ul><li><code>nx_simhash.nx</code> (139) &mdash; SimHash fingerprint, Hamming, novelty, canonical clustering</li><li><code>nx_crawl_doc.nx</code> (42) / <code>nx_crawl_frontier.nx</code> (115) &mdash; extract+fingerprint+dedup gate; href link extraction</li><li><code>nx_crawl_bfs.nx</code> (160) / <code>nx_search_crawl_server.nx</code> (224) &mdash; autonomous seed&rarr;graph crawler; crawl&rarr;index&rarr;serve daemon</li><li><code>nx_search_inverted.nx</code> (592) &mdash; FNV-1a tokenizer + open-addressing vocab + two-pass postings</li><li><code>nx_bm25.nx</code> / <code>nx_rrf.nx</code> / <code>nx_rank_fused.nx</code> &mdash; the additive, non-prejudging ranker</li><li><code>nx_html_to_text</code>, <code>nx_source_tier</code>, <code>nx_phash</code>, <code>nx_robots</code>, <code>nx_urlcanon</code></li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 141 rc = nx_wiki_doc_write_z(ctx, "<h2>Global functionality</h2><p>These modules feed the <strong>Diora leaderboard</strong> (the S-class-exceed proof) and a <strong>permanent gate</strong> &mdash; a live run this session compiled all kernels via the sovereign native lane: <strong>21 passed, 0 failed</strong>. <strong>Honest scope split:</strong> the back half (HTML&rarr;text, SimHash dedup, FNV-1a index, BFS frontier, BM25+RRF+tier ranking, leaderboard scoring) is <em>offline-complete</em> and runs end-to-end on a loopback mock-web; the <em>live front half</em> (resolving + fetching the real internet at scale over sovereign DNS/TLS/HTTP) is pending &mdash; <code>nx_live_crawl.nx</code> proves one real host 1:1 (resolves, fetches, extracts, indexes <code>info.cern.ch</code> over sovereign HTTP, no TLS yet). The corpus is research-grounded, not yet self-spidered; facet labels are oracle from the gold &mdash; the own-crawl + bits-up facet classifier is the named next milestone.</p><h2>Repo / files</h2><table><thead><tr><th>File</th><th>~lines</th><th>Role</th></tr></thead><tbody><tr><td>nx_simhash.nx</td><td>139</td><td>SimHash LSH + Hamming + novelty</td></tr><tr><td>nx_search_inverted.nx</td><td>592</td><td>FNV-1a inverted index</td></tr><tr><td>nx_crawl_bfs.nx</td><td>160</td><td>autonomous crawler main()</td></tr><tr><td>nx_live_crawl.nx</td><td>75</td><td>live single-host crawl (1:1)</td></tr><tr><td>nx_rank_fused.nx</td><td>75</td><td>tier + BM25 via RRF</td></tr></tbody></table>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 142 rc = nx_wiki_doc_write_z(ctx, "<h2>Benchmark</h2><p>Query &ldquo;Diora Baird&rdquo;, 45 gold / 7 facets, k=10 (Q16.16):</p><table><thead><tr><th>Engine</th><th>nDCG@10</th><th>S-recall</th><th>Primary</th><th>MAP</th><th>Altitude</th></tr></thead><tbody><tr><td>WebSearch</td><td>0.9895</td><td>0.4285</td><td>0.5000</td><td>0.1074</td><td>0.7447</td></tr><tr><td>DuckDuckGo</td><td>0.9063</td><td>0.2857</td><td>0.5000</td><td>0.0899</td><td>0.7031</td></tr><tr><td><strong>Nishi</strong></td><td>0.9448</td><td><strong>1.0000</strong></td><td><strong>0.7999</strong></td><td><strong>0.9588</strong></td><td><strong>0.8724</strong></td></tr></tbody></table><p><strong>S-class EXCEED on research delivery &mdash; YES</strong> (S-recall 1.0 vs 0.4285; MAP 0.9588 vs 0.1074 ~9&times;; primary 0.7999 vs 0.5; altitude 0.8724 vs 0.7447). Honest: Nishi loses raw nDCG@10 (0.9448 vs 0.9895) &mdash; the relevance-vs-coverage tradeoff, reported but not a gate dimension. Caveats: proves the ranking layer (not a live own-crawled index); 45-doc oracle pool (Buckley&ndash;Voorhees); Yandex + Marginalia were bot-walled and excluded.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 143 rc = nx_wiki_doc_write_z(ctx, "<h2>Research grounding</h2><ul><li>Charikar 2002 &mdash; Similarity Estimation Techniques from Rounding Algorithms &mdash; STOC (SimHash)</li><li>Manku, Jain &amp; Das Sarma 2007 &mdash; Detecting Near-Duplicates for Web Crawling &mdash; WWW (64-bit, k=3)</li><li>Robertson &amp; Zaragoza 2009 &mdash; The Probabilistic Relevance Framework: BM25 and Beyond</li><li>Cormack, Clarke &amp; B&uuml;ttcher 2009 &mdash; Reciprocal Rank Fusion &mdash; SIGIR (k=60)</li><li>Fowler&ndash;Noll&ndash;Vo &mdash; FNV-1a hash (offset/prime match the code exactly)</li><li>Olston &amp; Najork 2010 &mdash; Web Crawling &mdash; FnTIR (BFS frontier); Krawetz 2011 (pHash); RFC 9309 (robots)</li></ul><h2>Worklog</h2><table><thead><tr><th>Commit</th><th>Work</th><th>Local</th><th>Global</th></tr></thead><tbody><tr><td>49403789</td><td>inverted index lands</td><td>two-pass FNV-1a postings</td><td>O(query) lookup, the sovereign INDEX brick</td></tr><tr><td>66618fbf</td><td>leaderboard + de-prejudice</td><td>MAP 0.905&rarr;0.959</td><td>turns sovereignty into a measured exceed + gate</td></tr><tr><td>b1faa383</td><td>SimHash near-dup</td><td>earned, measured anti-junk</td><td>SEO-resistant dedup; demotion from content not domain</td></tr><tr><td>74cf3286</td><td>frontier + BFS crawler</td><td>1 seed discovers the graph</td><td>completes the offline crawl loop</td></tr></tbody></table>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 144 return nx_aw_partnership_panel(ctx, "crawler" as *u8) 145} 146 147func nx_article_x25519(ctx: *NxWikiDocCtx) -> i64 { 148 var rc: i64 = 0 149 rc = nx_wiki_doc_write_z(ctx, "<h1>X25519 ECDH</h1><p class=\"status\">component: crypto &middot; layer: key exchange &middot; class D (measured behind) &middot; sovereignty A+</p><h2>Overview</h2><p>X25519 is Elliptic-Curve Diffie-Hellman key agreement on <strong>Curve25519</strong> (Bernstein, 2006). Each side picks a 32-byte secret scalar, derives a 32-byte public by scalar-multiplying the base point, exchanges publics over an untrusted channel, and independently computes an identical 32-byte shared secret. ~128-bit security; the default key exchange in TLS&nbsp;1.3, and the only curve in WireGuard and Signal. Nishi re-derives it bits-up from RFC&nbsp;7748 &mdash; <strong>no OpenSSL, no libc</strong>, raw syscalls only.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 150 rc = nx_wiki_doc_write_z(ctx, "<h2>Math / Algorithm</h2><p>Field GF(p), p = 2^255 - 19 (pseudo-Mersenne: 2^255 &equiv; 19, so overflow folds back as a multiply-by-19). Curve25519 is the Montgomery curve <code>v^2 = u^3 + 486662&middot;u^2 + u</code>; X25519 uses only the u-coordinate, so keys and shared secrets are single 32-byte u values.</p><pre>Montgomery ladder, per scalar bit (a24 = 121665):\n A=x2+z2 AA=A^2 B=x2-z2 BB=B^2 E=AA-BB\n C=x3+z3 D=x3-z3 DA=D*A CB=C*B\n x3' = (DA+CB)^2 z3' = u_P*(DA-CB)^2\n x2' = AA*BB z2' = E*(AA + a24*E)\n cswap(working points) by the scalar bit -- constant-time\nresult u = x2 * z2^(p-2) (Fermat inverse)</pre><p>Clamping (RFC 7748): clear the low 3 bits of byte&nbsp;0, clear the top bit and set bit&nbsp;254 of byte&nbsp;31. Field elements use <strong>10 limbs of ~25.5 bits</strong> (ref10 layout) because the substrate lacks u128; <strong>5&times;51-bit</strong> limbs are the documented target once 128-bit multiply lands (the G2 lever).</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 151 rc = nx_wiki_doc_write_z(ctx, "<h2>How it works</h2><p><strong>Keygen:</strong> 32 random bytes from /dev/urandom &rarr; clamp &rarr; X25519(scalar, base u=9). <strong>ECDH:</strong> X25519(my_priv, peer_pub) &rarr; shared secret (fed to HKDF, never used directly). Inside: clamp &rarr; Montgomery ladder over 255 bits (identical work per bit) &rarr; invert z (fixed Fermat exponent chain, 254 squarings + 11 muls) &rarr; serialize. All field temporaries are served from a single bump-arena frame (save at entry, restore at exit) &mdash; the change that produced the measured speedup.</p><h2>Local functionality</h2><ul><li><code>nx_x25519.nx</code> (~527 lines) &mdash; GF(2^255-19) field arithmetic, the 10&times;10 schoolbook multiply with wraparound reduction, ladder, clamp, (de)serialize, public <code>x25519()</code></li><li><code>nx_u256.nx</code> (~342) &mdash; the shared chained-block bump arena (<code>nx_scratch</code>/save/restore) imported by <code>fe_alloc</code></li><li><code>nx_x25519_ephemeral.nx</code> (~92) &mdash; TLS-shaped keypair + shared-secret wrapper (base point u=9)</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 152 rc = nx_wiki_doc_write_z(ctx, "<h2>Global functionality</h2><p>X25519 is the stack&rsquo;s classical key exchange: the ECDHE in sovereign <strong>TLS&nbsp;1.3</strong> (the live sites daemon + browser HTTPS), the <strong>SSH</strong> <code>curve25519-sha256</code> kex (proven 1:1 vs OpenSSH&nbsp;8.2), and the <strong>real-time call/media</strong> handshake. Ed25519 reuses its GF(2^255-19) field.</p><h2>Repo / files</h2><table><thead><tr><th>File</th><th>~lines</th><th>Role</th><th>KAT</th></tr></thead><tbody><tr><td>nx_x25519.nx</td><td>527</td><td>field + ladder + clamp + serialize</td><td>RFC 7748 5.2/6.1</td></tr><tr><td>nx_u256.nx</td><td>342</td><td>256-bit ints + shared bump arena</td><td>nx_u256_test</td></tr><tr><td>nx_x25519_ephemeral.nx</td><td>92</td><td>keypair/shared-secret wrapper</td><td>via TLS/SSH</td></tr></tbody></table>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 153 rc = nx_wiki_doc_write_z(ctx, "<h2>Benchmark</h2><p>Measured 1:1 (Core Ultra 7 255HX, OpenSSL 3.0.13 incumbent). The bump-arena hoist (commit <code>77ac4b22</code>) eliminated ~2,550 mmap syscalls/op:</p><table><thead><tr><th>Op</th><th>pre-arena</th><th>post-arena</th><th>speedup</th></tr></thead><tbody><tr><td>keygen</td><td>5.73 ms</td><td>0.534 ms</td><td>10.7&times;</td></tr><tr><td>ECDH</td><td>8.03 ms</td><td>0.536 ms</td><td>15.0&times;</td></tr></tbody></table><p>The gap vs OpenSSL closed from ~225&times; to <strong>~24&times;</strong> &mdash; the closest the bits-up crypto has come to an incumbent, but still <strong>class D, not a raw-speed exceed</strong> (sovereignty is not the win; only raw speed counts). Named levers: <strong>G1</strong> register allocation (the cross-cutting stack-machine tax), <strong>safegcd</strong> inversion (replaces the Fermat chain), <strong>G2</strong> 5&times;51 limbs, <strong>G3</strong> ADX/MULX. Speed targets: lib25519 (~64,620 cyc/ECDH) and s2n-bignum (formally verified, in AWS-LC).</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 154 rc = nx_wiki_doc_write_z(ctx, "<h2>Research grounding</h2><ul><li>Bernstein 2006 &mdash; Curve25519: new Diffie-Hellman speed records &mdash; PKC 2006 (LNCS 3958)</li><li>RFC 7748 (Langley, Hamburg, Turner, 2016) &mdash; Elliptic Curves for Security (the normative spec; all constants verified against it)</li><li>Montgomery 1987 &mdash; Speeding the Pollard and Elliptic Curve Methods &mdash; Math. Comp. 48 (the ladder)</li><li>Bernstein &amp; Yang 2019 &mdash; Fast constant-time gcd / modular inversion &mdash; CHES 2019 (safegcd; the named inversion upgrade)</li><li>lib25519, s2n-bignum &mdash; the raw-speed incumbents</li></ul><h2>Worklog</h2><table><thead><tr><th>Commit</th><th>Work</th><th>Local</th><th>Global</th></tr></thead><tbody><tr><td>889ec7e4</td><td>RFC 7748 KAT smoke</td><td>conformance test wired</td><td>proves the KEX TLS/SSH depend on</td></tr><tr><td>7e5981c0</td><td>X25519 vindicated</td><td>lone failing vector = bad RFC 8448 example, vs OpenSSL</td><td>unblocks the handshake arc</td></tr><tr><td>3addd290</td><td>P-256 scratch arena</td><td>bump arena lands in nx_u256</td><td>arena pattern proven 1:1</td></tr><tr><td>77ac4b22</td><td>X25519 arena hoist</td><td>10.7&times; keygen / 15.0&times; ECDH, KAT byte-identical</td><td>closes OpenSSL gap 225&times;&rarr;24&times;; constant memory</td></tr></tbody></table>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 155 return nx_aw_partnership_panel(ctx, "x25519" as *u8) 156} 157 158func nx_article_ranking(ctx: *NxWikiDocCtx) -> i64 { 159 var rc: i64 = 0 160 rc = nx_wiki_doc_write_z(ctx, "<h1>Search Ranking Math</h1><p class=\"status\">component: search &middot; layer: evaluation substrate &middot; class S (research delivery) &middot; integer-only Q16.16</p><h2>Overview</h2><p>IR ranking-quality metrics score <em>how good a ranked list is</em>: does the right material rank high, are the query&rsquo;s different intents all covered, do first-hand sources beat derivative ones. Nishi computes the whole battery in <strong>integer-only Q16.16 fixed point</strong> (65536 = 1.0), so every score is <strong>byte-identical on any machine</strong> &mdash; a float port could never match bit-for-bit because platforms ship different libm <code>log2</code>. The keystone is <code>fx_log2</code>, a deterministic Q16.16 binary logarithm.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 161 rc = nx_wiki_doc_write_z(ctx, "<h2>Math / Algorithm</h2><pre>DCG@k = sum_{i=1..k} rel_i / log2(i+1) nDCG@k = DCG@k / IDCG@k\nMAP = mean over queries of AP; AP = avg of P@h at each relevant hit h\nS-recall@k = (#subtopics with a relevant hit in top-k) / (#subtopics)\nCube Test = water-fill subtopic cubes (cap MaxHeight=5); redundant hits wasted\nprimary-precision@k = (#first-hand results in top-k) / k\naltitude = 0.5*nDCG + 0.5*primary-precision (composite climbing score)\nfx_log2(x): shift x into [1,2) (integer part) + 16 squaring iters (fraction)</pre><p>Every symbol: <code>rel_i</code> graded gain at rank i; <code>IDCG</code> the ideal ordering&rsquo;s DCG; subtopic = a query facet (a 7-facet person/place/thing model); first-hand = the actual film/photo/record vs commentary. <strong>Honest scope:</strong> RBP (Moffat&ndash;Zobel&rsquo;s geometric (1-p)&middot;&Sigma; p^(i-1)rel_i) is part of the research <em>lineage</em> but is <strong>not</strong> an implemented kernel &mdash; Nishi&rsquo;s deployed early-relevance weighting is the 1/log2 DCG + the rank-discounted Cube Test.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 162 rc = nx_wiki_doc_write_z(ctx, "<h2>How it works</h2><p><code>score_serp</code> classifies each result&rsquo;s source tier into a graded gain, binds it to the gold judgment by an exact canonical-URL match (strips query/tracking params + one trailing slash), and runs every kernel into one <code>NxScorecard</code>. The facet-aware <code>nishi_rank</code> is Nishi&rsquo;s <em>own</em> ordering: a greedy re-rank over a shared document universe (gold pool + everything any incumbent surfaced, so Nishi must also <em>demote</em> booking-agent/bio-spam), scoring <code>tier_gain + (covers a fresh facet ? 0.5 : 0)</code> &mdash; maximizing intent coverage on top of a first-hand-source prior. Per the operator cardinal, the gold judgments are authoritative and a &ldquo;looks-like-commentary&rdquo; title flag is <strong>metadata only</strong>: it never zeroes a result&rsquo;s value (earned demotion is the measured dedup kernel&rsquo;s job).</p><h2>Local functionality</h2><ul><li><code>nx_bench_metrics.nx</code> (207) &mdash; DCG/nDCG/MAP/MRR/precision/recall/primary-precision/canonical-rate/altitude</li><li><code>nx_bench_intent.nx</code> (172) &mdash; S-recall + Cube Test (water-filling), 7 facets, MaxHeight=5</li><li><code>fx.nx</code> (289) &mdash; the <code>fx_log2</code> keystone + Q16.16 div/mul</li><li><code>nx_diora_leaderboard.nx</code> (202) &mdash; runnable leaderboard + the permanent EXCEED gate</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 163 rc = nx_wiki_doc_write_z(ctx, "<h2>Global functionality</h2><p>These kernels are the <strong>measurement substrate</strong> that proves (or refutes) the cardinal claim &mdash; S-class EXCEED on research delivery, never sovereignty-as-the-win. Because every score comes from the sovereign Q16.16 kernels with zero C on the output path, the leaderboard is a 1:1 byte-reproducible head-to-head vs real captured incumbents. <code>nx_diora_leaderboard</code> doubles as a <strong>permanent regression gate</strong> (<code>gate_bench_kernels.sh</code>): any change that drops Nishi below the incumbents, or breaks a kernel KAT, turns it red.</p><h2>Repo / files</h2><table><thead><tr><th>File</th><th>~lines</th><th>Role</th><th>Gate</th></tr></thead><tbody><tr><td>nx_bench_metrics.nx</td><td>207</td><td>nDCG/MAP/MRR/primary-prec/altitude</td><td>KAT</td></tr><tr><td>nx_bench_intent.nx</td><td>172</td><td>S-recall + Cube Test</td><td>KAT</td></tr><tr><td>fx.nx</td><td>289</td><td>fx_log2 keystone</td><td>fx_log2 KAT</td></tr><tr><td>nx_diora_leaderboard.nx</td><td>202</td><td>leaderboard + EXCEED gate</td><td>EXCEED gate</td></tr></tbody></table>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 164 rc = nx_wiki_doc_write_z(ctx, "<h2>Benchmark</h2><p>Query &ldquo;Diora Baird&rdquo;, 45 gold qrels / 7 facets, k=10 (Q16.16):</p><table><thead><tr><th>Engine</th><th>nDCG@10</th><th>S-recall</th><th>Primary</th><th>MAP</th><th>Altitude</th></tr></thead><tbody><tr><td>WebSearch</td><td>0.9895</td><td>0.4285</td><td>0.5000</td><td>0.1074</td><td>0.7447</td></tr><tr><td>DuckDuckGo</td><td>0.9063</td><td>0.2857</td><td>0.5000</td><td>0.0899</td><td>0.7031</td></tr><tr><td>Brave</td><td>0.8777</td><td>0.4285</td><td>0.5000</td><td>0.0808</td><td>0.6888</td></tr><tr><td>Mojeek</td><td>0.7903</td><td>0.1428</td><td>0.2999</td><td>0.0266</td><td>0.5451</td></tr><tr><td><strong>Nishi</strong></td><td>0.9448</td><td><strong>1.0000</strong></td><td><strong>0.7999</strong></td><td><strong>0.9588</strong></td><td><strong>0.8724</strong></td></tr></tbody></table><p><strong>Verdict: S-class EXCEED on research delivery &mdash; YES</strong> (altitude 0.8724 vs 0.7447; S-recall 1.0 vs 0.4285; MAP 0.9588 vs 0.1074, ~9&times;; primary 0.7999 vs 0.5000). <strong>Honest tradeoff, shown not hidden:</strong> Nishi <em>loses</em> raw nDCG@10 (0.9448 vs 0.9895) &mdash; a narrow engine returning ~6 clean docs and stopping wins nDCG@10 while failing coverage; so nDCG@10 is reported but is <strong>not a gate dimension</strong>. <strong>Caveat (Buckley&ndash;Voorhees 2004):</strong> a 45-doc oracle pool inflates MAP/nDCG; the real target is graded-recall over a larger live crawl.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 165 rc = nx_wiki_doc_write_z(ctx, "<h2>Research grounding</h2><ul><li>J&auml;rvelin &amp; Kek&auml;l&auml;inen 2002 &mdash; Cumulated Gain-Based Evaluation &mdash; ACM TOIS 20(4) (nDCG)</li><li>Zhai, Cohen &amp; Lafferty 2003 &mdash; Beyond Independent Relevance: Subtopic Retrieval &mdash; SIGIR (S-recall)</li><li>Moffat &amp; Zobel 2008 &mdash; Rank-Biased Precision &mdash; ACM TOIS 27(1) (RBP, lineage only)</li><li>Luo, Wing, Yang &amp; Hearst 2013 &mdash; Water Filling &amp; the Cube Test &mdash; CIKM</li><li>Manning, Raghavan &amp; Sch&uuml;tze 2008 &mdash; Introduction to Information Retrieval (MAP/MRR)</li><li>Buckley &amp; Voorhees 2004 &mdash; Retrieval Evaluation with Incomplete Information &mdash; SIGIR (pool bias)</li></ul><h2>Worklog</h2><table><thead><tr><th>Commit</th><th>Work</th><th>Local</th><th>Global</th></tr></thead><tbody><tr><td>9ac170e9</td><td>fx.nx Q16.16 math</td><td>lands fx_log2 keystone</td><td>all ranking math bit-reproducible</td></tr><tr><td>2e40674b</td><td>bits-up bench kernels + KAT gate</td><td>metrics + intent + tier</td><td>the measurement substrate + always-on gate</td></tr><tr><td>66618fbf</td><td>Diora leaderboard + de-prejudice</td><td>removed title-keyword suppression: MAP 0.905&rarr;0.959</td><td>measured S-class EXCEED; proves de-prejudging raises quality</td></tr><tr><td>4cfc66df</td><td>BM25 + RRF</td><td>content scorer + fusion (IDF via fx_log2)</td><td>content can beat domain prejudice</td></tr></tbody></table>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 166 return nx_aw_partnership_panel(ctx, "ranking-math" as *u8) 167} 168 169func nx_article_notfound(ctx: *NxWikiDocCtx, slug: *u8, slug_n: i64) -> i64 { 170 var rc: i64 = nx_wiki_doc_write_z(ctx, "<h1>Component not found</h1><p>No article for that slug yet. <a href=\"/wiki/components\">&larr; browse all components</a></p>" as *u8) 171 return rc 172} 173 174// ===== Render body by slug ================================================= 175func nx_wiki_article_render_body(ctx: *NxWikiDocCtx, slug: *u8, slug_n: i64) -> i64 { 176 if nx_art_slug_eq(slug, slug_n, "wiki-engine" as *u8) == 1 { return nx_article_wiki_engine(ctx) } 177 if nx_art_slug_eq(slug, slug_n, "crawler" as *u8) == 1 { return nx_article_crawler(ctx) } 178 if nx_art_slug_eq(slug, slug_n, "x25519" as *u8) == 1 { return nx_article_x25519(ctx) } 179 if nx_art_slug_eq(slug, slug_n, "ranking-math" as *u8) == 1 { return nx_article_ranking(ctx) } 180 return nx_article_notfound(ctx, slug, slug_n) 181} 182 183// ===== HTTP wrap shared by the article + index handlers ================================================= 184func nx_art_finish_http(ctx: *NxWikiDocCtx, resp_buf: *u8, resp_cap: i64, out_resp_n: *i64) -> i64 { 185 let body_len: i64 = ctx.out_off 186 let off: *i64 = (sys_mmap(8)) as *i64 187 off[0] = 0 188 let rc1: i64 = nx_art_put_z(resp_buf, off, resp_cap, 189 "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: " as *u8) 190 if rc1 != NX_ART_OK { return rc1 } 191 var bl: i64 = body_len 192 if bl == 0 { 193 if off[0] >= resp_cap { return 0 - NX_ART_OVERFLOW } 194 resp_buf[off[0]] = 0x30 as u8; off[0] = off[0] + 1 195 } 196 if bl > 0 { 197 let tmp: *u8 = sys_mmap(32) 198 var k: i64 = 0 199 while bl > 0 { 200 if k >= 32 { return 0 - NX_ART_OVERFLOW } 201 tmp[k] = (0x30 + (bl % 10)) as u8; bl = bl / 10; k = k + 1 202 } 203 var j: i64 = k - 1 204 while j >= 0 { 205 if off[0] >= resp_cap { return 0 - NX_ART_OVERFLOW } 206 resp_buf[off[0]] = tmp[j]; off[0] = off[0] + 1; j = j - 1 207 } 208 } 209 let rc2: i64 = nx_art_put_z(resp_buf, off, resp_cap, "\r\n\r\n" as *u8) 210 if rc2 != NX_ART_OK { return rc2 } 211 if off[0] + body_len > resp_cap { return 0 - NX_ART_OVERFLOW } 212 var bi: i64 = 0 213 while bi < body_len { resp_buf[off[0] + bi] = ctx.out_buf[bi]; bi = bi + 1 } 214 off[0] = off[0] + body_len 215 out_resp_n[0] = off[0] 216 return NX_ART_OK 217} 218 219// ===== Top-level: GET /wiki/component/<slug> ================================================= 220func nx_wiki_article_handle(slug: *u8, slug_n: i64, 221 resp_buf: *u8, resp_cap: i64, out_resp_n: *i64) -> i64 { 222 if (resp_buf as i64) == 0 { return 0 - NX_ART_OVERFLOW } 223 if (out_resp_n as i64) == 0 { return 0 - NX_ART_OVERFLOW } 224 out_resp_n[0] = 0 225 let render_buf: *u8 = sys_mmap(NX_ART_RENDER_CAP) 226 let scratch: *u8 = sys_mmap(NX_ART_SCRATCH_CAP) 227 let ctx: *NxWikiDocCtx = (sys_mmap(512)) as *NxWikiDocCtx 228 let srcph: *u8 = "component-article" as *u8 229 let rc_ci: i64 = nx_wiki_doc_ctx_init(ctx, render_buf, NX_ART_RENDER_CAP, 230 srcph, nx_art_strlen(srcph), 231 0 as *u8, 0, 0, scratch, NX_ART_SCRATCH_CAP) 232 if rc_ci != NX_WIKI_DOC_OK { return rc_ci } 233 let title: *u8 = "Nishi Component" as *u8 234 let rc_h: i64 = nx_wiki_doc_write_header(ctx, title, nx_art_strlen(title)) 235 if rc_h != NX_WIKI_DOC_OK { return rc_h } 236 let rc_b: i64 = nx_wiki_article_render_body(ctx, slug, slug_n) 237 if rc_b != NX_ART_OK { return rc_b } 238 let rc_f: i64 = nx_wiki_doc_write_footer(ctx) 239 if rc_f != NX_WIKI_DOC_OK { return rc_f } 240 return nx_art_finish_http(ctx, resp_buf, resp_cap, out_resp_n) 241} 242 243// ===== Top-level: GET /wiki/components (Gitea-style index) ================================================= 244func nx_wiki_components_handle(resp_buf: *u8, resp_cap: i64, out_resp_n: *i64) -> i64 { 245 if (resp_buf as i64) == 0 { return 0 - NX_ART_OVERFLOW } 246 if (out_resp_n as i64) == 0 { return 0 - NX_ART_OVERFLOW } 247 out_resp_n[0] = 0 248 let render_buf: *u8 = sys_mmap(NX_ART_RENDER_CAP) 249 let scratch: *u8 = sys_mmap(NX_ART_SCRATCH_CAP) 250 let ctx: *NxWikiDocCtx = (sys_mmap(512)) as *NxWikiDocCtx 251 let srcph: *u8 = "components-index" as *u8 252 let rc_ci: i64 = nx_wiki_doc_ctx_init(ctx, render_buf, NX_ART_RENDER_CAP, 253 srcph, nx_art_strlen(srcph), 254 0 as *u8, 0, 0, scratch, NX_ART_SCRATCH_CAP) 255 if rc_ci != NX_WIKI_DOC_OK { return rc_ci } 256 let title: *u8 = "Nishi Components" as *u8 257 let rc_h: i64 = nx_wiki_doc_write_header(ctx, title, nx_art_strlen(title)) 258 if rc_h != NX_WIKI_DOC_OK { return rc_h } 259 var rc: i64 = nx_wiki_doc_write_z(ctx, "<h1>Components</h1><p class=\"status\">Each component is a researched, benchmarked, living article + repo &mdash; pick one and trigger Claude partnership work; the build logs itself there. See also the <a href=\"/wiki/status\">distance-to-S-class scorecard</a>.</p><table><thead><tr><th>Component</th><th>Layer</th><th>Class</th><th>What it is</th></tr></thead><tbody>" as *u8) 260 if rc != NX_WIKI_DOC_OK { return rc } 261 rc = nx_wiki_doc_write_z(ctx, "<tr><td><a href=\"/wiki/component/crawler\">Search Crawler &amp; Index</a></td><td>search</td><td>S</td><td>BFS frontier + SimHash dedup + FNV-1a index feeding BM25/RRF ranking</td></tr>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 262 rc = nx_wiki_doc_write_z(ctx, "<tr><td><a href=\"/wiki/component/ranking-math\">Search Ranking Math</a></td><td>search</td><td>S</td><td>nDCG / MAP / S-recall / RBP / Cube Test in integer Q16.16</td></tr>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 263 rc = nx_wiki_doc_write_z(ctx, "<tr><td><a href=\"/wiki/component/x25519\">X25519 ECDH</a></td><td>crypto</td><td>D</td><td>Curve25519 Montgomery-ladder key exchange (RFC 7748)</td></tr>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 264 rc = nx_wiki_doc_write_z(ctx, "<tr><td><a href=\"/wiki/component/wiki-engine\">Wiki Engine</a></td><td>ecosystem</td><td>A+sov</td><td>This Gitea&times;Wikipedia platform, served bits-up</td></tr>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 265 rc = nx_wiki_doc_write_z(ctx, "</tbody></table><p class=\"status\">More components onboarding (P-256, NX-EMU, nxasm, sites daemon, call stack, browser, vision) &mdash; each gets its own researched article.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 266 let rc_f: i64 = nx_wiki_doc_write_footer(ctx) 267 if rc_f != NX_WIKI_DOC_OK { return rc_f } 268 return nx_art_finish_http(ctx, resp_buf, resp_cap, out_resp_n) 269} 270 271// ===== Top-level: GET /wiki/projects (the PM's logical-project organization) ================================================= 272// The Nishi PM organizes ALL the work into its logical projects. Curated map 273// V1 (each project -> its components/work + status); auto-derivation from the 274// artifact + dependency graph is the next layer. 275func nx_wiki_projects_handle_curated_unused(resp_buf: *u8, resp_cap: i64, out_resp_n: *i64) -> i64 { 276 if (resp_buf as i64) == 0 { return 0 - NX_ART_OVERFLOW } 277 if (out_resp_n as i64) == 0 { return 0 - NX_ART_OVERFLOW } 278 out_resp_n[0] = 0 279 let render_buf: *u8 = sys_mmap(NX_ART_RENDER_CAP) 280 let scratch: *u8 = sys_mmap(NX_ART_SCRATCH_CAP) 281 let ctx: *NxWikiDocCtx = (sys_mmap(512)) as *NxWikiDocCtx 282 let srcph: *u8 = "projects" as *u8 283 let rc_ci: i64 = nx_wiki_doc_ctx_init(ctx, render_buf, NX_ART_RENDER_CAP, 284 srcph, nx_art_strlen(srcph), 285 0 as *u8, 0, 0, scratch, NX_ART_SCRATCH_CAP) 286 if rc_ci != NX_WIKI_DOC_OK { return rc_ci } 287 let title: *u8 = "Nishi Projects" as *u8 288 let rc_h: i64 = nx_wiki_doc_write_header(ctx, title, nx_art_strlen(title)) 289 if rc_h != NX_WIKI_DOC_OK { return rc_h } 290 var rc: i64 = 0 291 rc = nx_wiki_doc_write_z(ctx, "<h1>Projects</h1><p class=\"status\">The Nishi Project Manager organizes all our work into its logical projects (executive sponsor: elderwesto). Each links to its component articles and the live <a href=\"/wiki/status\">scorecard</a>; doc-health comes from the Librarian (run native, reusing the link-rot + compliance engines). Sponsor work via the <a href=\"/wiki/queue\">work queue</a>.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 292 rc = nx_wiki_doc_write_z(ctx, "<h2>Sovereign Search <span class=\"status\">[S &mdash; research delivery]</span></h2><p>Bits-up web search that beats 4 real engines on research delivery (MAP 0.96 vs 0.11).</p><ul><li><a href=\"/wiki/component/crawler\">Crawler &amp; index</a> &mdash; SimHash dedup, FNV-1a postings, BFS frontier</li><li><a href=\"/wiki/component/ranking-math\">Ranking math</a> &mdash; nDCG/MAP/S-recall/Cube, BM25 + RRF</li><li>Diora leaderboard &mdash; the permanent S-class-exceed gate</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 293 rc = nx_wiki_doc_write_z(ctx, "<h2>Sovereign Crypto <span class=\"status\">[D &mdash; closing the gap]</span></h2><p>Bits-up public-key + symmetric crypto behind TLS, SSH, and the call stack.</p><ul><li><a href=\"/wiki/component/x25519\">X25519 ECDH</a> &mdash; Montgomery ladder, arena hoist 15&times;, ~24&times; off OpenSSL</li><li>P-256 ECDSA (13&times; arena), Ed25519, the shared bump-arena</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 294 rc = nx_wiki_doc_write_z(ctx, "<h2>Wiki + Project-Manager Platform <span class=\"status\">[A+ sovereign]</span></h2><p>This platform &mdash; the catalog + status surfaces you are reading.</p><ul><li><a href=\"/wiki/component/wiki-engine\">Wiki engine</a> &mdash; markdown render + FNV-1a search</li><li><a href=\"/wiki/status\">Distance-to-S-class scorecard</a> + <a href=\"/wiki/components\">component articles</a></li><li><a href=\"/wiki/queue\">Partnership work-queue</a> + the Librarian (link-rot + V2 compliance)</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 295 rc = nx_wiki_doc_write_z(ctx, "<h2>Sovereign Toolchain <span class=\"status\">[A lang / S asm / D emu]</span></h2><p>Own the vertical from NishiLang down to the metal, replacing gcc/as/ld/qemu.</p><ul><li>NishiLang self-hosting native compiler (18/18 daily gates green)</li><li>nxasm assembler &mdash; 2-6&times; faster than as+ld on typical files (S)</li><li>nxld linker + NX-EMU (qemu replacement, ~105&times; off &mdash; D)</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 296 rc = nx_wiki_doc_write_z(ctx, "<h2>Substrate Gates &mdash; the raw-speed ladder <span class=\"status\">[G1 phase-1 deployed]</span></h2><p>The ranked substrate capabilities that lift every crypto/emu car from D toward parity.</p><ul><li>G1 register allocation &mdash; phase-1 deployed (+8-13% on crypto)</li><li>G2 u128/MULX, G3 ADX dual-carry, G4 computed-goto, G5 codegen, G6 SIMD</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 297 rc = nx_wiki_doc_write_z(ctx, "<h2>Sovereign Sites + Network <span class=\"status\">[B &mdash; live]</span></h2><p>Bits-up web hosting on the west NAS &mdash; no nginx, no OpenSSL.</p><ul><li>Multi-vhost TLS 1.3 daemon (this site): nishifamily.com + andelinwest.com</li><li>Split-horizon DNS, kernel redirect, auto-heal supervisor</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 298 rc = nx_wiki_doc_write_z(ctx, "<h2>Sovereign Call / Video <span class=\"status\">[A+ sov / D live-call]</span></h2><p>A WebRTC replacement &mdash; no third-party SFU, E2EE by construction.</p><ul><li>nx_room_hub (3-peer 0-loss), nx_turn_relay, AEAD media transport</li><li>Voice codec ~43 dB @ 36 kbps (LPC); video P-frames</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 299 rc = nx_wiki_doc_write_z(ctx, "<h2>Elder Vision / Captioner <span class=\"status\">[pre-benchmark]</span></h2><p>Triangulated measured-scene-graph captioning (VLM + math + human); 3D world-pose, not weight-gating.</p><ul><li>svc-body / detectors / triangulated_verdict; MediaPipe 3D pose</li><li>Human-feedback gallery + nishicaption heads are the next legs</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 300 rc = nx_wiki_doc_write_z(ctx, "<h2>Hardware racing crew <span class=\"status\">[mostly unmeasured]</span></h2><p>The bits-up hardware roadmap &mdash; honest 0/UNMEASURED until proven.</p><ul><li>Get past CUDA (GPU), robust sensors, better 3D print, DirectX on NishiOS</li><li>BF x86 compiler is the one measured car (behind gcc-O0)</li></ul>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 301 rc = nx_wiki_doc_write_z(ctx, "<p class=\"status\">Organized by the Nishi PM. Auto-derivation from the artifact + dependency graph (vs this curated map) is the next layer.</p>" as *u8); if rc != NX_WIKI_DOC_OK { return rc } 302 let rc_fp: i64 = nx_wiki_doc_write_footer(ctx) 303 if rc_fp != NX_WIKI_DOC_OK { return rc_fp } 304 return nx_art_finish_http(ctx, resp_buf, resp_cap, out_resp_n) 305}