code wiki / _hdl_build / nx_docportal_search_serve_snip_20260912.nx

nx_docportal_search_serve_snip_20260912.nx

buildroot/runtime/_hdl_build/nx_docportal_search_serve_snip_20260912.nx

73291 B1269 linesdepth 5pulls 13 transitivereach 2 importersview sourcekind librarytopic docportal
docsdependenciesstructsconstsfunctions

about

nx_docportal_search_serve.nx -- R2: the PUBLIC /search serve handler over the SOVEREIGN seg_store search. bytes-in -> bytes-out (no socket -- the gate drives it directly, like dad_handle). Parses GET /search?q=<query>, runs dss_search over the domain's PUBLIC seg_store shard (NO tsv), reads each hit's text (ss_hget) and renders a branded results page with Content-Length (sites.elf's buffered reverse proxy needs the length). A stale/old- format shard (-2) degrades to "0 results", never a 500. license_tier: ORIGINAL

dependencies 4 imports · 2 importers

nx_docportal_search_seg.nx nx_artifact_root.nx nx_textcut.nx nx_docprose.nx nx_docportal_search_serve_snip nx_search_snip_focus_20260912.nx nx_search_snip_gate_20260912.nx

imports: nx_docportal_search_seg.nxnx_artifact_root.nxnx_textcut.nxnx_docprose.nx

imported by: nx_search_snip_focus_20260912.nxnx_search_snip_gate_20260912.nx

structs

none

consts

12const DSV_ASCII_0: i64 = 48
13const DSV_DEC: i64 = 10
14const DSV_TSBUF: i64 = 16
16const DSV_MAGIC_1000000: i64 = 1000000
17const DSV_MAGIC_1024: i64 = 1024
18const DSV_MAGIC_80000: i64 = 80000
20const DSV_OUTCAP: i64 = 262144
21const DSV_BODYCAP: i64 = 786432 // uniform per-request body mmap size (>= the largest body 600000); munmap'd every request to kill the leak
22const DSV_MAXR: i64 = 30 // results per page (20->30 2026-07-24: fuller SERPs; the shrunk tf-scan cap keeps it fast)
23const DSV_SNIP: i64 = 240 // chars of a hit's text to show
27const DSV_TITLE_CAP: i64 = 72 // bytes of the title line shown
28const DSV_TITLE_FLOOR: i64 = 56 // degenerate fallback when a document has no titled line at all
29const DSV_SENT_MAX: i64 = 320 // hard cap on one "sentence" before dsv_best_sentence gives up looking for . ! ?
30const DSV_SNIPSCAN: i64 = 8000 // head window scanned for the best query-covering sentence
31const DSV_SENT_MIN: i64 = 40 // shortest span that can qualify as a sentence
32const DSV_SENT_MAXNL: i64 = 2 // newlines tolerated inside prose before it reads as a nav blob
262const DSV_BOXBYTES: i64 = 64
449const DSV_SCOPE_SITE: i64 = 0
450const DSV_SCOPE_WEB: i64 = 1
451const DSV_SCOPE_TRUSTED: i64 = 2
452const DSV_SCOPE_CONF_CAP: i64 = 4096
453const DSV_PATHCAP: i64 = 1024
454const DSV_CH_LF: i64 = 10
455const DSV_CH_CR: i64 = 13
456const DSV_CH_SP: i64 = 32
457const DSV_CH_HASH: i64 = 35

functions

34func dsv_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
35func dsv_cat(out: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { out[o] = s[i]; o = o + 1; i = i + 1 } return o }
36func dsv_catn(out: *u8, o: i64, v: i64) -> i64
47func dsv_esc(out: *u8, o: i64, src: *u8, n: i64) -> i64
called by 3: dsv_hldsv_resultdss_serve calls 1: dsv_cat
60func dsv_hexval(c: u8) -> i64
called by 1: dsv_urldecode
67func dsv_urldecode(src: *u8, n: i64, out: *u8, outcap: i64) -> i64
called by 1: dsv_qparam calls 1: dsv_hexval
90func dsv_qparam(req: *u8, req_n: i64, name: *u8, nlen: i64, out: *u8, outcap: i64) -> i64
128func dsv_host(req: *u8, req_n: i64, out: *u8, cap: i64) -> i64
called by 1: main
160func dsv_tokq(q: *u8, qn: i64, termstore: *u8, termptrs: *i64, tbl: *u8) -> i64
184func dsv_hl(out: *u8, o: i64, src: *u8, n: i64, termptrs: *i64, nterms: i64, tbl: *u8) -> i64
220func dsv_urlenc(out: *u8, o: i64, src: *u8, n: i64) -> i64
242func dsv_mkurlkey(cid: i64, out: *u8) -> i64
264func dsv_box() -> *i64
269func dsv_slot(b: *i64, i: i64) -> *i64 { return ((b as i64) + i * 8) as *i64 }
272func dsv_snippet_span(txt: *u8, tn: i64, title_end: i64, termptrs: *i64, nterms: i64, tbl: *u8, offout: *i64, lenout: *i64, cutbox: *i64) -> i64
285func dsv_result(body: *u8, b: i64, txt: *u8, tn: i64, cid: i64, q: *u8, qn: i64, termptrs: *i64, nterms: i64, tbl: *u8, url: *u8, ul: i64, webscope: i64) -> i64
338func dsv_style(body: *u8, b: i64) -> i64
called by 2: dss_servedsv_doc_serve calls 1: dsv_cat
348func dsv_u8seq(src: *u8, n: i64, i: i64) -> i64
called by 1: dsv_jesc
367func dsv_jesc(out: *u8, o: i64, src: *u8, n: i64) -> i64
416func dsv_respond_json(out: *u8, status: *u8, body: *u8, b: i64) -> i64
429func dsv_respond(out: *u8, status: *u8, body: *u8, b: i64) -> i64
464func dsv_scope_conf_load() -> i64
called by 1: dsv_default_scope calls 2: ar_resolvear_read
478func dsv_tok_eq(off: i64, len: i64, lit: *u8) -> i64
called by 1: dsv_default_scope calls 1: dsv_slen
487func dsv_default_scope(domain: *u8) -> i64
522func dsv_scope(req: *u8, req_n: i64, domain: *u8, effdom: *u8) -> i64
558func dsv_scope_name(body: *u8, b: i64, scope: i64) -> i64
564func dsv_tabs(body: *u8, b: i64, q: *u8, qn: i64, scope: i64) -> i64
called by 1: dss_serve calls 2: dsv_catdsv_urlenc
582func dsv_now_us() -> i64
called by 1: dss_serve
594func dsv_best_sentence(txt: *u8, tn: i64, termptrs: *i64, nterms: i64, tbl: *u8, offout: *i64, lenout: *i64) -> i64
675func dss_serve(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64
900func dsv_atoin(s: *u8, n: i64, okbox: *i64) -> i64
920func dsv_doc_serve(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64
989func dss_api_openapi(srv: *u8, out: *u8) -> i64
called by 1: main calls 2: dsv_catdsv_respond_json
1180func dss_api_suggest(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64
1221func dss_api_doc(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64