Skip to content

[2/3] core: persist world state in rollouts - #29835

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

[2/3] core: persist world state in rollouts#29835
sayan-oai merged 3 commits into
mainfrom
codex/persist-world-state

Conversation

@sayan-oai

Copy link
Copy Markdown
Contributor

Why

WorldState currently remembers its model-visible diff baseline only in memory. That leaves no durable source for restoring the exact baseline after resume, fork, rollback, or compaction.

This is the second PR in the WorldState persistence stack, built on #29833 and following #29249. It records durable state transitions; the next PR will replay them during rollout reconstruction.

What

  • Add a world_state rollout item containing either a full snapshot or an RFC 7386 JSON Merge Patch.
  • Persist a full snapshot after initial context and after compaction establishes a new context window.
  • Persist non-empty patches when later sampling steps or turns advance the WorldState baseline.
  • Write model-visible history before its matching WorldState record, so an interrupted write can only cause a safe repeated update on replay.
  • Preserve WorldState records for full-history forks while excluding them from thread previews, metadata, and app-server history materialization.

Older binaries read rollout lines independently, so they skip the unknown world_state records while retaining the rest of the thread.

Testing

  • just test -p codex-core snapshot_merge_patch_changes_and_removes_nested_values
  • just test -p codex-core world_state_baseline_deduplicates_until_history_is_replaced
  • just test -p codex-core deferred_executor_compaction_preserves_then_updates_environment_once
  • just test -p codex-protocol
  • just test -p codex-rollout
  • just test -p codex-state
  • just test -p codex-thread-store
  • just test -p codex-app-server-protocol

@sayan-oai sayan-oai changed the title core: persist world state in rollouts [2/3] core: persist world state in rollouts Jun 24, 2026
@sayan-oai
sayan-oai marked this pull request as ready for review June 24, 2026 19:48
@sayan-oai
sayan-oai requested a review from a team as a code owner June 24, 2026 19:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7af2b6f44a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/context_manager/history.rs

@jif-oai jif-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sayan-oai
sayan-oai force-pushed the codex/world-state-snapshots branch from 46d2d19 to 27dac17 Compare June 25, 2026 00:36
@sayan-oai
sayan-oai force-pushed the codex/persist-world-state branch from 7af2b6f to f2750c1 Compare June 25, 2026 00:36
@sayan-oai
sayan-oai force-pushed the codex/persist-world-state branch from f2750c1 to 922aac2 Compare June 25, 2026 01:11
Base automatically changed from codex/world-state-snapshots to main June 25, 2026 02:26
@sayan-oai
sayan-oai force-pushed the codex/persist-world-state branch from 922aac2 to 4ed9d3a Compare June 25, 2026 02:28
sayan-oai added a commit that referenced this pull request Jun 25, 2026
@sayan-oai
sayan-oai force-pushed the codex/persist-world-state branch from 8218445 to 7667ec5 Compare June 25, 2026 02:58
@sayan-oai
sayan-oai merged commit fa036d3 into main Jun 25, 2026
31 checks passed
@sayan-oai
sayan-oai deleted the codex/persist-world-state branch June 25, 2026 03:13
@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.

2 participants