Repository navigation
fix: prevent queued replies from wedging plugin reloads - #193501
Conversation
Wait on the plugin owner's replacement settlement for refused pre-execution work while retaining the exact FIFO claim. Let cancellation hand durable input back before channel teardown, and record abandonment for unavailable owners without a replacement instead of immediately retrying them. Preserve the existing claim settlement and live-authority checks. Cover reload, rollback, unavailable owners, and cancellation with a regression that fails on main. Real isolated Node and Bun Gateways with Ollama also pass reload success, registration failure, and disablement without losing the queued source.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesQueued replies wait for plugin replacement settlement instead of immediately retrying an unavailable plugin. Example: Discord input B is queued with zero debounce while its plugin reloads.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main Gateway starvation path using existing lifecycle owners; no definite introduced defect was found, and exact-head CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe session mailbox passes claimed queued inputs to the follow-up runner; plugin preparation refusals return to the drain, which coordinates retry or abandonment with source custody. flowchart TD
A[Durable channel ingress] --> B[Session mailbox claim]
B --> C[Follow-up preparation]
C --> D[Plugin replacement settlement]
D --> E[Authority and cancellation checks]
E --> C
C --> F[Model execution and reply]
E --> A
Technical reviewBest possible solution: Use the existing replacement settlement and source-custody owners to suspend refused preparation without replaying executed work. Do we have a high-confidence way to reproduce the issue? Current-main source returns a refused pre-execution input directly to dispatch at zero debounce, matching the reported isolated-Gateway starvation; this read-only review ran no target code. Is this the best way to solve the issue? The repair addresses the retry owner directly, retains FIFO custody, and reuses established cancellation and authority checks without adding a competing lifecycle. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 87ba3bf150db. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +25, Tests -2, Docs +2. Total +25 across 4 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 5, 2026, 8:38 AM ET / 13:38 UTC. |
|
Merged via squash.
|
) Wait on the plugin owner's replacement settlement for refused pre-execution work while retaining the exact FIFO claim. Let cancellation hand durable input back before channel teardown, and record abandonment for unavailable owners without a replacement instead of immediately retrying them. Preserve the existing claim settlement and live-authority checks. Cover reload, rollback, unavailable owners, and cancellation with a regression that fails on main. Real isolated Node and Bun Gateways with Ollama also pass reload success, registration failure, and disablement without losing the queued source.
Backport 668744f (#193501), a required dependency of approved #193564. Preserve FIFO claim and live source checks while replacement settles; abandon unavailable owners. Co-authored-by: RomneyDa <[email protected]>
Related: #193313. Preserves the exact-claim settlement fence from #193423.
What Problem This Solves
Fixes a Gateway hang when an ordinary queued follow-up starts preparing while its channel plugin is being replaced.
User Impact
Health and status requests keep responding during reload. Queued inputs survive successful replacement and rollback without duplicate model runs. Disabling a channel preserves unexecuted durable input as pending for re-enablement, with its existing abandonment record.
Why This Change Was Made
A pre-execution plugin refusal retained the same queue head and immediately retried it. At zero debounce, the promise chain starved I/O, replacement progress, timers, and signal handling. This reproduces on current main without the queue-cap PR.
The drain now waits on the existing plugin owner's replacement settlement while keeping its exact FIFO claim. Source, claim, or mailbox cancellation releases that wait through existing custody handling. The successor channel reclaims the durable input with fresh callbacks; early rollback can resume the original instance. An unavailable instance without a pending replacement records abandonment instead of spinning. Existing live-authority checks and settlement fences remain intact. No schema, dependency, configuration, or public API change.
Evidence
Current-main control: Node 26.12.1 and pinned Bun, real isolated Gateway, shared Ollama
qwen2.5:7b, ordinary follow-up queue, one survivor, no cap drops. The running request received its model response; the survivor stayed claimed at attempts=0. Health/status timed out and SIGTERM needed an exact-PID SIGKILL fallback. The clean Bun capture recorded 4,694 repeated refusals and more than five seconds without the main-thread timer running.All six candidate cases pass. Measurements run after the running request is held and the follow-up is queued, through reload and source settlement. Requests and replies are RUNNER/B/C/D exactly once for success and recovery. Disablement cancels the running turn and leaves B pending with attempts=1 and
last_error=turn-abandoned, without a B model request.Every reload-window health/status probe succeeded. The 200 ms main-thread timer's maximum observed interval was 375 ms across the candidate reloads, compared with over five seconds of starvation on main. Reload operations settled in 1.1–3.1 seconds. CPU was sampled separately: median samples were 130.2% in the main reproduction and 30.9% in the candidate Bun success window. Registration and disablement still produce brief CPU bursts; these observations are not a peak-CPU ceiling.
Production +40/-15 (net +25); tests +152/-154 (net -2); docs +2/-0. The added production code waits and cancels through existing owners; no new retry framework or state owner. A nearby delivery-preparation retry already yields through a timer and remains outside this execution-drain fix.
The transport fixture uses the real Discord plugin, ingress ledger, Gateway and model with synthetic local Discord HTTP/Gateway contracts. Proof is on macOS arm64; real Discord service behavior and Linux/Windows are not covered. Raw startup samples are retained separately from the reload window; one cold-start health timeout was observed before a mutation. No state schema or update migration changed.