Bug Description
porch approve NNN plan-approval fails with "Plan not found" when run from the main workspace root. The plan file exists in the builder's worktree (.builders/<spir-NNN-slug>/codev/plans/NNN-slug.md), but the plan_exists check looks in cwd/codev/plans/ instead of the resolved project's worktree.
Repro Steps
afx spawn NNN --protocol spir
- Builder writes plan to
.builders/spir-NNN-slug/codev/plans/NNN-slug.md
- Architect runs
porch approve NNN plan-approval --a-human-explicitly-approved-this from repo root
- Porch prints "CHECKS FAILED. Cannot approve gate." with "Plan not found"
- But state.yaml in the worktree sometimes flips to
approved anyway
Observed On
At least 3 projects (568, 615, 629) on the Shannon workspace. Behavior is inconsistent — sometimes approval silently goes through, sometimes it doesn't take effect until retry.
Root Cause
The plan_exists check (and likely spec_exists) resolves file paths relative to cwd rather than the project's resolved worktree. porch status NNN correctly resolves the worktree (via findStatusPath which was fixed in PR #674 to search .builders/ first), but the artifact existence checks don't use the same resolution logic.
Additionally, the approve command appears to write the state update BEFORE consulting the check result — so the gate flips to approved even when the check fails. This should be audited: either run checks before the write, or roll back on failure.
Expected Behavior
plan_exists (and any other path-based checks) should resolve the project's worktree from the project ID — same logic porch status uses — and check for the plan file in <worktree>/codev/plans/ instead of cwd/codev/plans/.
Impact
Architects give up on porch CLI for plan approvals and edit status.yaml by hand, which defeats the point of porch.
Reported by Shannon workspace architect session.
Bug Description
porch approve NNN plan-approvalfails with "Plan not found" when run from the main workspace root. The plan file exists in the builder's worktree (.builders/<spir-NNN-slug>/codev/plans/NNN-slug.md), but theplan_existscheck looks incwd/codev/plans/instead of the resolved project's worktree.Repro Steps
afx spawn NNN --protocol spir.builders/spir-NNN-slug/codev/plans/NNN-slug.mdporch approve NNN plan-approval --a-human-explicitly-approved-thisfrom repo rootapprovedanywayObserved On
At least 3 projects (568, 615, 629) on the Shannon workspace. Behavior is inconsistent — sometimes approval silently goes through, sometimes it doesn't take effect until retry.
Root Cause
The
plan_existscheck (and likelyspec_exists) resolves file paths relative tocwdrather than the project's resolved worktree.porch status NNNcorrectly resolves the worktree (viafindStatusPathwhich was fixed in PR #674 to search.builders/first), but the artifact existence checks don't use the same resolution logic.Additionally, the approve command appears to write the state update BEFORE consulting the check result — so the gate flips to
approvedeven when the check fails. This should be audited: either run checks before the write, or roll back on failure.Expected Behavior
plan_exists(and any other path-based checks) should resolve the project's worktree from the project ID — same logicporch statususes — and check for the plan file in<worktree>/codev/plans/instead ofcwd/codev/plans/.Impact
Architects give up on porch CLI for plan approvals and edit status.yaml by hand, which defeats the point of porch.
Reported by Shannon workspace architect session.