Skip to content

fix(gateway): continue on Gateway with pending offline results - #147390

Merged
obviyus merged 6 commits into
mainfrom
bugloop/continue-on-gateway-pending-result
Sep 13, 2026
Merged

obviyus merged 6 commits into
mainfrom
bugloop/continue-on-gateway-pending-result

Conversation

@obviyus

@obviyus obviyus commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #146012. Supersedes #146205 by @MasterSwords1. Thanks @jalehman for the report. The contributor's four commits retain their authorship.

What Problem This Solves

Continue on Gateway fails after confirmation when an offline device session has a pending workspace result, leaving the session blocked.

User Impact

Confirmed abandonment returns the session to local use. A fresh turn completes, and normal deletion archives its transcript. Ordinary moves still preserve pending results. Unsynced device work can be lost, as the existing confirmation warns.

Why This Change Was Made

The durable move intent is the single owner of the abandonment decision. It permits the pending-result drain; result recovery yields to it, and existing teardown retires the exact result and claim. The placement coordinator orders moves against recovery. No schema, migration, configuration, protocol, or dependency changes.

Tests now cover the full user flow and explicit fixture cleanup, removing overlapping handler tests and shutdown-error suppression. The correction commits remove 269 net lines from the contributor version. Remaining growth supplies three real Gateway regressions.

Evidence

Real Gateway capture, using the same exact-source sessions.move request with target: {kind: "gateway"} and abandonSource: true:

Main a2b2391e3538 This change
UNAVAILABLE: Cannot drain session … with a pending cloud workspace result ok: true, placement.state: local
Original claim and pending result remain Pending result and move intent gone; old claim/result rejected
Recovery action blocked One fresh reply: RECOVERED_SESSION_OK; deletion returns deleted: true with a readable transcript archive

Commands: pnpm openclaw gateway call sessions.move, then chat.send, agent.wait, chat.history, and sessions.delete. The ordinary-move negative case still rejects. The old device cleanup record remains until its exact stop is acknowledged.

Fresh two-parent merge proof: candidate 0801a11ab50c + main 6f58faf3eb0d → ec30ae86f2439. The repository CI test runner (node --import tsx scripts/ci-run-node-test-shard.mts) passed 146 tests in 7 files, using the Gateway core, server, and isolated-server configurations. Coverage includes move/store ownership, forced abandonment, recovery coordination, startup, fresh turns, and archived deletion. Formatting, changed-file lint, line limits, assertion safety, unused exports, and architecture checks pass. Typechecking remains with CI.

Startup cases prove database reopen plus in-process Gateway startup, including an already-failed placement with a different error. No physical-device shutdown or operating-system crash claim.

Reviewed proof scope

The read-only review found no blocking source or test correction at 0801a11ab50cdf94e514951b36b68793bb58a0e5.

Consumers

Confirmed sessions.move and startup recovery share the durable abandonment decision. Fresh chat turns and session deletion consume the resulting local placement; ordinary moves retain their existing pending-result guard. Session-change events refresh the existing placement projection.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 13, 2026
@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 147390
head: 0801a11
scope: owner-review

@obviyus
obviyus marked this pull request as ready for review September 13, 2026 20:41
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 4:47 PM ET / 20:47 UTC.

ClawSweeper review

What this changes

Allows confirmed abandonment of offline-device sessions with pending workspace results, restores interrupted abandonment during startup, and adds recovery-through-deletion regression coverage.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main and v2026.9.4. The reviewed patch preserves ordinary-move safeguards and addresses the reported recovery failure without introducing a blocking defect.

Priority: P0
Reviewed head: 0801a11ab50cdf94e514951b36b68793bb58a0e5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant Gateway evidence, meaningful negative coverage, and no blocking correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied Gateway capture exercises sessions.move through the changed placement owners and records local recovery, stale-claim/result rejection, a fresh reply, and archived deletion; inspected regression coverage additionally establishes database-reopen startup scenarios without claiming physical-device shutdown.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied Gateway capture exercises sessions.move through the changed placement owners and records local recovery, stale-claim/result rejection, a fresh reply, and archived deletion; inspected regression coverage additionally establishes database-reopen startup scenarios without claiming physical-device shutdown.
Evidence reviewed 9 items Verified introduced production changes: The merge-base comparison introduces only the abandonment-specific drain allowance, pending-result recovery handoff, and failed-placement error alignment in production. The verified test merge contains the same production changes against its main parent.
Current main still has the defect: The current-main move transaction calls the pending-result drain without the allowance, so explicit abandonment still fails before reaching result retirement.
Latest release remains affected: The supplied latest release, v2026.9.4, contains the same drain call without the abandonment allowance.
Findings None None.
Security None None.

How this fits together

Gateway placement management decides whether a session runs locally or on a worker device. It coordinates move requests, pending workspace results, and worker cleanup before allowing subsequent conversation turns.

flowchart TD
  A[Confirmed recovery request] --> B[Validate exact offline device]
  B --> C[Persist abandonment decision]
  D[Pending workspace result] --> C
  C --> E[Retire result and worker authority]
  E --> F[Resume session on Gateway]
  E --> G[Retain remote cleanup until acknowledged]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +7, Tests +424. Total +431 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 8 1 +7
Tests 4 484 60 +424
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 492 61 +431

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +7 lines; tests net +423; test routing +1 Production growth is bounded to the existing recovery owners; most growth supplies three Gateway lifecycle scenarios and negative regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #146012
Summary: This PR is a candidate repair for the documented drain-before-abandon failure and adopts the earlier contributor implementation.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep the existing Continue on Gateway recovery action owner-fenced and usable with pending results, while preserving ordinary reconciliation and deferred physical-device cleanup.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: an exact-source abandonment request with a pending result reaches the unconditional drain rejection on current main; the linked report supplies the matching live failure. This review did not execute current main.

Is this the best way to solve the issue?

Yes. Passing the existing drain allowance only for confirmed abandonment and letting its durable owner control recovery is a narrow repair that preserves ordinary-move safety.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b4a89e8ad2bd.

Labels

Label changes:

  • add P0: The advertised in-product recovery action leaves affected sessions blocked, and the demonstrated workaround requires privileged lifecycle commands and ownership inspection.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied Gateway capture exercises sessions.move through the changed placement owners and records local recovery, stale-claim/result rejection, a fresh reply, and archived deletion; inspected regression coverage additionally establishes database-reopen startup scenarios without claiming physical-device shutdown.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied Gateway capture exercises sessions.move through the changed placement owners and records local recovery, stale-claim/result rejection, a fresh reply, and archived deletion; inspected regression coverage additionally establishes database-reopen startup scenarios without claiming physical-device shutdown.

Label justifications:

  • P0: The advertised in-product recovery action leaves affected sessions blocked, and the demonstrated workaround requires privileged lifecycle commands and ownership inspection.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied Gateway capture exercises sessions.move through the changed placement owners and records local recovery, stale-claim/result rejection, a fresh reply, and archived deletion; inspected regression coverage additionally establishes database-reopen startup scenarios without claiming physical-device shutdown.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied Gateway capture exercises sessions.move through the changed placement owners and records local recovery, stale-claim/result rejection, a fresh reply, and archived deletion; inspected regression coverage additionally establishes database-reopen startup scenarios without claiming physical-device shutdown.

Evidence

What I checked:

  • Verified introduced production changes: The merge-base comparison introduces only the abandonment-specific drain allowance, pending-result recovery handoff, and failed-placement error alignment in production. The verified test merge contains the same production changes against its main parent. (src/gateway/worker-environments/placement-move-intent.ts:491, 11210665754f)
  • Current main still has the defect: The current-main move transaction calls the pending-result drain without the allowance, so explicit abandonment still fails before reaching result retirement. (src/gateway/worker-environments/placement-move-intent.ts:485, b4a89e8ad2bd)
  • Latest release remains affected: The supplied latest release, v2026.9.4, contains the same drain call without the abandonment allowance. (src/gateway/worker-environments/placement-move-intent.ts:485, 3a9d69db306c)
  • Existing authorization and retirement owners: The move barrier checks current session authority before admission and after partial persistence. Abandonment retains exact source checks; pending-result retirement rechecks the result owner within its transaction, and tool-state closure waits for running operations before clearing authority. (src/gateway/server-worker-placement-move-barrier.ts:60, 0801a11ab50c)
  • Recovery ownership and negative coverage: Pending-result recovery yields to the existing durable abandonment decision. Reviewed tests cover results pending before and after move admission, ordinary-move refusal, stale-result rejection, conflicting retries, and unavailable versus available device sources. (src/gateway/worker-environments/placement-move-abandon.test.ts:343, 0801a11ab50c)
  • After-fix Gateway evidence: The supplied PR-body snapshot reports an actual sessions.move capture changing from UNAVAILABLE to local placement, followed by one RECOVERED_SESSION_OK reply and readable archived deletion. The inspected server test exercises those registered RPCs with real Gateway and SQLite owners, a mock model endpoint, and a synthetic offline device. Its two startup cases explicitly cover database reopen and in-process startup, not physical-device shutdown or an operating-system crash. The body reports 146 passing tests; this read-only review did not execute them. (src/gateway/server.placement-abandonment.test.ts:226, 0801a11ab50c)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@obviyus
obviyus merged commit b7fb84e into main Sep 13, 2026
268 checks passed
@obviyus
obviyus deleted the bugloop/continue-on-gateway-pending-result branch September 13, 2026 21:03
@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @MasterSwords1!

Proof: Confirmed offline-device recovery returns to local use, completes a fresh reply, and deletes the session with a readable transcript archive. Ordinary moves still preserve pending results.

  • Bug: Continue on Gateway failed when an offline device had a pending workspace result.
  • Fix: The existing abandonment decision now retires that exact result and claim before restoring local ownership.
Before After
Confirmed recovery fails and leaves the session blocked Recovery completes; a fresh turn and archived deletion succeed

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…law#147390)

Related: openclaw#146012. Supersedes openclaw#146205 by @MasterSwords1. Thanks @jalehman for the report. The contributor's four commits retain their authorship.

## What Problem This Solves

**Continue on Gateway** fails after confirmation when an offline device session has a pending workspace result, leaving the session blocked.

## User Impact

Confirmed abandonment returns the session to local use. A fresh turn completes, and normal deletion archives its transcript. Ordinary moves still preserve pending results. Unsynced device work can be lost, as the existing confirmation warns.

## Why This Change Was Made

The durable move intent is the single owner of the abandonment decision. It permits the pending-result drain; result recovery yields to it, and existing teardown retires the exact result and claim. The placement coordinator orders moves against recovery. No schema, migration, configuration, protocol, or dependency changes.

Tests now cover the full user flow and explicit fixture cleanup, removing overlapping handler tests and shutdown-error suppression. The correction commits remove 269 net lines from the contributor version. Remaining growth supplies three real Gateway regressions.

## Evidence

Real Gateway capture, using the same exact-source `sessions.move` request with `target: {kind: "gateway"}` and `abandonSource: true`:

| Main `a9d0dc39c9e8` | This change |
| --- | --- |
| `UNAVAILABLE: Cannot drain session … with a pending cloud workspace result` | `ok: true`, `placement.state: local` |
| Original claim and pending result remain | Pending result and move intent gone; old claim/result rejected |
| Recovery action blocked | One fresh reply: `RECOVERED_SESSION_OK`; deletion returns `deleted: true` with a readable transcript archive |

Commands: `pnpm openclaw gateway call sessions.move`, then `chat.send`, `agent.wait`, `chat.history`, and `sessions.delete`. The ordinary-move negative case still rejects. The old device cleanup record remains until its exact stop is acknowledged.

Fresh two-parent merge proof: candidate `0801a11ab50c` + main `3eafa82bb6c6` → `ec30ae86f2439`. The repository CI test runner (`node --import tsx scripts/ci-run-node-test-shard.mts`) passed **146 tests in 7 files**, using the Gateway core, server, and isolated-server configurations. Coverage includes move/store ownership, forced abandonment, recovery coordination, startup, fresh turns, and archived deletion. Formatting, changed-file lint, line limits, assertion safety, unused exports, and architecture checks pass. Typechecking remains with CI.

Startup cases prove **database reopen plus in-process Gateway startup**, including an already-failed placement with a different error. No physical-device shutdown or operating-system crash claim.

## Reviewed proof scope

The read-only review found no blocking source or test correction at `0801a11ab50cdf94e514951b36b68793bb58a0e5`.

- The real Gateway proof covers confirmed abandonment, one fresh reply, and exact-session deletion with a readable transcript archive. Ordinary moves still reject the pending result.
- The standalone capture used the same three production blobs as the final head. All three maintained full-flow cases also passed on merge `ec30ae86f24390d69e7af606aa7c50cc9683107a`, with candidate `0801a11ab50cdf94e514951b36b68793bb58a0e5` and main `3eafa82bb6c63303b7d4341ce8cbe82b61b98c9c` as parents. The selected suite passed 146 tests in seven files.
- Recovery coverage means database reopen plus in-process Gateway startup, including an already-failed placement with a different error. It does not claim a browser click, an operating-system crash, or physical-device shutdown.
- The old device cleanup record remains until its exact stop is acknowledged. The tests use an explicit synthetic acknowledgement only during teardown.
- The original contributor's four commits retain their authorship. Credit remains with @MasterSwords1 for openclaw#146205 and @jalehman for openclaw#146012. Closure of openclaw#146205 remains a landing step.

## Consumers

Confirmed `sessions.move` and startup recovery share the durable abandonment decision. Fresh chat turns and session deletion consume the resulting local placement; ordinary moves retain their existing pending-result guard. Session-change events refresh the existing placement projection.

Co-authored-by: MasterSwords1 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
@fuller-stack-dev

Copy link
Copy Markdown
Member

@obviyus — current-owner coordination for the real Gateway regression introduced in #147390 (preserving the original contributor attribution).

The existing #149581 CI run 35047985200 / job 104642118377 now blocks that PR and dependents #149585/#149587 with three failures in src/gateway/server.placement-abandonment.test.ts:

  • First full-flow case: 90s timeout.
  • Second: recursive createNodeWorkerTunnelManager spy, RangeError at line 99.
  • Third: SESSION_MUTATION_AUTHORIZATION_CHANGED from the fresh chat.send.

The fixture is unchanged on current main: Git blob d3ad8d81094b6dbc17798dba95c2cad235b3a9d3. Its per-case spy captures the current export, and restoration happens in an async finally after Gateway shutdown. The timeout/cleanup overlap is a lead for the recursive-spy failure, not a verified common root cause; the authority-change failure needs its own exact-session analysis.

Please identify any already-active repair/checkout and take the smallest follow-up through review, the real Gateway cases, and required CI/native landing, or explicitly delegate a bounded repair if you are no longer its writer. Keep actual shutdown/child settlement, one fresh reply, pending-result retirement, archived deletion, and mutation-authority assertions; no timeout increase, fake success, or production guard weakening. We will consume the canonical correction, not publish a competing fixture rewrite.

No test rerun, dependency install, gateway source edit, or duplicate repair PR was started for this handoff. The saved failing log was reused (SHA256 c41f8338801cd3343de8cde7c4d9a21a59887cedc07134c4380bd6987f8e6f00).

fuller-stack-dev added a commit that referenced this pull request Sep 16, 2026
Keep teardown inside the original 90-second body deadline and join it before the next case acquires shared state. Preserve the fixture scenarios and assertions introduced by obviyus in #147390. Add a source-bound cancellation regression, forward context-local expect, and use the existing typed deferred owner.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…49668)

Keep teardown inside the original 90-second body deadline and join it before the next case acquires shared state. Preserve the fixture scenarios and assertions introduced by obviyus in openclaw#147390. Add a source-bound cancellation regression, forward context-local expect, and use the existing typed deferred owner.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants