nx_wiki_backlinks.nx
buildroot/runtime/wiki/nx_wiki_backlinks.nx
about
nx_wiki_backlinks.nx -- wiki R4: "what links here" reverse-link index.
COMPOSES (zero new storage/parse substrate introduced):
nx_wiki_index_builder NxWikiDocStore: doc_count + per-rowid
(title, url, body) lookup -- the page corpus.
nx_syscalls sys_mmap for the reverse-map scratch.
WHAT IT DOES:
Every wiki page body carries forward [[wikilink]] cross-references
(resolved/rendered by nx_wiki_doc_render). This organ INVERTS them:
given a target slug, it enumerates the source pages whose bodies link
TO it. That is the classic wiki "What links here" affordance, computed
from ground truth (the actual bodies in the doc store), never a
hand-maintained list.
IDENTITY MODEL:
A page's identity ("slug") is its store URL field as-stored. The wiki
convention is a bare name (e.g. "alpha") or "/wiki/alpha"; a [[alpha]]
wikilink targets that same slug. nx_wiki_backlink_slug_matches compares
a link target against a stored slug allowing the optional "/wiki/"
prefix on either side, so both conventions resolve.
[[cite:...]] links are SKIPPED -- those are supporting-source citations
handled by nx_wiki_cite_render, not page-to-page cross-references.
Hygiene (NISHI_CODE_HYGIENE_STANDARD): M1 out-params not *T returns;
M3 every while has a hard iter cap; M5 every buffer index bounded;
M6 no pretend stubs; M7 named sizing constants; M8 verdicts propagated.
Status: V1 (wiki R4). 2026-06-15. license_tier: ORIGINAL
dependencies 2 imports · 5 importers
imports: nx_syscalls.nxnx_wiki_index_builder.nx
imported by: _wiki_backlinks_gate.nxnx_ims_monitor.nxnx_wiki_doc_handler.nxnx_wiki_graph.nxnx_wiki_shell.nx
structs
| none |
consts
| 35 | const NX_WBL_OK: i64 = 0 |
| 36 | const NX_WBL_BAD_INPUT: i64 = 2640 |
| 37 | const NX_WBL_OVERFLOW: i64 = 2641 |
| 38 | const NX_WBL_LOOP_BUDGET: i64 = 2642 |
| 41 | const NX_WBL_MAX_LINKS_PER_PAGE: i64 = 512 // forward links scanned per body |
| 42 | const NX_WBL_MAX_LINK_LEN: i64 = 256 // a single [[target]] name cap |
| 43 | const NX_WBL_MAX_PAGES: i64 = 1000 // mirrors doc-store docs cap |
| 44 | const NX_WBL_SCAN_BUDGET: i64 = 8000000 // per-body byte-scan cap (M3) |
| 45 | const NX_WBL_WIKI_PREFIX_LEN: i64 = 6 // len("/wiki/") |
| 48 | const NX_WBL_LBRACKET: i64 = 0x5B // '[' |
| 49 | const NX_WBL_RBRACKET: i64 = 0x5D // ']' |
| 50 | const NX_WBL_COLON: i64 = 0x3A // ':' |
functions
| 53 | func nx_wbl_slen(s: *u8) -> i64 |
| 65 | func nx_wbl_strip_wiki(p: *u8, n: i64, out_ptr: *i64) -> i64 |
| 82 | func nx_wiki_backlink_slug_matches(lp: *u8, ln: i64, sp: *u8, sn: i64) -> i64 |
| 111 | func nx_wiki_forward_links(body: *u8, n: i64, |
| 198 | func nx_wiki_backlinks_of(store: *NxWikiDocStore, |
| 263 | func nx_wbl_emit(out: *u8, off: i64, cap: i64, s: *u8) -> i64 called by 1: nx_wiki_backlinks_panel |
| 272 | func nx_wbl_emit_bytes(out: *u8, off: i64, cap: i64, src: *u8, n: i64) -> i64 called by 1: nx_wiki_backlinks_panel |
| 283 | func nx_wiki_backlinks_panel(store: *NxWikiDocStore, |