code wiki / (root) / nx_memindex_emit.nx

nx_memindex_emit.nx

buildroot/runtime/nx_memindex_emit.nx

10449 B242 linesdepth 5pulls 5 transitivereach 0 importersview sourcekind tooltopic memindex
docsdependenciesstructsconstsfunctions

about

nx_memindex_emit.nx -- splice the DERIVED index into a curated markdown file (the MEMORY.md wiring of the conflict-free coindex rail). Sessions APPEND entries to the journal (nx_coindex append -- never editing the shared file); THIS organ is the single writer that regenerates the auto-derived section between whole-line markers: <!-- COINDEX:BEGIN --> ...derived lines (last-write-wins per slug)... <!-- COINDEX:END --> Everything OUTSIDE the markers is preserved BYTE-IDENTICAL (curated sections stay human). FAIL-CLOSED: missing markers -> file untouched. ATOMIC: tmp + fsync + renameat. Serialized under <journal>.lock. EVICTION (2026-07-31, debt 1785558752): the budget gate has always specified a SPLIT -- newest entries stay live in the md block, oldest move into an overflow file COINDEX-OVFL block, nothing is ever lost -- but that capability WAS NEVER IMPLEMENTED. This organ contained zero references to the overflow file, so 4 gate teeth were testing a feature that did not exist, and the whole memindex family read as broken logic when it was in fact an ABSENT CAPABILITY. Built here rather than deleting the teeth (rule 25: build intelligence, never strip features). WHY EVICTION AND NOT REFUSAL: refusing protects the file but leaves the index stale forever, and the harness drops everything past its hard load cliff SILENTLY and TAIL-FIRST. Moving the oldest entries to an overflow file is NOT silent shrinking -- every entry still exists in exactly one of the two blocks (additive, rule 13), and the budget is actually enforced instead of wished for. usage: nx_memindex_emit <journal> <md> [ovfl] [budget] -- legacy: <journal> <md> [budget] The 3rd arg is disambiguated BY CONTENT: all-digits => legacy budget, otherwise the overflow path. That keeps the pre-existing 4th-arg-is-budget contract working (rule 19). With an overflow file the budget measures the DERIVED SECTION; without one it measures the WHOLE composed file and the organ REFUSES rather than write over budget (unchanged behaviour). license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_coindex_core.nx nx_memindex_emit.nx

imports: nx_syscalls.nxnx_coindex_core.nx

imported by: nobody (leaf or entry point)

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

main m_puts sys_write mi_atoi sys_mmap ccz_cat_str ci_lock sys_openat_wr sys_flock sys_close ci_emit sys_mmap ↻ ccz_read sys_openat_rd sys_read sys_close ↻ ci_slug_end ci_slug_eq mi_splice sys_mmap ↻ ccz_read ↻ sys_munmap m_find ccz_slen ccz_cat_str ↻ sys_openat_wr ↻ sys_write ↻ sys_fsync sys_close ↻ sys_renameat ci_unlock sys_flock ↻ sys_close ↻ m_putn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap ↻

structs

none

consts

31const MI_DEFAULT_BUDGET: i64 = 17100
32const K_1024: i64 = 1024
33const K_262144: i64 = 262144
34const K_262143: i64 = 262143
35const MI_NL: i64 = 10
36const MI_MODE: i64 = 420

functions

47func m_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
50func mi_atoi(s: *u8) -> i64
called by 1: main
56func m_putn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
59func m_find(hay: *u8, n: i64, needle: *u8) -> i64
called by 1: mi_splice calls 1: ccz_slen
77func mi_splice() -> i64
122func mi_cut(d: *u8, dn: i64, budget: i64) -> i64
called by 1: main
142func main(argc: i64, argv: *i64) -> i64