code wiki / (root) / nx_atlas_frontdoor.nx

nx_atlas_frontdoor.nx source

↩ module page · 102 lines · 8872 B

1// nx_atlas_frontdoor -- regenerates the /compare/atlas hub page from the LIVE ecograph_full store. 2// Kills the hand-baked-staleness debt: stats (nodes/edges/god-Ca/leaves) are computed from the graph 3// on every run, never typed. THREE modes: 4// (argless) -> ATOMIC SELF-DEPLOY to the docroot (write .new + sys_renameat hot-swap). This is what 5// the clock dispatches (clk_dispatch_run execs argless) -> supervised, managed cadence. 6// json -> live ecosystem-size stats as JSON (the MCP/agent surface, pinned in tool_allowlist). 7// html -> the hub HTML to stdout (manual piping / inspection). 8// license_tier: ORIGINAL 9import "nx_syscalls.nx" 10import "nx_eco_graph.nx" 11 12func cslen(s: *u8) -> i64 { var n:i64=0; while s[n]!=(0 as u8){n=n+1} return n } 13func cw(fd: i64, s: *u8) -> i64 { sys_write(fd, s, cslen(s)); return 0 } 14func cn(fd: i64, v: i64) -> i64 { let b:*u8=sys_mmap(24); 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; 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 j:i64=0; while j<k{b[j]=t[k-1-j];j=j+1} sys_write(fd,b,k); return 0 } 15 16func emit_html(fd: i64, nc: i64, ec: i64, god: i64, leaves: i64) -> i64 { 17 cw(fd, "<!doctype html><html lang=en><head><meta charset=utf-8><meta name=viewport content='width=device-width,initial-scale=1'><title>Nishi Ecosystem Atlas</title><style>\n" as *u8) 18 cw(fd, ":root{--bg:#0d1018;--pan:#141a26;--ink:#e8ecf6;--dim:#93a0b8;--line:#26304a;--ac:#c9a0ff;--grn:#7ee0a0;--amb:#e6a86a}\n" as *u8) 19 cw(fd, "*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.6 -apple-system,Segoe UI,system-ui,sans-serif}\n" as *u8) 20 cw(fd, ".wrap{max-width:920px;margin:0 auto;padding:28px 22px 80px}\n" as *u8) 21 cw(fd, ".crumb{font-size:.82rem;color:var(--dim);margin-bottom:14px}a{color:var(--ac);text-decoration:none}a:hover{text-decoration:underline}\n" as *u8) 22 cw(fd, "h1{font-size:30px;margin:0 0 4px;color:var(--ink)}.tag{color:var(--dim);font-size:1.05rem;margin:0 0 24px}\n" as *u8) 23 cw(fd, ".grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:14px;margin:18px 0 30px}\n" as *u8) 24 cw(fd, ".tile{background:var(--pan);border:1px solid var(--line);border-radius:14px;padding:16px 18px}\n" as *u8) 25 cw(fd, ".tnum{font-size:30px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1}.tlab{color:var(--dim);font-size:.8rem;margin-top:6px}\n" as *u8) 26 cw(fd, "h2{font-size:12px;letter-spacing:.13em;text-transform:uppercase;color:var(--ac);margin:34px 0 12px;border-bottom:1px solid var(--line);padding-bottom:7px}\n" as *u8) 27 cw(fd, "p{color:#cdd6e6}.k{color:var(--ink);font-weight:600}\n" as *u8) 28 cw(fd, ".layers{display:grid;gap:8px}.layer{background:var(--pan);border:1px solid var(--line);border-radius:12px;padding:12px 16px}.layer b{color:var(--grn)}\n" as *u8) 29 cw(fd, ".links a{display:inline-block;background:var(--pan);border:1px solid var(--line);border-radius:10px;padding:9px 15px;margin:4px 8px 4px 0;color:var(--ink);font-weight:600}\n" as *u8) 30 cw(fd, ".foot{margin-top:40px;color:var(--dim);font-size:.8rem;border-top:1px solid var(--line);padding-top:14px}\n" as *u8) 31 cw(fd, "</style></head><body><div class=wrap>\n" as *u8) 32 cw(fd, "<p class=crumb><a href='/'>Nishi Family</a> &rsaquo; <a href='/compare'>Compare</a> &rsaquo; Atlas</p>\n" as *u8) 33 cw(fd, "<h1>Nishi Ecosystem Atlas</h1>\n" as *u8) 34 cw(fd, "<p class=tag>The living map of the sovereign stack &mdash; every organ, its roots to god and its children, tied to maturity, activity, and the team. Bits-up, zero third-party, generated fresh from the sovereign store on every load.</p>\n" as *u8) 35 cw(fd, "<div class=grid>\n" as *u8) 36 cw(fd, "<div class=tile><div class=tnum>" as *u8); cn(fd, nc); cw(fd, "</div><div class=tlab>organs (graph nodes)</div></div>\n" as *u8) 37 cw(fd, "<div class=tile><div class=tnum>" as *u8); cn(fd, ec); cw(fd, "</div><div class=tlab>dependency edges (imports)</div></div>\n" as *u8) 38 cw(fd, "<div class=tile><div class=tnum>" as *u8); cn(fd, god); cw(fd, "</div><div class=tlab>importers of nx_syscalls &mdash; the god node</div></div>\n" as *u8) 39 cw(fd, "<div class=tile><div class=tnum>" as *u8); cn(fd, leaves); cw(fd, "</div><div class=tlab>entry-points &amp; leaves (Ca=0)</div></div>\n" as *u8) 40 cw(fd, "</div>\n" as *u8) 41 cw(fd, "<h2>What the Atlas is</h2>\n<div class=layers>\n" as *u8) 42 cw(fd, "<div class=layer><b>The graph is the skeleton</b> &mdash; every organ, walked from real imports, with its roots-to-god (ancestry to <span class=k>nx_syscalls</span>) and its children (what depends on it).</div>\n" as *u8) 43 cw(fd, "<div class=layer><b>The cards are the flesh</b> &mdash; each node is a card that is <span class=k>documentation AND a callable unit at once</span>: the same object is its wiki page, its API contract, its git history, and the thing the swarm runs. Doc and unit never drift.</div>\n" as *u8) 44 cw(fd, "<div class=layer><b>The wiki is the surface</b> &mdash; cards render as auto-regenerating, no-link-rot, walkable pages from the sovereign seg_store &mdash; <a href='/compare/atlas/card'>browse all " as *u8); cn(fd, nc); cw(fd, " organ cards &rarr;</a>.</div>\n" as *u8) 45 cw(fd, "<div class=layer><b>The swarm is the pulse</b> &mdash; the fabric ties in so a card lights up when its organ is running, and compositions of cards become workflows the swarm executes.</div>\n" as *u8) 46 cw(fd, "</div>\n" as *u8) 47 cw(fd, "<h2>Name an outcome &rarr; the atlas plans it</h2>\n" as *u8) 48 cw(fd, "<p>Because every card carries its ancestors (what it needs) and descendants (what it enables), naming an outcome decomposes it into the cards required, <span class=k>sees the missing ones as gaps to fill</span>, and returns a maturity-aware plan and an exploding view of how the parts come together &mdash; from a butter churn to a kit car to a building.</p>\n" as *u8) 49 cw(fd, "<h2>Explore</h2>\n<div class=links>" as *u8) 50 cw(fd, "<a href='/compare/atlas/tree'>Lineage tree (SVG visual)</a>" as *u8) 51 cw(fd, "<a href='/compare/atlas/graph'>Text index (all organs)</a>" as *u8) 52 cw(fd, "<a href='/compare/atlas/card'>Card wiki &mdash; every organ card</a>" as *u8) 53 cw(fd, "<a href='/compare/livingdocs'>Living-docs SOTA</a>" as *u8) 54 cw(fd, "<a href='/compare'>Compare &amp; maturity plane</a>" as *u8) 55 cw(fd, "<a href='/git'>Sovereign git</a><a href='/wiki'>Wiki</a></div>\n" as *u8) 56 cw(fd, "<p class=foot>Measured live from the sovereign seg_store (" as *u8); cn(fd, nc) 57 cw(fd, "-node whole-tree walk, " as *u8); cn(fd, ec); cw(fd, " edges) &mdash; regenerated by nx_atlas_frontdoor on cadence, not hand-baked. Honest note: maturity is graded separately from feature-presence &mdash; the atlas shows what is <em>earned</em> (live, callable, hardened), never inflated. Served bits-up by the Nishi stack &mdash; TLS 1.3, zero third-party web server, no JavaScript.</p>\n" as *u8) 58 cw(fd, "</div></body></html>\n" as *u8) 59 return 0 60} 61 62func main(argc: i64, argv: *i64) -> i64 { 63 let g: *EcoGraph = eg_load("knowledge/store/ecograph_full" as *u8) 64 if g == 0 as *EcoGraph { cw(2, "nx_atlas_frontdoor: eg_load failed\n" as *u8); return 1 } 65 let nc: i64 = g.node_count 66 let ec: i64 = g.edge_count 67 var god: i64 = 0 68 var leaves: i64 = 0 69 var i: i64 = 0 70 while i < nc { 71 let ca: i64 = eg_ca(g, i) 72 if ca > god { god = ca } 73 if ca == 0 { leaves = leaves + 1 } 74 i = i + 1 75 } 76 77 if argc >= 2 { 78 let a1: *u8 = argv[1] as *u8 79 if a1[0] == (106 as u8) { 80 cw(1, "{\"nodes\":" as *u8); cn(1, nc) 81 cw(1, ",\"edges\":" as *u8); cn(1, ec) 82 cw(1, ",\"god_ca\":" as *u8); cn(1, god) 83 cw(1, ",\"leaves\":" as *u8); cn(1, leaves) 84 cw(1, ",\"source\":\"ecograph_full\",\"generator\":\"nx_atlas_frontdoor\"}\n" as *u8) 85 return 0 86 } 87 if a1[0] == (104 as u8) { emit_html(1, nc, ec, god, leaves); return 0 } 88 } 89 90 // argless (incl clock dispatch) = ATOMIC SELF-DEPLOY: write .new then renameat hot-swap 91 let np: *u8 = "sites/nishifamily/compare/atlas/index.html.new" as *u8 92 let lp: *u8 = "sites/nishifamily/compare/atlas/index.html" as *u8 93 let fd: i64 = sys_openat_wr(np, 0x1a4) 94 if fd < 0 { cw(2, "nx_atlas_frontdoor: deploy open failed\n" as *u8); return 1 } 95 emit_html(fd, nc, ec, god, leaves) 96 sys_close(fd) 97 let rr: i64 = sys_renameat(np, lp) 98 if rr != 0 { cw(2, "nx_atlas_frontdoor: deploy rename failed\n" as *u8); return 1 } 99 cw(1, "{\"deployed\":\"/compare/atlas\",\"nodes\":" as *u8); cn(1, nc) 100 cw(1, ",\"edges\":" as *u8); cn(1, ec); cw(1, ",\"leaves\":" as *u8); cn(1, leaves); cw(1, "}\n" as *u8) 101 return 0 102}