Delete aggregate Persona memory mirrors
This commit is contained in:
parent
387afe4941
commit
bf516f9930
16 changed files with 158 additions and 2859 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,3 @@
|
|||
use crate::EpiphanyAgentStateSoaEntry;
|
||||
use crate::default_continuity_cultnet_contracts;
|
||||
use crate::default_eyes_cultnet_contracts;
|
||||
use crate::default_hands_cultnet_contracts;
|
||||
|
|
@ -30,10 +29,8 @@ use chrono::DateTime;
|
|||
use chrono::FixedOffset;
|
||||
use chrono::Utc;
|
||||
use cultcache_rs::CacheBackingStore;
|
||||
use cultcache_rs::CultSoaColumnValues;
|
||||
use cultcache_rs::DatabaseEntry;
|
||||
use cultcache_rs::SingleFileMessagePackBackingStore;
|
||||
use cultcache_rs::SoaDocument;
|
||||
use cultmesh_rs::CultMesh;
|
||||
use cultmesh_rs::CultMeshNode;
|
||||
use cultmesh_rs::CultMeshNodeOptions;
|
||||
|
|
@ -87,12 +84,6 @@ pub const EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION: &str =
|
|||
"epiphany.cultmesh.work_loop_telemetry.v0";
|
||||
pub const EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY: &str =
|
||||
"epiphany-internal/work-loop-telemetry/latest";
|
||||
pub const EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_TYPE: &str =
|
||||
"epiphany.cultmesh.agent_state_soa_summary";
|
||||
pub const EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_SCHEMA_VERSION: &str =
|
||||
"epiphany.cultmesh.agent_state_soa_summary.v0";
|
||||
pub const EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_LATEST_KEY: &str =
|
||||
"epiphany-local/agent-state-soa-summary/latest";
|
||||
pub const EPIPHANY_CULTMESH_REPO_WORK_OVERVIEW_TYPE: &str = "epiphany.cultmesh.repo_work_overview";
|
||||
pub const EPIPHANY_CULTMESH_REPO_WORK_OVERVIEW_SCHEMA_VERSION: &str =
|
||||
"epiphany.cultmesh.repo_work_overview.v0";
|
||||
|
|
@ -681,95 +672,6 @@ pub struct EpiphanyCultMeshWorkLoopTelemetryEntry {
|
|||
pub verification_assertions: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.cultmesh.agent_state_soa_summary",
|
||||
schema = "EpiphanyCultMeshAgentStateSoaSummaryEntry"
|
||||
)]
|
||||
pub struct EpiphanyCultMeshAgentStateSoaSummaryEntry {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub runtime_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub verse_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub summary_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub generated_at: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub source_store: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub row_count: u32,
|
||||
#[cultcache(key = 7)]
|
||||
pub role_ids: Vec<String>,
|
||||
#[cultcache(key = 8)]
|
||||
pub agent_ids: Vec<String>,
|
||||
#[cultcache(key = 9)]
|
||||
pub display_names: Vec<String>,
|
||||
#[cultcache(key = 10)]
|
||||
pub profile_kinds: Vec<String>,
|
||||
#[cultcache(key = 11)]
|
||||
pub portable_contracts: Vec<String>,
|
||||
#[cultcache(key = 12)]
|
||||
pub semantic_memory_counts: Vec<u32>,
|
||||
#[cultcache(key = 13)]
|
||||
pub episodic_memory_counts: Vec<u32>,
|
||||
#[cultcache(key = 14)]
|
||||
pub relationship_memory_counts: Vec<u32>,
|
||||
#[cultcache(key = 15)]
|
||||
pub goal_counts: Vec<u32>,
|
||||
#[cultcache(key = 16)]
|
||||
pub value_counts: Vec<u32>,
|
||||
#[cultcache(key = 17)]
|
||||
pub private_state_exposed: bool,
|
||||
#[cultcache(key = 18)]
|
||||
pub notes: Vec<String>,
|
||||
}
|
||||
|
||||
impl SoaDocument for EpiphanyCultMeshAgentStateSoaSummaryEntry {
|
||||
fn soa_columns(rows: &[Self]) -> std::collections::BTreeMap<&'static str, CultSoaColumnValues> {
|
||||
let mut columns = std::collections::BTreeMap::new();
|
||||
columns.insert(
|
||||
"summaryId",
|
||||
CultSoaColumnValues::new(
|
||||
rows.iter()
|
||||
.map(|row| row.summary_id.clone())
|
||||
.collect::<Vec<_>>(),
|
||||
),
|
||||
);
|
||||
columns.insert(
|
||||
"rowCount",
|
||||
CultSoaColumnValues::new(rows.iter().map(|row| row.row_count).collect::<Vec<_>>()),
|
||||
);
|
||||
columns.insert(
|
||||
"privateStateExposed",
|
||||
CultSoaColumnValues::new(
|
||||
rows.iter()
|
||||
.map(|row| row.private_state_exposed)
|
||||
.collect::<Vec<_>>(),
|
||||
),
|
||||
);
|
||||
columns.insert(
|
||||
"roleIds",
|
||||
CultSoaColumnValues::new(
|
||||
rows.iter()
|
||||
.map(|row| row.role_ids.clone())
|
||||
.collect::<Vec<_>>(),
|
||||
),
|
||||
);
|
||||
columns.insert(
|
||||
"portableContracts",
|
||||
CultSoaColumnValues::new(
|
||||
rows.iter()
|
||||
.map(|row| row.portable_contracts.clone())
|
||||
.collect::<Vec<_>>(),
|
||||
),
|
||||
);
|
||||
columns
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.cultmesh.repo_work_overview",
|
||||
|
|
@ -2439,7 +2341,6 @@ pub struct EpiphanyLocalVerseContext {
|
|||
pub latest_hands_action_gate: Option<EpiphanyCultMeshHandsActionGateEntry>,
|
||||
pub latest_role_review_event: Option<EpiphanyCultMeshRoleReviewEventEntry>,
|
||||
pub latest_work_loop_summary: Option<EpiphanyLocalVerseWorkLoopSummary>,
|
||||
pub latest_agent_state_soa_summary: Option<EpiphanyCultMeshAgentStateSoaSummaryEntry>,
|
||||
pub latest_repo_work_overview: Option<EpiphanyCultMeshRepoWorkOverviewEntry>,
|
||||
pub latest_repo_work_map_entry: Option<EpiphanyCultMeshRepoWorkMapEntry>,
|
||||
pub contract_summaries: Vec<EpiphanyLocalVerseContractSummary>,
|
||||
|
|
@ -2488,7 +2389,6 @@ cultmesh_documents!(EpiphanyCultMeshDocuments {
|
|||
EpiphanyCultMeshHandsActionGateEntry => EPIPHANY_CULTMESH_HANDS_ACTION_GATE_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshRoleReviewEventEntry => EPIPHANY_CULTMESH_ROLE_REVIEW_EVENT_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshWorkLoopTelemetryEntry => EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshAgentStateSoaSummaryEntry => EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshRepoWorkOverviewEntry => EPIPHANY_CULTMESH_REPO_WORK_OVERVIEW_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshRepoWorkReadinessEntry => EPIPHANY_CULTMESH_REPO_WORK_READINESS_SCHEMA_VERSION,
|
||||
EpiphanyCultMeshRepoWorkMapEntry => EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_SCHEMA_VERSION,
|
||||
|
|
@ -5939,136 +5839,6 @@ pub fn epiphany_local_verse_work_loop_summary(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn epiphany_cultmesh_agent_state_soa_summary_from_entry(
|
||||
runtime_id: impl Into<String>,
|
||||
summary_id: impl Into<String>,
|
||||
soa: &EpiphanyAgentStateSoaEntry,
|
||||
) -> EpiphanyCultMeshAgentStateSoaSummaryEntry {
|
||||
EpiphanyCultMeshAgentStateSoaSummaryEntry {
|
||||
schema_version: EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_SCHEMA_VERSION.to_string(),
|
||||
runtime_id: runtime_id.into(),
|
||||
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
|
||||
summary_id: summary_id.into(),
|
||||
generated_at: soa.generated_at.clone(),
|
||||
source_store: soa.source_store.clone(),
|
||||
row_count: soa.role_ids.len() as u32,
|
||||
role_ids: soa.role_ids.clone(),
|
||||
agent_ids: soa.agent_ids.clone(),
|
||||
display_names: soa.display_names.clone(),
|
||||
profile_kinds: soa.profile_kinds.clone(),
|
||||
portable_contracts: soa.portable_contracts.clone(),
|
||||
semantic_memory_counts: soa.semantic_memory_counts.clone(),
|
||||
episodic_memory_counts: soa.episodic_memory_counts.clone(),
|
||||
relationship_memory_counts: soa.relationship_memory_counts.clone(),
|
||||
goal_counts: soa.goal_counts.clone(),
|
||||
value_counts: soa.value_counts.clone(),
|
||||
private_state_exposed: false,
|
||||
notes: vec![
|
||||
"Summary mirrors persisted epiphany.agent_state_soa.v0 column shape for local Verse discovery; agent memory text remains in the agent-memory store.".to_string(),
|
||||
"CultMesh carries row/column topology for Odin, Eve, and prompt assembly without becoming the agent-memory owner.".to_string(),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_epiphany_cultmesh_agent_state_soa_summary(
|
||||
store_path: impl AsRef<Path>,
|
||||
summary: EpiphanyCultMeshAgentStateSoaSummaryEntry,
|
||||
) -> Result<EpiphanyCultMeshAgentStateSoaSummaryEntry> {
|
||||
validate_agent_state_soa_summary(&summary)?;
|
||||
let mut node = open_epiphany_cultmesh_node(&store_path, summary.runtime_id.clone())?;
|
||||
let written = node.put(summary.summary_id.clone(), &summary)?;
|
||||
let current_latest = node.get::<EpiphanyCultMeshAgentStateSoaSummaryEntry>(
|
||||
EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_LATEST_KEY,
|
||||
)?;
|
||||
if current_latest.as_ref().is_none_or(|current| {
|
||||
agent_state_soa_generation_key(&written) >= agent_state_soa_generation_key(current)
|
||||
}) {
|
||||
node.put(
|
||||
EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_LATEST_KEY,
|
||||
&written,
|
||||
)?;
|
||||
}
|
||||
node.flush()?;
|
||||
Ok(written)
|
||||
}
|
||||
|
||||
pub fn load_latest_epiphany_cultmesh_agent_state_soa_summary(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
) -> Result<Option<EpiphanyCultMeshAgentStateSoaSummaryEntry>> {
|
||||
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
|
||||
node.get(EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_LATEST_KEY)
|
||||
}
|
||||
|
||||
fn validate_agent_state_soa_summary(
|
||||
summary: &EpiphanyCultMeshAgentStateSoaSummaryEntry,
|
||||
) -> Result<()> {
|
||||
if summary.private_state_exposed {
|
||||
return Err(anyhow!(
|
||||
"agent state SoA summaries must not expose private state"
|
||||
));
|
||||
}
|
||||
if summary.schema_version != EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_SCHEMA_VERSION {
|
||||
return Err(anyhow!(
|
||||
"agent state SoA summary schema_version must be {:?}",
|
||||
EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_SCHEMA_VERSION
|
||||
));
|
||||
}
|
||||
if summary.verse_id != EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID {
|
||||
return Err(anyhow!(
|
||||
"agent state SoA summary belongs in the local-area Verse"
|
||||
));
|
||||
}
|
||||
DateTime::parse_from_rfc3339(&summary.generated_at)
|
||||
.map_err(|error| anyhow!("agent state SoA summary has invalid generated_at: {error}"))?;
|
||||
let len = summary.role_ids.len();
|
||||
if summary.row_count as usize != len {
|
||||
return Err(anyhow!(
|
||||
"agent state SoA summary row_count is {}, expected {}",
|
||||
summary.row_count,
|
||||
len
|
||||
));
|
||||
}
|
||||
for (name, candidate) in [
|
||||
("agentIds", summary.agent_ids.len()),
|
||||
("displayNames", summary.display_names.len()),
|
||||
("profileKinds", summary.profile_kinds.len()),
|
||||
("portableContracts", summary.portable_contracts.len()),
|
||||
("semanticMemoryCounts", summary.semantic_memory_counts.len()),
|
||||
("episodicMemoryCounts", summary.episodic_memory_counts.len()),
|
||||
(
|
||||
"relationshipMemoryCounts",
|
||||
summary.relationship_memory_counts.len(),
|
||||
),
|
||||
("goalCounts", summary.goal_counts.len()),
|
||||
("valueCounts", summary.value_counts.len()),
|
||||
] {
|
||||
if candidate != len {
|
||||
return Err(anyhow!(
|
||||
"agent state SoA summary column {name} has length {candidate}, expected {len}"
|
||||
));
|
||||
}
|
||||
}
|
||||
if summary
|
||||
.role_ids
|
||||
.iter()
|
||||
.any(|role_id| role_id.trim().is_empty())
|
||||
{
|
||||
return Err(anyhow!("agent state SoA summary contains an empty role id"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn agent_state_soa_generation_key(
|
||||
summary: &EpiphanyCultMeshAgentStateSoaSummaryEntry,
|
||||
) -> (DateTime<FixedOffset>, &str) {
|
||||
(
|
||||
DateTime::parse_from_rfc3339(&summary.generated_at)
|
||||
.expect("validated agent state SoA generation timestamp"),
|
||||
summary.summary_id.as_str(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn load_latest_epiphany_cultmesh_repo_work_overview(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
|
|
@ -6375,8 +6145,6 @@ pub fn query_epiphany_local_verse_context(
|
|||
)?
|
||||
.as_ref()
|
||||
.map(epiphany_local_verse_work_loop_summary),
|
||||
latest_agent_state_soa_summary: node
|
||||
.get(EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_LATEST_KEY)?,
|
||||
latest_repo_work_overview: node.get(EPIPHANY_CULTMESH_REPO_WORK_OVERVIEW_LATEST_KEY)?,
|
||||
latest_repo_work_map_entry: node.get(EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_LATEST_KEY)?,
|
||||
contract_summaries,
|
||||
|
|
@ -9485,124 +9253,6 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn agent_state_soa_summary_mirrors_agent_store_shape_without_memory_text() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("epiphany-local-verse.ccmp");
|
||||
let soa = EpiphanyAgentStateSoaEntry {
|
||||
schema_version: "epiphany.agent_state_soa.v0".to_string(),
|
||||
generated_at: "2026-06-18T00:00:00Z".to_string(),
|
||||
source_store: "state/agents.msgpack".to_string(),
|
||||
role_ids: vec!["Persona".to_string(), "implementation".to_string()],
|
||||
agent_ids: vec!["epiphany.Persona".to_string(), "epiphany.hands".to_string()],
|
||||
display_names: vec!["Persona".to_string(), "Hands".to_string()],
|
||||
profile_kinds: vec!["Persona".to_string(), "WorkOrgan".to_string()],
|
||||
portable_contracts: vec![
|
||||
"gamecult.persona_state.v0".to_string(),
|
||||
"epiphany.work_organ_state.v0".to_string(),
|
||||
],
|
||||
semantic_memory_counts: vec![3, 2],
|
||||
episodic_memory_counts: vec![1, 0],
|
||||
relationship_memory_counts: vec![2, 0],
|
||||
goal_counts: vec![1, 1],
|
||||
value_counts: vec![4, 3],
|
||||
};
|
||||
let summary = epiphany_cultmesh_agent_state_soa_summary_from_entry(
|
||||
"epiphany-test",
|
||||
"agent-state-soa-summary-test",
|
||||
&soa,
|
||||
);
|
||||
write_epiphany_cultmesh_agent_state_soa_summary(&store, summary.clone())?;
|
||||
assert_eq!(
|
||||
load_latest_epiphany_cultmesh_agent_state_soa_summary(&store, "epiphany-test")?,
|
||||
Some(summary.clone())
|
||||
);
|
||||
let context = query_epiphany_local_verse_context(&store, "epiphany-test")?;
|
||||
assert_eq!(
|
||||
context.latest_agent_state_soa_summary,
|
||||
Some(summary.clone())
|
||||
);
|
||||
let node = open_epiphany_cultmesh_node(&store, "epiphany-test")?;
|
||||
assert!(
|
||||
node.documents()
|
||||
.binding(EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_TYPE)
|
||||
.is_some()
|
||||
);
|
||||
let summary_table = node.soa::<EpiphanyCultMeshAgentStateSoaSummaryEntry>()?;
|
||||
assert_eq!(summary_table.len(), 2);
|
||||
assert!(
|
||||
summary_table
|
||||
.column::<String>("summaryId")?
|
||||
.values()
|
||||
.contains(&"agent-state-soa-summary-test".to_string())
|
||||
);
|
||||
assert!(
|
||||
summary_table
|
||||
.column::<u32>("rowCount")?
|
||||
.values()
|
||||
.contains(&2)
|
||||
);
|
||||
assert!(
|
||||
summary_table
|
||||
.column::<bool>("privateStateExposed")?
|
||||
.values()
|
||||
.iter()
|
||||
.all(|exposed| !exposed)
|
||||
);
|
||||
assert!(
|
||||
summary_table
|
||||
.column::<Vec<String>>("portableContracts")?
|
||||
.values()
|
||||
.iter()
|
||||
.any(|contracts| contracts.contains(&"gamecult.persona_state.v0".to_string()))
|
||||
);
|
||||
let serialized = serde_json::to_string(&summary)?;
|
||||
assert!(serialized.contains("gamecult.persona_state.v0"));
|
||||
assert!(!serialized.contains("privateNotes"));
|
||||
assert!(!summary.private_state_exposed);
|
||||
|
||||
let mut newer = summary.clone();
|
||||
newer.summary_id = "agent-state-soa-summary-newer".to_string();
|
||||
newer.generated_at = "2026-06-18T01:00:00Z".to_string();
|
||||
write_epiphany_cultmesh_agent_state_soa_summary(&store, newer.clone())?;
|
||||
|
||||
let mut delayed = summary.clone();
|
||||
delayed.summary_id = "agent-state-soa-summary-delayed".to_string();
|
||||
delayed.generated_at = "2026-06-17T23:00:00Z".to_string();
|
||||
write_epiphany_cultmesh_agent_state_soa_summary(&store, delayed)?;
|
||||
assert_eq!(
|
||||
load_latest_epiphany_cultmesh_agent_state_soa_summary(&store, "epiphany-test")?,
|
||||
Some(newer)
|
||||
);
|
||||
|
||||
let mut invalid_time = summary.clone();
|
||||
invalid_time.summary_id = "agent-state-soa-summary-invalid".to_string();
|
||||
invalid_time.generated_at = "not-a-time".to_string();
|
||||
let err = write_epiphany_cultmesh_agent_state_soa_summary(&store, invalid_time)
|
||||
.expect_err("invalid agent summary time must be refused");
|
||||
assert!(err.to_string().contains("invalid generated_at"));
|
||||
|
||||
let mut wrong_verse = summary.clone();
|
||||
wrong_verse.summary_id = "agent-state-soa-summary-wrong-verse".to_string();
|
||||
wrong_verse.verse_id = EPIPHANY_CULTMESH_INTERNAL_VERSE_ID.to_string();
|
||||
let err = write_epiphany_cultmesh_agent_state_soa_summary(&store, wrong_verse)
|
||||
.expect_err("agent summary outside local-area Verse must be refused");
|
||||
assert!(err.to_string().contains("local-area Verse"));
|
||||
|
||||
let mut leaked = summary.clone();
|
||||
leaked.private_state_exposed = true;
|
||||
let err = write_epiphany_cultmesh_agent_state_soa_summary(&store, leaked)
|
||||
.expect_err("private-state agent summaries must be refused");
|
||||
assert!(err.to_string().contains("must not expose private state"));
|
||||
|
||||
let mut drifted = summary;
|
||||
drifted.agent_ids.pop();
|
||||
let err = write_epiphany_cultmesh_agent_state_soa_summary(&store, drifted)
|
||||
.expect_err("column length drift must be refused");
|
||||
assert!(err.to_string().contains("column agentIds has length"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builtin_verse_policies_keep_public_and_private_boundaries_apart() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
|
|
|
|||
|
|
@ -114,17 +114,12 @@ pub use agent_memory::AGENT_MEMORY_MIND_ADMISSION_TYPE;
|
|||
pub use agent_memory::AGENT_MEMORY_SWARM_IDENTITY_KEY;
|
||||
pub use agent_memory::AGENT_MEMORY_SWARM_IDENTITY_SCHEMA_VERSION;
|
||||
pub use agent_memory::AGENT_MEMORY_SWARM_IDENTITY_TYPE;
|
||||
pub use agent_memory::AgentCanonicalTraitSeed;
|
||||
pub use agent_memory::AgentMemoryBundle;
|
||||
pub use agent_memory::AgentMemoryGenerationWitness;
|
||||
pub use agent_memory::AgentMemoryLifecycleAction;
|
||||
pub use agent_memory::AgentMemoryLifecycleOperation;
|
||||
pub use agent_memory::AgentMemoryMindAdmissionReceipt;
|
||||
pub use agent_memory::AgentMemoryReview;
|
||||
pub use agent_memory::AgentMemorySwarmIdentity;
|
||||
pub use agent_memory::AgentSelfPatch;
|
||||
pub use agent_memory::EpiphanyAgentMemoryEntry;
|
||||
pub use agent_memory::EpiphanyAgentStateSoaEntry;
|
||||
pub use agent_memory::EpiphanyOrganStateProfile;
|
||||
pub use agent_memory::EpiphanyOrganStateProfileKind;
|
||||
pub use agent_memory::GhostlightAgent;
|
||||
|
|
@ -141,28 +136,15 @@ pub use agent_memory::GhostlightTraitVector;
|
|||
pub use agent_memory::GhostlightValue;
|
||||
pub use agent_memory::GhostlightWorld;
|
||||
pub use agent_memory::PERSONA_STATE_SCHEMA_VERSION;
|
||||
pub use agent_memory::admit_legacy_agent_memory_generation;
|
||||
pub use agent_memory::agent_memory_role_ids;
|
||||
pub use agent_memory::agent_memory_semantic_projection_input;
|
||||
pub use agent_memory::agent_memory_status;
|
||||
pub use agent_memory::apply_agent_canonical_trait_seeds;
|
||||
pub use agent_memory::apply_agent_memory_lifecycle_operation;
|
||||
pub use agent_memory::apply_agent_self_patch;
|
||||
pub use agent_memory::apply_agent_self_patch_document;
|
||||
pub use agent_memory::ensure_agent_memory_swarm_identity;
|
||||
pub use agent_memory::initialize_fresh_agent_memory_store;
|
||||
pub use agent_memory::load_agent_memory_entry_for_role;
|
||||
pub use agent_memory::load_agent_memory_generation_witness;
|
||||
pub use agent_memory::load_agent_memory_swarm_identity;
|
||||
pub use agent_memory::load_agent_state_soa_entry;
|
||||
pub use agent_memory::migrate_agent_memory_json_dir_to_cultcache;
|
||||
pub use agent_memory::organ_state_profile_for_role;
|
||||
pub use agent_memory::project_agent_memory_to_json_dir;
|
||||
pub use agent_memory::project_persona_state_for_role;
|
||||
pub use agent_memory::project_persona_state_from_entry;
|
||||
pub use agent_memory::refresh_agent_state_soa;
|
||||
pub use agent_memory::repair_agent_memory_store;
|
||||
pub use agent_memory::review_agent_memory_lifecycle_operation;
|
||||
pub use agent_memory::review_agent_self_patch;
|
||||
pub use agent_memory::review_agent_self_patch_document;
|
||||
pub use agent_memory::validate_agent_memory_store;
|
||||
|
|
@ -205,9 +187,6 @@ pub use cultcache_rs::RedbMessagePackBackingStore;
|
|||
pub use cultcache_rs::SingleFileMessagePackBackingStore;
|
||||
pub use cultmesh_integration::EPIPHANY_CANONICAL_SWARM_BRAKE_ID;
|
||||
pub use cultmesh_integration::EPIPHANY_CANONICAL_SWARM_BRAKE_OWNER;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_AGENT_STATE_SOA_SUMMARY_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_ARTIFACT_ACCEPTANCE_RECEIPT_ARRIVAL_LATEST_KEY;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_ARTIFACT_ACCEPTANCE_RECEIPT_SCHEMA_VERSION;
|
||||
pub use cultmesh_integration::EPIPHANY_CULTMESH_BIFROST_ARTIFACT_ACCEPTANCE_RECEIPT_TYPE;
|
||||
|
|
@ -326,7 +305,6 @@ pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSI
|
|||
pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_TYPE;
|
||||
pub use cultmesh_integration::EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID;
|
||||
pub use cultmesh_integration::EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshAgentStateSoaSummaryEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshBifrostArtifactAcceptanceReceiptEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshBifrostBodyChangePublicationIntentEntry;
|
||||
pub use cultmesh_integration::EpiphanyCultMeshBifrostBodyChangePublicationReceiptEntry;
|
||||
|
|
@ -385,7 +363,6 @@ pub use cultmesh_integration::canonical_epiphany_swarm_brake_protected_surfaces;
|
|||
pub use cultmesh_integration::default_epiphany_cultmesh_swarm_brake;
|
||||
pub use cultmesh_integration::engage_epiphany_cultmesh_swarm_brake;
|
||||
pub use cultmesh_integration::epiphany_cluster_service_execution_audit_report;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_agent_state_soa_summary_from_entry;
|
||||
#[cfg(test)]
|
||||
pub use cultmesh_integration::epiphany_cultmesh_bifrost_artifact_acceptance_receipt_for_map_entry;
|
||||
pub use cultmesh_integration::epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
|
|
@ -456,7 +433,6 @@ pub use cultmesh_integration::load_epiphany_cultmesh_repo_work_readiness_reports
|
|||
pub use cultmesh_integration::load_epiphany_cultmesh_semantic_projection_health;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_status;
|
||||
pub use cultmesh_integration::load_epiphany_cultmesh_swarm_brake;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_agent_state_soa_summary;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_coordinator_run_receipt;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_heartbeat;
|
||||
pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_poke_intent;
|
||||
|
|
@ -487,7 +463,6 @@ pub use cultmesh_integration::release_epiphany_cultmesh_swarm_brake;
|
|||
pub use cultmesh_integration::retire_epiphany_cultmesh_legacy_provider_documents;
|
||||
pub use cultmesh_integration::retire_epiphany_cultmesh_operator_status_documents;
|
||||
pub use cultmesh_integration::seed_epiphany_local_verse_context;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_agent_state_soa_summary;
|
||||
#[cfg(test)]
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_artifact_acceptance_receipt;
|
||||
pub use cultmesh_integration::write_epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
|
|
|
|||
|
|
@ -351,6 +351,7 @@ pub struct EpiphanyMindView {
|
|||
pub invariants: Vec<EpiphanyInvariant>,
|
||||
pub observations: Vec<EpiphanyObservation>,
|
||||
pub evidence: Vec<EpiphanyEvidenceRecord>,
|
||||
pub persona_memories: Vec<EpiphanyMindPersonaMemoryDocument>,
|
||||
pub verification_audits: Vec<EpiphanyMindVerificationAuditDocument>,
|
||||
pub reorientation_decisions: Vec<crate::EpiphanyMindReorientationDecisionDocument>,
|
||||
pub reorientation_failures: Vec<crate::EpiphanyMindReorientationPassFailureDocument>,
|
||||
|
|
@ -588,6 +589,10 @@ pub fn assemble_mind_view(store_path: impl AsRef<Path>) -> Result<EpiphanyMindVi
|
|||
let mut observations =
|
||||
values::<EpiphanyMindObservationDocument, _>(&cache, |value| value.value)?;
|
||||
let mut evidence = values::<EpiphanyMindEvidenceDocument, _>(&cache, |value| value.value)?;
|
||||
let mut persona_memories = cache.get_all::<EpiphanyMindPersonaMemoryDocument>()?;
|
||||
for memory in &persona_memories {
|
||||
memory.validate()?;
|
||||
}
|
||||
let mut verification_audits = cache.get_all::<EpiphanyMindVerificationAuditDocument>()?;
|
||||
let mut reorientation_decisions =
|
||||
cache.get_all::<crate::EpiphanyMindReorientationDecisionDocument>()?;
|
||||
|
|
@ -638,6 +643,7 @@ pub fn assemble_mind_view(store_path: impl AsRef<Path>) -> Result<EpiphanyMindVi
|
|||
invariants.sort_by(|left, right| left.id.cmp(&right.id));
|
||||
observations.sort_by(|left, right| left.id.cmp(&right.id));
|
||||
evidence.sort_by(|left, right| left.id.cmp(&right.id));
|
||||
persona_memories.sort_by(|left, right| left.memory_id.cmp(&right.memory_id));
|
||||
verification_audits.sort_by(|left, right| left.audit_id.cmp(&right.audit_id));
|
||||
reorientation_decisions.sort_by(|left, right| left.decision_id.cmp(&right.decision_id));
|
||||
reorientation_failures.sort_by(|left, right| left.failure_id.cmp(&right.failure_id));
|
||||
|
|
@ -683,6 +689,7 @@ pub fn assemble_mind_view(store_path: impl AsRef<Path>) -> Result<EpiphanyMindVi
|
|||
invariants,
|
||||
observations,
|
||||
evidence,
|
||||
persona_memories,
|
||||
verification_audits,
|
||||
reorientation_decisions,
|
||||
reorientation_failures,
|
||||
|
|
@ -724,6 +731,8 @@ fn canonical_mind_versions(
|
|||
| EpiphanyMindInvariantDocument::TYPE
|
||||
| EpiphanyMindObservationDocument::TYPE
|
||||
| EpiphanyMindEvidenceDocument::TYPE
|
||||
| EpiphanyMindPersonaMemoryDocument::TYPE
|
||||
| EpiphanyMindPersonaPassInputDocument::TYPE
|
||||
| EpiphanyMindVerificationAuditDocument::TYPE
|
||||
| crate::EpiphanyMindReorientationDecisionDocument::TYPE
|
||||
| crate::EpiphanyMindReorientationPassFailureDocument::TYPE
|
||||
|
|
|
|||
|
|
@ -1641,12 +1641,21 @@ mod tests {
|
|||
cache.pull_all_backing_stores()?;
|
||||
let first = cache.get_all::<crate::EpiphanyMindCommitReceipt>()?;
|
||||
assert_eq!(first.len(), 1);
|
||||
let memories = cache.get_all::<crate::EpiphanyMindPersonaMemoryDocument>()?;
|
||||
let mut memories = cache.get_all::<crate::EpiphanyMindPersonaMemoryDocument>()?;
|
||||
memories.sort_by(|left, right| left.memory_id.cmp(&right.memory_id));
|
||||
assert_eq!(memories.len(), 2);
|
||||
assert!(memories.iter().all(|memory| {
|
||||
memory.agent_id == request.agent_id
|
||||
&& memory.decision_context_id == document.decision_context_id
|
||||
}));
|
||||
let view = crate::assemble_mind_view(&runtime)?;
|
||||
assert_eq!(view.persona_memories, memories);
|
||||
assert!(view.persona_memories.iter().all(|memory| {
|
||||
view.source_documents.iter().any(|source| {
|
||||
source.document_type == crate::EpiphanyMindPersonaMemoryDocument::TYPE
|
||||
&& source.document_key == memory.memory_id
|
||||
})
|
||||
}));
|
||||
|
||||
assert_eq!(
|
||||
admit_persona_state_notes(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::EpiphanyAgentMemoryEntry;
|
||||
use crate::EpiphanyMindPersonaMemoryDocument;
|
||||
use crate::EpiphanyOrganDependency;
|
||||
use crate::HeartbeatPendingMention;
|
||||
use crate::default_organ_dependencies_for;
|
||||
|
|
@ -239,7 +239,7 @@ pub struct PersonaSocialAffordance {
|
|||
pub struct PersonaProjectorInput {
|
||||
pub identity: PersonaIdentity,
|
||||
#[serde(default)]
|
||||
pub memory: Option<EpiphanyAgentMemoryEntry>,
|
||||
pub memories: Vec<EpiphanyMindPersonaMemoryDocument>,
|
||||
#[serde(default)]
|
||||
pub semantic_memory_recall: String,
|
||||
#[serde(default)]
|
||||
|
|
@ -283,11 +283,7 @@ pub fn build_persona_projector_prompt_with_transcript(
|
|||
input: &PersonaProjectorInput,
|
||||
transcript: &[PersonaTranscriptMessage],
|
||||
) -> String {
|
||||
let memory = input
|
||||
.memory
|
||||
.as_ref()
|
||||
.map(render_memory_packet)
|
||||
.unwrap_or_else(|| "No durable Persona memory entry is loaded.".to_string());
|
||||
let memory = render_memory_packet(&input.memories);
|
||||
let dependencies = if input.organ_dependencies.is_empty() {
|
||||
vec![default_organ_dependencies_for("Persona")]
|
||||
} else {
|
||||
|
|
@ -603,38 +599,20 @@ fn render_identity(identity: &PersonaIdentity) -> String {
|
|||
)
|
||||
}
|
||||
|
||||
fn render_memory_packet(memory: &EpiphanyAgentMemoryEntry) -> String {
|
||||
let values = memory
|
||||
.agent
|
||||
.canonical_state
|
||||
.values
|
||||
fn render_memory_packet(memories: &[EpiphanyMindPersonaMemoryDocument]) -> String {
|
||||
if memories.is_empty() {
|
||||
return "- no durable Persona memories".to_string();
|
||||
}
|
||||
memories
|
||||
.iter()
|
||||
.map(|value| format!("- {} ({:.2})", value.label, value.priority))
|
||||
.map(|memory| {
|
||||
format!(
|
||||
"- {} [{}; salience {:.2}; confidence {:.2}]",
|
||||
memory.summary, memory.memory_kind, memory.salience, memory.confidence
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
let goals = memory
|
||||
.agent
|
||||
.goals
|
||||
.iter()
|
||||
.map(|goal| format!("- {} [{}]", goal.description, goal.status))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
let notes = memory
|
||||
.agent
|
||||
.identity
|
||||
.private_notes
|
||||
.iter()
|
||||
.map(|note| format!("- {note}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
format!(
|
||||
"Identity: {}\nPublic description: {}\nPrivate notes:\n{}\nValues:\n{}\nGoals:\n{}",
|
||||
memory.agent.identity.name,
|
||||
memory.agent.identity.public_description,
|
||||
fallback(¬es, "- none"),
|
||||
fallback(&values, "- none"),
|
||||
fallback(&goals, "- none"),
|
||||
)
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
fn render_pending_mentions(mentions: &[HeartbeatPendingMention]) -> String {
|
||||
|
|
|
|||
|
|
@ -103,53 +103,6 @@ pub fn render_epiphany_prompt_context(input: &EpiphanyPromptContextInput) -> Str
|
|||
);
|
||||
}
|
||||
|
||||
if let Some(summary) = input.local_verse.latest_agent_state_soa_summary.as_ref() {
|
||||
lines.push("## Agent State SoA".to_string());
|
||||
lines.push(format!(
|
||||
"- Summary `{}`: rows={}, source={}, private_state_exposed={}",
|
||||
summary.summary_id,
|
||||
summary.row_count,
|
||||
summary.source_store,
|
||||
summary.private_state_exposed
|
||||
));
|
||||
for index in 0..summary.role_ids.len().min(7) {
|
||||
lines.push(format!(
|
||||
"- `{}` / `{}`: profile={}, contract={}, semantic={}, episodic={}, relationship={}, goals={}, values={}",
|
||||
summary.role_ids[index],
|
||||
summary.agent_ids.get(index).cloned().unwrap_or_default(),
|
||||
summary.profile_kinds.get(index).cloned().unwrap_or_default(),
|
||||
summary
|
||||
.portable_contracts
|
||||
.get(index)
|
||||
.cloned()
|
||||
.unwrap_or_default(),
|
||||
summary
|
||||
.semantic_memory_counts
|
||||
.get(index)
|
||||
.copied()
|
||||
.unwrap_or_default(),
|
||||
summary
|
||||
.episodic_memory_counts
|
||||
.get(index)
|
||||
.copied()
|
||||
.unwrap_or_default(),
|
||||
summary
|
||||
.relationship_memory_counts
|
||||
.get(index)
|
||||
.copied()
|
||||
.unwrap_or_default(),
|
||||
summary.goal_counts.get(index).copied().unwrap_or_default(),
|
||||
summary.value_counts.get(index).copied().unwrap_or_default()
|
||||
));
|
||||
}
|
||||
push_omitted_count(
|
||||
&mut lines,
|
||||
summary.role_ids.len(),
|
||||
7,
|
||||
"agent state SoA rows",
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(intent) = input
|
||||
.local_verse
|
||||
.latest_daemon_tool_invocation_intent
|
||||
|
|
@ -404,15 +357,12 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::EPIPHANY_CULTMESH_INTERNAL_VERSE_ID;
|
||||
use crate::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION;
|
||||
use crate::EpiphanyAgentStateSoaEntry;
|
||||
use crate::EpiphanyCultMeshWorkLoopTelemetryEntry;
|
||||
use crate::epiphany_cultmesh_agent_state_soa_summary_from_entry;
|
||||
use crate::epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
use crate::epiphany_cultmesh_bifrost_body_change_publication_receipt_for_intent;
|
||||
use crate::epiphany_cultmesh_bifrost_github_publication_receipt_for_publication;
|
||||
use crate::query_epiphany_local_verse_context;
|
||||
use crate::seed_epiphany_local_verse_context;
|
||||
use crate::write_epiphany_cultmesh_agent_state_soa_summary;
|
||||
use crate::write_epiphany_cultmesh_bifrost_body_change_publication_intent;
|
||||
use crate::write_epiphany_cultmesh_bifrost_body_change_publication_receipt;
|
||||
use crate::write_epiphany_cultmesh_bifrost_github_publication_receipt;
|
||||
|
|
@ -520,30 +470,6 @@ mod tests {
|
|||
verification_assertions: vec!["prompt renders digest only".to_string()],
|
||||
},
|
||||
)?;
|
||||
let agent_state_soa = EpiphanyAgentStateSoaEntry {
|
||||
schema_version: "epiphany.agent_state_soa.v0".to_string(),
|
||||
generated_at: "2026-06-18T00:00:00Z".to_string(),
|
||||
source_store: "state/agents.msgpack".to_string(),
|
||||
role_ids: vec!["Persona".to_string(), "implementation".to_string()],
|
||||
agent_ids: vec!["epiphany.Persona".to_string(), "epiphany.hands".to_string()],
|
||||
display_names: vec!["Persona".to_string(), "Hands".to_string()],
|
||||
profile_kinds: vec!["Persona".to_string(), "WorkOrgan".to_string()],
|
||||
portable_contracts: vec![
|
||||
"gamecult.persona_state.v0".to_string(),
|
||||
"epiphany.work_organ_state.v0".to_string(),
|
||||
],
|
||||
semantic_memory_counts: vec![3, 2],
|
||||
episodic_memory_counts: vec![1, 0],
|
||||
relationship_memory_counts: vec![2, 0],
|
||||
goal_counts: vec![1, 1],
|
||||
value_counts: vec![4, 3],
|
||||
};
|
||||
let agent_state_summary = epiphany_cultmesh_agent_state_soa_summary_from_entry(
|
||||
"epiphany-test",
|
||||
"agent-state-soa-summary-prompt-test",
|
||||
&agent_state_soa,
|
||||
);
|
||||
write_epiphany_cultmesh_agent_state_soa_summary(&store, agent_state_summary)?;
|
||||
let local_verse = query_epiphany_local_verse_context(&store, "epiphany-test")?;
|
||||
let memory_context = EpiphanyMemoryContextPacket {
|
||||
id: "memctx-test".to_string(),
|
||||
|
|
@ -596,10 +522,6 @@ mod tests {
|
|||
assert!(rendered.contains("private_state_exposed=false"));
|
||||
assert!(!rendered.contains("inspectCompactSurface"));
|
||||
assert!(!rendered.contains("watchTypedReceipts"));
|
||||
assert!(rendered.contains("Agent State SoA"));
|
||||
assert!(rendered.contains("agent-state-soa-summary-prompt-test"));
|
||||
assert!(rendered.contains("gamecult.persona_state.v0"));
|
||||
assert!(rendered.contains("epiphany.work_organ_state.v0"));
|
||||
assert!(rendered.contains("Bifrost Publication Gate"));
|
||||
assert!(rendered.contains("bifrost-publication-intent-prompt-test"));
|
||||
assert!(rendered.contains("github_receipt=github-publication-prompt-test"));
|
||||
|
|
|
|||
|
|
@ -805,206 +805,6 @@ pub fn resident_prepared_launch_thread_id(prepared: &ResidentSelfPreparedLaunch)
|
|||
prepared_coordinator_thread_id(&prepared.argv)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn reconcile_resident_self(
|
||||
state: &mut ResidentSelfState,
|
||||
policy: &ResidentSelfPolicy,
|
||||
ports: &mut impl ResidentSelfPorts,
|
||||
now_millis: u64,
|
||||
wake: Option<ResidentSelfWake>,
|
||||
) -> Result<(ResidentSelfOutcome, ResidentSelfRuntimeReceipt)> {
|
||||
policy.validate()?;
|
||||
let receipt_revision = state.revision + 1;
|
||||
let receipt = |status: &str,
|
||||
reason: &str,
|
||||
turn_id: Option<String>,
|
||||
coordinator_receipt_id: Option<String>,
|
||||
process_id: Option<u32>| {
|
||||
ResidentSelfRuntimeReceipt {
|
||||
schema_version: RESIDENT_SELF_RUNTIME_RECEIPT_SCHEMA_VERSION.into(),
|
||||
receipt_id: format!("resident-self-{now_millis}-{receipt_revision}"),
|
||||
occurred_at_millis: now_millis,
|
||||
status: status.into(),
|
||||
reason: reason.into(),
|
||||
turn_id,
|
||||
coordinator_receipt_id,
|
||||
process_id,
|
||||
private_state_exposed: false,
|
||||
}
|
||||
};
|
||||
if ports.brake_engaged()? && state.active_turn.is_none() {
|
||||
return Ok((
|
||||
ResidentSelfOutcome::Braked,
|
||||
receipt(
|
||||
"braked",
|
||||
"local Verse swarm brake is engaged",
|
||||
state.active_turn.as_ref().map(|v| v.turn_id.clone()),
|
||||
None,
|
||||
state.active_turn.as_ref().map(|v| v.process_id),
|
||||
),
|
||||
));
|
||||
}
|
||||
if let Some(active) = state.active_turn.clone() {
|
||||
if ports.brake_engaged()? {
|
||||
match ports.observe_child(&active)? {
|
||||
ChildObservation::Running => {
|
||||
ports.request_child_stop(&active)?;
|
||||
return Ok((
|
||||
ResidentSelfOutcome::Draining,
|
||||
receipt(
|
||||
"draining",
|
||||
"local Verse brake is engaged; exact active coordinator stop requested and lease remains active until termination is proven",
|
||||
Some(active.turn_id),
|
||||
None,
|
||||
Some(active.process_id),
|
||||
),
|
||||
));
|
||||
}
|
||||
ChildObservation::Exited(_) | ChildObservation::Missing => {
|
||||
// Continue into terminal reconciliation. A brake does not erase receipt obligations.
|
||||
}
|
||||
}
|
||||
}
|
||||
match ports.observe_child(&active)? {
|
||||
ChildObservation::Running => {
|
||||
return Ok((
|
||||
ResidentSelfOutcome::Running,
|
||||
receipt(
|
||||
"running",
|
||||
"bounded coordinator turn remains active",
|
||||
Some(active.turn_id),
|
||||
None,
|
||||
Some(active.process_id),
|
||||
),
|
||||
));
|
||||
}
|
||||
ChildObservation::Exited(0) => {
|
||||
if let Some(coordinator_receipt_id) =
|
||||
ports.coordinator_receipt_since(&active.turn_id, active.started_at_millis)?
|
||||
{
|
||||
state.active_turn = None;
|
||||
state.last_coordinator_receipt_id = Some(coordinator_receipt_id.clone());
|
||||
state.next_eligible_at_millis =
|
||||
now_millis.saturating_add(policy.cooldown_seconds * 1000);
|
||||
state.consecutive_failures = 0;
|
||||
state.revision += 1;
|
||||
return Ok((
|
||||
ResidentSelfOutcome::Completed,
|
||||
receipt(
|
||||
"completed",
|
||||
"coordinator exited successfully with typed run receipt",
|
||||
Some(active.turn_id),
|
||||
Some(coordinator_receipt_id),
|
||||
Some(active.process_id),
|
||||
),
|
||||
));
|
||||
}
|
||||
state.active_turn = None;
|
||||
state.consecutive_failures += 1;
|
||||
state.next_eligible_at_millis =
|
||||
now_millis.saturating_add(policy.failure_backoff_seconds * 1000);
|
||||
state.revision += 1;
|
||||
return Ok((
|
||||
ResidentSelfOutcome::Failed,
|
||||
receipt(
|
||||
"failed",
|
||||
"coordinator exited zero without a typed run receipt",
|
||||
Some(active.turn_id),
|
||||
None,
|
||||
Some(active.process_id),
|
||||
),
|
||||
));
|
||||
}
|
||||
ChildObservation::Exited(code) => {
|
||||
state.active_turn = None;
|
||||
state.consecutive_failures += 1;
|
||||
state.next_eligible_at_millis =
|
||||
now_millis.saturating_add(policy.failure_backoff_seconds * 1000);
|
||||
state.revision += 1;
|
||||
return Ok((
|
||||
ResidentSelfOutcome::Failed,
|
||||
receipt(
|
||||
"failed",
|
||||
&format!("coordinator exited with status {code}"),
|
||||
Some(active.turn_id),
|
||||
None,
|
||||
Some(active.process_id),
|
||||
),
|
||||
));
|
||||
}
|
||||
ChildObservation::Missing => {
|
||||
state.active_turn = None;
|
||||
state.consecutive_failures += 1;
|
||||
state.next_eligible_at_millis =
|
||||
now_millis.saturating_add(policy.failure_backoff_seconds * 1000);
|
||||
state.revision += 1;
|
||||
return Ok((
|
||||
ResidentSelfOutcome::Failed,
|
||||
receipt(
|
||||
"failed",
|
||||
"coordinator process disappeared without a typed run receipt",
|
||||
Some(active.turn_id),
|
||||
None,
|
||||
Some(active.process_id),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
if now_millis < state.next_eligible_at_millis || wake.is_none() {
|
||||
return Ok((
|
||||
ResidentSelfOutcome::Sleeping,
|
||||
receipt(
|
||||
"sleeping",
|
||||
if wake.is_none() {
|
||||
"no explicit or existing idle wake is pending; proactive Body and feedback wake derivation is not implemented"
|
||||
} else {
|
||||
"cooldown or failure backoff remains active"
|
||||
},
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
),
|
||||
));
|
||||
}
|
||||
let wake = wake.expect("checked above");
|
||||
let turn_id = format!("resident-self-turn-{now_millis}-{}", state.revision + 1);
|
||||
let launch = CoordinatorLaunch {
|
||||
turn_id: turn_id.clone(),
|
||||
wake: wake.clone(),
|
||||
argv: coordinator_argv(policy, &policy.release_runtime_id, &turn_id, None, &wake),
|
||||
};
|
||||
let process = ports.launch_coordinator(&launch)?;
|
||||
let process_id = process.process_id;
|
||||
state.active_turn = Some(ResidentSelfTurnLease {
|
||||
turn_id: turn_id.clone(),
|
||||
wake,
|
||||
process_id,
|
||||
process_creation_token: process.process_creation_token,
|
||||
process_executable_path: process.process_executable_path,
|
||||
started_at_millis: now_millis,
|
||||
grant_id: String::new(),
|
||||
launch_digest: String::new(),
|
||||
policy_digest: String::new(),
|
||||
argv_digest: String::new(),
|
||||
objective_digest: String::new(),
|
||||
release_commit: policy.release_commit.clone(),
|
||||
release_manifest_digest: policy.release_manifest_digest.clone(),
|
||||
coordinator_executable_digest: String::new(),
|
||||
});
|
||||
state.revision += 1;
|
||||
Ok((
|
||||
ResidentSelfOutcome::Launched,
|
||||
receipt(
|
||||
"launched",
|
||||
"one bounded coordinator turn admitted",
|
||||
Some(turn_id),
|
||||
None,
|
||||
Some(process_id),
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
fn state_cache(path: &Path) -> Result<CultCache> {
|
||||
let mut cache = CultCache::new();
|
||||
cache.register_entry_type::<ResidentSelfState>()?;
|
||||
|
|
@ -2565,26 +2365,6 @@ pub fn validate_resident_self_prepared_objective(
|
|||
))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn complete_resident_self_turn(
|
||||
path: &Path,
|
||||
lease: &ResidentSelfTurnLease,
|
||||
coordinator: &crate::EpiphanyCoordinatorRunReceipt,
|
||||
now_millis: u64,
|
||||
cooldown_seconds: u64,
|
||||
) -> Result<ResidentSelfTerminalAck> {
|
||||
validate_resident_self_coordinator_receipt(lease, coordinator)?;
|
||||
complete_resident_self_turn_with_terminal(
|
||||
path,
|
||||
lease,
|
||||
&coordinator.receipt_id,
|
||||
&coordinator.status,
|
||||
now_millis,
|
||||
cooldown_seconds,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn validate_resident_self_coordinator_receipt(
|
||||
lease: &ResidentSelfTurnLease,
|
||||
coordinator: &crate::EpiphanyCoordinatorRunReceipt,
|
||||
|
|
|
|||
|
|
@ -11181,34 +11181,6 @@ pub fn runtime_soul_verdict_receipt(
|
|||
cache.get::<SoulVerdictReceipt>(receipt_id)
|
||||
}
|
||||
|
||||
// Continuity recovery receipts are accepted-reorientation prerequisites and
|
||||
// publish atomically with the coordinator state transition. Direct insertion
|
||||
// is fixture-only.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn put_continuity_recovery_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
receipt: &ContinuityRecoveryReceipt,
|
||||
) -> Result<()> {
|
||||
validate_non_empty(&receipt.receipt_id, "Continuity recovery receipt id")?;
|
||||
validate_non_empty(
|
||||
&receipt.source_result_id,
|
||||
"Continuity recovery source result",
|
||||
)?;
|
||||
validate_non_empty(&receipt.source_job_id, "Continuity recovery source job")?;
|
||||
validate_non_empty(&receipt.binding_id, "Continuity recovery binding")?;
|
||||
validate_non_empty(&receipt.mode, "Continuity recovery mode")?;
|
||||
validate_non_empty(
|
||||
&receipt.checkpoint_still_valid,
|
||||
"Continuity recovery checkpoint validity",
|
||||
)?;
|
||||
validate_non_empty(&receipt.emitted_at, "Continuity recovery timestamp")?;
|
||||
let mut cache = runtime_spine_cache(store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
require_identity(&cache)?;
|
||||
cache.put(&receipt.receipt_id, receipt)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn runtime_continuity_recovery_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
receipt_id: &str,
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ mod tests {
|
|||
invariants: Vec::new(),
|
||||
observations: Vec::new(),
|
||||
evidence: Vec::new(),
|
||||
persona_memories: Vec::new(),
|
||||
verification_audits: Vec::new(),
|
||||
reorientation_decisions: Vec::new(),
|
||||
reorientation_failures: Vec::new(),
|
||||
|
|
|
|||
|
|
@ -426,6 +426,7 @@ mod tests {
|
|||
],
|
||||
observations: Vec::new(),
|
||||
evidence: Vec::new(),
|
||||
persona_memories: Vec::new(),
|
||||
verification_audits: Vec::new(),
|
||||
reorientation_decisions: Vec::new(),
|
||||
reorientation_failures: Vec::new(),
|
||||
|
|
|
|||
Reference in a new issue