From 519574ce0d63ffa8fa813885c6629c664a3ae2e0 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 19 Jul 2026 06:48:24 +0100 Subject: [PATCH] Preserve terminal coverage authority across restarts --- .../workspace_coverage_process_documents.rs | 30 ++++++- .../workspace_coverage_projector_service.rs | 83 ++++++++++-------- notes/fresh-workspace-handoff.md | 26 ++++++ state/ledgers.msgpack | Bin 532171 -> 532605 bytes state/map.yaml | 2 +- 5 files changed, 99 insertions(+), 42 deletions(-) diff --git a/epiphany-core/src/workspace_coverage_process_documents.rs b/epiphany-core/src/workspace_coverage_process_documents.rs index 7a47c3c1..4c9a35e6 100644 --- a/epiphany-core/src/workspace_coverage_process_documents.rs +++ b/epiphany-core/src/workspace_coverage_process_documents.rs @@ -2817,16 +2817,13 @@ pub(crate) fn publish_workspace_coverage_terminal_sight( let terminal = crate::workspace_coverage_projector::authenticate_current_workspace_coverage_terminal_authority_with_store( runtime_store, &coverage.store, )?.ok_or_else(|| anyhow!("owned workspace coverage has no current terminal authority"))?; - if terminal.managed_process_launch_id != launch_id { - bail!("terminal sight launch disagrees with terminal coverage authority"); - } if let Some(existing) = authenticate_current_workspace_coverage_terminal_sight( runtime_store, local_verse_store, runtime_id, trusted_host, )? { - if existing.launch_id == launch_id + if existing.launch_id == terminal.managed_process_launch_id && existing.claim_id == terminal.claim_id && existing.claim_epoch == terminal.claim_epoch && existing.plan_id == terminal.plan_id @@ -2836,6 +2833,9 @@ pub(crate) fn publish_workspace_coverage_terminal_sight( } bail!("current terminal sight disagrees with owned terminal authority"); } + if terminal.managed_process_launch_id != launch_id { + bail!("terminal sight launch disagrees with terminal coverage authority"); + } let opening = coverage.store.pull_all()?; let receipt_env = opening .iter() @@ -3899,6 +3899,28 @@ mod tests { _ => bail!("reopened exact executor did not resume claim"), }; crate::workspace_coverage_projector::commit_workspace_coverage_success(&resumed, observed)?; + let terminal_sight = publish_workspace_coverage_terminal_sight( + &verse, + &runtime, + &reopened, + "local", + &launch.launch_id, + host.entry(), + &provider, + chrono::Utc::now(), + )?; + let historical_sight = publish_workspace_coverage_terminal_sight( + &verse, + &runtime, + &reopened, + "local", + &Uuid::new_v4().to_string(), + host.entry(), + &provider_key(), + chrono::Utc::now(), + )?; + assert_eq!(historical_sight, terminal_sight); + assert_eq!(historical_sight.launch_id, launch.launch_id); assert_eq!(std::fs::read(&body_store)?, body_before); assert!(reopened.store.pull_all()?.iter().all(|entry| !matches!( entry.r#type.as_str(), diff --git a/epiphany-core/src/workspace_coverage_projector_service.rs b/epiphany-core/src/workspace_coverage_projector_service.rs index bbdb1499..06343c95 100644 --- a/epiphany-core/src/workspace_coverage_projector_service.rs +++ b/epiphany-core/src/workspace_coverage_projector_service.rs @@ -220,40 +220,6 @@ impl WorkspaceCoverageProjectorServiceBody { let authority = self.execution_authority.as_ref().ok_or_else(|| { anyhow!("workspace coverage projector has no installed execution authority") })?; - if let Some(directive) = authenticate_workspace_coverage_recovery_directive( - &authority.local_verse_store, - &self.runtime_store, - &authority.runtime_id, - &self.managed_process_launch_id, - &authority.trusted_host, - )? - { - let basis = load_current_runtime_repository_body_basis(&self.runtime_store)?; - if directive.workspace_id != basis.workspace_id - || directive.body_binding_sha256 != basis.body_binding_sha256 - || directive.body_observation_id != basis.observation_id - || directive.body_generation != basis.generation - || directive.manifest_root_sha256 != basis.manifest_root_sha256 - || directive.coverage_store_binding_id - != self.coverage_authority.store_binding.binding_id - || directive.coverage_store_binding_envelope_digest - != self.coverage_authority.store_binding_envelope_sha256 - || directive.coverage_store_file_identity - != self.coverage_authority.store_binding.store_file_identity - || directive.runtime_coverage_route_envelope_digest - != self - .coverage_authority - .runtime_coverage_route_envelope_sha256 - { - bail!("workspace coverage recovery directive disagrees with held authority"); - } - crate::workspace_coverage_projector::recover_workspace_coverage_projection_with_authority( - &self.coverage_authority, &self.runtime_store, &authority.local_verse_store, - &authority.runtime_id, &authority.trusted_host, &directive.old_launch_id, - &directive.replacement_launch_id, &directive.replacement_ready_heartbeat_id, - &directive.old_claim_id, - )?; - } // Retirement is derived from typed Body history and is deliberately // performed before the idle fast path. Qdrant never nominates its own // garbage and incompatible same-name collections stop the pulse. @@ -296,6 +262,43 @@ impl WorkspaceCoverageProjectorServiceBody { fault: None, }); } + // A durable terminal projection outranks process recovery. Its signed + // historical sight remains valid across managed-policy rotation; a new + // daemon observes that fact but does not take ownership of the old + // succeeded claim. Recovery still precedes all nonterminal claim work. + if let Some(directive) = authenticate_workspace_coverage_recovery_directive( + &authority.local_verse_store, + &self.runtime_store, + &authority.runtime_id, + &self.managed_process_launch_id, + &authority.trusted_host, + )? + { + if directive.workspace_id != basis.workspace_id + || directive.body_binding_sha256 != basis.body_binding_sha256 + || directive.body_observation_id != basis.observation_id + || directive.body_generation != basis.generation + || directive.manifest_root_sha256 != basis.manifest_root_sha256 + || directive.coverage_store_binding_id + != self.coverage_authority.store_binding.binding_id + || directive.coverage_store_binding_envelope_digest + != self.coverage_authority.store_binding_envelope_sha256 + || directive.coverage_store_file_identity + != self.coverage_authority.store_binding.store_file_identity + || directive.runtime_coverage_route_envelope_digest + != self + .coverage_authority + .runtime_coverage_route_envelope_sha256 + { + bail!("workspace coverage recovery directive disagrees with held authority"); + } + crate::workspace_coverage_projector::recover_workspace_coverage_projection_with_authority( + &self.coverage_authority, &self.runtime_store, &authority.local_verse_store, + &authority.runtime_id, &authority.trusted_host, &directive.old_launch_id, + &directive.replacement_launch_id, &directive.replacement_ready_heartbeat_id, + &directive.old_claim_id, + )?; + } let body = RepositoryBodyReadSession::open(&self.runtime_store, &basis)?; let prepared = prepare_workspace_coverage_projection( &body, @@ -416,7 +419,7 @@ mod tests { } #[test] - fn recovery_directive_is_consumed_before_normal_projection_work() { + fn terminal_authority_precedes_recovery_and_recovery_precedes_new_work() { let source = include_str!("workspace_coverage_projector_service.rs"); let start = source.find("fn pulse_inner(&mut self)").unwrap(); let tail = &source[start..]; @@ -427,10 +430,16 @@ mod tests { let recovery = body .find("recover_workspace_coverage_projection_with_authority") .unwrap(); - let normal = body + let retirement = body .find("retire_workspace_coverage_collections") .unwrap(); - assert!(directive < recovery && recovery < normal); + let classification = body + .find("classify_current_workspace_coverage") + .unwrap(); + let new_work = body.find("RepositoryBodyReadSession::open").unwrap(); + assert!(retirement < classification); + assert!(classification < directive && directive < recovery); + assert!(recovery < new_work); assert!(!body.contains("authenticate_current_workspace_coverage_claim_sight")); } diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 8fc17991..00dabf46 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -2964,3 +2964,29 @@ creation token, and executable. Exact token and executable substitution still refuse. Focused process-observation and resident-readiness suites pass. Replace the braked, unadmitted `c9e9a352` transaction through Idunn after committing this cut; do not reinterpret the current candidate as deployed. + +Candidate `5e298e637d3470828fec3b26feeaa550a0ad91f9` proved resident readiness and +the installed operator check healthy under the `epiphany` runtime identity, +with all three services stable and the all-scope brake engaged. Idunn still +withheld final admission because workspace coverage had already terminalized +under a historical managed launch, while the restarted projector obeyed a +stale recovery directive before recognizing that durable terminal authority. +It first rejected the new launch as the owner of the old terminal receipt and +then refused to recover the already-succeeded claim. + +Terminal coverage authority belongs to the succeeded claim and its historical +managed launch. A later daemon may authenticate and reuse the immutable signed +terminal sight, but cannot rewrite it or inherit the receipt. Projector pulse +now classifies current terminal coverage and republishes that historical sight +before considering process-recovery pressure; recovery still precedes every +nonterminal acquisition or claim path. The real checkpoint-to-terminal fixture +proves a different later launch receives the original sight byte-for-byte, and +the service ordering proof fixes terminal classification before recovery and +recovery before new Body work. + +Next action: commit and push this successor, revoke exact candidate `5e298e63`, +terminate only Idunn transaction PGID `1485835`, and verify the installed +signal-safe rollback boundary. Then authorize and deploy the exact successor +through Bifrost and Idunn under brake. Require historical terminal-sight reuse, +three stable services, typed resident readiness, signed aggregate health, and +`deployment.env` before beginning the ordinary organizational product loop. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index f3564cf3aa66066c9eeeb211aae4a79993005827..a4094cb197c18634e9814a916e4d9b3607cf4715 100644 GIT binary patch delta 465 zcmYk2zfJ-{5XL=4JVP-|Z=UgXBi+FKUD(}py&|mdHY8*Kp zPlVD0W}?|Ln1YKCD3cN~2;$G^_@!al)yY(Wj7RF=1{;q(%zq7ZF6}B7V(HAwahK3wH>UNc|5>PQ`H^Su!Sp rHu@(gOpLv#!kLjvv=l9I28PTpRPvu#!W$c+ReH=G#*7G3rm21d(14~} delta 65 zcmex+K;iUWg$)vn+=gaWhK5nc7&v5CY*uD0WMq8ZJe8?^Dib3RgJ@ autonomous bounded Imagination proposal, with organization feedback through Persona as additional attributed pressure; explicit Mind adoption -> Hands consequence -> Bifrost release -> Idunn deployment remain separate gates. Prove replay/tamper refusal and that conversation alone grants no Mind, Hands, Persona-speech, release, or deployment authority. No host reboot is authorized." + next_action: "Candidate 5e298e63 is braked and unadmitted on Yggdrasil: readiness is healthy, but the restarted workspace projector obeyed stale recovery pressure before recognizing durable terminal coverage owned by the historical succeeded claim and launch. Commit/push the terminal-authority correction, revoke 5e298e63, terminate only Idunn transaction PGID 1485835, and verify the installed signal-safe rollback leaves no services, current links, active-release.env, or deployment.env. Then Bifrost-authorize and Idunn-deploy the exact successor under brake. Require immutable historical terminal-sight reuse, three stable services, typed resident readiness, signed aggregate health, and final deployment.env before the Starfire-offline ordinary-product rehearsal: persistent Modeling map -> autonomous bounded Imagination proposal, with organization feedback through Persona as additional attributed pressure; explicit Mind adoption -> Hands consequence -> Bifrost release -> Idunn deployment remain separate gates. Prove replay/tamper refusal and that conversation alone grants no Mind, Hands, Persona-speech, release, or deployment authority. No host reboot is authorized."