code wiki / _hdl_build / nx_tenancy_gate.nx
nx_tenancy_gate.nx
buildroot/runtime/_hdl_build/nx_tenancy_gate.nx
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
imports: nx_syscalls.nxnx_health_probe.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 27 | const TG_HOME: *u8 = "/volume1/homes/elderwesto/nishihost" as *u8 |
| 28 | const TG_PLANES: *u8 = "/volume1/homes/elderwesto/nishihost/tenancy_planes.conf" as *u8 |
| 29 | const TG_ROUTES: *u8 = "/volume1/homes/elderwesto/nishihost/proxy_routes.conf" as *u8 |
| 30 | const TG_SHARDS: *u8 = "/volume1/homes/elderwesto/nishihost/shards.conf" as *u8 |
| 31 | const TG_SITES: *u8 = "/volume1/homes/elderwesto/nishihost/sites.conf" as *u8 |
| 32 | const TG_PRODS: *u8 = "/volume1/homes/elderwesto/nishihost/tenancy_products.list" as *u8 |
| 33 | const TG_PROPREG: *u8 = "/volume1/homes/elderwesto/nishihost/property_registry.conf" as *u8 |
| 34 | const TG_MANIF: *u8 = "/volume1/homes/elderwesto/nishihost/certs/sni_certs.manifest" as *u8 |
| 35 | const TG_LREG: *u8 = "/volume1/homes/elderwesto/nishihost/domain_lifecycle.reg" as *u8 |
| 36 | const TG_BASE: *u8 = "/volume1/homes/elderwesto/nishihost/tenancy_debt_baseline.txt" as *u8 |
| 37 | const TG_ALERTS: *u8 = "/volume1/homes/elderwesto/nishihost/tenancy_alerts.log" as *u8 |
| 38 | const TG_CLI: *u8 = "./nx_https_get_cli.elf" as *u8 |
| 39 | const TG_FETCH: *u8 = "/volume1/homes/elderwesto/nishihost/_scratch/tg_fetch.out" as *u8 |
| 40 | const TG_PORT: i64 = 18094 |
| 41 | const TG_CYCLE_SEC: i64 = 120 |
| 42 | const TG_SHSZ: i64 = 16384 |
| 43 | const TG_FBUF: i64 = 65536 |
| 44 | const TG_FETCHCAP: i64 = 131072 |
| 45 | const TG_FETCH_TMO_MS: i64 = 20000 |
functions
| 47 | func tg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 48 | func tg_p(s: *u8) -> i64 { sys_write(1, s, tg_slen(s)); return 0 } |
| 49 | func tg_decw(v: i64, out: *u8) -> i64 |
| 61 | func tg_sappend(dst: *u8, w: i64, s: *u8) -> i64 |
| 67 | func tg_streq(a: *u8, b: *u8) -> i64 called by 1: tg_in_list |
| 73 | func tg_atoi(s: *u8) -> i64 |
| 79 | func tg_contains(hay: *u8, hlen: i64, needle: *u8) -> i64 |
| 94 | func tg_next_line(buf: *u8, pos: i64, end: i64) -> i64 |
| 100 | func tg_line_end(buf: *u8, pos: i64, end: i64) -> i64 |
| 107 | func tg_wsfield(buf: *u8, ls: i64, le: i64, idx: i64, out: *u8, cap: i64) -> i64 |
| 137 | func tg_tabfield(buf: *u8, ls: i64, le: i64, idx: i64, out: *u8, cap: i64) -> i64 |
| 163 | func tg_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 172 | func tg_list_add(list: *u8, llen: i64, s: *u8) -> i64 |
| 181 | func tg_in_list(list: *u8, s: *u8) -> i64 calls 1: tg_streq |
| 193 | func tg_file_nonempty(path: *u8, tmp: *u8) -> i64 |
| 202 | func tg_cand(cand: *u8, w: i64, key: *u8, msg: *u8) -> i64 |
| 215 | func tg_fetch(dom: *u8) -> i64 |
| 261 | func tg_server(shm: *u8) -> i64 |
| 313 | func main() -> i64 |