code wiki / _hdl_build / nx_memhealth.nx
nx_memhealth.nx
buildroot/runtime/_hdl_build/nx_memhealth.nx
about
nx_memhealth.nx -- SOVEREIGN health instrument for the laptop-local memory corpus. READ-ONLY.
CONVERTED TO nx_memplane_lib 2026-08-07. It now owns only the analysis -- document frequency, the
duplicate ladder, the series and co-authorship discriminators, the cross-name index. Walk, name
table, link scanner, read, join and the derived-artefact test come from the lib.
⚠THIS ORGAN WAS THE THIRD VICTIM of the dump-suppression bug, precisely because it kept a private
hardcoded list while its siblings were converted. The conversion retires that list.
WHY IT EXISTS
-------------
nx_memcliff keeps MEMORY.md under the harness cliff (25,000 B / 200 lines, both measured). But the
index exists to make memories FINDABLE, and a 25,000 B ceiling can only ever NAME about 35 files
out of 2,181. Everything else is reached by following links, or not at all -- which makes link
integrity the whole retrieval system, and nothing was measuring it.
WHAT IT MEASURES (each a defect, not a statistic)
* DANGLING FROM THE INDEX -- a pointer in MEMORY.md to a file that does not exist. Every session
reads that file, so its pointers are the only ones GUARANTEED to be followed. Gate condition.
* DANGLING ANYWHERE -- 373 corpus-wide; the file the index labels "Read FIRST" emitted 11 alone.
* ORPHANS -- 581 files nothing points to. Written, then unreachable.
* DUPLICATE CANDIDATES -- the ladder below.
THE DUPLICATE LADDER, each rung measured rather than assumed:
1 slug prefix only ............ 67 candidates
2 + raw token overlap >=400 ... 13
3 + rarity weighting .......... 10 (true dups rank to the top: 800, 571)
4 + sequence-marker rule ...... 3
plus a CROSS-NAME index (shared rare tokens, no slug similarity required), because
★★★★★★ A SLUG-ANCHORED DETECTOR CANNOT SEE A DUPLICATE THAT WAS NAMED DIFFERENTLY -- AND A
DUPLICATE IS EXACTLY THE THING TWO AUTHORS NAME DIFFERENTLY.
⚠ AND ITS CEILING, MEASURED: the two files stating the store law share ZERO rare tokens, so every
lexical method here is blind to them. Independent wording is what makes a rediscovery a
rediscovery, and it is what defeats lexical detection. Found only by ranked search (nx_memfind).
usage: nx_memhealth [--dir <memdir>] [--list] [--dups]
exit: 0 = front door intact; 1 = MEMORY.md contains a dangling pointer
Sovereign: imports nx_memplane_lib. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_memplane_lib.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 41 | const MH_DIR: *u8 = "/mnt/c/Users/elder/.claude/projects/C--Users-elder/memory" |
| 42 | const MH_IDX: *u8 = "MEMORY.md" |
| 43 | const MH_FBUF: i64 = 1048576 |
| 44 | const MH_MSG: i64 = 16384 |
| 45 | const MH_DUPPFX: i64 = 22 // shared normalised prefix that flags a near-duplicate slug |
| 46 | const MH_TOK: i64 = 16384 |
| 47 | const MH_DF: i64 = 262144 |
| 48 | const MH_RARE: i64 = 20 // in >20 of 2181 files (~1%) => template, not topic |
| 49 | const MH_TOPK: i64 = 10 |
| 50 | const MH_POST: i64 = 16 |
| 51 | const MH_PIDX: i64 = 65536 |
| 52 | const MH_PAIRH: i64 = 262144 |
| 53 | const MH_MINSHARE: i64 = 3 |
functions
| 57 | func mh_tokhas(set: *i64, h: i64) -> i64 called by 1: mh_pairsim |
| 69 | func mh_tokput(set: *i64, h: i64) -> i64 |
| 81 | func mh_tokenise(buf: *u8, n: i64, set: *i64) -> i64 |
| 114 | func mh_dfslot(dfk: *i64, h: i64) -> i64 called by 1: mh_tokenise_df |
| 126 | func mh_dfget(dfk: *i64, dfv: *i64, h: i64) -> i64 |
| 138 | func mh_tokenise_df(buf: *u8, n: i64, set: *i64, dfk: *i64, dfv: *i64) -> i64 |
| 173 | func mh_rarecount(buf: *u8, n: i64, seen: *i64, dfk: *i64, dfv: *i64) -> i64 |
| 209 | func mh_sesshash(buf: *u8, n: i64) -> i64 |
| 253 | func mh_pairsim(dir: *u8, na: *u8, nb: *u8, fbuf: *u8, fbuf2: *u8, |
| 302 | func mh_isdigitc(c: u8) -> i64 called by 1: mh_is_series |
| 308 | func mh_common(a: *u8, b: *u8) -> i64 |
| 317 | func mh_is_series(a: *u8, b: *u8) -> i64 |
| 332 | func mh_cmp(a: *u8, b: *u8) -> i64 called by 1: main |
| 346 | func mh_norm(dst: *u8, src: *u8) -> i64 called by 1: main |
| 364 | func mh_post_slot(ptok: *i64, h: i64) -> i64 called by 1: main |
| 376 | func mh_pair_bump(pk: *i64, pv: *i64, key: i64) -> i64 called by 1: main |
| 388 | func main(argc: i64, argv: *i64) -> i64 |