[Bugfix #676] Scope porch check artifact resolution to the worktree#679
Merged
waleedkadous merged 1 commit intomainfrom Apr 17, 2026
Merged
Conversation
`porch approve plan-approval` was failing with "Plan not found" when run from the main workspace root while the plan lived in the builder worktree. `findStatusPath` (fixed in PR #674) already resolves the worktree, but the artifact resolver and the cwd passed to `runPhaseChecks` remained rooted at `process.cwd()`, so checks like `plan_exists` looked in the wrong tree. `check`, `done`, and `approve` now derive the artifact root from the resolved status path via `getArtifactRoot` and rebuild a LocalResolver scoped to that path. `runPhaseChecks` is called with the worktree as its cwd so shell-based checks resolve relative paths against the right tree. Checks still run before any state write in `approve`, so a failed check cannot flip the gate to `approved`. - state.ts: add `getArtifactRoot(statusPath)` helper. - artifacts.ts: `getResolver(workspaceRoot, artifactRoot?)` lets callers point the local backend at a worktree while still loading config from the main workspace. - index.ts: `check`/`done`/`approve` build a scoped resolver and pass `artifactRoot` to `runPhaseChecks` and `resolveArtifactBaseName`. - __tests__/bugfix-676-approve-worktree-artifacts.test.ts: regression coverage for `approve`, `check`, and `done` against a worktree layout.
Contributor
Author
|
Architect review: Approved. Worktree-scoped artifact resolution with 4 regression tests, CI green. |
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.
Fixes #676.
Summary
porch approve plan-approvalfailed withPlan not foundwhen the plan lived in a builder worktree.findStatusPath(PR Decouple worktree/branch/PR, add verify phase, remove TICK (#653) #674) already resolves the worktree, but the artifact resolver and thecwdpassed torunPhaseChecksremained rooted atprocess.cwd(), soplan_existslooked in the main tree instead of the worktree.check,done, andapprovenow derive the artifact root from the resolved status path via a newgetArtifactRoothelper and rebuild aLocalResolverscoped to that path.runPhaseChecksis also invoked with the worktree as itscwd, so shell-based checks resolve relative paths against the correct tree.approve; a failed check cannot flip the gate toapproved.Changes
state.tsgetArtifactRoot(statusPath)helper (three levels up fromstatus.yaml).artifacts.tsgetResolver(workspaceRoot, artifactRoot?)lets callers point the local backend at a worktree while still loading config from the main workspace.index.tscheck/done/approvebuild a scoped resolver and passartifactRoottorunPhaseChecksandresolveArtifactBaseName.__tests__/bugfix-676-approve-worktree-artifacts.test.tsapprove,check, anddoneagainst a worktree layout (including a negative test that a decoy plan in the main tree cannot approve the gate).Test plan
pnpm exec vitest run src/commands/porch/__tests__/bugfix-676-approve-worktree-artifacts.test.ts— 4/4 pass.pnpm exec vitest run src/commands/porch— full porch suite 275/275 pass.mainwithout the fix (3/4 fail exactly where expected).pnpm exec tsc --noEmitclean.porch approve NNN plan-approval --a-human-explicitly-approved-thisfrom repo root against a plan that lives in.builders/<slug>/codev/plans/and the gate flips toapproved.Pre-existing failing tests in
adopt.test.ts,consult.test.ts,update.test.ts, andsession-manager.test.tsare unrelated to this change.