fix(01KVWMCK): reviewer installs PR-worktree deps before the AC walk#446
Merged
Conversation
The run's reviewer materialised the PR head into a fresh git worktree and ran each vitest: acceptance check against it WITHOUT ever installing dependencies. A fresh `git worktree add` carries no node_modules, so dependency-importing suites failed on UNRESOLVED_IMPORT and a genuinely-green PR was mislabelled NEEDS CHANGES -> rework-exhausted. The dev side never hit this because the dev is an agent that installs as it codes; the reviewer is a pure tool seam. Fix: install the worktree's dependencies ONCE, before the AC walk, in runReviewerSession: - New lib `prepare-review-worktree.ts` reuses the same structural toolchain resolver the dev pre-PR gate uses (resolveProjectToolchain) and runs a clean frozen install (npm ci / pnpm install --frozen-lockfile / yarn install --immutable / bun install --frozen-lockfile), gated on lockfile presence. - The install runs at the LOCKFILE's workspace root, walked up from the build home, which on a workspace/monorepo target may differ from the resolver's build-home cwd (for Flow they coincide at plugins/flow). - The install runs exactly once per review, before the per-AC loop, never per AC. - If the worktree cannot be prepared, the review surfaces a re-runnable setup-error (NOT a quality verdict), reusing the existing setup-error result path so the story is not dead-ended in doomed rework. The shared writeSetupErrorResult helper now backs both the standards-missing and the install-failure setup-error paths. Tests: new unit suite for the install helper (plan walk, per-manager frozen args, skip/success/failure/timeout) plus reviewer behavioural tests for install-once-before-the-walk and failed-install-is-a-setup-error. Existing reviewer stubs updated to route install commands. dist bundles rebuilt. Claude-Session: https://claude.ai/code/session_01JczczroEnDH6k8KMNdMMxE
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.
What & why
The run's reviewer materialised the PR head into a fresh
git worktreeand ran eachvitest:acceptance check against it without ever installing dependencies. A freshgit worktree addcarries nonode_modules, so any dependency-importing suite (or avitest.config.tsimportingvitest/config) failed onUNRESOLVED_IMPORT. The reviewer recorded that as a quality failure, derived NEEDS CHANGES, and bounced the story until it blockedrework-exhausted— with a genuinely-green PR sitting on the branch and nothing shipped. This hit essentially every story whose tests import a dependency, so one false negative on a foundational story stalled the whole backlog.The dev side never hit this because the dev is an agent that installs as it codes; the reviewer is a pure deterministic tool seam that never did.
The fix
Install the materialised worktree's dependencies once, before the AC walk, in
runReviewerSession:plugins/flow/mcp-server/src/lib/prepare-review-worktree.tsreuses the same structural toolchain resolver the dev pre-PR gate uses (resolveProjectToolchain) and runs a clean frozen install (npm ci/pnpm install --frozen-lockfile/yarn install --immutable/bun install --frozen-lockfile), gated on lockfile presence (--prefer-offlinewhere supported).cwd(for the Flow repo they coincide atplugins/flow).setup-error(never a quality verdict), reusing the existing setup-error result path so the story is not dead-ended in rework. A sharedwriteSetupErrorResulthelper now backs both the standards-missing and the install-failure setup-error paths.Acceptance criteria
Tests & checks
setup-error(AC walk skipped, worktree cleaned, result file carries the setup detail).dist/bundles rebuilt and committed (deterministic).Note for review
This fixes the very reviewer path it touches, so the currently-installed reviewer cannot validate this PR's own dependency-importing suite — it was built and verified by hand (
/ship-story-style), not via/flow:run. Merge on green CI, then/reinstall-flow+ restart to make the fix live for subsequent autonomous runs.https://claude.ai/code/session_01JczczroEnDH6k8KMNdMMxE