Skip to content

fix(worktrees): retire redundant removed snapshots explicitly - #156464

Merged
fuller-stack-dev merged 4 commits into
mainfrom
openclaw/snapshot-retirement-807-20260923
Sep 23, 2026
Merged

fuller-stack-dev merged 4 commits into
mainfrom
openclaw/snapshot-retirement-807-20260923

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Completed update-PR worktree cleanup cannot explicitly retire an already-removed, redundant snapshot without waiting for retention expiry or invoking broader cleanup.

Related: #156265, #156366.

User Impact

Operators can retire one ordinary removed snapshot using its exact ID, ref, commit and removal timestamp, while proving that its source remains retained. This does not deploy an update, run global garbage collection, or claim physical disk recovery.

Exact-state recovery snapshots and retained checkouts remain outside this operation. Unknown or nonempty provisioning, projection custody, live/removal consumers, changed identities, and reappeared checkouts are preserved.

Why This Change Was Made

Adds local worktrees retire-snapshot at the existing snapshot owner. It uses the allocation lease, verifies retained tree and parent history, atomically checks reference custody, and removes only the exact redundant snapshot and registry record. Automatic exact-state expiration is unchanged. Contributor ancestry is preserved.

Retention decision — accepted scope

The explicitly requested and accepted maintainer scope is CLI-only early retirement of a proven-redundant ordinary removed snapshot, before the normal 30-day recovery deadline. This accepts permanent loss of that entry's managed worktrees restore capability; retaining source elsewhere is not a promise to recreate the managed restore entry.

The existing Git snapshot-ref and SQLite worktree owners remain authoritative. No schema, stored representation, new persistence, migration or automatic retention policy is introduced. Waiting for normal expiry remains available; broader/global cleanup is not used for this exact-ID action. Unknown inventory, projections, exact-state snapshots, live paths/registrations and active/removal custody remain excluded. The allocation lease, final registry reread and atomic reference checks preserve concurrent newer/foreign state. No physical disk-recovery amount is promised.

The documented interruption behavior is also accepted: Git ref deletion and registry completion are not one cross-store crash-atomic transaction. If interrupted after ref deletion, inspect the remaining record and projection custody before further cleanup; a missing ref is not permission to bypass the guards. Successful retirement is intentionally irreversible as a managed-restore operation, with no new rollback or backup promise. This is the bounded retention decision requested in the completed review, not a change to automatic expiry or richer recovery.

Evidence

Current candidate: b969fa0f3ddca66779b572defa113ac1585bcfea.

Independent full-candidate source/test review found no actionable P0–P2 defects. The retirement implementation remains unchanged from qualified head d409b006b73271336bfb434c1fc56e789c624fd8; main integration preserves contributor ancestry. Required hosted CI passed on final head b969fa0f3ddca66779b572defa113ac1585bcfea: CI run, including the corrected integration shard, and the enforced CI gate. Native squash merge landed as d7b45d7e76c66a5c8ea048012a1f178840d818c8.

Completed on the identical implementation at d409b006b73271336bfb434c1fc56e789c624fd8:

  • Full build passed.
  • Retirement tests: 33/33, using pnpm test src/agents/worktrees/service.retire-snapshot.test.ts --maxWorkers=1: 155.28s wall, 144.04s Vitest including cold worker compilation. Real Git transactions, reference locks, SQLite custody and deterministic races require process-backed checks; mocks cannot establish those contracts. Hosted per-file timing has not been extracted.
  • GC siblings 37/37, public CLI siblings 20/20, selected projection-retention cases 6/6 passed.
  • The real public CLI passed synthetic create/remove/wrong-timestamp refusal/exact-retirement checks in physically private state, preserving source/outcome refs. The fixture was deleted. No completed live cleanup target was tested.
  • Formatting, source guards, production/test types, all dead-export scans, script lint, schema and remaining boundary guards passed. Exact-head hosted core-lint shards and general lint passed.

The complete new test file, helpers, imports, setup/teardown, routing and assertions were audited. Async provisioning reads are awaited before teardown. No valid assertion, timeout or failure case was weakened.

CI integration prerequisite

The refreshed acf0bca53c418aa06267312c185da7ad3c0b2fef CI job exposed three unchanged Session Share integration failures after landed #156400 moved catalog invocation under a registered service lifetime. The old integration helper never started that service. This candidate starts and stops the real registered service inside its existing private-state fixture; no product behavior, assertions, skips, retries or timeouts were changed.

A pristine local run reproduced the same 3 failures / 10 passes. The corrected full file passes 13/13 using pnpm test test/plugins/session-share.integration.test.ts --maxWorkers=1: 94.50s wall, 9.583s test-file execution, 86.53s Vitest and 93.52s runner (including 45.056s cold compilation). The entire touched file and its helpers, imports and teardown were audited. Formatting, compiler-boundary and test-root types, coercion guards, all three unused-export scans, script lint and targeted type-aware lint passed. The corrected hosted shard passed all 13/13, with 6.627s file execution (209.25s for its 41-file logical shard).

Known broader-check results

The initial CI run failed three unchanged tooling fixtures. All three owning fixes landed in #156136 (ceb109668b4396181205e330a2b466c132fede89) and are included in the refreshed head; the failed run is not claimed as a pass.

Local full-core lint reports existing max-lines errors in unchanged src/cron/service/timer.test.ts (1022/1000) and ui/src/pages/chat/components/chat-detail-panel.ts (701/700). No suppression or unrelated repair was added. Required hosted lint remains enforced.

An earlier broad pre-integration projection run had two macOS EILSEQ filename-fixture errors and one Podman skip. It is not current-candidate pass evidence; the six applicable retention cases passed separately.

@clawsweeper

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

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review September 23, 2026 11:15
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes agents Agent runtime and tooling size: L labels Sep 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 23, 2026, 9:01 AM ET / 13:01 UTC (Revision 4).

ClawSweeper review

What this changes

Adds a local command to retire one redundant removed worktree snapshot, documents its safeguards, adds retirement coverage, and repairs Session Share integration-test service startup and shutdown.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains useful work absent from current main, with no actionable correctness findings. The previously identified retention-policy decision remains unresolved; the latest commit only repairs the Session Share test lifecycle.

Priority: P2
Reviewed head: b969fa0f3ddca66779b572defa113ac1585bcfea
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with substantial custody coverage and no concrete code findings; the outstanding retention decision does not reduce patch quality.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its body reports a private-state public CLI retirement and refusal run on unchanged implementation, supported by real Git/SQLite boundary coverage; this reviewer ran no target code. Stored formats and automatic upgrade behavior are unchanged, while retention acceptance remains a separate decision.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its body reports a private-state public CLI retirement and refusal run on unchanged implementation, supported by real Git/SQLite boundary coverage; this reviewer ran no target code. Stored formats and automatic upgrade behavior are unchanged, while retention acceptance remains a separate decision.
Evidence reviewed 9 items Pinned introduction and review continuity: Reviewed the introduced delta from 6457db9 to the pinned head. Comparing the retirement implementation, CLI, and retirement tests with the earlier qualified head produced no differences. No prior code findings were carried forward; the prior retention decision remains relevant.
Current main still lacks selective early retirement: Current main exposes list, create, remove, restore, and gc, but no retire-snapshot command. Its snapshot owner retains the existing expiration path. The relevant production files are unchanged between the pinned base and fetched main.
Latest-release check: The CLI source retrieved for v2026.9.5 also lacks selective snapshot retirement. The supplied related merged PRs address different update or test-lifecycle behavior and do not implement this command.
Findings None None.
Security None None.

How this fits together

Managed worktrees preserve removed checkouts as Git snapshots with SQLite recovery records. The new CLI operation checks the operator’s exact snapshot identities and retained source before removing that snapshot’s managed restore entry.

flowchart TD
  A[Operator supplies exact identities] --> B[Allocation lease]
  B --> C[Check registry and recovery custody]
  C --> D[Verify retained tree and history]
  D --> E[Atomic Git reference transaction]
  E --> F[Delete matching registry record]
  C --> G[Refuse and preserve recovery]
  D --> G
Loading

Decision needed

Question Recommendation
Should operators be allowed to permanently retire an ordinary redundant snapshot before its 30-day recovery deadline using these exact-identity safeguards? Accept the bounded early-retirement exception: Record acceptance for this explicit local command while retaining the automatic deadline and excluding exact-state, provisioned, and projection recovery data.

Why: This changes the documented retention contract, whose repository policy requires recorded acceptance; the proposal and prior automated review do not establish that acceptance.

Before merge

  • Resolve merge risk (P1) - Explicit retirement permanently removes the selected snapshot’s managed restore capability before the normal 30-day deadline. Source redundancy does not preserve that restore entry, and recorded acceptance of this retention exception remains outstanding.
  • Complete next step (P2) - Record or link maintainer acceptance of explicitly forfeiting managed restore before the ordinary snapshot retention deadline.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +293, Tests +608, Docs +33. Total +934 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 295 2 +293
Tests 3 628 20 +608
Docs 1 33 0 +33
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 956 22 +934

Review metrics

Metric Value Why it matters
Operator surface 1 new subcommand; 5 required identity options Retirement requires an explicit snapshot and retained-source selection instead of changing cleanup defaults.
Production versus test growth Production +293 net lines; tests +607; test routing +1 The stated production-growth justification is exact-identity and recovery-custody validation at the existing retirement owner.

Merge-risk options

Maintainer options:

  1. Approve the explicit recovery cutoff (recommended)
    Accept and record that selecting this command forfeits managed restore for the identified redundant snapshot before normal expiry.
  2. Defer early retirement
    Keep the existing expiration-only behavior until the retention exception has product approval.

Technical review

Best possible solution:

Keep selective retirement opt-in, preserve the existing automatic retention policy and recovery exclusions, and record acceptance of the early-restoration cutoff.

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

Not applicable as a defect reproduction: this adds a selective cleanup operation that current main and the latest release do not expose.

Is this the best way to solve the issue?

Yes, technically: extending the existing snapshot owner with exact reference checks is a focused approach. Its early-retention exception still requires acceptance.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded operator cleanup capability, with no demonstrated urgent runtime regression.
  • merge-risk: 🚨 session-state: Invoking the new command removes an existing managed recovery entry before its documented retention deadline.
  • 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 MEMBER-authored PR is exempt from the external-contributor proof gate. Its body reports a private-state public CLI retirement and refusal run on unchanged implementation, supported by real Git/SQLite boundary coverage; this reviewer ran no target code. Stored formats and automatic upgrade behavior are unchanged, while retention acceptance remains a separate decision.

Evidence

What I checked:

  • Pinned introduction and review continuity: Reviewed the introduced delta from 6457db9 to the pinned head. Comparing the retirement implementation, CLI, and retirement tests with the earlier qualified head produced no differences. No prior code findings were carried forward; the prior retention decision remains relevant. (src/agents/worktrees/snapshot-host.ts:165, b969fa0f3ddc)
  • Current main still lacks selective early retirement: Current main exposes list, create, remove, restore, and gc, but no retire-snapshot command. Its snapshot owner retains the existing expiration path. The relevant production files are unchanged between the pinned base and fetched main. (src/cli/worktrees-cli.ts:33, bdd47f252a33)
  • Latest-release check: The CLI source retrieved for v2026.9.5 also lacks selective snapshot retirement. The supplied related merged PRs address different update or test-lifecycle behavior and do not implement this command. (src/cli/worktrees-cli.ts, ec9c1a13db89)
  • Deletion safeguards: The new path checks exact identity, repository identity, absent checkout/registration, identical trees, retained parent history, empty known provisioning, absent projection custody, and run/removal consumers. The final Git transaction verifies retained-source custody and absent pending removal while deleting the expected snapshot reference. (src/agents/worktrees/snapshot-host.ts:193, b969fa0f3ddc)
  • Retention checkpoint: Existing documentation promises 30-day restorability; the added section explicitly says successful early retirement removes the registry entry and prevents restore. Repository storage guidance requires recorded acceptance for retention changes. The captured body describes the proposal but supplies no accepted retention exception; the REST discussion and review reads supplied no human acceptance. Public docs: docs/reference/database-schemas/storage-changes.md. (docs/reference/database-schemas/storage-changes.md:1947, b969fa0f3ddc)
  • Boundary coverage and reported execution: Read the complete retirement test file, including real Git/SQLite preservation assertions, changed-reference races, symbolic-reference retargeting, newer registry lifecycle, and revoked caller guard before deletion. The captured PR body reports 33 passing retirement cases and a private-state public CLI create/remove/refusal/retirement run at d409b00. Those are contributor-reported results; this review executed no target code. (src/agents/worktrees/service.retire-snapshot.test.ts:452, b969fa0f3ddc)

Likely related people:

  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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 (3 earlier review cycles)
  • reviewed 2026-09-23T11:21:26.300Z sha d409b00 :: needs changes before merge. :: none
  • reviewed 2026-09-23T12:06:34.989Z sha acf0bca :: needs maintainer review before merge. :: none
  • reviewed 2026-09-23T12:15:31.524Z sha acf0bca :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Sep 23, 2026
@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) September 23, 2026 13:04
@fuller-stack-dev
fuller-stack-dev merged commit d7b45d7 into main Sep 23, 2026
230 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/snapshot-retirement-807-20260923 branch September 23, 2026 13:08
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
…aw#156464)

* fix(worktrees): retire redundant removed snapshots explicitly

* fix(worktrees): preserve current recovery owners during explicit retirement

* test(session-share): run integration catalog service lifecycle
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. 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.

1 participant