Repository navigation
fix(worktrees): retire redundant removed snapshots explicitly - #156464
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 23, 2026, 9:01 AM ET / 13:01 UTC (Revision 4). ClawSweeper reviewWhat this changesAdds 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 Review scores
Verification
How this fits togetherManaged 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
Decision needed
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
Agent review detailsSecurityNone. PR surfaceSource +293, Tests +608, Docs +33. Total +934 across 8 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash auto-merge.
|
…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
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-snapshotat 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 restorecapability; 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 headb969fa0f3ddca66779b572defa113ac1585bcfea: CI run, including the corrected integration shard, and the enforced CI gate. Native squash merge landed asd7b45d7e76c66a5c8ea048012a1f178840d818c8.Completed on the identical implementation at
d409b006b73271336bfb434c1fc56e789c624fd8: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.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
acf0bca53c418aa06267312c185da7ad3c0b2fefCI 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) andui/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.