code wiki / hub / nx_nishi_page_emit.nx

nx_nishi_page_emit.nx

buildroot/runtime/hub/nx_nishi_page_emit.nx

13273 B289 linesdepth 4pulls 7 transitivereach 24 importersview sourcekind librarytopic nishi
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_html_escape.nx nx_search_inverted.nx nx_nishi_page_validator.nx nx_nishi_page_emit.nx nx_wiki_doc_render.nx

imports: nx_syscalls.nxnx_html_escape.nxnx_search_inverted.nxnx_nishi_page_validator.nx

imported by: nx_wiki_doc_render.nx

structs

77struct NxNishiPageEmitInputs

consts

39const NX_NPE_OK: i64 = 0
40const NX_NPE_BAD_INPUT: i64 = 2500
41const NX_NPE_OUTPUT_OVERFLOW: i64 = 2501
42const NX_NPE_INVALID_FIELD_LEN: i64 = 2502
43const NX_NPE_ESCAPE_FAIL: i64 = 2503
44const NX_NPE_INTERNAL_ASSERT_FAIL: i64 = 2504 // emit produced non-conformant output
45const NX_NPE_BODY_TOO_LARGE: i64 = 2505
48const NX_NPE_MAX_BODY_BYTES: i64 = 1048576 // 1 MB
49const NX_NPE_CONTENT_HASH_LEN: i64 = 16
50const NX_NPE_PAGE_VERSION: *u8 = "1.0.0" as *u8
51const NX_NPE_PAGE_VERSION_N: i64 = 5
52const NX_NPE_HEAD_OPEN: *u8 = "<head>\n <meta charset=\"utf-8\">\n <!-- NISHI PAGE FORMAT V1 -->\n" as *u8
53const NX_NPE_HEAD_OPEN_N: i64 = 67
54const NX_NPE_HEAD_CLOSE: *u8 = "</head>\n" as *u8
55const NX_NPE_HEAD_CLOSE_N: i64 = 8
56const NX_NPE_HTML_OPEN: *u8 = "<!DOCTYPE html>\n<html lang=\"en\">\n" as *u8
57const NX_NPE_HTML_OPEN_N: i64 = 32
58const NX_NPE_HTML_CLOSE: *u8 = "</html>\n" as *u8
59const NX_NPE_HTML_CLOSE_N: i64 = 8
60const NX_NPE_BODY_OPEN: *u8 = "<body>\n" as *u8
61const NX_NPE_BODY_OPEN_N: i64 = 7
62const NX_NPE_BODY_CLOSE: *u8 = "</body>\n" as *u8
63const NX_NPE_BODY_CLOSE_N: i64 = 8
64const NX_NPE_META_OPEN: *u8 = " <meta name=\"" as *u8
65const 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-...")
66const NX_NPE_META_MID: *u8 = "\" content=\"" as *u8
67const NX_NPE_META_MID_N: i64 = 11
68const NX_NPE_META_CLOSE: *u8 = "\">\n" as *u8
69const NX_NPE_META_CLOSE_N: i64 = 3
70const NX_NPE_TITLE_OPEN: *u8 = " <title>" as *u8
71const NX_NPE_TITLE_OPEN_N: i64 = 11
72const NX_NPE_TITLE_CLOSE: *u8 = "</title>\n" as *u8
73const NX_NPE_TITLE_CLOSE_N: i64 = 9

functions

97func nx_npe_inputs_init(inp: *NxNishiPageEmitInputs,
143func nx_npe_put_raw(out: *u8, cap: i64, off: i64,
155func nx_npe_put_escaped(out: *u8, cap: i64, off: i64,
166func nx_npe_hex16(v: i64, out: *u8) -> i64
178func nx_nishi_compute_content_hash(body: *u8, body_n: i64, out_hex: *u8) -> i64
190func nx_nishi_emit_meta(out: *u8, cap: i64, off: i64,
206func nx_nishi_emit_head_block(inp: *NxNishiPageEmitInputs,
255func nx_nishi_emit_full_page(inp: *NxNishiPageEmitInputs,