Repository navigation
fix: recover cloud sessions across restart and cancellation - #133728
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 4:14 PM ET / 20:14 UTC. ClawSweeper reviewWhat this changesThe PR adds durable browser handoff receipts, revalidates worker-tool authority around Gateway calls, relaxes safe workspace recovery reconciliation, and records the filesystem mode actually applied to bootstrap artifacts. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer review: the owner-bound recovery design appears coherent and no introduced defect was found, but supplied final-head checks were incomplete and local current-main comparison could not finish after the partial clone’s network fetch failed. Priority: P1 Review scores
Verification
How this fits togetherBrowser clients recover pending chat input through Gateway history, while cloud workers execute delegated tool requests through placement and run-claim authority. The changes affect duplicate-input prevention, restart recovery, worker side effects, workspace reconciliation, and bootstrap packaging. flowchart LR
A[Browser chat client] --> B[Gateway chat history]
B --> C[Input custody receipts]
C --> D[Restart recovery]
E[Worker tool request] --> F[Placement turn authority]
F --> G[Gateway side effect]
H[Workspace snapshot] --> I[Recovery reconciliation]
Decision needed
Why: The patch changes durable session custody and privileged worker-side effects, and it is explicitly maintainer-routed. Before merge
Agent review detailsSecurityNone. PR surfaceSource -7, Tests +614, Docs 0, Other +4. Total +611 across 51 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the single live-owner capability path and confirm the final merge candidate still passes restart, cancellation, and browser-handoff coverage before merge. Do we have a high-confidence way to reproduce the issue? Yes, at source level: focused tests define controlled custody, restart, cancellation, and authority-revocation scenarios, but this read-only review did not execute them at the final head. Is this the best way to solve the issue? Likely yes: the patch makes existing custody and live-authority owners authoritative rather than adding a downstream replay fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8558bb57ece1. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (22 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review The latest finding is addressed at |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Adopt the exact fixture from #134207 to resolve the concurrent CI repair conflict without changing production code. Co-authored-by: Shakker <[email protected]>
|
Merged via squash.
|
…#133728) * fix(gateway): harden cloud session recovery * fix(gateway): fence worker tools after cancellation * fix(gateway): return exact retained input receipts * fix(protocol): keep input receipts additive * docs(changelog): note cloud session recovery * chore(changelog): leave release notes to release owner * fix(gateway): normalize optional continuation scope * style(gateway): satisfy cloud authority lint * test: align cloud recovery fixtures and native receipt client * test: preserve receipt and send custody expectations after rebase * fix: preserve bootstrap permissions during concurrent staging * fix(workers): preserve child dispatch authority through startup * test(workers): use the leased service projection in startup fixture * test: keep sandbox prompt fixture on its prepared provider handle * test: correct channel recovery fixtures for CI * test: align recovery fixture with main Adopt the exact fixture from openclaw#134207 to resolve the concurrent CI repair conflict without changing production code. Co-authored-by: Shakker <[email protected]> * test: isolate source replies and await terminal settlement * test: synchronize maintenance lock publication fixtures * refactor: simplify workspace transfer authorization checks * fix: align bootstrap archive repair with main * test: isolate context tooltip geometry from lazy media * test: use canonical registry in worker startup fixture --------- Co-authored-by: Shakker <[email protected]>
Fixes #131713
What Problem This Solves
Real cloud-session testing exposed several failures at shared lifecycle boundaries: restart recovery rejected legitimate workspace drift; a lost browser ACK could leave a retained input marked unconfirmed; closed parent authority could outlive awaited worker provisioning; concurrent bootstrap packaging could reject its own archive under a restrictive process mask; and Gateway startup dropped the authorization callback that should tear down a cancelled child allocation.
What Changed
inputConsumptionsprojection alongside the additiveinputReceiptsunion, using one query. Retained interrupted input remains visible and never runs automatically.No configuration, SQLite schema/version, index, retention, migration, protocol version, fallback, retry, or timeout was added. Production code is net smaller.
Live Evidence
Current head: 865b6da, following the c8f513 integration of main 44888f1. The final live runtime is ac6b19d. The intervening d6a3/dfe55 fixes changed only tests, but the final main integration also incorporates upstream runtime changes; this is not claimed as an exact-head live run. The c8f513 integration conflict retained main’s prompt fixture verbatim. Main’s chat-history snapshot and package-lifecycle-marker changes were inspected in the combined modules; all 8 history + 31 bootstrap/bundle/installer tests passed on the integrated candidate. Workspace recovery, browser custody and worker authority remain unchanged; bootstrap now follows main’s canonical implementation described below. Build identity was not rewritten.
Final cancellation proof: PASS. Real AWS/OpenAI run, with execution-identity auditing disabled: the parent successfully executed the exact requested command, then began child provisioning. Exact-run Stop was confirmed at 10:15:46 UTC. The late child allocation was destroyed at 10:20:33 with no attachments. Observation continued for 65 seconds after teardown, with zero child tasks, model admissions, transcript messages, tool authorities, or observed turn claims. This is model/RPC and provider-release proof; direct child filesystem absence is not claimed.
Positive browser controls: PASS. After Stop, Chrome sent another real OpenAI turn through the same parent; its command wrote the expected file and completed in six seconds. Gateway PID 25446 was then SIGKILLed and restarted as PID 30040. Chrome reconnected automatically. The next six-second turn read the pre-crash file and wrote a new one. Exact tool calls, successful results, and
openai/gpt-5.4-miniwere checked in the canonical transcript. An allowed child subsequently provisioned, executed its command, and returnedALLOWED_CHILD_DONE; parent-to-childsessions_sendalso succeeded. Both workers reclaimed through the normal Gateway owner. All worker environments are terminal without attachments, the test Gateway lease is released, and temporary credential files are removed.Historical lost-ACK and restart proof: AWS run on ba1a7d72 exercised restart with Gateway-added identity files and an attachment-backed initial send whose ACK was dropped before Gateway termination. Reload showed exactly one retained input, no unconfirmed alert, an enabled composer, and no active run. A real OpenAI follow-up completed in seven seconds. This evidence retains its actual revision; it is not described as a later exact-head run.
Captures contain synthetic task data only.
Root-Cause Proof and Verification
The live 6766 build failed before allocation: at umask 077, 145 of 10,381 archive entries had matching bytes but incorrect modes. Node v24.18.1's getter briefly clears the process mask, racing concurrent file creation. Raw-parent inspection ties the concurrent staging change to #133725. The earlier branch repair passed the full artifact at masks077 and022; its controlled32-file regression failed before the fix and all31 owner/sibling tests passed afterward. That evidence remains pinned to its actual earlier revision. Main subsequently landed an independent repair in #134043, and the final branch adopts its producer and tests byte for byte at588219879f97. It never reads the process mask during preparation and records the mode the filesystem actually applied. The final adopted implementation passes all30 bootstrap/bundle/installer cases both normally and under077; independent review is clean. Its one metadata stat perPOSIX file is explicit, without a throughput claim. Main’s separately recorded compiled10362-entry077 evidence is prior canonical-implementation proof, not a fresh run from this task. The local distribution identifies an older build, so no current full-build or exact-final-head live claim is made.
The 6adb live run exposed a separate startup composition failure: after Chrome Stop, no child model task ran, but the late allocation became active and retained its lease. That failed run is not passing evidence. Startup's one-argument adapter discarded dispatch's authorization callback; forwarding the complete argument tuple reconnects the existing owner checks. The adapter predated its #133176 move. A real startup/executor composition regression fails before this repair and passes afterward; all 43 spawn/send tests pass. The final live run above verifies actual provider teardown.
Earlier focused revisions passed 168 Gateway tests, 6 protocol tests, 24 pending-input tests, and 439 Control UI tests. The integrated branch passed CI at 6766b029. Later fixes retain their own proof: current startup composition cases pass; the final service-projection/lease fixture correction removes its type error; full-branch and all follow-up Codex reviews have no accepted/actionable findings. Unrelated local Logger dependency type errors are not represented as a passing local typecheck. Hosted CI validates the final head.
A bounded CI cleanup fixed a sandbox-prompt fixture introduced on main by #133715; main subsequently incorporated the equivalent correction and its exact fixture is retained in the merge: its prepared provider handle omitted the model ID and inadvertently loaded the real provider runtime. Adding the matching ID preserves all sandbox assertions. Full file 12/12 and neighboring prompt file 11/11 pass. Same-host before/after case timings: 5.111s→243ms and 290ms→5ms. Whole-file wall time 58.97s→55.38s and peak RSS 1.849GB→1.844GB include differing import/build costs; the CI 120-second timeout was not reproduced locally. No timeout or assertion was weakened. Fresh review is clean.
Final-head CI: PASS. Both the ordinary PR run, attempt 3 and the repository-native hosted capacity fallback completed successfully on
865b6da18e7346be33777b0dc6eb5adec17804ec. GitHub now reports the requiredopenclaw/ci-gateas SUCCESS. UI, type checks, Gateway, updater, extension lint, Windows, Android, iOS Debug/Release builds, lifecycle and Watch simulator tests, and combined screenshot evidence pass. This answers the latest ClawSweeper exact-head rank-up request.CI retry history is preserved: the manual gate initially passed but was omitted from GitHub's effective PR rollup despite a valid PR association and matching App. The ordinary run's attempt 1 stalled on a queued iPad job. Attempt 2 acquired hosted macOS through the existing retry policy, but Fastlane timed out reading iPhone build settings before any app build/test. Its locked 2.238.0 source confirms the observed 3/6/12/24-second deadlines; the underlying Xcode delay is unproven. The still-running iPad job was cancelled so both screenshot families could retry together. Attempt 3 passed both families and the same-attempt evidence reducer. No runner setting, timeout, gate, assertion, limit or source was changed for these retries.
The tooltip fixture grouped context and unrelated media messages into one assistant run. Its image-only wait could not prevent lazy video metadata from changing the measured group during hover. A controlled original-order delayed-WebM reproduction fails before the fix (video and group both grow410.078125px) and passes afterward. Giving the context fixture its canonical run identity separates the groups and deletes the unrelated image wait: +2/-5 test lines, zero production changes. The complete112-case browser file, scoped formatting/lint and independent review pass; all geometry, top-layer, pinning, keyboard and dismissal assertions remain unchanged. The baseline separately encountered a cold-navigation MCP fixture error; the candidate passed that unchanged case, without claiming it repaired.
The hosted extension-lint job failed before lint during a Matrix crypto0.6.6 binary download (
ECONNRESET); its upstream catch block also references an undefined variable. Direct exact-tag source confirms that error handling defect. No dependency override or source workaround was added; the final-head hosted run completed both installation and lint successfully. This does not claim to repair the upstream error handler.Main #134088 concurrently broadened Gateway startup to require the full plugin registry. Exact previous-head CI caught our partial composition fixture with TS2740. Reusing one stable
createEmptyPluginRegistry()instance matches main’s startup fixtures and removes another three test lines. The actual hosted failure is retained; the merged-contract target typecheck has zero diagnostics, both existing active/cancelled-parent composition cases pass, and scoped lint/format plus independent review pass. The preceding head’s full hosted UI suite also passes after the tooltip repair.The last merge-time lint failure combined this PR with main #134200: the transfer service reached707 lines under a700-line rule. The final simplification collapses a Boolean-only owner wrapper and chooses the closed download route union directly, preserving lookup order, exact context identity, blob hash membership and manifest matching. The same three-way merged-file lint check fails before and passes afterward; no limit was raised. All30 service/credential/pack/retention/revocation tests, scoped lint and independent review pass. A subsequent bootstrap conflict is resolved by adopting main #134043's two files verbatim; all30 bootstrap/bundle/installer tests pass normally and under umask077.
The hosted fallback also exposed an updater fixture race: a fresh shell plus a30ms sleep had to publish its lock owner within the production200ms window. An injected300ms shell-start delay makes both original missing/empty cases fail with the CI error. Publishing real owner JSON at the incomplete-read retry boundary makes both cases pass under that same delay; all87 updater tests pass. Production behavior and budgets are unchanged, and23 test lines are removed. Formatting, scoped lint and independent review pass.
Earlier CI fixture repairs retain their assertions and timeouts. The terminal sandbox-denial test now uses the existing helper to await the same Code Mode run, without replay; its full file passes30/30. The WebChat source-reply fixture declares its empty external-channel catalog instead of discovering real bundled metadata through inherited channel stubs; its full file passes9/9, with first-case time12.887s→1.872s. A phase probe had measured5.070s in construction,1.463s in execution and about6ms per final projection. The CI120s timeout was not reproduced locally, and total wall-time changes include varying import/build load. Main's Promise-executor and channel WebSocket/raw-SecretRef fixture fixes are retained; the two focused Gateway files passed7 tests, and the subsequently adopted exact #134207 fixture passed both cases.
One Gateway cancellation fixture failed with
ENOTEMPTYduring cleanup after its behavioral assertions passed. The unchanged six-case baseline and a diagnostic run of the full225-file/4109-test Gateway shard passed locally, with no post-cleanup database reopen observed. Temporary diagnostics were removed. This intermittent teardown race remains an explicit follow-up; no speculative retry, timeout, suppressed error or production repair was added, and a passing CI rerun will not be called proof of repair. Earlier UI keyboard-readiness and Cron-timeout failures likewise remain recorded rather than relabeled harmless.Local broader static checks are not represented as green: unchanged installed Logger types block core/declaration checks, and the updater test-root check also reports unchanged Telegram dependency types. Corrected files have no remaining diagnostics, scoped lint/format pass, and hosted checks remain authoritative. Earlier GitHub checkout-authentication failures and trusted-base fetch timeouts occurred before tests/scanning; targeted retries recovered them. The dfe55 CI run completed successfully after retrying only those checkout failures. No workflow or security guard was weakened.
Review Follow-Through and Scope
Maintainer disposition: The user's explicit direction to land follows the discussion and live proof of these recovery semantics: retain exact-session custody, never replay an unconfirmed input automatically, reconcile recovered workspaces through the canonical owner, and revoke worker authority after cancellation. That standing direction accepts the reviewed contract and addresses ClawSweeper's maintainer-confirmation request; the subsequent 20:14 UTC exact-head review has no source/security findings, and its remaining CI rank-up request is now satisfied. No additional schema or configuration change is introduced or authorized by this disposition.
The lead also completed the current-main comparison that the reviewer could not finish after a partial-clone DNS failure: through main961f927be8f, the only later overlapping changes are retained-input chronology tests and background-session documentation. The corresponding projection and submission owners were inspected directly; canonical receipt lookup and placement recovery handoff remain intact.
ClawSweeper's exact final-effect evidence requests are answered by the final live cancellation and positive controls above. The earlier receipt fixture/rank-up findings are corrected. Its storage-surface detection does not correspond to a schema change: no schema, version, migration, index, or retention change exists in this diff. The lead directly inspected the Node getter implementation; a review worker's DNS failure did not replace that dependency proof. The integrated independent review raised one older-Gateway UI fallback suggestion, rejected after inspecting
ui/AGENTS.mdGateway Coupling and the enforced same-origin build admission: the UI ships with its Gateway and does not support version-skew compatibility. The external v4 response projection remains additive. No accepted/actionable findings remain; the reviewer’s finding and disposition are retained rather than represented as a clean reviewer result.Landed as bcf8e986c19d. Against the actual merge parent: production +385/-429 (net -44); tests/support +891/-275 (net +616); generated Swift +4/-0; docs +1/-1. Total +1281/-705 across 47 files. Main had already absorbed several overlapping fixes.
Against pinned review base 44888f1: production +394/-431 (net -37); tests/support +958/-314 (net +644); generated Swift +4/-0; docs +1/-1. Total +1357/-746 across 51 files.
Separate work remains explicit: #133735 owns prompt cancellation of in-flight provider allocation and late-allocation custody (#132471/#132514); #132027 owns the completed-model-result/finalization crash gap. #128792 tracks generic CLI admin-scope selection; server authorization remains intentional. The proof uses authenticated admin Stop and the real Control UI, without weakening that policy. Prompt-test import cost remains a separate performance follow-up, not a claimed cloud runtime improvement.