Repository navigation
fix(gateway): reject stale node work before enqueue - #132909
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 7:30 PM ET / 23:30 UTC. ClawSweeper reviewWhat this changesThe PR replaces pending-node work’s local pairing check with the existing shared liveness guard and adds a regression test for invalidation during the asynchronous generation lookup. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer review: this member-authored, maintainer-labeled PR is still needed, and the introduced change correctly prevents a stale pairing lifecycle from reaching the pending-work queue. Priority: P2 Review scores
Verification
How this fits togetherGateway operators enqueue work for paired nodes that may reconnect later. Pairing generation and wake-lifecycle state determine whether that work may enter the queue or must return a retryable unavailable result. flowchart LR
A[Operator node-work request] --> B[Capture pairing generation]
B --> C[Capture wake lifecycle]
C --> D[Shared liveness check]
D -->|Current| E[Enqueue pending work]
D -->|Changed| F[Return PAIRING_CHANGED]
E --> G[Optional node wake]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -12, Tests +40. Total +28 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt the shared post-await liveness predicate at every pending-work wake checkpoint, retain the distinct non-lifecycle checks for pull and acknowledgement paths, and merge once the exact-head gate is clean. Do we have a high-confidence way to reproduce the issue? Yes, from source: aborting the wake lifecycle during the awaited generation lookup made the prior helper return true and reach enqueue; the added handler-boundary test encodes that exact sequence. Is this the best way to solve the issue? Yes. Reusing the shared liveness owner is the narrowest maintainable repair because it already performs the required post-await lifecycle recheck used by node invocation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3b92e84d2934. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Before-merge resolution:
Both listed |
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where node pending work could be briefly enqueued after the node was re-paired or removed while the Gateway was checking its pairing generation.
Why This Change Was Made
Pending-work enqueue and wake stages now use the existing shared pairing-work liveness check. That check validates the wake lifecycle both before and after the asynchronous pairing-generation lookup, so invalidation during the lookup is rejected before any queue mutation.
User Impact
Operators no longer get stale node work inserted and then cleaned up when pairing changes during the initial enqueue check. The request instead returns the existing retryable
PAIRING_CHANGEDresult without mutating the queue.Evidence
isNodePairingGenerationCurrentstill calledenqueueNodePendingWorkoncePAIRING_CHANGEDnode scripts/run-vitest.mjs src/gateway/server-methods/nodes.pending-work.test.ts— 9 tests passedpnpm tsgo:corepassed+6/-18(net-12); tests:+40pnpm tsgo:core:testreached the unrelated linked-install error for missingpakodeclarations inui/vite.config.ts