From 3f5aab427b6bbe5139a53341ab1ec9c8881cfdd8 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 16 Jul 2026 13:21:59 +0100 Subject: [PATCH] Repair legacy semantic successes through Idunn --- .../src/memory_graph/semantic_projector.rs | 153 +++++++++++++++--- .../memory_graph/semantic_projector_pulse.rs | 33 ++-- notes/fresh-workspace-handoff.md | 35 +++- ...graph-semantic-projection-authority-map.md | 7 +- state/ledgers.msgpack | Bin 523688 -> 524201 bytes state/map.yaml | 3 +- 6 files changed, 195 insertions(+), 36 deletions(-) diff --git a/epiphany-core/src/memory_graph/semantic_projector.rs b/epiphany-core/src/memory_graph/semantic_projector.rs index 4fe34b10..f7df9749 100644 --- a/epiphany-core/src/memory_graph/semantic_projector.rs +++ b/epiphany-core/src/memory_graph/semantic_projector.rs @@ -2,8 +2,8 @@ use super::{ MEMORY_SEMANTIC_PROJECTION_ATTEMPT_SCHEMA_VERSION, MemorySemanticIndexReceipt, MemorySemanticProjectionAttempt, MemorySemanticProjectionObligation, MemorySemanticProjectionSourceHead, bind_memory_semantic_index_receipt, - memory_semantic_projection_terminal_success, - validate_memory_semantic_projection_attempt, validate_memory_semantic_projection_obligation, + memory_semantic_projection_terminal_success, validate_memory_semantic_projection_attempt, + validate_memory_semantic_projection_obligation, }; use anyhow::{Result, anyhow}; use cultcache_rs::{ @@ -413,7 +413,7 @@ mod authority_tests { )); assert_eq!( classify_memory_semantic_projection_for_pulse(&store, &input)?, - crate::MemorySemanticProjectorPulseClassification::Succeeded + crate::MemorySemanticProjectorPulseClassification::Ready ); assert!( idunn_acquire_memory_semantic_projection( @@ -427,6 +427,87 @@ mod authority_tests { ) .is_err() ); + let mut legacy = readiness.receipt; + legacy.schema_version = "gamecult.epiphany.memory_semantic_index_receipt.v1".into(); + legacy.observed_vector_binding_root_sha256.clear(); + let mut cache = semantic_projector_cache(&store)?; + cache.put(&legacy.receipt_id, &legacy)?; + assert_eq!( + classify_memory_semantic_projection_for_pulse(&store, &input)?, + crate::MemorySemanticProjectorPulseClassification::Repair + ); + let scope_id = projection_scope_id(&obligation.swarm_id, &obligation.partition)?; + cache.pull_all_backing_stores()?; + let current = cache + .get::(&scope_id)? + .expect("succeeded predecessor"); + let mut forged = current.clone(); + forged.authority_id = "missing-consumed-authority".into(); + cache.put(&scope_id, &forged)?; + assert!(classify_memory_semantic_projection_for_pulse(&store, &input).is_err()); + assert!( + idunn_acquire_memory_semantic_projection( + &store, + &input, + "executor-b", + "executor-incarnation-b", + "repair", + "idunn-b", + "2026-07-15T04:03:00Z", + ) + .is_err() + ); + cache.put(&scope_id, ¤t)?; + let repair = idunn_acquire_memory_semantic_projection( + &store, + &input, + "executor-b", + "executor-incarnation-b", + "repair", + "idunn-b", + "2026-07-15T04:03:00Z", + )?; + assert_eq!(repair.claim.epoch, acquisition.claim.epoch + 1); + fail_memory_semantic_projection_claim( + &store, + &repair.claim.claim_id, + "2026-07-15T04:04:00Z", + "transient embedding failure", + )?; + assert_eq!( + classify_memory_semantic_projection_for_pulse(&store, &input)?, + crate::MemorySemanticProjectorPulseClassification::Failed + ); + let retry = idunn_acquire_memory_semantic_projection( + &store, + &input, + "executor-c", + "executor-incarnation-c", + "execute", + "idunn-c", + "2026-07-15T04:05:00Z", + )?; + assert_eq!(retry.claim.epoch, repair.claim.epoch + 1); + let migrated = MemorySemanticIndexReceipt { + schema_version: crate::MEMORY_SEMANTIC_INDEX_RECEIPT_SCHEMA_VERSION.to_string(), + receipt_id: "empty-receipt-v2".into(), + indexed_at: "2026-07-15T04:06:00Z".into(), + claim_id: retry.claim.claim_id.clone(), + claim_epoch: retry.claim.epoch, + observed_vector_binding_root_sha256: format!("{:x}", Sha256::digest([])), + ..legacy + }; + succeed_memory_semantic_projection_claim( + &store, + &retry.claim.claim_id, + &input.authority, + migrated, + "2026-07-15T04:06:01Z", + )?; + assert_eq!( + classify_memory_semantic_projection_for_pulse(&store, &input)?, + crate::MemorySemanticProjectorPulseClassification::Ready + ); Ok(()) } @@ -1384,7 +1465,8 @@ pub(crate) fn classify_memory_semantic_projection_for_pulse( } } let scope_id = projection_scope_id(&input.obligation.swarm_id, &input.obligation.partition)?; - if let Some(claim) = decode_one::(&envelopes, &scope_id)? { + let current_claim = decode_one::(&envelopes, &scope_id)?; + if let Some(claim) = ¤t_claim { validate_memory_semantic_projection_claim(&claim)?; if claim.scope_id != scope_id { return Err(anyhow!("semantic projector pulse claim key disagrees")); @@ -1392,9 +1474,6 @@ pub(crate) fn classify_memory_semantic_projection_for_pulse( if claim.obligation_id == input.obligation.obligation_id { match claim.status.as_str() { "running" => return Ok(super::MemorySemanticProjectorPulseClassification::Running), - "succeeded" => { - return Ok(super::MemorySemanticProjectorPulseClassification::Succeeded); - } _ => {} } } @@ -1405,12 +1484,27 @@ pub(crate) fn classify_memory_semantic_projection_for_pulse( &decode_all::(&envelopes)?, &decode_all::(&envelopes)?, )?; + let succeeded_predecessor = current_claim + .as_ref() + .map(|claim| { + authenticated_succeeded_predecessor(&envelopes, claim, &input.obligation.obligation_id) + }) + .transpose()? + .unwrap_or(false); Ok(match health.status { super::MemorySemanticProjectionHealthStatus::Pending => { - super::MemorySemanticProjectorPulseClassification::Pending + if succeeded_predecessor { + super::MemorySemanticProjectorPulseClassification::Repair + } else { + super::MemorySemanticProjectorPulseClassification::Pending + } } super::MemorySemanticProjectionHealthStatus::Failed => { - super::MemorySemanticProjectorPulseClassification::Failed + if succeeded_predecessor { + super::MemorySemanticProjectorPulseClassification::Repair + } else { + super::MemorySemanticProjectorPulseClassification::Failed + } } super::MemorySemanticProjectionHealthStatus::Ready => { super::MemorySemanticProjectorPulseClassification::Ready @@ -1498,7 +1592,7 @@ pub(crate) fn idunn_acquire_memory_semantic_projection( let attempt = decode_one::(&opening, &claim.attempt_id)? .ok_or_else(|| anyhow!("semantic projector scope attempt disappeared"))?; validate_memory_semantic_projection_attempt(&attempt)?; - if attempt.obligation_id != claim.obligation_id || attempt.status != claim.status { + if !attempt_authenticates_claim(&attempt, claim) || attempt.status != claim.status { return Err(anyhow!( "semantic projector scope claim and attempt disagree" )); @@ -1512,19 +1606,18 @@ pub(crate) fn idunn_acquire_memory_semantic_projection( "acquisition before predecessor", )?; } + let succeeded_predecessor = current + .as_ref() + .map(|claim| { + authenticated_succeeded_predecessor(&opening, claim, &obligation.obligation_id) + }) + .transpose()? + .unwrap_or(false); match purpose { - "execute" - if current.as_ref().is_some_and(|claim| { - claim.status == "succeeded" && claim.obligation_id == obligation.obligation_id - }) => - { + "execute" if succeeded_predecessor => { return Err(anyhow!("execute grant cannot authorize succeeded repair")); } - "repair" - if !current.as_ref().is_some_and(|claim| { - claim.status == "succeeded" && claim.obligation_id == obligation.obligation_id - }) => - { + "repair" if !succeeded_predecessor => { return Err(anyhow!("repair grant requires exact succeeded claim")); } _ => {} @@ -2407,6 +2500,26 @@ fn attempt_authenticates_claim( } } +fn authenticated_succeeded_predecessor( + envelopes: &[CultCacheEnvelope], + claim: &MemorySemanticProjectionClaim, + obligation_id: &str, +) -> Result { + if claim.status != "succeeded" || claim.obligation_id != obligation_id { + return Ok(false); + } + authenticate_claim_authority_from_envelopes(envelopes, claim)?; + let attempt = decode_one::(envelopes, &claim.attempt_id)? + .ok_or_else(|| anyhow!("succeeded semantic predecessor lost its exact attempt"))?; + validate_memory_semantic_projection_attempt(&attempt)?; + if attempt.status != "succeeded" || !attempt_authenticates_claim(&attempt, claim) { + return Err(anyhow!( + "succeeded semantic predecessor is not authenticated by its exact attempt" + )); + } + Ok(true) +} + fn terminal_or_recovery_cas( store_path: &Path, opening: &[CultCacheEnvelope], diff --git a/epiphany-core/src/memory_graph/semantic_projector_pulse.rs b/epiphany-core/src/memory_graph/semantic_projector_pulse.rs index 7e095303..de7da3f8 100644 --- a/epiphany-core/src/memory_graph/semantic_projector_pulse.rs +++ b/epiphany-core/src/memory_graph/semantic_projector_pulse.rs @@ -6,10 +6,10 @@ use std::sync::atomic::{AtomicBool, Ordering}; pub enum MemorySemanticProjectorPulseClassification { Pending, Failed, + Repair, Ready, Running, RunningOwned { claim_id: String }, - Succeeded, Stale, } @@ -17,11 +17,8 @@ impl MemorySemanticProjectorPulseClassification { fn automatic_purpose(&self) -> Option<&'static str> { match self { Self::Pending | Self::Failed => Some("execute"), - Self::Ready - | Self::Running - | Self::RunningOwned { .. } - | Self::Succeeded - | Self::Stale => None, + Self::Repair => Some("repair"), + Self::Ready | Self::Running | Self::RunningOwned { .. } | Self::Stale => None, } } } @@ -288,7 +285,7 @@ mod tests { Vec>, >, acquire_result: Mutex>>, - acquisitions: Mutex>, + acquisitions: Mutex>, executions: Mutex>, execute_barriers: Option<(Arc, Arc)>, } @@ -322,8 +319,10 @@ mod tests { input: &MemorySemanticProjectionInput, purpose: &str, ) -> Result> { - assert_eq!(purpose, "execute"); - self.acquisitions.lock().unwrap().push(scope_key(input)); + self.acquisitions + .lock() + .unwrap() + .push((scope_key(input), purpose.to_string())); Ok(self.acquire_result.lock().unwrap().take().unwrap_or(None)) } @@ -338,11 +337,10 @@ mod tests { } #[test] - fn decision_table_never_runs_ready_running_succeeded_or_stale() { + fn decision_table_never_runs_ready_running_or_stale() { for classification in [ MemorySemanticProjectorPulseClassification::Ready, MemorySemanticProjectorPulseClassification::Running, - MemorySemanticProjectorPulseClassification::Succeeded, MemorySemanticProjectorPulseClassification::Stale, ] { let pulser = MemorySemanticProjectorPulser::new(MockPort::new(vec![classification])); @@ -353,6 +351,19 @@ mod tests { } } + #[test] + fn repair_classification_acquires_the_typed_repair_path() { + let pulser = MemorySemanticProjectorPulser::new(MockPort::new(vec![ + MemorySemanticProjectorPulseClassification::Repair, + ])); + let outcome = pulser.pulse(&[input("modeling")], None); + assert_eq!(outcome.status, MemorySemanticProjectorPulseStatus::Executed); + assert_eq!( + pulser.port.acquisitions.lock().unwrap().as_slice(), + &[("swarm-a:modeling".to_string(), "repair".to_string())] + ); + } + #[test] fn native_classification_refuses_an_advanced_sealed_input_as_stale() -> Result<()> { let temp = tempdir()?; diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index f5adc191..22857835 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -1260,8 +1260,11 @@ receipts; they merely share one survival body. Every pulse reloads both canonical inputs. It stores no open-obligation queue and allows at most one global action, rotating fairly between actionable -partitions. Ready, foreign-running, succeeded, and stale inputs never execute. -Pending and failed inputs acquire exact Idunn authority before using the one +partitions. Ready, foreign-running, and stale inputs never execute. A succeeded +claim is not itself terminal evidence: valid receipt-v2 health derives Ready, +while an exact authority-authenticated succeeded claim whose receipt is legacy +or invalid derives Repair and acquires the typed Idunn repair path. Pending and +failed inputs acquire exact Idunn execute authority before using the one crate-private executor. A running claim owned by the current provider incarnation resumes directly without minting a second grant; a foreign running claim remains pressure until exact recovery. Overlapping pulses return busy, @@ -2027,6 +2030,34 @@ The installed sibling-generation gate is closed for the current boot. Next: build Mind's whole-repository observed-readiness join. Reboot/logon remains permission-bound. +## Semantic receipt-v2 live migration wound (2026-07-16) + +The first readiness release exposed an honest migration failure. Receipt v2 +correctly made the old v1 Mind/Modeling receipts ineligible, but pulse +classification returned `Succeeded` from claim status before deriving receipt +health. Both partitions therefore stayed idle and packaged queries fell back to +canonical BM25. `Succeeded` is removed as a pulse state. Valid v2 terminal +evidence derives `Ready`; a same-obligation succeeded predecessor with missing, +legacy, or invalid receipt evidence derives `Repair`. + +Repair is not opened by claim shape alone. Classification and acquisition share +one predicate that authenticates the consumed executor grant or recovery +authorization plus the exact succeeded attempt/claim binding. The repair grant +advances the epoch. A failed repair becomes a failed current claim and retries +through the ordinary execute path at the next epoch. Tests cover forged +authority refusal, v1 repair acquisition, failed repair, execute retry, v2 +terminal success, final Ready, and empty-v2 Ready/nonqueryable stability. Soul +approved; the full library suite is 466 passed, 2 intentionally ignored. + +Operational evidence before the fix: release +`sha256-6f9ab4848207a110e7e3836f41e6a74c0f463369ad4b04ce2d0d3831a6b262ae` +from commit `360dcb43` launched witnessed Idunn PID `29476` and direct child +projector PID `22840`, but both packaged semantic queries fell back because the +v1 receipts had no migration path. The next action is to commit this repair, +package/deploy a successor witnessed release, observe v2 semantic ranking, then +derive the first live whole-repository readiness projection. Reboot/logon still +requires explicit live operator approval. + ## Mind whole-repository readiness join (2026-07-16) The missing join now exists in source. `repository_readiness.rs` is Mind's sole diff --git a/notes/memory-graph-semantic-projection-authority-map.md b/notes/memory-graph-semantic-projection-authority-map.md index 44853807..ad40a32c 100644 --- a/notes/memory-graph-semantic-projection-authority-map.md +++ b/notes/memory-graph-semantic-projection-authority-map.md @@ -436,8 +436,11 @@ the canonical locator point id, and payload `pointId` remains the canonical locator identity. Empty synchronization, upsert, observation, deletion, and query therefore address one claim incarnation only. -Success receipts use schema v1 and bind `claim_id` and `claim_epoch`. Legacy -receipts decode with empty/zero defaults but cannot become query eligible. +Success receipts use schema v2 and bind `claim_id`, `claim_epoch`, and the exact +post-scroll vector-binding root. Legacy receipts decode with empty/zero defaults +but cannot become query eligible. An authority-authenticated succeeded claim +with legacy or invalid receipt evidence derives the typed repair posture; claim +status alone never opens repair. Opaque readiness carries the exact successful receipt, and query derives its Qdrant filter only from that receipt. Activation is consequently the CultCache terminal-success CAS selecting an already-observed physical namespace; a diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 8d00136c53a287422eea448ee5fb516ab5953735..d2b9a246e4f6321aa2ff099f5964a0a99233ca7a 100644 GIT binary patch delta 559 zcmY+Azit#U5XRX{LaH<%(WJ;oX%Z=S$*tg!E)7lc03i|*onz14j^wo+d%WCMS44sr z;FK4jARQ6~;stmCI$kAGV3tjUC`SG_pTFOHpKo_=e(!vFR&15iay)%ezWwoN^X~oE z-Quz+eqF5wA6A1xs$18j)}=P29)DX6HlN-;`S`s&DksCEm&5VoeBAwU{p!>D_VVW$ zYNWu!rUZk*`nE>LfQ#T08c+_%VPr^IYea))sI8(}&KHS^Gn02Cc>VASA=`wISTVvo zl^|m68#KqzC`$&!1sgKxG>ToMWrGRMP?=V&3|O2i-5!$byJOGxzob_LMG?HSEpQcm zo>v{J%3KLOX>m9IkRe1N*O-!zu&2FCx$b6@?xl~!Ed-mB%&atnV#Ye~{s>NeoZq+g zT@hzF39lrO63sdrnf_4e%S?&7{V~iGSrJA23mB0jiQ<6~7pSu&qgbvG9KKmd*1_va y0xEmr)P=@5y8B=xU7sze5Mr0)2u=cpO1Ty+T}TPsGyoOe$##SbVQO6kA|FmvaW-Mf6yxBaJseLLFBM^gVW*}w(Vpbq# L+dh?vUHCTuzz`JS diff --git a/state/map.yaml b/state/map.yaml index 42e265a1..2ae1ab80 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -734,4 +734,5 @@ current_status: - The feature-gated native `epiphany-workspace-coverage-recovery-smoke` proves the real packaged supervisor/projector boundary in GUID-scoped repo/runtime/Body/Verse state. It warms local Ollama, derives only its exact fenced Qdrant collection names, publishes reserved policy, launches the initial child through fixed bootstrap, observes epoch 1 claim, kills only after exact native launch-incarnation revalidation, invokes Idunn reconcile, authenticates epoch 2 successor authority plus the immutable recovery receipt through freshly reopened stores, kills the replacement under the same identity fence, and verifies only its owned collections absent before success. Live proof `C:\Users\Meta\AppData\Local\Temp\epiphany-workspace-coverage-a577f820-b0e2-4733-b628-529ee3bdb143\proof.json` passed with receipt `2b44f28f-7c0f-4ad2-aefe-d7c8222e8642` and binds the executed binary, exact embedded smoke source, source head, and tracked-source diff digests. Operator orchestration, not the harness, restored local Qdrant to its prior stopped state. The run also repaired normal-user Windows boot identity and exact recovered-owner claim resumption. - The 2026-07-16 deployability audit replaced `notes/epiphany-swarm-readiness-plan.md`'s obsolete June queue with the live evidence matrix. Brake, initiative recovery, Persona speech eligibility, memory lifecycle, CultNet-first operation, and branch-local Hands/Soul/Mind gates are landed. The installed after-login host is operational and real Mind/Modeling semantic queries pass against Yggdrasil, but it is not yet deployable as one proven machine: installed binaries predate recovery commit `34802407`; mutable sibling lookup permits mixed build generations; Mind lacks the race-bounded whole-repository readiness join; and reboot/logon lineage remains permission-bound. Health, heartbeat, Task Scheduler state, Qdrant existence, legacy retrieval Ready, and Eve/Gjallar rows cannot substitute for either query admission or repository readiness. Sight surfaces no longer publish the foreign constant `queryAdmission=false`; they report only facts they observe. - Release `sha256-c94109f94ee42c1257089830f399cb87cd5ad672772c274194371995ce4df923` is the first deployed immutable sibling generation. Native packaging builds from detached exact source commit `dd80f4a51c18425a6665710698a357be61154abf`, initializes pinned submodules, uses the tracked lockfile under `--locked`, and publishes four exact binaries plus a typed CultCache witness/head only after atomic directory publication and byte verification. Task Scheduler pins release id/digest and the witnessed supervisor path; Idunn reauthenticates the complete set and reserved policy role paths. Current-boot proof: reconciler PID 21228 launched direct child 22736; witnessed Mind/Modeling queries ranked semantically; killing that exact-path child caused Idunn to launch PID 19748 with receipt `86a42d51-9930-4b5d-9e61-e74c82a0d808`, ready heartbeat `4fc91977-b635-474b-812b-c364847e2b4b`, and witnessed executable digest `sha256-1060dd64e8c2b520ec8744b67e8306db04a6618d463fc2117c352adf9e30e6b0`. This closes current-boot artifact generation and recurrence, not reboot/logon survival. - next_action: Implement Mind's repository-readiness join with fresh Body R1/R2, exact Body-grounded RepoModel admission, live Modeling semantic eligibility, and a new live workspace-coverage Qdrant evidence reader over the sealed plan/receipt. Stored coverage `Current` is forbidden as a substitute. Then perform Soul review and update the evidence matrix. Do not run the final reboot/logon proof without explicit live operator approval. + - Release `sha256-6f9ab4848207a110e7e3836f41e6a74c0f463369ad4b04ce2d0d3831a6b262ae` packages repository-readiness source commit `360dcb433dda9599fca14282592608d26b8b6cc8`; witnessed Idunn PID 29476 directly owns witnessed projector PID 22840 with launch receipt `50879209-b65f-4411-ae3f-6f647d37bf42` and ready heartbeat `134df620-9e20-4220-ad4e-117ea4ca8188`. Deployment exposed receipt-v2 migration pressure: v1 receipts became correctly ineligible, but the old Succeeded pulse shortcut kept both partitions idle. The shortcut is now cut in source. Valid v2 terminal evidence derives Ready; an exact same-obligation succeeded claim opens Repair only after its consumed grant/recovery authority and exact succeeded attempt are authenticated. Failed repair retries through execute at the next epoch. Forged predecessor authority cannot be laundered by a repair grant. + next_action: Commit and package the authenticated semantic receipt-v2 repair, deploy the successor witnessed release, prove Mind/Modeling semantic ranking, then derive the first live Mind repository-readiness projection. Also repair Idunn's alive-child reconciliation so policy/release path drift forces typed replacement instead of requiring an operator exact-PID termination. Do not run the final reboot/logon proof without explicit live operator approval.