nx_companion_mind.nx
buildroot/runtime/nx_companion_mind.nx
about
nx_companion_mind.nx -- THE MIND CONTEXT (companionchat CC0, 2026-08-30): ONE composer that puts the companion's
LONG-TERM MEMORY (nx_elara_memory recall), RELATIONSHIP STATE (nx_charmem ctx) and TYPED PRESENT-TENSE STATE
(nx_elara_state context) into the chat turn's system prompt.
FOUND BY IMPORT-LIST MEASUREMENT: nx_gen_orchestrator carried persona, wardrobe and the affect vector and NEVER
consulted these three PROMOTED organs, so the intelligence was built and dark. This lib COMPOSES them by forking
the serving-root binaries (the nx_companion_sota idiom) -- it re-implements none of them -- and it FABRICATES
NOTHING: an empty store contributes zero bytes, an unset present is never narrated as a fact, a wedged organ costs
the turn at most MIND_FORK_TIMEOUT_MS and then contributes nothing.
Contract symbol: go_mind_context (the companionchat.matrix CC0 watch), measured in the orchestrator that calls it.
Gate: nx_gen_mind_gate (fixture sessions under /tmp, positive + neg-control-empty-session teeth).
CC3 (2026-08-30): the LOREBOOK plane rides the same composer -- em_lorebook (nx_lorebook.nx, in-process, no fork) injects
keyed world facts only when the turn touches a trigger; a budget refusal is logged to stderr and contributes ZERO bytes.
license_tier: ORIGINAL
dependencies 3 imports · 2 importers
imports: nx_syscalls.nxnx_tool_run.nxnx_lorebook.nx
imported by: nx_gen_mind_gate.nxnx_gen_orchestrator.nx
structs
| none |
consts
| 18 | const MIND_ELF_MEM: *u8 = "/volume1/homes/elderwesto/nishihost/nx_elara_memory.elf" as *u8 |
| 19 | const MIND_ELF_CHAR: *u8 = "/volume1/homes/elderwesto/nishihost/nx_charmem.elf" as *u8 |
| 20 | const MIND_ELF_STATE: *u8 = "/volume1/homes/elderwesto/nishihost/nx_elara_state.elf" as *u8 |
| 22 | const MIND_CAP: i64 = 65536 |
| 24 | const MIND_FORK_TIMEOUT_MS: i64 = 4000 |
| 26 | const MIND_RECALL_MAX: *u8 = "5" as *u8 |
| 28 | const MIND_SESSION_FILE: *u8 = "elara_session.txt" as *u8 |
| 29 | const MIND_SESSION_DEFAULT: *u8 = "elara" as *u8 |
| 31 | const MIND_SESSION_CAP: i64 = 32 |
| 33 | const MIND_QUERY_CAP: i64 = 512 |
| 34 | const MIND_BLOCK_CAP: i64 = 4096 |
| 35 | const MIND_CH_QUOTE: i64 = 34 |
| 36 | const MIND_CH_BSLASH: i64 = 92 |
| 37 | const MIND_CH_NL: i64 = 10 |
| 38 | const MIND_CH_SPACE: i64 = 32 |
| 39 | const MIND_CH_LOWER_N: i64 = 110 |
| 40 | const MIND_FD_STDERR: i64 = 2 |
| 41 | const MIND_I64_BYTES: i64 = 8 |
functions
| 43 | func mind_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 44 | func mind_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var i: i64 = 0; while s[i] != (0 as u8) { dst[o] = s[i]; o = o + 1; i = i + 1 } return o } |
| 47 | func mind_find(buf: *u8, n: i64, from: i64, needle: *u8) -> i64 |
| 68 | func mind_run(elf: *u8, nargs: i64, a1: *u8, a2: *u8, a3: *u8, a4: *u8, out: *u8) -> i64 called by 5: mind_state_blockmind_rel_blockmind_mem_blockgo_mind_remembermain calls 2: sys_mmaptr_run_capture_to |
| 87 | func mind_session(out: *u8) -> i64 |
| 112 | func mind_query(umsg: *u8, umlen: i64, q: *u8) -> i64 |
| 123 | func mind_jstr(body: *u8, blen: i64, from: i64, key: *u8, out: *u8, cap: i64, endpos: *i64) -> i64 |
| 154 | func mind_state_block(session: *u8, out: *u8, cap: i64) -> i64 |
| 172 | func mind_rel_block(session: *u8, out: *u8, cap: i64) -> i64 |
| 186 | func mind_mem_block(session: *u8, umsg: *u8, umlen: i64, out: *u8, cap: i64) -> i64 |
| 220 | func mind_world_block(umsg: *u8, umlen: i64, out: *u8, cap: i64) -> i64 |
| 234 | func go_mind_context(umsg: *u8, umlen: i64, out: *u8, cap: i64) -> i64 |
| 249 | func go_mind_remember(umsg: *u8, umlen: i64) -> i64 |