Skip to content

feat: recover abandoned Crabbox source staging - #152006

Merged
shakkernerd merged 4 commits into
mainfrom
feat/crabbox-staging-recovery
Sep 18, 2026
Merged

shakkernerd merged 4 commits into
mainfrom
feat/crabbox-staging-recovery

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An abrupt wrapper exit can leave a frozen Crabbox source copy behind even when the remote lease has ended. Neither an old directory nor a missing PID proves that deleting the copy is safe: it may retain unique source, an unsettled writer, a live claim, or diagnostics that were never preserved.

This adds inspection and recovery at the wrapper that owns source staging. It follows the normal-cancellation repair in #151862 and handles remnants that survive beyond the original process's cleanup opportunity.

User Impact

node scripts/crabbox-wrapper.mjs staging inspect reports recognized copies and the reason each remains protected. staging recover <id> can remove a prepared or positively settled capsule after proving that its selected source remains available through an independent named Git ref and its diagnostics are preserved. An explicit --witness-repo <path> --witness-ref <full-ref> can identify an existing retained source. Successful ordinary source-transfer commands also attempt one eligible older copy after completing their own cleanup.

Recovery is local and reads the original native claim namespace. It neither provisions nor stops machines, rewrites claims, nor creates permanent source backups. Normal execution and cleanup still work with ignored or unignored repository-local staging roots; these locations receive no new recovery metadata and their abandoned copies remain protected. This feature does not add general restrictions on source selection or extra mounts.

Recovery requires a known, unchanged boot and PID namespace. Copies from an earlier boot, unknown or older receipt formats, full Git worktrees, uncertified preparation callbacks, unsettled consumers, active claims, and unique or changed source remain protected. Inspection explains these limits instead of inferring safety from age or a stale PID.

Why This Change Was Made

Eligible producers write a private receipt beside the disposable payload, seal an immutable source manifest, persist admission before starting a consumer, and record settlement through the existing process finalizer. Optional registration is withheld when the staging location overlaps the supplied source or effective Git workspace. Preparation that may invoke Git callbacks keeps a permanent writer hold without disabling those callbacks or changing ordinary command execution. Installed filters with no applicable path attributes do not withhold recovery.

Recovery acquires exclusive ownership and checks the producer, native claims, independent Git witness, remaining payload, and preserved artifacts. The witness validates retained-ref ancestry, commit/tree connectivity, selected raw blobs, modes, and deletions. Artifact preservation uses content-addressed evidence without replacing the original source manifest. Interrupted removal can resume only from recorded intent; unknown files, changed identities, incomplete metadata, and unjoined recovery readers remain protected.

Discovery reads bounded headers rather than hashing payloads or querying providers. Its non-authoritative paging hint allows later candidates to progress even when an earlier copy cannot be recovered. Unsupported filesystem durability disables orphan recovery while preserving normal staging and cleanup, and metadata reads reject non-regular files without blocking on a FIFO.

Evidence

The retained Linux environment passed 344 existing wrapper/capsule cases with one platform skip, plus 16 recovery cases, 17 claim cases, and seven staging-location cases. The final constructor replay retained the earlier unaffected results and reran the changed recovery behavior. These exercise the actual producer and public wrapper, abrupt owner loss, admission and settlement, dirty source and an explicit retained witness, preserved diagnostics, interrupted removal, replacement and corruption, concurrent recovery, bounded discovery, and protected worktree registrations. Two actual native-CLI cases also verified ignored and unignored repository-local staging without new recovery metadata or source/index changes.

The actual native sync-plan and claims list --json path recovered an outside-repository copy, refused a synthetic live claim without rewriting it, recovered after the fixture owner removed that claim, and refused a substituted claim namespace. On head 1081333c3cac8a1d51354f4b3005daf7fda9984c, an installed-Mac-runtime fixture created a version-2 receipt, killed the producer after preparation, and recovered through the public launcher in 615 ms, preserving source, HEAD, index, all observed native claims, and the installed binary. That Mac runtime used its existing @openclaw/fs-safe 0.8.5; the Linux proof used the checkout's locked dependencies. The Mac fixture was removed after readback.

Discovery measured 64 headers and 28,608 header bytes in 9.3 ms with no payload hashing. The affected format, lint, type graphs, compiler boundary, dependency-export check, and repository ratchets passed remotely. The actual native callback replay confirms that configured helpers still execute normally, their staging stays held after configuration removal, and a fresh ordinary capsule recovers. Regression cases also cover inactive versus active filters, deleted-file probes, ambiguous filter names, and a writer hold that survives later cleanup failures. Independent source review has no outstanding findings, and the bounded Autoreview pass over the complete patch found no P0 defects. The CI run for this head tracks hosted validation separately.

@clawsweeper

clawsweeper Bot commented Sep 18, 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 scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Sep 18, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 18, 2026, 5:00 PM ET / 21:00 UTC (Revision 2).

ClawSweeper review

What this changes

Adds commands and conservative automatic cleanup for abandoned Crabbox source copies, with checks that source, diagnostics, and lease ownership remain safe.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains useful work absent from current main. Both previous findings are resolved, and the reviewed recovery path has no remaining concrete blocking defect. The member-authored, protected PR should remain open for normal landing.

Priority: P2
Reviewed head: 1081333c3cac8a1d51354f4b3005daf7fda9984c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent, conservatively scoped implementation with resolved prior findings, meaningful boundary coverage, and reported native runtime validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The author is a member, so the ordinary external-contributor proof gate does not apply. The captured body nevertheless reports exact-head public-launcher recovery and native claim refusal/retry observations; source and negative-path coverage reveal no unresolved authority case requiring additional proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a member, so the ordinary external-contributor proof gate does not apply. The captured body nevertheless reports exact-head public-launcher recovery and native claim refusal/retry observations; source and negative-path coverage reveal no unresolved authority case requiring additional proof.
Evidence reviewed 11 items Current main still lacks abandoned-copy recovery: Fetched main contains the capsule producer and wrapper but no staging recovery modules. Its wrapper retains invocation-owned cleanup; the latest release tree also lacks these recovery modules.
Latest release comparison: The supplied latest release, v2026.9.4, contains the existing wrapper and capsule files but none of the new staging recovery modules.
Previous findings resolved: Metadata opens now include O_NONBLOCK and reject non-regular descriptors. Unsupported file/directory flush errors mark receipts nondurable; ordinary cleanup remains available. The earlier source was also inspected through GitHub after the local historical blob comparison failed.
Findings None None.
Security None None.

How this fits together

The Crabbox wrapper prepares local source copies for remote validation and preserves diagnostic outputs afterward. Recovery handles copies left behind when the original wrapper disappears, deleting them only after checking ownership and independently retained contents.

flowchart TD
  A[Local source checkout] --> B[Temporary source copy]
  B --> C[Ownership and source receipts]
  C --> D[Abandoned copy discovery]
  D --> E[Verify settlement and native claims]
  E --> F[Verify retained source and diagnostics]
  F --> G[Remove unchanged copy]
  E --> H[Keep protected copy]
  F --> H
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Tests +1500, Other +2912. Total +4412 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 1507 7 +1500
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 7 3000 88 +2912
Total 12 4507 95 +4412

Review metrics

Metric Value Why it matters
Recovery command surface 2 subcommands, 3 flags Inspection and recovery add paging and explicit retained-source selection without adding a force-delete override.
Production versus test growth Production/tooling net +2,912 lines; tests net +1,430 lines The substantial production growth is explained by separate ownership, claim, witness, artifact, and recovery checks.

Stored data model

Persistent data-model change detected: serialized state: scripts/crabbox-staging.mts, unknown-data-model-change: scripts/crabbox-staging.mts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep recovery with the staging owner, preserving uncertain copies and requiring independent source and diagnostic preservation before deletion.

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

Not applicable as a new-capability review. Abrupt producer loss is exercised by the supplied recovery fixtures and reported native runs; no runtime reproduction was executed here.

Is this the best way to solve the issue?

Yes. Extending the existing staging owner and withholding recovery when preservation cannot be established is a coherent approach; both earlier compatibility defects are repaired.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a member, so the ordinary external-contributor proof gate does not apply. The captured body nevertheless reports exact-head public-launcher recovery and native claim refusal/retry observations; source and negative-path coverage reveal no unresolved authority case requiring additional proof.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded remote-validation tooling improvement for safely reclaiming abandoned local source copies.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a member, so the ordinary external-contributor proof gate does not apply. The captured body nevertheless reports exact-head public-launcher recovery and native claim refusal/retry observations; source and negative-path coverage reveal no unresolved authority case requiring additional proof.

Evidence

What I checked:

  • Current main still lacks abandoned-copy recovery: Fetched main contains the capsule producer and wrapper but no staging recovery modules. Its wrapper retains invocation-owned cleanup; the latest release tree also lacks these recovery modules. (scripts/crabbox-wrapper.mts:3435, d9cb5f84d00e)
  • Latest release comparison: The supplied latest release, v2026.9.4, contains the existing wrapper and capsule files but none of the new staging recovery modules. (3a9d69db306c)
  • Previous findings resolved: Metadata opens now include O_NONBLOCK and reject non-regular descriptors. Unsupported file/directory flush errors mark receipts nondurable; ordinary cleanup remains available. The earlier source was also inspected through GitHub after the local historical blob comparison failed. (scripts/crabbox-staging.mts:190, 1081333c3cac)
  • Deletion authority and preservation checks: Recovery requires exclusive ownership, absent producer, recorded settlement, original claim namespace, matching payload, independently retained Git source, and preserved diagnostics. It repeats claims and content checks after asynchronous verification and revalidates the witness before removal. (scripts/crabbox-staging.mts:969, 1081333c3cac)
  • Applicable dependency contract: verifyNoStagingClaims executes the native Crabbox claims list --json command and decodes its versioned inventory. This establishes a Crabbox dependency signal; the changed behavior does not depend on the Codex harness. (scripts/crabbox-staging-claims.mts:247, 1081333c3cac)
  • Supported native inventory contract verified: Crabbox v0.56.0 emits version 1 local-claims inventories with leaseId and repoRoot, reports malformed records, and returns nonzero for inventory problems. Its annotated release tag resolves to the cited dependency commit. (internal/cli/claims.go:15, 2c9e78e32f92)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

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

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

Workflow

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

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-18T17:42:51.363Z sha 90b1948 :: blocked before merge. :: [P1] [P1] Keep unsupported directory flushing from blocking normal runs | [P2] [P2] Reject special metadata files before a blocking open

@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 18, 2026
@shakkernerd shakkernerd self-assigned this Sep 18, 2026
@shakkernerd
shakkernerd merged commit d5b46df into main Sep 18, 2026
169 of 170 checks passed
@shakkernerd
shakkernerd deleted the feat/crabbox-staging-recovery branch September 18, 2026 21:11
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Added: local inspection and recovery of abandoned Crabbox source capsules with verified ownership and retained source.

vincentkoc added a commit that referenced this pull request Sep 18, 2026
…49075-c1-control-repair

* commit 'dc5b321b5f89f9cf0e704ee202ea3059fb1ce63d': (79 commits)
  fix: start background context maintenance after durable turns (#151936)
  fix(models): avoid ambient state reads during prepared selection (#152119)
  feat: recover abandoned Crabbox source staging (#152006)
  chore(ui): refresh control ui locales (#152098)
  fix(ui): keep cloud startup prompts and progress in chat (#152024)
  fix: report completed subprocess cleanup after cancellation (#152107)
  perf(reply): reuse normalized inbound text (#152110)
  fix(cron): paused future one-shots disappear after Run now (#152126)
  perf(sessions): reuse rows and skip discarded terminal labels (#152109)
  fix(ui): keep keyboard-focused automation controls clear of sticky actions (#152135)
  fix(ui): load remote images in compact activity previews (#152045)
  refactor(health): skip unused verbose account projection (#152108)
  fix: restore dashboard test limits and SQLite test compilation (#152089)
  test(qa-lab): stabilize timeout recovery delivery proof (#152100)
  fix: probe SQLite when Node denies worker threads (#152075)
  perf(gateway): keep GitHub co-author trailer scans linear (#152115)
  fix(media): report CLI models with missing command or args (#151969)
  refactor: remove retired runtime code and duplicate helpers (#151973)
  perf(plugins): combine runtime and tool call scopes (#152101)
  test(memory): seed restart fixtures with the Gateway stopped (#152038)
  ...
vincentkoc added a commit that referenced this pull request Sep 18, 2026
…n-20260918-v4

* origin/main: (81 commits)
  fix: retire failed setup plugins without replaying facade initialization (#152026)
  fix(test): select Node for built runtime recovery fixtures (#152162)
  refactor(auth): reuse privately assembled choice groups (#152166)
  fix: preserve chat media delivery and session boundaries (#152079)
  fix: keep stale Stop messages from canceling replacement sessions (#152116)
  improve(plugins): reduce mutable argument handling overhead (#152154)
  fix(scripts): prevent host tooling drift from blocking PR workflows (#152078)
  improve: reduce model capability preparation work (#152128)
  fix: stop marking delivered scheduled reports as failed (#152165)
  fix: start background context maintenance after durable turns (#151936)
  fix(models): avoid ambient state reads during prepared selection (#152119)
  feat: recover abandoned Crabbox source staging (#152006)
  chore(ui): refresh control ui locales (#152098)
  fix(ui): keep cloud startup prompts and progress in chat (#152024)
  fix: report completed subprocess cleanup after cancellation (#152107)
  perf(reply): reuse normalized inbound text (#152110)
  fix(cron): paused future one-shots disappear after Run now (#152126)
  perf(sessions): reuse rows and skip discarded terminal labels (#152109)
  fix(ui): keep keyboard-focused automation controls clear of sticky actions (#152135)
  fix(ui): load remote images in compact activity previews (#152045)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
Add local inspection and recovery of abandoned Crabbox source capsules after verifying writer settlement, native claims, retained source, and diagnostics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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