Repository navigation
fix: preserve queued ingress messages during gateway restart - #196923
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR separates shutdown admission fencing from authority retirement so accepted ingress messages retain restart custody. Example: Two accepted app messages await execution when the Gateway receives SIGTERM.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR repairs a current shutdown-ordering bug that loses accepted queued messages. No actionable source defects remain; exact-head CI is still pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherTrusted plugins bind principals to Gateway ingress; accepted inputs enter the session queue, shutdown records their existing recovery metadata, and startup restores them through current authorization. flowchart TD
A[App principal] --> B[Request admission]
B --> C[Accepted session queue]
C --> D[Restart custody marker]
D --> E[Current authority checks]
E --> F[Agent execution and effects]
Technical reviewBest possible solution: Keep admission fenced while existing session owners record restart custody, then retire retained authority without weakening live permission checks. Do we have a high-confidence way to reproduce the issue? The supplied compiled CLI receipts establish the base failure, and current-main source exposes the premature authority-abort path; this read-only review executed no target code. Is this the best way to solve the issue? The patch repairs shutdown ordering at the existing lifecycle, request-entry, scheduler, and ingress owners, with no competing recovery implementation or unnecessary production layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aa4ebbb626c4. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +33, Tests +272, Docs +7, Other +3. Total +315 across 18 files. Added test files: 1. 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 HistoryReviewed November 10, 2026, 7:49 PM ET / November 11, 2026, 00:49 UTC (Revision 3). |
|
@clawsweeper re-review The current Evidence section now includes completed compiled CLI restart traces and sanitized original-run terminal receipts for FIFO replay, role downgrade, People removal and app revocation at the tool boundary. It also records the separate eager-cancellation limitation and an unresolved pre-provider timeout. Source head is unchanged. |
|
🦞👀 Re-review progress:
|
…w#196923) * fix: preserve queued ingress messages during gateway restart * test: complete ingress host admission fixture * fix: fence mention intake before restart preparation
…ent (#197213) Preserve #196923 admission-first restart custody. Assert request entry closes while scheduler authority is fenced, then assert scheduler retirement after accepted fork and rewind finish. Keep persistence and late-request refusal checks; three affected tests pass. Co-authored-by: obviyus <[email protected]>
…ent (openclaw#197213) Preserve openclaw#196923 admission-first restart custody. Assert request entry closes while scheduler authority is fenced, then assert scheduler retirement after accepted fork and rewind finish. Keep persistence and late-request refusal checks; three affected tests pass. Co-authored-by: obviyus <[email protected]>
Adapt admission fencing to canonical retained request authority and graceful restart markers without restoring retired crash-principal reconstruction. Independent local review omitted per release owner; scoped gates pass. (cherry picked from commit 73a0ce1) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
What Problem This Solves
Fixes accepted queued app messages being silently cancelled when the Gateway shuts down for a restart.
User Impact
Queued ingress messages survive a graceful restart and continue under their original source limits and current permissions. New requests are refused as soon as shutdown begins. No schema, configuration, or migration change is required.
Why This Change Was Made
Close request admission and scheduled wakeups first, then retire retained authority after the existing marker and session-stop owners have recorded restart custody. This keeps shutdown from being mistaken for grant revocation while preserving live permission checks.
Evidence
The real compiled CLI reproduces the queue loss on base
5ef2ef59edee69d1597d7aedcc1ec12b08c6a2ff: SIGTERM exits cleanly, the distinct replacement becomes ready, but the accepted queued marker never reaches the model. The new Gateway/SQLite regression also fails on that base; its actual-revocation control passes. Both owner cases pass with this change, including immediate new-request/new-binding refusal and exact source/message/run preservation.Compiled candidate
4646580a4953e6b600ca29624590ebe49f1446b5was exercised through real owner login, invitation/People approval, member shell, app consent, normal SIGTERM, and a distinct normal CLI process with a fresh signed relay handshake:Every successful scenario also verifies an independent owner app write, clean old/new Gateway exits, and no queued write-capable dispatch during old-process shutdown. Saved receipts, original run IDs, files and artifact hashes were independently checked. All 113,452 archived candidate files still match after execution; the separately built native binding is pinned independently. Build metadata names the base plus the pre-commit source snapshot; all 17 files from the compiled source snapshot match reviewed commit
4646580a4953e6b600ca29624590ebe49f1446b5. Subsequent CI corrections complete one integration fixture and move existing mention-inbox disposal into synchronous shutdown preparation. The latter is covered by the existing production Gateway lifecycle/SQLite regressions described below; the full compiled browser campaign was not repeated on the final head.Remaining limits: revoking a recovered app does not eagerly close its already in-flight provider stream (a separate 60-second check failed); the next authority check refuses the late tool effect, as the distinct final-effect run proves. One earlier authorized control timed out in
sessions.createbefore provider I/O; its cause remains unresolved, and the later pass is not claimed as a timeout fix. Two incorrect harness assertions were corrected against the current terminal/transport contracts; their failed runs are retained.admissionSignalin the existing Control UI fixture; the same typecheck and all 10 integration cases pass after correction. The next CI run caught mention-inbox admission staying open during marker preparation; the unchanged public-close test reproduced the failure locally. Moving its existing disposal earlier restores immediate refusal while preserving accepted writes. All 12 focused Gateway kernel, accepted auth/mention close, and queued-ingress cases pass on the final source, as do production types and targeted lint/format. The final-head CI typecheck and previously failing Gateway shard both pass. PostgreSQL 17 conformance passed all three shards. The additional PostgreSQL 16 Gateway cron smoke remained incomplete when its parent job hit the confirmed 30-minute limit; its log showed passing tests and no failed assertion before cancellation. This remains a deferred validation blocker; no retry or timeout increase is claimed as a fix.9847ccca5d5f55fee61be1ca06bc4d8a62689dd3counts 6,643,529 lines against a 6,643,522 ceiling. Its main parent041c3b7164636b25d9e7bf9aa3c14058c507d408already has 6,643,257 lines against a 6,643,250 ceiling. Exact Git LF comparison verifies this PR adds 272 lines and exactly 272 allocation credit, with the shared scalar unchanged. The overage is retained as a deferred blocker. The canonical classifier calls it new against an older passing scheduled main; this attribution uses the actual CI main parent.5ef2ef59edee69d1597d7aedcc1ec12b08c6a2ffcompleted through P2 with no actionable findings. An earlier pass correctly flagged the unrepaired index version of the mention fence while accepting the working-tree correction; the fix was then staged and reviewed. Local ClawSweeper was unavailable. The completed hosted follow-up reviewed source head4646580a4953e6b600ca29624590ebe49f1446b5, accepted the compiled runtime/final-effect proof, and reported no findings or before-merge requests. The final review additionally covers the later CI corrections inf872177f2befa67b68399502fc5e07e94009493b.Runtime proof uses a separately source-built native transport and deterministic external mail, app and model services in an isolated Linux VM. It does not qualify npm distribution, a live model provider, or deployed services. Loader browser glue/WASM was reused from the retained fixture rather than rebuilt in this campaign. No live services were changed.
Sanitized compiled CLI runtime receipts
Each terminal is selected from the actual
agent.waitresponse for the original queued run ID. File outcomes were checked independently in the retained workspace. External services are fixtures, with the limits described above.{"scenario":"valid-replay","oldPid":996,"newPid":1416,"oldExit":{"code":0,"signal":null},"queuedRunIds":["c006cc69-a3c8-4d90-b635-2c049661bbda","fec3ea68-c821-4dab-ba8f-46f021f613f7"],"terminal":{"runId":"fec3ea68-c821-4dab-ba8f-46f021f613f7","status":"ok","stopReason":"stop"},"independentOwnerWrite":true,"exactQueuedFiles":2,"firstEffectPresentAtSecondDispatch":true} {"scenario":"member-removal","oldPid":3812,"newPid":4240,"oldExit":{"code":0,"signal":null},"queuedRunIds":["a063478b-d79b-4be5-aa7d-1e436acf99de"],"terminal":{"runId":"a063478b-d79b-4be5-aa7d-1e436acf99de","status":"error","stopReason":"rpc"},"independentOwnerWrite":true,"queuedWritePresent":false,"originalAppDenial":"unavailable","providerClosedBeforeRelease":true,"freshRemovedMemberDenied":true} {"scenario":"role-downgrade","oldPid":2395,"newPid":2819,"oldExit":{"code":0,"signal":null},"queuedRunIds":["2567acec-2829-4386-a6ba-3ad879850970"],"terminal":{"runId":"2567acec-2829-4386-a6ba-3ad879850970","status":"error","stopReason":"rpc"},"independentOwnerWrite":true,"queuedWritePresent":false,"originalAppDenial":"unavailable","providerClosedBeforeRelease":true,"freshViewerReadOnly":true} {"scenario":"app-revocation","oldPid":99,"newPid":522,"oldExit":{"code":0,"signal":null},"queuedRunIds":["a1e4b477-d0de-4fe3-ad0b-84184932ba44"],"terminal":{"runId":"a1e4b477-d0de-4fe3-ad0b-84184932ba44","status":"error","stopReason":"rpc"},"independentOwnerWrite":true,"queuedWritePresent":false,"originalAppDenial":"grant_revoked","providerClosedBeforeRelease":false,"newCallDeniedBeforeRelease":true}