code-mode: linearize cell terminal state#29286
Conversation
2eb9c28 to
82722d4
Compare
| /// Implementations must honor callback cancellation and must not return from | ||
| /// `closed` until the session can no longer route requests to the cell. | ||
| /// Implementations should forward callback cancellation to downstream work. | ||
| /// The actor stops awaiting callbacks once cancellation begins. Implementations |
There was a problem hiding this comment.
Not true but I guess covered later?
34b6189 to
5d836cb
Compare
82722d4 to
728e1ad
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 728e1add33
ℹ️ 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".
| _ = cancellation_token.cancelled(), if !termination => { | ||
| termination = true; | ||
| yield_timer = None; | ||
| drop(command_rx.take()); |
There was a problem hiding this comment.
Preserve queued observers during termination
When terminate() cancels the cell after a begin_wait/observe call has already enqueued an Observe command but before run_cell polls it, this biased cancellation branch runs first and drops command_rx, which drops the queued observer's response sender. That admitted wait then resolves as Closed/missing instead of receiving the same terminal event as the terminator; previously the command queue preserved FIFO ordering between the earlier observe and later terminate. Drain or route already queued observations before closing the receiver.
Useful? React with 👍 / 👎.
Summary
Why
Completion, termination, observation, and stored-value updates must agree on one linearized outcome under cancellation races.
Impact
Terminal delivery becomes deterministic and terminated cells cannot commit state after termination wins.
Validation
just test -p codex-code-mode -p codex-code-mode-protocol(70 passed).cconger/code-mode-runtime-compact-03b-session-runtime.