Skip to content

[1/3] core: make world state snapshots serializable - #29833

Merged
sayan-oai merged 3 commits into
mainfrom
codex/world-state-snapshots
Jun 25, 2026
Merged

[1/3] core: make world state snapshots serializable#29833
sayan-oai merged 3 commits into
mainfrom
codex/world-state-snapshots

Conversation

@sayan-oai

@sayan-oai sayan-oai commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Why

WorldState currently keeps its diff baseline as live Rust objects keyed by process-local TypeId. That baseline cannot be written to a rollout or restored after resume, so Codex reconstructs an approximation from TurnContextItem.

This is the first change in the WorldState persistence stack. It gives every section a stable persisted identity and a compact serializable comparison snapshot without changing rollout behavior yet.

What changed

  • Require each WorldStateSection to define a stable ID and serializable snapshot type.
  • Reject duplicate section IDs when constructing WorldState.
  • Persist a dedicated environment comparison snapshot using model-visible strings instead of runtime path types.
  • Store only WorldStateSnapshot in ContextManager, removing the parallel live-object baseline.
  • Render diffs by restoring each section's typed snapshot; invalid snapshots fall back to a full section render.
  • Omit null object fields for future RFC 7386 patches while preserving null values inside arrays.

Follow-up PRs will record full snapshots and merge patches, then restore the baseline during resume, fork, and rollback.

Test plan

  • WorldState snapshot tests cover stable IDs, duplicate rejection, null omission, and array preservation.
  • Environment tests cover persistence-safe snapshot values and existing diff rendering.
  • ContextManager baseline deduplication and session context-update persistence tests.

Related: #29249

@sayan-oai
sayan-oai marked this pull request as ready for review June 24, 2026 19:05
@sayan-oai
sayan-oai requested a review from a team as a code owner June 24, 2026 19:05
@sayan-oai sayan-oai changed the title core: make world state snapshots serializable [1/3] core: make world state snapshots serializable Jun 24, 2026
Comment thread codex-rs/core/src/context/world_state/environment.rs Outdated
Comment thread codex-rs/core/src/context/world_state/mod.rs Outdated
Comment thread codex-rs/core/src/context/world_state/mod.rs Outdated
@sayan-oai sayan-oai changed the title [1/3] core: make world state snapshots serializable [1/3] core: make world state snapshots serializable Jun 24, 2026
Comment thread codex-rs/core/src/context/world_state/world_state_tests.rs
Comment thread codex-rs/core/src/context/world_state/mod.rs
@sayan-oai
sayan-oai merged commit 3e51b46 into main Jun 25, 2026
31 checks passed
@sayan-oai
sayan-oai deleted the codex/world-state-snapshots branch June 25, 2026 02:26
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants