fix(codex): fence overlapping compaction attempts - #94
Open
mulfyx wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Codex compaction kept one registry entry per Claude session, while asynchronous compaction producers and terminal handlers identified that entry only by session and model.
On base
529e1d6, a compaction request awaits upstream work before storing its result (request path). Meanwhile,store_compactionreplaces the session slot unconditionally, and activation/abort do not identify the originating attempt (registry and store, activation and abort).With overlapping compactions A and B for the same session, a late A completion could therefore:
This change:
CompactionAttemptbefore awaiting upstream compaction;Preparinggeneration immediately;The scope is same-session stale-completion/lost-update protection, not a cross-session isolation issue.
Consistency precedents
These are consistency precedents, not claims that the Responses compaction API mandates generation IDs:
encrypted_contentas an opaque item that must be carried into subsequent Responses requests (compaction guide). Keeping it paired with the portable summary from the same attempt is therefore an application-level consistency requirement.expectedTurnIdas an optimistic concurrency precondition (schema) and validates it atomically under the active-turn lock (implementation).Validation
cargo test --all-targets: 828 tests passed.cargo clippy --all-targets -- -D warnings: passed.native-Bhistory.