diff --git a/epiphany-core/src/resident_self.rs b/epiphany-core/src/resident_self.rs index 80976b2f..a55cd976 100644 --- a/epiphany-core/src/resident_self.rs +++ b/epiphany-core/src/resident_self.rs @@ -2992,6 +2992,42 @@ mod tests { } } + fn seed_terminal_worker_archive_scaffolding( + store: &Path, + session_id: &str, + job_id: &str, + result_id: &str, + ) -> Result<()> { + let mut cache = crate::runtime_spine_cache(store)?; + cache.put(job_id, &crate::EpiphanyRuntimeJob { + schema_version: crate::RUNTIME_SPINE_SCHEMA_VERSION.into(), + job_id: job_id.into(), + session_id: session_id.into(), + role: crate::EPIPHANY_IMAGINATION_OWNER_ROLE.into(), + status: crate::EpiphanyRuntimeJobStatus::Completed, + created_at: "2026-07-18T00:00:01Z".into(), + updated_at: "2026-07-18T00:00:03Z".into(), + summary: "Typed Imagination worker completed.".into(), + artifact_refs: Vec::new(), + metadata: BTreeMap::new(), + })?; + cache.put(&format!("runtime-worker-process-{job_id}"), &crate::EpiphanyRuntimeWorkerProcessClaim { + schema_version: crate::RUNTIME_WORKER_PROCESS_CLAIM_SCHEMA_VERSION.into(), + claim_id: format!("runtime-worker-process-{job_id}"), + job_id: job_id.into(), + process_id: 42, + process_creation_token: 43, + process_executable_path: "/fixture/epiphany-role-worker".into(), + activation_token_sha256: "a".repeat(64), + status: "terminal-result".into(), + claimed_at: "2026-07-18T00:00:01Z".into(), + activated_at: Some("2026-07-18T00:00:02Z".into()), + terminal_at: Some("2026-07-18T00:00:03Z".into()), + terminal_authority_id: Some(result_id.into()), + })?; + Ok(()) + } + fn admit_test_model_direction_result( store: &Path, request: &crate::AdmittedModelDirectionConsiderationRequest, @@ -3796,6 +3832,12 @@ mod tests { &result, "job-model-fulfillment", )?; + seed_terminal_worker_archive_scaffolding( + &runtime_store, + "worker-session-model-fulfillment", + "job-model-fulfillment", + &format!("result-{}", "job-model-fulfillment"), + )?; assert_eq!( verify_resident_self_grant_fulfillment( &resident_store, @@ -3860,6 +3902,36 @@ mod tests { )? .is_none() ); + for ack in pending_resident_self_acks(&resident_store)? { + heartbeat_consume_resident_self_ack(&resident_store, &ack.ack_id, 9)?; + } + retain_resident_self_lifecycles(&resident_store, 0, 10)? + .expect("closed model direction lifecycle must retire"); + let companion_before = { + let mut cache = crate::runtime_spine_cache(&runtime_store)?; + cache.pull_all_backing_stores()?; + cache.get::(&result.result_id)? + .expect("model direction companion") + }; + crate::archive_fulfilled_runtime_worker_attempt( + &runtime_store, + "job-model-fulfillment", + &live_resident_self_typed_request_ids(&resident_store)?, + "2026-07-18T00:00:04Z", + )?; + assert_eq!( + crate::runtime_typed_request_fulfillment( + &runtime_store, + crate::RuntimeTypedRequestRef::AdmittedModelDirection(&request.request_id), + )?.expect("archived model direction fulfillment").result_id, + format!("result-{}", "job-model-fulfillment") + ); + let mut cache = crate::runtime_spine_cache(&runtime_store)?; + cache.pull_all_backing_stores()?; + assert_eq!( + cache.get::(&result.result_id)?, + Some(companion_before) + ); Ok(()) } @@ -4054,6 +4126,12 @@ mod tests { &candidate, worker_job_id, )?; + seed_terminal_worker_archive_scaffolding( + &runtime_store, + "worker-session-imagination-fulfillment", + worker_job_id, + &format!("result-{worker_job_id}"), + )?; assert_eq!( verify_resident_self_grant_fulfillment( &resident_store, @@ -4137,6 +4215,31 @@ mod tests { )? .is_none() ); + let candidate_before = { + let mut cache = crate::runtime_spine_cache(&runtime_store)?; + cache.pull_all_backing_stores()?; + cache.get::(&candidate.candidate_id)? + .expect("Imagination candidate companion") + }; + crate::archive_fulfilled_runtime_worker_attempt( + &runtime_store, + worker_job_id, + &live_resident_self_typed_request_ids(&resident_store)?, + "2026-07-18T00:00:04Z", + )?; + assert_eq!( + crate::runtime_typed_request_fulfillment( + &runtime_store, + crate::RuntimeTypedRequestRef::ImaginationConsideration(&request.request_id), + )?.expect("archived Imagination fulfillment").result_id, + format!("result-{worker_job_id}") + ); + let mut cache = crate::runtime_spine_cache(&runtime_store)?; + cache.pull_all_backing_stores()?; + assert_eq!( + cache.get::(&candidate.candidate_id)?, + Some(candidate_before) + ); Ok(()) } diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index 723e4649..7e608636 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -11996,6 +11996,18 @@ fn epiphany_mutation_contracts() -> Vec { "Terminal result and exact process death replace the same claim; absence and age are not terminal authority.", ], ), + mutation_contract( + ARCHIVED_RUNTIME_WORKER_ATTEMPT_TYPE, + ARCHIVED_RUNTIME_WORKER_ATTEMPT_SCHEMA_VERSION, + vec![CultNetDocumentOperation::Snapshot], + CultNetMutationAuthority::ReadOnly, + vec![], + vec![], + vec![ + "Runtime spine atomically replaces one exact terminal typed worker family with this per-attempt tombstone only after resident liveness clears.", + "A terminal-result tombstone preserves authenticated fulfillment identity; it does not own producer semantic companions or Mind admission.", + ], + ), mutation_contract( RUNTIME_REORIENT_WORKER_RESULT_TYPE, RUNTIME_REORIENT_WORKER_RESULT_SCHEMA_VERSION, @@ -20071,8 +20083,44 @@ pub(crate) mod tests { }, ).is_err()); assert!(runtime_worker_launch_request(&store, &job_id)?.is_some()); - let tombstone = archive_failed_runtime_worker_attempt( - &store, &job_id, &BTreeSet::new(), "2026-08-10T20:00:03Z")?; + let current = runtime_current_repo_model(&store)?.expect("current model"); + let (newer_result, _) = repo_model_result_and_review( + &store, + "proposal-result-failed-archive-newer", + "proposal-job-failed-archive-newer", + ¤t, + "proposal-review-failed-archive-newer", + )?; + let newer_token = "failed-archive-newer-token"; + claim_runtime_worker_process( + &store, + &newer_result.job_id, + &process, + &format!("{:x}", Sha256::digest(newer_token.as_bytes())), + "2026-08-10T20:00:03Z", + )?; + activate_runtime_worker_process( + &store, + &newer_result.job_id, + &process, + newer_token, + "2026-08-10T20:00:04Z", + )?; + complete_runtime_job(&store, RuntimeSpineJobResultOptions { + result_id: format!("generic-failure-{}", newer_result.job_id), + job_id: newer_result.job_id.clone(), + completed_at: "2026-08-10T20:00:05Z".into(), + verdict: "failed".into(), + summary: "Newer typed worker attempt failed.".into(), + next_safe_move: "Preserve the newest failed attempt.".into(), + evidence_refs: Vec::new(), artifact_refs: Vec::new(), + })?; + let retained = retain_failed_runtime_worker_attempts( + &store, 1, &BTreeSet::new(), "2026-08-10T20:00:06Z")?; + assert_eq!(retained.len(), 1); + let tombstone = retained[0].clone(); + assert_eq!(tombstone.job_id, job_id); + assert!(runtime_worker_launch_request(&store, &newer_result.job_id)?.is_some()); assert_eq!(tombstone.request_id, request_id); assert_eq!(tombstone.terminal_process_status, "terminal-failure"); assert!(tombstone.retired_envelope_count >= 5); @@ -20081,7 +20129,7 @@ pub(crate) mod tests { assert!(!runtime_typed_request_attempt_exists( &store, RuntimeTypedRequestRef::ProposalModeling(&request_id))?); assert_eq!(archive_failed_runtime_worker_attempt( - &store, &job_id, &BTreeSet::new(), "2026-08-10T20:00:03Z")?, tombstone); + &store, &job_id, &BTreeSet::new(), "2026-08-10T20:00:06Z")?, tombstone); Ok(()) } diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 145732aa..c3fb9d38 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -3347,8 +3347,16 @@ counts, and chained digest. `runtime_typed_request_fulfillment` recognizes that narrow tombstone only when no live launch, claim, or worker result coexists. Thus resident settlement sees the same fulfillment before and after retention. Producer-owned semantic companions and admission receipts are not retirement -cargo. Successful Imagination and admitted-model-direction live proofs remain -required before this cut is packaged. +cargo. + +The all-lane source proof is now closed. Imagination and admitted model +direction each pass through real resident grant settlement, Heartbeat ack +consumption, and lifecycle deletion before worker archival; their candidate or +direction companion remains byte-identical and the tombstone answers the same +fulfillment query. Failed retention enumeration sorts exact terminal claims, +keeps the configured newest attempt, and archives the older eligible family. +The worker job is explicitly distinct from the coordinator's jobless +Continuity session; mixing those authorities is rejected. - Owner: runtime spine owns archival of one immutable outer worker attempt. Resident Self supplies cross-store liveness but cannot delete runtime rows. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 37a09c9f..a408c15b 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -2683,3 +2683,17 @@ liveness refusal, exact live fulfillment before retirement, identical archived fulfillment afterward, and a concurrent unrelated write that defeats the full snapshot CAS without losing either side. Imagination and admitted-direction successful companion preservation plus production enumeration remain open. +## All three successful worker lanes preserve semantic companions — 2026-08-10 + +The existing resident model-direction and feedback-Imagination fulfillment +tests now continue through Heartbeat ack consumption, resident lifecycle +retirement, and exact worker-attempt archival. Both prove archived fulfillment +still resolves while the exact producer-owned +`AdmittedModelDirectionConsiderationResult` or +`ImaginationConsiderationCandidate` remains byte-equal. The fixture initially +placed the worker job in the coordinator's jobless Continuity session and was +correctly rejected as competing authority; the accepted proof uses a distinct +outer-worker session identity. Failed production enumeration also now proves +two terminal attempts retain the newest and archive the older without +resurrection. The archive tombstone is published in the runtime CultNet schema +catalog. Source packaging and copied-state live proof are next. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 748a319a..78ebadf0 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 545ede79..a064013b 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -70,7 +70,7 @@ current_status: yggdrasil_epiphany_service_contract: repaired_in_gamecult_ops_812b427_not_installed resident_physiology: c006_exact_c693aaea_settled_braked_no_active_lease_no_attempt_three_old_processes_stopped 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, semantic logical/physical retention, Persona conversation retention, stable Starfire firewall ownership, completed model-adapter session archival, normal coordinator lifecycle opening/error closure/legacy repair/archival, packaged admitted-model-direction and Imagination fulfilled-before-receipt settlement, and packaged co-resident resident lifecycle retention are accepted live. Proposal Modeling fulfilled-before-receipt plus runtime retention of terminal worker attempts remain open. Historical migrated semantic attempts without recorded physical namespace remain durable and non-retirable. Repository Body observation still performs two authenticated full-tree Git index/manifest passes. Execute-mode workers require a persistent process body. Mutable Starfire bind storage still needs the packaged randomized interruption/read-loop proof before recovered c005 authority may be trusted. One completed Discord consequence remains blocked by the absent Yggdrasil credential. - next_action: Complete and package typed runtime worker-attempt retention. Source now archives failed attempts and admitted successful proposal-Modeling attempts after resident liveness clears; successful tombstones answer the same typed fulfillment query while the admitted model receipt remains producer-owned, and stale full-snapshot races refuse. Next prove successful Imagination and admitted-model-direction archives preserve their producer-owned companions, exercise production enumeration/retention across all three lanes, then package and run copied-state non-resurrection proof plus direct proposal Modeling construction. Keep actual c006 braked. Yggdrasil never builds. + next_action: Package and prove typed runtime worker-attempt retention. Source now covers failed production enumeration plus successful proposal Modeling, Imagination, and admitted-model-direction archives after genuine resident lifecycle closure; fulfillment survives through the tombstone while Mind admission and typed candidate/direction companions remain producer-owned, and stale full-snapshot races refuse. Build once with the persistent Starfire cache, authenticate exact source/24 binaries/witness/no warnings, then run copied-state failed-retry and successful-fulfillment retention proofs plus direct proposal Modeling construction. Keep actual c006 braked. Yggdrasil never builds. active_subgoals: - Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.