code wiki / wiki / nx_wiki_backlinks.nx

nx_wiki_backlinks.nx

buildroot/runtime/wiki/nx_wiki_backlinks.nx

14942 B350 linesdepth 5pulls 5 transitivereach 45 importersview sourcekind librarytopic wiki
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_wiki_index_builder.nx nx_wiki_backlinks.nx _wiki_backlinks_gate.nx nx_ims_monitor.nx nx_wiki_doc_handler.nx nx_wiki_graph.nx nx_wiki_shell.nx

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

35const NX_WBL_OK: i64 = 0
36const NX_WBL_BAD_INPUT: i64 = 2640
37const NX_WBL_OVERFLOW: i64 = 2641
38const NX_WBL_LOOP_BUDGET: i64 = 2642
41const NX_WBL_MAX_LINKS_PER_PAGE: i64 = 512 // forward links scanned per body
42const NX_WBL_MAX_LINK_LEN: i64 = 256 // a single [[target]] name cap
43const NX_WBL_MAX_PAGES: i64 = 1000 // mirrors doc-store docs cap
44const NX_WBL_SCAN_BUDGET: i64 = 8000000 // per-body byte-scan cap (M3)
45const NX_WBL_WIKI_PREFIX_LEN: i64 = 6 // len("/wiki/")
48const NX_WBL_LBRACKET: i64 = 0x5B // '['
49const NX_WBL_RBRACKET: i64 = 0x5D // ']'
50const NX_WBL_COLON: i64 = 0x3A // ':'

functions

53func nx_wbl_slen(s: *u8) -> i64
65func nx_wbl_strip_wiki(p: *u8, n: i64, out_ptr: *i64) -> i64
263func nx_wbl_emit(out: *u8, off: i64, cap: i64, s: *u8) -> i64
272func nx_wbl_emit_bytes(out: *u8, off: i64, cap: i64, src: *u8, n: i64) -> i64