Repository navigation
fix(patchy): a refresh killed mid-activation no longer locks the repo - #695
Merged
Merged
Conversation
Owner
Author
|
GPT 6.1 Sol (xhigh) reviewed this in three rounds. Every finding is fixed or dismissed below. Round 1 (on 1d7ea13)
Round 2 (on 47ec6e8; it agreed the dismissals of 3 and 5 hold)
Round 3 (on 0fe1935): both resolved, no new findings. |
The project lock now records its owner through the dev lock's claim core, moved to ownerLock.ts. A dead owner's lock is reclaimed; a live or unidentifiable owner is refused with a message that reaches the person. Refresh reinstalls when a dead run's transaction directory is present and removes it once that install succeeds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ck owner birth now returns undefined only when the process is gone and throws when it cannot tell (no ps, unreadable procfs), so claim refuses instead of reclaiming and dev callers fail safe. The dev lock again requires its own birth, an owner pid must be positive, and the tests cover stale managed bytes and a failed install keeping the orphan. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ps printing a diagnostic, or printing nothing on success, now cannot tell rather than meaning gone. claim takes the caller's own birth, so the dev lock records the birth it validated and the project lock records none only where its lookup fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
allisonmahmood
force-pushed
the
fix/580-stale-refresh-lock
branch
from
October 15, 2026 20:44
0fe1935 to
ff671d1
Compare
allisonmahmood
added a commit
that referenced
this pull request
Oct 16, 2026
…u when they fail (#720) Release 13's What's new entry, written from `c9b8fc4`, ahead of deploying it. `patchy` and `CURRENT_RELEASE` move to `0.13.0`, so CLIs and patch repos installed before this deploy are told to upgrade. | Change | PRs | | --- | --- | | New: Home puts the patches you use first | #713, #716, #719 | | New: Every patch in one list | #715 | | Improved: Each patch's page leads with Open | #717 | | New: See when your tools are failing | #718 | | Fixed: Everyone has a name | #687 | | Improved: Your company's look is easier to get right | #697, #696, #703, #688 | | Improved: Forms follow your look's error states | #691, #692 | | Improved: Clearer answers when a publish goes wrong | #686, #685, #689 | | Fixed: Your agent's Patchy commands are steadier | #695, #704, #680, #681 | | Behind the scenes: stricter checks on static pages and tools' database requests; malformed requests are logged | #682, #693, #683 | | Behind the scenes: usage numbers count every publish, sharing change and restore | #698, #699, #700, #690 | | Test and tooling only, no line | #705, #702, #701, #694, #684, #607 | Made by Claude Opus 5.5 in Claude Code, running in T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A refresh, add, remove or dev start killed while holding
.patchy/refresh-lock(SIGKILL, a closed terminal) left the lock behind, so every later run in the repo failed withBegin project transaction failed.until someone found and deleted it. A kill between activation's root swaps also left a mix of old and new managed files, and the dead run's.patchy/refresh-*directory, which can hold a whole oldnode_modules, was never removed.Fix
birth/sameProcesshelpers move toownerLock.ts, and both locks use it. A lock whose owner is gone is reclaimed. A live owner is refused with "Another patchy command is updating this repo's managed files. Retry when it finishes." A lock with no identifiable owner (an empty slot that stays empty on a brief recheck, a malformed owner file, an owner without a birth) is never reclaimed: the refusal names.patchy/refresh-lockand says to remove it only if no other patchy command is running in the repo.ProjectLockederror. The refresh and dev-preparation IO wrappers pass it through likeProjectChanged, so it reaches text and--jsoninstead of " failed.".node_modulesdoes not. It removes those directories once the transaction succeeds. Regeneration rewrites every managed root; the leftover snapshot is not restored. Dev start never installs, so it leaves them for the next refresh.ps, an unreadable procfs) never counts as a dead owner.birthnow returns nothing only when the process is gone and throws when it cannot tell. The lock then refuses, and dev's signal and cleanup paths stop rather than treat a live daemon as gone. The dev lock still requires this process's own birth, as before.EPERMfrom a rename onto an existing directory counts as occupied.renamesilently replaces an empty directory, which is what a pre-fix CLI holds.Tested by hand
pnpm dev up brightline, tier 2new-businessrepo. Every managed root (patchy/_generatedand the sevenpatchy-*skills) was first marked as old. The refresh was SIGKILLed the moment the newpatchy/_generatedwas renamed into place, by an inotify watch onpatchy/.Before (origin/main's CLI from source):
This branch, against that pre-fix empty lock (refused, never reclaimed):
This branch, killed mid-activation and recovered. The lock was removed as the message says, and
refresh-aAFKkofrom main's run was left in place.A live owner. A refresh was frozen with SIGSTOP right after it claimed the lock:
The environment's global
patchy devfails on tier 2 repos withCannot find module 'workerd/package.json', on untouched repos too. It is unrelated to this change, so dev was checked through the repo's ownpnpm patchy dev, as the issue's repro does.Surfaces
code: the refusal is exit 1,kind: "local", so ADR-0004 is unchanged.packages/patchy/README.md's refresh section now says how an interrupted run recovers. No skill describes the lock.Out of scope, per the brief: crash-atomic activation, repos already stuck under a pre-fix CLI (one
rm -r .patchy/refresh-lock), andpatchy devon Windows.Closes #580
Made by Claude Opus 5.5 in Claude Code, running in T3 Code.