From 6bc3ec3f2493c75b6fa7f61ad3b675b10b67ab0f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 10 Aug 2026 05:16:12 +0100 Subject: [PATCH] Retire semantic physical epochs with receipts --- .../admitted_model_direction_consideration.rs | 4 +- epiphany-core/src/agent_memory.rs | 2 + .../bin/epiphany-memory-semantic-projector.rs | 35 +- epiphany-core/src/lib.rs | 4 + .../src/memory_graph/semantic_projector.rs | 820 +++++++++++++++++- epiphany-core/src/runtime_spine.rs | 2 + .../workspace_coverage_process_documents.rs | 2 +- notes/epiphany-current-algorithmic-map.md | 26 + notes/fresh-workspace-handoff.md | 24 + state/ledgers.msgpack | Bin 595239 -> 595840 bytes state/map.yaml | 6 +- 11 files changed, 914 insertions(+), 11 deletions(-) diff --git a/epiphany-core/src/admitted_model_direction_consideration.rs b/epiphany-core/src/admitted_model_direction_consideration.rs index 2567f704..62378839 100644 --- a/epiphany-core/src/admitted_model_direction_consideration.rs +++ b/epiphany-core/src/admitted_model_direction_consideration.rs @@ -336,7 +336,7 @@ mod tests { #[test] fn cold_runtime_without_thread_has_no_direction_request_yet() -> Result<()> { let temp = tempfile::tempdir()?; - let store = temp.path().join("runtime.ccmp"); + let store = temp.path().join("runtime.cc"); let mut cache = crate::runtime_spine_cache(&store)?; cache.put( crate::RUNTIME_IDENTITY_KEY, @@ -366,7 +366,7 @@ mod tests { #[test] fn bootstrap_model_without_admission_receipt_has_no_direction_request_yet() -> Result<()> { let temp = tempfile::tempdir()?; - let store = temp.path().join("bootstrap-runtime.ccmp"); + let store = temp.path().join("bootstrap-runtime.cc"); let mut cache = crate::runtime_spine_cache(&store)?; cache.put( crate::RUNTIME_IDENTITY_KEY, diff --git a/epiphany-core/src/agent_memory.rs b/epiphany-core/src/agent_memory.rs index 62206ac8..cd3d3707 100644 --- a/epiphany-core/src/agent_memory.rs +++ b/epiphany-core/src/agent_memory.rs @@ -2535,6 +2535,8 @@ fn agent_memory_cache(store_path: &Path) -> Result { cache.register_entry_type::()?; cache.register_entry_type::()?; cache.register_entry_type::()?; + cache.register_entry_type::()?; + cache.register_entry_type::()?; cache.register_entry_type::()?; cache.register_entry_type::()?; cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(store_path)); diff --git a/epiphany-core/src/bin/epiphany-memory-semantic-projector.rs b/epiphany-core/src/bin/epiphany-memory-semantic-projector.rs index 0dfba434..81bc664d 100644 --- a/epiphany-core/src/bin/epiphany-memory-semantic-projector.rs +++ b/epiphany-core/src/bin/epiphany-memory-semantic-projector.rs @@ -4,6 +4,7 @@ use epiphany_core::{ EpiphanyCultMeshDaemonHeartbeatEventEntry, EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry, MemorySemanticIndexConfig, MemorySemanticProjectionInput, MemorySemanticProjectorPulseStatus, SemanticProjectorServiceBody, authenticate_epiphany_cultmesh_semantic_projector_launch, + authorize_memory_semantic_physical_retirements, execute_memory_semantic_physical_retirement, load_epiphany_cultmesh_daemon_service_lifecycle_receipt, publish_epiphany_cultmesh_semantic_projection_health, retain_memory_semantic_projection_lifecycles, write_epiphany_cultmesh_daemon_heartbeat_event, @@ -54,8 +55,11 @@ fn main() -> Result<()> { semantic_config.qdrant_url = args.qdrant_url.clone(); semantic_config.ollama_base_url = args.ollama_base_url.clone(); semantic_config.ollama_model = args.ollama_model.clone(); - let projector = - SemanticProjectorServiceBody::new(&args.agent_store, &args.runtime_store, semantic_config)?; + let projector = SemanticProjectorServiceBody::new( + &args.agent_store, + &args.runtime_store, + semantic_config.clone(), + )?; let provider_incarnation = projector.provider_incarnation().to_string(); let mut cursor = None; let mut sequence = 0_u64; @@ -74,6 +78,33 @@ fn main() -> Result<()> { let mut retention_mutation_count = 0_u32; for input in &inputs { let store = source_store(&args, input)?; + match authorize_memory_semantic_physical_retirements( + store, + input, + args.retained_generations, + &chrono::Utc::now().to_rfc3339(), + ) { + Ok(retirements) => { + for retirement in retirements { + if let Err(error) = execute_memory_semantic_physical_retirement( + store, + input, + &retirement.retirement_id, + &semantic_config, + &chrono::Utc::now().to_rfc3339(), + ) { + retention_faults.push(format!( + "{} physical: {error:#}", + input.obligation().partition + )); + } + } + } + Err(error) => retention_faults.push(format!( + "{} physical authorization: {error:#}", + input.obligation().partition + )), + } match retain_memory_semantic_projection_lifecycles( store, input, diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index 1540d5de..161fb240 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -757,6 +757,8 @@ pub use memory_graph::MEMORY_SEMANTIC_PROJECTOR_EXECUTOR_GRANT_SCHEMA_VERSION; pub use memory_graph::MEMORY_SEMANTIC_PROJECTOR_RECOVERY_AUTHORIZATION_SCHEMA_VERSION; pub use memory_graph::MemorySemanticIndexConfig; pub use memory_graph::MemorySemanticIndexReceipt; +pub use memory_graph::MemorySemanticPhysicalRetirementObligation; +pub use memory_graph::MemorySemanticPhysicalRetirementReceipt; pub use memory_graph::MemorySemanticProjectionAttempt; pub use memory_graph::MemorySemanticProjectionClaim; pub use memory_graph::MemorySemanticProjectionHealth; @@ -794,6 +796,7 @@ pub use memory_graph::SemanticProjectionDocument; pub use memory_graph::SemanticRecoverySmokeInspection; pub use memory_graph::SemanticVectorIndex; pub use memory_graph::SemanticVisibility; +pub use memory_graph::authorize_memory_semantic_physical_retirements; pub use memory_graph::bind_memory_semantic_index_receipt; pub use memory_graph::compose_memory_graph_snapshots; pub use memory_graph::derive_memory_graph_freshness; @@ -801,6 +804,7 @@ pub use memory_graph::derive_memory_semantic_projection_health; pub use memory_graph::derive_memory_semantic_projection_obligation; pub use memory_graph::derive_repo_model_patch; pub use memory_graph::derive_semantic_projection; +pub use memory_graph::execute_memory_semantic_physical_retirement; #[cfg(feature = "semantic-recovery-smoke")] pub use memory_graph::inspect_memory_semantic_recovery_for_smoke; pub use memory_graph::lifecycle_allowed_for_profile; diff --git a/epiphany-core/src/memory_graph/semantic_projector.rs b/epiphany-core/src/memory_graph/semantic_projector.rs index a4998b68..718dc549 100644 --- a/epiphany-core/src/memory_graph/semantic_projector.rs +++ b/epiphany-core/src/memory_graph/semantic_projector.rs @@ -16,6 +16,29 @@ use sha2::{Digest, Sha256}; use std::collections::{BTreeMap, BTreeSet}; use std::path::Path; +trait MemorySemanticPhysicalRetirementPort { + fn point_ids_for_scope( + &mut self, + collection: &str, + scope: &[(&str, &str)], + ) -> Result>; + fn delete_points(&mut self, collection: &str, point_ids: &[String]) -> Result<()>; +} + +impl MemorySemanticPhysicalRetirementPort for crate::semantic_backend::QdrantBackend { + fn point_ids_for_scope( + &mut self, + collection: &str, + scope: &[(&str, &str)], + ) -> Result> { + crate::semantic_backend::QdrantBackend::point_ids_for_scope(self, collection, scope) + } + + fn delete_points(&mut self, collection: &str, point_ids: &[String]) -> Result<()> { + crate::semantic_backend::QdrantBackend::delete_points(self, collection, point_ids) + } +} + pub const MEMORY_SEMANTIC_PROJECTION_CLAIM_SCHEMA_VERSION: &str = "gamecult.epiphany.memory_semantic_projection_claim.v1"; pub const MEMORY_SEMANTIC_PROJECTOR_EXECUTOR_GRANT_SCHEMA_VERSION: &str = @@ -24,6 +47,10 @@ pub const MEMORY_SEMANTIC_PROJECTOR_RECOVERY_AUTHORIZATION_SCHEMA_VERSION: &str "gamecult.epiphany.memory_semantic_projector_recovery_authorization.v2"; pub const MEMORY_SEMANTIC_PROJECTION_RETENTION_HEAD_SCHEMA_VERSION: &str = "gamecult.epiphany.memory_semantic_projection_retention_head.v0"; +pub const MEMORY_SEMANTIC_PHYSICAL_RETIREMENT_OBLIGATION_SCHEMA_VERSION: &str = + "gamecult.epiphany.memory_semantic_physical_retirement_obligation.v0"; +pub const MEMORY_SEMANTIC_PHYSICAL_RETIREMENT_RECEIPT_SCHEMA_VERSION: &str = + "gamecult.epiphany.memory_semantic_physical_retirement_receipt.v0"; #[derive(Clone, Debug, PartialEq, DatabaseEntry)] #[cultcache( @@ -53,6 +80,64 @@ pub struct MemorySemanticProjectionRetentionHead { pub private_state_exposed: bool, } +#[derive(Clone, Debug, PartialEq, DatabaseEntry)] +#[cultcache( + type = "gamecult.epiphany.memory_semantic_physical_retirement_obligation", + schema = "MemorySemanticPhysicalRetirementObligation" +)] +pub struct MemorySemanticPhysicalRetirementObligation { + #[cultcache(key = 0)] + pub schema_version: String, + #[cultcache(key = 1)] + pub retirement_id: String, + #[cultcache(key = 2)] + pub scope_id: String, + #[cultcache(key = 3)] + pub swarm_id: String, + #[cultcache(key = 4)] + pub partition: String, + #[cultcache(key = 5)] + pub obligation_id: String, + #[cultcache(key = 6)] + pub attempt_id: String, + #[cultcache(key = 7)] + pub claim_id: String, + #[cultcache(key = 8)] + pub claim_epoch: u64, + #[cultcache(key = 9)] + pub physical_backend_url: String, + #[cultcache(key = 10)] + pub collection_name: String, + #[cultcache(key = 11)] + pub retention_authorization_sha256: String, + #[cultcache(key = 12)] + pub authorized_at: String, + #[cultcache(key = 13)] + pub private_state_exposed: bool, +} + +#[derive(Clone, Debug, PartialEq, DatabaseEntry)] +#[cultcache( + type = "gamecult.epiphany.memory_semantic_physical_retirement_receipt", + schema = "MemorySemanticPhysicalRetirementReceipt" +)] +pub struct MemorySemanticPhysicalRetirementReceipt { + #[cultcache(key = 0)] + pub schema_version: String, + #[cultcache(key = 1)] + pub receipt_id: String, + #[cultcache(key = 2)] + pub retirement_id: String, + #[cultcache(key = 3)] + pub observed_point_count: u64, + #[cultcache(key = 4)] + pub deleted_point_count: u64, + #[cultcache(key = 5)] + pub completed_at: String, + #[cultcache(key = 6)] + pub private_state_exposed: bool, +} + #[derive(Deserialize, Serialize)] struct LegacyMemorySemanticProjectionAttemptV0 { schema_version: String, @@ -2451,6 +2536,507 @@ pub fn validate_memory_semantic_projector_recovery_authorization( Ok(()) } +pub fn validate_memory_semantic_physical_retirement_obligation( + obligation: &MemorySemanticPhysicalRetirementObligation, +) -> Result<()> { + if obligation.schema_version != MEMORY_SEMANTIC_PHYSICAL_RETIREMENT_OBLIGATION_SCHEMA_VERSION + || !obligation + .retirement_id + .starts_with("memory-semantic-physical-retirement-") + || !is_opaque_identity(&obligation.retirement_id) + || !is_opaque_identity(&obligation.scope_id) + || !is_opaque_identity(&obligation.swarm_id) + || !matches!(obligation.partition.as_str(), "mind" | "modeling") + || !is_opaque_identity(&obligation.obligation_id) + || !is_opaque_identity(&obligation.attempt_id) + || !is_opaque_identity(&obligation.claim_id) + || obligation.claim_epoch == 0 + || obligation.physical_backend_url.trim().is_empty() + || obligation.collection_name.trim().is_empty() + || !obligation + .retention_authorization_sha256 + .starts_with("sha256:") + || obligation.retention_authorization_sha256.len() != 71 + || !valid_rfc3339(&obligation.authorized_at) + || obligation.private_state_exposed + { + return Err(anyhow!( + "semantic physical-retirement obligation is invalid" + )); + } + Ok(()) +} + +pub fn validate_memory_semantic_physical_retirement_receipt( + receipt: &MemorySemanticPhysicalRetirementReceipt, +) -> Result<()> { + if receipt.schema_version != MEMORY_SEMANTIC_PHYSICAL_RETIREMENT_RECEIPT_SCHEMA_VERSION + || !receipt + .receipt_id + .starts_with("memory-semantic-physical-retirement-receipt-") + || !is_opaque_identity(&receipt.receipt_id) + || !is_opaque_identity(&receipt.retirement_id) + || receipt.deleted_point_count != receipt.observed_point_count + || !valid_rfc3339(&receipt.completed_at) + || receipt.private_state_exposed + { + return Err(anyhow!("semantic physical-retirement receipt is invalid")); + } + Ok(()) +} + +fn retirement_authorization_digest(envelopes: &[CultCacheEnvelope]) -> String { + let mut rows = envelopes.to_vec(); + rows.sort_by(|left, right| { + left.r#type + .cmp(&right.r#type) + .then(left.key.cmp(&right.key)) + .then(left.payload.cmp(&right.payload)) + }); + let mut digest = Sha256::new(); + for row in rows { + digest.update((row.r#type.len() as u64).to_le_bytes()); + digest.update(row.r#type.as_bytes()); + digest.update((row.key.len() as u64).to_le_bytes()); + digest.update(row.key.as_bytes()); + digest.update((row.payload.len() as u64).to_le_bytes()); + digest.update(&row.payload); + } + format!("sha256:{:x}", digest.finalize()) +} + +fn physical_retirement_attempt_authority_rows( + snapshot: &[CultCacheEnvelope], + attempt: &MemorySemanticProjectionAttempt, +) -> Result> { + if let Some(grant) = + decode_one::(snapshot, &attempt.authority_id)? + { + validate_memory_semantic_projector_executor_grant(&grant)?; + if grant.obligation_id != attempt.obligation_id + || grant.executor_id != attempt.executor_id + || grant.executor_incarnation != attempt.executor_incarnation + || grant.resulting_claim_id.as_deref() != Some(attempt.claim_id.as_str()) + || grant.resulting_claim_epoch != Some(attempt.claim_epoch) + { + return Err(anyhow!( + "semantic physical-retirement attempt grant disagrees" + )); + } + return Ok(vec![exact_envelope( + snapshot, + MemorySemanticProjectorExecutorGrant::TYPE, + &grant.grant_id, + )?]); + } + if let Some(authorization) = + decode_one::(snapshot, &attempt.authority_id)? + { + validate_memory_semantic_projector_recovery_authorization(&authorization)?; + if authorization.obligation_id != attempt.obligation_id + || authorization.replacement_executor_id != attempt.executor_id + || authorization.replacement_executor_incarnation != attempt.executor_incarnation + || authorization.resulting_claim_id.as_deref() != Some(attempt.claim_id.as_str()) + || authorization.resulting_claim_epoch != Some(attempt.claim_epoch) + { + return Err(anyhow!( + "semantic physical-retirement attempt recovery authority disagrees" + )); + } + return Ok(vec![exact_envelope( + snapshot, + MemorySemanticProjectorRecoveryAuthorization::TYPE, + &authorization.authorization_id, + )?]); + } + Err(anyhow!( + "semantic physical-retirement attempt lost exact issuance authority" + )) +} + +pub fn authorize_memory_semantic_physical_retirements( + store_path: impl AsRef, + input: &MemorySemanticProjectionInput, + retain_recent: usize, + authorized_at: &str, +) -> Result> { + if !valid_rfc3339(authorized_at) || input.authority.envelopes.is_empty() { + return Err(anyhow!( + "semantic physical retirement requires time and canonical authority" + )); + } + validate_memory_semantic_projection_obligation(&input.obligation)?; + let store_path = store_path.as_ref(); + let cache = semantic_projector_cache(store_path)?; + let snapshot = SingleFileMessagePackBackingStore::new(store_path).pull_all()?; + for expected in &input.authority.envelopes { + if snapshot + .iter() + .find(|row| row.r#type == expected.r#type && row.key == expected.key) + != Some(expected) + { + return Err(anyhow!( + "semantic physical-retirement canonical authority advanced" + )); + } + } + let scope_id = projection_scope_id(&input.obligation.swarm_id, &input.obligation.partition)?; + if let Some(claim) = decode_one::(&snapshot, &scope_id)? { + validate_memory_semantic_projection_claim(&claim)?; + authenticate_claim_authority_from_envelopes(&snapshot, &claim)?; + let attempt = decode_one::(&snapshot, &claim.attempt_id)? + .ok_or_else(|| anyhow!("semantic physical retirement current attempt disappeared"))?; + validate_memory_semantic_projection_attempt(&attempt)?; + if !attempt_authenticates_claim(&attempt, &claim) || attempt.status != claim.status { + return Err(anyhow!( + "semantic physical retirement current claim and attempt disagree" + )); + } + if claim.status == "running" { + return Err(anyhow!( + "semantic physical retirement refuses running scope authority" + )); + } + } + let mut obligations = decode_all::(&snapshot)? + .into_iter() + .filter(|row| { + row.swarm_id == input.obligation.swarm_id && row.partition == input.obligation.partition + }) + .collect::>(); + obligations.sort_by(|left, right| { + left.source_generation + .cmp(&right.source_generation) + .then(left.created_at.cmp(&right.created_at)) + .then(left.obligation_id.cmp(&right.obligation_id)) + }); + if obligations.iter().any(|row| { + row.obligation_id != input.obligation.obligation_id + && row.source_generation >= input.obligation.source_generation + }) { + return Err(anyhow!( + "semantic physical retirement refuses a non-stale generation" + )); + } + let recent = obligations + .iter() + .rev() + .take(retain_recent.max(1)) + .map(|row| row.obligation_id.clone()) + .collect::>(); + let attempts = decode_all::(&snapshot)?; + let existing = decode_all::(&snapshot)?; + let completed = decode_all::(&snapshot)? + .into_iter() + .map(|row| row.retirement_id) + .collect::>(); + let mut admitted = Vec::new(); + let mut changed = false; + let mut insertions = Vec::new(); + for obligation in obligations { + if obligation.source_generation >= input.obligation.source_generation + || recent.contains(&obligation.obligation_id) + { + continue; + } + let obligation_envelope = exact_envelope( + &snapshot, + MemorySemanticProjectionObligation::TYPE, + &obligation.obligation_id, + )?; + for attempt in attempts.iter().filter(|row| { + row.obligation_id == obligation.obligation_id + && row.status != "running" + && !row.physical_backend_url.trim().is_empty() + && !row.collection_name.trim().is_empty() + }) { + validate_memory_semantic_projection_attempt(attempt)?; + let attempt_envelope = exact_envelope( + &snapshot, + MemorySemanticProjectionAttempt::TYPE, + &attempt.attempt_id, + )?; + let mut authority_rows = vec![obligation_envelope.clone(), attempt_envelope.clone()]; + authority_rows.extend(physical_retirement_attempt_authority_rows( + &snapshot, attempt, + )?); + for receipt in decode_all::(&snapshot)? + .into_iter() + .filter(|receipt| { + receipt.obligation_id == attempt.obligation_id + && receipt.claim_id == attempt.claim_id + && receipt.claim_epoch == attempt.claim_epoch + }) + { + authority_rows.push(exact_envelope( + &snapshot, + MemorySemanticIndexReceipt::TYPE, + &receipt.receipt_id, + )?); + } + let digest = retirement_authorization_digest( + &input + .authority + .envelopes + .iter() + .cloned() + .chain(authority_rows.iter().cloned()) + .collect::>(), + ); + let retirement_id = format!( + "memory-semantic-physical-retirement-{:x}", + Sha256::digest(format!("{}|{}", attempt.attempt_id, digest).as_bytes()) + ); + if completed.contains(&retirement_id) { + continue; + } + let candidate = MemorySemanticPhysicalRetirementObligation { + schema_version: MEMORY_SEMANTIC_PHYSICAL_RETIREMENT_OBLIGATION_SCHEMA_VERSION + .to_string(), + retirement_id: retirement_id.clone(), + scope_id: scope_id.clone(), + swarm_id: obligation.swarm_id.clone(), + partition: obligation.partition.clone(), + obligation_id: obligation.obligation_id.clone(), + attempt_id: attempt.attempt_id.clone(), + claim_id: attempt.claim_id.clone(), + claim_epoch: attempt.claim_epoch, + physical_backend_url: attempt.physical_backend_url.clone(), + collection_name: attempt.collection_name.clone(), + retention_authorization_sha256: digest, + authorized_at: authorized_at.to_string(), + private_state_exposed: false, + }; + validate_memory_semantic_physical_retirement_obligation(&candidate)?; + if let Some(prior) = existing + .iter() + .find(|row| row.retirement_id == retirement_id) + { + let mut replay = candidate.clone(); + replay.authorized_at = prior.authorized_at.clone(); + if prior != &replay { + return Err(anyhow!("semantic physical-retirement identity collision")); + } + admitted.push(prior.clone()); + continue; + } + insertions.push(cache.prepare_entry(&retirement_id, &candidate)?.0); + admitted.push(candidate); + changed = true; + } + } + if !changed { + return Ok(admitted); + } + insertions.sort_by(|left, right| { + left.r#type + .cmp(&right.r#type) + .then(left.key.cmp(&right.key)) + }); + insertions.dedup_by(|left, right| left.r#type == right.r#type && left.key == right.key); + if !SingleFileMessagePackBackingStore::new(store_path) + .append_if_snapshot_unchanged(&snapshot, insertions)? + { + return Err(anyhow!( + "semantic physical-retirement authorization lost exact CAS" + )); + } + Ok(admitted) +} + +pub fn execute_memory_semantic_physical_retirement( + store_path: impl AsRef, + input: &MemorySemanticProjectionInput, + retirement_id: &str, + config: &super::MemorySemanticIndexConfig, + completed_at: &str, +) -> Result { + let mut backend = + crate::semantic_backend::QdrantBackend::new(crate::semantic_backend::QdrantConfig { + url: config.qdrant_url.clone(), + api_key: config.qdrant_api_key.clone(), + timeout_ms: config.qdrant_timeout_ms, + })?; + execute_memory_semantic_physical_retirement_with_port( + store_path.as_ref(), + input, + retirement_id, + config, + completed_at, + &mut backend, + ) +} + +fn execute_memory_semantic_physical_retirement_with_port

( + store_path: &Path, + input: &MemorySemanticProjectionInput, + retirement_id: &str, + config: &super::MemorySemanticIndexConfig, + completed_at: &str, + port: &mut P, +) -> Result +where + P: MemorySemanticPhysicalRetirementPort, +{ + if !valid_rfc3339(completed_at) || input.authority.envelopes.is_empty() { + return Err(anyhow!( + "semantic physical retirement requires time and canonical authority" + )); + } + let cache = semantic_projector_cache(store_path)?; + let snapshot = SingleFileMessagePackBackingStore::new(store_path).pull_all()?; + let retirement = + decode_one::(&snapshot, retirement_id)? + .ok_or_else(|| anyhow!("semantic physical-retirement obligation is missing"))?; + validate_memory_semantic_physical_retirement_obligation(&retirement)?; + let receipt_id = format!( + "memory-semantic-physical-retirement-receipt-{}", + retirement + .retirement_id + .trim_start_matches("memory-semantic-physical-retirement-") + ); + if let Some(receipt) = + decode_one::(&snapshot, &receipt_id)? + { + validate_memory_semantic_physical_retirement_receipt(&receipt)?; + if receipt.retirement_id != retirement.retirement_id { + return Err(anyhow!( + "semantic physical-retirement receipt identity collision" + )); + } + return Ok(receipt); + } + if retirement.physical_backend_url != config.qdrant_url + || retirement.collection_name + != config.collection(match retirement.partition.as_str() { + "mind" => super::SemanticPartition::Mind, + "modeling" => super::SemanticPartition::Modeling, + _ => return Err(anyhow!("semantic physical-retirement partition is invalid")), + }) + { + return Err(anyhow!( + "semantic physical-retirement namespace is not permitted by current projector policy" + )); + } + for expected in &input.authority.envelopes { + if snapshot + .iter() + .find(|row| row.r#type == expected.r#type && row.key == expected.key) + != Some(expected) + { + return Err(anyhow!( + "semantic physical-retirement canonical authority advanced" + )); + } + } + let source = + decode_one::(&snapshot, &retirement.obligation_id)? + .ok_or_else(|| anyhow!("semantic physical-retirement source obligation disappeared"))?; + let attempt = decode_one::(&snapshot, &retirement.attempt_id)? + .ok_or_else(|| anyhow!("semantic physical-retirement source attempt disappeared"))?; + validate_memory_semantic_projection_obligation(&source)?; + validate_memory_semantic_projection_attempt(&attempt)?; + if source.swarm_id != retirement.swarm_id + || source.partition != retirement.partition + || source.source_generation >= input.obligation.source_generation + || attempt.status == "running" + || attempt.obligation_id != source.obligation_id + || attempt.claim_id != retirement.claim_id + || attempt.claim_epoch != retirement.claim_epoch + || attempt.physical_backend_url != retirement.physical_backend_url + || attempt.collection_name != retirement.collection_name + { + return Err(anyhow!( + "semantic physical-retirement source authority disagrees" + )); + } + let mut source_rows = vec![ + exact_envelope( + &snapshot, + MemorySemanticProjectionObligation::TYPE, + &source.obligation_id, + )?, + exact_envelope( + &snapshot, + MemorySemanticProjectionAttempt::TYPE, + &attempt.attempt_id, + )?, + ]; + source_rows.extend(physical_retirement_attempt_authority_rows( + &snapshot, &attempt, + )?); + for index_receipt in decode_all::(&snapshot)? + .into_iter() + .filter(|index_receipt| { + index_receipt.obligation_id == attempt.obligation_id + && index_receipt.claim_id == attempt.claim_id + && index_receipt.claim_epoch == attempt.claim_epoch + }) + { + source_rows.push(exact_envelope( + &snapshot, + MemorySemanticIndexReceipt::TYPE, + &index_receipt.receipt_id, + )?); + } + let digest = retirement_authorization_digest( + &input + .authority + .envelopes + .iter() + .cloned() + .chain(source_rows.iter().cloned()) + .collect::>(), + ); + if digest != retirement.retention_authorization_sha256 { + return Err(anyhow!( + "semantic physical-retirement authorization digest disagrees" + )); + } + let claim_epoch = retirement.claim_epoch.to_string(); + let scope = [ + ("swarmId", retirement.swarm_id.as_str()), + ("partition", retirement.partition.as_str()), + ("obligationId", retirement.obligation_id.as_str()), + ("claimId", retirement.claim_id.as_str()), + ("claimEpoch", claim_epoch.as_str()), + ]; + let observed = port.point_ids_for_scope(&retirement.collection_name, &scope)?; + port.delete_points(&retirement.collection_name, &observed)?; + if !port + .point_ids_for_scope(&retirement.collection_name, &scope)? + .is_empty() + { + return Err(anyhow!( + "semantic physical retirement left points in the exact namespace" + )); + } + let receipt = MemorySemanticPhysicalRetirementReceipt { + schema_version: MEMORY_SEMANTIC_PHYSICAL_RETIREMENT_RECEIPT_SCHEMA_VERSION.to_string(), + receipt_id, + retirement_id: retirement.retirement_id.clone(), + observed_point_count: observed.len() as u64, + deleted_point_count: observed.len() as u64, + completed_at: completed_at.to_string(), + private_state_exposed: false, + }; + validate_memory_semantic_physical_retirement_receipt(&receipt)?; + exact_envelope( + &snapshot, + MemorySemanticPhysicalRetirementObligation::TYPE, + &retirement.retirement_id, + )?; + let receipt_envelope = cache.prepare_entry(&receipt.receipt_id, &receipt)?.0; + if !SingleFileMessagePackBackingStore::new(store_path) + .append_if_snapshot_unchanged(&snapshot, vec![receipt_envelope])? + { + return Err(anyhow!( + "semantic physical-retirement receipt lost exact CAS" + )); + } + Ok(receipt) +} + pub fn retain_memory_semantic_projection_lifecycles( store_path: impl AsRef, input: &MemorySemanticProjectionInput, @@ -2567,6 +3153,14 @@ where let receipts = decode_all::(&snapshot)?; let grants = decode_all::(&snapshot)?; let authorizations = decode_all::(&snapshot)?; + let physical_obligations = decode_all::(&snapshot)?; + let physical_receipts = decode_all::(&snapshot)?; + for retirement in &physical_obligations { + validate_memory_semantic_physical_retirement_obligation(retirement)?; + } + for receipt in &physical_receipts { + validate_memory_semantic_physical_retirement_receipt(receipt)?; + } let mut retired_status_counts = BTreeMap::::new(); let mut retired_obligation_ids = BTreeSet::new(); for obligation in &obligations { @@ -2589,8 +3183,34 @@ where .iter() .filter(|authorization| authorization.obligation_id == obligation.obligation_id) .collect::>(); - if !obligation_attempts.is_empty() - || !obligation_receipts.is_empty() + if !obligation_attempts.is_empty() { + let physically_closed = obligation_attempts.iter().all(|attempt| { + attempt.status != "running" + && !attempt.physical_backend_url.trim().is_empty() + && !attempt.collection_name.trim().is_empty() + && physical_obligations.iter().any(|retirement| { + retirement.attempt_id == attempt.attempt_id + && retirement.obligation_id == attempt.obligation_id + && retirement.claim_id == attempt.claim_id + && retirement.claim_epoch == attempt.claim_epoch + && retirement.physical_backend_url == attempt.physical_backend_url + && retirement.collection_name == attempt.collection_name + && physical_receipts.iter().any(|receipt| { + receipt.retirement_id == retirement.retirement_id + && receipt.deleted_point_count == receipt.observed_point_count + }) + }) + }); + if !physically_closed { + continue; + } + *retired_status_counts + .entry("physically_retired_attempted".to_string()) + .or_default() += 1; + retired_obligation_ids.insert(obligation.obligation_id.clone()); + continue; + } + if !obligation_receipts.is_empty() || !obligation_grants.is_empty() || !obligation_authorizations.is_empty() { @@ -2626,6 +3246,21 @@ where && retired_obligation_ids.contains(&authorization.obligation_id) }) } + MemorySemanticPhysicalRetirementObligation::TYPE => { + physical_obligations.iter().any(|retirement| { + retirement.retirement_id == entry.key + && retired_obligation_ids.contains(&retirement.obligation_id) + }) + } + MemorySemanticPhysicalRetirementReceipt::TYPE => { + physical_receipts.iter().any(|receipt| { + receipt.receipt_id == entry.key + && physical_obligations.iter().any(|retirement| { + retirement.retirement_id == receipt.retirement_id + && retired_obligation_ids.contains(&retirement.obligation_id) + }) + }) + } _ => false, }) .cloned() @@ -2730,6 +3365,8 @@ pub(crate) fn semantic_projector_cache(store_path: &Path) -> Result { cache.register_entry_type::()?; cache.register_entry_type::()?; cache.register_entry_type::()?; + cache.register_entry_type::()?; + cache.register_entry_type::()?; cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(store_path)); Ok(cache) } @@ -3167,6 +3804,41 @@ mod retention_tests { use super::*; use tempfile::tempdir; + #[derive(Default)] + struct FakePhysicalRetirementPort { + point_ids: Vec, + observed_scopes: Vec>, + delete_calls: Vec<(String, Vec)>, + fail_delete: bool, + } + + impl MemorySemanticPhysicalRetirementPort for FakePhysicalRetirementPort { + fn point_ids_for_scope( + &mut self, + _collection: &str, + scope: &[(&str, &str)], + ) -> Result> { + self.observed_scopes.push( + scope + .iter() + .map(|(key, value)| ((*key).to_string(), (*value).to_string())) + .collect(), + ); + Ok(self.point_ids.clone()) + } + + fn delete_points(&mut self, collection: &str, point_ids: &[String]) -> Result<()> { + self.delete_calls + .push((collection.to_string(), point_ids.to_vec())); + if self.fail_delete { + return Err(anyhow!("fixture backend deletion failure")); + } + self.point_ids + .retain(|point_id| !point_ids.contains(point_id)); + Ok(()) + } + } + fn obligation(swarm_id: &str, generation: u64) -> MemorySemanticProjectionObligation { MemorySemanticProjectionObligation { schema_version: super::super::MEMORY_SEMANTIC_PROJECTION_OBLIGATION_SCHEMA_VERSION @@ -3210,7 +3882,7 @@ mod retention_tests { ); claim.status = "failed".to_string(); claim.completed_at = Some(format!("2026-08-10T04:02:{epoch:02}Z")); - let mut attempt = running_attempt(&claim, "http://qdrant", "epiphany_mind_v1"); + let mut attempt = running_attempt(&claim, "http://qdrant", "epiphany_modeling_v1"); attempt.status = "failed".to_string(); attempt.completed_at = claim.completed_at.clone(); attempt.error = Some("fixture failure".to_string()); @@ -3276,6 +3948,148 @@ mod retention_tests { } } + #[test] + fn physical_retirement_is_policy_bound_receipted_and_then_logically_compactable() -> Result<()> + { + let directory = tempdir()?; + let store = directory.path().join("semantic.cc"); + let old = obligation("swarm-physical", 1); + let current = obligation("swarm-physical", 3); + let (_claim, attempt, grant) = failed_lifecycle(&old, 1); + let mut cache = semantic_projector_cache(&store)?; + cache.put(&old.obligation_id, &old)?; + cache.put(¤t.obligation_id, ¤t)?; + cache.put(&attempt.attempt_id, &attempt)?; + cache.put(&grant.grant_id, &grant)?; + let input = input_for(&store, ¤t); + let retirements = authorize_memory_semantic_physical_retirements( + &store, + &input, + 1, + "2026-08-10T09:00:00Z", + )?; + assert_eq!(retirements.len(), 1); + let retirement = &retirements[0]; + assert_eq!(retirement.attempt_id, attempt.attempt_id); + assert_eq!(retirement.physical_backend_url, "http://qdrant"); + assert_eq!(retirement.collection_name, "epiphany_modeling_v1"); + assert_eq!( + authorize_memory_semantic_physical_retirements( + &store, + &input, + 1, + "2026-08-10T09:00:30Z", + )?, + retirements, + "pending retirement authority must replay without a new timestamp identity" + ); + + let mut config = super::super::MemorySemanticIndexConfig::from_env(); + config.qdrant_url = "http://foreign-qdrant".into(); + config.modeling_collection = "epiphany_modeling_v1".into(); + let mut untouched = FakePhysicalRetirementPort { + point_ids: vec!["point-a".into()], + ..Default::default() + }; + let error = execute_memory_semantic_physical_retirement_with_port( + &store, + &input, + &retirement.retirement_id, + &config, + "2026-08-10T09:01:00Z", + &mut untouched, + ) + .unwrap_err(); + assert!(error.to_string().contains("not permitted")); + assert!(untouched.observed_scopes.is_empty()); + assert!(untouched.delete_calls.is_empty()); + + config.qdrant_url = "http://qdrant".into(); + let mut failing = FakePhysicalRetirementPort { + point_ids: vec!["point-a".into(), "point-b".into()], + fail_delete: true, + ..Default::default() + }; + assert!( + execute_memory_semantic_physical_retirement_with_port( + &store, + &input, + &retirement.retirement_id, + &config, + "2026-08-10T09:01:30Z", + &mut failing, + ) + .is_err() + ); + let after_failure = SingleFileMessagePackBackingStore::new(&store).pull_all()?; + assert!(after_failure.iter().any(|row| { + row.r#type == MemorySemanticPhysicalRetirementObligation::TYPE + && row.key == retirement.retirement_id + })); + assert!( + !after_failure + .iter() + .any(|row| { row.r#type == MemorySemanticPhysicalRetirementReceipt::TYPE }) + ); + assert!( + retain_memory_semantic_projection_lifecycles( + &store, + &input, + 1, + "2026-08-10T09:01:31Z", + )? + .is_none(), + "backend failure must preserve logical retry authority" + ); + let mut backend = FakePhysicalRetirementPort { + point_ids: vec!["point-a".into(), "point-b".into()], + ..Default::default() + }; + let receipt = execute_memory_semantic_physical_retirement_with_port( + &store, + &input, + &retirement.retirement_id, + &config, + "2026-08-10T09:02:00Z", + &mut backend, + )?; + assert_eq!(receipt.observed_point_count, 2); + assert_eq!(receipt.deleted_point_count, 2); + assert_eq!(backend.delete_calls.len(), 1); + assert_eq!(backend.observed_scopes.len(), 2); + assert!( + backend.observed_scopes[0] + .contains(&("obligationId".into(), old.obligation_id.clone())) + ); + assert!( + backend.observed_scopes[0] + .contains(&("claimEpoch".into(), attempt.claim_epoch.to_string())) + ); + + let head = retain_memory_semantic_projection_lifecycles( + &store, + &input, + 1, + "2026-08-10T09:03:00Z", + )? + .expect("receipted physical namespace should permit logical compaction"); + assert_eq!( + head.retired_status_counts + .get("physically_retired_attempted"), + Some(&1) + ); + let after = SingleFileMessagePackBackingStore::new(&store).pull_all()?; + assert!(!after.iter().any(|row| { + row.key == old.obligation_id + || row.key == attempt.attempt_id + || row.key == grant.grant_id + || row.key == retirement.retirement_id + || row.key == receipt.receipt_id + })); + assert!(after.iter().any(|row| row.key == current.obligation_id)); + Ok(()) + } + #[test] fn semantic_lifecycle_retention_preserves_current_chain_and_refuses_stale_snapshot() -> Result<()> { diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index 531354f3..a0d9ea91 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -1036,6 +1036,8 @@ pub fn runtime_spine_cache(store_path: impl AsRef) -> Result { cache.register_entry_type::()?; cache.register_entry_type::()?; cache.register_entry_type::()?; + cache.register_entry_type::()?; + cache.register_entry_type::()?; cache.register_entry_type::()?; cache.register_entry_type::()?; cache.register_entry_type::()?; diff --git a/epiphany-core/src/workspace_coverage_process_documents.rs b/epiphany-core/src/workspace_coverage_process_documents.rs index 1dcc71cd..6402f142 100644 --- a/epiphany-core/src/workspace_coverage_process_documents.rs +++ b/epiphany-core/src/workspace_coverage_process_documents.rs @@ -4386,7 +4386,7 @@ mod tests { .args(["add", "."]) .current_dir(&repo) .output()?; - let runtime = temp.path().join("runtime.ccmp"); + let runtime = temp.path().join("runtime.cc"); let agents = temp.path().join("agents.ccmp"); let body_store = temp.path().join("body.ccmp"); crate::initialize_runtime_spine( diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 2e3f20b5..dfcce3e2 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -2732,6 +2732,32 @@ typed physical-retirement obligations for inactive attempted epochs, process only obligations whose endpoint is permitted by current projector policy, and admit exact deletion receipts before logical lifecycle compaction. +The typed physical cut is now implemented in source. A full-snapshot-fenced +authorization pass considers only generations below the retained window and +refuses future or running authority. Each exact terminal attempt must retain its +authenticated Idunn grant or recovery authorization. The immutable retirement +obligation binds the old source obligation, attempt, claim and epoch, swarm and +partition, Qdrant endpoint and collection, plus a digest over current canonical +authority and the exact historical lifecycle rows. A changed timestamp replays +the existing obligation rather than minting a new identity. + +The executor first requires the recorded endpoint and collection to equal the +current managed projector configuration. Foreign persisted endpoints are +refused before backend reads. It then reauthenticates the source rows and digest, +scrolls only the full five-field namespace `(swarm, partition, obligation, +claim, epoch)`, deletes those exact point IDs, rescrolls to prove absence, and +appends a terminal receipt under a full-snapshot fence. Backend failure writes +no receipt and preserves retry authority. Logical compaction accepts attempted +history only when every attempt has a matching terminal physical receipt; it +then retires lifecycle and cleanup documents into the cumulative head in the +same fenced compaction. + +The daemon runs authorization and pending cleanup before logical retention on +each pulse. The endpoint gate is deliberately policy-bound: a historical +endpoint no longer present in current managed policy remains pending rather +than turning canonical state into arbitrary network deletion authority. Exact +package and copied-live Qdrant proof remain the acceptance boundary. + The copied-live physical audit sharpened the next ownership boundary. A durable physical-retirement obligation must be emitted before an attempted lifecycle can retire. It must carry exact collection name, obligation ID, claim ID, claim diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index d0569cd9..2e285750 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -1791,3 +1791,27 @@ Ten focused semantic authority tests pass, including exact namespace persistence and substituted-endpoint refusal before backend I/O. The next move is the typed physical-retirement obligation/receipt CAS and policy-bound executor. This source foundation is not yet packaged or accepted live. + +## Typed semantic physical retirement implemented — 2026-08-10 + +Source now contains the complete typed circuit: full-snapshot authorization of +inactive old attempts, immutable exact-namespace obligations, current-policy +endpoint/collection gating before backend I/O, full five-field Qdrant scope +deletion, empty-scope verification, terminal receipts, retry preservation on +backend failure, and logical compaction only after every attempted epoch is +physically receipted. Pending obligation replay keeps its original timestamp and +identity. General Mind and runtime readers register both new evidence schemas. + +The end-to-end fake-backend test proves foreign endpoints cause zero reads or +deletes, backend failure leaves the obligation without a receipt and blocks +logical compaction, retry deletes only the exact scope, and the receipt then +permits bounded lifecycle retirement. The complete library sweep passes 644 +tests with one intentional ignored helper after three stale `.ccmp` test fixtures +were corrected to the current explicit runtime-store extension contract. + +This phase is source-complete but not yet packaged or accepted live. Next: +commit/push, produce one exact cached package, then use copied canonical state +and an isolated Qdrant body to prove physical points disappear, unrelated +namespaces remain byte/ID-identical, failure retries, ordinary semantic health +survives, and replay is inert. Active `c005` remains untouchable; Yggdrasil never +builds. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 227d1cf12e622c2cde82d2e257d08d5ca4541e81..9e130064a2292cc5f48a0d8724fb175d6d76b173 100644 GIT binary patch delta 656 zcmX|;zityj5XL$4Hw8_KG&CcThT?1|I1#dI3Pb@&u8=6kdvm@~_I8)ux!9M+NGZ}I zEFJ-g1|$l^3-Azhya}^bLh)&f-TCJCef#C>;fHUB-w%q1lj+gP^yKN=-?#P--u-x7 zyf2FN<#uqj9Tcj3-d5dF-BsOF-B&&MxgG3%+~5E7>v(*8T8^KUN8|Z8dwu@WZ@2mNo%9_bm;IO3>&=6Fl(3wn=L`o)R^J)egq1dw9 zr8UGM@5hBzck7os<{VgK>@aS&)yTGs1VODRp6hGvD)u)eNI!(=I}lnqCn!au2+8K2kM=c@v2s32LE3 zW7+^UuSLNUtVr>U*Vc?^x8gw>(t?8a#{#iayH;n%`Zf8Xlc*tw@LK!CCA;OwYK}Xc2U7Fwj{pDw delta 71 zcmZozud;lV$_6n;USlg$BP(OWsACMAA}pJg84DR1%bTY%wNGVY1Y!`)48$xz%nHP8 QK+F!r9NVWdaZVBf0OW)eIsgCw diff --git a/state/map.yaml b/state/map.yaml index 7b3032db..d9c53e53 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -36,9 +36,9 @@ invariants: current_status: summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Exact b8138a6b active-child SIGTERM and restart, exact 9f369528 deterministic warm packaging, exact c930f505 cross-container ownership, exact ed15f83a resident lifecycle retention, exact 16c4b19f coordinator receipt and Heartbeat artifact retention, exact cce2b8ac narrow model-generation retention, exact eea15e82 model-turn JSON ingress, and exact b1e8c89a fail-closed semantic unattempted-generation retention are proven. Gamecult-ops 059821f makes journald the sole Yggdrasil supervisor/projector stream-retention owner. Exact 16c4b19f genuine idle and exact a987d2f7 active cognition completed 900-pulse bounded plateaus. Runtime-owned typed fulfillment is accepted live under exact 6dd9b132. Attempted semantic/physical retirement and Persona conversation retention remain separate. Stable Starfire firewall ownership remains open. Yggdrasil is the small public crossing body, never the release forge. - latest_phase: Exact b1e8c89a packaged warning-free with 24 binaries as release sha256-3ce86fa7ce0ce15d78756d1f57b56e972d9bc37be3115b302ec567ce5e9b202e and witness sha256-fb1dd5599340a2e94600994d68661ed53820ba7fc605ac5b753f5e9632b46baf. On a pristine copied Eyes-tools store, window-one retention retired exactly three superseded unattempted Modeling obligations into revision-1 digest sha256:1cbb209d0cac9decf0715fd91faf07d1c0261805a04c0e6c0af9f3c3d7b5bb54; zero unrelated envelopes changed or disappeared; all 20 Mind envelopes remained byte-identical; packaged health preserved exact Mind readiness, receipt, hashes, generation, and 43-document count; ordinary consumers read the head; replay reported zero retention mutations and left the head at revision 1. Every attempted generation is preserved pending a durable physical-retirement obligation. Receipts are under .epiphany-run/semantic-retention-b1e8c89a and .epiphany-run/linux-package-b1e8c89a. + latest_phase: Exact b1e8c89a remains the accepted live semantic logical-retention boundary. Current source adds typed physical retirement: attempt-owned endpoint/collection identity, full-snapshot authorization, exact five-field Qdrant deletion, current-policy endpoint gating before I/O, terminal receipt admission, retry preservation, and logical compaction only after every attempted epoch is receipted. The complete library sweep passes 644 tests with one intentional ignored helper. Exact packaging and isolated copied-live Qdrant proof remain open; therefore attempted physical retirement is implemented but not yet accepted live. operational_state: - local_worktree: semantic_physical_namespace_foundation_uncommitted + local_worktree: semantic_physical_retirement_implemented_uncommitted operator_wireguard: restored yggdrasil: canonical_small_public_crossing_body starfire: temporary_epiphany_cognition_body @@ -69,7 +69,7 @@ current_status: yggdrasil_epiphany_service_contract: repaired_in_gamecult_ops_812b427_not_installed resident_physiology: authenticated_9b8df0b4_c005_bound_to_eyes_tools_nervous_system_with_217dd_and_bd96305e_helpers_running unresolved_authority: Coordinator receipt, Heartbeat pulse-artifact, deployed supervisor/projector log retention, genuine-idle and active resource plateaus, exact-grant terminality, restart-persistent cooldown refusal, schedule/action issuance cardinality, runtime-owned typed fulfillment, narrow model-generation retention, published model-turn JSON ingress, and semantic unattempted-generation retention are accepted. Attempted semantic lifecycle and physical Qdrant epochs remain unbounded until a durable cleanup obligation preserves exact collection/claim/epoch identity across crash and backend failure. Conversation-wide runtime histories remain separate/unbounded. Repository Body observation still performs two authenticated full-tree Git index/manifest passes. Execute-mode workers require a persistent process body. Keyed storage has not earned live migration. One Discord consequence remains blocked by the absent Yggdrasil credential. - next_action: Complete the typed semantic physical-retirement obligation and receipt CAS on top of the acquired endpoint-and-collection namespace. Emit only for canonically inactive attempted epochs, let the projector act only when current policy permits the recorded endpoint, preserve retry authority across backend failure, and compact lifecycle only after the exact terminal receipt. Preserve active c005. Yggdrasil never builds. + next_action: Commit and push the typed semantic physical-retirement circuit, then package the exact source on Starfire and prove it against copied canonical state plus isolated Qdrant: exact old namespace deleted, foreign namespace unchanged, failed deletion retryable, health unchanged, logical compaction receipted, replay inert. Preserve active c005. Yggdrasil never builds. active_subgoals: - Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.