diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 6e3757a0..97f04ba3 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -1912,7 +1912,12 @@ slab is deleted: app-server-protocol, app-server, and core legacy tests import the native model directly; Codex protocol keeps only a private state-item import for historical rollout decoding. Next make that legacy payload opaque in Codex protocol and decode it only in the app-server quarantine, removing -`epiphany-state-model` from Codex protocol's production dependency graph. +`epiphany-state-model` from Codex protocol's production dependency graph. That +cut is complete: the rollout variant carries opaque JSON, app-server alone +performs typed validation, malformed payloads fail closed, and production +Codex protocol has no native-state dependency. Next delete its obsolete +native-state test fixture and dev-dependency, leaving only an opaque historical +envelope preservation test. ## Immediate Re-entry Instruction diff --git a/notes/native-coordinator-liberation-map.md b/notes/native-coordinator-liberation-map.md index e385eb8d..d9f7e426 100644 --- a/notes/native-coordinator-liberation-map.md +++ b/notes/native-coordinator-liberation-map.md @@ -312,3 +312,11 @@ app-server compatibility code, and legacy-focused core tests import `EpiphanyStateItem` import solely to decode the historical rollout variant; its two round-trip tests and app-server's two migration tests pass. A source guard forbids `pub use epiphany_state_model::*` from returning. + +The historical rollout payload is now opaque inside Codex protocol: +`RolloutItem::EpiphanyState(serde_json::Value)`. App-server's legacy quarantine +alone decodes that value into `EpiphanyStateItem`, returns a typed state only +after validation, and rejects malformed payloads. The old tagged JSON shape, +latest-surviving selection, and rollback semantics remain covered. Codex +protocol no longer has a production dependency on `epiphany-state-model`; a +source guard proves both the opaque variant and dependency boundary. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index d4f0ce50..c5b7f144 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 83463030..32ff5136 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -659,4 +659,4 @@ current_status: - Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass. - `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure. last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. Gjallar readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync. - next_action: Remove `epiphany-state-model` as a production dependency of `codex-protocol` by making the legacy `epiphany_state` rollout payload opaque at the Codex layer and decoding it into `EpiphanyStateItem` only inside app-server's migration quarantine. Preserve exact old-file readability and rollback semantics with focused fixtures before deleting the typed protocol variant. + next_action: Remove `epiphany-state-model` from `codex-protocol` dev-dependencies too. Replace the obsolete native-state round-trip fixture and giant sample builder with a minimal opaque legacy-envelope fixture; native state serialization belongs to `epiphany-state-model`, while Codex protocol should prove only preservation of historical payload bytes/shape. diff --git a/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_thread_host.rs b/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_thread_host.rs index fb100dff..5648ca44 100644 --- a/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_thread_host.rs +++ b/vendor/codex/codex-rs/app-server/src/codex_message_processor/epiphany_thread_host.rs @@ -70,7 +70,7 @@ pub(super) async fn load_epiphany_state_from_rollout_path( InitialHistory::Forked(items) => items, InitialHistory::Resumed(resumed) => resumed.history, }; - Ok(latest_legacy_epiphany_state(&items)) + latest_legacy_epiphany_state(&items) } pub(super) async fn live_thread_epiphany_state( diff --git a/vendor/codex/codex-rs/app-server/src/codex_message_processor/legacy_epiphany_rollout.rs b/vendor/codex/codex-rs/app-server/src/codex_message_processor/legacy_epiphany_rollout.rs index 3000ffcd..290ec11a 100644 --- a/vendor/codex/codex-rs/app-server/src/codex_message_processor/legacy_epiphany_rollout.rs +++ b/vendor/codex/codex-rs/app-server/src/codex_message_processor/legacy_epiphany_rollout.rs @@ -28,7 +28,9 @@ fn is_out_of_band(segment: &LegacySegment) -> bool { segment.turn_id.is_none() && !segment.user_turn && segment.state.is_some() } -pub(super) fn latest_legacy_epiphany_state(items: &[RolloutItem]) -> Option { +pub(super) fn latest_legacy_epiphany_state( + items: &[RolloutItem], +) -> Result, String> { let mut state = None; let mut rollbacks = 0usize; let mut segment: Option = None; @@ -66,7 +68,11 @@ pub(super) fn latest_legacy_epiphany_state(items: &[RolloutItem]) -> Option { segment.get_or_insert_with(LegacySegment::default).user_turn = true; } - RolloutItem::EpiphanyState(item) => { + RolloutItem::EpiphanyState(payload) => { + let item: epiphany_state_model::EpiphanyStateItem = + serde_json::from_value(payload.clone()).map_err(|error| { + format!("invalid legacy Epiphany rollout payload: {error}") + })?; let segment = segment.get_or_insert_with(LegacySegment::default); if segment.turn_id.is_none() { segment.turn_id = item.turn_id.clone(); @@ -96,7 +102,7 @@ pub(super) fn latest_legacy_epiphany_state(items: &[RolloutItem]) -> Option RolloutItem { + RolloutItem::EpiphanyState( + serde_json::to_value(item).expect("serialize legacy Epiphany rollout payload"), + ) +} + fn user_message(text: &str) -> ResponseItem { ResponseItem::Message { id: None, @@ -138,7 +144,7 @@ async fn record_initial_history_resumed_accepts_legacy_epiphany_state_items() { }, )), RolloutItem::TurnContext(first_context_item), - RolloutItem::EpiphanyState(EpiphanyStateItem { + legacy_epiphany_state(EpiphanyStateItem { turn_id: Some(first_turn_id.clone()), state: first_epiphany, }), @@ -167,7 +173,7 @@ async fn record_initial_history_resumed_accepts_legacy_epiphany_state_items() { text_elements: Vec::new(), }, )), - RolloutItem::EpiphanyState(EpiphanyStateItem { + legacy_epiphany_state(EpiphanyStateItem { turn_id: Some(second_turn_id.clone()), state: second_epiphany.clone(), }), @@ -201,7 +207,7 @@ async fn record_initial_history_resumed_accepts_out_of_band_epiphany_state_befor session .record_initial_history(InitialHistory::Resumed(ResumedHistory { conversation_id: ThreadId::default(), - history: vec![RolloutItem::EpiphanyState(EpiphanyStateItem { + history: vec![legacy_epiphany_state(EpiphanyStateItem { turn_id: None, state: epiphany_state.clone(), })], @@ -239,7 +245,7 @@ async fn record_initial_history_resumed_accepts_out_of_band_epiphany_state_after text_elements: Vec::new(), }, )), - RolloutItem::EpiphanyState(EpiphanyStateItem { + legacy_epiphany_state(EpiphanyStateItem { turn_id: Some(turn_id.clone()), state: turn_state, }), @@ -252,7 +258,7 @@ async fn record_initial_history_resumed_accepts_out_of_band_epiphany_state_after time_to_first_token_ms: None, }, )), - RolloutItem::EpiphanyState(EpiphanyStateItem { + legacy_epiphany_state(EpiphanyStateItem { turn_id: None, state: control_plane_state.clone(), }), @@ -476,7 +482,7 @@ async fn reconstruct_history_ignores_legacy_epiphany_items_during_rollback() { }, )), RolloutItem::TurnContext(first_context_item), - RolloutItem::EpiphanyState(EpiphanyStateItem { + legacy_epiphany_state(EpiphanyStateItem { turn_id: Some(first_turn_id.clone()), state: sample_epiphany_state("turn-1"), }), @@ -505,7 +511,7 @@ async fn reconstruct_history_ignores_legacy_epiphany_items_during_rollback() { text_elements: Vec::new(), }, )), - RolloutItem::EpiphanyState(EpiphanyStateItem { + legacy_epiphany_state(EpiphanyStateItem { turn_id: Some(rolled_back_turn_id.clone()), state: sample_epiphany_state("turn-2"), }), @@ -1293,7 +1299,7 @@ async fn reconstruct_history_ignores_legacy_epiphany_items_during_compaction() { }, )), RolloutItem::TurnContext(previous_context_item), - RolloutItem::EpiphanyState(EpiphanyStateItem { + legacy_epiphany_state(EpiphanyStateItem { turn_id: Some(previous_turn_id.clone()), state: epiphany_state.clone(), }), diff --git a/vendor/codex/codex-rs/core/src/session/tests.rs b/vendor/codex/codex-rs/core/src/session/tests.rs index ef3489e1..1b5110ea 100644 --- a/vendor/codex/codex-rs/core/src/session/tests.rs +++ b/vendor/codex/codex-rs/core/src/session/tests.rs @@ -147,6 +147,12 @@ use std::time::Duration as StdDuration; mod guardian_tests; +fn legacy_epiphany_state(item: EpiphanyStateItem) -> RolloutItem { + RolloutItem::EpiphanyState( + serde_json::to_value(item).expect("serialize legacy Epiphany rollout payload"), + ) +} + #[test] fn codex_session_has_no_epiphany_state_custody() { let session_state = include_str!("../state/session.rs"); @@ -154,6 +160,7 @@ fn codex_session_has_no_epiphany_state_custody() { let codex_thread = include_str!("../codex_thread.rs"); let core_lib = include_str!("../lib.rs"); let protocol = include_str!("../../../protocol/src/protocol.rs"); + let protocol_manifest = include_str!("../../../protocol/Cargo.toml"); assert!(!session_state.contains("epiphany_state")); assert!(!session.contains("set_epiphany_state")); @@ -162,6 +169,12 @@ fn codex_session_has_no_epiphany_state_custody() { assert!(!codex_thread.contains("pub async fn epiphany_")); assert!(!core_lib.contains("epiphany_rollout")); assert!(!protocol.contains("pub use epiphany_state_model::")); + assert!(protocol.contains("EpiphanyState(serde_json::Value)")); + let production_dependencies = protocol_manifest + .split("[dev-dependencies]") + .next() + .expect("protocol manifest should declare dependencies"); + assert!(!production_dependencies.contains("epiphany-state-model")); } fn sample_epiphany_state_for_prompt() -> EpiphanyThreadState { @@ -5350,7 +5363,7 @@ async fn build_initial_context_does_not_inject_resumed_epiphany_state() { text_elements: Vec::new(), })), RolloutItem::TurnContext(turn_context_item), - RolloutItem::EpiphanyState(EpiphanyStateItem { + legacy_epiphany_state(EpiphanyStateItem { turn_id: Some(turn_id), state: epiphany_state, }), diff --git a/vendor/codex/codex-rs/protocol/Cargo.toml b/vendor/codex/codex-rs/protocol/Cargo.toml index e058452b..d3ae68ea 100644 --- a/vendor/codex/codex-rs/protocol/Cargo.toml +++ b/vendor/codex/codex-rs/protocol/Cargo.toml @@ -22,7 +22,6 @@ codex-utils-image = { workspace = true } codex-utils-string = { workspace = true } codex-utils-template = { workspace = true } encoding_rs = { workspace = true } -epiphany-state-model = { path = "../../../../epiphany-state-model" } globset = { workspace = true } icu_decimal = { workspace = true } icu_locale_core = { workspace = true } @@ -52,6 +51,7 @@ seccompiler = { workspace = true } [dev-dependencies] anyhow = { workspace = true } +epiphany-state-model = { path = "../../../../epiphany-state-model" } http = { workspace = true } pretty_assertions = { workspace = true } tempfile = { workspace = true } diff --git a/vendor/codex/codex-rs/protocol/src/protocol.rs b/vendor/codex/codex-rs/protocol/src/protocol.rs index 1bbfaf6d..fc32638b 100644 --- a/vendor/codex/codex-rs/protocol/src/protocol.rs +++ b/vendor/codex/codex-rs/protocol/src/protocol.rs @@ -52,8 +52,6 @@ use crate::request_user_input::RequestUserInputResponse; use crate::user_input::UserInput; #[cfg(test)] use epiphany_state_model::*; -#[cfg(not(test))] -use epiphany_state_model::EpiphanyStateItem; use codex_utils_absolute_path::AbsolutePathBuf; use schemars::JsonSchema; use serde::Deserialize; @@ -2947,7 +2945,7 @@ pub enum RolloutItem { ResponseItem(ResponseItem), Compacted(CompactedItem), TurnContext(TurnContextItem), - EpiphanyState(EpiphanyStateItem), + EpiphanyState(serde_json::Value), EventMsg(EventMsg), } @@ -5284,8 +5282,14 @@ mod tests { turn_id: Some("turn-123".to_string()), state: sample_epiphany_thread_state(), }; - let value = serde_json::to_value(&original)?; - let reparsed: EpiphanyStateItem = serde_json::from_value(value)?; + let rollout_item = RolloutItem::EpiphanyState(serde_json::to_value(&original)?); + let value = serde_json::to_value(&rollout_item)?; + assert_eq!(value["type"], "epiphany_state"); + let reparsed: RolloutItem = serde_json::from_value(value)?; + let RolloutItem::EpiphanyState(payload) = reparsed else { + panic!("expected opaque legacy Epiphany rollout payload"); + }; + let reparsed: EpiphanyStateItem = serde_json::from_value(payload)?; assert_eq!(reparsed, original); Ok(()) }