5.7 KiB
Codex Epiphany Phase 1 Implementation Plan
This is the actionable implementation note for the first Epiphany patch slice against the real openai/codex tree vendored under vendor/codex.
Phase 1 is deliberately internal/dev-usable, not user-facing. The goal is to give Codex a real durable Epiphany state seam in core, keep the app usable, and prove replay/persistence before touching prompts, presets, protocol notifications, or GUI reflection.
Summary
Land Phase 1 as an additive core slice that persists and rehydrates structured Epiphany thread state without changing normal Codex behavior.
After this slice:
- non-Epiphany sessions still behave exactly as they do now
- the app remains usable because existing clients ignore the new metadata
- Epiphany state can be exercised and validated through automated core/rollout/resume tests
This slice does not include:
- prompt integration
- app-server notifications
- GUI surfaces
- collaboration-mode presets
- mutation gates
- retrieval indexing
- specialist-agent orchestration
Key Changes
1. Add minimal durable Epiphany protocol types
Touch:
vendor/codex/codex-rs/protocol/src/protocol.rs
Add:
EpiphanyThreadStateEpiphanyStateItem { turn_id: Option<String>, state: EpiphanyThreadState }RolloutItem::EpiphanyState(EpiphanyStateItem)
Phase 1 schema should stay minimal but sufficient:
revisionobjectiveactive_subgoal_idsubgoalsinvariantsgraphsgraph_frontiergraph_checkpointscratchobservationsrecent_evidencechurnmodelast_updated_turn_id
Defer these to later phases:
agentsjobsretrieval- separate append-only evidence/checkpoint rollout items
- separate turn intent rollout item
- any new
EventMsgvariants
All new protocol types should derive the same serialization/schema traits as neighboring rollout types.
2. Store Epiphany state in SessionState
Touch:
vendor/codex/codex-rs/core/src/state/session.rsvendor/codex/codex-rs/core/src/session/mod.rs
Add:
epiphany_state: Option<EpiphanyThreadState>toSessionState- simple getter/setter helpers on session state
Persistence rule:
- persist one
RolloutItem::EpiphanyState(...)per real user turn - write it immediately after the
TurnContextItembaseline is persisted - skip the write when
epiphany_stateisNone
Do not change prompt assembly or tool behavior in this slice.
3. Rehydrate Epiphany state on resume and fork
Touch:
vendor/codex/codex-rs/core/src/session/rollout_reconstruction.rs- the session-start/resume path that consumes
RolloutReconstruction
Extend reconstruction to carry:
epiphany_state: Option<EpiphanyThreadState>
Replay rule:
- the newest surviving
EpiphanyStateItemwins - rollback must discard Epiphany snapshots from rolled-back turns
- compaction must not erase the latest surviving snapshot
Treat EpiphanyStateItem as turn-scoped metadata in the same reverse scan that already respects rollback and compaction boundaries.
4. Update rollout readers to tolerate the new variant
Adding a RolloutItem variant will create exhaustiveness fallout across the repo. Update those sites explicitly instead of letting it turn into whack-a-mole.
At minimum touch:
vendor/codex/codex-rs/app-server-protocol/src/protocol/thread_history.rsvendor/codex/codex-rs/rollout/src/policy.rsvendor/codex/codex-rs/rollout/src/metadata.rsvendor/codex/codex-rs/rollout/src/list.rsvendor/codex/codex-rs/rollout/src/recorder.rs- any additional exhaustive
RolloutItemmatches incore,tui,exec, andprotocol
Phase 1 behavior at those call sites:
- thread-history/UI builders should ignore
EpiphanyState - rollout metadata/listing code should treat it as non-rendered metadata
- existing user-visible thread rendering must stay unchanged
Test Plan
Protocol and schema
- serde round-trip for
EpiphanyThreadState - serde round-trip for
EpiphanyStateItem - any protocol/schema snapshots updated for the new
RolloutItemvariant
Core persistence
- a session with populated Epiphany state writes
RolloutItem::EpiphanyState - a session with
NoneEpiphany state writes nothing extra - the Epiphany rollout item appears after the turn-context baseline for the turn
Replay correctness
- resume restores the newest surviving Epiphany snapshot
- rollback drops snapshots from discarded turns
- compaction keeps the latest surviving Epiphany snapshot available after reconstruction
Compatibility
app-server-protocolthread reconstruction still builds the same visible turn history- rollout list/metadata readers still work with mixed old/new rollout files
- untouched user flows remain unchanged in tests
Compile-fallout coverage
- build/test the touched crates so all exhaustive
RolloutItemmatches are updated in one pass
Assumptions
- Phase 1 is internal/dev-usable, not operator-usable or GUI-visible.
- "Testable after Phase 1" means persistence/replay behavior is verifiable through automated tests and internal session wiring, not that users can activate Epiphany from the UI yet.
- Phase 1 keeps evidence and checkpoint data embedded inside the baseline Epiphany snapshot instead of splitting them into separate rollout item variants.
- Prompt integration, app-server typed updates, GUI scene loading, retrieval, jobs, and specialist-agent scheduling are later slices.
Immediate Next Step After This Plan
Implement the protocol/core/replay slice only:
- add the minimal protocol types
- wire
SessionState - persist one snapshot per real user turn
- restore it through rollout reconstruction
- patch exhaustive
RolloutItemmatches - add replay/persistence tests before moving on