From 6b01642d3aa9cf84b35e300371d2168698f633eb Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 10 Aug 2026 04:52:32 +0100 Subject: [PATCH] Bind semantic attempts to physical namespace --- .../src/memory_graph/semantic_index.rs | 13 +- .../src/memory_graph/semantic_projector.rs | 146 +++++++++++++++++- epiphany-core/src/repository_readiness.rs | 2 + .../src/semantic_projector_service.rs | 6 +- notes/epiphany-current-algorithmic-map.md | 16 ++ notes/fresh-workspace-handoff.md | 15 ++ state/ledgers.msgpack | Bin 594806 -> 595239 bytes state/map.yaml | 4 +- 8 files changed, 190 insertions(+), 12 deletions(-) diff --git a/epiphany-core/src/memory_graph/semantic_index.rs b/epiphany-core/src/memory_graph/semantic_index.rs index b2186ab3..76054ce5 100644 --- a/epiphany-core/src/memory_graph/semantic_index.rs +++ b/epiphany-core/src/memory_graph/semantic_index.rs @@ -70,7 +70,7 @@ impl MemorySemanticIndexConfig { } } - fn collection(&self, partition: SemanticPartition) -> &str { + pub(crate) fn collection(&self, partition: SemanticPartition) -> &str { match partition { SemanticPartition::Mind => &self.mind_collection, SemanticPartition::Modeling => &self.modeling_collection, @@ -170,6 +170,10 @@ pub struct MemorySemanticProjectionAttempt { pub executor_incarnation: String, #[cultcache(key = 11)] pub authority_id: String, + #[cultcache(key = 12, default)] + pub physical_backend_url: String, + #[cultcache(key = 13, default)] + pub collection_name: String, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] @@ -426,6 +430,11 @@ pub fn validate_memory_semantic_projection_attempt( "semantic projection attempt completes before it starts" )); } + if attempt.physical_backend_url.trim().is_empty() != attempt.collection_name.trim().is_empty() { + return Err(anyhow!( + "semantic projection attempt has a partial physical namespace" + )); + } match attempt.status.as_str() { "running" if attempt.completed_at.is_none() && attempt.error.is_none() => Ok(()), "failed" if attempt.completed_at.is_some() && attempt.error.is_some() => Ok(()), @@ -1670,6 +1679,8 @@ mod tests { executor_id: "executor-a".to_string(), executor_incarnation: "executor-a-incarnation".to_string(), authority_id: "authority-a".to_string(), + physical_backend_url: "http://qdrant".to_string(), + collection_name: "epiphany_modeling_v1".to_string(), } } diff --git a/epiphany-core/src/memory_graph/semantic_projector.rs b/epiphany-core/src/memory_graph/semantic_projector.rs index ebdfde34..a4998b68 100644 --- a/epiphany-core/src/memory_graph/semantic_projector.rs +++ b/epiphany-core/src/memory_graph/semantic_projector.rs @@ -264,6 +264,8 @@ pub fn migrate_memory_semantic_projection_attempts_v0( executor_id: claim.executor_id.clone(), executor_incarnation: claim.executor_incarnation.clone(), authority_id: claim.authority_id.clone(), + physical_backend_url: String::new(), + collection_name: String::new(), }; validate_memory_semantic_projection_attempt(&upgraded)?; let mut replacement: CultCacheEnvelope = envelope.clone(); @@ -384,6 +386,77 @@ mod authority_tests { }) } + #[test] + fn acquisition_persists_exact_physical_namespace() -> Result<()> { + let temp = tempdir()?; + let store = temp.path().join("physical-namespace.cc"); + let obligation = obligation(); + let mut cache = semantic_projector_cache(&store)?; + cache.put(&obligation.obligation_id, &obligation)?; + let input = input(&store, &obligation)?; + let mut config = super::super::MemorySemanticIndexConfig::from_env(); + config.qdrant_url = "http://qdrant-history:6333".into(); + config.modeling_collection = "modeling-history-v9".into(); + let acquisition = idunn_acquire_memory_semantic_projection_with_config( + &store, + &input, + "executor-a", + "executor-incarnation-a", + "execute", + "idunn-a", + "2026-07-15T04:01:00Z", + &config, + )?; + let rows = SingleFileMessagePackBackingStore::new(&store).pull_all()?; + let attempt = + decode_one::(&rows, &acquisition.claim.attempt_id)? + .context("acquired attempt missing")?; + assert_eq!(attempt.physical_backend_url, config.qdrant_url); + assert_eq!(attempt.collection_name, config.modeling_collection); + Ok(()) + } + + #[test] + fn execution_refuses_a_substituted_physical_namespace_before_backend_io() -> Result<()> { + let temp = tempdir()?; + let store = temp.path().join("substituted-namespace.cc"); + let obligation = obligation(); + let mut cache = semantic_projector_cache(&store)?; + cache.put(&obligation.obligation_id, &obligation)?; + let input = input(&store, &obligation)?; + let mut acquired = super::super::MemorySemanticIndexConfig::from_env(); + acquired.qdrant_url = "http://qdrant-history:6333".into(); + acquired.modeling_collection = "modeling-history-v9".into(); + let acquisition = idunn_acquire_memory_semantic_projection_with_config( + &store, + &input, + "executor-a", + "executor-incarnation-a", + "execute", + "idunn-a", + "2026-07-15T04:01:00Z", + &acquired, + )?; + let mut substituted = acquired.clone(); + substituted.qdrant_url = "http://foreign-qdrant:6333".into(); + let error = execute_memory_semantic_projection( + &store, + &input, + &acquisition.claim.claim_id, + &substituted, + ) + .expect_err("substituted physical namespace must fail closed"); + assert!(error.to_string().contains("acquired physical namespace")); + let rows = SingleFileMessagePackBackingStore::new(&store).pull_all()?; + let attempt = + decode_one::(&rows, &acquisition.claim.attempt_id)? + .context("failed attempt missing")?; + assert_eq!(attempt.status, "failed"); + assert_eq!(attempt.physical_backend_url, acquired.qdrant_url); + assert_eq!(attempt.collection_name, acquired.modeling_collection); + Ok(()) + } + #[test] fn empty_projection_terminal_succeeds_once_without_becoming_query_eligible() -> Result<()> { let temp = tempdir()?; @@ -1579,7 +1652,7 @@ pub(crate) fn owned_running_memory_semantic_projection_claim( } #[allow(clippy::too_many_arguments)] -pub(crate) fn idunn_acquire_memory_semantic_projection( +pub(crate) fn idunn_acquire_memory_semantic_projection_with_config( store_path: impl AsRef, input: &MemorySemanticProjectionInput, executor_id: &str, @@ -1587,6 +1660,7 @@ pub(crate) fn idunn_acquire_memory_semantic_projection( purpose: &str, idunn_incarnation: &str, acquired_at: &str, + config: &super::MemorySemanticIndexConfig, ) -> Result { let obligation = &input.obligation; validate_memory_semantic_projection_obligation(obligation)?; @@ -1665,7 +1739,19 @@ pub(crate) fn idunn_acquire_memory_semantic_projection( epoch, acquired_at, ); - let attempt = running_attempt(&claim); + let partition = match obligation.partition.as_str() { + "mind" => super::SemanticPartition::Mind, + "modeling" => super::SemanticPartition::Modeling, + _ => { + return Err(anyhow!( + "semantic projection obligation partition is invalid" + )); + } + }; + if config.qdrant_url.trim().is_empty() || config.collection(partition).trim().is_empty() { + return Err(anyhow!("semantic projection physical namespace is invalid")); + } + let attempt = running_attempt(&claim, &config.qdrant_url, config.collection(partition)); let grant = MemorySemanticProjectorExecutorGrant { schema_version: MEMORY_SEMANTIC_PROJECTOR_EXECUTOR_GRANT_SCHEMA_VERSION.to_string(), grant_id: grant_id.clone(), @@ -1749,6 +1835,28 @@ pub(crate) fn idunn_acquire_memory_semantic_projection( Ok(MemorySemanticProjectorAcquisition { grant, claim }) } +#[cfg(test)] +pub(crate) fn idunn_acquire_memory_semantic_projection( + store_path: impl AsRef, + input: &MemorySemanticProjectionInput, + executor_id: &str, + executor_incarnation: &str, + purpose: &str, + idunn_incarnation: &str, + acquired_at: &str, +) -> Result { + idunn_acquire_memory_semantic_projection_with_config( + store_path, + input, + executor_id, + executor_incarnation, + purpose, + idunn_incarnation, + acquired_at, + &super::MemorySemanticIndexConfig::from_env(), + ) +} + pub(crate) fn execute_memory_semantic_projection( store_path: impl AsRef, input: &MemorySemanticProjectionInput, @@ -1766,13 +1874,27 @@ pub(crate) fn execute_memory_semantic_projection( }; let store_path = store_path.as_ref(); let started_at = now_rfc3339(); - let (_, _, claim, _) = load_running_claim(store_path, claim_id)?; + let (_, _, claim, attempt) = load_running_claim(store_path, claim_id)?; if claim.obligation_id != input.obligation.obligation_id { return Err(anyhow!( "semantic projection claim does not bind input obligation" )); } authenticate_claim_authority(store_path, &claim)?; + if attempt.physical_backend_url != config.qdrant_url + || attempt.collection_name != config.collection(partition) + { + let error = anyhow!( + "semantic projection execution config disagrees with acquired physical namespace" + ); + let _ = fail_memory_semantic_projection_claim( + store_path, + &claim.claim_id, + &now_rfc3339(), + &format!("{error:#}"), + ); + return Err(error); + } let raw_receipt = match super::semantic_index::index_memory_semantic_partition( &input.snapshot, &input.obligation.swarm_id, @@ -1938,7 +2060,11 @@ pub(crate) fn idunn_recover_memory_semantic_projection( current.epoch + 1, recovered_at, ); - let next_attempt = running_attempt(&next); + let next_attempt = running_attempt( + &next, + &old_attempt.physical_backend_url, + &old_attempt.collection_name, + ); let failed_attempt = MemorySemanticProjectionAttempt { completed_at: Some(recovered_at.to_string()), status: "failed".to_string(), @@ -2649,7 +2775,11 @@ fn running_claim( } } -fn running_attempt(claim: &MemorySemanticProjectionClaim) -> MemorySemanticProjectionAttempt { +fn running_attempt( + claim: &MemorySemanticProjectionClaim, + physical_backend_url: &str, + collection_name: &str, +) -> MemorySemanticProjectionAttempt { MemorySemanticProjectionAttempt { schema_version: MEMORY_SEMANTIC_PROJECTION_ATTEMPT_SCHEMA_VERSION.to_string(), attempt_id: claim.attempt_id.clone(), @@ -2663,6 +2793,8 @@ fn running_attempt(claim: &MemorySemanticProjectionClaim) -> MemorySemanticProje executor_id: claim.executor_id.clone(), executor_incarnation: claim.executor_incarnation.clone(), authority_id: claim.authority_id.clone(), + physical_backend_url: physical_backend_url.to_string(), + collection_name: collection_name.to_string(), } } @@ -3078,7 +3210,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); + let mut attempt = running_attempt(&claim, "http://qdrant", "epiphany_mind_v1"); attempt.status = "failed".to_string(); attempt.completed_at = claim.completed_at.clone(); attempt.error = Some("fixture failure".to_string()); @@ -3384,7 +3516,7 @@ mod retention_tests { 1, "2026-08-10T06:00:00Z", ); - let attempt = running_attempt(&claim); + let attempt = running_attempt(&claim, "http://qdrant", "epiphany_mind_v1"); let grant = MemorySemanticProjectorExecutorGrant { schema_version: MEMORY_SEMANTIC_PROJECTOR_EXECUTOR_GRANT_SCHEMA_VERSION.to_string(), grant_id: grant_id.to_string(), diff --git a/epiphany-core/src/repository_readiness.rs b/epiphany-core/src/repository_readiness.rs index e31171b8..00a8e295 100644 --- a/epiphany-core/src/repository_readiness.rs +++ b/epiphany-core/src/repository_readiness.rs @@ -1131,6 +1131,8 @@ mod tests { executor_id: claim.executor_id.clone(), executor_incarnation: claim.executor_incarnation.clone(), authority_id: claim.authority_id.clone(), + physical_backend_url: "http://qdrant".into(), + collection_name: "semantic-modeling".into(), }; let rows = vec![ envelope(crate::MEMORY_GRAPH_KEY, &model_entry), diff --git a/epiphany-core/src/semantic_projector_service.rs b/epiphany-core/src/semantic_projector_service.rs index 6621742b..0b7d23a2 100644 --- a/epiphany-core/src/semantic_projector_service.rs +++ b/epiphany-core/src/semantic_projector_service.rs @@ -1,6 +1,7 @@ use crate::memory_graph::semantic_projector::{ classify_memory_semantic_projection_for_pulse, execute_memory_semantic_projection, - idunn_acquire_memory_semantic_projection, owned_running_memory_semantic_projection_claim, + idunn_acquire_memory_semantic_projection_with_config, + owned_running_memory_semantic_projection_claim, }; use crate::memory_graph::{ MemorySemanticProjectorPulseClassification, MemorySemanticProjectorPulseOutcome, @@ -262,7 +263,7 @@ impl MemorySemanticProjectorPulsePort for LocalIdunnSemanticProjectorSession { purpose: &str, ) -> Result> { let store = self.store_for(input)?; - match idunn_acquire_memory_semantic_projection( + match idunn_acquire_memory_semantic_projection_with_config( store, input, &self.executor_id, @@ -270,6 +271,7 @@ impl MemorySemanticProjectorPulsePort for LocalIdunnSemanticProjectorSession { purpose, &self.idunn_incarnation, &Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true), + &self.config, ) { Ok(acquisition) => Ok(Some(acquisition.claim.claim_id)), Err(_error) diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 7e890bea..2e3f20b5 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -2716,6 +2716,22 @@ zero retention mutation. Receipts live under collection/configuration identity required for failed partial writes; resolve that ownership seam from source before implementation. +Source inspection resolved the first half of that seam. The Qdrant endpoint and +collection are selected by `MemorySemanticIndexConfig` in the resident projector +body, after Idunn previously created the attempt. The attempt therefore owned +claim/epoch identity but not the physical address used by its writes. Acquisition +now receives the same exact config used by execution and persists both endpoint +and collection on the attempt before backend I/O. Execution compares its live +config with that acquired namespace and terminally fails the claim before any +backend call when they differ. Migrated historical attempts retain empty paired +fields rather than receiving invented history; they remain non-retirable until +operator-grounded evidence can name their old backend. + +This is only the address-ownership foundation. The next cut must atomically emit +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 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 8a91ed6e..d0569cd9 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -1776,3 +1776,18 @@ The accepted boundary is deliberately narrow: unattempted superseded semantic obligations are bounded; every attempted generation remains durable. The next cut is a physical-retirement obligation and executor receipt carrying exact backend namespace. Active `c005` was untouched. Yggdrasil did not build. + +## Physical namespace ownership foundation — 2026-08-10 + +The physical audit found that collection identity alone was insufficient: a +historical Qdrant endpoint is also part of the address. Projector acquisition +now persists the exact configured endpoint and partition collection on each new +semantic attempt before backend I/O. Execution refuses and terminally fails a +claim when its current config differs, without touching either backend. Legacy +attempt rows remain readable with both fields empty; no migration fabricates a +physical address that was never recorded. + +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. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index ed40a95193c6c4aa22b83d734bb63ec726c6645f..227d1cf12e622c2cde82d2e257d08d5ca4541e81 100644 GIT binary patch delta 461 zcmX|7u}T9$5cQI1qBa&HHp+k&7BMD~H2DC*O2kxlb9-~i;$`>T+2gz_h=pGe@&lqE z7J`L;ApV9wVeMQr7LQ%#&CGjmz909Wp7&q3gY{mwf84qJSX$kzz3m0pL6F}~EBDh% zASmCepe9%rtO)9Y#{0Cg`n558`E0B;I_*LGxZmr}5UV?r+Y1__@mc|TPvg`Bs_RU% z_SzaSHV2y<20tR88&n?BQNdba0wJm^G7(@DIb!aEp?tA~AtlF}J)B2Q)`K*rR?8<% zG9l6VUxA6TNkVEa7E){-!RgUiQ?y8B^QxmbV`AVeWEsjlMWC#S^$`9B{*5RlKAM1H zDxo2&0-Vhm9C_46M75LIGGhU;rX&*T0414|cxWKT&`GjVU?kS9D_SrhsauutZ1fMAX`flBB9+d?ISxfd_K!(2+Az^WEZrYDQl#am!iWc!8{PQU4?O*)=l}o! delta 69 zcmZ3!O6A)!l?@V%+$IKACWcYR7&wK3H!Cw1GBTDmPi1PK%ESo7AetG7S%8=oh}nRc O9f&!$Pi5kKC;$NN&J@uA diff --git a/state/map.yaml b/state/map.yaml index c925c0ed..7b3032db 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -38,7 +38,7 @@ 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. operational_state: - local_worktree: semantic_unattempted_retention_accepted_mind_refresh_uncommitted + local_worktree: semantic_physical_namespace_foundation_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: Map and implement a durable semantic physical-retirement obligation before allowing any attempted lifecycle to compact. It must preserve exact collection, obligation, claim, epoch, partition/swarm, and canonical retention authorization; the semantic executor alone deletes that exact Qdrant namespace and writes a terminal receipt; backend failure leaves retryable authority without affecting readiness. Preserve active c005. Yggdrasil never builds. + 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. active_subgoals: - Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.