code wiki / (root) / nx_compare_gw.nx

nx_compare_gw.nx

buildroot/runtime/nx_compare_gw.nx

21033 B359 linesdepth 17pulls 58 transitivereach 0 importersview sourcekind servicetopic compare
docsdependenciesstructsconstsfunctions

about

nx_compare_gw.nx -- the /compare GATEWAY DAEMON (loopback HTTP): the compare surface behind the same OPAQUE login wall and the same HR access structure as /studio and /hub (operator 2026-08-27: "i can see them as the owner but then others see different levels of /compare so i can provide a client a /compare"). It sits behind sites_daemon's fail-closed `gated` reverse-proxy for /compare, mirroring the /hub -> hub_gw topology exactly, and changes NOTHING about how nx_compare_regen emits the pages -- it gates at SERVE time from knowledge/compare/access.conf, so the single-emission publish pipeline is untouched and a board's visibility is one conf row, live with no restart. THE CHAIN, all sovereign and all already proven elsewhere: olg_whoami (nx_hr_access -> hac_session_level) validates the no-cookie X-Nishi-Session token against the nishi_site_admin realm and resolves the viewer's HR LEVEL (deny-by-default: an invalid/expired token, or a valid token for someone not enrolled in HR, resolves to 0 = public) ; then cg_required(access.conf, domain) gives the board's required level ; then cg_decide serves, 404s or 403s. FAIL-CLOSED and NO-LEAK by construction: a board a viewer may not see is absent from their index bytes AND answers 404, the SAME answer a board that does not exist gives -- an anonymous visitor can never tell a gated board from a missing one, while the owner serves it. HARDENING baked in from the studio/hub post-mortems: binds 127.0.0.1 ONLY (the edge reaches it through the proxy), and sets FD_CLOEXEC on the listener so a forked child can never hold the port (the outage that survives every restart). All buffers are allocated ONCE before the accept loop and reused, and every per-request read is bounded into a reused buffer -> a flat virtual footprint. This daemon never forks. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_hr_access.nx nx_opaque_login.nx nx_compare_openapi.nx nx_compare_gw_lib.nx nx_compare_gw.nx

imports: nx_syscalls.nxnx_hr_access.nxnx_opaque_login.nxnx_compare_openapi.nxnx_compare_gw_lib.nx

imported by: nobody (leaf or entry point)

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

main sys_write sys_exit sys_mmap nxa_die sys_write ↻ sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ olg_ctx_setup olg_ctx_setup_ttl nx_uas_server_keys_load_or sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close _uas_hex_dec _uas_nib nx_csprng_fill sys_mmap ↻ nx_csprng_urandom_path sys_openat_rd ↻ sys_read ↻ sys_close ↻ nx_opq_derive_keypair sys_mmap ↻ u256_alloc

structs

none

consts

29const CGW_DOCROOT: *u8 = "/volume1/homes/elderwesto/nishihost/sites/nishifamily/compare" as *u8
30const CGW_ACCESS: *u8 = "knowledge/compare/access.conf" as *u8
33const CGW_HR: *u8 = "/volume1/homes/elderwesto/nishihost/nishi_hr-" as *u8
34const CGW_REALM: *u8 = "nishi_site_admin" as *u8
35const CGW_REALM_N: i64 = 16
36const CGW_DISP: *u8 = "Nishi Compare" as *u8
37const CGW_DISP_N: i64 = 13
39const CGW_REQ: i64 = 32768
40const CGW_CONF: i64 = 262144
41const CGW_BODY: i64 = 4194304
42const CGW_SCRATCH: i64 = 8388608
43const CGW_DENTS: i64 = 65536
44const CGW_PATH: i64 = 1024
45const CGW_TITLE: i64 = 512
46const CGW_TOK: i64 = 512
47const CGW_DOM: i64 = 128
48const CGW_REST: i64 = 512
49const CGW_STAT: i64 = 256
50const CGW_DEFAULT_STEPS: i64 = 65536
51const CGW_TCOST: i64 = 3
52const CGW_PCOST: i64 = 4
54const CGW_STMODE_OFF: i64 = 24
55const CGW_S_IFMT: i64 = 61440
56const CGW_S_IFDIR: i64 = 16384
57const CGW_S_IFREG: i64 = 32768
58const CGW_FCNTL: i64 = 72
59const CGW_FSETFD: i64 = 2
60const CGW_FD_CLOEXEC: i64 = 1
172const CGW_FEED_FILE: *u8 = "feed.xml" as *u8
173const CGW_FEED_PATH: *u8 = "/feed.xml" as *u8
174const CGW_CTYPE_RSS: *u8 = "application/rss+xml; charset=utf-8" as *u8
175const CGW_FEED_CTR_BYTES: i64 = 16 // kept + dropped, one i64 each

functions

62func cgw_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: cgw_textmain
63func cgw_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; var p: i64 = o; while s[i] != (0 as u8) { d[p] = s[i]; p = p + 1; i = i + 1 } return p }
64func cgw_catn(d: *u8, o: i64, s: *u8, n: i64) -> i64 { var i: i64 = 0; var p: i64 = o; while i < n { d[p] = s[i]; p = p + 1; i = i + 1 } return p }
called by 1: cgw_send
65func cgw_itoa(d: *u8, o: i64, v: i64) -> i64
called by 1: cgw_send calls 1: sys_mmap
78func cgw_read_file(path: *u8, out: *u8, cap: i64) -> i64
95func cgw_kind(path: *u8, stbuf: *u8) -> i64
called by 1: main calls 2: sys_fstatatscm_get_i64
102func cgw_send(cfd: i64, scratch: *u8, status: *u8, ctype: *u8, body: *u8, blen: i64) -> i64
112func cgw_text(cfd: i64, scratch: *u8, status: *u8, msg: *u8) -> i64
called by 2: cgw_feedmain calls 2: cgw_sendcgw_slen
119func cgw_index(level: i64, with_upgrade: i64, json: i64, conf: *u8, cn: i64,
176func cgw_feed(cfd: i64, scratch: *u8, level: i64, conf: *u8, cnv: i64, body: *u8, jbuf: *u8, pathb: *u8, dom: *u8) -> i64
189func main(argc: i64, argv: *i64) -> i64