nx_wiki_queue.nx
buildroot/runtime/wiki/nx_wiki_queue.nx
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
imports: nx_syscalls.nxnx_wiki_doc_render.nx
imported by: nx_sites_daemon.nxnx_sites_daemon_v2.nxnx_wiki_routes.nx
structs
| none |
consts
| 32 | const NX_WQ_OK: i64 = 0 |
| 33 | const NX_WQ_ERR: i64 = 3000 |
| 36 | const NX_WQ_LOG_PATH: *u8 = "/volume1/homes/elderwesto/nishihost/wiki_workqueue.log" as *u8 |
| 37 | const NX_WQ_FS: i64 = 0x1F // field separator |
| 38 | const NX_WQ_REC: i64 = 0x0A // record separator (newline) |
| 39 | const NX_WQ_MAX_TASK: i64 = 600 // cap on the task field |
| 40 | const NX_WQ_MAX_SLUG: i64 = 96 |
| 41 | const NX_WQ_RENDER_CAP: i64 = 131072 |
| 42 | const NX_WQ_SCRATCH_CAP: i64 = 4096 |
| 43 | const NX_WQ_LINE_CAP: i64 = 1024 |
| 44 | const NX_WQ_PUTZ_CAP: i64 = 1048576 |
| 45 | const NX_WQ_STRLEN_CAP: i64 = 65536 |
| 46 | const NX_WQ_MAX_RENDER_RECS: i64 = 80 // bound the rendered list (TLS record budget) |
functions
| 49 | func nx_wq_strlen(s: *u8) -> i64 called by 1: nx_wiki_queue_handle |
| 59 | func nx_wq_put_z(dst: *u8, off: *i64, cap: i64, s: *u8) -> i64 |
| 77 | func nx_wq_sanitize(dst: *u8, max: i64, src: *u8, src_n: i64) -> i64 called by 1: nx_wq_append |
| 93 | func nx_wq_hexval(c: i64) -> i64 called by 1: nx_wq_urldecode |
| 101 | func nx_wq_urldecode(src: *u8, src_n: i64, out: *u8, out_cap: i64) -> i64 |
| 128 | func nx_wq_form_field(body: *u8, body_n: i64, key: *u8, key_n: i64, |
| 156 | func nx_wq_append(kind: *u8, kind_n: i64, slug: *u8, slug_n: i64, called by 1: nx_wiki_request_handle calls 5: sys_openat_appendsys_mmapnx_wq_sanitizesys_writesys_close |
| 175 | func nx_wq_finish_http(ctx: *NxWikiDocCtx, resp_buf: *u8, resp_cap: i64, out_resp_n: *i64) -> i64 |
| 202 | func nx_wiki_request_handle(body: *u8, body_n: i64, |
| 228 | func nx_wq_emit_row(ctx: *NxWikiDocCtx, data: *u8, ks: i64, ke: i64, |
| 239 | func nx_wiki_queue_handle(resp_buf: *u8, resp_cap: i64, out_resp_n: *i64) -> i64 |