qwen-code/packages/cli
Shaojin Wen 36cf31fb6c
Some checks are pending
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run
E2E Tests / web-shell Browser Regression (push) Waiting to run
refactor(review): run the test-efficacy probe in a disposable worktree (#6836)
The probe used to revert the PR's source to base IN the shared review worktree
and restore it in a `finally`. That shared tree is the one every Step 3 review
agent reads, and the in-place mutate/restore was the root of two findings on
#6790:

  - a concurrent reader could observe the tree half-reverted to base for the
    probe's whole duration (Critical), and the later restore cannot un-produce a
    finding written from the wrong source;
  - the restore's in-place delete followed a PR-controlled symlink out of the
    tree and removed an outside file (P0, band-aided with `safeRmWithin`).

Both share one cause — mutating a live, shared tree — and one fix retires both.
The probe now runs in its OWN disposable worktree, checked out at the PR head as
a sibling of the shared one (`.qwen/tmp/review-pr-<n>-probe`) and removed
wholesale when it finishes:

  - the shared tree is never touched, so no reader can see a reverted state;
  - there is no in-place restore, so the delete that followed a symlink is gone
    with it — `safeRmWithin` stays only as belt-and-suspenders on the
    revert-phase delete of added files;
  - `node_modules` needs no per-tree install: the probe tree is nested under the
    repo, so `npx vitest` resolves upward to the repo-root `node_modules`,
    exactly as the shared worktree already does. (Confirmed empirically before
    relying on it — this is what had the refactor deferred.)

Because the shared tree is no longer mutated, the dirty-worktree guard is gone
(nothing the caller has uncommitted is ever discarded), and the loud
`restoreFailure` / non-zero exit becomes a soft `cleanupFailure` warning: a
leftover probe worktree does not corrupt anything and is swept at the next run's
`worktree add` and by `cleanup.ts`.

Verified by driving the real handler (new `test-efficacy.integration.test.ts`,
real git worktrees, a stub vitest bin): verdicts are unchanged (gated/inert),
the shared tree is byte-identical before and after, the probe tree is always
discarded, and the symlink P0 repro leaves the outside file intact WITHOUT
`safeRmWithin` having to refuse — isolation alone protects it.

Closes #6832.
2026-07-13 17:07:21 +00:00
..
src refactor(review): run the test-efficacy probe in a disposable worktree (#6836) 2026-07-13 17:07:21 +00:00
index.ts fix(cli): add bootstrap fast paths (#6188) 2026-07-02 22:28:11 +00:00
package.json feat(serve): persist dynamic workspace registrations (#6716) 2026-07-11 16:49:40 +00:00
test-setup.ts feat(serve): persist dynamic workspace registrations (#6716) 2026-07-11 16:49:40 +00:00
tsconfig.json feat(channels): add WeCom intelligent robot channel (#6436) 2026-07-07 15:24:19 +00:00
vitest.config.ts feat(cli): Add runtime daemon channel control (#6741) 2026-07-13 02:53:27 +00:00