Skip to content

fix(sandbox): prevent missing workspace baselines after cleanup - #186278

Merged
steipete merged 2 commits into
mainfrom
codex/workspace-baseline-missing-nodes
Oct 28, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/workspace-baseline-missing-nodes

Conversation

@steipete

@steipete steipete commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes sandboxed managed sessions becoming stuck when manifest cleanup collects a stalled preparation before its baseline or checkpoint is published.

User Impact

A stale preparation now fails before publishing references to missing content, and retrying the session prepares the preserved live files again. Older missing baselines can recover from an intact pending-checkpoint result without discarding either workspace's edits. Unverifiable divergence still refuses recovery and reports both preserved paths with an inspection command.

Why This Change Was Made

Immutable pack preparation and root publication use separate worker transactions. Packs prepared at sweep epoch E are collectible at E+2, but publication previously accepted their digest without checking that window. Preparation now returns its epoch, and the writer checks the oldest preparation epoch before any mutation. Ordinary manifest reads omit the potentially large checkpoint payload; only repair requests load it. The existing schema, retention window, lease checks, and commit settlement remain unchanged.

Recovery can reverse an authenticated checkpoint delta in memory when a live workspace matches its resulting tree. It publishes repaired CAS metadata only if the reconstructed tree matches the saved baseline digest. Comparing or recreating workspaces cannot recover an unknown three-way merge base; no automatic selection between divergent edits is introduced.

Evidence

  • Deterministic red-on-base store regression: run two sweeps after preparation and before publication. Base incorrectly resolves the publication after its packs were collected.
  • Red-on-base recovery regression: neither workspace equals the old baseline, but one exactly matches the saved checkpoint result. Base refuses; the repair reconstructs and verifies the old baseline without modifying either live file.
  • Five focused suites: local-workspace-{store,manifest-scan,cas,conversion,projection}.test.ts through node scripts/run-vitest.mjs ... --maxWorkers=1: 82 passed, 2 preexisting environment skips; 393.36s suite time / 423.38s wrapper wall time. The skipped cases require real Podman or raw non-UTF-8 filenames unsupported by this filesystem.
  • Final touched-file run after fixture cleanup: store, manifest-scan, and CAS: 31 passed; 157.60s suite time / 187.91s wrapper wall time. Worker/runtime preparation accounts for most overhead; the new manifest-scan recovery test itself took under 0.2s.
  • Targeted typecheck extends test/tsconfig/tsconfig.core.test.gateway-other.json with only the nine touched TypeScript files: passed. Focused run-oxlint.mjs, run-format.mts --check for all 11 changed files, and git diff --check: passed.
  • Codex autoreview, P1, complete working-tree change against base 451ec41c26c67cca7d8a61b7da6b0188cf52249e, with complete publication/GC/recovery context: no actionable P0/P1 findings.
  • Follow-up limiting checkpoint reads to repair: affected store and manifest-scan suites 26 passed, 169.78s suite / 193.46s wrapper wall time; targeted typecheck/lint/format passed. P1 autoreview of that delta against e242a31b008570e7938a8d946ee44f79d7cbdff0 found no actionable P0/P1 findings.
  • Accepted edge case: a reconciliation spanning two sweeps may need another session attempt even if some earlier prepared content has since become reachable. Keeping the oldest preparation epoch covers unpinned scan output across observation commits.
  • Existing known-tree insertion proof is consolidated into the rollback/lost-reply test. All assertions and CAS sharing/GC contracts are retained; net test lines decrease by 13. Production code grows by 79 lines; documentation grows by 18.
  • No live Gateway, user state, deployment, schema migration, dependency, or configuration change.

CI Classification

Exact-head CI run 40578654178, attempt 1, failed only check-lint-core-2 (job 122454243417) and its downstream openclaw/ci-gate; security-fast passed. The root failure is five eslint(curly) errors in ui/src/pages/new-session/draft-body.browser.test.tsx (lines 31–32) and ui/src/pages/chat/chat-content-column.browser.test.tsx (lines 288–289 and 362). Reactive-use and max-lines diagnostics are warnings.

Core stripe 4/5 was run locally on CI's main parent 5010c3e80f8bb2271bbd347d4639218f84f9fac4 and reproduced exactly those five errors, including identical files, messages, and locations. The UI tree, lint rule/configuration owners, dependency manifests, and warning-source objects are identical between that parent and tested merge fb4746a70ec39bf378a50ceac661e2a71857c89c, whose second parent is the reviewed head f1a6f74fafbce52ff582af01a7ad4815f44549a7. These failures are unrelated to this worker-environment fix. CI remains failed; the authorized native pre-existing-failure exception is selected. No CI rerun or branch update was used.

@clawsweeper

clawsweeper Bot commented Oct 27, 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 docs Improvements or additions to documentation gateway Gateway runtime docker Docker and sandbox tooling size: M labels Oct 27, 2026
@steipete
steipete marked this pull request as ready for review October 27, 2026 20:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T20:24:43.494962Z e242a31 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR rejects expired workspace preparations before publication and reconstructs missing baselines from verified pending checkpoints.

Example: Workspace packs are prepared at sweep epoch 4, then cleanup advances to epoch 6 before publication.

  • Before: Publication can accept references to packs that cleanup already deleted.
  • After: Publication rejects the expired preparation and asks the user to retry while preserving both workspaces.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful regressions and no identified introduced defect; existing-state compatibility remains unqualified.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored ordinary proof exemption applies, and the supplied tests exercise real store workers and filesystem scanning; however, no upgrade run qualifies the changed persisted-baseline repair path, so the separate data compatibility gate remains unmet.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Managed sandbox sessions can become stuck after cleanup removes manifest content before its references are published.
Reason: The maintainer-authored direction repairs a concrete persistence invariant while retaining existing retention, authority, and divergent-edit preservation contracts.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it addresses a concrete workspace publication failure still present on main, and no definite introduced correctness or security defect was found.

Priority: P1
Reviewed head: f1a6f74fafbce52ff582af01a7ad4815f44549a7

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Supply an isolated upgrade from the latest stable release followed by native workspace recovery, showing saved references, pending receipts, and both workspaces' edits remain intact.
Agent review details

How this fits together

The local workspace owner scans canonical and sandbox files, prepares immutable SQLite manifest packs, and publishes baseline or checkpoint references through the existing worker transaction.

flowchart TD
  A[Canonical and sandbox files] --> B[Manifest scan worker]
  B --> C[Immutable pack preparation]
  C --> D[Publication transaction]
  E[Epoch cleanup] --> C
  E --> D
  D --> F[Saved baseline and checkpoint]
Loading

Technical review

Best possible solution:

Retain the existing epoch and transaction owners, reject expired publications, and repair only an exactly verified saved baseline.

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

Source establishes that preparation and publication use separate transactions while cleanup can collect unpublished content after two sweeps; the supplied deterministic regression exercises that ordering.

Is this the best way to solve the issue?

The patch uses the smallest existing owners for the two failures: one transactional expiration check prevents invalid publication, and authenticated checkpoint reversal extends exact-baseline recovery without modifying live files.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Content preparation and publication keeps the original intent (a25b072: Shared directory packs reduce duplicated workspace inventories and shorten writer transactions, with epoch cleanup instead of reference counts.)
  • Missing-baseline recovery keeps the original intent (a25b072: Recover only the exact saved baseline from preserved files, refusing to replace an unknown merge base with divergent edits.)
  • Worker preparation and settlement keeps the original intent (7462184: Prepare full baseline replacements off the Gateway thread while preserving atomic publication and lost-reply recovery.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a25b072 adds src/gateway/worker-environments/local-workspace-manifest-scan.ts:227 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a25b072d1684; files: src/gateway/worker-environments/local-workspace-manifest-scan.ts)
  • Shakker: Raw commit 5c410ef adds src/gateway/worker-environments/local-workspace-manifest-scan.ts:438 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5c410ef4eb56; files: src/gateway/worker-environments/local-workspace-manifest-scan.ts)

PR surface

Source +79, Tests -13, Docs +18. Total +84 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 90 11 +79
Tests 3 53 66 -13
Docs 2 22 4 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 165 81 +84

Review metrics

Metric Value Why it matters
Production versus test LOC Production net +79; tests net -13 Growth implements checkpoint reconstruction and carries preparation epochs through existing owners; test consolidation retains rollback, lost-reply, sharing, and cleanup contracts.

Labels

Label changes:

  • add P1: Publishing collected manifest content can leave managed sandbox sessions unable to reconcile their workspaces.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: Publishing collected manifest content can leave managed sandbox sessions unable to reconcile their workspaces.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Demonstrate the changed recovery path after an upgrade from the latest stable release, preserving pending receipts and both workspaces' edits.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 27, 2026, 4:45 PM ET / 20:45 UTC.

@steipete
steipete enabled auto-merge (squash) October 27, 2026 20:55
@steipete
steipete disabled auto-merge October 28, 2026 01:58
@steipete
steipete merged commit e69b382 into main Oct 28, 2026
150 of 154 checks passed
@steipete
steipete deleted the codex/workspace-baseline-missing-nodes branch October 28, 2026 02:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

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

Labels

docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant