diff --git a/epiphany-core/src/resident_self.rs b/epiphany-core/src/resident_self.rs index a55cd976..2549f1d0 100644 --- a/epiphany-core/src/resident_self.rs +++ b/epiphany-core/src/resident_self.rs @@ -3034,6 +3034,8 @@ mod tests { result: &crate::AdmittedModelDirectionConsiderationResult, job_id: &str, ) -> Result<()> { + let model = crate::runtime_current_repo_model(store)? + .ok_or_else(|| anyhow!("model direction fixture lost admitted model"))?; let document = crate::EpiphanyWorkerLaunchDocument::Role(crate::EpiphanyRoleWorkerLaunchDocument { thread_id: request.thread_id.clone(), @@ -3050,7 +3052,7 @@ mod tests { admitted_model_direction_consideration_context: Some( crate::AdmittedModelDirectionConsiderationContextProjection::new( request, - &crate::EpiphanyMemoryGraphSnapshot::default(), + &model, ), ), active_subgoal_id: None, diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index 7e608636..d9bf2b21 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -3956,6 +3956,10 @@ pub fn put_runtime_role_worker_result( .as_deref() != Some(request_id) || projection.map(|projection| &projection.request) != Some(&request) + || projection + .map(|projection| crate::memory_graph_model_hash(&projection.model)) + .transpose()? + != Some(request.model_hash.clone()) { return Err(anyhow!( "model direction result does not exactly bind request and launch" @@ -10571,6 +10575,140 @@ pub fn archive_fulfilled_runtime_worker_attempt( ) } +fn validate_archivable_typed_worker_launch( + cache: &CultCache, + launch: &EpiphanyRuntimeWorkerLaunchRequest, + request_kind: &str, + request_id: &str, +) -> Result<()> { + if launch.schema_version != RUNTIME_WORKER_LAUNCH_REQUEST_SCHEMA_VERSION + || launch.job_id.trim().is_empty() + { + return Err(anyhow!("worker attempt archive found invalid immutable launch")); + } + let document = launch.launch_document()?; + let identity = require_identity(cache)?; + let launch_sha256 = format!("{:x}", Sha256::digest(&launch.launch_document_msgpack)); + match request_kind { + "proposal-modeling" => { + validate_proposal_modeling_launch_carrier( + &launch.role, + &launch.binding_id, + Some(request_id), + &document, + )?; + validate_repository_body_launch_carrier(&launch.role, &document)?; + let request = cache.get::(request_id)? + .ok_or_else(|| anyhow!("archived proposal Modeling launch lost its request"))?; + validate_repo_frontier_proposal_modeling_request(&request)?; + let proposal = cache.get::(&request.proposal_id)? + .ok_or_else(|| anyhow!("archived proposal Modeling launch lost its proposal"))?; + validate_repo_frontier_work_proposal(&proposal)?; + let bindings = cache.get_all::()? + .into_iter().filter(|binding| binding.job_id == launch.job_id).collect::>(); + if bindings.len() != 1 { + return Err(anyhow!("archived proposal Modeling launch requires one binding")); + } + let binding = &bindings[0]; + let projection = match &document { + EpiphanyWorkerLaunchDocument::Role(document) => document.proposal_modeling_context.as_ref(), + EpiphanyWorkerLaunchDocument::Reorient(_) => None, + }.ok_or_else(|| anyhow!("archived proposal Modeling launch lost its context"))?; + if request.runtime_id != identity.runtime_id + || request.proposal_payload_sha256 != proposal.payload_sha256 + || request.repository != proposal.repository + || request.workspace != proposal.workspace + || binding.schema_version != REPO_FRONTIER_PROPOSAL_MODELING_LAUNCH_BINDING_SCHEMA_VERSION + || binding.contract != REPO_FRONTIER_PROPOSAL_MODELING_LAUNCH_BINDING_CONTRACT + || binding.binding_record_id != format!("repo-frontier-proposal-modeling-launch-{}", launch.job_id) + || binding.proposal_modeling_request_id != request.request_id + || binding.proposal_id != proposal.proposal_id + || binding.proposal_payload_sha256 != proposal.payload_sha256 + || binding.binding_id != EPIPHANY_MODELING_ROLE_BINDING_ID + || binding.runtime_id != request.runtime_id + || binding.thread_id != request.thread_id + || binding.worker_launch_document_sha256 != launch_sha256 + || projection.request_id != request.request_id + || projection.proposal_id != proposal.proposal_id + || projection.proposal_payload_sha256 != proposal.payload_sha256 + || projection.runtime_id != request.runtime_id + || projection.thread_id != request.thread_id + || projection.repository != request.repository + || projection.workspace != request.workspace + { + return Err(anyhow!("archived proposal Modeling launch provenance mismatch")); + } + } + "imagination-consideration" => { + validate_imagination_consideration_launch_carrier( + &launch.role, + &launch.binding_id, + Some(request_id), + &document, + )?; + let request = cache.get::(request_id)? + .ok_or_else(|| anyhow!("archived Imagination launch lost its request"))?; + if request.schema_version != crate::IMAGINATION_CONSIDERATION_REQUEST_SCHEMA_VERSION + || request.contract != crate::IMAGINATION_CONSIDERATION_REQUEST_CONTRACT + || request.request_id != request_id + || request.private_state_included + || chrono::DateTime::parse_from_rfc3339(&request.requested_at).is_err() + { + return Err(anyhow!("archived Imagination launch request is invalid")); + } + let bindings = cache.get_all::()? + .into_iter().filter(|binding| binding.job_id == launch.job_id).collect::>(); + if bindings.len() != 1 { + return Err(anyhow!("archived Imagination launch requires one binding")); + } + let binding = &bindings[0]; + let projection = match &document { + EpiphanyWorkerLaunchDocument::Role(document) => document.imagination_consideration_context.as_ref(), + EpiphanyWorkerLaunchDocument::Reorient(_) => None, + }.ok_or_else(|| anyhow!("archived Imagination launch lost its context"))?; + if request.runtime_id != identity.runtime_id + || binding.request_id != request.request_id + || binding.binding_id != EPIPHANY_IMAGINATION_ROLE_BINDING_ID + || binding.runtime_id != request.runtime_id + || binding.thread_id != request.thread_id + || binding.worker_launch_document_sha256 != launch_sha256 + || projection.request != request + || crate::memory_graph_model_hash(&projection.model)? != request.model_hash + { + return Err(anyhow!("archived Imagination launch provenance mismatch")); + } + } + "admitted-model-direction" => { + let request = cache.get::(request_id)? + .ok_or_else(|| anyhow!("archived model-direction launch lost its request"))?; + if request.schema_version + != crate::ADMITTED_MODEL_DIRECTION_CONSIDERATION_REQUEST_SCHEMA_VERSION + || request.contract + != crate::ADMITTED_MODEL_DIRECTION_CONSIDERATION_REQUEST_CONTRACT + || request.request_id != request_id + || request.private_state_included + || chrono::DateTime::parse_from_rfc3339(&request.requested_at).is_err() + { + return Err(anyhow!("archived model-direction launch request is invalid")); + } + let projection = match &document { + EpiphanyWorkerLaunchDocument::Role(document) => document.admitted_model_direction_consideration_context.as_ref(), + EpiphanyWorkerLaunchDocument::Reorient(_) => None, + }.ok_or_else(|| anyhow!("archived model-direction launch lost its context"))?; + if launch.role != EPIPHANY_IMAGINATION_OWNER_ROLE + || launch.binding_id != EPIPHANY_IMAGINATION_ROLE_BINDING_ID + || request.runtime_id != identity.runtime_id + || projection.request != request + || crate::memory_graph_model_hash(&projection.model)? != request.model_hash + { + return Err(anyhow!("archived model-direction launch provenance mismatch")); + } + } + _ => return Err(anyhow!("worker attempt archive found unsupported typed request")), + } + Ok(()) +} + fn archive_runtime_worker_attempt( store_path: impl AsRef, job_id: &str, @@ -10617,6 +10755,7 @@ where return Err(anyhow!("worker attempt archive requires exactly one supported typed request")); } let (request_kind, request_id) = typed[0]; + validate_archivable_typed_worker_launch(&cache, &launch, request_kind, request_id)?; if live_resident_request_ids.contains(request_id) { return Err(anyhow!("worker attempt archive refuses resident-live typed request")); } @@ -20067,6 +20206,18 @@ pub(crate) mod tests { assert!(archive_failed_runtime_worker_attempt(&store, &job_id, &BTreeSet::from([request_id.clone()]), "2026-08-10T20:00:03Z").is_err()); assert_eq!(std::fs::read(&store)?, before); + let mut cache = runtime_spine_cache(&store)?; + cache.pull_all_backing_stores()?; + let binding = cache.get_all::()? + .into_iter().find(|binding| binding.job_id == job_id).expect("proposal launch binding"); + let mut hostile_binding = binding.clone(); + hostile_binding.worker_launch_document_sha256 = "0".repeat(64); + cache.put(&hostile_binding.binding_record_id, &hostile_binding)?; + let hostile_bytes = std::fs::read(&store)?; + assert!(archive_failed_runtime_worker_attempt( + &store, &job_id, &BTreeSet::new(), "2026-08-10T20:00:03Z").is_err()); + assert_eq!(std::fs::read(&store)?, hostile_bytes); + cache.put(&binding.binding_record_id, &binding)?; assert!(archive_runtime_worker_attempt( &store, &job_id, &BTreeSet::new(), "2026-08-10T20:00:03Z", false, || { diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index c3fb9d38..2cbb65e0 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -3358,6 +3358,16 @@ 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. +Before retirement, runtime spine now authenticates the immutable failed launch +with the same lane facts that made it admissible: persisted typed request, +producer proposal where applicable, exact role/binding, runtime and thread, +launch-document digest, and exact typed context projection. Proposal Modeling +also binds repository/workspace/payload and Body-bearing Modeling carrier; +Imagination binds its one launch record and request/model projection; admitted +model direction binds the request/model projection directly. Failed terminal +status is not permission to launder malformed launch state into a tombstone. +Model-direction result admission now checks the same projected model hash. + - Owner: runtime spine owns archival of one immutable outer worker attempt. Resident Self supplies cross-store liveness but cannot delete runtime rows. - Inputs: exact typed request identity; worker launch; lane-specific launch diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index a408c15b..cb39ba1e 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -2697,3 +2697,18 @@ 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. +## Mechanical package rejected; failed archive provenance cut — 2026-08-10 + +Exact `452c250e` mechanically packaged in 7m14s as release +`sha256-e585f91054e3333d6fe7d52912e0338fdd4793f413eaebd9a278eb3836a97d63` +with witness +`sha256-1f3087d589499c73a98fdfb5909850c8c0ae416d7e97d0a20998dfb644f774f0`, +24 binaries, and zero warnings. It is not accepted for runtime proof: inspection +found that failed-attempt archival trusted the typed request echo without +authenticating the persisted request, lane binding, launch hash, role, runtime, +thread, and projected context. Source now validates that immutable chain for +all three lanes before any archive. A hostile proposal binding hash refuses +byte-identically. The stronger check also exposed a model-direction fixture +that projected a default model; the fixture now uses the admitted model and +result admission itself requires the projected model hash. Repackage the new +commit; do not publish or use the 452c release as accepted evidence. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 78ebadf0..c0aaa31a 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index a064013b..a135deb8 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: 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. + next_action: Repackage and prove typed runtime worker-attempt retention after the failed-launch authentication cut. Exact 452c250e mechanically packaged as release sha256-e585f91054e3333d6fe7d52912e0338fdd4793f413eaebd9a278eb3836a97d63 with witness sha256-1f3087d589499c73a98fdfb5909850c8c0ae416d7e97d0a20998dfb644f774f0, 24 binaries and no warnings, but live acceptance stopped because failed archives did not authenticate request/binding/launch provenance. Source now requires exact immutable provenance across proposal Modeling, Imagination, and admitted model direction; model-direction result admission also binds the projected model hash. Run full tests, commit, repackage from a stable source clone path so the persistent cache survives commits, then run copied-state failed-retry and successful-fulfillment proofs plus direct proposal Modeling. Keep actual c006 braked. Yggdrasil never builds. active_subgoals: - Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.