code wiki / (root) / nx_companion_mind.nx

nx_companion_mind.nx

buildroot/runtime/nx_companion_mind.nx

11965 B258 linesdepth 5pulls 6 transitivereach 8 importersview sourcekind librarytopic companion
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tool_run.nx nx_lorebook.nx nx_companion_mind.nx nx_gen_mind_gate.nx nx_gen_orchestrator.nx

imports: nx_syscalls.nxnx_tool_run.nxnx_lorebook.nx

imported by: nx_gen_mind_gate.nxnx_gen_orchestrator.nx

structs

none

consts

18const MIND_ELF_MEM: *u8 = "/volume1/homes/elderwesto/nishihost/nx_elara_memory.elf" as *u8
19const MIND_ELF_CHAR: *u8 = "/volume1/homes/elderwesto/nishihost/nx_charmem.elf" as *u8
20const MIND_ELF_STATE: *u8 = "/volume1/homes/elderwesto/nishihost/nx_elara_state.elf" as *u8
22const MIND_CAP: i64 = 65536
24const MIND_FORK_TIMEOUT_MS: i64 = 4000
26const MIND_RECALL_MAX: *u8 = "5" as *u8
28const MIND_SESSION_FILE: *u8 = "elara_session.txt" as *u8
29const MIND_SESSION_DEFAULT: *u8 = "elara" as *u8
31const MIND_SESSION_CAP: i64 = 32
33const MIND_QUERY_CAP: i64 = 512
34const MIND_BLOCK_CAP: i64 = 4096
35const MIND_CH_QUOTE: i64 = 34
36const MIND_CH_BSLASH: i64 = 92
37const MIND_CH_NL: i64 = 10
38const MIND_CH_SPACE: i64 = 32
39const MIND_CH_LOWER_N: i64 = 110
40const MIND_FD_STDERR: i64 = 2
41const MIND_I64_BYTES: i64 = 8

functions

43func mind_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: mind_findmind_jstr
44func 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 }
47func mind_find(buf: *u8, n: i64, from: i64, needle: *u8) -> i64
68func mind_run(elf: *u8, nargs: i64, a1: *u8, a2: *u8, a3: *u8, a4: *u8, out: *u8) -> i64
87func mind_session(out: *u8) -> i64
112func mind_query(umsg: *u8, umlen: i64, q: *u8) -> i64
123func mind_jstr(body: *u8, blen: i64, from: i64, key: *u8, out: *u8, cap: i64, endpos: *i64) -> i64
154func mind_state_block(session: *u8, out: *u8, cap: i64) -> i64
172func mind_rel_block(session: *u8, out: *u8, cap: i64) -> i64
186func mind_mem_block(session: *u8, umsg: *u8, umlen: i64, out: *u8, cap: i64) -> i64
220func mind_world_block(umsg: *u8, umlen: i64, out: *u8, cap: i64) -> i64
234func go_mind_context(umsg: *u8, umlen: i64, out: *u8, cap: i64) -> i64
249func go_mind_remember(umsg: *u8, umlen: i64) -> i64