code wiki / _hdl_build / nx_ims_monitor.nx
nx_ims_monitor.nx
buildroot/runtime/_hdl_build/nx_ims_monitor.nx
about
nx_ims_monitor.nx -- IMS arc rung A1: READ-ONLY orphan + link-rot MONITOR.
PURPOSE (Information Management System health, sovereign):
Given the published page set and each page's OUTBOUND internal links, find
ORPHANS = published pages with 0 INBOUND internal links, excluding the
designated front-door root(s) (start.html is the root -- it is
expected to be reached directly, never linked-to).
DEAD_LINKS = an outbound internal link whose target page is NOT in the
published set (internal link rot / a 404 waiting to happen).
READ-ONLY BY CONSTRUCTION:
This organ NEVER opens a corpus file for write, NEVER deletes, NEVER renames.
It only READS (the live path uses sys_read_file) and computes in memory. The
gate proves the pure logic with in-memory fixtures (no I/O at all).
COMPOSES (DRY -- zero new corpus/link substrate invented):
nx_wiki_index_builder NxWikiDocStore: the page corpus (rowid -> title/url/
body) + lookup. Fixtures + live both populate this.
nx_wiki_backlinks nx_wiki_forward_links (the ONE shared [[wikilink]]
extractor) + nx_wiki_backlink_slug_matches (the ONE
shared slug resolver) -- so the monitor's notion of
"a link" agrees byte-for-byte with the backlinks
panel and the graph edge builder. No 4th scanner.
nx_syscalls sys_mmap scratch.
LINK MODEL -- the monitor recognises BOTH internal-link conventions a Nishi
page carries, and folds them into ONE outbound-target list per page:
(a) [[wikilink]] -- markdown-body cross-refs (reused extractor).
(b) href="/wiki/<x>.html" -- served-HTML anchors (the live corpus is HTML).
Both are normalised to a bare slug (the "/wiki/" prefix and a trailing
".html" are stripped) so a body link [[econsim]], an href "/wiki/econsim",
and a stored url "/wiki/econsim.html" all resolve to the same node. [[cite:]]
refs are skipped by the reused extractor (they are sources, not page links).
Hygiene: 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 constants;
M8 verdicts propagated. ("loop" is a reserved word -- never used as an ident.)
Status: V1 (IMS arc A1). 2026-06-17. license_tier: ORIGINAL
dependencies 3 imports · 5 importers
imports: nx_syscalls.nxnx_wiki_index_builder.nxnx_wiki_backlinks.nx
imported by: nx_ims_monitor_gate.nxnx_ims_monitor_live.nxnx_wiki_structure_regen.nxnx_wiki_walk_metrics.nxnx_wiki_walkability.nx
structs
| none |
consts
| 45 | const NX_IMS_OK: i64 = 0 |
| 46 | const NX_IMS_BAD_INPUT: i64 = 2720 |
| 47 | const NX_IMS_OVERFLOW: i64 = 2721 |
| 48 | const NX_IMS_LOOP_BUDGET: i64 = 2722 |
| 51 | const NX_IMS_MAX_PAGES: i64 = 1000 // mirrors doc-store docs cap |
| 52 | const NX_IMS_MAX_LINKS_PP: i64 = 512 // outbound links scanned per page |
| 53 | const NX_IMS_MAX_ROOTS: i64 = 16 // designated root pages cap |
| 54 | const NX_IMS_SCAN_BUDGET: i64 = 8000000 // per-body byte-scan cap (M3) |
| 55 | const NX_IMS_MAX_SLUG_LEN: i64 = 256 // a single resolved slug name cap |
| 56 | const NX_IMS_WIKI_PREFIX_LEN: i64 = 6 // len("/wiki/") |
| 57 | const NX_IMS_HTML_SUFFIX_LEN: i64 = 5 // len(".html") |
| 60 | const NX_IMS_QUOTE: i64 = 0x22 // '"' |
| 61 | const NX_IMS_DOT: i64 = 0x2E // '.' |
functions
| 66 | func nx_ims_strip_frag_query(p: *u8, n: i64) -> i64 |
| 82 | func nx_ims_norm_slug(p: *u8, n: i64, out_ptr: *i64) -> i64 |
| 128 | func nx_ims_slug_eq(ap: *u8, an: i64, bp: *u8, bn: i64) -> i64 |
| 155 | func nx_ims_href_links(body: *u8, n: i64, |
| 254 | func nx_ims_collect_targets(body: *u8, n: i64, |
| 281 | func nx_ims_is_root(r: i64, roots: *i64, nroots: i64) -> i64 called by 1: nx_ims_orphans |
| 292 | func nx_ims_resolve_root(store: *NxWikiDocStore, sp: *u8, sn: i64) -> i64 |
| 318 | func nx_ims_inbound_counts(store: *NxWikiDocStore, |
| 407 | func nx_ims_orphans(store: *NxWikiDocStore, called by 3: mainmainreg_decide calls 4: nx_wiki_doc_store_countsys_mmapnx_ims_inbound_countsnx_ims_is_root |
| 443 | func nx_ims_dead_links(store: *NxWikiDocStore, |