Skip to content

fix: cloud-worker results are lost when the box dies before reconciliation - #110952

Merged
steipete merged 5 commits into
mainfrom
claude/cloud-result-staging
Jul 18, 2026
Merged

steipete merged 5 commits into
mainfrom
claude/cloud-result-staging

Conversation

@steipete

@steipete steipete commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #110224 (phase 1 of 3)

What Problem This Solves

Resolves the data-loss half of #110224: a cloud-worker turn's file result only existed on the leased box until a clean workspace apply succeeded. If inbound reconciliation failed (real local divergence) and the box then died — or the Gateway restarted and its recovery sweep found the environment gone — the unaccepted result was abandoned and the placement force-failed, permanently losing the turn's work. Observed live during a cloud-workers stress test (full incident log in #110224).

Why This Change Was Made

Stage-first reconciliation: when a worker result is pulled, the complete result tree is committed as a durable Git ref in the session workspace repo (refs/openclaw/worker-results/<claim>, with a crash-safe candidate ref during construction) before any apply is attempted, and recorded on the pending-result fence row (new nullable staged_result_ref column, state schema v5, additive migration). Apply and every retry then run from the staged tree as a purely local operation; the recovery sweep skips the tunnel entirely when a staged ref exists. Recovery semantics change accordingly: an unaccepted fence with a staged ref must never be destroyed by environment lifecycle — the environment can be reclaimed while the fence and placement stay alive until the local apply is durably accepted. Only legacy fences without a staged ref keep the old abandon path. Staged refs are deleted on acceptance or explicit abandonment; ref construction validates claim ids ([A-Za-z0-9-]+) and fails closed; ordering is candidate apply → quiescence/fence checks → canonical ref publish → SQLite pointer, so a crash at any step leaves a recoverable state. Object retention after ref deletion matches the existing managed-worktree snapshot pattern (refs/openclaw/snapshots/*).

Non-goals (later phases per #110224): conflict resolution policy, turn-claim release semantics, chat error copy, UI affordances.

Maintainer rulings for this PR: keep the state schema at main + 1 (v5); the rollback consequence is deliberately accepted. Complete-tree staging and object-store retention parity with managed-worktree snapshots are also accepted design decisions.

User Impact

A dead or reclaimed cloud box can no longer lose a finished turn's file changes: the result is already safe on the Gateway and is applied or retried locally. Gateway restarts preserve pending results instead of force-failing their placements.

Evidence

  • Focused tests: node scripts/run-vitest.mjs src/gateway/worker-environments/ src/state/openclaw-state-db.test.ts — 447 tests green (89 + 358 across shards), including: staging order (ref before apply), crash-gap adoption of canonical refs, dead-environment recovery applying from the staged ref without a tunnel, divergence keeping fence + placement alive, ref cleanup on accept, hostile git-hook neutralization, and the v4→v5 migration.
  • Remote pnpm check:changed (Blacksmith Testbox): exit 0 (typecheck, lint, format, policy guards, import cycles).
  • Structured autoreview (codex, gpt-5.6-sol): accepted findings fixed (ref-name validation, staging/finalization race reordering, candidate-ref leak); final run clean. Two rejected-by-owner suggestions documented inline (object-store retention parity with worktree snapshots; complete-tree vs delta storage is the requested contract).

Real recovery proof

Exact head a9d37cdda82c3bb1ce5092c9609a609366f31245 was built and run through an isolated real Gateway → bundled Crabbox provider → AWS worker path. The model side used the deterministic local QA provider; provisioning, bundle install, SSH/tunnel, worker runtime, workspace transfer, durable staging, lease loss, Gateway restart, and recovery were production paths.

The proof injected one persistence-boundary failure with an isolated SQLite trigger: reject the first workspace_accepted_at_ms update after the canonical staged Git ref was published. This models the crash window without modifying production code. It then stopped the actual AWS lease before restarting the Gateway.

provider: aws
lease: cbx_f8b8fd6f4912 (stopped before Gateway restart; cleaned up)
pending before restart: staged_result_ref present, workspace_accepted_at_ms null
worker result before restart sha256: e0b584a31c3f16c59b04d9e00d0c4421618f0ad633ededdefa3e052fc401eb2c
worker result after restart sha256:  e0b584a31c3f16c59b04d9e00d0c4421618f0ad633ededdefa3e052fc401eb2c
pending rows after restart: 0
placement after restart: reclaimed
turn claim after restart: null
recovery_error after restart: null
staged Git ref after restart: absent

The first harness attempt reached an attached AWS worker but selected an empty side-database path before starting a turn; it failed during trigger installation and cleaned up its lease. The corrected run above used the Gateway's canonical state/openclaw.sqlite path and completed end to end.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Jul 18, 2026
@steipete steipete self-assigned this Jul 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af6e467fcd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (probe.termination === "exit" && probe.code === 0) {
return resolved;
}
await requireGit(resolved, ["init", "--quiet", "--object-format=sha1"]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid initializing Git in plain workspaces

When a cloud turn runs against a plain, non-Git workspace, this fallback permanently adds a .git directory. On the next dispatch, syncWorkspaceImpl treats the successful git rev-parse --show-toplevel as Git mode (src/gateway/worker-environments/workspace-sync.ts:257-264) and then requires a valid HEAD (src/gateway/worker-environments/workspace-sync.ts:290-299); this newly initialized repository has no commits, so every subsequent cloud turn fails with “Worker git workspace has no base commit.” Keep the durable result repository outside plain user workspaces or otherwise preserve their plain-mode classification.

Useful? React with 👍 / 👎.

Comment thread package.json
@@ -3,7 +3,7 @@
"version": "2026.7.2",
"openclaw": {
"schemaVersions": {
"state": 4,
"state": 5,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep the additive state column on schema version 4

When a user starts this version and subsequently rolls back, the database remains at user_version = 5, while the older build supports version 4 and rejects any larger version in src/state/openclaw-state-db-maintenance.ts:64-72, preventing the Gateway from opening its state database. Because staged_result_ref is a nullable additive column that older readers tolerate, this bump creates an unnecessary rollback incompatibility and conflicts with the root AGENTS.md rule that purely additive SQLite surfaces must not bump the schema version.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the claude/cloud-result-staging branch from 1cb2e45 to 4c84633 Compare July 18, 2026 20:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c84633ae2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

chunks.push(Buffer.from(`M ${mode} :${blob.mark} ${quoteFastImportPath(blob.entry.path)}\n`));
}
chunks.push(Buffer.from("done\n"));
const imported = await runCommandBuffered(gitCommand(root, ["fast-import", "--quiet"]), {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Replace the prepared ref when rebuilding a retry candidate

If the Gateway crashes after applyPreparedStagedResult() commits the new manifest but before publishStagedResult(), the candidate ref survives while the placement base advances. Recovery then stages a new root commit at the same candidate ref using the advanced base, but this fast-import lacks --force; Git 2.43 rejects that update with Not updating ... new tip ... does not contain <old tip> and exits 1. Every sweep repeats the failure, and after the worker disappears the hasPreparedResult branch preserves the fence indefinitely, blocking the placement until forced abandonment. Delete the prior candidate before rebuilding it or explicitly force this validated ref update.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the claude/cloud-result-staging branch from 49ce95d to 90f77b3 Compare July 18, 2026 20:53
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 6:17 PM ET / 22:17 UTC.

Summary
The branch stages completed cloud-worker workspace results as durable local Git refs, persists their pending-result pointer, and recovers locally after worker loss or Gateway restart.

PR surface: Source +1164, Tests +837, Config 0, Generated +2. Total +2003 across 27 files.

Reproducibility: yes. The PR provides a concrete current-head live path: complete a cloud-worker result, force the acceptance persistence boundary to fail after staging, stop the AWS lease, restart Gateway, and verify the identical result is applied and the pending state is cleared.

Review metrics: 1 noteworthy metric.

  • State schema surface: 1 nullable column added; schema version changed 4 → 5. This is the specific compatibility boundary that can affect Gateway rollback behavior after upgrade.

Stored data model
Persistent data-model change detected: database schema: src/state/openclaw-state-db.test.ts, durable storage schema: src/gateway/worker-environments/placement-dispatch-staged-results.test.ts, durable storage schema: src/gateway/worker-environments/placement-dispatch-test-harness.ts, durable storage schema: src/gateway/worker-environments/placement-force-abandon.test.ts, durable storage schema: src/gateway/worker-environments/placement-force-abandon.ts, durable storage schema: src/gateway/worker-environments/placement-store.test.ts, and 26 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #110224
Summary: This PR is the candidate implementation for the data-loss portion of the open cloud-worker reconciliation incident; the linked issue retains additional recovery and product-work items.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Obtain explicit current maintainer confirmation for the v5 state-schema rollback boundary before merge.

Risk before merge

  • [P1] Upgrading writes SQLite schema version 5; rolling back to a build that only accepts version 4 can prevent that older Gateway from opening the state database. The PR body says this is an accepted design, but the explicit current maintainer acceptance should be confirmed before merge.

Maintainer options:

  1. Confirm the state-version tradeoff (recommended)
    Accept the deliberate v5 upgrade and rollback boundary only after the relevant state/release owner confirms it applies to the current merge.
  2. Preserve rollback compatibility
    Revise the additive column to remain version-4 readable if maintainers require users to roll back safely after upgrading.

Next step before merge

  • [P2] No narrow mechanical repair remains; a state/release owner must confirm the deliberate schema-version compatibility decision before this PR enters a merge path.

Maintainer decision needed

  • Question: Should this PR intentionally advance the state schema to v5 for a nullable additive column, accepting that rollback to a v4-only build may be blocked?
  • Rationale: Repository policy normally keeps purely additive SQLite changes version-compatible, while the PR asserts a contrary accepted ruling; that compatibility tradeoff is product and release ownership, not a mechanical reviewer choice.
  • Likely owner: steipete — The linked incident, implementation, and stated design ruling place this contributor closest to the cloud-worker recovery decision; an additional release/state owner should confirm the final tradeoff.
  • Options:
    • Accept the v5 rollback boundary (recommended): Confirm that protecting completed cloud-worker results is worth the explicit rollback limitation, then merge with the existing migration and recovery proof.
    • Keep schema version 4: Use the additive-column ensure path without advancing the primary schema version if backward rollback compatibility remains required.

Security
Cleared: The reviewed diff validates generated ref names and disables Git hooks for staging commands; no concrete security or supply-chain regression is established.

Review details

Best possible solution:

Land the durable staging design only with an explicit maintainer decision that the v5 rollback behavior is intentional; retain the v4→v5 migration coverage and the proven restart-recovery path.

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

Yes. The PR provides a concrete current-head live path: complete a cloud-worker result, force the acceptance persistence boundary to fail after staging, stop the AWS lease, restart Gateway, and verify the identical result is applied and the pending state is cleared.

Is this the best way to solve the issue?

Yes, conditional on the schema-version decision. Durable local staging before apply directly addresses the failure window and avoids depending on a dead worker tunnel during recovery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 19d887169f78.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains redacted exact-head live Gateway → Crabbox → AWS-worker recovery output showing byte-identical result preservation after lease loss and Gateway restart.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 PR body contains redacted exact-head live Gateway → Crabbox → AWS-worker recovery output showing byte-identical result preservation after lease loss and Gateway restart.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: This fixes a real cloud-worker workflow that can permanently lose completed workspace results after recovery failure.
  • merge-risk: 🚨 compatibility: The PR advances the persisted state schema version despite adding a nullable column, creating a potential downgrade incompatibility.
  • merge-risk: 🚨 session-state: The change alters persisted pending-result, placement, and turn-claim recovery semantics across Gateway restart.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 PR body contains redacted exact-head live Gateway → Crabbox → AWS-worker recovery output showing byte-identical result preservation after lease loss and Gateway restart.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains redacted exact-head live Gateway → Crabbox → AWS-worker recovery output showing byte-identical result preservation after lease loss and Gateway restart.
Evidence reviewed

PR surface:

Source +1164, Tests +837, Config 0, Generated +2. Total +2003 across 27 files.

View PR surface stats
Area Files Added Removed Net
Source 15 1234 70 +1164
Tests 9 840 3 +837
Docs 0 0 0 0
Config 1 1 1 0
Generated 2 2 0 +2
Other 0 0 0 0
Total 27 2077 74 +2003

What I checked:

  • Durable recovery implementation: The branch adds staged-result references and recovery helpers so a pending result can be applied locally after its remote environment disappears, rather than being abandoned with the placement. (src/gateway/worker-environments/placement-dispatch-recovery.ts:67, a9d37cdda82c)
  • Persisted recovery fence: Pending workspace-result rows now carry staged_result_ref, and recordStagedWorkspaceResult validates the ref shape before recording it for restart recovery. (src/gateway/worker-environments/placement-workspace-result.ts:216, a9d37cdda82c)
  • Schema and upgrade boundary: The PR changes the state schema version from 4 to 5 while adding one nullable staged_result_ref column and includes a v4→v5 migration test. (src/state/openclaw-state-db-contract.ts:5, a9d37cdda82c)
  • Exact-head real recovery proof: The PR body reports an exact-head Gateway → Crabbox → AWS-worker run where a published staged ref survived lease loss and Gateway restart; before/after workspace SHA-256 values matched, then recovery cleared the pending row and claim and reclaimed the placement. (a9d37cdda82c)
  • Prior review continuity: The current diff includes the prior-cycle repairs for plain/unborn Git workspace detection, candidate-ref handling, forced abandonment without a resolvable worktree, and reconciliation staging coverage; no remaining discrete line-level regression is established from the supplied current-head evidence. (src/gateway/worker-environments/workspace-sync-helpers.ts:51, a9d37cdda82c)

Likely related people:

  • steipete: Authored the linked cloud-worker incident report and the five-commit recovery implementation, including the current-head hardening commit and real recovery proof. (role: cloud-worker incident investigator and recent area contributor; confidence: medium; commits: bef482a3d0fc, a9d37cdda82c; files: src/gateway/worker-environments/placement-dispatch-recovery.ts, src/gateway/worker-environments/workspace-result-staging.ts, src/state/openclaw-state-db-contract.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (3 earlier review cycles)
  • reviewed 2026-07-18T20:55:52.724Z sha 90f77b391b4a6aaca350122c9076132fad929c8a :: needs real behavior proof before merge. :: [P1] Keep the additive state column on schema version 4 | [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-18T21:23:59.481Z sha a6ed7040dc4f000258d3b7d31c67493293ef3616 :: needs real behavior proof before merge. :: [P1] Keep the additive state column on schema version 4 | [P1] Limit staged payloads to changed workspace entries | [P1] Avoid converting plain workspaces into empty Git repositories | [P2] Let forced abandonment continue without a worktree
  • reviewed 2026-07-18T22:00:50.643Z sha a9d37cd :: needs real behavior proof before merge. :: [P1] Keep the additive state column on schema version 4

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Jul 18, 2026
@steipete
steipete force-pushed the claude/cloud-result-staging branch from ba7286d to 2f57a2d Compare July 18, 2026 21:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f57a2d7e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +257 to +259
const entries = reconciliationEntries(current.entries).toSorted((left, right) =>
left.path.localeCompare(right.path),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Apply reconciliation limits only to changed entries

When the workspace contains an unchanged file larger than 64 MiB, more than 25,000 total entries, or over 256 MiB of total content, this stages every current entry and applies the reconciliation limits to the entire workspace. Previously, workerWorkspaceTransferPaths filtered to changed paths before enforcing these limits, so even a no-op cloud turn in such a workspace now fails with a size/entry-limit error. Only changed payload blobs need to be stored because applyStagedWorkerWorkspaceResult materializes only paths in changedPaths.

Useful? React with 👍 / 👎.

);
}
} else {
const root = await params.resolveWorkspacePath(placement);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow forced teardown without resolving the worktree

When the session worktree registry or session entry is already missing or inconsistent, resolveWorkspacePath throws here before the pending result is abandoned. Since forceDestroyEnvironment calls environments.destroy only after this helper succeeds (src/gateway/worker-environments/placement-dispatch.ts:327-334), the documented last-resort forced teardown leaves both the environment and claim fenced indefinitely. Treat an unresolvable workspace as having no deletable result ref and continue the explicit abandonment.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@steipete
steipete force-pushed the claude/cloud-result-staging branch from a6ed704 to a9d37cd Compare July 18, 2026 21:53
@openclaw-barnacle openclaw-barnacle Bot removed the agents Agent runtime and tooling label Jul 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a9d37cdda8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +562 to +565
await requireGit(root, ["update-ref", "-d", stagedResultRef]);
if (stagedResultRef.startsWith(`${WORKER_RESULT_REF_PREFIX}/`)) {
await requireGit(root, ["update-ref", "-d", preparedWorkerWorkspaceResultRef(stagedResultRef)]);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prune staged objects after deleting result refs

When cloud turns run repeatedly against a plain workspace, ensureWorkerWorkspaceResultRepository creates an unborn .git at src/gateway/worker-environments/workspace-result-staging.ts:142-152, but this cleanup deletes only the refs. Git 2.43's git gc -h identifies --prune as the operation that removes unreferenced objects; no GC or object cleanup runs here, and an import/delete probe leaves every blob, tree, and commit as loose objects. Because such a workspace has no normal Git maintenance owner, successive changed results can retain deleted content and grow the hidden repository indefinitely, potentially by the reconciliation limits per turn. Use lifecycle-owned result storage or explicitly remove its unreachable objects after the fence is complete.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 18, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now contains redacted exact-head proof from a real Gateway → bundled Crabbox → AWS worker run. The worker result was durably staged, the AWS lease was stopped, and Gateway restart recovery preserved identical file bytes, cleared the pending row and claim, removed the staging ref, and reclaimed the placement.

Maintainer rulings for this PR remain: keep the state schema at main + 1 (v5), and accept complete-tree staging plus object-store retention parity. Please evaluate current head a9d37cdda82c3bb1ce5092c9609a609366f31245 only.

@clawsweeper

clawsweeper Bot commented Jul 18, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 18, 2026
@steipete
steipete merged commit 7a7d6bb into main Jul 18, 2026
163 of 174 checks passed
@steipete
steipete deleted the claude/cloud-result-staging branch July 18, 2026 22:24
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 19, 2026
…ation (openclaw#110952)

* fix(cloud-workers): stage worker results durably before reconciliation

* fix(cloud-workers): model result staging test seam

* fix(cloud-workers): disable staging git hooks safely

* chore: defer cloud worker release note

* fix(cloud-workers): harden staged result recovery
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…ation (openclaw#110952)

* fix(cloud-workers): stage worker results durably before reconciliation

* fix(cloud-workers): model result staging test seam

* fix(cloud-workers): disable staging git hooks safely

* chore: defer cloud worker release note

* fix(cloud-workers): harden staged result recovery
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant