code wiki / (root) / nx_ts_slot_router_gate.nx

nx_ts_slot_router_gate.nx

buildroot/runtime/nx_ts_slot_router_gate.nx

19047 B419 linesdepth 6pulls 11 transitivereach 0 importersview sourcekind gate/prooftopic ts
docsdependenciesstructsconstsfunctions

about

nx_ts_slot_router_gate.nx -- TS3: A FLIP THE CLIENT CANNOT SEE, AND A COLD SLOT IT REFUSES. /compare/trafficsafety rung TS3, accept rule taken VERBATIM from trafficsafety.plan and not re-invented here: "a flip changes which slot answers with zero failed requests across the flip, a slot that fails its warm-up probe is NEVER flipped to, and the front door's own uptime is unbroken across the whole exercise." ALL THREE CONJUNCTS ARE TESTED SEPARATELY AND EACH NAMES ITSELF, because a compound assertion that will not name its failing conjunct is a false-alarm generator -- the reader always guesses the alarming third. THE SUBJECT IS THE REAL ROUTER BINARY, fork+exec'd, not a function called in-process. And the gate plays OWNER of the front listener, handing it over with ts_handoff_publish, which does double duty: it is a deterministic readiness edge (the publish returns only once the router asked for the socket) AND it demonstrates the property TS3's own risk row demands -- that the one component which must never restart is itself replaceable without a gap, which is why TS3 depends on TS1. THE COLD-SLOT CONTROL IS A REAL DEATH, NOT A FICTION. Slot A's server is killed AND its listening socket closed, so the port genuinely refuses connections; only then is a flip back to A attempted. A guard that gates a destructive action must be wrong in the direction of doing nothing, and moving live traffic onto a dead slot is the destructive action here -- so the control asserts three things, not one: that the flip was REFUSED BY NAME, that the active slot did not move, and that the client still reaches the healthy slot afterwards. A refusal that quietly parked traffic nowhere would pass the first and fail the third. SAFETY: loopback only; every port is FOUND by a bind that would have failed had it been occupied. Nothing live is touched -- this router is standalone by design and fronts only the gate's own two throwaway slot servers. Fixtures live under /tmp/<gate>/ and setup clears them, so a run cannot inherit a previous run's state file and report on it. expect_exit: 0 license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_http_server.nx nx_ts_slot_lib.nx nx_gate_emit_lib.nx nx_gate_verdict.nx nx_ts_slot_router_gate.nx

imports: nx_syscalls.nxnx_http_server.nxnx_ts_slot_lib.nxnx_gate_emit_lib.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

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

main gv_ctr 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 ↻ gv_head gv_puts sys_write ↻ g_puts sys_write ↻ sys_mkdir sys_unlinkat sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close gv_need gv_puts ↻ gv_verdict gv_note_bare_rate gv_bare_rate gv_at gv_obj_has_n gv_at ↻

structs

none

consts

37const TG_NUM_SCRATCH: i64 = 24
38const TG_ASCII_ZERO: i64 = 48
39const TG_B10: i64 = 10
40const TG_SA_BYTES: i64 = 16
43const TG_SA_PORT_OFF: i64 = 2
44const TG_SA_ADDR_OFF: i64 = 4
45const TG_ADDR_BYTES: i64 = 4
46const TG_BYTE_RADIX: i64 = 256
47const TG_OUT_BYTES: i64 = 128
48const TG_LOOPBACK_A: i64 = 127
49const TG_LOOPBACK_D: i64 = 1
50const TG_PORT_BASE: i64 = 39700
51const TG_PORT_TRIES: i64 = 64
52const TG_PORT_NONE: i64 = 0 - 1
53const TG_TRUE: i64 = 1
54const TG_FALSE: i64 = 0
55const TG_BUF: i64 = 4096
56const TG_ARGV_BYTES: i64 = 64
57const TG_SIG_TERM: i64 = 15
58const TG_ARGC_SUBJECT: i64 = 2
61const TG_F_SETFD: i64 = 2
62const TG_FD_CLOEXEC: i64 = 1
63const TG_AV_FRONT: i64 = 1
64const TG_AV_SLOTA: i64 = 2
65const TG_AV_SLOTB: i64 = 3
66const TG_AV_STATE: i64 = 4
67const TG_AV_SOCK: i64 = 5
68const TG_AV_END: i64 = 6
71const TG_RC_EXEC_FAILED: i64 = 127
72const TG_DEADLINE_S: i64 = ACCEPT_TMO_S
73const TG_MARK_A: i64 = 65
74const TG_MARK_B: i64 = 66
75const TG_PROBE: i64 = 80
78const TG_REQS: i64 = TSR_BACKLOG
80const TG_DIR: *u8 = "/tmp/nx_ts_slot_router_gate" as *u8
81const TG_STATE: *u8 = "/tmp/nx_ts_slot_router_gate/slots.conf" as *u8
82const TG_SOCK: *u8 = "/tmp/nx_ts_slot_router_gate/front.sock" as *u8
83const TG_DEFAULT_ROUTER: *u8 = "./nx_ts_slot_router.elf" as *u8

functions

85func g_putn(v: i64) -> i64
called by 2: gqmain calls 2: sys_writesys_mmap
96func gq(label: *u8, got: i64, want: i64, ctr: *i64) -> i64
called by 1: main calls 3: gv_checkg_putsg_putn
108func tg_sa(sa: *u8, port: i64) -> i64
called by 2: tg_listentg_ask
120func tg_listen(port: i64, reuse: i64) -> i64
148func tg_find_port(from: i64) -> i64
called by 1: main calls 2: tg_listensys_close
161func tg_slot_server(lfd: i64, marker: i64) -> i64
179func tg_ask(front: i64) -> i64
196func tg_drive(front: i64, want: i64, out: *i64) -> i64
called by 1: main calls 1: tg_ask
210func tg_write_state(slot: i64) -> i64
228func tg_spawn_router(router: *u8, front: i64, pa: i64, pb: i64) -> i64
252func main(argc: i64, argv: **u8) -> i64