code wiki / _hdl_build / _wiki_version_gate.nx

_wiki_version_gate.nx

buildroot/runtime/_hdl_build/_wiki_version_gate.nx

15193 B297 linesdepth 17pulls 53 transitivereach 0 importersview sourcekind gate/prooftopic wiki
docsdependenciesstructsconstsfunctions

about

_wiki_version_gate.nx -- unit gate PROVING wiki R2 page VERSIONING: HISTORY (the immutable wikirev:* rows enumerate in order), DIFF (line-level, non-empty for a real change + empty for identical revisions), and ROLLBACK (auth-gated, ADDITIVE -- restores old content as a NEW revision while every prior revision survives), plus the liar-kill: an UNAUTH rollback is REFUSED with the store UNCHANGED. NO mocks, NO live socket: drives the REAL R2 core (nx_wiki_version) on top of the REAL R1 save (nx_wiki_page_save) + REAL doc store + the REAL reused auth (armed NxAuthContext: persistent key bundle + OPAQUE account store + argon2id KSF -- the exact production auth) + the REAL append-only seg_store. The auth recipe mirrors _wiki_edit_gate.nx (armed ctx + register + login -> real token). Per the native-codegen desync landmine, EVERY assertion is judged on a GROUND-TRUTH observable -- the BYTES read back out of the seg_store and the COUNT of enumerated revisions -- never a bare returned status code. Distinct epochs: v1/v2/v3 are saved with distinct now_unix_s stamps (base+10/+20/+30) so their wikirev:<slug>:<epoch> keys are distinct (a single shared epoch would collide one rev key and under-count history). All offsets sit well inside the session TTL so the freshly minted token still validates. Rows / markers: history_ok : >= 3 revisions enumerate for the slug, in ascending epoch order (the v1/v2/v3 epochs come back sorted). diff_ok : nx_wiki_diff(v1,v3) is non-empty AND mentions a changed line; nx_wiki_diff(v2,v2) is empty (0 bytes). rollback_ok : authed nx_wiki_rollback(v1_epoch) -> wikicur readback now equals v1's content (ground-truth bytes). additive_ok : after rollback the revision count GREW by 1 AND v2's and v3's revisions are STILL retrievable (history not truncated). unauth_refused : nx_wiki_rollback with an empty token AND a garbage token -> REFUSED, and wikicur is UNCHANGED (the rollback never touched the store). JUDGED by the printed WIKIVERSION marker (verdict=GREEN only if EVERY assertion holds), NOT by $?. Import set: nx_syscalls + wiki/nx_wiki_version (pulls the R2 core -> R1 save -> reused auth flow -> seg_store) + wiki/nx_wiki_edit_handler (the doc-store +

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_wiki_version.nx nx_wiki_edit_handler.nx _wiki_version_gate.nx

imports: nx_syscalls.nxnx_wiki_version.nxnx_wiki_edit_handler.nx

imported by: nobody (leaf or entry point)

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

main gw sys_write sys_openat_wr sys_close sys_mmap nx_uas_server_keys_load_or sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read 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 ↻ _voprf_load_context_string u256_alloc nx_scratch nx_scratch_init sys_mmap ↻ nx_scratch_oom sys_write ↻ sys_exit sys_mmap ↻ nx_opq_hash_to_scalar sys_mmap ↻ nx_h2c_expand_message_xmd_ sys_mmap ↻ _h2c_i2osp_1 _h2c_i2osp_2 u256_alloc ↻

structs

none

consts

none

functions

49func gw(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 2: w2main calls 1: sys_write
50func gn(fd: i64, v: i64) -> i64
called by 2: n2main calls 2: sys_mmapsys_write
57func w2(lfd: i64, s: *u8) -> i64 { gw(1, s); if lfd >= 0 { gw(lfd, s) } return 0 }
called by 1: main calls 1: gw
58func n2(lfd: i64, v: i64) -> i64 { gn(1, v); if lfd >= 0 { gn(lfd, v) } return 0 }
called by 1: main calls 1: gn
61func bytes_eq(a: *u8, an: i64, b: *u8, bn: i64) -> i64
called by 1: main
69func contains(hay: *u8, hay_n: i64, needle: *u8, needle_n: i64) -> i64
called by 1: main
83func main() -> i64