code wiki / (root) / nx_compare_serve.nx

nx_compare_serve.nx

buildroot/runtime/nx_compare_serve.nx

3104 B51 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind servicetopic compare
docsdependenciesstructsconstsfunctions

about

nx_compare_serve.nx -- fork-exec backend for the `nishi_compare` MCP tool. v2 SINGLE-SOURCE: serves the EXACT file the public REST endpoint serves (sites/nishifamily/compare/... relative to the tools-API CWD = nishihost) -- there is NO second copy to drift (operator 2026-07-09: no frozen snapshots). Domain map: "index" -> the comparison index api.json, "openapi" -> the OpenAPI 3.1 contract, else -> <domain>/api.json. No re-measurement here (measurement happens in nx_compare_regen against the buildroot source tree, gate-checked); this serves the latest gate-GREEN generation. SECURITY: the caller-supplied domain is sanitized to [a-z]{1,40} ONLY -> no path traversal / injection. Absent file -> structured JSON error envelope. license_tier: ORIGINAL expect_exit:0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_compare_serve.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main san_ok err_json wc sys_mmap sys_write w sys_write ↻ sys_exit sys_mmap ↻ scopy streq sys_openat_rd sys_read sys_close sys_write ↻

structs

none

consts

9const K_MAGIC_1048576: i64 = 1048576

functions

11func w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 1: err_json calls 1: sys_write
12func wc(fd: i64, code: i64) -> i64 { let t: *u8 = sys_mmap(2); t[0] = code as u8; sys_write(fd, t, 1); return 0 }
called by 1: err_json calls 2: sys_mmapsys_write
13func scopy(dst: *u8, doff: i64, src: *u8) -> i64 { var i: i64 = 0; while src[i] != (0 as u8) { dst[doff+i] = src[i]; i = i + 1 } return doff + i }
called by 1: main
14func 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 }
called by 1: main
15func san_ok(s: *u8) -> i64
called by 1: main
21func err_json(code: *u8, dom: *u8) -> i64
called by 1: main calls 2: wcw
29func main(argc: i64, argv: *i64) -> i64