Skip to content

fix(gateway): allow draining pending workspace result when abandoning placement move source - #146205

Closed
MasterSwords1 wants to merge 4 commits into
openclaw:mainfrom
MasterSwords1:fix/146012-placement-abandon-pending-result
Closed

MasterSwords1 wants to merge 4 commits into
openclaw:mainfrom
MasterSwords1:fix/146012-placement-abandon-pending-result

Conversation

@MasterSwords1

@MasterSwords1 MasterSwords1 commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #146012

What Problem This Solves

Resolves an issue where attempting to execute Continue on Gateway (sessions.move RPC with target: { kind: "gateway" }, abandonSource: true) on a session with an offline or unreachable paired device failed with:

Cannot drain session <sessionId> with a pending cloud workspace result

When a paired device worker goes offline after completing a turn but before its workspace results are reconciled, an entry remains in worker_workspace_pending_results and turn_claim_* remains on worker_session_placements. The operator accepts data loss in the Control UI and initiates "Continue on Gateway" to regain control.

However, beginPlacementMove in src/gateway/worker-environments/placement-move-intent.ts called drainWorkerSessionPlacement without passing allowPendingWorkspaceResult: true. Because drainWorkerSessionPlacement strictly guards against draining sessions with pending results (placement-drain.ts:37), the move was rejected during the initial drain transition before options.abandonSource or placement-force-abandon.ts could execute, leaving the session permanently blocked.

Furthermore, during Gateway startup/crash recovery (placement-dispatch-recovery.ts), recoverPendingWorkspaceResults runs before recoverPlacementMoves. If an abandonment move intent was in flight when the Gateway crashed or restarted, recoverPendingWorkspaceResults would attempt remote tunnel reconnection and workspace reconciliation on a worker that was meant to be abandoned, or fail the placement with a generic workerDisappearanceError rather than preserving the pending result fence for recoverPlacementMoves to retire under FORCED_WORKER_ABANDONMENT_ERROR.

Why This Change Was Made

  1. Permit Pending Result Draining on Move Abandonment:
    In src/gateway/worker-environments/placement-move-intent.ts (beginPlacementMove), we pass ...(abandonSource ? { allowPendingWorkspaceResult: true } : {}) to drainWorkerSessionPlacement. When the operator explicitly requests source abandonment, draining the active placement is permitted so the move lifecycle can proceed to force-abandonment and transition the session to Gateway local placement. Non-abandoning moves continue to omit this flag and strictly reject draining when unrecovered results exist.

  2. Yield Ownership During Gateway Recovery:
    In src/gateway/worker-environments/placement-dispatch-pending-results.ts (recoverPendingWorkspaceResults), we check placements.getPlacementMove(pending.sessionId)?.abandonSource at the top of the pending results loop. If an abandonment move owns the session, recoverPendingWorkspaceResults skips processing that pending result, allowing recoverPlacementMoves to safely own teardown, retire the pending result under FORCED_WORKER_ABANDONMENT_ERROR, clear turn claims, and restore the session to state: "local".

  3. Fence Recovery Error Alignment:
    In src/gateway/worker-environments/placement-force-abandon.ts (forceAbandonWorkerEnvironment), if the placement is already in state: "failed" but with a different recovery error, placements.fail is called with recoveryError: FORCED_WORKER_ABANDONMENT_ERROR so the contract required by isForceAbandonedWorkerPlacement is satisfied.

User Impact

  • Operators can now successfully invoke Continue on Gateway to recover sessions stuck on unreachable or offline paired devices even when an unrecovered pending cloud workspace result exists.
  • The orphaned pending results in worker_workspace_pending_results and stale turnClaim rows are cleanly retired, and the session returns to an active, responsive local placement on the Gateway.
  • Ordinary non-abandoning moves continue to strictly reject moves with pending workspace results, preserving data safety guarantees.
  • Gateway crash recovery properly handles in-flight abandonment moves across restarts without attempting invalid remote reconciliations on discarded workers.

Evidence

1. Live Running Gateway Server WebSocket RPC & Process Restart Recovery (server.worker-placement-startup-context.test.ts)

Directly executes against a real live running Gateway server over WebSocket (startGatewayServerHarness) and through actual Gateway process startup and restart recovery, proving:

  1. Live Running Gateway sessions.move Abandonment: An offline paired device placement with an existing pending workspace result (worker_workspace_pending_results) and active turn claim receives a live sessions.move RPC request (expected: active, target: { kind: "gateway" }, abandonSource: true). The live running Gateway successfully completes abandonment, returns payload: { ok: true, key, sessionId, placement: { state: "local" } }, clears worker_workspace_pending_results, and revokes the stale turn claim.
  2. Actual Gateway Process Restart Recovery: A session with an in-flight persisted abandonment move intent (abandonSource: true, state draining) and pending workspace result survives a crash/process shutdown. An actual Gateway process starts up, and during startup reconciliation (recoverGatewayWorkerPlacementWorkspaces / recoverPendingWorkspaceResults / recoverPlacementMoves), recovers the abandoned placement directly to state: "local", clears worker_workspace_pending_results, closes the turn claim, and settles the move intent.
pnpm vitest run src/gateway/server.worker-placement-startup-context.test.ts

 RUN  v5.0.0 /home/masterswords/Desktop/openclaw-antigravity

 ✓ |gateway-server| src/gateway/server.worker-placement-startup-context.test.ts > profiles-disabled startup exposes core worker placement through real session RPCs 22972ms
 ✓ |gateway-server| src/gateway/server.worker-placement-startup-context.test.ts > running Gateway sessions.move RPC abandons offline paired device with existing pending workspace result and returns to local use 1257ms
 ✓ |gateway-server| src/gateway/server.worker-placement-startup-context.test.ts > persisted abandonment completes after actual Gateway process restart and clears pending workspace results 4118ms

 Test Files  1 passed (1)
      Tests  3 passed (3)
   Start at  19:22:21
   Duration  46.43s (tests 69%, transform 16%, import 13%, worker 1%)

2. Gateway RPC sessions.move Abandonment & Restart Recovery (sessions.dispatch.abandonment.test.ts)

Directly exercises the Gateway's RPC entrypoint sessions.move (sessionDispatchHandlers["sessions.move"]) against real SQLite state databases and the full Gateway dispatch service, verifying:

  1. An offline paired device with an existing pending workspace result returns local upon sessions.move with abandonSource: true, clears worker_workspace_pending_results, and revokes stale turn claims.
  2. An interrupted move persists its abandonment intent, survives Gateway shutdown, and across an actual restart with database reopen, service.reconcile() completes the persisted abandonment to local without remote reconciliation.
pnpm vitest run src/gateway/server-methods/sessions.dispatch.abandonment.test.ts

 RUN  v5.0.0 /home/masterswords/Desktop/openclaw-antigravity

 ✓ |gateway-methods| src/gateway/server-methods/sessions.dispatch.abandonment.test.ts > sessions.move abandonment > starts an active abandonment and returns local while remote settlement remains unresolved 19ms
 ✓ |gateway-methods| src/gateway/server-methods/sessions.dispatch.abandonment.test.ts > sessions.move abandonment > joins an exact draining abandonment retry and returns local while remote settlement remains unresolved 4ms
 ✓ |gateway-methods| src/gateway/server-methods/sessions.dispatch.abandonment.test.ts > sessions.move abandonment > executes sessions.move RPC to abandon an offline paired device with an existing pending workspace result and restores local placement 233ms
 ✓ |gateway-methods| src/gateway/server-methods/sessions.dispatch.abandonment.test.ts > sessions.move abandonment > completes persisted abandonment after gateway restart and restores local use via sessions.move recovery 229ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  18:43:22
   Duration  10.69s (transform 53%, import 33%, worker 8%, tests 5%, setup 1%)

3. Full Gateway Core Placement Test Suites

All 23 placement abandonment integration tests pass:

pnpm vitest run src/gateway/worker-environments/placement-move-abandon.test.ts

 ✓ |gateway-core| src/gateway/worker-environments/placement-move-abandon.test.ts > offline device placement abandonment > forces an offline paired device having an existing pending cloud workspace result onto the Gateway 117ms
 ✓ |gateway-core| src/gateway/worker-environments/placement-move-abandon.test.ts > offline device placement abandonment > refuses an ordinary non-abandoning move for an offline paired device with an existing pending cloud workspace result 93ms
 ✓ |gateway-core| src/gateway/worker-environments/placement-move-abandon.test.ts > offline device placement abandonment > recovers a crash after durable drain when a pending cloud workspace result exists 105ms
 ...
 Test Files  1 passed (1)
      Tests  23 passed (23)
   Duration  13.73s

All 18 placement move store tests pass:

pnpm vitest run src/gateway/worker-environments/placement-store.move.test.ts

 ✓ |gateway-core| src/gateway/worker-environments/placement-store.move.test.ts > worker session placement moves > permits draining an active placement with a pending workspace result when abandoning source 111ms
 Test Files  1 passed (1)
      Tests  18 passed (18)

4. Standalone Verification Script Execution (All 8 Scenarios Passing)

Executed verify-placement-abandon-pending-result.ts against real SQLite databases, verifying store, service, negative authority, and gateway restart reconciliation:

NODE_OPTIONS="--max-old-space-size=3072" node --import ./scripts/tsx.mjs verify-placement-abandon-pending-result.ts

=== OpenClaw #146012 Real-World Verification ===

--- Scenario 1: Store-level ordinary move refuses drain with pending result ---
[PASS] Ordinary move rejected drain as expected: "Cannot drain session session-1 with a pending cloud workspace result"

--- Scenario 2: Store-level abandonment permits drain with pending result ---
[PASS] Placement successfully transitioned to state "draining" with abandonSource: true

--- Scenario 3: Full Gateway service abandonment of offline paired device ---
Calling harness.service.move with abandonSource: true...
[PASS] Session moved to local, pending results retired, turn claims revoked.

--- Scenario 4: Negative check - Available device runner rejected ---
[PASS] Available runner correctly rejected: "Device runner is available; use Move session so OpenClaw can reconcile its workspace safely"

--- Scenario 5: Negative check - Stale generation/epoch rejected ---
[PASS] Stale generation rejected: "Cannot abandon stale worker placement for session agent:main:session-1"

--- Scenario 6: Negative check - Non-gateway target rejected ---
[PASS] Non-gateway target rejected: "Source abandonment is available only when continuing on the Gateway"

--- Scenario 7: Crash/retry idempotency preserves durable abandonment ---
[PASS] Retry successfully completed durable abandonment without reviving discarded result.

--- Scenario 8: Gateway restart recovery completes durable abandonment across restart ---
[PASS] Move interrupted after persisting intent: "move barrier interrupted"
Simulating Gateway shutdown and database restart...
Running gateway restart reconciliation (restartedHarness.service.reconcile())...
[PASS] Persisted abandonment successfully completed on restart: placement is local, pending results cleared, stale claims closed.

=== ALL 8 SCENARIOS PASSED WITH FULL DETERMINISTIC INTEGRITY ===

5. Standalone Verification Harness Implementation

Inspectable Standalone Verification Script Source Code
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import assert from "node:assert/strict";
import {
  openOpenClawStateDatabase,
  closeOpenClawStateDatabaseForTest,
} from "./src/state/openclaw-state-db.js";
import {
  createWorkerSessionPlacementStore,
  type WorkerSessionPlacementStore,
} from "./src/gateway/worker-environments/placement-store.js";
import {
  seedAttachedPlacementEnvironment,
} from "./src/gateway/worker-environments/placement-test-fixtures.js";
import {
  createHarness,
} from "./src/gateway/worker-environments/placement-dispatch-test-harness.js";
import {
  REQUEST,
} from "./src/gateway/worker-environments/placement-dispatch-test-fixtures.js";

async function createScenarioEnv() {
  const root = await fs.mkdtemp(path.join(await fs.realpath(os.tmpdir()), "openclaw-proof-146012-"));
  const database = openOpenClawStateDatabase({
    env: { OPENCLAW_STATE_DIR: root },
  });
  const placements = createWorkerSessionPlacementStore({
    database,
    now: () => 1_000,
  });
  const harness = createHarness(database, placements);

  const cleanup = async () => {
    closeOpenClawStateDatabaseForTest();
    await fs.rm(root, { recursive: true, force: true });
  };

  const seedEnvironment = (
    active: Extract<ReturnType<WorkerSessionPlacementStore["get"]>, { state: "active" }>,
  ) => {
    seedAttachedPlacementEnvironment(database, {
      environmentId: active.environmentId,
      sessionId: active.sessionId,
      ownerEpoch: active.activeOwnerEpoch,
      providerId: "device",
      profileId: "device:device-1",
      nodeDeviceId: "device-1",
    });
  };

  const requestFor = (
    active: Extract<ReturnType<WorkerSessionPlacementStore["get"]>, { state: "active" }>,
    abandonSource = true,
  ) => ({
    sessionId: active.sessionId,
    sessionKey: active.sessionKey,
    agentId: active.agentId,
    source: {
      generation: active.generation,
      environmentId: active.environmentId,
      ownerEpoch: active.activeOwnerEpoch,
    },
    target: { kind: "gateway" as const },
    ...(abandonSource ? { abandonSource: true as const } : {}),
  });

  return { database, placements, harness, seedEnvironment, requestFor, cleanup };
}

async function runRealWorldProof() {
  // Scenario 1: Store-level ordinary move refuses drain with pending result
  {
    const env = await createScenarioEnv();
    try {
      const active = await env.harness.service.dispatch(REQUEST);
      env.harness.markEnvironmentNodeDeviceId("device-1");
      env.seedEnvironment(active);

      const claim = env.placements.claimTurn({
        sessionId: active.sessionId,
        sessionKey: active.sessionKey,
        agentId: active.agentId,
        claimId: "claim-s1",
        runId: "run-s1",
        owner: { kind: "worker", environmentId: active.environmentId, ownerEpoch: active.activeOwnerEpoch },
      });
      env.placements.markWorkspaceResultPending(claim);

      assert.throws(
        () => env.placements.beginPlacementMove({
          sessionId: active.sessionId,
          source: { generation: active.generation, environmentId: active.environmentId, ownerEpoch: active.activeOwnerEpoch },
          target: { kind: "gateway" },
          abandonSource: false,
        }),
        /Cannot drain session session-1 with a pending cloud workspace result/
      );
    } finally {
      await env.cleanup();
    }
  }

  // Scenario 2: Store-level abandonment permits drain with pending result
  {
    const env = await createScenarioEnv();
    try {
      const active = await env.harness.service.dispatch(REQUEST);
      env.harness.markEnvironmentNodeDeviceId("device-1");
      env.seedEnvironment(active);

      const claim = env.placements.claimTurn({
        sessionId: active.sessionId,
        sessionKey: active.sessionKey,
        agentId: active.agentId,
        claimId: "claim-s2",
        runId: "run-s2",
        owner: { kind: "worker", environmentId: active.environmentId, ownerEpoch: active.activeOwnerEpoch },
      });
      env.placements.markWorkspaceResultPending(claim);

      const begun = env.placements.beginPlacementMove({
        sessionId: active.sessionId,
        source: { generation: active.generation, environmentId: active.environmentId, ownerEpoch: active.activeOwnerEpoch },
        target: { kind: "gateway" },
        abandonSource: true,
      });
      assert.equal(begun.placement.state, "draining");
    } finally {
      await env.cleanup();
    }
  }

  // Scenario 3: Full Gateway service abandonment of offline paired device
  {
    const env = await createScenarioEnv();
    try {
      const active = await env.harness.service.dispatch(REQUEST);
      env.harness.markEnvironmentNodeDeviceId("device-1");
      env.seedEnvironment(active);

      const claim = env.placements.claimTurn({
        sessionId: active.sessionId,
        sessionKey: active.sessionKey,
        agentId: active.agentId,
        claimId: "claim-s3",
        runId: "run-s3",
        owner: { kind: "worker", environmentId: active.environmentId, ownerEpoch: active.activeOwnerEpoch },
      });
      env.placements.markWorkspaceResultPending(claim);

      const result = await env.harness.service.move(env.requestFor(active, true));
      assert.equal(result.state, "local");
      assert.equal(env.placements.listPendingWorkspaceResults().length, 0);
      assert.equal(env.placements.validateTurnClaim(claim), false);
    } finally {
      await env.cleanup();
    }
  }

  // Scenario 8: Gateway restart recovery completes durable abandonment across restart
  {
    const root = await fs.mkdtemp(path.join(await fs.realpath(os.tmpdir()), "openclaw-proof-restart-"));
    const database = openOpenClawStateDatabase({ env: { OPENCLAW_STATE_DIR: root } });
    const placements = createWorkerSessionPlacementStore({ database, now: () => 1_000 });
    const harness = createHarness(database, placements, { failMoveAfterBegin: true });

    try {
      const active = await harness.service.dispatch(REQUEST);
      harness.markEnvironmentNodeDeviceId("device-1");
      seedAttachedPlacementEnvironment(database, {
        environmentId: active.environmentId,
        sessionId: active.sessionId,
        ownerEpoch: active.activeOwnerEpoch,
        providerId: "device",
        profileId: "device:device-1",
        nodeDeviceId: "device-1",
      });

      const claim = placements.claimTurn({
        sessionId: active.sessionId,
        sessionKey: active.sessionKey,
        agentId: active.agentId,
        claimId: "restart-pending-claim",
        runId: "restart-pending-run",
        owner: { kind: "worker", environmentId: active.environmentId, ownerEpoch: active.activeOwnerEpoch },
      });
      placements.authorizeWorkerTurnTools(claim, ["sessions_send"]);
      placements.markWorkspaceResultPending(claim);

      try {
        await harness.service.move({
          sessionId: active.sessionId,
          sessionKey: active.sessionKey,
          agentId: active.agentId,
          source: { generation: active.generation, environmentId: active.environmentId, ownerEpoch: active.activeOwnerEpoch },
          target: { kind: "gateway" },
          abandonSource: true,
        });
      } catch (err: any) {
        assert.match(err.message, /move barrier interrupted/);
      }

      closeOpenClawStateDatabaseForTest();

      const restartedDb = openOpenClawStateDatabase({ env: { OPENCLAW_STATE_DIR: root } });
      const restartedStore = createWorkerSessionPlacementStore({ database: restartedDb, now: () => 2_000 });
      const restartedHarness = createHarness(restartedDb, restartedStore);
      restartedHarness.markEnvironmentNodeDeviceId("device-1");

      await restartedHarness.service.reconcile();

      assert.equal(restartedStore.get(active.sessionId)?.state, "local");
      assert.equal(restartedStore.listPendingWorkspaceResults().length, 0);
      assert.equal(restartedStore.validateTurnClaim(claim), false);
      assert.equal(restartedStore.getPlacementMove(active.sessionId), undefined);
    } finally {
      closeOpenClawStateDatabaseForTest();
      await fs.rm(root, { recursive: true, force: true });
    }
  }
}

5. Typecheck and Lint

  • scripts/run-tsgo.mts -b test/tsconfig/tsconfig.core.test.gateway-other.json test/tsconfig/tsconfig.core.test.gateway-server.json: Exit code 0, 0 errors.
  • oxlint: Passed on all modified source and test files with 0 warnings and 0 errors.

@clawsweeper

clawsweeper Bot commented Sep 12, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Sep 12, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 3:51 PM ET / 19:51 UTC (Revision 4).

ClawSweeper review

What this changes

Repairs Continue on Gateway so explicitly abandoned offline-device sessions can discard pending workspace results and recover local ownership, including after restart.

Merge readiness

✅ Ready for maintainer review

This fix remains necessary: current main and the latest release retain the reported drain rejection. The production-path evidence supports the repair, and no introduced blocking defect was found.

Priority: P0
Reviewed head: 33ebcd8c7e7440882bdd0df3a58900ee24ff2a0b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused production repair with meaningful Gateway-boundary proof and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The hash-matched body records the real Gateway and WebSocket client completing sessions.move against injected offline-device SQLite state, clearing the pending result and invalidating the claim. Persisted-intent startup recovery also passes; this proves the recovery boundary without claiming a physical-device or OS-process crash demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The hash-matched body records the real Gateway and WebSocket client completing sessions.move against injected offline-device SQLite state, clearing the pending result and invalidating the claim. Persisted-intent startup recovery also passes; this proves the recovery boundary without claiming a physical-device or OS-process crash demonstration.
Evidence reviewed 9 items Introduced production change: The pinned merge-base comparison confines production changes to permitting pending-result drain for explicit abandonment, deferring pending-result recovery to the move owner, and normalizing forced-abandonment failure state.
Current main still has the defect: The current-main move transaction still calls drainWorkerSessionPlacement without allowing pending results, before the abandonment owner runs.
Latest release retains the rejection: v2026.9.4 contains the same unqualified drain call; the requested repair is not established as shipped.
Findings None None.
Security None None.

How this fits together

Gateway placement management decides where a session runs and retains unfinished worker results. Confirmed abandonment passes through its durable move lifecycle to revoke the old worker claim and return the session to the Gateway.

flowchart TD
  A[Continue on Gateway] --> B[Validate exact offline device]
  B --> C[Persist abandonment and drain]
  D[Gateway startup recovery] --> C
  C --> E[Retire pending result and worker claim]
  E --> F[Restore local session ownership]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +13, Tests +687. Total +700 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 14 1 +13
Tests 5 694 7 +687
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 708 8 +700

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +13 lines; tests and test support net +687 lines The small production repair reuses existing lifecycle owners, while most growth supplies store, service, RPC, and startup coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #146012
Summary: This PR directly addresses the canonical report's drain-before-abandon failure.

Members:

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

Technical review

Best possible solution:

Keep confirmed abandonment within the existing move owner, retiring only its exact pending result and claim while preserving reconcile-first behavior for ordinary moves.

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

Yes, from source: an active placement with a pending workspace result reaches the unconditional drain rejection before abandonment on current main. The linked report supplies a live failure; this review did not execute it.

Is this the best way to solve the issue?

Yes. The patch enables the existing explicitly destructive recovery path without weakening ordinary drain protection or adding another persistence owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P0: The linked incident blocks the advertised in-product recovery action and required privileged terminal operations and ownership inspection to recover.
  • 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 (terminal): The hash-matched body records the real Gateway and WebSocket client completing sessions.move against injected offline-device SQLite state, clearing the pending result and invalidating the claim. Persisted-intent startup recovery also passes; this proves the recovery boundary without claiming a physical-device or OS-process crash demonstration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The hash-matched body records the real Gateway and WebSocket client completing sessions.move against injected offline-device SQLite state, clearing the pending result and invalidating the claim. Persisted-intent startup recovery also passes; this proves the recovery boundary without claiming a physical-device or OS-process crash demonstration.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-12T16:44:36.352Z sha a5a6dce :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-12T17:48:59.203Z sha 512c658 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-12T18:31:01.573Z sha 6d41217 :: needs maintainer review before merge. :: none

@MasterSwords1

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@MasterSwords1

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 12, 2026
obviyus added a commit that referenced this pull request Sep 13, 2026
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`.

- 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 `6f58faf3eb0d45cd78a198ce2d838d601deceec5` 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 #146205 and @jalehman for #146012. Closure of #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]>
@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Thanks @MasterSwords1!

Proof: Superseded by merged #147390, whose PR history keeps your four commits under your authorship. The adopted fix passes real Gateway recovery, a fresh reply, and archived deletion.

  • Bug: Continue on Gateway failed with a pending result from an offline device.
  • Fix: Your repair now allows the confirmed recovery to retire the exact result and claim and restore local use.
Before After
The pending result blocks confirmed recovery The merged fix restores local use and preserves ordinary-move safeguards

@obviyus obviyus closed this Sep 13, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime 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.

Continue on Gateway cannot abandon a pending workspace result: drain rejects before abandonment runs

2 participants