code wiki / _hdl_build / nx_wiki_versioned_publish.nx
nx_wiki_versioned_publish.nx
buildroot/runtime/_hdl_build/nx_wiki_versioned_publish.nx
about
nx_wiki_versioned_publish.nx -- A4a: VERSIONED-PUBLISH + the multi-point rollback INDEX.
THE OPERATOR PRECONDITION (verbatim intent): "ability to revert via versions held so we can roll back
not just to another broken one but have FULL RESTORE via MULTIPLE rollback points." This is the safety
net that must exist BEFORE any full-auto re-publishing: every time a page goes live we FIRST capture the
exact bytes as a RETAINED, content-addressed version record, so a later restore can land the LIVE page
byte-exact on ANY prior version -- not just the last one, not just a different broken one.
COMPOSITION (no storage/crypto reinvented -- every line below routes through a proven organ):
nx_wiki_archive war_archive_page / war_get_by_cid / war_cid_of_body (content-addressed blob = the
no-rot anchor; the SAME WAR_PREFIX store A2's guard resolves citations from, so a
version blob survives across runs / is durable by construction).
nx_seg_store ss_begin / ss_add / ss_commit / ss_get_cap (append-only durable KV: a new
record is a NEW segment, never an in-place overwrite -- the additive-data law #13).
nx_canon_cid cid_of (via war_cid_of_body) (CID = nxc1-+sha256(bytes)).
nx_wiki_publish pub_publish_ex (A3 GUARDED publish -- the SOLE
enforcement point; EVERY live write here flows through the A2 guard, fail-closed).
THE VERSION INDEX (a SEPARATE key family in the SAME durable store; never collides with wikiblob:/wikicid:
which the archive owns):
wpv:cnt:<slug> -> decimal version COUNT for the slug (a latest-wins pointer; seg_store keeps
every prior value in history too, so even this is additive, never destroyed)
wpv:ver:<slug>:<v#> -> the content CID of version v# (written EXACTLY ONCE per (slug,v#); a new
publish appends a NEW v#, it NEVER rewrites an existing wpv:ver key -- this
is the append-only, multi-rollback-point guarantee, mechanical not promised)
wpv:ep:<slug>:<v#> -> the fixed epoch stamped for v# (written once; NO wall-clock call -- the
caller passes a fixed epoch so the record is deterministic/reproducible)
Because v# is monotonic and each wpv:ver:<slug>:<v#> key is unique, publishing v2/v3 can NEVER mutate or
delete the v1 record. The blob itself is content-addressed, so even dropping a pointer cannot lose bytes.
Pure NishiLang, NO sql/.sh/.py/.js, no new .tsv/.conf. license_tier: ORIGINAL
dependencies 4 imports · 16 importers
diagram shows first 10 each side; +0 more imports, +6 more importers in the complete lists below.
imports: nx_wiki_publish.nxnx_wiki_archive.nxnx_seg_store.nxnx_syscalls.nx
imported by: nx_asset_dashboard_publish.nxnx_figures_publish.nxnx_ims_batch1_publish.nxnx_ims_batch1_repush.nxnx_ims_batch2_publish.nxnx_ims_batch2_repush.nxnx_ims_batch2_tail.nxnx_ims_search_publish.nxnx_math_render_publish.nxnx_wiki_pub_board.nxnx_wiki_restore.nxnx_wiki_structure_regen.nxnx_wiki_versioned_publish_gate.nxnx_wiki_versioned_publish_live.nxnx_wiki_vplist_probe.nxnx_wiki_walk_republish.nx
structs
| none |
consts
| 38 | const VP_OK: i64 = 0 |
| 39 | const VP_BAD_INPUT: i64 = 0 - 4940 // null/empty slug or path |
| 40 | const VP_READ_FAILED: i64 = 0 - 4941 // could not read the new local page bytes |
| 41 | const VP_ARCHIVE_FAIL: i64 = 0 - 4942 // archive add/commit returned an error |
| 42 | const VP_NOT_FOUND: i64 = 0 - 4943 // requested version# has no retained record |
| 43 | const VP_PUSH_REJECT: i64 = 0 - 4944 // A3 guard REJECTED the page (fail-closed; nothing pushed) |
| 46 | const VP_SCAN_CAP: i64 = 256 |
| 48 | const VP_MAX_VERS: i64 = 4096 |
| 50 | const VP_MODE_0644: i64 = 0x1a4 |
functions
| 53 | func vp_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: vpub_ex |
| 56 | func vp_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 63 | func vp_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 74 | func vp_parse_dec(b: *u8, n: i64) -> i64 called by 1: vp_get_count |
| 89 | func vp_cnt_key(slug: *u8, out: *u8) -> i64 |
| 97 | func vp_ver_key(slug: *u8, v: i64, out: *u8) -> i64 |
| 107 | func vp_ep_key(slug: *u8, v: i64, out: *u8) -> i64 |
| 119 | func vp_get_count(prefix: *u8, slug: *u8) -> i64 |
| 139 | func vp_cid_of_version(prefix: *u8, slug: *u8, v: i64, cidout: *u8) -> i64 |
| 158 | func vp_list_ex(prefix: *u8, slug: *u8, vers: *i64, cidbuf: *u8, max: i64) -> i64 |
| 177 | func vp_list(slug: *u8, vers: *i64, cidbuf: *u8, max: i64) -> i64 |
| 197 | func vpub_ex(prefix: *u8, slug: *u8, new_local_html_path: *u8, called by 3: reg_guard_and_applyvpubmain calls 13: vp_lensys_mmapsys_read_filevp_get_countss_beginwar_archive_page+7 |
| 251 | func vpub(slug: *u8, new_local_html_path: *u8, |
| 260 | func vp_status_name(s: i64) -> *u8 |