code wiki / (root) / nx_companion_memory.nx

nx_companion_memory.nx

buildroot/runtime/nx_companion_memory.nx

5893 B124 linesdepth 6pulls 8 transitivereach 7 importersview sourcekind librarytopic companion
docsdependenciesstructsconstsfunctions

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

nx_registry.nx nx_tabrec.nx nx_companion_memory.nx nx_companion_chat.nx nx_companion_memory_gate.nx nx_companion_photo.nx nx_companion_proactive.nx nx_companion_turn.nx

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

10const EPI_MAGIC_1048576: i64 = 1048576
11const EPI_MAGIC_8192: i64 = 8192
13const EPI_PREFIX: *u8 = "knowledge/episodic-" as *u8
14const EPI_KP: *u8 = "epi:" as *u8
17const MF_SESSION: i64 = 0
18const MF_TS: i64 = 1
19const MF_SPEAKER: i64 = 2
20const MF_TEXT: i64 = 3

functions

23func mem_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
24func 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 }
26func mem_pad8(dst: *u8, o: i64, v: i64) -> i64
called by 2: mem_epi_idmain
33func mem_epi_id(buf: *u8, persona: *u8, seq: i64) -> i64
41func mem_idxkey(buf: *u8, persona: *u8) -> i64
49func mem_lc(c: u8) -> u8 { if c >= (65 as u8) { if c <= (90 as u8) { return (c + (32 as u8)) as u8 } } return c }
called by 2: ci_findmem_ci_find
50func mem_ci_find(hay: *u8, hlen: i64, needle: *u8) -> i64
called by 2: mem_search_pfxmain calls 1: mem_lc
66func mem_count_pfx(prefix: *u8, persona: *u8) -> i64
76func mem_append_pfx(prefix: *u8, persona: *u8, session: *u8, ts: *u8, speaker: *u8, text: *u8) -> i64
89func mem_get_pfx(prefix: *u8, persona: *u8, seq: i64, ptrout: *i64, lenout: *i64) -> i64
97func mem_search_pfx(prefix: *u8, persona: *u8, needle: *u8, out_seqs: *i64, cap: i64) -> i64
121func mem_count(persona: *u8) -> i64 { return mem_count_pfx(EPI_PREFIX, persona) }
called by 2: mainrecall_recent calls 1: mem_count_pfx
122func mem_append(persona: *u8, session: *u8, ts: *u8, speaker: *u8, text: *u8) -> i64 { return mem_append_pfx(EPI_PREFIX, persona, session, ts, speaker, text) }
called by 2: mainmain calls 1: mem_append_pfx
123func mem_get(persona: *u8, seq: i64, ptrout: *i64, lenout: *i64) -> i64 { return mem_get_pfx(EPI_PREFIX, persona, seq, ptrout, lenout) }
called by 2: mainrecall_recent calls 1: mem_get_pfx