code wiki / _hdl_build / nx_wiki_codec_status_page.nx

nx_wiki_codec_status_page.nx source

↩ module page · 127 lines · 11081 B

1// nx_wiki_codec_status_page.nx -- EMIT the sovereign-codec arc as an S-class HTML wiki page through the 2// proven sovereign page builder (nx_wiki_shell), then PUBLISH it LIVE through the guarded wrapper 3// (pub_publish): the A2 guard refuses any placeholder / un-stamped / dangling-cite / dead-link page, then 4// the proven vault+SSH push streams it ADDITIVELY to the served doc-root /wiki/codec-arc-status.html. 5// 6// WHY (operator 2026-06-18): "make sure this and everything else in parallel workstreams is getting logged 7// to the wiki for accurate live documentation thats being built out by the wiki as we work." The lessons' 8// SOURCE .md are already live in NAS wiki-content/ (daemon-ingestible); this page is the genuinely-VIEWABLE 9// capstone of the codec workstream, on the same emit->guard->push->fetch-verify loop charter/start use. 10// 11// Each milestone CITES the gate that proved it + a reproduce command (evidence resolves by re-running). 12// Freshness-stamped (epoch). Internal links only to live corpus slugs (start/charter/search/self) so the 13// guard's dead-link check passes; the lessons are referenced by name (their HTML render awaits the daemon). 14// DRY (#15): no new push/render primitive -- composes nx_wiki_shell + nx_wiki_publish. license_tier: ORIGINAL 15import "nx_syscalls.nx" 16import "nx_wiki_shell.nx" 17import "nx_wiki_publish.nx" 18 19const CS_OUT: *u8 = "web_assets/codec-arc-status.html" 20const CS_CAP: i64 = 262144 21 22func cp(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 23func cnum(v: i64) -> i64 { 24 let bb: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m } 25 let t: *u8 = sys_mmap(28); var k: i64 = 0 26 if m == 0 { t[0] = 48 as u8; k = 1 } 27 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 28 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0 29} 30func cs_codename(v: i64) -> *u8 { 31 if v == PG_ALLOW { return "ALLOW" as *u8 } 32 if v == PG_REJECT_NO_FRESHNESS { return "REJECT NO_FRESHNESS" as *u8 } 33 if v == PG_REJECT_DANGLING_CITE { return "REJECT DANGLING_CITE" as *u8 } 34 if v == PG_REJECT_DEAD_LINK { return "REJECT DEAD_LINK" as *u8 } 35 if v == PG_REJECT_PLACEHOLDER { return "REJECT PLACEHOLDER" as *u8 } 36 return "UNKNOWN" as *u8 37} 38 39func main() -> i64 { 40 let now: i64 = sys_now_realtime_sec() 41 let h: *u8 = sys_mmap(CS_CAP) 42 var w: i64 = 0 43 44 w = sh_head(h, w, "Sovereign Codec Arc \xE2\x80\x94 Live Status" as *u8, "codec-arc-status" as *u8) 45 w = sh_nav(h, w, "codec-arc-status" as *u8) 46 47 w = sh_cat(h, w, "<h1>Sovereign Codec Arc &mdash; Live Status</h1>\n" as *u8) 48 w = sh_cat(h, w, "<p class=\"fresh\">&#10227; Banked LIVE by <code>nx_wiki_codec_status_page</code> at epoch=" as *u8) 49 w = sh_catn(h, w, now) 50 w = sh_cat(h, w, " &mdash; every milestone CITES the gate that proved it and a reproduce command (evidence resolves by re-running). Regenerate to refresh.</p>\n" as *u8) 51 w = sh_cat(h, w, "<p class=\"lede\">A 100%-sovereign H.264 decoder built from the hardware rung up in NishiLang (<code>nx_cc</code>&rarr;<code>nxasm_x86</code>, no gcc, no float). We build these standard codecs <em>to learn</em> the no-float / no-GPU capability and use them ONLY as in-test-harness benchmarks. Any codec with patent or license encumbrance (H.264/AVC, HEVC) is QUARANTINED from the shipping ecosystem &mdash; the destination is a Nishi-native, patent/license-free format any user can stream and play royalty-free. ffmpeg is used as an oracle in the TEST HARNESS ONLY, never in product.</p>\n" as *u8) 52 53 w = sh_infobox_open(h, w, "Codec workstream" as *u8) 54 w = sh_infobox_row(h, w, "I-frame" as *u8, "BIT-EXACT vs ffmpeg (luma+chroma+deblock)" as *u8) 55 w = sh_infobox_row(h, w, "P-frame" as *u8, "BIT-EXACT vs ffmpeg (luma+chroma+deblock)" as *u8) 56 w = sh_infobox_row(h, w, "B-frame parse" as *u8, "GREEN (POC type-0, dual ref-lists, B mb-types)" as *u8) 57 w = sh_infobox_row(h, w, "B-frame luma" as *u8, "BIT-EXACT vs ffmpeg (589824/589824, MAXDIFF=0)" as *u8) 58 w = sh_infobox_row(h, w, "Sovereignty" as *u8, "no gcc, no float, no GPU; ffmpeg oracle in harness only" as *u8) 59 w = sh_infobox_row(h, w, "Destination" as *u8, "Nishi-native patent/license-free streaming format" as *u8) 60 w = sh_infobox_close(h, w) 61 62 w = sh_toc_open(h, w) 63 w = sh_toc_item(h, w, "milestones" as *u8, "Milestones (each cites its gate)" as *u8) 64 w = sh_toc_item(h, w, "remains" as *u8, "What remains (B-frame)" as *u8) 65 w = sh_toc_item(h, w, "lessons" as *u8, "How we got here (the lessons)" as *u8) 66 w = sh_toc_item(h, w, "evidence" as *u8, "Evidence (gates + reproduce)" as *u8) 67 w = sh_toc_close(h, w) 68 69 w = sh_section(h, w, "milestones" as *u8, "Milestones &mdash; each cites the gate that proved it" as *u8) 70 w = sh_cat(h, w, "<table><tr><th>Stage</th><th>Status</th><th>Verified result</th><th>Proving gate</th></tr>\n" as *u8) 71 w = sh_cat(h, w, "<tr><td>I-frame decode (intra 4x4/16x16/chroma, CAVLC, IDCT, deblock)</td><td><strong>BIT-EXACT</strong></td><td>luma 589824/589824 px, MAXDIFF=0 vs ffmpeg</td><td><code>nx_h264_decode_frame</code></td></tr>\n" as *u8) 72 w = sh_cat(h, w, "<tr><td>P-frame decode (MV pred, quarter-pel MC, P_Skip, P_8x8, deblock)</td><td><strong>BIT-EXACT</strong></td><td>luma 589824/589824 + chroma 294912/294912, MAXDIFF=0</td><td><code>nx_h264_pframe_recon</code></td></tr>\n" as *u8) 73 w = sh_cat(h, w, "<tr><td>P motion-vector field (row-0 P_16x16 MVs)</td><td>GREEN</td><td>12/12 MVs match ffmpeg</td><td><code>nx_h264_mv_recon_gate</code></td></tr>\n" as *u8) 74 w = sh_cat(h, w, "<tr><td>P co-located MV field (for B direct mode)</td><td>GREEN</td><td>L0 MV field matches</td><td><code>nx_h264_colmv_gate</code></td></tr>\n" as *u8) 75 w = sh_cat(h, w, "<tr><td>B-frame parse (POC type-0, dual ref-lists L0/L1, B mb-types)</td><td>GREEN</td><td>entropy walk syncs 2101/2101, num_ref 1/1</td><td><code>nx_h264_bframe_walk</code></td></tr>\n" as *u8) 76 w = sh_cat(h, w, "<tr><td>B-frame luma decode (full: parse + two-list MV + bi-pred + spatial-direct + B_8x8 + intra-in-B + dual-list in-loop deblock)</td><td><strong>BIT-EXACT</strong></td><td>luma 589824/589824 px, MAXDIFF=0, erroring MBs=0 vs ffmpeg</td><td><code>nx_h264_brecon</code></td></tr>\n" as *u8) 77 w = sh_cat(h, w, "</table>\n" as *u8) 78 w = sh_cat(h, w, "<p>The B-frame luma is now bit-exact, matching I and P. The in-loop deblock was validated by a cordon-and-widen method (score only MBs whose deblock inputs are all reconstructed) plus a pre/post snapshot; the definitive proof came from completing the frame (intra-in-B + B_8x8 recon), which drove the residual 107&rarr;0 &mdash; confirming it was 100% frontier propagation, no deblock or recon bug. A debugging-craft lesson now in the curriculum.</p>\n" as *u8) 79 80 w = sh_section(h, w, "remains" as *u8, "What remains (B-frame)" as *u8) 81 w = sh_cat(h, w, "<ul>\n" as *u8) 82 w = sh_cat(h, w, "<li><strong>B chroma</strong> &mdash; reuse the chroma motion-compensation + deblock kernels (luma is complete; chroma is the last piece for full B parity with I and P).</li>\n" as *u8) 83 w = sh_cat(h, w, "</ul>\n" as *u8) 84 85 w = sh_section(h, w, "lessons" as *u8, "How we got here (the lessons)" as *u8) 86 w = sh_cat(h, w, "<p>Every bug on this arc was banked as an S-class Nishi-Teacher lesson (machine + human educatable), live in the wiki source corpus. By slug: <code>h264-bitexact-decode</code>, <code>h264-pframe-desync-hunt</code>, <code>h264-deblock-test-harness-bug</code>, <code>debugging-craft-bframe-traps</code>, <code>h264-bframe-header-sync-trap</code>, <code>h264-deblock-vs-recon-cordon</code>; index <code>nishi-lessons</code>. Two standouts: <em>a clean end-of-stream sync is not a correct parse</em> (a missing B-slice-only flag misaligned every value yet still synced, caught only by a domain-impossible reference count); and <em>a single-pixel deblock error is propagation, not a boundary-strength bug</em> (a per-segment op that errs on one isolated sample is never the segment parameter).</p>\n" as *u8) 87 88 w = sh_section(h, w, "evidence" as *u8, "Evidence (gates + reproduce)" as *u8) 89 w = sh_cat(h, w, "<p>Each milestone resolves by RE-RUNNING its gate (the strongest evidence). Build+run any gate sovereignly:</p>\n" as *u8) 90 w = sh_cat(h, w, "<pre><code>./_offc/nx_sov_build_run.elf nx_h264_decode_frame # I-frame bit-exact\n./_offc/nx_sov_build_run.elf nx_h264_pframe_recon # P-frame bit-exact (luma+chroma+deblock)\n./_offc/nx_sov_build_run.elf nx_h264_bframe_walk # B-frame parse syncs 2101/2101\n./_offc/nx_sov_build_run.elf nx_h264_brecon # B-frame recon (95.5% pre-deblock)</code></pre>\n" as *u8) 91 w = sh_cat(h, w, "<p>The bit-exact root-cause discipline (instrument the oracle, distrust the test harness, a passing invariant is not a value-correctness proof) is documented in the lessons above and in the Nishi issue taxonomy the diagnostic engine reads.</p>\n" as *u8) 92 93 w = sh_footer(h, w, "codec-arc-status" as *u8, now) 94 w = sh_cat(h, w, "</body></html>\n" as *u8) 95 96 // write the page to disk (the publisher reads it back). 97 let fd: i64 = sys_openat_wr(CS_OUT, 0x1a4) 98 if fd < 0 { cp("ERROR: cannot open web_assets/codec-arc-status.html\n\x00" as *u8); sys_exit(1); return 1 } 99 sys_write(fd, h, w) 100 sys_close(fd) 101 cp("emitted web_assets/codec-arc-status.html bytes=\x00" as *u8); cnum(w); cp("\n\x00" as *u8) 102 103 // corpus = the live wiki slugs this page links to (furniture: start/charter/search + self). Any 104 // internal /wiki/<x>.html href outside this set -> guard DEAD_LINK. 105 let cs_ptr: *i64 = sys_mmap(8 * 16) as *i64 106 let cs_len: *i64 = sys_mmap(8 * 16) as *i64 107 cs_ptr[0] = "start" as *u8 as i64; cs_len[0] = 5 108 cs_ptr[1] = "charter" as *u8 as i64; cs_len[1] = 7 109 cs_ptr[2] = "search" as *u8 as i64; cs_len[2] = 6 110 cs_ptr[3] = "codec-arc-status" as *u8 as i64; cs_len[3] = 16 111 let ncorpus: i64 = 4 112 113 let res: *PubResult = sys_mmap(64) as *PubResult 114 cp("[PUBLISH] web_assets/codec-arc-status.html -> /wiki/codec-arc-status.html via guarded wrapper\n\x00" as *u8) 115 pub_publish(CS_OUT, "codec-arc-status" as *u8, cs_ptr, cs_len, ncorpus, 1, res) 116 cp("[PUBLISH] guard_verdict=\x00" as *u8); cp(cs_codename(res.code)); cp("\n\x00" as *u8) 117 cp("[PUBLISH] status=\x00" as *u8); cp(pub_status_name(res.status)); cp("\n\x00" as *u8) 118 cp("[PUBLISH] bytes=\x00" as *u8); cnum(res.bytes); cp("\n\x00" as *u8) 119 cp("[PUBLISH] push_invoked=\x00" as *u8); cnum(res.push_invoked); cp("\n\x00" as *u8) 120 cp("[PUBLISH] push_rc=\x00" as *u8); cnum(res.push_rc); cp("\n\x00" as *u8) 121 if res.status == PUB_PUBLISHED { 122 if res.push_rc == 0 { cp("[PUBLISH] RESULT=PUBLISHED-OK\n\x00" as *u8); sys_exit(0); return 0 } 123 cp("[PUBLISH] RESULT=PUSH-INVOKED-NONZERO-RC\n\x00" as *u8); sys_exit(1); return 1 124 } 125 cp("[PUBLISH] RESULT=NOT-PUBLISHED\n\x00" as *u8) 126 sys_exit(1); return 1 127}