code wiki / _hdl_build / _wiki_version_gate.nx
_wiki_version_gate.nx
buildroot/runtime/_hdl_build/_wiki_version_gate.nx
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
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
structs
| none |
consts
| none |
functions
| 49 | func 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 } |
| 50 | func gn(fd: i64, v: i64) -> i64 |
| 57 | func w2(lfd: i64, s: *u8) -> i64 { gw(1, s); if lfd >= 0 { gw(lfd, s) } return 0 } |
| 58 | func n2(lfd: i64, v: i64) -> i64 { gn(1, v); if lfd >= 0 { gn(lfd, v) } return 0 } |
| 61 | func bytes_eq(a: *u8, an: i64, b: *u8, bn: i64) -> i64 called by 1: main |
| 69 | func contains(hay: *u8, hay_n: i64, needle: *u8, needle_n: i64) -> i64 called by 1: main |
| 83 | func main() -> i64 |