nx_elara_memory.nx
buildroot/runtime/nx_elara_memory.nx
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
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
structs
| none |
consts
| 17 | const EM_MAGIC_1024: i64 = 1024 |
| 18 | const EM_MAGIC_8192: i64 = 8192 |
| 19 | const EM_MAGIC_4096: i64 = 4096 |
| 20 | const EM_MAGIC_65536: i64 = 65536 |
| 22 | const EM_STORE: *u8 = "knowledge/store/elaramem-" as *u8 |
| 23 | const EM_MAXMATCH: i64 = 512 |
| 119 | const EM_SAL_BASE: i64 = 10 |
| 120 | const EM_SAL_PREF: i64 = 30 |
| 121 | const EM_SAL_FACT: i64 = 22 |
| 122 | const EM_SAL_EVENT: i64 = 8 |
| 123 | const EM_SAL_USER: i64 = 15 // per 'you'/'your' hit |
| 124 | const EM_SAL_LOAD: i64 = 10 // per load-bearing term |
functions
| 25 | func 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 } |
| 26 | func em_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 27 | func 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 } |
| 28 | func em_ch(d: *u8, o: i64, c: i64) -> i64 { d[o]=c as u8; return o+1 } |
| 29 | func em_udec(d: *u8, o: i64, v: i64) -> i64 |
| 37 | func em_lc(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c } called by 1: em_score |
| 38 | func 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 |
| 39 | func 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 } |
| 41 | func em_field(rec: *u8, reclen: i64, key: *u8, out: *u8, maxout: i64) -> i64 |
| 70 | func em_key_prefix(key: *u8, kl: i64, prefix: *u8) -> i64 |
| 78 | func em_score(text: *u8, tn: i64, query: *u8) -> i64 |
| 118 | func 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 } |
| 125 | func em_salience(text: *u8, tn: i64, kind: *u8) -> i64 |
| 137 | func em_remember(session: *u8, text: *u8, kind: *u8) -> i64 called by 2: em_selftestmain calls 15: sys_mkdirsys_now_realtime_msem_lenem_saliencesys_mmapem_udec+9 |
| 169 | func em_recall(session: *u8, query: *u8, max: i64) -> i64 |
| 267 | func em_selftest() -> i64 |
| 300 | func main(argc: i64, argv: *i64) -> i64 |