Skip to content

fix(agents): guard vanished workspaces - #88485

Merged
steipete merged 17 commits into
openclaw:mainfrom
TurboTheTurtle:fix/88333-workspace-vanish-guard
Jun 1, 2026
Merged

steipete merged 17 commits into
openclaw:mainfrom
TurboTheTurtle:fix/88333-workspace-vanish-guard

Conversation

@TurboTheTurtle

@TurboTheTurtle TurboTheTurtle commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #88333

Summary

  • add a recent-workspace attestation marker next to the agent workspace path
  • refuse to silently re-seed BOOTSTRAP.md/state when a recently attested workspace directory disappears or is wiped
  • cover the vanished-directory, wiped-directory, and stale-attestation paths, plus docs and changelog

Verification

  • pnpm test src/agents/workspace.test.ts
  • pnpm exec oxfmt --check --threads=1 src/agents/workspace.ts src/agents/workspace.test.ts docs/concepts/agent.md CHANGELOG.md
  • git diff --check

Real behavior proof

  • Behavior or issue addressed: ensureAgentWorkspace no longer silently re-seeds BOOTSTRAP.md and .openclaw/workspace-state.json over an agent workspace that was previously initialized and then disappeared or was wiped.
  • Real environment tested: Local OpenClaw checkout at /Users/andy/openclaw/openclaw-88333 on macOS, using the real src/agents/workspace.js entrypoint through the repo tsx loader and a real temporary filesystem workspace under /tmp.
  • Exact steps or command run after this patch: Ran node --import tsx --eval <script> where the script called ensureAgentWorkspace({ ensureBootstrapFiles: true }), verified the sibling .attested marker, removed the workspace directory, called ensureAgentWorkspace again, caught the thrown error code, and checked whether BOOTSTRAP.md or .openclaw/workspace-state.json had been recreated.
  • Evidence after fix: Terminal output from the live command:
{
  "attestedExists": true,
  "errorCode": "WORKSPACE_VANISHED",
  "bootstrapExists": false,
  "stateExists": false
}
  • Observed result after fix: The second startup refused to re-seed the vanished workspace with WORKSPACE_VANISHED; the attestation marker remained the signal, and both BOOTSTRAP.md and workspace state stayed absent.
  • What was not tested: No additional gaps.

Attribution

If maintainers squash or rework this PR, please preserve author attribution or include Co-authored-by: Andy Ye <[email protected]>.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. size: S labels May 31, 2026
@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 31, 2026
@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 31, 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 commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed May 31, 2026, 9:09 PM ET / 01:09 UTC.

Summary
The PR adds workspace attestation markers, makes ensureAgentWorkspace throw WORKSPACE_VANISHED for recently attested missing or wiped workspaces, clears markers from reset/delete/uninstall paths, and updates tests, docs, and the UI raw-copy baseline.

PR surface: Source +520, Tests +530, Docs +2. Total +1052 across 17 files.

Reproducibility: yes. Source inspection on current main shows an empty workspace with missing state and no BOOTSTRAP.md reaches the reseed branch, and the PR's terminal proof plus tests show the after-fix WORKSPACE_VANISHED path.

Review metrics: 1 noteworthy metric.

  • Persistent runtime state: 1 marker family added. workspace-attestations/*.attested becomes a new lifecycle state surface that maintainers should notice before merge.

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] Wait for the queued required checks to finish.
  • [P1] Record maintainer acceptance of the fail-closed workspace and marker-state contract before merge.

Risk before merge

  • [P1] Merging intentionally changes upgrade behavior: a recently attested missing or wiped workspace now stops with WORKSPACE_VANISHED instead of silently reseeding bootstrap files.
  • [P1] The new workspace-attestations/*.attested marker family is persistent runtime state outside SQLite, so maintainers should explicitly accept that file-backed lifecycle guard or move it into the shared state database.
  • [P1] Several required security and quality check-runs were still queued for the latest head when inspected, so merge should wait for the normal gates to finish.

Maintainer options:

  1. Accept the fail-closed guard after checks (recommended)
    Maintainers can accept that a recently attested missing or wiped workspace now blocks startup until the user restores it or performs a full reset.
  2. Move the marker into SQLite first
    If file-backed runtime state is not acceptable here, move the attestation contract into the shared state database and keep the same workspace tests.
  3. Pause for compatibility policy
    If blocking startup on upgrade is too disruptive, pause this branch and choose an explicit compatibility mode or operator-facing reset flow before landing.

Next step before merge

  • [P1] The remaining action is maintainer judgment on the fail-closed upgrade behavior and file-backed marker contract, plus waiting for queued checks, not a narrow automated repair.

Security
Cleared: No concrete security or supply-chain regression was found in the diff; the marker path is hashed under state, marker reads are size/header checked, and symlink/non-marker cases are covered by tests.

Review details

Best possible solution:

Land the guard after CI completes and maintainers explicitly accept the fail-closed workspace contract, or move the attestation into the shared state DB before merge if the file-backed exception is not acceptable.

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

Yes. Source inspection on current main shows an empty workspace with missing state and no BOOTSTRAP.md reaches the reseed branch, and the PR's terminal proof plus tests show the after-fix WORKSPACE_VANISHED path.

Is this the best way to solve the issue?

Yes, if maintainers accept the fail-closed contract. The fix is in the workspace owner boundary, preserves first-run bootstrap, and includes cleanup paths; the remaining question is policy around marker persistence and upgrade behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 570e2db25210.

Label changes

Label justifications:

  • P2: This fixes a bounded core workspace safety bug with data-loss masking potential, but it is not an emergency runtime outage by itself.
  • merge-risk: 🚨 compatibility: Existing setups that previously reseeded after a missing or wiped workspace can now fail closed and require restore or reset.
  • merge-risk: 🚨 availability: The new guard can stop agent setup/startup with WORKSPACE_VANISHED when the marker says a recent workspace disappeared.
  • 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 (terminal): The PR body includes after-fix terminal output from the real workspace entrypoint showing a vanished workspace returns WORKSPACE_VANISHED and does not recreate bootstrap or state files.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from the real workspace entrypoint showing a vanished workspace returns WORKSPACE_VANISHED and does not recreate bootstrap or state files.
Evidence reviewed

PR surface:

Source +520, Tests +530, Docs +2. Total +1052 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 9 612 92 +520
Tests 7 531 1 +530
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 1145 93 +1052

What I checked:

  • Current main reseed behavior: Current main still creates the workspace directory and reaches the missing-state/no-BOOTSTRAP branch that writes a fresh BOOTSTRAP.md and records bootstrapSeededAt. (src/agents/workspace.ts:500, 570e2db25210)
  • PR guard behavior: The PR resolves state and legacy attestation paths, detects a recent marker before setup, throws WorkspaceVanishedError for missing/wiped workspaces, and refreshes the marker after successful setup. (src/agents/workspace.ts:820, 557ba2ff765b)
  • Cleanup coverage: The PR adds marker cleanup for reset/uninstall/delete flows so a full reset or delete can intentionally clear the attestation with the workspace. (src/commands/cleanup-utils.ts:115, 557ba2ff765b)
  • Regression coverage: New workspace tests cover vanished directories, wiped contents, generated remnants, skip-bootstrap workspaces, stale markers, non-marker sibling files, unreadable markers, and symlink markers. (src/agents/workspace.test.ts:127, 557ba2ff765b)
  • Docs update: The agent docs now tell users that a recently attested disappeared or wiped workspace refuses silent BOOTSTRAP reseeding and should be restored or fully reset. Public docs: docs/concepts/agent.md. (docs/concepts/agent.md:44, 557ba2ff765b)
  • Linked issue context: The linked issue is a high-confidence source repro for silent reseeding after an external workspace wipe, and the PR body includes terminal output showing WORKSPACE_VANISHED with no recreated bootstrap or state file.

Likely related people:

  • steipete: Prior issue review history ties the workspace bootstrap ritual and recent workspace implementation to this path, and this PR also contains maintainer follow-up commits on the same guard. (role: introduced behavior and recent area contributor; confidence: high; commits: 3876c1679ac9, ec7e3eaf649a, 9a2d1d5d7bb7; files: src/agents/workspace.ts, src/agents/workspace.test.ts)
  • gumadeiras: Prior issue review history identifies bootstrap state persistence and bootstrapSeededAt/setupCompletedAt behavior as central to the reported reseed path. (role: bootstrap state contributor; confidence: high; commits: 28b78b25b721, b4f14d6f7aa0; files: src/agents/workspace.ts)
  • vincentkoc: Recent main history shows adjacent gateway agents handler refactors on a PR-touched delete path, making this a useful routing candidate for gateway-side cleanup behavior. (role: recent adjacent owner; confidence: medium; commits: 48afba96a300, dd8d52c7d9c6; files: src/gateway/server-methods/agents.ts)
  • Jason-Bai: Recent main history shows workspace preservation work in cleanup/uninstall utilities, which overlaps the PR's marker cleanup paths. (role: recent cleanup-path contributor; confidence: medium; commits: e74931778c69; files: src/commands/cleanup-utils.ts, src/commands/uninstall.ts, src/commands/reset.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.

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels May 31, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/88333-workspace-vanish-guard branch from ac1c4d6 to b534585 Compare May 31, 2026 00:47
@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 31, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/88333-workspace-vanish-guard branch from b534585 to 0b42a65 Compare May 31, 2026 00:49
@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 31, 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed 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 May 31, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels May 31, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/88333-workspace-vanish-guard branch from e61c884 to 6eebd22 Compare May 31, 2026 19:46
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label May 31, 2026
@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 31, 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 commented May 31, 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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. 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.

ensureAgentWorkspace re-seeds over wiped workspace without confirmation

3 participants