code wiki / wiki / nx_wiki_queue.nx

nx_wiki_queue.nx

buildroot/runtime/wiki/nx_wiki_queue.nx

14228 B303 linesdepth 10pulls 22 transitivereach 7 importersview sourcekind librarytopic wiki
docsdependenciesstructsconstsfunctions

about

nx_wiki_queue.nx -- the sovereign partnership work-queue. This closes the "trigger Claude partnership work" loop: a visitor submits a task on a component article (POST /wiki/request), it is appended to an append-only Nishi journal on disk, and GET /wiki/queue renders the live log -- the durable, sovereign record of requested + completed work that a Claude session drains and documents. All NishiLang, written + read by Nishi I/O (sys_openat_append / sys_write / sys_read_file). No shell, no TSV-glue, no external lib. NEW CAPABILITY vs the rest of the wiki: this is RENDERED AT REQUEST TIME (it reads the live journal), so it runs in the daemon's forked child -- where per-request allocation is fine (the child exits and the OS reclaims it), unlike the parent loop where everything must be hoisted. SECURITY (Cardinal 12, defensive at boundary): the task text is untrusted public input. On write it is sanitized (control bytes + the field separator replaced with spaces, length-capped); on render it is HTML-escaped via the wiki render primitive. The record format uses the 0x1F field separator (never present in sanitized text) so parsing is unambiguous. COMPOSED BY: wiki/nx_wiki_routes (GET /wiki/queue, POST /wiki/request) and bin/nx_sites_daemon (same, dispatched in the child). Status: V1. 2026-05-30.

dependencies 2 imports · 3 importers

nx_syscalls.nx nx_wiki_doc_render.nx nx_wiki_queue.nx nx_sites_daemon.nx nx_sites_daemon_v2.nx nx_wiki_routes.nx

imports: nx_syscalls.nxnx_wiki_doc_render.nx

imported by: nx_sites_daemon.nxnx_sites_daemon_v2.nxnx_wiki_routes.nx

structs

none

consts

32const NX_WQ_OK: i64 = 0
33const NX_WQ_ERR: i64 = 3000
36const NX_WQ_LOG_PATH: *u8 = "/volume1/homes/elderwesto/nishihost/wiki_workqueue.log" as *u8
37const NX_WQ_FS: i64 = 0x1F // field separator
38const NX_WQ_REC: i64 = 0x0A // record separator (newline)
39const NX_WQ_MAX_TASK: i64 = 600 // cap on the task field
40const NX_WQ_MAX_SLUG: i64 = 96
41const NX_WQ_RENDER_CAP: i64 = 131072
42const NX_WQ_SCRATCH_CAP: i64 = 4096
43const NX_WQ_LINE_CAP: i64 = 1024
44const NX_WQ_PUTZ_CAP: i64 = 1048576
45const NX_WQ_STRLEN_CAP: i64 = 65536
46const NX_WQ_MAX_RENDER_RECS: i64 = 80 // bound the rendered list (TLS record budget)

functions

49func nx_wq_strlen(s: *u8) -> i64
59func nx_wq_put_z(dst: *u8, off: *i64, cap: i64, s: *u8) -> i64
77func nx_wq_sanitize(dst: *u8, max: i64, src: *u8, src_n: i64) -> i64
called by 1: nx_wq_append
93func nx_wq_hexval(c: i64) -> i64
called by 1: nx_wq_urldecode
101func nx_wq_urldecode(src: *u8, src_n: i64, out: *u8, out_cap: i64) -> i64
called by 1: nx_wq_form_field calls 1: nx_wq_hexval
128func nx_wq_form_field(body: *u8, body_n: i64, key: *u8, key_n: i64,
156func nx_wq_append(kind: *u8, kind_n: i64, slug: *u8, slug_n: i64,
175func nx_wq_finish_http(ctx: *NxWikiDocCtx, resp_buf: *u8, resp_cap: i64, out_resp_n: *i64) -> i64
202func nx_wiki_request_handle(body: *u8, body_n: i64,
228func nx_wq_emit_row(ctx: *NxWikiDocCtx, data: *u8, ks: i64, ke: i64,
239func nx_wiki_queue_handle(resp_buf: *u8, resp_cap: i64, out_resp_n: *i64) -> i64