Add memory graph agent profile import

This commit is contained in:
Meta Vens 2026-05-18 01:48:03 +01:00
commit 17542726e6
7 changed files with 277 additions and 2 deletions

View file

@ -102,6 +102,7 @@ pub use memory_graph::load_memory_graph_snapshot;
pub use memory_graph::memory_graph_cache;
pub use memory_graph::memory_graph_domain_id;
pub use memory_graph::memory_graph_edge_id;
pub use memory_graph::memory_graph_from_agent_memories;
pub use memory_graph::memory_graph_from_epiphany_graphs;
pub use memory_graph::memory_graph_node_id;
pub use memory_graph::plan_memory_graph_context_cut;

View file

@ -28,6 +28,7 @@ pub use freshness::derive_memory_graph_freshness;
pub use ids::memory_graph_domain_id;
pub use ids::memory_graph_edge_id;
pub use ids::memory_graph_node_id;
pub use profiles::memory_graph_from_agent_memories;
pub use profiles::memory_graph_from_epiphany_graphs;
pub use store::EpiphanyMemoryGraphEntry;
pub use store::MEMORY_GRAPH_KEY;

View file

@ -0,0 +1,271 @@
use crate::agent_memory::EpiphanyAgentMemoryEntry;
use crate::agent_memory::GhostlightGoal;
use crate::agent_memory::GhostlightMemory;
use crate::agent_memory::GhostlightValue;
use crate::memory_graph::EpiphanyMemoryDomain;
use crate::memory_graph::EpiphanyMemoryGraphSnapshot;
use crate::memory_graph::EpiphanyMemoryLifecycle;
use crate::memory_graph::EpiphanyMemoryNode;
use crate::memory_graph::EpiphanyMemoryNodeKind;
use crate::memory_graph::EpiphanyMemoryProfile;
use crate::memory_graph::EpiphanyMemorySummary;
use crate::memory_graph::memory_graph_domain_id;
use crate::memory_graph::memory_graph_node_id;
pub fn memory_graph_from_agent_memories(
graph_id: impl Into<String>,
entries: &[EpiphanyAgentMemoryEntry],
) -> EpiphanyMemoryGraphSnapshot {
let mut domains = Vec::new();
let mut nodes = Vec::new();
let mut summaries = Vec::new();
for entry in entries {
let domain_id = memory_graph_domain_id(
EpiphanyMemoryProfile::RoleSelf,
"role",
entry.role_id.as_str(),
);
domains.push(EpiphanyMemoryDomain {
id: domain_id.clone(),
profile: EpiphanyMemoryProfile::RoleSelf,
title: format!("{} role self-memory", entry.role_id),
description: Some(
"Reviewed role dossier memory imported into the shared memory graph.".to_string(),
),
lifecycle: EpiphanyMemoryLifecycle::Accepted,
});
let before = nodes.len();
import_memories(
&domain_id,
&entry.role_id,
"semantic",
&entry.agent.memories.semantic,
&mut nodes,
);
import_memories(
&domain_id,
&entry.role_id,
"episodic",
&entry.agent.memories.episodic,
&mut nodes,
);
import_memories(
&domain_id,
&entry.role_id,
"relationship",
&entry.agent.memories.relationship_summaries,
&mut nodes,
);
import_goals(&domain_id, &entry.role_id, &entry.agent.goals, &mut nodes);
import_values(
&domain_id,
&entry.role_id,
&entry.agent.canonical_state.values,
&mut nodes,
);
let role_node_ids = nodes[before..]
.iter()
.map(|node| node.id.clone())
.collect::<Vec<_>>();
if !role_node_ids.is_empty() {
summaries.push(EpiphanyMemorySummary {
id: format!("summary-role-self-{}", entry.role_id),
domain_id: domain_id.clone(),
covers_node_ids: role_node_ids,
target: format!("role:{}", entry.role_id),
claim: format!(
"{} reviewed role self-memory records are available in the shared memory graph.",
entry.role_id
),
question: "Which memory should shape this role's next context packet?".to_string(),
tension: "Role memory is self truth, not project truth.".to_string(),
action_implication: "Use this summary for role-local context; keep project architecture in repo profiles.".to_string(),
anchor_count: 0,
freshness: crate::memory_graph::EpiphanyMemoryFreshnessStatus::Ready,
confidence: 80,
..Default::default()
});
}
}
EpiphanyMemoryGraphSnapshot {
schema_version: Some("epiphany.memory_graph.v0".to_string()),
graph_id: graph_id.into(),
domains,
nodes,
summaries,
freshness: Some(crate::memory_graph::EpiphanyMemoryFreshness {
status: crate::memory_graph::EpiphanyMemoryFreshnessStatus::Ready,
note: Some("Imported from reviewed role dossier memory.".to_string()),
..Default::default()
}),
..Default::default()
}
}
fn import_memories(
domain_id: &str,
role_id: &str,
memory_kind: &str,
memories: &[GhostlightMemory],
nodes: &mut Vec<EpiphanyMemoryNode>,
) {
for memory in memories {
nodes.push(EpiphanyMemoryNode {
id: memory_graph_node_id(domain_id, memory_kind, memory.memory_id.as_str(), None),
domain_id: domain_id.to_string(),
profile: EpiphanyMemoryProfile::RoleSelf,
kind: EpiphanyMemoryNodeKind::RoleMemory,
title: format!("{role_id} {memory_kind} memory"),
claim: memory.summary.clone(),
question: "How should this memory shape future role judgment?".to_string(),
tension: String::new(),
action_implication: format!("Use as {role_id} role-local memory, not project truth."),
source_hashes: vec!["anchor:missing".to_string()],
lifecycle: EpiphanyMemoryLifecycle::Accepted,
salience: score_to_u32(memory.salience),
confidence: score_to_u32(memory.confidence),
..Default::default()
});
}
}
fn import_goals(
domain_id: &str,
role_id: &str,
goals: &[GhostlightGoal],
nodes: &mut Vec<EpiphanyMemoryNode>,
) {
for goal in goals {
nodes.push(EpiphanyMemoryNode {
id: memory_graph_node_id(domain_id, "goal", goal.goal_id.as_str(), None),
domain_id: domain_id.to_string(),
profile: EpiphanyMemoryProfile::RoleSelf,
kind: EpiphanyMemoryNodeKind::RoleMemory,
title: format!("{role_id} goal"),
claim: goal.description.clone(),
question: "Does this goal still serve the current role?".to_string(),
tension: goal.blockers.join("; "),
action_implication: format!(
"Goal status is {} with scope {}.",
goal.status, goal.scope
),
source_hashes: vec!["anchor:missing".to_string()],
lifecycle: EpiphanyMemoryLifecycle::Accepted,
salience: score_to_u32(goal.priority),
confidence: 80,
..Default::default()
});
}
}
fn import_values(
domain_id: &str,
role_id: &str,
values: &[GhostlightValue],
nodes: &mut Vec<EpiphanyMemoryNode>,
) {
for value in values {
nodes.push(EpiphanyMemoryNode {
id: memory_graph_node_id(domain_id, "value", value.value_id.as_str(), None),
domain_id: domain_id.to_string(),
profile: EpiphanyMemoryProfile::Identity,
kind: EpiphanyMemoryNodeKind::Identity,
title: format!("{role_id} value: {}", value.label),
claim: value.label.clone(),
question: "How should this value constrain future role behavior?".to_string(),
tension: if value.unforgivable_if_betrayed {
"Marked unforgivable if betrayed.".to_string()
} else {
String::new()
},
action_implication: format!("Respect this value when selecting {role_id} context."),
source_hashes: vec!["anchor:missing".to_string()],
lifecycle: EpiphanyMemoryLifecycle::Accepted,
salience: score_to_u32(value.priority),
confidence: 80,
..Default::default()
});
}
}
fn score_to_u32(value: f64) -> u32 {
if value.is_finite() {
(value.clamp(0.0, 1.0) * 100.0).round() as u32
} else {
0
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::agent_memory::GhostlightAgent;
use crate::agent_memory::GhostlightCanonicalState;
use crate::agent_memory::GhostlightMemories;
use crate::agent_memory::GhostlightWorld;
use crate::memory_graph::validate_memory_graph_snapshot;
#[test]
fn agent_profile_imports_reviewed_role_memory_into_valid_graph() {
let entry = EpiphanyAgentMemoryEntry {
schema_version: "ghostlight.agent_state.v0".to_string(),
role_id: "modeling".to_string(),
world: GhostlightWorld::default(),
agent: GhostlightAgent {
memories: GhostlightMemories {
semantic: vec![GhostlightMemory {
memory_id: "mem-1".to_string(),
summary: "Modeling should reject graph updates without source anchors."
.to_string(),
salience: 0.8,
confidence: 0.9,
..Default::default()
}],
..Default::default()
},
goals: vec![GhostlightGoal {
goal_id: "goal-1".to_string(),
description: "Keep architecture maps source-grounded.".to_string(),
scope: "role".to_string(),
priority: 0.7,
emotional_stake: "coherence".to_string(),
status: "active".to_string(),
..Default::default()
}],
canonical_state: GhostlightCanonicalState {
values: vec![GhostlightValue {
value_id: "value-1".to_string(),
label: "Coherence over velocity".to_string(),
priority: 1.0,
unforgivable_if_betrayed: true,
..Default::default()
}],
..Default::default()
},
..Default::default()
},
relationships: Vec::new(),
events: Vec::new(),
scenes: Vec::new(),
extra: Default::default(),
};
let snapshot = memory_graph_from_agent_memories("agent-profile", &[entry]);
let errors = validate_memory_graph_snapshot(&snapshot);
assert!(errors.is_empty(), "{errors:?}");
assert_eq!(snapshot.domains.len(), 1);
assert_eq!(snapshot.nodes.len(), 3);
assert_eq!(snapshot.summaries.len(), 1);
assert!(
snapshot
.nodes
.iter()
.any(|node| node.profile == EpiphanyMemoryProfile::Identity)
);
}
}

View file

@ -1,3 +1,5 @@
pub mod agent;
pub mod repo;
pub use agent::memory_graph_from_agent_memories;
pub use repo::memory_graph_from_epiphany_graphs;

View file

@ -96,7 +96,7 @@ remembers doctrine; the branch remembers the blade.
- The heartbeat initiative pass is landed as a bounded tool seam. `state/agent-heartbeats.msgpack` tracks Self, Face, Imagination, Eyes, Body, Hands, Soul, and Life as Ghostlight-style initiative participants with arena, participant kind, speed, next-ready time, reaction bias, interrupt threshold, load, status, constraints, personality cooldown, mood cooldown, effective cooldown, adaptive pacing, history, and pending turns through `epiphany-core::EpiphanyHeartbeatStateEntry` and the native `epiphany-heartbeat-store` binary. Role dossiers set baseline timing; appraisal mood/anxiety bends it through urgency, arousal, thought pressure, guardedness, and reaction intensity, so Hands-like work pressure and high-need anxious lanes recover sooner without being heartbeaten while a prior turn is running. `epiphany-heartbeat-store pump` computes pressure from external urgency, mood/anxiety, reaction intensity, thought pressure, and current pending load, then chooses tempo plus target concurrency: calm can launch zero and sleep slow; alarm can fill most active lanes. Idle turns are for rumination: light thought shuffling, role-quality attention, and candidate selfPatch pressure. Sleep/dream cycle passes are the intended distillation window for durable self-memory and doctrine. JSON heartbeat state and Python wrapper state are gone; general CultCache schema sync, polyglot domain loading, and debug display tools belong in CultLib. This is a callable scheduler seam, not yet an always-on daemon; a heart valve, not a whole circulatory god.
- The first Ghostlight-derived timing slice is landed in Epiphany, but Ghostlight is reference lineage rather than a sibling runtime to preserve. `epiphany-heartbeat-store init --profile ghostlight-scene --scene-id <id> --scene-participant <id|name|speed|reaction|threshold|constraints>` creates a typed CultCache MessagePack scene heartbeat store whose participants are `arena=scene`, `participantKind=character`; `tick` emits `ghostlight.initiative_schedule.v0` receipts with `scene_turn` actions and local-affordance basis. The generic Epiphany maintenance lanes are not auto-patched into scene stores.
- The first Void-derived routine slice is landed in Epiphany, but VoidBot is reference lineage rather than a runtime dependency. `epiphany-heartbeat-store routine --store .\state\agent-heartbeats.msgpack --artifact-dir .\.epiphany-heartbeats --agent-store .\state\agents.msgpack` reads typed role dossiers, computes bounded memory resonance, maintains incubation themes, runs analytic and associative cognition lanes, writes bridge syntheses/saturation/tension, projects the active thought cluster through each role's Ghostlight-shaped personality vectors, derives participant-local reactions, applies personality/mood timing, advances the sleep/dream cycle, updates the typed heartbeat store, and emits an auditable `epiphany.void_routine.v0` receipt. The routine now also carries anti-loop physiology imported from Void's calmer brain: `noveltyToSelf`, `noveltyToRoom`, source coverage, saturation pressure, refractory cooling, and explicit permission to let a live unsaturated thought deepen without forcing novelty theater every pass. This mutates only heartbeat physiology fields: project truth and role memory mutation remain on their reviewed surfaces.
- The next memory foundation must not build separate engines for repo graph and agent mind. Heartbeat cognition, role self-memory, repo architecture/dataflow, evidence scars, incubation, agency pressure, and context packets should converge through `EpiphanyMemoryGraph` profiles so one typed graph owns anchors, lifecycle, summaries, freshness, context cuts, and Qdrant embedding manifests. The repo profile producer now maps existing accepted architecture/dataflow graph state into memory graph documents without scanner/Qdrant/model work and deliberately keeps bad topology visible as validation failure. The next clean implementation slice is an agent profile producer over reviewed role self-memory and heartbeat cognition pressure, still before sleep runner, Qdrant, CultNet, or prompt integration.
- The next memory foundation must not build separate engines for repo graph and agent mind. Heartbeat cognition, role self-memory, repo architecture/dataflow, evidence scars, incubation, agency pressure, and context packets should converge through `EpiphanyMemoryGraph` profiles so one typed graph owns anchors, lifecycle, summaries, freshness, context cuts, and Qdrant embedding manifests. The repo profile producer maps accepted architecture/dataflow graph state into memory graph documents without scanner/Qdrant/model work and keeps bad topology visible as validation failure. The agent profile producer maps reviewed role dossier memories/goals/values into role_self/identity graph nodes without treating heartbeat rumination as durable memory. The next clean implementation slice is heartbeat cognition pressure import as provisional short-term/incubation/agency/candidate profile documents, still before sleep runner, Qdrant, CultNet, or prompt integration.
- Manual Codex-run rumination still has an explicit aftercare rule until Epiphany owns the full sleep consolidator. In the intended Epiphany cycle, sub-agents ruminate when idle and distill when they sleep; in this supervising Codex thread, a heartbeat/routine vigil is only physiology until a separate closing pass reviews the receipts and decides whether map, handoff, evidence, or role self-memory should change.
- The Face public-surface pass is landed as a bounded lane. Face's role dossier lives in `state/agents.msgpack`; `epiphany_specialists.toml` gives it a VoidBot-heartbeat-derived prompt stripped of moderation authority; `state/face-discord.toml` and the native `epiphany-face-discord` binary enforce that Face may interact only through #aquarium. Missing channel id or token writes candidate chat artifacts instead of posting elsewhere. If a Face has a persona name/avatar, `post` uses the shared Discord webhook pipe so each Epiphany can speak with its own nickname and avatar without a separate bot identity.
- The Void memory bridge is now native enough to keep the useful organs attached. `state/void-memory.toml` and `epiphany-void-memory` can check Void's Docker Postgres state spine, query Qdrant Discord-history and source/lore collections with the configured Ollama embedding model, and fetch raw archive context windows from Void's file-backed Discord archive. Native `epiphany-mvp-status` includes a `voidMemory` block so Aquarium/backend clients can inspect whether the mouth and memory are actually wired.

Binary file not shown.

View file

@ -297,4 +297,4 @@ current_status:
freshness propagation, summary-versus-child context cuts, and a validated
CultCache store entry; the native `epiphany-memory-graph` binary can
status/validate/query/smoke the store without Qdrant.
next_action: Continue the memory graph build unless a more urgent Codex starvation regression appears. The repo profile producer now maps existing accepted architecture/dataflow graph state into `EpiphanyMemoryGraph` documents without scanner/Qdrant/model work. The next clean slice is an agent profile producer that maps reviewed role self-memory and heartbeat cognition pressure into shared memory graph profile documents, still without sleep runner, Qdrant, CultNet advertisement, or prompt integration.
next_action: Continue the memory graph build unless a more urgent Codex starvation regression appears. Repo and agent profile producers now map existing accepted architecture/dataflow graph state plus reviewed role dossier memories/goals/values into `EpiphanyMemoryGraph` documents without scanner/Qdrant/model work. The next clean slice is heartbeat cognition pressure import as provisional short-term/incubation/agency/candidate profile documents, still without sleep runner, Qdrant, CultNet advertisement, or prompt integration.