nx_nishi_page_emit.nx
buildroot/runtime/hub/nx_nishi_page_emit.nx
about
nx_nishi_page_emit.nx -- HUB primitive; emits Nishi Page Format V1
conformant <head> block from caller-supplied metadata. Cross-checks
own output via nx_nishi_page_validator before returning (idempotency
proof per Cardinal #10).
COMPOSES (HUB primitives only):
nx_html_escape (safe meta-value emission)
nx_search_inverted (FNV-1a 64 for content-hash)
hub/nx_nishi_page_validator (cross-validates output)
COMPOSED BY:
wiki/nx_wiki_doc_render (retrofit; queued next commit)
hub/nx_html_to_nishi_page (uses emit_meta helper)
(future) obd-config doc emitter
(future) sprinkler-config doc emitter
API surfaces:
- emit_head_block: stamps 9 required <meta> tags into out buffer;
caller wraps with <html>/<head>/<body> shell
- emit_full_page: emits complete conforming HTML page (shell + head + body)
- compute_content_hash: FNV-1a 64 of body bytes -> 16-char hex
V1 SCOPE per NISHI_PAGE_FORMAT_V1 ยง6:
- All 9 required tags emitted inp canonical order
- Caller supplies values; emitter html-escapes each
- Auto-compute: content-hash (from body bytes)
- Constants: page-version="1.0.0"
- Cross-validate emitted output -- if validator rejects own emit,
return INTERNAL_ASSERT_FAIL (catches our own bugs inp development)
Status: V1. 2026-05-27.
dependencies 4 imports · 1 importers
imports: nx_syscalls.nxnx_html_escape.nxnx_search_inverted.nxnx_nishi_page_validator.nx
imported by: nx_wiki_doc_render.nx
structs
| 77 | struct NxNishiPageEmitInputs |
consts
| 39 | const NX_NPE_OK: i64 = 0 |
| 40 | const NX_NPE_BAD_INPUT: i64 = 2500 |
| 41 | const NX_NPE_OUTPUT_OVERFLOW: i64 = 2501 |
| 42 | const NX_NPE_INVALID_FIELD_LEN: i64 = 2502 |
| 43 | const NX_NPE_ESCAPE_FAIL: i64 = 2503 |
| 44 | const NX_NPE_INTERNAL_ASSERT_FAIL: i64 = 2504 // emit produced non-conformant output |
| 45 | const NX_NPE_BODY_TOO_LARGE: i64 = 2505 |
| 48 | const NX_NPE_MAX_BODY_BYTES: i64 = 1048576 // 1 MB |
| 49 | const NX_NPE_CONTENT_HASH_LEN: i64 = 16 |
| 50 | const NX_NPE_PAGE_VERSION: *u8 = "1.0.0" as *u8 |
| 51 | const NX_NPE_PAGE_VERSION_N: i64 = 5 |
| 52 | const NX_NPE_HEAD_OPEN: *u8 = "<head>\n <meta charset=\"utf-8\">\n <!-- NISHI PAGE FORMAT V1 -->\n" as *u8 |
| 53 | const NX_NPE_HEAD_OPEN_N: i64 = 67 |
| 54 | const NX_NPE_HEAD_CLOSE: *u8 = "</head>\n" as *u8 |
| 55 | const NX_NPE_HEAD_CLOSE_N: i64 = 8 |
| 56 | const NX_NPE_HTML_OPEN: *u8 = "<!DOCTYPE html>\n<html lang=\"en\">\n" as *u8 |
| 57 | const NX_NPE_HTML_OPEN_N: i64 = 32 |
| 58 | const NX_NPE_HTML_CLOSE: *u8 = "</html>\n" as *u8 |
| 59 | const NX_NPE_HTML_CLOSE_N: i64 = 8 |
| 60 | const NX_NPE_BODY_OPEN: *u8 = "<body>\n" as *u8 |
| 61 | const NX_NPE_BODY_OPEN_N: i64 = 7 |
| 62 | const NX_NPE_BODY_CLOSE: *u8 = "</body>\n" as *u8 |
| 63 | const NX_NPE_BODY_CLOSE_N: i64 = 8 |
| 64 | const NX_NPE_META_OPEN: *u8 = " <meta name=\"" as *u8 |
| 65 | const NX_NPE_META_OPEN_N: i64 = 16 // 4 spaces + `<meta name="` (12) = 16; was 17 (off-by-one -> a stray leading byte inside name=" nishi-...") |
| 66 | const NX_NPE_META_MID: *u8 = "\" content=\"" as *u8 |
| 67 | const NX_NPE_META_MID_N: i64 = 11 |
| 68 | const NX_NPE_META_CLOSE: *u8 = "\">\n" as *u8 |
| 69 | const NX_NPE_META_CLOSE_N: i64 = 3 |
| 70 | const NX_NPE_TITLE_OPEN: *u8 = " <title>" as *u8 |
| 71 | const NX_NPE_TITLE_OPEN_N: i64 = 11 |
| 72 | const NX_NPE_TITLE_CLOSE: *u8 = "</title>\n" as *u8 |
| 73 | const NX_NPE_TITLE_CLOSE_N: i64 = 9 |
functions
| 97 | func nx_npe_inputs_init(inp: *NxNishiPageEmitInputs, |
| 143 | func nx_npe_put_raw(out: *u8, cap: i64, off: i64, |
| 155 | func nx_npe_put_escaped(out: *u8, cap: i64, off: i64, |
| 166 | func nx_npe_hex16(v: i64, out: *u8) -> i64 called by 1: nx_nishi_compute_content_hash |
| 178 | func nx_nishi_compute_content_hash(body: *u8, body_n: i64, out_hex: *u8) -> i64 called by 2: nx_nishi_emit_head_blocknx_wiki_doc_write_header_v1 calls 2: nx_inv_hash_bytes_lowernx_npe_hex16 |
| 190 | func nx_nishi_emit_meta(out: *u8, cap: i64, off: i64, |
| 206 | func nx_nishi_emit_head_block(inp: *NxNishiPageEmitInputs, |
| 255 | func nx_nishi_emit_full_page(inp: *NxNishiPageEmitInputs, |