code wiki / wiki / nx_wiki_archive_router.nx

nx_wiki_archive_router.nx

buildroot/runtime/wiki/nx_wiki_archive_router.nx

18467 B450 linesdepth 4pulls 4 transitivereach 6 importersview sourcekind librarytopic wiki
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_search_inverted.nx nx_wiki_archive_router.nx nx_wiki_https_daemon.nx nx_wiki_https_daemon_mv.nx nx_wiki_main.nx nx_wiki_routes.nx nx_wiki_vhost_table.nx

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

66struct NxArchiveStore

consts

36const NX_ARCH_OK: i64 = 0
37const NX_ARCH_BAD_INPUT: i64 = 800
38const NX_ARCH_SNAPSHOT_PENDING: i64 = 800
39const NX_ARCH_SNAPSHOT_FAILED: i64 = 801
40const NX_ARCH_BLOCKED_BY_ROBOTS: i64 = 802
41const NX_ARCH_RATE_LIMITED: i64 = 803
42const NX_ARCH_BAD_URL: i64 = 804
43const NX_ARCH_KV_FULL: i64 = 805
44const NX_ARCH_BLOB_FULL: i64 = 806
45const NX_ARCH_COMMIT_NOT_FOUND: i64 = 807
46const NX_ARCH_REPO_NOT_INDEXED: i64 = 808
47const NX_ARCH_M11_VIOLATION: i64 = 809
48const NX_ARCH_M12_VIOLATION: i64 = 810
49const NX_ARCH_M13_VIOLATION: i64 = 811
51const NX_ARCH_NOT_FOUND: i64 = 815
52const NX_ARCH_RESP_OVERFLOW: i64 = 816
53const NX_ARCH_RENDER_FAILED: i64 = 817
56const NX_ARCH_MAX_SNAPSHOTS: i64 = 1000 // V1 cap
57const NX_ARCH_URLS_POOL_CAP: i64 = 65536 // 64 KB packed URLs
58const NX_ARCH_DATES_POOL_CAP: i64 = 32768 // 32 KB packed dates
59const NX_ARCH_BODIES_POOL_CAP: i64 = 16777216 // 16 MB packed bodies
60const NX_ARCH_INDEX_PAGE_CAP: i64 = 524288 // 512 KB index page
61const NX_ARCH_HASH_HEX_LEN: i64 = 16 // 16 hex chars per hash
62const NX_ARCH_INT_BUF_CAP: i64 = 32
86const NX_ARCH_CT_HTML: i64 = 0
87const NX_ARCH_CT_PLAIN: i64 = 1
88const NX_ARCH_CT_JSON: i64 = 2

functions

90func nx_arch_ct_string(ct: i64) -> *u8
97func nx_arch_ct_string_n(ct: i64) -> i64
104func nx_archive_store_init(s: *NxArchiveStore, snapshots_cap: i64) -> i64
called by 3: mainnx_mv_setup_sitemain calls 1: sys_mmap
133func nx_archive_store_add(s: *NxArchiveStore,
called by 1: main calls 1: nx_inv_hash_bytes_lower
187func nx_archive_store_find_by_hash(s: *NxArchiveStore, h: i64) -> i64
199func nx_arch_hex_to_i64(src: *u8, src_n: i64) -> i64
218func nx_arch_i64_to_hex(v: i64, out: *u8) -> i64
called by 1: nx_arch_serve_index
232func nx_arch_int_to_dec(v: i64, out: *u8, cap: i64) -> i64
249func nx_arch_serve_index(s: *NxArchiveStore,
348func nx_arch_serve_wayback(s: *NxArchiveStore, hash_hex: *u8, hash_hex_n: i64,
408func nx_wiki_archive_route(s: *NxArchiveStore,