fix: reclaim stale local feature locks - #170
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 1:44 AM ET / 05:44 UTC. ClawSweeper reviewWhat this changesThis PR reclaims only dead same-host feature locks during claims, adds Merge readinessThe repaired PR head directly addresses the prior stale-unlink race: lock claims and stale cleanup now use the same per-feature filesystem mutation boundary, and the branch includes a focused replacement-lock regression test. The PR is still necessary because current Priority: P1 Review scores
Verification
How this fits togetherClawpatch review workers claim a feature record plus a matching flowchart LR
A[Review or cleanup command] --> B[Feature record and lock file]
B --> C[Per-feature mutation lock]
C --> D[Re-read both lock records]
D --> E{Both owners stale locally?}
E -->|Yes| F[Clear stale state]
E -->|No| G[Keep live or remote owner]
F --> H[Claim feature or report cleanup]
G --> H
Before merge
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Merge the final serialized implementation after normal maintainer review, retaining the race regression and the conservative same-host-only rule; this resolves the linked lock-recovery issue without changing remote-lock behavior. Do we have a high-confidence way to reproduce the issue? Yes. The linked issue gives a concrete killed-review reproduction, and the PR includes after-fix built-CLI runs plus a focused interleaving regression for the stale-reclaim race. Is this the best way to solve the issue? Yes. Reclaiming only locks whose hostname matches and whose PID is dead, while serializing claims and cleanup around both stored representations, is the narrowest safe repair for the established lock contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4a5028c27f01. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (25 earlier review cycles; latest 8 shown)
|
|
I reproduced the cleanup/claim race reported by ClawSweeper and repaired it on this branch while preserving the contributor commit. The final branch now serializes claim and stale-reclaim mutations across processes, re-reads both persistent lock representations inside that boundary, and conservatively preserves a feature whenever either representation is live or belongs to another host. It also documents the automatic reclaim and stale-only cleanup behavior. Proof on the final branch:
Dependency note: the coordination layer uses |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix: reclaim stale local feature locks This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Closes #168
What Problem This Solves
Fixes an issue where users who restarted
clawpatch reviewafter a killed run would remain blocked by a stale per-feature lock when the recorded process was already gone on the same host.Why This Change Was Made
The change reclaims only local dead-PID feature locks before claiming a feature, and adds
clean-locks --stale-onlyfor the same conservative cleanup path. Locks from live local processes or other hosts are preserved, and the existing full cleanup behavior remains available throughclean-locks.User Impact
Users can recover interrupted review runs without manually deleting lock files, while active or remote review work remains protected from accidental cleanup.
Evidence
Real CLI behavior proof from a disposable local fixture:
Focused and broader validation:
pnpm test src/workflow.test.tspnpm typecheckpnpm lintpnpm format:checkpnpm testengines.node >=22requirement.pnpm buildCommit verification:
Disclosure: AI was used to understand the codebase and review the fix.