code wiki / (root) / nx_elara_memory.nx

nx_elara_memory.nx

buildroot/runtime/nx_elara_memory.nx

17311 B317 linesdepth 6pulls 7 transitivereach 0 importersview sourcekind tooltopic elara
docsdependenciesstructsconstsfunctions

about

nx_elara_memory.nx -- LONG-TERM RELATIONSHIP MEMORY for the companion (F920/F925 memory axis). The companion mind (nx_elara_state) holds her PRESENT (wardrobe/mood/location/day). This is the other half a real synthetic human needs and every incumbent (Replika's flagship) ships: she REMEMBERS things about YOU and the relationship across time, and RECALLS the relevant ones. Sovereign, first-byte-up. Storage: seg-store plane knowledge/store/elaramem-, one NXR1 record per memory keyed <session>:<ms> {text, kind, ts}. RECALL is keyword-overlap ranked (term match + recency) -- honest IR-lite, not yet semantic embeddings (that is rung 2, when a CPU embed path is wired). SCALABLE: recall maps each segment .docs ONCE and munmaps (the leak-free plane-scan pattern; a naive ss_get loop would crash, seq750). VERBS: remember <session> <text...> [kind] | recall <session> <query...> [max] | selftest license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_canon_cid.nx nx_seg_store.nx nx_elara_memory.nx

imports: nx_syscalls.nxnx_canon_cid.nxnx_seg_store.nx

imported by: nobody (leaf or entry point)

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

main em_eq em_selftest sys_mmap em_cat em_udec sys_now_realtime_ms sys_mmap ↻ sys_clock_gettime_real em_remember sys_mkdir sys_now_realtime_ms ↻ em_len em_salience em_eq ↻ em_score em_lc em_isalnum sys_mmap ↻ em_udec ↻ canon_encode sys_mmap ↻ cc_cmp cc_w32 cc_len sys_munmap em_cat ↻ em_ch ss_begin_cap sys_mmap ↻ ss_add ss_add2 ss_w32 ss_len ss_next_segid sys_mmap ↻ ss_cat ss_readall sys_openat_rd sys_lseek

structs

none

consts

17const EM_MAGIC_1024: i64 = 1024
18const EM_MAGIC_8192: i64 = 8192
19const EM_MAGIC_4096: i64 = 4096
20const EM_MAGIC_65536: i64 = 65536
22const EM_STORE: *u8 = "knowledge/store/elaramem-" as *u8
23const EM_MAXMATCH: i64 = 512
119const EM_SAL_BASE: i64 = 10
120const EM_SAL_PREF: i64 = 30
121const EM_SAL_FACT: i64 = 22
122const EM_SAL_EVENT: i64 = 8
123const EM_SAL_USER: i64 = 15 // per 'you'/'your' hit
124const EM_SAL_LOAD: i64 = 10 // per load-bearing term

functions

25func em_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
26func em_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
27func em_cat(d: *u8, o: i64, s: *u8) -> i64 { var p: i64=o; var i: i64=0; while s[i]!=(0 as u8){ d[p]=s[i]; p=p+1; i=i+1 } return p }
28func em_ch(d: *u8, o: i64, c: i64) -> i64 { d[o]=c as u8; return o+1 }
29func em_udec(d: *u8, o: i64, v: i64) -> i64
37func em_lc(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c }
called by 1: em_score
38func em_isalnum(c: i64) -> i64 { if c>=48 { if c<=57 { return 1 } } if c>=65 { if c<=90 { return 1 } } if c>=97 { if c<=122 { return 1 } } return 0 }
called by 1: em_score
39func em_r32(p: *u8, o: i64) -> i64 { let a: i64=p[o]; let b: i64=p[o+1]; let c: i64=p[o+2]; let d: i64=p[o+3]; return (((((a<<8)|b)<<8)|c)<<8)|d }
called by 2: em_fieldem_recall
41func em_field(rec: *u8, reclen: i64, key: *u8, out: *u8, maxout: i64) -> i64
called by 2: em_recallem_selftest calls 2: em_lenem_r32
70func em_key_prefix(key: *u8, kl: i64, prefix: *u8) -> i64
called by 1: em_recall calls 1: em_len
78func em_score(text: *u8, tn: i64, query: *u8) -> i64
118func em_eq(a: *u8, b: *u8) -> i64 { var i: i64=0; while 1==1 { if a[i]!=b[i] { return 0 } if a[i]==(0 as u8) { return 1 } i=i+1 } return 0 }
called by 2: em_saliencemain
125func em_salience(text: *u8, tn: i64, kind: *u8) -> i64
called by 1: em_remember calls 2: em_eqem_score
137func em_remember(session: *u8, text: *u8, kind: *u8) -> i64
169func em_recall(session: *u8, query: *u8, max: i64) -> i64
267func em_selftest() -> i64
300func main(argc: i64, argv: *i64) -> i64