code wiki / _hdl_build / nx_atomic_publish_gate.nx

nx_atomic_publish_gate.nx

buildroot/runtime/_hdl_build/nx_atomic_publish_gate.nx

43176 B710 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind gate/prooftopic atomic
docsdependenciesstructsconstsfunctions

about

nx_atomic_publish_gate.nx -- END-TO-END gate for `nx_atomic_publish landed` (ap_landed, DM4). THE CORPUS IS THE ESTATE'S OWN RECORD. Every REAL row below reproduces an ambiguous write from 2026-08-15 to 2026-08-20 whose landed-or-not was settled BY HAND at the time, mined out of the lane memories and CLAUDE.md; the hand answer travels beside it as ground truth. Three rows are labelled CONSTRUCTED and counted separately: two are grammar guards, and one is the double-insert the CAS guard AVERTED on 2026-08-20 -- the record describes the outcome it prevented, so the artifact never existed and claiming it as observed would be a fabrication. THE BAR, pre-declared in devmgmt.plan: "emits LANDED or NOT per row matching the hand adjudication with ZERO FALSE LANDED -- wrong only toward NOT". A false LANDED is a lost edit nobody re-applies; a false NOT-LANDED costs one idempotent retry. false_landed is therefore counted as its own number and asserted at zero, separately from the overall diff. THE TWO CONTROLLED PAIRS ARE THE SHARPEST ROWS, and they come straight out of the record: the SAME 503 reply over a write that HAD landed and three that had NOT, in the same hour; the SAME bare empty-object reply over a write that had landed and one that had not. An organ that consults the transport reply gets one of each pair wrong by construction. The third discriminator is one ARTIFACT adjudicated twice: from a size-only row it must ABSTAIN, from a content-hash row it must say LANDED. An organ answering from the file rather than from the declared evidence cannot separate those two. TEETH THE TRIVIAL WRONG IMPLEMENTATIONS CANNOT PASS, all in ONE run: an always-LANDED organ loses the NOT-LANDED rows and trips the false-landed bar; an always-NOT-LANDED organ loses the LANDED rows; an always-UNKNOWN organ -- the guard that refuses everything and thereby passes every negative test -- loses both and cannot reach DECIDED-ALL. Fixtures are assembled at RUNTIME under /tmp/nx_ap_landed_gate/<epoch>/ -- never beside a production beat. Idempotent: the epoch-suffixed directory means a second run cannot inherit the first run's state. usage: nx_atomic_publish_gate [subject-elf] SUBJECT RESOLUTION, announced on every run because the answer depends on it: argv[1] if given, else the freshly BUILT candidate buildroot/_build/nx_atomic_publish.sov.elf, else the deployed twin _offc/nx_atomic_publish.elf, else the serving root, else SKIP. The build-first order is what makes this gate usable as nx_organ_ship's PROVE stage, which runs seconds after /api/build and is asking about the CANDIDATE. ★A GATE THAT DOES NOT SAY WHICH COPY IT JUDGED CAN BE READ AS A VERDICT ABOUT THE WRONG BINARY -- so the resolved path AND its byte count are printed before any tooth runs. Sovereign: imports nx_gatekit_lib + nx_gate_verdict. license_tier: ORIGINAL expect_exit: 0

dependencies 3 imports · 0 importers

nx_gatekit_lib.nx nx_gate_verdict.nx nx_sha256.nx nx_atomic_publish_gate.nx

imports: nx_gatekit_lib.nxnx_gate_verdict.nxnx_sha256.nx

imported by: nobody (leaf or entry point)

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

main gv_head gv_puts sys_write 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 ↻ gk_exists sys_openat_rd sys_close gv_need gv_puts ↻ gv_verdict gv_note_bare_rate gv_bare_rate gv_at gv_obj_has_n gv_at ↻ gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_puts ↻ gv_num ↻ gv_journal sys_openat_append

structs

none

consts

43const APG_NAME: *u8 = "ATOMIC-PUBLISH-GATE"
44const APG_BUILT_ELF: *u8 = "buildroot/_build/nx_atomic_publish.sov.elf"
45const APG_OFFC_ELF: *u8 = "_offc/nx_atomic_publish.elf"
46const APG_ROOT_ELF: *u8 = "./nx_atomic_publish.elf"
47const APG_ROOT: *u8 = "/tmp/nx_atomic_publish_gate"
48const APG_CAP: i64 = 262144
49const APG_WLCAP: i64 = 65536
50const APG_PATHCAP: i64 = 1024
51const APG_TAB: i64 = 9
52const APG_NL: i64 = 10
53const APG_SPACE: i64 = 32
54const APG_D0: i64 = 48 // ASCII '0'
55const APG_D9: i64 = 57
56const APG_DEC_BASE: i64 = 10
57const APG_MAXCASE: i64 = 64
58const APG_PTRW: i64 = 8
59const APG_HEX: i64 = 80
60const APG_REAL: i64 = 1
61const APG_CONSTRUCTED: i64 = 0
66const APG_RACE_DIVISOR: i64 = 2
67const APG_RACE_FLOOR_MS: i64 = 100

functions

69func apg_eq(a: i64, b: i64) -> i64 { if a == b { return 1 } return 0 }
called by 1: main
70func apg_gt(a: i64, b: i64) -> i64 { if a > b { return 1 } return 0 }
71func apg_zero(a: i64) -> i64 { if a == 0 { return 1 } return 0 }
called by 1: main
73func apg_hex(dig: *u8, out: *u8) -> i64
86func apg_hash_text(t: *u8, out: *u8) -> i64
called by 1: main calls 3: gk_lensha256_digestapg_hex
96func apg_hash_file(path: *u8, out: *u8) -> i64
called by 1: main calls 2: sha256_digestapg_hex
106func apg_tab(b: *u8, o: i64) -> i64 { b[o] = APG_TAB as u8; return o + 1 }
called by 1: main
111func apg_verdict_of(buf: *u8, n: i64, id: *u8, out: *u8) -> i64
called by 1: main calls 2: gk_catgk_out_pos
135func apg_int_after(buf: *u8, n: i64, key: *u8) -> i64
154func apg_push(ids: *i64, hands: *i64, real: *i64, n: *i64, id: *u8, hand: *u8, isreal: i64) -> i64
162func main(argc: i64, argv: *i64) -> i64