From 2455c4d4a9b3190b10ff8946191d1d47fdf126df Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 21 Jun 2026 17:58:06 +0100 Subject: [PATCH] Add semantic recall to repo Persona intake --- .../src/bin/epiphany-repo-swarm-mvp-smoke.rs | 5 + epiphany-core/src/bin/epiphany-work.rs | 96 ++++++++++++++++++ notes/fresh-workspace-handoff.md | 6 ++ state/ledgers.msgpack | Bin 381210 -> 381778 bytes state/map.yaml | 2 +- 5 files changed, 108 insertions(+), 1 deletion(-) diff --git a/epiphany-core/src/bin/epiphany-repo-swarm-mvp-smoke.rs b/epiphany-core/src/bin/epiphany-repo-swarm-mvp-smoke.rs index fc4ede05..b9517148 100644 --- a/epiphany-core/src/bin/epiphany-repo-swarm-mvp-smoke.rs +++ b/epiphany-core/src/bin/epiphany-repo-swarm-mvp-smoke.rs @@ -309,6 +309,8 @@ fn run_smoke(args: Args) -> Result { require_eq(&publish, &["status"], "publication-receipts-recorded")?; require_eq(&sync, &["status"], "upstream-main-synced")?; require_eq(&export, &["status"], "public-proof-exported")?; + require_non_empty(&intake, &["memoryRecallStatus"])?; + require_non_empty(&intake, &["memoryRecallCacheStatus"])?; require_non_empty(&intake, &["weksaLoweringReceiptId"])?; require_bool(&intake, &["privateStateExposed"], false)?; require_bool(&overview, &["privateStateExposed"], false)?; @@ -337,6 +339,9 @@ fn run_smoke(args: Args) -> Result { "initStatus": init["status"], "onlineStatus": online["status"], "personaIntakeStatus": intake["status"], + "personaMemoryRecallStatus": intake["memoryRecallStatus"], + "personaMemoryRecallCacheStatus": intake["memoryRecallCacheStatus"], + "personaMemoryRecallHitCount": intake["memoryRecallHitCount"], "weksaLoweringReceiptId": intake["weksaLoweringReceiptId"], "planStatus": plan["status"], "preRunOverviewGate": pre_run_overview["gate"], diff --git a/epiphany-core/src/bin/epiphany-work.rs b/epiphany-core/src/bin/epiphany-work.rs index 89112076..23ffc6d9 100644 --- a/epiphany-core/src/bin/epiphany-work.rs +++ b/epiphany-core/src/bin/epiphany-work.rs @@ -26,6 +26,7 @@ use epiphany_core::HandsActionIntent; use epiphany_core::MIND_GATEWAY_REVIEW_SCHEMA_VERSION; use epiphany_core::MindGatewayDecision; use epiphany_core::MindGatewayReview; +use epiphany_core::PersonaMemoryCacheConfig; use epiphany_core::RuntimeSpineInitOptions; use epiphany_core::SOUL_VERDICT_RECEIPT_SCHEMA_VERSION; use epiphany_core::SUBSTRATE_GATE_REPO_ACCESS_GRANT_RECEIPT_SCHEMA_VERSION; @@ -41,6 +42,7 @@ use epiphany_core::hands_commit_receipt_for_review; use epiphany_core::hands_patch_receipt_for_review; use epiphany_core::hands_pr_receipt_for_review; use epiphany_core::initialize_runtime_spine; +use epiphany_core::load_agent_memory_entry_for_role; use epiphany_core::load_epiphany_cultmesh_idunn_aftercare_audit_receipt; use epiphany_core::load_epiphany_cultmesh_idunn_deployment_receipt; use epiphany_core::load_epiphany_cultmesh_repo_work_overviews; @@ -50,7 +52,9 @@ use epiphany_core::load_latest_epiphany_cultmesh_bifrost_github_publication_rece use epiphany_core::load_latest_epiphany_cultmesh_idunn_aftercare_audit_receipt; use epiphany_core::load_latest_epiphany_cultmesh_idunn_deployment_receipt; use epiphany_core::load_latest_epiphany_cultmesh_repo_work_overview; +use epiphany_core::memory_graph_from_agent_memories; use epiphany_core::mind_state_commit_receipt; +use epiphany_core::plan_memory_graph_context_cut; use epiphany_core::put_hands_action_intent; use epiphany_core::put_hands_action_review; use epiphany_core::put_hands_command_receipt; @@ -62,6 +66,7 @@ use epiphany_core::put_mind_state_commit_receipt; use epiphany_core::put_soul_verdict_receipt; use epiphany_core::put_substrate_gate_repo_access_grant_receipt; use epiphany_core::record_weksa_target_lowering_receipt; +use epiphany_core::render_persona_memory_recall_with_cache; use epiphany_core::runtime_hands_action_intent; use epiphany_core::runtime_hands_action_review; use epiphany_core::runtime_hands_commit_receipt; @@ -72,6 +77,8 @@ use epiphany_core::write_epiphany_cultmesh_repo_work_public_proof; use epiphany_core::write_epiphany_cultmesh_repo_work_readiness; use epiphany_core::write_epiphany_cultmesh_repo_work_readiness_review; use epiphany_core::write_epiphany_cultmesh_weksa_lowering_receipt; +use epiphany_state_model::EpiphanyMemoryContextQuery; +use epiphany_state_model::EpiphanyMemoryProfile; use serde::Deserialize; use serde::Serialize; use serde_json::Value; @@ -1799,6 +1806,9 @@ fn run_persona_intake(args: PersonaIntakeArgs) -> Result { path_from_json(&online_receipt, &["localVerseStore"]) .unwrap_or_else(|| workspace.join(".epiphany").join("local-verse.ccmp")) }); + let state_dir = path_from_json(&online_receipt, &["stateDir"]) + .unwrap_or_else(|| workspace.join(".epiphany").join("state")); + let agent_store = state_dir.join("agents.msgpack"); let runtime_id = args.runtime_id.clone().unwrap_or_else(|| { string_from_json(&online_receipt, &["runtimeId"]) .unwrap_or_else(|| "repo-swarm-local".to_string()) @@ -1846,6 +1856,8 @@ fn run_persona_intake(args: PersonaIntakeArgs) -> Result { .clone() .unwrap_or_else(|| format!("repo-persona-intake-{item_slug}")); let summary = compact_text(&args.message, 480); + let memory_recall = + record_repo_persona_intake_memory_recall(&agent_store, &item_slug, &args.message); let public_ref = format!("eve://epiphany/persona#repo-intake/{item_slug}/{audit_id}"); let candidate_ref = format!("candidate-action://{runtime_id}/{item_slug}/{audit_id}"); let weksa = record_repo_persona_intake_weksa( @@ -1888,6 +1900,7 @@ fn run_persona_intake(args: PersonaIntakeArgs) -> Result { "contentFingerprint": content_fingerprint, "publicDiscussionRef": public_ref, "candidateActionRef": candidate_ref, + "memoryRecall": memory_recall, "weksa": weksa }, "accept": accept, @@ -1915,6 +1928,9 @@ fn run_persona_intake(args: PersonaIntakeArgs) -> Result { "receiptPath": receipt_path, "item": receipt["item"], "speechAuditId": audit_id, + "memoryRecallStatus": receipt["persona"]["memoryRecall"]["status"], + "memoryRecallCacheStatus": receipt["persona"]["memoryRecall"]["cacheStatus"], + "memoryRecallHitCount": receipt["persona"]["memoryRecall"]["hitCount"], "weksaLoweringReceiptId": receipt["persona"]["weksa"]["receiptId"], "bubblePath": receipt["persona"]["bubblePath"], "acceptReceiptPath": accept["receiptPath"], @@ -1925,6 +1941,86 @@ fn run_persona_intake(args: PersonaIntakeArgs) -> Result { })) } +fn record_repo_persona_intake_memory_recall( + agent_store: &Path, + item_slug: &str, + message: &str, +) -> Value { + let entry = match load_agent_memory_entry_for_role(agent_store, "Persona") { + Ok(Some(entry)) => entry, + Ok(None) => { + return json!({ + "schemaVersion": "epiphany.persona_memory_cache.v0", + "status": "unavailable", + "cacheStatus": "persona-memory-missing", + "identityId": "epiphany.Persona", + "roleId": "Persona", + "chunkCount": 0, + "hitCount": 0, + "renderedRecall": "- semantic Persona memory recall unavailable: Persona memory entry is missing", + "warnings": ["Persona memory entry is missing"], + "privateStateExposed": false, + }); + } + Err(error) => { + return json!({ + "schemaVersion": "epiphany.persona_memory_cache.v0", + "status": "unavailable", + "cacheStatus": "persona-memory-load-failed", + "identityId": "epiphany.Persona", + "roleId": "Persona", + "chunkCount": 0, + "hitCount": 0, + "renderedRecall": format!("- semantic Persona memory recall unavailable: {}", compact_text(&format!("{error:#}"), 320)), + "warnings": [format!("Persona memory load failed: {}", compact_text(&format!("{error:#}"), 240))], + "privateStateExposed": false, + }); + } + }; + + let query = format!("Repo Persona intake {item_slug}\n{message}"); + let graph = memory_graph_from_agent_memories( + "repo-persona-intake-memory", + std::slice::from_ref(&entry), + ); + let fallback = plan_memory_graph_context_cut( + &graph, + &EpiphanyMemoryContextQuery { + id: format!("repo-persona-intake-{item_slug}"), + profile: Some(EpiphanyMemoryProfile::RoleSelf), + domain_ids: Vec::new(), + node_ids: Vec::new(), + edge_ids: Vec::new(), + text: Some(query.clone()), + budget: Some(8), + }, + ); + let mut config = PersonaMemoryCacheConfig::from_env(); + config.qdrant_timeout_ms = config.qdrant_timeout_ms.min(1_000); + config.ollama_timeout_ms = config.ollama_timeout_ms.min(1_000); + let recall = render_persona_memory_recall_with_cache( + &entry, + format!("{}#Persona", agent_store.display()), + &query, + 8, + Some(&fallback), + &config, + ); + + json!({ + "schemaVersion": recall.schema_version, + "status": recall.status, + "cacheStatus": recall.cache_status, + "identityId": recall.identity_id, + "roleId": recall.role_id, + "chunkCount": recall.chunk_count, + "hitCount": recall.hit_count, + "renderedRecall": recall.rendered_recall, + "warnings": recall.warnings, + "privateStateExposed": recall.private_state_exposed, + }) +} + fn record_repo_persona_intake_weksa( local_verse_store: &Path, runtime_id: &str, diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index a5548b5f..6907052c 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -1532,6 +1532,12 @@ target-language lowering request, lowering receipt, and local Verse `epiphany.cultmesh.weksa_lowering_receipt.v0` mirror before any mouth transport publication. The receipt-directory row is Weksa-owned sight only; Bifrost or the configured mouth edge still owns publication, and Mind still owns durable state. +Repo Persona intake also carries semantic Persona memory recall now. It loads +repo-local `agents.msgpack`, tries the bounded Qdrant/Ollama Persona-memory +cache, falls back to a typed RoleSelf memory-graph context cut, and records +sealed recall status in the intake receipt before routing public pressure to +Imagination. Qdrant is a rebuildable semantic cache; typed memory remains the +owner. `notes/organ-dependency-contracts.md` is the standing dependency map: every sub-agent depends on all the other standing sub-agents. Dependency does not collapse ownership; it makes each turn whole-organism-aware while Substrate Gate still gates repo diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 649f48bb5061bd0e1c566b2204c37137943847fe..0d1ff780cbe7824af2a90db7e46c4e51baed02ce 100644 GIT binary patch delta 545 zcmXw$ziSjh6vy3*2Z8}BIl;mQ>E!k{Iq(8@VwzORUD9ZCyxo1fJ7jidGV?Y+suUs? zf{h*rmMKyT7UCa}lot7me7kokh8bqw`+h&~J3p@n_cw!IFQTV!cHfS7Ki)m+-zUGf zqSGk)_G!`kvgk#!+I>UT<3EdD|MS0RKmLxl$CG$_5|4L|cP8IA?_Ry`J(-cSa7aE_ zgP;uK34yWa;3=~{4-lwE!zx=I-1Y}o)&N%o&fC1n7#wmnf_(;UQEI(t#oA`50ZTF* zMs+A1W+y{nuPAiAsclS7IZSge!pVWwSmOghTvKiRC1jXYG=u`R4v>lhum!%na?&`n znvO^pu&RwqkFJ8u8m0>#0-9VvxbdciM=c$z!WjveK4Ro1B%Q(fTq%ApPz)&*))RQ! zurj4gNg*_HA>R8nmddP-RcA8E7G~Bi^e?lDlf&J0*5y9Gg_w>3v$=@VAa0Xj^SK+ HAs_t*du_%9 delta 53 zcmcb#OnlZN@eLA;+$QE$rsh${7+BAL->l47$jI2+Je8?^Dib3RgJ@