diff --git a/epiphany-core/src/resident_self.rs b/epiphany-core/src/resident_self.rs index d3d84eb8..46fc0384 100644 --- a/epiphany-core/src/resident_self.rs +++ b/epiphany-core/src/resident_self.rs @@ -3846,10 +3846,23 @@ mod tests { } #[test] - fn feedback_imagination_grant_waits_for_exact_bound_candidate() -> Result<()> { + fn feedback_imagination_grant_settles_only_for_exact_bound_candidate() -> Result<()> { let temp = tempfile::tempdir()?; let resident_store = temp.path().join("resident-self.cc"); let runtime_store = temp.path().join("runtime.cc"); + let coordinator = temp.path().join("epiphany-mvp-coordinator"); + std::fs::write(&coordinator, b"witnessed executable")?; + crate::initialize_runtime_spine( + &runtime_store, + crate::RuntimeSpineInitOptions { + runtime_id: "test-runtime".into(), + display_name: "Imagination fulfillment runtime".into(), + created_at: "2026-07-18T00:00:00Z".into(), + }, + )?; + let mut resident_policy = policy(); + resident_policy.coordinator_bin = coordinator.clone(); + resident_policy.runtime_store = runtime_store.clone(); let runtime = crate::runtime_spine_cache(&runtime_store)?; let mut model = crate::EpiphanyMemoryGraphSnapshot::default(); model.model_revision = 1; @@ -3940,6 +3953,37 @@ mod tests { 2, )? .expect("Imagination consideration grant"); + let prepared = prepare_resident_self_launch(&resident_store, &resident_policy, 3)? + .expect("Imagination consideration preparation"); + let process = LaunchedCoordinator { + process_id: u32::MAX - 12, + process_creation_token: 78, + process_executable_path: coordinator, + }; + claim_resident_self_preparation_as_child( + &resident_store, + &prepared.preparation_id, + &process, + 4, + )?; + let lease = acknowledge_resident_self_launch( + &resident_store, + &prepared.preparation_id, + &process, + 5, + )?; + let session_id = crate::coordinator_run_session_id( + &lease.turn_id, + Some(&lease.launch_digest), + )?; + crate::open_coordinator_run( + &runtime_store, + &session_id, + &lease.turn_id, + Some(&lease.launch_digest), + &format!("Resident coordinator launch {}.", lease.objective_digest), + "1970-01-01T00:00:00.005Z", + )?; assert_eq!( verify_resident_self_grant_fulfillment( &resident_store, @@ -4000,6 +4044,81 @@ mod tests { )?, ResidentSelfGrantFulfillment::Fulfilled ); + assert!(crate::coordinator_run_receipts(&runtime_store)?.is_empty()); + assert_eq!( + settle_resident_self_receipt_free_dead_coordinator( + &resident_store, + &runtime_store, + &lease, + ChildObservation::Missing, + false, + false, + false, + 6, + resident_policy.cooldown_seconds, + )?, + ResidentSelfOutcome::Completed + ); + assert!(load_resident_self_state(&resident_store)?.active_turn.is_none()); + let cache = state_cache(&resident_store)?; + let terminal_grant = cache + .get::(&grant.grant_id)? + .expect("terminal Imagination grant"); + assert_eq!( + terminal_grant.terminal_status.as_deref(), + Some("recovered-fulfilled") + ); + let pressure = cache + .get::("pressure-imagination-fulfillment")? + .expect("consumed Imagination pressure"); + assert_eq!(pressure.status, "consumed"); + assert_eq!( + pressure.consumed_by_grant_id.as_deref(), + Some(grant.grant_id.as_str()) + ); + let settled_bytes = std::fs::read(&resident_store)?; + assert!( + settle_resident_self_receipt_free_dead_coordinator( + &resident_store, + &runtime_store, + &lease, + ChildObservation::Missing, + false, + false, + false, + 8, + resident_policy.cooldown_seconds, + ) + .is_err() + ); + assert_eq!(std::fs::read(&resident_store)?, settled_bytes); + assert!( + heartbeat_issue_resident_self_grant( + &resident_store, + "heartbeat-imagination-must-not-retry", + "action-imagination-must-not-retry", + 7, + )? + .is_none() + ); + for ack in pending_resident_self_acks(&resident_store)? { + heartbeat_consume_resident_self_ack(&resident_store, &ack.ack_id, 9)?; + } + let head = retain_resident_self_lifecycles(&resident_store, 0, 10)? + .expect("closed Imagination lifecycle must retire"); + assert_eq!(head.retired_lifecycle_count, 1); + assert!(resident_self_pressures(&resident_store)?.is_empty()); + assert!(pending_resident_self_grant(&resident_store)?.is_none()); + assert!(pending_resident_self_acks(&resident_store)?.is_empty()); + assert!( + heartbeat_issue_resident_self_grant( + &resident_store, + "heartbeat-imagination-after-retention", + "action-imagination-after-retention", + 11, + )? + .is_none() + ); Ok(()) } diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index a6440a34..a876967e 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -3290,3 +3290,12 @@ replacement grant. Replay had neither retired work nor retry authority. The full-backing fence is therefore accepted; Imagination and proposal Modeling remain independent typed-fulfillment variants, not reasons to reopen retention ownership. + +The Imagination variant now has the same complete source-level proof. Runtime +accepts fulfillment only after the exact request, model basis, deterministic +candidate, launch binding, worker launch hash, and terminal role result agree. +Resident Self then settles the zero-receipt dead coordinator once, terminalizes +the original grant `recovered-fulfilled`, preserves consumed pressure, refuses +replay byte-identically, and permits lifecycle retirement without reopening a +grant. This changes no owner or production mechanism; it closes the missing +variant test. Exact packaged Imagination state remains the next evidence gate. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 6f8457a5..8f41d867 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -2561,3 +2561,20 @@ Imagination candidate chain, including exact request, launch binding, worker launch/result, death recovery, retention, and no-retry proof. Proposal Modeling and runtime retention of terminal worker attempts follow. Actual c006 remains braked and stopped; Yggdrasil never builds. + +## Imagination fulfilled-before-receipt source gate — 2026-08-10 + +The existing Imagination fulfillment test now crosses the complete resident +ownership boundary. It opens a real typed request and lease, proves a candidate +without its exact launch binding remains pending, admits the authenticated +worker launch/binding/result companion, and requires zero coordinator receipts. +Exact missing-child recovery then closes the original grant +`recovered-fulfilled`, preserves its pressure as consumed, refuses replay with +byte-identical resident state, and yields no retry. After Heartbeat consumes the +ack, lifecycle retention removes the exact family and still yields no retry. +Full core tests pass 662 with one intentional ignore; all seven swarm tests pass. + +This is a source verification pass only; `52ee6b53` already contains the generic +runtime and resident behavior, but a fresh exact packaged Imagination state run +is still required for direct binary provenance. Proposal Modeling and terminal +worker-attempt retention follow. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index ca03add1..59d80105 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 8acad651..7b74e1f2 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -36,9 +36,9 @@ invariants: current_status: summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Exact b8138a6b active-child SIGTERM and restart, exact 9f369528 deterministic warm packaging, exact c930f505 cross-container ownership, exact ed15f83a resident lifecycle retention, exact 16c4b19f coordinator receipt and Heartbeat artifact retention, exact cce2b8ac narrow model-generation retention, exact eea15e82 model-turn JSON ingress, exact b1e8c89a semantic unattempted-generation retention, exact 6bc3ec3f semantic physical-epoch retirement, and exact 44230a05 Persona conversation retention are proven. Gamecult-ops 059821f owns Yggdrasil stream retention and exact 6ee08a4 owns stable Starfire Persona-permit firewall ingress. Exact 16c4b19f genuine idle and exact a987d2f7 active cognition completed 900-pulse bounded plateaus. Runtime-owned typed fulfillment is accepted live under exact 6dd9b132. Yggdrasil is the small public crossing body, never the release forge. - latest_phase: Exact pushed 52ee6b53 repairs resident lifecycle retention so its CAS fence covers the complete co-resident backing snapshot while deletion remains limited to exact closed pressure/grant/ack/claim families. Exact release sha256-24a8faee17bc28fa7eca877748cfa14472832881352f251b2d4b4f33db823771 with witness sha256-c1d0f4f1d9a5d0a253eefacf50d1901d2b8de062bcef5e692bda2a6f39d5af48 authenticates 24 binaries with zero warnings; Cargo took 7m06s. A fresh exact packaged run settled an authenticated admitted-model-direction result with zero coordinator receipts as recovered-fulfilled and published provider readiness beside the closed lifecycle. After Heartbeat consumed the ack, a second exact packaged once with retention window zero exited 0 sleeping, retired the full lifecycle despite the co-resident readiness row, left no active authority, and yielded no retry. Receipts are under .epiphany-run/linux-package-52ee6b53 and .epiphany-run/resident-retention-52ee6b53. Actual c006 remains braked and stopped. + latest_phase: Exact pushed 52ee6b53 packages and proves the full-backing resident lifecycle retention fence: release sha256-24a8faee17bc28fa7eca877748cfa14472832881352f251b2d4b4f33db823771, witness sha256-c1d0f4f1d9a5d0a253eefacf50d1901d2b8de062bcef5e692bda2a6f39d5af48, 24 binaries, zero warnings. Packaged admitted-model-direction fulfillment settled recovered-fulfilled with zero coordinator receipts; after readiness publication and Heartbeat ack consumption, packaged zero-window retention exited 0 sleeping, removed the lifecycle, and yielded no retry. The next source pass now proves the Imagination variant across exact request/candidate/launch binding/worker result, zero-receipt death recovery, recovered-fulfilled settlement, byte-identical replay refusal, lifecycle retirement, and no retry before or after retention. Full core 662/1 ignored and swarm 7 pass. Packaged Imagination execution remains open. Actual c006 remains braked and stopped. operational_state: - local_worktree: packaged_retention_fence_accepted_imagination_fulfillment_next + local_worktree: imagination_fulfilled_before_receipt_source_verified_packaged_live_next operator_wireguard: restored starfire_persona_permit_firewall: persistent_exact_gamecult_ops_6ee08a4 yggdrasil: canonical_small_public_crossing_body @@ -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 fulfilled-before-receipt settlement, and packaged co-resident resident lifecycle retention are accepted live. Proposal Modeling and Imagination fulfilled-before-receipt variants 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: Exercise Imagination fulfilled-before-receipt through its exact request, launch binding, worker launch, candidate companion, runtime result, resident death recovery, lifecycle retention, and no-retry proof; then cover proposal Modeling and runtime retention of terminal worker attempts. Keep actual c006 braked. Yggdrasil never builds. + next_action: Exercise the source-verified Imagination fulfilled-before-receipt chain through exact packaged epiphany-swarm on fresh copied state, including lifecycle retention and no retry; then cover proposal Modeling and runtime retention of terminal worker attempts. Keep actual c006 braked. Yggdrasil never builds. active_subgoals: - Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.