code wiki / _hdl_build / nx_ciq_publish.nx

nx_ciq_publish.nx source

↩ module page · 135 lines · 12469 B

1// nx_ciq_publish.nx -- the CIQ PUBLISH bundle: parses the finished analysis OUT of the sovereign seg_store 2// into THREE readability modalities (operator: "parse out s class exceed for human and ai and machine 3// readability"), all authored byte-by-byte (no 3rd-party format): 4// HUMAN -> knowledge/staging/ciq_report.html (exec summary + portfolio table + per-market links + 5// honest caveats; wiki-guard-compatible: epoch= freshness footer, no placeholder, no dead links; 6// family-gated dest marker /wiki/family/ciq.html = opaque-gate behind family level) 7// AI -> knowledge/staging/ciq_report_ai.md (semantic markdown: per-market claim+evidence, LLM-ingestible) 8// MACHINE -> knowledge/staging/ciq_report_machine.nxr (sovereign labeled records, one per (market,entity), 9// deterministic + parseable; the faithfulness substrate the S-class gate cross-checks vs the store) 10// Reads markets registry + per-market placements/gaps. The actual outward push is routed through the 11// publisher (pub_submit, family-gated dest) as a separate governed step. 100% sovereign. license_tier: ORIGINAL expect_exit: 0 12import "nx_syscalls.nx" 13import "nx_canon_cid.nx" 14import "nx_seg_store.nx" 15import "nx_uxf_decode.nx" 16const CP_MAGIC_1024: i64 = 1024 17const CP_MAGIC_262144: i64 = 262144 18 19const CP_STORE: *u8 = "knowledge/store/ciq-" 20const CP_HUMAN: *u8 = "knowledge/staging/ciq_report.html" 21const CP_AI: *u8 = "knowledge/staging/ciq_report_ai.md" 22const CP_MACHINE: *u8 = "knowledge/staging/ciq_report_machine.nxr" 23 24func pw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 25func pn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); 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} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 } 26func p_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 } 27func p_pint(s: *u8) -> i64 { var v: i64=0; var i: i64=0; var go: i64=1; while go==1 { let c: i64=s[i]; if c>=48 { if c<=57 { v=v*10+(c-48); i=i+1 } else { go=0 } } else { go=0 } } return v } 28func p_field(dk: *i64, dv: *i64, nf: i64, name: *u8) -> *u8 { var f: i64=0; while f<nf { if p_streq(dk[f] as *u8, name)==1 { return dv[f] as *u8 } f=f+1 } return 0 as *u8 } 29func p_split(buf: *u8, delim: i64, out: *i64, maxn: i64) -> i64 { var n: i64=0; var i: i64=0; var intok: i64=0; while buf[i]!=(0 as u8) { let c: i64=buf[i]; if c==delim { buf[i]=0 as u8; intok=0 } else { if intok==0 { if n<maxn { out[n]=(buf as i64)+i; n=n+1 } intok=1 } } i=i+1 } return n } 30func p_copy(src: *u8, dst: *u8) -> i64 { var i: i64=0; while src[i]!=(0 as u8){ dst[i]=src[i]; i=i+1 } dst[i]=0 as u8; return i } 31func bcat(buf: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ buf[off+i]=s[i]; i=i+1 } return off+i } 32func bint(buf: *u8, off: i64, v: i64) -> i64 { var m: i64=v; var o: i64=off; if m<0{ buf[o]=45 as u8; o=o+1; m=0-m } let t: *u8=sys_mmap(32); 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} var i: i64=0; while i<k{ buf[o+i]=t[k-1-i]; i=i+1 } return o+k } 33func p_key(buf: *u8, market: *u8, suffix: *u8) -> i64 { var o: i64=0; o=ss_cat(buf,o,"ciq:" as *u8); o=ss_cat(buf,o,market); o=ss_cat(buf,o,":" as *u8); o=ss_cat(buf,o,suffix); buf[o]=0 as u8; return o } 34 35func p_write(path: *u8, buf: *u8, n: i64) -> i64 { let fd: i64 = sys_openat_wr(path, 420); if fd < 0 { return 0 - 1 } sys_write(fd, buf, n); sys_close(fd); return n } 36 37func main() -> i64 { 38 let gp: *i64 = sys_mmap(8) as *i64 39 let gl: *i64 = sys_mmap(8) as *i64 40 let dk: *i64 = sys_mmap(8 * 16) as *i64 41 let dv: *i64 = sys_mmap(8 * 16) as *i64 42 let mbuf: *u8 = sys_mmap(CP_MAGIC_1024) 43 if ss_get(CP_STORE, "ciq:markets" as *u8, gp, gl) != 1 { pw("CIQ-PUBLISH RED reason=no-markets\n" as *u8); sys_exit(1); return 1 } 44 let mnf0: i64 = canon_decode(gp[0] as *u8, gl[0], dk, dv, 16) 45 p_copy(p_field(dk, dv, mnf0, "list" as *u8), mbuf) 46 let markets: *i64 = sys_mmap(8 * 16) as *i64 47 let nm: i64 = p_split(mbuf, 44, markets, 16) 48 let epoch: i64 = sys_now_realtime_sec() 49 50 let H: *u8 = sys_mmap(CP_MAGIC_262144); var ho: i64 = 0 // human html 51 let A: *u8 = sys_mmap(CP_MAGIC_262144); var ao: i64 = 0 // ai markdown 52 let M: *u8 = sys_mmap(CP_MAGIC_262144); var mo: i64 = 0 // machine records 53 54 // ---- HUMAN header ---- 55 ho = bcat(H, ho, "<!doctype html><html><head><meta charset=\"utf-8\"><title>Nishi Competitive-Intelligence Quadrant &mdash; Portfolio</title>\n" as *u8) 56 ho = bcat(H, ho, "<style>body{font-family:monospace;max-width:880px;margin:24px auto;color:#111}table{border-collapse:collapse}td,th{border:1px solid #ccc;padding:4px 8px}.v{color:#c0392b}</style></head><body>\n" as *u8) 57 ho = bcat(H, ho, "<p style=\"color:#888\">Family-level access (opaque-gated) &middot; /wiki/family/ciq.html</p>\n" as *u8) 58 ho = bcat(H, ho, "<h1>Nishi Competitive-Intelligence Quadrant &mdash; Portfolio</h1>\n" as *u8) 59 ho = bcat(H, ho, "<p>Computed end-to-end by the sovereign Nishi CI team (census &rarr; analyst &rarr; placer &rarr; visualizer) over cited capability matrices held in the sovereign seg_store. Gartner-style Magic Quadrant per market; axes are no-float permil 0..1000 (x=Vision, y=Execute).</p>\n" as *u8) 60 ho = bcat(H, ho, "<h2>Portfolio &mdash; where Nishi stands per market</h2>\n<table><tr><th>Market</th><th>Nishi quadrant</th><th>Execute</th><th>Vision</th><th>Gap to Leader</th></tr>\n" as *u8) 61 62 // ---- AI header ---- 63 ao = bcat(A, ao, "# Nishi Competitive-Intelligence Quadrant -- Portfolio (AI-readable)\n\n" as *u8) 64 ao = bcat(A, ao, "Source: sovereign Nishi CI team (census->analyst->placer). Gartner MQ per market; permil 0..1000; x=Vision y=Execute. Every figure traces to the seg_store (machine artifact cross-checks it).\n\n## Per-market placements\n\n" as *u8) 65 66 // ---- MACHINE header ---- 67 mo = bcat(M, mo, "# nx-records v1 (sovereign labeled records; field=value; one per market+entity)\n" as *u8) 68 mo = bcat(M, mo, "meta kind=ciq-portfolio epoch=" as *u8); mo = bint(M, mo, epoch); mo = bcat(M, mo, " markets=" as *u8); mo = bint(M, mo, nm); mo = bcat(M, mo, "\n" as *u8) 69 70 // ---- per market ---- 71 var mi: i64 = 0 72 while mi < nm { 73 let mk: *u8 = markets[mi] as *u8 74 // entities 75 let kb: *u8 = sys_mmap(256); p_key(kb, mk, "meta" as *u8) 76 let ent: *i64 = sys_mmap(8 * 16) as *i64 77 var N: i64 = 0 78 if ss_get(CP_STORE, kb, gp, gl) == 1 { 79 let mnf: i64 = canon_decode(gp[0] as *u8, gl[0], dk, dv, 16) 80 let ebuf: *u8 = sys_mmap(CP_MAGIC_1024); p_copy(p_field(dk, dv, mnf, "entities" as *u8), ebuf) 81 N = p_split(ebuf, 44, ent, 16) 82 } 83 // nishi gap 84 var exg: i64 = 0; var vsg: i64 = 0 85 let gk: *u8 = sys_mmap(256); p_key(gk, mk, "gap:nishi" as *u8) 86 if ss_get(CP_STORE, gk, gp, gl) == 1 { let gnf: i64 = canon_decode(gp[0] as *u8, gl[0], dk, dv, 16); exg = p_pint(p_field(dk, dv, gnf, "ex_gap" as *u8)); vsg = p_pint(p_field(dk, dv, gnf, "vis_gap" as *u8)) } 87 88 ao = bcat(A, ao, "### " as *u8); ao = bcat(A, ao, mk); ao = bcat(A, ao, "\n\n" as *u8) 89 90 // per entity placements 91 var nq: *u8 = "?" as *u8; var nex: i64 = 0; var nvs: i64 = 0 92 var e: i64 = 0 93 while e < N { 94 let suf: *u8 = sys_mmap(128); var so: i64 = 0; so = ss_cat(suf, so, "placement:" as *u8); so = ss_cat(suf, so, ent[e] as *u8); suf[so] = 0 as u8 95 let pk: *u8 = sys_mmap(256); p_key(pk, mk, suf) 96 if ss_get(CP_STORE, pk, gp, gl) == 1 { 97 let pnf: i64 = canon_decode(gp[0] as *u8, gl[0], dk, dv, 16) 98 let q: *u8 = p_field(dk, dv, pnf, "quadrant" as *u8) 99 let ex: i64 = p_pint(p_field(dk, dv, pnf, "execute" as *u8)) 100 let vs: i64 = p_pint(p_field(dk, dv, pnf, "vision" as *u8)) 101 // machine record (the faithfulness substrate) 102 mo = bcat(M, mo, "rec market=" as *u8); mo = bcat(M, mo, mk); mo = bcat(M, mo, " entity=" as *u8); mo = bcat(M, mo, ent[e] as *u8) 103 mo = bcat(M, mo, " execute=" as *u8); mo = bint(M, mo, ex); mo = bcat(M, mo, " vision=" as *u8); mo = bint(M, mo, vs); mo = bcat(M, mo, " quadrant=" as *u8); mo = bcat(M, mo, q); mo = bcat(M, mo, "\n" as *u8) 104 // ai line 105 ao = bcat(A, ao, "- " as *u8); ao = bcat(A, ao, ent[e] as *u8); ao = bcat(A, ao, ": execute=" as *u8); ao = bint(A, ao, ex); ao = bcat(A, ao, " vision=" as *u8); ao = bint(A, ao, vs); ao = bcat(A, ao, " -> " as *u8); ao = bcat(A, ao, q); ao = bcat(A, ao, " [evidence: seg_store ciq:" as *u8); ao = bcat(A, ao, mk); ao = bcat(A, ao, ":score:" as *u8); ao = bcat(A, ao, ent[e] as *u8); ao = bcat(A, ao, "]\n" as *u8) 106 if p_streq(ent[e] as *u8, "nishi" as *u8) == 1 { nq = q; nex = ex; nvs = vs } 107 } 108 e = e + 1 109 } 110 ao = bcat(A, ao, "\nNishi gap to Leader: +" as *u8); ao = bint(A, ao, exg); ao = bcat(A, ao, " execute, +" as *u8); ao = bint(A, ao, vsg); ao = bcat(A, ao, " vision\n\n" as *u8) 111 112 // human table row 113 ho = bcat(H, ho, "<tr><td><a href=\"ciq_" as *u8); ho = bcat(H, ho, mk); ho = bcat(H, ho, "_quadrant.html\">" as *u8); ho = bcat(H, ho, mk); ho = bcat(H, ho, "</a></td><td class=\"v\">" as *u8); ho = bcat(H, ho, nq); ho = bcat(H, ho, "</td><td>" as *u8); ho = bint(H, ho, nex); ho = bcat(H, ho, "</td><td>" as *u8); ho = bint(H, ho, nvs); ho = bcat(H, ho, "</td><td>+" as *u8); ho = bint(H, ho, exg); ho = bcat(H, ho, "E / +" as *u8); ho = bint(H, ho, vsg); ho = bcat(H, ho, "V</td></tr>\n" as *u8) 114 mi = mi + 1 115 } 116 117 ho = bcat(H, ho, "</table>\n" as *u8) 118 ho = bcat(H, ho, "<h2>The one finding</h2>\n<p>Across <b>every</b> market, Nishi's gap to Leader is <b>pure execution, never vision</b> — its vision is Leader-grade everywhere (the sovereignty/integrity DNA); the only lever is scale and maturity. Portfolio directive: <b>convert the vision lead into mature, scaled execution.</b></p>\n" as *u8) 119 ho = bcat(H, ho, "<h2>Honest scope (no overclaim)</h2>\n<p>Placements are measured on Nishi's integrity/sovereignty-weighted capability scorecards. Where market-standard scale/viability is included (see Connect), the brand-new entrant is a Visionary, not a blanket Leader — incumbents lead on user-base, revenue and brand, which most of these scorecards do not weight. Competitor cells without cited research are excluded and counted against data-completeness; nothing is fabricated.</p>\n" as *u8) 120 ho = bcat(H, ho, "<footer style=\"color:#888;border-top:1px solid #ccc;margin-top:16px;padding-top:8px\">Authored by the sovereign Nishi CI team. epoch=" as *u8); ho = bint(H, ho, epoch); ho = bcat(H, ho, " &middot; readability: human + ai + machine &middot; figures cross-checked against the seg_store.</footer>\n</body></html>\n" as *u8) 121 122 ao = bcat(A, ao, "## The one finding\n\nAcross every market, Nishi's gap to Leader is PURE EXECUTION, never vision (vision >= 500 = Leader-grade everywhere). Directive: convert the vision lead into mature, scaled execution.\n\n## Honest scope\n\nIntegrity/sovereignty-weighted scorecards; with market-standard scale included Nishi is a Visionary not a blanket Leader; no fabrication (uncited competitor cells excluded).\n\nepoch=" as *u8); ao = bint(A, ao, epoch); ao = bcat(A, ao, "\n" as *u8) 123 mo = bcat(M, mo, "finding gap_axis=execute_only vision_leader_grade=all_markets\n" as *u8) 124 125 let hr: i64 = p_write(CP_HUMAN, H, ho) 126 let ar: i64 = p_write(CP_AI, A, ao) 127 let mr: i64 = p_write(CP_MACHINE, M, mo) 128 129 pw("=== nx_ciq_publish -- 3-modality bundle parsed from seg_store ===\n" as *u8) 130 pw("HUMAN " as *u8); pw(CP_HUMAN); pw(" " as *u8); pn(hr); pw("B\n" as *u8) 131 pw("AI " as *u8); pw(CP_AI); pw(" " as *u8); pn(ar); pw("B\n" as *u8) 132 pw("MACHINE " as *u8); pw(CP_MACHINE); pw(" " as *u8); pn(mr); pw("B\n" as *u8) 133 if hr > 0 { if ar > 0 { if mr > 0 { pw("CIQ-PUBLISH verdict=GREEN (all 3 modalities emitted; family-gated dest /wiki/family/ciq.html)\n" as *u8); sys_exit(0); return 0 } } } 134 pw("CIQ-PUBLISH verdict=RED (a modality failed to write)\n" as *u8); sys_exit(1); return 1 135}