nx_companion_memory.nx
buildroot/runtime/nx_companion_memory.nx
about
nx_companion_memory.nx -- R1b of the ELDER AI companion spine: EPISODIC MEMORY. The Replika-differentiator
is that a real companion does not forget -- Elder's memory is APPEND-ONLY and total by construction (rule 13:
additive; history is sacred). Every interaction is one episode appended to the canonical nx_registry over
seg_store, keyed uniquely and enumerable per-persona in chronological order. Recall is (a) total (mem_count
== everything ever said) and (b) content-searchable (mem_search = plant a fact early, find it many turns
later -- LEXICAL here; the semantic layer is R1c via nx_distrib_embed + nx_vec_index). One memory stream per
persona, so Aria's history and Vera's history never mix. license_tier: ORIGINAL
dependencies 2 imports · 5 importers
imports: nx_registry.nxnx_tabrec.nx
imported by: nx_companion_chat.nxnx_companion_memory_gate.nxnx_companion_photo.nxnx_companion_proactive.nxnx_companion_turn.nx
structs
| none |
consts
| 10 | const EPI_MAGIC_1048576: i64 = 1048576 |
| 11 | const EPI_MAGIC_8192: i64 = 8192 |
| 13 | const EPI_PREFIX: *u8 = "knowledge/episodic-" as *u8 |
| 14 | const EPI_KP: *u8 = "epi:" as *u8 |
| 17 | const MF_SESSION: i64 = 0 |
| 18 | const MF_TS: i64 = 1 |
| 19 | const MF_SPEAKER: i64 = 2 |
| 20 | const MF_TEXT: i64 = 3 |
functions
| 23 | func mem_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 24 | func mem_catz(dst: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ dst[o+i]=s[i]; i=i+1 } return o+i } |
| 26 | func mem_pad8(dst: *u8, o: i64, v: i64) -> i64 |
| 33 | func mem_epi_id(buf: *u8, persona: *u8, seq: i64) -> i64 |
| 41 | func mem_idxkey(buf: *u8, persona: *u8) -> i64 |
| 49 | func mem_lc(c: u8) -> u8 { if c >= (65 as u8) { if c <= (90 as u8) { return (c + (32 as u8)) as u8 } } return c } |
| 50 | func mem_ci_find(hay: *u8, hlen: i64, needle: *u8) -> i64 |
| 66 | func mem_count_pfx(prefix: *u8, persona: *u8) -> i64 |
| 76 | func mem_append_pfx(prefix: *u8, persona: *u8, session: *u8, ts: *u8, speaker: *u8, text: *u8) -> i64 |
| 89 | func mem_get_pfx(prefix: *u8, persona: *u8, seq: i64, ptrout: *i64, lenout: *i64) -> i64 |
| 97 | func mem_search_pfx(prefix: *u8, persona: *u8, needle: *u8, out_seqs: *i64, cap: i64) -> i64 called by 3: mem_searchmaincompanion_context_pfx calls 4: mem_count_pfxmem_get_pfxtr_fieldmem_ci_find |
| 121 | func mem_count(persona: *u8) -> i64 { return mem_count_pfx(EPI_PREFIX, persona) } |
| 122 | func mem_append(persona: *u8, session: *u8, ts: *u8, speaker: *u8, text: *u8) -> i64 { return mem_append_pfx(EPI_PREFIX, persona, session, ts, speaker, text) } |
| 123 | func mem_get(persona: *u8, seq: i64, ptrout: *i64, lenout: *i64) -> i64 { return mem_get_pfx(EPI_PREFIX, persona, seq, ptrout, lenout) } |
| 124 | func mem_search(persona: *u8, needle: *u8, out_seqs: *i64, cap: i64) -> i64 { return mem_search_pfx(EPI_PREFIX, persona, needle, out_seqs, cap) } |