Skip to content

[Bugfix #676] Scope porch check artifact resolution to the worktree#679

Merged
waleedkadous merged 1 commit intomainfrom
builder/bugfix-676-porch-approve-plan-approval-fa
Apr 17, 2026
Merged

[Bugfix #676] Scope porch check artifact resolution to the worktree#679
waleedkadous merged 1 commit intomainfrom
builder/bugfix-676-porch-approve-plan-approval-fa

Conversation

@waleedkadous
Copy link
Copy Markdown
Contributor

Fixes #676.

Summary

  • porch approve plan-approval failed with Plan not found when 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 the cwd passed to runPhaseChecks remained rooted at process.cwd(), so plan_exists looked in the main tree instead of the worktree.
  • check, done, and approve now derive the artifact root from the resolved status path via a new getArtifactRoot helper and rebuild a LocalResolver scoped to that path. runPhaseChecks is also invoked with the worktree as its cwd, so shell-based checks resolve relative paths against the correct tree.
  • Confirmed existing behavior: checks still run before any state write in approve; a failed check cannot flip the gate to approved.

Changes

File What
state.ts Add getArtifactRoot(statusPath) helper (three levels up from status.yaml).
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 (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.
  • Verified the new tests fail on main without the fix (3/4 fail exactly where expected).
  • pnpm exec tsc --noEmit clean.
  • Manual repro: architect runs porch approve NNN plan-approval --a-human-explicitly-approved-this from repo root against a plan that lives in .builders/<slug>/codev/plans/ and the gate flips to approved.

Pre-existing failing tests in adopt.test.ts, consult.test.ts, update.test.ts, and session-manager.test.ts are unrelated to this change.

`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.
@waleedkadous
Copy link
Copy Markdown
Contributor Author

Architect review: Approved. Worktree-scoped artifact resolution with 4 regression tests, CI green.

@waleedkadous waleedkadous merged commit 4b6b2f8 into main Apr 17, 2026
6 checks passed
@waleedkadous waleedkadous deleted the builder/bugfix-676-porch-approve-plan-approval-fa branch April 17, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

porch approve plan-approval fails with 'Plan not found' when plan is in builder worktree

1 participant