From 8a9439ca2e0dddaec832a5e9285735b4d5a109cd Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 8 Aug 2026 01:19:07 +0100 Subject: [PATCH] Preserve typed request thread in resident launch --- epiphany-core/src/bin/epiphany-swarm.rs | 10 +- epiphany-core/src/resident_self.rs | 170 ++++++++++++++++++---- notes/epiphany-current-algorithmic-map.md | 9 ++ notes/fresh-workspace-handoff.md | 22 ++- state/ledgers.msgpack | Bin 562585 -> 563134 bytes state/map.yaml | 10 +- 6 files changed, 182 insertions(+), 39 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-swarm.rs b/epiphany-core/src/bin/epiphany-swarm.rs index 8250e00a..5fface60 100644 --- a/epiphany-core/src/bin/epiphany-swarm.rs +++ b/epiphany-core/src/bin/epiphany-swarm.rs @@ -12,9 +12,9 @@ use epiphany_core::{ import_bifrost_persona_feedback_deliveries, ingest_resident_self_domain_pressure, load_epiphany_cultmesh_swarm_brake, load_resident_self_state, observe_process_instance, prepare_resident_self_launch, publish_resident_provider_readiness, - resident_coordinator_thread_id, resident_self_child_claim, resident_self_local_provider_status, - terminate_process_instance, validate_persona_feedback_store_separation, - validate_resident_self_store_separation, + resident_prepared_launch_thread_id, resident_self_child_claim, + resident_self_local_provider_status, terminate_process_instance, + validate_persona_feedback_store_separation, validate_resident_self_store_separation, }; use serde_json::json; use std::collections::BTreeMap; @@ -186,7 +186,7 @@ fn cycle( return Ok(ResidentSelfOutcome::Braked); } let launch = CoordinatorLaunch { - turn_id: resident_coordinator_thread_id(&args.policy.release_runtime_id)?, + turn_id: resident_prepared_launch_thread_id(&prepared)?, wake: epiphany_core::ResidentSelfWake::Explicit { objective: prepared.grant.objective.clone(), }, @@ -283,7 +283,7 @@ fn cycle( return Ok(ResidentSelfOutcome::Sleeping); }; let launch = CoordinatorLaunch { - turn_id: resident_coordinator_thread_id(&args.policy.release_runtime_id)?, + turn_id: resident_prepared_launch_thread_id(&prepared)?, wake: epiphany_core::ResidentSelfWake::Explicit { objective: prepared.grant.objective.clone(), }, diff --git a/epiphany-core/src/resident_self.rs b/epiphany-core/src/resident_self.rs index f1c9b469..48636a0a 100644 --- a/epiphany-core/src/resident_self.rs +++ b/epiphany-core/src/resident_self.rs @@ -552,6 +552,65 @@ pub fn resident_coordinator_thread_id(runtime_id: &str) -> Result { Ok(format!("resident-self-thread-{runtime_id}")) } +fn resident_coordinator_binding_for_grant( + policy: &ResidentSelfPolicy, + grant: &ResidentSelfHeartbeatGrant, +) -> Result<(String, Option<(String, String)>)> { + let (prefix, request_flag) = match grant.pressure_kind.as_str() { + "imagination-consideration" => ( + "cultcache://imagination-consideration/", + "--imagination-consideration-request-id", + ), + "admitted-model-direction-consideration" => ( + "cultcache://admitted-model-direction-consideration/", + "--admitted-model-direction-consideration-request-id", + ), + "repo-frontier-proposal-modeling" => ( + "cultcache://repo-frontier-proposal-modeling/", + "--proposal-modeling-request-id", + ), + _ => { + return Ok(( + resident_coordinator_thread_id(&policy.release_runtime_id)?, + None, + )); + } + }; + let request_id = grant + .provenance_ref + .strip_prefix(prefix) + .filter(|value| !value.trim().is_empty()) + .ok_or_else(|| anyhow!("consideration grant lost exact request provenance"))?; + let mut cache = crate::runtime_spine_cache(&policy.runtime_store)?; + cache.pull_all_backing_stores()?; + let (runtime_id, thread_id) = match grant.pressure_kind.as_str() { + "imagination-consideration" => { + let request = cache + .get::(request_id)? + .ok_or_else(|| anyhow!("Imagination consideration request is missing"))?; + (request.runtime_id, request.thread_id) + } + "admitted-model-direction-consideration" => { + let request = cache + .get::(request_id)? + .ok_or_else(|| anyhow!("model direction consideration request is missing"))?; + (request.runtime_id, request.thread_id) + } + _ => { + let request = cache + .get::(request_id)? + .ok_or_else(|| anyhow!("proposal Modeling request is missing"))?; + (request.runtime_id, request.thread_id) + } + }; + if runtime_id != policy.release_runtime_id || thread_id.trim().is_empty() { + return Err(anyhow!( + "resident typed request escaped its runtime or thread authority" + )); + } + Ok((thread_id, Some((request_flag.into(), request_id.into())))) +} + fn prepared_coordinator_thread_id(argv: &[String]) -> Result { let index = argv .iter() @@ -563,6 +622,10 @@ fn prepared_coordinator_thread_id(argv: &[String]) -> Result { .ok_or_else(|| anyhow!("prepared coordinator argv has empty thread identity")) } +pub fn resident_prepared_launch_thread_id(prepared: &ResidentSelfPreparedLaunch) -> Result { + prepared_coordinator_thread_id(&prepared.argv) +} + #[cfg(test)] fn reconcile_resident_self( state: &mut ResidentSelfState, @@ -1069,36 +1132,12 @@ pub fn prepare_resident_self_launch( let Some(mut grant) = pending_resident_self_grant(path)? else { return Ok(None); }; - let turn_id = resident_coordinator_thread_id(&policy.release_runtime_id)?; + let (turn_id, typed_request) = resident_coordinator_binding_for_grant(policy, &grant)?; let wake = ResidentSelfWake::Explicit { objective: grant.objective.clone(), }; let mut argv = coordinator_argv(policy, &turn_id, &wake); - if matches!( - grant.pressure_kind.as_str(), - "imagination-consideration" - | "admitted-model-direction-consideration" - | "repo-frontier-proposal-modeling" - ) { - let (prefix, request_flag) = match grant.pressure_kind.as_str() { - "imagination-consideration" => ( - "cultcache://imagination-consideration/", - "--imagination-consideration-request-id", - ), - "admitted-model-direction-consideration" => ( - "cultcache://admitted-model-direction-consideration/", - "--admitted-model-direction-consideration-request-id", - ), - _ => ( - "cultcache://repo-frontier-proposal-modeling/", - "--proposal-modeling-request-id", - ), - }; - let request_id = grant - .provenance_ref - .strip_prefix(prefix) - .filter(|value| !value.trim().is_empty()) - .ok_or_else(|| anyhow!("consideration grant lost exact request provenance"))?; + if let Some((request_flag, request_id)) = typed_request { let objective = argv.pop(); let flag = argv.pop(); if objective.is_none() || flag.as_deref() != Some("--objective") { @@ -1106,7 +1145,7 @@ pub fn prepare_resident_self_launch( "consideration launch could not remove objective carrier" )); } - argv.extend([request_flag.into(), request_id.into()]); + argv.extend([request_flag, request_id]); } let executable = std::fs::read(&policy.coordinator_bin) .with_context(|| format!("failed to hash {}", policy.coordinator_bin.display()))?; @@ -1724,6 +1763,54 @@ mod tests { release_witness_sha256: "sha256:test-manifest".into(), } } + fn seed_model_direction_request( + store: &Path, + request_id: &str, + runtime_id: &str, + thread_id: &str, + ) -> Result<()> { + let cache = crate::runtime_spine_cache(store)?; + let request = crate::AdmittedModelDirectionConsiderationRequest { + schema_version: crate::ADMITTED_MODEL_DIRECTION_CONSIDERATION_REQUEST_SCHEMA_VERSION + .into(), + request_id: request_id.into(), + runtime_id: runtime_id.into(), + thread_id: thread_id.into(), + model_revision: 1, + model_hash: "sha256:model-1".into(), + model_admission_receipt_id: "model-admission-1".into(), + previous_terminal_result_id: None, + requested_at: "2026-07-18T00:00:00Z".into(), + contract: crate::ADMITTED_MODEL_DIRECTION_CONSIDERATION_REQUEST_CONTRACT.into(), + private_state_included: false, + }; + let (entry, _) = cache.prepare_entry(request_id, &request)?; + SingleFileMessagePackBackingStore::new(store).push(&entry)?; + Ok(()) + } + fn seed_proposal_modeling_request( + store: &Path, + request_id: &str, + runtime_id: &str, + thread_id: &str, + ) -> Result<()> { + let cache = crate::runtime_spine_cache(store)?; + let request = crate::RepoFrontierProposalModelingRequest { + schema_version: crate::REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_SCHEMA_VERSION.into(), + request_id: request_id.into(), + proposal_id: "proposal-1".into(), + proposal_payload_sha256: "sha256:proposal-1".into(), + runtime_id: runtime_id.into(), + thread_id: thread_id.into(), + repository: "GameCult/Epiphany".into(), + workspace: absolute("workspace").display().to_string(), + selected_at: "2026-07-18T00:00:00Z".into(), + contract: crate::REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_CONTRACT.into(), + }; + let (entry, _) = cache.prepare_entry(request_id, &request)?; + SingleFileMessagePackBackingStore::new(store).push(&entry)?; + Ok(()) + } fn explicit() -> Option { Some(ResidentSelfWake::Explicit { objective: "inspect".into(), @@ -1830,6 +1917,13 @@ mod tests { std::fs::write(&coordinator, b"witnessed executable")?; let mut policy = policy(); policy.coordinator_bin = coordinator.clone(); + policy.runtime_store = temp.path().join("runtime.cc"); + seed_model_direction_request( + &policy.runtime_store, + "request-model-1", + &policy.release_runtime_id, + "implementation-thread-1", + )?; let pressure = ResidentSelfPressure { schema_version: RESIDENT_SELF_PRESSURE_SCHEMA_VERSION.into(), pressure_id: "pressure-body-1".into(), @@ -1856,6 +1950,10 @@ mod tests { "--admitted-model-direction-consideration-request-id", "request-model-1" ])); + assert_eq!( + resident_prepared_launch_thread_id(&prepared)?, + "implementation-thread-1" + ); assert!(prepare_resident_self_launch(&store, &policy, 5)?.is_none()); let process = LaunchedCoordinator { process_id: 44, @@ -1915,6 +2013,13 @@ mod tests { std::fs::write(&coordinator, b"witnessed executable")?; let mut policy = policy(); policy.coordinator_bin = coordinator.clone(); + policy.runtime_store = temp.path().join("runtime.cc"); + seed_model_direction_request( + &policy.runtime_store, + "request-retry-1", + &policy.release_runtime_id, + "implementation-thread-retry", + )?; enqueue_resident_self_pressure( &store, &ResidentSelfPressure { @@ -1973,6 +2078,13 @@ mod tests { std::fs::write(&coordinator, b"witnessed executable")?; let mut policy = policy(); policy.coordinator_bin = coordinator; + policy.runtime_store = temp.path().join("runtime.cc"); + seed_proposal_modeling_request( + &policy.runtime_store, + "selection-1", + &policy.release_runtime_id, + "implementation-thread-proposal", + )?; enqueue_resident_self_pressure( &store, &ResidentSelfPressure { @@ -1998,6 +2110,10 @@ mod tests { .windows(2) .any(|pair| { pair == ["--proposal-modeling-request-id", "selection-1"] }) ); + assert_eq!( + resident_prepared_launch_thread_id(&prepared)?, + "implementation-thread-proposal" + ); Ok(()) } diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 15f7f343..cd28c444 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -1257,6 +1257,15 @@ failed turn and schedules the replacement within the same physiological action. Concurrent issuers still derive the same next ordinal and contend on the one pending-pressure CAS, so attempt identity does not weaken single consumption. +Typed pressure does not own a new coordinator thread. Imagination +consideration, admitted-model direction consideration, and autonomous proposal +Modeling requests each carry the implementation thread that owns their causal +state. Resident preparation reloads that exact request from the runtime store, +verifies its runtime identity, and binds its thread into the coordinator argv. +The prepared argv is then the single source for child launch and lease thread +identity. Only plain operator objectives use the resident runtime thread. +`epiphany-swarm` no longer reconstructs a fixed thread after preparation. + ## Exact release build cache ownership Release construction has two serialized cache authorities. The graph cache is diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index b83e5e81..74cf7449 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -59,10 +59,28 @@ The retry test now uses the same heartbeat schedule/action and proves attempt 2 receives a distinct grant while retaining the same pressure authority. All 16 resident-Self tests pass. +Exact pushed `d4b446ab` packages as +`sha256-d31ab4329dd34d93e101fa3a783373b6b1f3bc311fac057c6f0d0b4ce5911122` +with witness +`sha256-d5256ee2181dcacc3da87c8f491a12c359a0bde6139a362d40053d453acac4b8`. +The v34 live timeline proved the deliberate failure, cancellation, attempt-2 +grant, and replacement launch. Running the replacement under persistent +`epiphany-swarm serve` reached coordinator validation, which correctly refused +`model direction consideration provenance mismatch`: resident preparation had +substituted fixed thread `resident-self-thread-epiphany-starfire` for the +implementation thread owned by the typed direction request. + +The current worktree reloads typed direction, Imagination-consideration, and +proposal-Modeling requests during preparation and carries their exact runtime +and thread identity through argv, child launch, and lease. Plain operator +pressure alone retains the fixed resident thread. All 16 resident-Self tests and +both packaged swarm tests pass; typed launch tests assert the request-owned +thread. + ## Next action -1. Commit, push, package, and authenticate attempt-qualified retry grants. -2. Preserve v31 through v33 as failure evidence; clone the recovered boundary +1. Commit, push, package, and authenticate request-owned resident threads. +2. Preserve v31 through v34 as failure evidence; clone the recovered boundary into a new replay runtime using an approved `.epiphany-dogfood` artifact root. 3. Re-run heartbeat selection and resident launch, including exact retry after one deliberate failed launch. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 621f8e940af5d40b453d2a3d9762290699dccc07..67e3650f9b1ba9c2084268510fc4be4d3852e71f 100644 GIT binary patch delta 567 zcmZvYv2GMG5Qf#Mxyjt#u~W51G)k`kRT7tqUlTp-1oRFnSn7%M`OdnYpE||FlS}tcBb)S)6o5 z3Cxt1mOxgiIB-m6=rf&mltu3fqdJ(@3DsMHLOj!{KBCP~)a>a!Glrhn%^YRmE{IzY z3|Tl?{q<>(x!gKYe28?fOt;w0TR@)onpo?+-3L*?_j(}A^bTV1E6}W5fS5|)Y9gu4 ntVu(cb#$@xU-!FToBHvylJ+s=Gvoy{njx=1)NO`@IUn5uj5f|H delta 65 zcmdnDUTNlPr415{)89|#U}cLs#=tS9Y_l?BAtR$f^HiqxsZ5MO45FEVm<5PgftU@5 M*|$$+;$WE!0N^nci~s-t diff --git a/state/map.yaml b/state/map.yaml index 30e99e25..aa23b7ba 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -34,15 +34,15 @@ invariants: - Evidence and git retain history; this map retains only state that changes future decisions. current_status: - summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Exact c5f99c46 packages 21 independently authenticated binaries as sha256-04a4854a1268139e42c028503460bb75d5b4c97b28c7fafcfb963ad1210c0090 with witness sha256-615b3878473d65c67998614e1f6e33cec2bb5ea08a985210ff1c2161c1a481a5. v33 proved cancellation returns failed pressure to heartbeat, then exposed a second retry identity defect: reconciliation can grant within the same schedule/action, so the immutable original grant collided with the retry. The current worktree adds a pressure-local attempt ordinal to grant identity and passes all 16 resident-Self tests, including same-action attempt 2. Exact packaging and live retry remain required before resuming the implementation chain. Persona consequence, retention, endurance, and Linux/Yggdrasil cognition remain open. + summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Exact d4b446ab packages 21 independently authenticated binaries as sha256-d31ab4329dd34d93e101fa3a783373b6b1f3bc311fac057c6f0d0b4ce5911122 with witness sha256-d5256ee2181dcacc3da87c8f491a12c359a0bde6139a362d40053d453acac4b8. v34 proved deliberate resident failure, cancellation, attempt-2 grant, and replacement launch. Persistent serve then exposed that preparation substituted a fixed resident thread for the typed direction request's implementation thread; coordinator validation correctly refused the mismatch. The current worktree makes typed request runtime/thread authority own preparation, child launch, and lease identity. All 16 resident-Self tests and both swarm binary tests pass. Exact packaging and live continuation remain required. Persona consequence, retention, endurance, and Linux/Yggdrasil cognition remain open. operational_state: - local_worktree: attempt_qualified_resident_retry_verified_pending_commit + local_worktree: request_owned_resident_thread_verified_pending_commit operator_wireguard: restored yggdrasil: canonical_small_public_crossing_body starfire: temporary_epiphany_cognition_body starfire_runtime_identity: epiphany-starfire starfire_swarm_brake: released - starfire_release: authenticated_c5f99c46_cancellation_retry; attempt_identity_successor_pending + starfire_release: authenticated_d4b446ab_attempt_retry; request_thread_successor_pending starfire_repository_body: bound_and_observed starfire_verse_topology: bound_to_current_repository_body starfire_native_status: supervised_shakedown_active @@ -52,8 +52,8 @@ current_status: bifrost_feedback_crossing: authenticated_transport_only yggdrasil_epiphany_services: absent resident_physiology: heartbeat_and_self_running - unresolved_authority: v31's generic user proposal produced a lawful direct Hands gate, but the active objective requires the autonomous Imagination-origin path and dedicated Mind adoption, so that gate remains inert. v32 proved producer replay; v33 proved cancellation returns exact pressure, then falsified same-action retry because grant identity lacked attempt lineage. The attempt-qualified repair is locally verified but not yet packaged or proven live. Canonical Imagination, dedicated Mind adoption, exact Hands binding, deliberate worker failure/restart/closure, Persona consequence, retention, endurance, and Linux/Yggdrasil cognition remain open. - next_action: Commit and package attempt-qualified retry grants, preserve v31-v33 as failure evidence, and prove heartbeat issues same-action attempt 2 into an approved dogfood artifact root. Then continue the autonomous Imagination-to-Modeling-to-Mind-to-Hands chain and deliberate failure/restart/Soul closure. + unresolved_authority: v31's generic user proposal produced a lawful direct Hands gate, but the active objective requires the autonomous Imagination-origin path and dedicated Mind adoption, so that gate remains inert. v32 proved producer replay; v33 proved cancellation requeue; v34 proved attempt-qualified retry and then falsified fixed resident thread substitution against the typed request. The request-owned thread repair is locally verified but not yet packaged or proven live. Canonical Imagination, dedicated Mind adoption, exact Hands binding, bounded-worker failure/restart/closure, Persona consequence, retention, endurance, and Linux/Yggdrasil cognition remain open. + next_action: Commit and package request-owned resident threads, preserve v31-v34 as failure evidence, and prove the retried direction request reaches Imagination on its exact implementation thread. Then continue autonomous proposal Modeling, canonical Imagination, dedicated Mind, Hands, and bounded-worker failure/restart/Soul closure. active_subgoals: - Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.