nx_wiki_main.nx
buildroot/runtime/wiki/nx_wiki_main.nx
about
nx_wiki_main.nx -- wiki daemon entry point.
Forks the nx_audit_server_routed::main 140-line accept-loop
pattern. Reuses every existing HTTP / health / log primitive;
zero new daemon primitives introduced (per duplicate-primitives
audit). Per the small-sharp+composable standard: this file is
the wiki's site-specific main() that wires the hub primitives +
the wiki route dispatcher into a runnable daemon.
COMPOSES:
nx_http_server bind / listen / accept / read / send
nx_kv_store session storage (caller-allocated)
nx_hash_facade password hash compare
nx_log_jsonl per-request structured log
nx_syscalls (sys_read_file) read admin-hash file at startup
nx_syscalls (sys_now_ms) wall-clock for session expiry
hub/nx_admin_login_flow admin-login flow init
wiki/nx_wiki_routes route dispatcher
Status: V1 SEED. 2026-05-27.
WINNER-TIER: BASELINE-C provisional (forks audit-server's shipped
keepalive + per-conn-budget shape; throughput parity
expected; paired bench pending wiki workload fixture)
INCUMBENTS: nginx (single-process), Caddy, Apache HTTPD MPM,
substrate's own nx_audit_server_routed
NUMBERS: V1 ships the daemon; paired req/sec vs audit-server
pending real load
GAP: nginx multi-worker + master process management;
V1 ships single-process with supervisor-restart on
request-budget exhaustion (matches audit-server)
PLAN: M-next: multi-worker fork pattern when wiki workload
demands > 1 process's throughput
EXEMPTION REASON: n/a; provisional pending measurement
V1 HONEST SCOPE LIMITS (per NISHI_CODE_HYGIENE_STANDARD M6):
- Bind: loopback-only (127.0.0.1:51850). Operator wires a
reverse-proxy / nginx-front-end to expose at nishifamily.com/wiki.
V2 supports listening on non-loopback addresses + TLS via
future nx_tls_shim.
dependencies 19 imports · 0 importers
diagram shows first 10 each side; +9 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_http_server.nxnx_kv_store.nxnx_hash_facade.nxnx_log_jsonl.nxnx_http_header_find.nxnx_admin_login_flow.nxnx_search_handler_flow.nxnx_wiki_routes.nxnx_wiki_index_builder.nxnx_wiki_page_save.nxnx_wiki_content_loader.nxnx_wiki_archive_router.nxnx_artifact_store.nxnx_pipeline_walker.nxnx_pipeline_recursive_walker.nxnx_pipeline_graph_builder.nxnx_dep_graph.nxnx_search_inverted.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
| 71 | const NX_WIKI_MAIN_OK: i64 = 0 |
| 72 | const NX_WIKI_MAIN_BIND_FAILED: i64 = 1300 |
| 73 | const NX_WIKI_MAIN_NO_ADMIN_HASH: i64 = 1301 |
| 74 | const NX_WIKI_MAIN_KV_INIT_FAILED: i64 = 1302 |
| 75 | const NX_WIKI_MAIN_CONFIG_INIT_FAILED: i64 = 1303 |
| 76 | const NX_WIKI_MAIN_RANDOM_FAILED: i64 = 1304 |
| 77 | const NX_WIKI_MAIN_REQUEST_BUDGET_HIT: i64 = 1305 |
| 83 | const NX_WIKI_MAIN_BACKLOG: i64 = 64 |
| 84 | const NX_WIKI_MAIN_REALM: *u8 = "Nishi Wiki Admin" as *u8 |
| 85 | const NX_WIKI_MAIN_REALM_N: i64 = 16 |
| 86 | const NX_WIKI_MAIN_ADMIN_USERNAME: *u8 = "elderwesto" as *u8 |
| 87 | const NX_WIKI_MAIN_ADMIN_USERNAME_N: i64 = 10 |
| 88 | const NX_WIKI_MAIN_ADMIN_HASH_PATH: *u8 = "/tmp/nishi_wiki_admin_hash" as *u8 |
| 91 | const NX_WIKI_MAIN_SYS_GETRANDOM: i64 = 318 // x86_64 |
| 94 | const NX_WIKI_MAIN_KV_DATA_CAP: i64 = 1048576 // 1 MiB session data |
| 95 | const NX_WIKI_MAIN_KV_INDEX_CAP: i64 = 65536 // 64 KiB index (~4000 sessions) |
| 98 | const NX_WIKI_MAIN_RANDOM_BYTES: i64 = 16 |
| 101 | const NX_WIKI_MAIN_LOG_COMPONENT: *u8 = "nx_wiki_main" as *u8 |
| 102 | const NX_WIKI_MAIN_LOG_COMPONENT_N: i64 = 12 |
functions
| 115 | func nx_wiki_main_load_admin_hash(path: *u8) -> i64 |
| 137 | func nx_wiki_main_fill_random(out_16: *u8) -> i64 |
| 152 | func nx_wiki_main_log_request(ts_ms: i64, |
| 200 | func nxar_method_name(k: i64) -> *u8 called by 1: nx_wiki_main_log_request |
| 206 | func nxar_method_name_len(k: i64) -> i64 called by 1: nx_wiki_main_log_request |
| 225 | func main() -> i64 |