nx_wiki_archive_router.nx
buildroot/runtime/wiki/nx_wiki_archive_router.nx
about
nx_wiki_archive_router.nx -- /wiki/archive/* + /wiki/wayback/<hash>
HTTP handler. V1 closes the last wiki 501 per the archive cardinal
("no link rot as hygiene of the nishi ecosystem").
COMPOSES:
nx_syscalls (sys_mmap; sys_now_ms)
nx_search_inverted (nx_inv_hash_bytes_lower for URL -> 64-bit hash)
COMPOSED BY:
wiki/nx_wiki_routes (dispatches /wiki/archive* + /wiki/wayback/*)
V1 SCOPE per NISHI_ARCHIVE_INTEGRATION_CHARTER §5:
- NxArchiveStore (in-memory; parallel pools per URL hash)
- /wiki/archive -- index page listing all stored snapshots
- /wiki/wayback/<hash> -- serves stored snapshot bytes with
X-Archive-Original-URL + X-Archive-Snapshot-Date headers
- /wiki/commit/<repo>/<hash> -- 404 V1 (V2 ships code-archive walker)
- Hardcoded V1 seed list (3 sample snapshots) demonstrates the
cite-time-snapshot pattern with real content; V2 adds live fetch
- Sealed verdict surface 800-819 (reserved per charter §9)
V2 SCOPE (TODO):
- nx_wiki_wayback.nx live fetch via nx_http_client + robots.txt
- nx_wiki_code_archive.nx gitea API walker
- nx_wiki_cite_rewriter.nx wiki build pass that rewrites external
URLs to /wiki/wayback/<hash>
- nx_wiki_audit_emit.nx structured audit log
- nx_kv_store-backed persistence (currently in-memory only)
Status: V1. 2026-05-27.
dependencies 2 imports · 5 importers
imports: nx_syscalls.nxnx_search_inverted.nx
imported by: nx_wiki_https_daemon.nxnx_wiki_https_daemon_mv.nxnx_wiki_main.nxnx_wiki_routes.nxnx_wiki_vhost_table.nx
structs
| 66 | struct NxArchiveStore |
consts
| 36 | const NX_ARCH_OK: i64 = 0 |
| 37 | const NX_ARCH_BAD_INPUT: i64 = 800 |
| 38 | const NX_ARCH_SNAPSHOT_PENDING: i64 = 800 |
| 39 | const NX_ARCH_SNAPSHOT_FAILED: i64 = 801 |
| 40 | const NX_ARCH_BLOCKED_BY_ROBOTS: i64 = 802 |
| 41 | const NX_ARCH_RATE_LIMITED: i64 = 803 |
| 42 | const NX_ARCH_BAD_URL: i64 = 804 |
| 43 | const NX_ARCH_KV_FULL: i64 = 805 |
| 44 | const NX_ARCH_BLOB_FULL: i64 = 806 |
| 45 | const NX_ARCH_COMMIT_NOT_FOUND: i64 = 807 |
| 46 | const NX_ARCH_REPO_NOT_INDEXED: i64 = 808 |
| 47 | const NX_ARCH_M11_VIOLATION: i64 = 809 |
| 48 | const NX_ARCH_M12_VIOLATION: i64 = 810 |
| 49 | const NX_ARCH_M13_VIOLATION: i64 = 811 |
| 51 | const NX_ARCH_NOT_FOUND: i64 = 815 |
| 52 | const NX_ARCH_RESP_OVERFLOW: i64 = 816 |
| 53 | const NX_ARCH_RENDER_FAILED: i64 = 817 |
| 56 | const NX_ARCH_MAX_SNAPSHOTS: i64 = 1000 // V1 cap |
| 57 | const NX_ARCH_URLS_POOL_CAP: i64 = 65536 // 64 KB packed URLs |
| 58 | const NX_ARCH_DATES_POOL_CAP: i64 = 32768 // 32 KB packed dates |
| 59 | const NX_ARCH_BODIES_POOL_CAP: i64 = 16777216 // 16 MB packed bodies |
| 60 | const NX_ARCH_INDEX_PAGE_CAP: i64 = 524288 // 512 KB index page |
| 61 | const NX_ARCH_HASH_HEX_LEN: i64 = 16 // 16 hex chars per hash |
| 62 | const NX_ARCH_INT_BUF_CAP: i64 = 32 |
| 86 | const NX_ARCH_CT_HTML: i64 = 0 |
| 87 | const NX_ARCH_CT_PLAIN: i64 = 1 |
| 88 | const NX_ARCH_CT_JSON: i64 = 2 |
functions
| 90 | func nx_arch_ct_string(ct: i64) -> *u8 called by 1: nx_arch_serve_wayback |
| 97 | func nx_arch_ct_string_n(ct: i64) -> i64 called by 1: nx_arch_serve_wayback |
| 104 | func nx_archive_store_init(s: *NxArchiveStore, snapshots_cap: i64) -> i64 |
| 133 | func nx_archive_store_add(s: *NxArchiveStore, |
| 187 | func nx_archive_store_find_by_hash(s: *NxArchiveStore, h: i64) -> i64 called by 1: nx_arch_serve_wayback |
| 199 | func nx_arch_hex_to_i64(src: *u8, src_n: i64) -> i64 called by 1: nx_arch_serve_wayback |
| 218 | func nx_arch_i64_to_hex(v: i64, out: *u8) -> i64 called by 1: nx_arch_serve_index |
| 232 | func nx_arch_int_to_dec(v: i64, out: *u8, cap: i64) -> i64 |
| 249 | func nx_arch_serve_index(s: *NxArchiveStore, |
| 348 | func nx_arch_serve_wayback(s: *NxArchiveStore, hash_hex: *u8, hash_hex_n: i64, |
| 408 | func nx_wiki_archive_route(s: *NxArchiveStore, |