code wiki / _hdl_build / nx_tenancy_gate.nx

nx_tenancy_gate.nx

buildroot/runtime/_hdl_build/nx_tenancy_gate.nx

40469 B830 linesdepth 6pulls 6 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_tenancy_gate.nx -- SOVEREIGN tenancy-orthogonality gate ORGAN (ports nx_tenancy_orthogonality_gate.sh + nx_tenancy_gate_alert.sh out of bash -- operator law: sovereign all the way up and down, no shell loops). Enforces the three-plane model (alpha=private dogfood | product=own domain | client=isolated, billable): orthogonality is DATA-isolation (realms/keys/stores), never port-exclusivity. Reads the LIVE SSOTs each cycle, checks INV-1..9, classifies findings against the acknowledged debt baseline (GREEN with known debt baselined; RED the instant NEW sprawl appears), serves the full report on 127.0.0.1:18094 (seqlock shared page + forked server -- the proven /status pattern; NO tsv, NO files as the interface), and appends NEW violations to tenancy_alerts.log. Invariants: INV-1 every served host (proxy_routes+sites) declares a plane in tenancy_planes.conf INV-3 every RUNNING nx_mgmt_api sits on a DECLARED shards.conf mgmt port (no orphan store-sharer) INV-4 client shards use their OWN keys+store (never the shared control opaque_keys/opaque_store) INV-5 a confirmed product is not a bare path on an alpha domain (products graduate to own domains) INV-6 every property_registry domain routed to :8443 has a cert row in certs/sni_certs.manifest INV-7 every manifest cert+key file exists and is non-empty INV-8 every sites.conf vhost has a domain_lifecycle.reg row (the monitored-domain list) INV-9 LIVE-EDGE EVIDENCE via the sovereign HTTPS client (fork+exec nx_https_get_cli.elf, loopback endpoint, SNI from the URL): stage!=production MUST serve the coming-soon marker (else = an unapproved go-live LEAK); stage=production must NOT (else = launch STUCK). Fetch-failure is its own finding (fetchfail), never mistaken for a leak -- an improvement over the bash gate, which could read an empty failed fetch as "no marker" = false leak. Skipped while the edge is down (selfheal owns that alarm). BOUNDED-VSZ discipline: every buffer is allocated ONCE before the loop; the hot loop performs ZERO mmap. license_tier: ORIGINAL module: nishi-core.ops.tenancy_gate

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_health_probe.nx nx_tenancy_gate.nx

imports: nx_syscalls.nxnx_health_probe.nx

imported by: nobody (leaf or entry point)

structs

none

consts

27const TG_HOME: *u8 = "/volume1/homes/elderwesto/nishihost" as *u8
28const TG_PLANES: *u8 = "/volume1/homes/elderwesto/nishihost/tenancy_planes.conf" as *u8
29const TG_ROUTES: *u8 = "/volume1/homes/elderwesto/nishihost/proxy_routes.conf" as *u8
30const TG_SHARDS: *u8 = "/volume1/homes/elderwesto/nishihost/shards.conf" as *u8
31const TG_SITES: *u8 = "/volume1/homes/elderwesto/nishihost/sites.conf" as *u8
32const TG_PRODS: *u8 = "/volume1/homes/elderwesto/nishihost/tenancy_products.list" as *u8
33const TG_PROPREG: *u8 = "/volume1/homes/elderwesto/nishihost/property_registry.conf" as *u8
34const TG_MANIF: *u8 = "/volume1/homes/elderwesto/nishihost/certs/sni_certs.manifest" as *u8
35const TG_LREG: *u8 = "/volume1/homes/elderwesto/nishihost/domain_lifecycle.reg" as *u8
36const TG_BASE: *u8 = "/volume1/homes/elderwesto/nishihost/tenancy_debt_baseline.txt" as *u8
37const TG_ALERTS: *u8 = "/volume1/homes/elderwesto/nishihost/tenancy_alerts.log" as *u8
38const TG_CLI: *u8 = "./nx_https_get_cli.elf" as *u8
39const TG_FETCH: *u8 = "/volume1/homes/elderwesto/nishihost/_scratch/tg_fetch.out" as *u8
40const TG_PORT: i64 = 18094
41const TG_CYCLE_SEC: i64 = 120
42const TG_SHSZ: i64 = 16384
43const TG_FBUF: i64 = 65536
44const TG_FETCHCAP: i64 = 131072
45const TG_FETCH_TMO_MS: i64 = 20000

functions

47func tg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: tg_ptg_contains
48func tg_p(s: *u8) -> i64 { sys_write(1, s, tg_slen(s)); return 0 }
49func tg_decw(v: i64, out: *u8) -> i64
61func tg_sappend(dst: *u8, w: i64, s: *u8) -> i64
called by 2: tg_candtg_fetch
67func tg_streq(a: *u8, b: *u8) -> i64
called by 1: tg_in_list
73func tg_atoi(s: *u8) -> i64
79func tg_contains(hay: *u8, hlen: i64, needle: *u8) -> i64
called by 1: tg_cand calls 1: tg_slen
94func tg_next_line(buf: *u8, pos: i64, end: i64) -> i64
100func tg_line_end(buf: *u8, pos: i64, end: i64) -> i64
107func tg_wsfield(buf: *u8, ls: i64, le: i64, idx: i64, out: *u8, cap: i64) -> i64
137func tg_tabfield(buf: *u8, ls: i64, le: i64, idx: i64, out: *u8, cap: i64) -> i64
163func tg_read(path: *u8, buf: *u8, cap: i64) -> i64
172func tg_list_add(list: *u8, llen: i64, s: *u8) -> i64
181func tg_in_list(list: *u8, s: *u8) -> i64
calls 1: tg_streq
193func tg_file_nonempty(path: *u8, tmp: *u8) -> i64
202func tg_cand(cand: *u8, w: i64, key: *u8, msg: *u8) -> i64
215func tg_fetch(dom: *u8) -> i64
261func tg_server(shm: *u8) -> i64
313func main() -> i64