code wiki / (root) / nx_companion_rel.nx

nx_companion_rel.nx

buildroot/runtime/nx_companion_rel.nx

8637 B157 linesdepth 6pulls 8 transitivereach 3 importersview sourcekind librarytopic companion
docsdependenciesstructsconstsfunctions

about

nx_companion_rel.nx -- R1d of the ELDER AI companion spine: RELATIONSHIP STATE. Distinct from episodic memory (R1b = the raw immutable log of everything said): this is the evolving SUMMARY of who the user is to Elder -- relationship stage, trust level, durable facts about the person, their recent mood. It is what lets the companion at month 6 relate differently than at day 1, grounded in real shared history. Keyed per (persona,user) so one persona holds a separate, private relationship with each person. Stored in the canonical nx_registry over seg_store (additive: every update is a new version, get returns latest, history kept -- rule 13). never-brick: trust is CLAMPED to 0..100; facts APPEND (never overwrite/lose). All fields are DATA (rule 11/25) -- no policy, no censor; the relationship is whatever the record says it is. license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_registry.nx nx_tabrec.nx nx_companion_rel.nx nx_companion_rel_gate.nx nx_companion_turn.nx

imports: nx_registry.nxnx_tabrec.nx

imported by: nx_companion_rel_gate.nxnx_companion_turn.nx

structs

none

consts

12const REL_MAGIC_16384: i64 = 16384
13const REL_MAGIC_8192: i64 = 8192
15const REL_PREFIX: *u8 = "knowledge/relstate-" as *u8
16const REL_KP: *u8 = "rel:" as *u8
17const REL_IDX: *u8 = "__relidx__" as *u8
20const RF_STAGE: i64 = 0
21const RF_TRUST: i64 = 1
22const RF_FACTS: i64 = 2
23const RF_MOOD: i64 = 3
24const RF_HL: i64 = 4
26const TRUST_MAX: i64 = 100
27const TRUST_MIN: i64 = 0

functions

29func rel_cpz(dst: *u8, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ dst[i]=s[i]; i=i+1 } dst[i]=0 as u8; return i }
30func rel_catn(d: *u8, o: i64, v: i64) -> i64
40func rel_id(buf: *u8, persona: *u8, user: *u8) -> i64
50func rel_update_pfx(prefix: *u8, persona: *u8, user: *u8, stage: *u8, trust: i64, facts: *u8, mood: *u8, hl: *u8) -> i64
63func rel_get_pfx(prefix: *u8, persona: *u8, user: *u8, ptrout: *i64, lenout: *i64) -> i64
called by 2: rel_read5rel_get calls 2: rel_idreg_get
68func rel_getf(rec: *u8, rlen: i64, idx: i64, out: *u8, cap: i64) -> i64
called by 1: rel_read5 calls 1: tr_field
79func rel_read5(prefix: *u8, persona: *u8, user: *u8, stageb: *u8, factsb: *u8, moodb: *u8, hlb: *u8, cap: i64) -> i64
96func rel_note_fact_pfx(prefix: *u8, persona: *u8, user: *u8, fact: *u8) -> i64
109func rel_bump_trust_pfx(prefix: *u8, persona: *u8, user: *u8, delta: i64) -> i64
119func rel_set_stage_pfx(prefix: *u8, persona: *u8, user: *u8, stage: *u8) -> i64
126func rel_set_mood_pfx(prefix: *u8, persona: *u8, user: *u8, mood: *u8) -> i64
135func rel_context_pfx(prefix: *u8, persona: *u8, user: *u8, out: *u8, cap: i64) -> i64
151func rel_update(persona: *u8, user: *u8, stage: *u8, trust: i64, facts: *u8, mood: *u8, hl: *u8) -> i64 { return rel_update_pfx(REL_PREFIX, persona, user, stage, trust, facts, mood, hl) }
calls 1: rel_update_pfx
152func rel_get(persona: *u8, user: *u8, ptrout: *i64, lenout: *i64) -> i64 { return rel_get_pfx(REL_PREFIX, persona, user, ptrout, lenout) }
calls 1: rel_get_pfx
153func rel_note_fact(persona: *u8, user: *u8, fact: *u8) -> i64 { return rel_note_fact_pfx(REL_PREFIX, persona, user, fact) }
154func rel_bump_trust(persona: *u8, user: *u8, delta: i64) -> i64 { return rel_bump_trust_pfx(REL_PREFIX, persona, user, delta) }
155func rel_set_stage(persona: *u8, user: *u8, stage: *u8) -> i64 { return rel_set_stage_pfx(REL_PREFIX, persona, user, stage) }
156func rel_set_mood(persona: *u8, user: *u8, mood: *u8) -> i64 { return rel_set_mood_pfx(REL_PREFIX, persona, user, mood) }
157func rel_context(persona: *u8, user: *u8, out: *u8, cap: i64) -> i64 { return rel_context_pfx(REL_PREFIX, persona, user, out, cap) }
calls 1: rel_context_pfx