nx_compare_tool_register.nx source
↩ module page · 54 lines · 5693 B
1// nx_compare_tool_register.nx -- register the NISHI COMPARE API into the sovereign tool registry (operator 2026-07-08:
2// "get it to state of the art api level"). The registry IS what nishifamily.com/api/tools + /mcp tools/list serve, so
3// registration = DISCOVERABILITY for any engaging model: they SEE that a measured, liar-killed software-comparison API
4// exists and exactly how to call it (versioned JSON endpoints + an OpenAPI 3.1 contract). Mirrors nx_codereview_tool_register:
5// DISCOVERY here; making it a native /mcp tools/call target stays a SEPARATE fail-closed step (tool_allowlist/backends +
6// cap, operator-gated). Writes the CWD registry (knowledge/toolreg-); flipping the LIVE NAS registry = run this on the NAS
7// (CWD nishihost). Idempotent (reg_put additive). Verifies by READBACK, not claim. expect_exit: 0 license_tier: ORIGINAL
8import "nx_tool_registry.nx"
9
10func cr_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
11func cr_putn(v: i64) -> i64 {
12 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
13 var m: i64 = v
14 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
15 let d: *u8 = sys_mmap(24); var k: i64 = 0
16 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
17 let o: *u8 = sys_mmap(24); var i: i64 = 0
18 while i < k { o[i] = d[k - 1 - i]; i = i + 1 }
19 sys_write(1, o, k)
20 return 0
21}
22func cr_reg1(name: *u8, desc: *u8, invoke: *u8, status: *u8) -> i64 {
23 let w: i64 = tool_register(name, desc, invoke, status)
24 let p: *i64 = sys_mmap(8) as *i64
25 let l: *i64 = sys_mmap(8) as *i64
26 let g: i64 = tool_get(name, p, l)
27 cr_puts(" " as *u8); cr_puts(name); cr_puts(" put-rc=" as *u8); cr_putn(w); cr_puts(" readback=" as *u8)
28 if g == 1 { if l[0] > 0 { cr_puts("OK len=" as *u8); cr_putn(l[0]); cr_puts("\n" as *u8); return 1 } }
29 cr_puts("MISSING -- REGISTER FAILED\n" as *u8)
30 return 0
31}
32
33func main() -> i64 {
34 cr_puts("=== nx_compare_tool_register -- Nishi Compare API into the discovery registry (knowledge/toolreg-) ===\n" as *u8)
35 var ok: i64 = 0
36 ok = ok + cr_reg1("nishi_compare" as *u8,
37 "sovereign, mechanically-measured, LIAR-KILLED software comparisons (Nishi vs the field) as versioned JSON. Two views per domain: a head-to-head MATRIX (who leads each capability axis, Nishi + named competitors) and a frontier RADAR (where the 2025/26 research is moving). Every Nishi cell is verified against real organ source on disk (no self-grading); competitor cells are documented capability presence; a faked win fails the build. Machine-readable domains: search (vs Mojeek/Brave/Google/Marginalia), webscraping (vs Firecrawl/Apify/Bright Data/Zyte), deepresearch (vs Perplexity/DeepResearcher/Tongyi/deep-searcher)." as *u8,
38 "GET https://nishifamily.com/compare/api.json (self-describing index + _links) . GET /compare/{domain}/api.json (matrix: competitors[], axes[{label,nishi,cells[],note}], tally{coverage,exceeds,present,absent}; domain in search|webscraping|deepresearch) . GET /compare/openapi.json (OpenAPI 3.1 contract). Versioned JSON v:1 over TLS 1.3; codes 0=No 1=Yes 2=Best 3=Part." as *u8,
39 "GREEN (live + external-verified; 3 machine-readable matrices coverage 812/705/666 permille; OpenAPI 3.1; JSON-schema valid; data self-assembles from knowledge/compare/*.matrix via nx_swcompare_matrix + nx_swcompare_hub)" as *u8)
40 ok = ok + cr_reg1("nishi_compare_index" as *u8,
41 "the Nishi Compare INDEX: lists every published comparison (matrix + radar) with its coverage, page, machine-readable data endpoint (where available), and HATEOAS _links (self, openapi, html). The single discovery entry point for the whole /compare surface -- 9+ comparisons across search, scraping, deep-research, computational math, office, mail, CRM, LLM stack, and video codec." as *u8,
42 "GET https://nishifamily.com/compare/api.json -> {v,api:nishi-compare,resource:index,comparisons[{domain,title,kind,page,radar,data,summary}],_links{self,openapi,html}}" as *u8,
43 "GREEN (live JSON; index self-generated by nx_swcompare_hub json from knowledge/compare/registry; data links emitted only where a machine-readable matrix exists, checked on disk)" as *u8)
44 ok = ok + cr_reg1("nishi_compare_regen" as *u8,
45 "SELF-REFRESH the Nishi Compare surface: re-MEASURES every matrix domain from live organ source on disk (gate-checked -- a RED measurement is never published) and ATOMICALLY republishes its JSON+HTML (renameat hot-swap, no torn read). Because the serve tool reads the same docroot, one call refreshes BOTH the /mcp tool output and the public REST endpoints, freshening generated_unix. Args are PINNED (a caller cannot redirect the writes)." as *u8,
46 "over /mcp: tools/call name=nishi_compare_regen arguments={argv:[]} -> re-measure + atomic republish; returns the verdict GREEN + published/fails counts" as *u8,
47 "GREEN (proven: a /mcp call advanced generated_unix, published=6 fails=0; matrices-only on the NAS -- hub/openapi are laptop-published by design to avoid clobbering the multi-session registry)" as *u8)
48 cr_puts("registered+readback " as *u8); cr_putn(ok); cr_puts(" / 3\n" as *u8)
49 cr_puts("NOTE: writes the CWD registry (knowledge/toolreg-). Run on the NAS (CWD nishihost) to flip the LIVE\n" as *u8)
50 cr_puts(" nishifamily.com/api/tools registry. Native /mcp tools/call execution = a separate cap-gated step.\n" as *u8)
51 if ok == 3 { cr_puts("verdict=GREEN (Nishi Compare API + self-refresh discoverable in the sovereign tool surface)\n" as *u8); sys_exit(0); return 0 }
52 cr_puts("verdict=RED\n" as *u8)
53 sys_exit(1); return 1
54}