Cancel timed-out upstream requests before retry - #187
Conversation
Keep process catalog retries on the existing bridge and wait for upstream cancellation delivery before arming the next attempt. This prevents repeated mcpbridge attachment generations from accumulating in Xcode.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06e1d4cb7c
ℹ️ 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".
Make RPC cancellation wait for the original upstream send, preserve rejected delivery as a distinct terminal result, and recover the channel instead of reusing it. Gate catalog admission during backoff and advance a route-owned retry ordinal across same-slot retries.
Carry cancellation completion through the empty-catalog path and allow retry scheduling when cancellation is no longer needed. Keep rejected cancellation on the channel-recovery path.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97d452180d
ℹ️ 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".
Keep request and catalog leases owned until send and cancellation outcomes settle. Recover rejected cancellation channels atomically, serialize topology replacement with shutdown, and block replacement traffic until predecessor stop completes.
Move catalog timeout ownership into each CatalogLease load. Preserve sibling loads, reject stale callbacks by reservation generation, and phase-scope initialize timeouts after channel initialization.
Publish prepared request ID mappings atomically with cancellation state so cancellation cleans them without sending an upstream notification before registration. Consume catalog timeout reservations even when callbacks fire before timer attachment, and linearize timeout mutation against shutdown.
Make RPCHandle own handler installation and lifecycle transitions in one state machine so cancellation always reaches a terminal delivery. Reject late installation, release the reserved request lease, and cover pre-install cancellation and reentrant delivery sharing.
Route stops are owned by upstreamRetirementTasks, so draining runtimeTasks does not establish completion. Synchronize the three retirement assertions on the upstream stop event they verify.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b8619337a
ℹ️ 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".
Keep health probe reservation and process route reconciliation inside the lifecycle gate, then apply control-plane and probe effects only after releasing its non-recursive lock. Cover successful probes and shutdown-winning handoffs deterministically.
Observe the upstream cancellation and drain runtime settlement before asserting the correlated lease was released. The waiter timeout alone does not establish that happens-before edge.
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
The failing The failure was a race in Validation:
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Purpose
Prevent timed-out or abandoned proxy requests from leaving work active on a degraded Xcode bridge while replacement work starts, which can repeatedly create bridge processes and duplicate Xcode agent attachments.
Changes
RPCHandleone lifecycle state machine for cancellation-handler installation, queue registration, upstream ID assignment, completion, and cancellation.notifications/cancelledafter the original request send and preserve exact request identity until cancellation delivery settles.Testing
scripts/check.shgit diff --checkcodex-reviewagainst pinnedmain: no findingsScreenshots
Not applicable; this changes proxy runtime lifecycle behavior.