code wiki / _hdl_build / nx_ims_monitor.nx

nx_ims_monitor.nx

buildroot/runtime/_hdl_build/nx_ims_monitor.nx

22409 B510 linesdepth 6pulls 6 transitivereach 8 importersview sourcekind librarytopic ims
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_wiki_index_builder.nx nx_wiki_backlinks.nx nx_ims_monitor.nx nx_ims_monitor_gate.nx nx_ims_monitor_live.nx nx_wiki_structure_regen.nx nx_wiki_walk_metrics.nx nx_wiki_walkability.nx

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

45const NX_IMS_OK: i64 = 0
46const NX_IMS_BAD_INPUT: i64 = 2720
47const NX_IMS_OVERFLOW: i64 = 2721
48const NX_IMS_LOOP_BUDGET: i64 = 2722
51const NX_IMS_MAX_PAGES: i64 = 1000 // mirrors doc-store docs cap
52const NX_IMS_MAX_LINKS_PP: i64 = 512 // outbound links scanned per page
53const NX_IMS_MAX_ROOTS: i64 = 16 // designated root pages cap
54const NX_IMS_SCAN_BUDGET: i64 = 8000000 // per-body byte-scan cap (M3)
55const NX_IMS_MAX_SLUG_LEN: i64 = 256 // a single resolved slug name cap
56const NX_IMS_WIKI_PREFIX_LEN: i64 = 6 // len("/wiki/")
57const NX_IMS_HTML_SUFFIX_LEN: i64 = 5 // len(".html")
60const NX_IMS_QUOTE: i64 = 0x22 // '"'
61const NX_IMS_DOT: i64 = 0x2E // '.'

functions

66func nx_ims_strip_frag_query(p: *u8, n: i64) -> i64
82func nx_ims_norm_slug(p: *u8, n: i64, out_ptr: *i64) -> i64
128func nx_ims_slug_eq(ap: *u8, an: i64, bp: *u8, bn: i64) -> i64
254func nx_ims_collect_targets(body: *u8, n: i64,
281func nx_ims_is_root(r: i64, roots: *i64, nroots: i64) -> i64
called by 1: nx_ims_orphans
292func nx_ims_resolve_root(store: *NxWikiDocStore, sp: *u8, sn: i64) -> i64
318func nx_ims_inbound_counts(store: *NxWikiDocStore,
407func nx_ims_orphans(store: *NxWikiDocStore,