From 3491d620be395572a5066d2df8000aedacd8d9f8 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 8 Aug 2026 13:41:01 +0100 Subject: [PATCH] Bind Modeling context to newest accepted boundary --- .../src/bin/epiphany-mvp-coordinator.rs | 27 ++++-- .../src/coordinator_launch_context.rs | 86 ++++++++++++++++--- epiphany-core/src/lib.rs | 1 + notes/epiphany-current-algorithmic-map.md | 31 +++++++ notes/fresh-workspace-handoff.md | 30 +++++-- state/map.yaml | 6 +- 6 files changed, 150 insertions(+), 31 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs index e391710f..8f61d531 100644 --- a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs +++ b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs @@ -1407,12 +1407,23 @@ fn launch_role( .ok_or_else(|| anyhow!("cannot launch role without native coordinator state"))?; let role = parse_role_id(role_id)?; let expected_revision = expected_revision.and_then(|value| u64::try_from(value).ok()); - let mut context = epiphany_core::render_launch_dynamic_prompt_context( - runtime_store, - local_verse_store, - &state, - epiphany_core::role_launch_context_focus(&state, epiphany_core::epiphany_role_label(role)), - ) + let focus = + epiphany_core::role_launch_context_focus(&state, epiphany_core::epiphany_role_label(role)); + let mut context = if role == epiphany_core::EpiphanyRoleResultRoleId::Modeling { + epiphany_core::render_modeling_launch_dynamic_prompt_context( + runtime_store, + local_verse_store, + &state, + focus, + ) + } else { + epiphany_core::render_launch_dynamic_prompt_context( + runtime_store, + local_verse_store, + &state, + focus, + ) + } .map_err(anyhow::Error::msg)?; if role == epiphany_core::EpiphanyRoleResultRoleId::Verification { context = epiphany_core::append_verification_hands_receipt_context( @@ -1422,8 +1433,6 @@ fn launch_role( ) .map_err(anyhow::Error::msg)?; } else if role == epiphany_core::EpiphanyRoleResultRoleId::Modeling { - context = epiphany_core::append_modeling_repo_model_shape_context(context, runtime_store) - .map_err(anyhow::Error::msg)?; context = epiphany_core::append_modeling_work_loop_telemetry_context( context, runtime_store, @@ -2360,6 +2369,7 @@ mod tests { let native_roles = &source[start..end]; for required in [ "render_launch_dynamic_prompt_context", + "render_modeling_launch_dynamic_prompt_context", "append_verification_hands_receipt_context", "append_modeling_work_loop_telemetry_context", ".launch_job(", @@ -2370,6 +2380,7 @@ mod tests { "missing native role seam {required:?}" ); } + assert!(!native_roles.contains("append_modeling_repo_model_shape_context(")); assert!(!native_roles.contains("AppServerClient")); assert!(!native_roles.contains("thread/epiphany/")); } diff --git a/epiphany-core/src/coordinator_launch_context.rs b/epiphany-core/src/coordinator_launch_context.rs index 36a92fac..bf89d8b2 100644 --- a/epiphany-core/src/coordinator_launch_context.rs +++ b/epiphany-core/src/coordinator_launch_context.rs @@ -3,6 +3,7 @@ use crate::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION; use crate::EpiphanyCultMeshWorkLoopTelemetryEntry; use crate::EpiphanyMemoryContextPacket; use crate::EpiphanyMemoryContextQuery; +use crate::EpiphanyMemoryGraphSnapshot; use crate::EpiphanyMemoryProfile; use crate::EpiphanyPromptContextInput; use crate::RuntimeHandsReceiptChainSummary; @@ -72,6 +73,38 @@ pub fn render_launch_dynamic_prompt_context( state: &EpiphanyThreadState, focus: String, ) -> Result { + render_launch_dynamic_prompt_context_with_snapshot( + runtime_store_path, + local_verse_store, + state, + focus, + ) + .map(|(context, _)| context) +} + +pub fn render_modeling_launch_dynamic_prompt_context( + runtime_store_path: &Path, + local_verse_store: &Path, + state: &EpiphanyThreadState, + focus: String, +) -> Result { + let (context, snapshot) = render_launch_dynamic_prompt_context_with_snapshot( + runtime_store_path, + local_verse_store, + state, + focus, + )?; + Ok(append_modeling_repo_model_shape_snapshot( + context, &snapshot, + )) +} + +fn render_launch_dynamic_prompt_context_with_snapshot( + runtime_store_path: &Path, + local_verse_store: &Path, + state: &EpiphanyThreadState, + focus: String, +) -> Result<(String, EpiphanyMemoryGraphSnapshot), String> { load_epiphany_cultmesh_status(local_verse_store, EPIPHANY_LOCAL_VERSE_RUNTIME_ID) .map_err(|error| { format!( @@ -107,19 +140,20 @@ pub fn render_launch_dynamic_prompt_context( local_verse_store.display() ) })?; - let memory_context = + let (memory_context, snapshot) = launch_memory_context(runtime_store_path, state, focus.as_str()).map_err(|error| { format!( "failed to build launch memory context beside {}: {error}", runtime_store_path.display() ) })?; - Ok(render_epiphany_prompt_context( - &EpiphanyPromptContextInput { + Ok(( + render_epiphany_prompt_context(&EpiphanyPromptContextInput { focus, local_verse, memory_context, - }, + }), + snapshot, )) } @@ -446,7 +480,7 @@ pub fn has_complete_hands_consequence_after_latest_accepted_boundary( } pub fn append_modeling_repo_model_shape_context( - mut context: String, + context: String, runtime_store_path: &Path, ) -> Result { let snapshot = crate::runtime_current_repo_model(runtime_store_path) @@ -457,6 +491,15 @@ pub fn append_modeling_repo_model_shape_context( runtime_store_path.display() ) })?; + Ok(append_modeling_repo_model_shape_snapshot( + context, &snapshot, + )) +} + +fn append_modeling_repo_model_shape_snapshot( + mut context: String, + snapshot: &EpiphanyMemoryGraphSnapshot, +) -> String { context.push_str("\n\n\n"); context.push_str(&format!( "modelRevision: {}\nmodelHash: {}\n", @@ -492,7 +535,7 @@ pub fn append_modeling_repo_model_shape_context( } context.push_str("New nodes must reference one exact existing domain id. Every unresolved frontier item must target at least one exact existing claim id from existingClaims, or a claim id created by the same patch. Every frontier source_scope must be non-empty and contain safe relative paths in strict lexicographic ascending order with no duplicates; proposal scope hints are evidence to normalize into that canonical order, not an instruction to preserve unsafe or unsorted serialization. A proposal Evolution upsert must use status active: Mind acceptance is the admission decision, and proposed state is not routeable by Self. Its recommended_next_organ must be exactly one routeable canonical value with exact case: Hands, Eyes, or Imagination; lowercase labels are dead documents and Mind will refuse them. Use upsert_frontier only for a genuinely new frontier id not listed in existingFrontier. Use revise_frontier when changing an id listed in existingFrontier; an existing frontier id cannot be upserted again. RepoArchitecture and RepoDataflow nodes/edges may use only observed, proposed, accepted, stale, or retired lifecycle. Prefer accepted for a source-grounded current claim. Do not invent a domain because RepoModel patches have no domain mutation operation.\n"); context.push_str(""); - Ok(context) + context } fn debug_variant_snake_case(value: impl std::fmt::Debug) -> String { @@ -516,7 +559,7 @@ pub fn append_modeling_work_loop_telemetry_context( if proposal_modeling_request_id.is_some() { return Ok(context); } - if accepted_research_is_newer_than_modeling(state) { + if accepted_research_is_newest_unmodeled_boundary(state) { context.push_str("\n\n\n"); context.push_str("The current Modeling turn is caused by accepted Eyes evidence newer than the last accepted Modeling boundary. Use the accepted Research finding already present in coordinator context to update the body model. This is not a historical Soul-verdict incorporation turn; do not substitute an older frontier verification route.\n"); context.push_str(""); @@ -644,7 +687,7 @@ pub fn append_modeling_work_loop_telemetry_context( Ok(context) } -fn accepted_research_is_newer_than_modeling(state: &EpiphanyThreadState) -> bool { +fn accepted_research_is_newest_unmodeled_boundary(state: &EpiphanyThreadState) -> bool { let latest_accepted_at = |role_id: &str| { state .acceptance_receipts @@ -661,6 +704,8 @@ fn accepted_research_is_newer_than_modeling(state: &EpiphanyThreadState) -> bool return false; }; latest_accepted_at("modeling").is_none_or(|modeling_at| research_at > modeling_at) + && latest_accepted_at("verification") + .is_none_or(|verification_at| research_at > verification_at) } fn latest_unique_accepted_verification( @@ -1053,7 +1098,7 @@ fn launch_memory_context( runtime_store_path: &Path, state: &EpiphanyThreadState, focus: &str, -) -> Result { +) -> Result<(EpiphanyMemoryContextPacket, EpiphanyMemoryGraphSnapshot), String> { let memory_graph_store = memory_graph_store_path(runtime_store_path); let repo_root = runtime_store_path .parent() @@ -1098,7 +1143,7 @@ fn launch_memory_context( "Memory graph context is empty for this launch focus; the accepted repo graph may be thin or stale.".to_string(), ); } - Ok(packet) + Ok((packet, snapshot)) } #[cfg(test)] @@ -1429,7 +1474,7 @@ mod tests { ..Default::default() }; - let packet = launch_memory_context( + let (packet, _) = launch_memory_context( &runtime_store, &newer_thread_state, "irrelevant weather bananas", @@ -1448,6 +1493,10 @@ mod tests { assert_eq!(preserved.frontier, snapshot.frontier); let shape = append_modeling_repo_model_shape_context("base".to_string(), &runtime_store) .map_err(anyhow::Error::msg)?; + assert_eq!( + shape, + append_modeling_repo_model_shape_snapshot("base".to_string(), &preserved) + ); assert!(shape.contains("")); assert!(shape.contains("id=repo")); assert!(shape.contains("existingClaims:")); @@ -1676,6 +1725,9 @@ mod tests { ], ..Default::default() }; + assert!(accepted_research_is_newest_unmodeled_boundary( + &eyes_handoff + )); let context = append_modeling_work_loop_telemetry_context( "eyes".to_string(), missing_store, @@ -1685,6 +1737,18 @@ mod tests { .expect("accepted Eyes handoff must not bind an older Soul route"); assert!(context.contains("accepted_eyes_modeling_handoff")); assert!(context.contains("not a historical Soul-verdict incorporation turn")); + + let soul_handoff = EpiphanyThreadState { + acceptance_receipts: vec![ + accepted("modeling", "2026-07-13T08:00:00Z"), + accepted("research", "2026-07-13T09:00:00Z"), + accepted("verification", "2026-07-13T10:00:00Z"), + ], + ..Default::default() + }; + assert!(!accepted_research_is_newest_unmodeled_boundary( + &soul_handoff + )); } #[test] diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index dabe607a..5183e461 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -220,6 +220,7 @@ pub use coordinator_launch_context::has_complete_hands_consequence_after_latest_ pub use coordinator_launch_context::local_verse_store_path; pub use coordinator_launch_context::memory_graph_store_path; pub use coordinator_launch_context::render_launch_dynamic_prompt_context; +pub use coordinator_launch_context::render_modeling_launch_dynamic_prompt_context; pub use coordinator_launch_context::reorient_launch_context_focus; pub use coordinator_launch_context::role_launch_context_focus; pub use coordinator_objective_intake::USER_OBJECTIVE_INTAKE_CONTRACT; diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 5a5f6b2c..75ae4dc3 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -1533,3 +1533,34 @@ all 21 binaries. Release incremental compilation and `rust-lld` therefore have separate measurable hypotheses; an authority-based core crate split remains the larger structural option if those two changes do not materially reduce edits to the current monolith. + +Exact `6f3cdc61` sharpened the remaining ownership defect. The stable source and +graph caches were active and third-party dependencies stayed warm, yet one core +schema/routing change rebuilt the four first-party libraries and all 21 root +release binaries in 6m59s. The root `epiphany-release-bundle` is one Cargo +package whose package-wide dependency list includes `epiphany-core` and every +adapter/runtime crate; 19 of its 21 binary sources directly import +`epiphany_core`. A changed core artifact therefore invalidates almost the whole +release bundle even when the changed authority belongs only to coordinator +routing. + +The intended split follows authority rather than file size. Stable coordinator +state/view contracts must live below a volatile Self policy leaf. Runtime-spine +persistence, Persona/transport, repository observation, and release tooling +must not depend on that leaf. Only status/coordinator consumers should relink +when Self policy changes. Removing the root mega-package eventually requires +the release packager to build and witness binaries from their owning packages; +the witness remains the cross-package release authority. A compatibility +re-export from `epiphany-core` would preserve the invalidation edge and is not a +completed split. + +Launch latency is a separate whole-store-read wound. The live runtime store was +about 40 MiB, and post-Soul Modeling launch took roughly 50-90 seconds before +the detached model process appeared. `launch_role` currently reads coordinator +state, assembles memory context, reloads RepoModel shape, commits/reloads the +Soul-to-Modeling request and route, reads telemetry, writes telemetry, and then +commits the job through path-based helpers. Each helper may independently +construct and pull the append-only CultCache store. The next launch-path cut is +one transaction-scoped typed read view plus explicit write boundaries, with +phase timings at the same owner seams. A cache wrapper that leaves repeated +whole-store pulls authoritative would merely hide the smell. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 434db68d..ee3e3fb3 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -12,8 +12,8 @@ machine at its present memory budget. - Thread: `shakedown-v49-hands-relinquishment-r1` - Current release: `sha256-d2e7205a2b714c89892ba623b26c3cc4c98ac6b4f54dfb9a0a2a623f0d92402d` - Release witness: `sha256-399d952e5944450775516e612d447be8b2a106e83399f35e2fb6ffb166d17876` -- Thread-state revision: `34` -- Current action: Modeling retry job `07cdae28-8f11-4cba-a19a-b847d2a4792c` is running with a 600-second budget under PID `17784`. +- Thread-state revision: `36` +- Current action: causal Modeling job `9d7cd7d8-2d43-4165-b3c5-54381126579e` is running with a 600-second budget under PID `29792`. - Sealed evidence: v49 through v52. Do not mutate them. ## Live causal boundary @@ -53,18 +53,30 @@ projections above as authoritative evidence. ## Next action The first post-Soul Modeling job `8851bbcc-d013-4e5a-95bf-d69b4833dc29` -timed out at its 300-second boundary and was reviewed/superseded at revision 33. -Poll retry job `07cdae28-8f11-4cba-a19a-b847d2a4792c` only through an -operator-safe coordinator projection. Accept its first valid result, then -inspect Self's next typed action. Do not recreate Eyes, Imagination, Hands, or -Soul work from this circuit. +timed out at its 300-second boundary and was reviewed/superseded. Its retry +completed but received the older Eyes handoff because launch-context selection +checked Research freshness before the newer accepted Soul boundary. Mind +correctly rejected its resulting Evolution patch and the coordinator superseded +it at revision 35. + +Launch context now lets the newest accepted organ boundary own the Modeling +brief. It also reuses the RepoModel snapshot already loaded for dynamic memory +context instead of reopening the whole runtime store to render model shape. +All seven launch-context tests and the native coordinator seam test pass. + +Poll job `9d7cd7d8-2d43-4165-b3c5-54381126579e` only through an operator-safe +coordinator projection. Accept its first valid verdict-incorporation result, +then inspect Self's next typed action. Do not recreate Eyes, Imagination, Hands, +or Soul work from this circuit. Commit and push the Soul-precedence repair and this Mind refresh. After the current Modeling boundary lands, attack the iteration path: - exact `6f3cdc61` packaging rebuilt 21 first-party release binaries in 6m59s; -- Modeling launch-context assembly against the roughly 40 MiB runtime store took - about 90 seconds before the detached worker appeared; +- Modeling launch-context assembly against the roughly 40 MiB runtime store + still took about 48 seconds before the detached worker appeared and about 83 + seconds before the coordinator finished, even after removing one redundant + RepoModel pull; - the stable source/graph cache already exists, so the next cut is first-party crate/module fan-out plus projection cost, not another cache wrapper. diff --git a/state/map.yaml b/state/map.yaml index 89e9d892..b37d7f9b 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -34,7 +34,7 @@ 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. Live v53 now carries RepoModel revision 6, an exact amended Hands consequence, and an accepted Soul pass. Self correctly derives post-Soul Modeling after repairing verification precedence over generic CRRC/regather routing. The first Modeling run timed out cleanly at 300 seconds; its reviewed 600-second retry, job 07cdae28-8f11-4cba-a19a-b847d2a4792c, is the current live action at thread-state revision 34. Persona consequence, retention, endurance, restart closure, and Linux/Yggdrasil cognition remain open. + summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Live v53 carries RepoModel revision 6, an exact amended Hands consequence, and an accepted Soul pass. Self correctly derives post-Soul Modeling after repairing verification precedence over generic CRRC/regather routing. One timeout and one miscontextualized Evolution patch were reviewed and superseded. Causal Modeling job 9d7cd7d8-2d43-4165-b3c5-54381126579e now runs from the newer Soul boundary at thread-state revision 36. Persona consequence, retention, endurance, restart closure, and Linux/Yggdrasil cognition remain open. operational_state: local_worktree: soul_precedence_verified_pending_commit operator_wireguard: restored @@ -52,8 +52,8 @@ current_status: bifrost_feedback_crossing: authenticated_transport_only yggdrasil_epiphany_services: absent resident_physiology: heartbeat_and_self_running - unresolved_authority: The local execution amendment is user-authorized and packet-hash bound, not Bifrost-signed. Soul passed the amended consequence but reported that derived reorientation checkpoints carry empty evidence_ids; Modeling must preserve that limitation rather than overstate source provenance. The adopted Mind decision also carries a model-supplied 2025 timestamp; coordinator commit-time timestamp ownership remains open. The 6m59s exact package and roughly 90s Modeling launch-context assembly show that epiphany-core compilation fan-out and the 40 MiB runtime-state projection are active iteration defects. - next_action: Poll Modeling job 07cdae28-8f11-4cba-a19a-b847d2a4792c through operator-safe coordinator projection, accept its first valid result, and inspect Self's next typed action. Then split the volatile coordinator/runtime-spine build seam and profile launch-context projection without weakening exact release or state provenance. + unresolved_authority: The local execution amendment is user-authorized and packet-hash bound, not Bifrost-signed. Soul passed the amended consequence but reported that derived reorientation checkpoints carry empty evidence_ids; Modeling must preserve that limitation rather than overstate source provenance. The adopted Mind decision also carries a model-supplied 2025 timestamp; coordinator commit-time timestamp ownership remains open. Exact packaging still takes 6m59s after core changes. Removing one redundant RepoModel pull left worker appearance near 48s and full coordinator launch near 83s, so repeated whole-store transactions remain the dominant 40 MiB launch-path defect. + next_action: Poll Modeling job 9d7cd7d8-2d43-4165-b3c5-54381126579e through operator-safe coordinator projection, accept its first valid verdict-incorporation result, and inspect Self's next typed action. Continue collapsing launch context onto one transaction-scoped typed read view and split volatile Self policy from the release mega-package without weakening provenance. active_subgoals: - Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.