poteto-mode orch store: stale-lock takeover can delete a live lock and admit two writers
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- tooling
Research direction
Start in scripts/orch/store.ts at acquireLock around :385-430, especially the EEXIST path and the unconditional unlink in takeOver at :394; also inspect --force handling. Reproduce the interleaving with the in-memory filesystem approach described, then design recovery serialization and a per-acquisition token checked by release and takeover. Done means the two-acquirer/one-stale-holder schedule admits at most one writer and the regression test asserts that.
Written by the indexing model from the issue text.
Description
Found against pstack 0.15.34 at cursor/plugins 519d36aa98955bf680db01bcde5fdfba686dc901 (harness/pstack/claude-code/skills/poteto-mode/). Line numbers refer to that commit.
scripts/orch/store.ts (acquireLock, around :385-430) recovers a stale lock like this:
open(path, "wx")fails withEEXIST.- It reads the holder PID, and
holderIsDead(holder)is true. takeOver()callsunlink(path)unconditionally (:394), thencreate()again.
Between steps 2 and 3, another process can take over the same stale lock and create its own lock file. The slower
process then unlinks that new, live lock and creates its own. Both believe they hold the lock. The same applies to
--force (options.force). Every store write is a whole-file read-modify-write (unit updates, ledger records, gates,
standing orders), so two writers lose updates: units or verification records disappear.
Repro (executed in a no-write harness, using the transpiled acquireLock body over an in-memory filesystem):
A and B both fail create() with EEXIST and read the same dead holder PID.
A: unlink, create -> A holds the lock.
B resumes: unlink (deletes A's live lock), create -> B holds the lock too.
Suggested fix:
- Serialize recovery with a separate exclusive mechanism, such as an OS advisory lock (
flock) or a separate
wx-created recovery lock that is itself removed only by its creator. - Write a unique token with each acquisition (pid plus random nonce plus time), and have release and takeover check
that token instead of only the PID. - Rereading the holder just before the
unlinknarrows the window but doesn't close it. - Add a concurrency regression test for the schedule above: two acquirers, one stale holder, interleaved
read/unlink/create. Assert that at most one acquirer succeeds.
- Dominant language
- TypeScript
- Stars
- 18.2k
- Forks
- 2k
- Avg merge
- 3h 56m
- Merged PRs (30d)
- 96
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cursor/plugins
-
pstack: interrogate asks the user, which worker.md forbids for delegates that reach itPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cursor/plugins#1272 · 1 comment ·
Maintainers usually reply within 1 day
-
poteto-mode: multi-phase-plan Merge placeholder still appends every PR to a base-branch stackPossibly taken @mangeshraut712 claimed this 15 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
typescript-best-practices: schema example uses z.string().uuid(), deprecated in Zod 4Possibly taken @mangeshraut712 claimed this 14 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
cursor/plugins#1165 · 1 comment ·
Maintainers usually reply within 1 day
-
statechart: relative-symlink launcher test fails on macOS because /var is a symlinkPossibly taken @lnuxe claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cursor/plugins#1164 · 2 comments ·
Maintainers usually reply within 1 day
-
pstack docs/harness/claude-code.md: transcript slug replaces every non-alphanumeric character, not only / and .Possibly taken @isTuhin claimed this 9 days ago. Open
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
cursor/plugins#1155 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
infra needs-triage
Difficulty 2/5 Under an hour Newbie friendliness 82/100
LucasSantana-Dev/Lucky#3331 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
kOaDT/oss-oopssec-store#381 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nocobase/nocobase#11669 · 1 comment ·
Maintainers usually reply within 1 day
-
iOS: Clear Context (/clear) and model picker fallback use negative agent check instead of isClaudeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Area: API Bug Difficulty: Low Priority: Low
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
DouglasNeuroInformatics/OpenDataCapture#1937 ·
Maintainers usually reply within 1 day