code wiki / (root) / nx_store_janitor.nx

nx_store_janitor.nx

buildroot/runtime/nx_store_janitor.nx

12138 B261 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic store
docsdependenciesstructsconstsfunctions

about

nx_store_janitor.nx -- reclaim SUPERSEDED seg-store segment files. The janitor pass that seq724/RK013 named as reclaimable and nobody had built. MEASURED 2026-07-30 BEFORE WRITING THIS: knowledge/store holds 63,669 MB across 14,585 segment .docs files, while all 1,088 manifests TOGETHER reference only 3,031 live segments. debt-manifest.txt lists exactly TWO segments while 2,055 debt-seg-*.docs exist on disk, ~2.4 GB for one plane. So roughly 79 percent of the information plane's bytes are segments no reader can ever reach: the seg-store is append-only and every commit writes a NEW segment, so superseded generations simply accumulate forever. WHY THIS IS SAFE BY CONSTRUCTION: the manifest IS the definition of live. ss_manifest/ss_scan_seglist read ONLY segments listed there, so a file whose segid is absent from its own plane's manifest is unreachable BY DEFINITION, not by inference. That is the whole safety argument and it is why this tool refuses to run when it cannot read the manifest -- an unknown live set means an unknown safe set. RULE 13 -- MOVE ASIDE, NEVER DELETE. Superseded files are RENAMED into knowledge/store/retired/ (the convention already present on the box). Nothing is unlinked, so a mistake is reversible by renaming back. DRY RUN IS THE DEFAULT: it reports what it WOULD move and touches nothing. Pass 'apply' to actually move. EXIT: 0 clean/reported - 2 usage - 3 REFUSED (manifest unreadable or empty live set) - 4 nothing superseded license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_store_janitor.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap sj_cat sys_write sj_len sys_openat_rd sys_read sys_close sj_num sys_mmap ↻ sys_munmap sys_getdents64 dirent_reclen dirent_name sj_size sys_mmap ↻ sys_fstatat sys_munmap ↻ sys_renameat sys_munmap ↻

structs

none

consts

23const SJ_MANI: i64 = 262144
24const SJ_DBUF: i64 = 262144
25const SJ_LIVE: i64 = 65536
26const SJ_MAXLIVE: i64 = 8192
27const SJ_PATH: i64 = 1024
28const SJ_MSG: i64 = 8192
29const SJ_STAT: i64 = 256
30const SJ_STAT_SIZE_OFF: i64 = 48
31const SJ_NL: i64 = 10
32const SJ_DOT: i64 = 46
33const SJ_SLASH: i64 = 47
34const SJ_STDOUT: i64 = 1
35const SJ_EXIT_USAGE: i64 = 2
36const SJ_EXIT_REFUSED: i64 = 3
37const SJ_EXIT_NONE: i64 = 4
38const SJ_MB: i64 = 1048576

functions

40func sj_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: main
41func sj_cat(d: *u8, off: i64, s: *u8) -> i64
called by 1: main
46func sj_num(d: *u8, off: i64, v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_munmap
60func sj_size(path: *u8) -> i64
called by 1: main calls 3: sys_mmapsys_fstatatsys_munmap
69func main(argc: i64, argv: *i64) -> i64