qwen-code/docs
Shaojin Wen 7091b8c761
fix(review): lock the PR review worktree lease against concurrent sessions (#9211)
* fix(review): lock the PR review worktree lease against concurrent sessions

The /review worktree lives at a fixed path per PR number, and the lease recording its owning session was only consulted by the end-of-session crash sweep. A second session reviewing or finishing the same PR deleted the first session's worktree, branch, and side files mid-run (#9205).

Make the lease double as a lock: fetch-pr refuses with an actionable error before touching anything when another session holds it, and cleanup skips the whole target with a note. Ownership is per session, so drift restarts and later rounds of a multi-prompt review are not locked out. A missing worktree now fails repo-context with a re-run-fetch-pr message instead of a bare ENOENT.

* fix(review): roll back the lease on fetch-pr failures and scope the missing-worktree remedy

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(review): shield live leases from the cleanup sweep and roll back on any fetch-pr failure

* fix(review): re-check the lease after cleanup's audit to close a TOCTOU (#9211)

- Re-read the lease after the network-bound bypass audit and before any destructive step, so a session that acquires the lease during the audit is skipped, not destroyed (R2-10).

- Narrow the cleanup lease-skip guard to the real lease shape so a target named 'lease' still has its own side files swept (R2-1).

- Make the fetch-pr lease rollback best-effort via tryRemove so an un-removable lease file cannot mask the original failure (R2-5).

- Pin the lease-lock wiring and success/rollback invariants in tests (R2-2, R2-7, R2-8, R2-11).

* fix(review): validate fetch-pr's number and release leases off side-file residue (#9211)

The lease gate only engaged `pr-\d+` targets while cleanStale destroyed
worktreePath(prNumber) for any input, so a malformed number bypassed the
lock and deleted a live holder's worktree; refuse non-positive-integer
pr_number before the gate like the sibling commands. Cleanup now releases
the lease once the worktree and branch steps succeed instead of holding it
on an un-deletable side file, which wedged every later review of the PR.
The lease-file grammar is one shared predicate (isReviewLeaseFile) across
the writer, the sweep guard, and the finalizer scan, and the lease tests
pin the arguments and ordering the mocks previously left blind.

* fix(review): acquire review leases atomically and fail closed on identity (#9211)

Close the round-5/6 lease-lock findings:

- Create the lease with `flag: 'wx'` so two concurrent fetch-prs that both
  pass the gate's read cannot clobber each other's lease; on EEXIST,
  same-session re-fetch rewrites, a foreign holder refuses (R6-1).
- Roll the lease back on failure only when this run created it, and
  compare ownership before deleting so a re-fetch keeps the session's
  live lease and a lease acquired during a stuck run survives (R6-2).
- Refuse fetch-pr before any state when QWEN_CODE_SESSION_ID /
  QWEN_CODE_PROMPT_ID are absent instead of running lease-less (R6-3).
- Register the lease inside the rollback try (R6-5).
- Track the platform separator in the lease assertion (R6-4) and gate
  the POSIX-only ENOTDIR test off Windows (R5-1).
- Pin the `Number(prNumber) <= 0` validation disjunct (R5-2) and arm
  the side-file sweep in the lease-skip test (R4-3).

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: qwen-code-autofix[bot] <qwen-code-autofix[bot]@users.noreply.github.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev@service.alibaba.com>
2026-08-17 00:48:00 +00:00
..
assets feat: support workspace display names (#7179) 2026-07-20 15:16:44 +00:00
design feat(release): user-facing bilingual digest for release notes (#9216) 2026-08-17 00:12:04 +00:00
developers feat(daemon): Isolate the Conversations runtime boundary (#9181) 2026-08-16 17:32:45 +00:00
e2e-tests feat(worktree): Phase D — startup --worktree flag + symlinkDirectories + PR refs (#4381) 2026-05-27 17:04:51 +08:00
images fix(web-shell): render built-in tag icons (#7024) 2026-07-17 15:33:34 +00:00
plans feat(daemon): Isolate the Conversations runtime boundary (#9181) 2026-08-16 17:32:45 +00:00
superpowers feat(cli): reference prior sessions via @ and add completion tabs (#7302) 2026-07-24 06:11:48 +00:00
users fix(review): lock the PR review worktree lease against concurrent sessions (#9211) 2026-08-17 00:48:00 +00:00
verification/abort-controller-refactor fix(core): stop AbortSignal listener leak in long sessions (MaxListenersExceededWarning) (#4366) 2026-05-26 14:21:49 +08:00
_meta.ts feat: refactor docs 2025-12-05 10:51:57 +08:00
index.md fix: lint issues 2025-12-19 15:52:11 +08:00