Skip to content

Fix #1903: PIR prompts match porch; porch renders {{issue.number}}/{{issue.title}} - #1904

Merged
waleedkadous merged 13 commits into
mainfrom
builder/bugfix-1903
Nov 16, 2026
Merged

waleedkadous merged 13 commits into
mainfrom
builder/bugfix-1903

Conversation

@waleedkadous

@waleedkadous waleedkadous commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

PIR's prompts (mostly prompts/review.md) disagreed with pir/protocol.json and with what porch does, so a builder following them literally stalled or skipped steps. Separately, porch never substituted {{issue.number}} / {{issue.title}}, so PIR, AIR and BUGFIX prompts reached builders with the literal tags. This fixes porch once and rewrites the PIR files (both trees, byte-identical) against porch's actual behavior.

Fixes #1903

Problem → Root Cause → Fix

# Problem Root cause (verified in porch source) Fix
8 {{issue.number}} / {{issue.title}} render literally porch/prompts.ts matched \{\{(\w+)\}\} only; and BUGFIX's porch id is bugfix-<N>, so fetchIssue(state.id) never found the issue (BUGFIX Goal header showed the slug) Porch derives the issue id from the porch id (issueNumberFromPorchId, moved to lib/issue-id.ts), fetches it once through the workspace's configured forge, substitutes dotted names. Unknown names are still left as written; issue.title stays visibly unrendered if the fetch fails. No AIR/BUGFIX prompt edits needed.
1, 2 Reviewer count / wrong reviewer prompt verify was type: impl, ["gemini","codex"] → loaded impl-review.md (a pre-dev-approval review) type: pr (loads pr-review.md; consult --type pr finds the PR for the branch, which exists by then), three models. Deleted impl-review.md, which nothing loads now. Docs say how to reduce via porch.consultation.byProtocol.pir.models.
3, 4, 7 Who runs consult; verdicts; REQUEST_CHANGES; post-approval checks Porch emits consult … --output <id>-review-iter1-<model>.txt as a task (next.ts); REQUEST_CHANGES requires a rebuttal file, then porch done fires the gate; re-running porch done at a pending gate does not re-consult; gate_status is only in porch status --json; PR numbers are pr_history[].pr_number review.md steps 4a–10 rewritten to that flow. Verdicts come from porch's own output (the old grep '^approve' returned UNKNOWN on a real VERDICT: REQUEST_CHANGES file). After approval, porch next must return status: complete + the merge task.
5 Four accounts of the pr gate — One rule everywhere: architect relays the human's approval → builder runs porch approve <id> <gate> --a-human-explicitly-approved-this → builder merges with gh pr merge --merge. Removed "wait for porch wake-up", "human merges on GitHub", and "approve with Cmd+K G" from the builder-facing summaries.
6 Gate notification notify.ts: architect-bound gate notifications were removed on purpose Notify step (afx send architect …) in plan, implement, review and builder-prompt. Porch's own gate-pending text (next.ts, "The architect has already been notified") now says porch does not notify and how to record the relayed approval.
9 No Baked Decisions — Added to protocol.md, builder-prompt.md, plan.md, implement.md, consult-types/pr-review.md (AIR's wording, adapted for no spec).
10 Minor — Signal blocks marked informational in all three prompts; git log "$MERGE_BASE"..HEAD not main..HEAD; View Diff (the VS Code command's name); {{artifact_name}} instead of a dangling <slug>; implement.md no longer cites a null verify block; PR title [PIR #N] … to match the commit prefix.

Testing

  • Regression test porch/__tests__/bugfix-1903-issue-variables.test.ts (goes through buildPhasePrompt): PIR id, bugfix-<N>, tracker key, failed fetch, no-issue id, plus every shipped PIR/AIR/BUGFIX prompt in both trees rendered with no {{issue.*}} left. With the porch change reverted, 20 of 21 fail (the 21st is the no-issue guard).
  • Configured-forge test porch/__tests__/bugfix-1903-issue-forge.test.ts (no mock): a .codev/config.json issue-view override really runs and its title reaches {{issue.title}} and the Goal header. Fails without passing the workspace to fetchIssue.
  • PIR shape guard: shipped protocol.json review verify is type: pr with three reviewers and pr-review.md exists, in both trees; the two PIR trees are byte-identical.
  • Full suite: 347 files, 7272 tests passed; npm run build passes.
  • End-to-end path exercised: a real PIR project walked through porch in a scratch workspace (bare-repo origin, this branch's built porch, the edited PIR protocol). Plan → plan-approval → implement → dev-approval → review → consult task → simulated reviews (2× APPROVE, 1× REQUEST_CHANGES) → rebuttal task → porch done → pr gate → porch done re-run at the gate (no re-consult) → porch approve → porch next = complete + merge task → porch done --merged → pr_history marked merged. Every command and field review.md names was checked against what porch emitted at each step. Consult itself was simulated by writing the review files, not run against live models.

CMAP

  • gemini: COMMENT. The lane skipped itself (agy exited with code 3), no review content.
  • codex: REQUEST_CHANGES → fixed → APPROVE on re-run. (1) fetchIssue ignored a configured non-GitHub forge (also pre-existing in getProjectSummary's lookup): it now passes the workspace. (2) Nothing pinned the PIR protocol.json change: guard added.
  • claude: APPROVE. Two minor points, both applied: account for porch's own "Gate X approved" wake-up when the human approves directly; use porch done (not porch next) after the rebuttal to avoid a misleading force_advanced record.

Things to look at

  • Behavior change: BUGFIX's Goal header now shows the real issue title instead of the slug (same root cause as API Research Failures - AI Assumes APIs Exist Without Verification #8).
  • issueNumberFromPorchId moved from agent-farm/commands/reset/context.ts to lib/issue-id.ts, with a re-export so existing importers are unchanged.
  • History nit: the impl-review.md deletion was staged early and landed in the porch commit rather than the PIR commit.
  • Flaky test (pre-existing, not skipped): one full run exited 1 on an unhandled ERR_INTERNAL_ASSERTION from agent-farm/__tests__/tunnel-edge-cases.test.ts teardown (Node http2), with every test green. bugfix-1898's builder recorded the same flake. Clean on re-run.
  • Outside this issue's scope (sibling builder owns the rest of the skeleton): the consult skill's --protocol list omits pir.

🤖 Generated with Claude Code

waleedkadous and others added 9 commits November 15, 2026 21:15
…ext no longer claims the architect was notified

substituteVariables matched \w+ only, so the dotted tags in PIR, AIR and
BUGFIX phase prompts reached builders literally. Porch now derives the issue
id from the porch id (bare number, bugfix-<N>, tracker key) via
issueNumberFromPorchId (moved to lib/issue-id.ts), fetches the issue once,
and feeds both the tags and the Goal header — which for BUGFIX showed the
slug because fetchIssue("bugfix-N") never matched.

The gate-pending task said "The architect has already been notified"; porch
does not notify the architect (notify.ts). It now tells the builder to
afx send the architect and how to record the relayed approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s, pr gate, merge

- protocol.json: review verify type impl -> pr (loads pr-review.md, not the
  pre-dev-approval impl-review.md), three reviewers by default.
- Delete pir/consult-types/impl-review.md: nothing loads it any more.
- review.md: builder runs the consult commands porch emits; verdicts come
  from porch's output (the old grep read UNKNOWN on every VERDICT: line);
  REQUEST_CHANGES -> rebuttal file + porch done -> pr gate; re-running
  porch done at the gate does not re-consult; architect relays approval,
  builder runs porch approve and merges with gh pr merge --merge; verify via
  porch next status complete; PR number from pr_history.
- plan/implement/builder-prompt: builder notifies the architect at each gate
  (porch does not); approval wording aligned; signals informational.
- Baked Decisions added to protocol.md, builder-prompt, plan, implement,
  pr-review.
- Minor: merge-base not hardcoded main, View Diff, artifact name instead of
  dangling <slug>, implement.md no longer cites a null verify block.

Both trees byte-identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…onsult shape; prompt nits

- Codex: fetchIssue was called without the workspace, so a configured
  Linear/Jira/GitLab forge was ignored for {{issue.title}} and the Goal
  header (the same gap pre-existed in getProjectSummary's own lookup). Pass
  cwd: workspaceRoot in both. New unmocked test runs a configured
  issue-view override; it fails without the fix.
- Codex: guard the shipped PIR protocol.json (review verify type "pr",
  three reviewers, pr-review.md present) and byte-identity of both trees.
- Claude: review.md/builder-prompt account for porch's own "Gate X
  approved" wake-up when the human approves directly; step 6 says use
  porch done (not porch next) after the rebuttal, to avoid a misleading
  force_advanced record.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@waleedkadous

Copy link
Copy Markdown
Contributor Author

Excellent work, thank you. Walking a real PIR project through porch in a scratch workspace is exactly the right check for this bug class, and the configured-forge fix was a good catch.

Independent integration reviews: codex APPROVE (no issues), claude APPROVE (no blockers). CI is 8/8 green. I read the porch changes myself and agree.

Before merge I would like four small things folded in here rather than filed as follow-ups (owner's fix-in-place rule; you have the context now):

  1. Pin the PIR prompts. spec-1280-prompt-deletion-guard.test.ts covers spir/aspir/air and baked-decisions.test.ts enumerates spir/air. You rewrote review.md and added Baked Decisions to four PIR files with nothing guarding them. Adding pir to both enumerations (with fresh baselines captured from this PR) would do it. If that needs a retirements-register entry, draft it and tell me.
  2. Step 9 of review.md hardcodes gh pr view / gh pr merge. Step 4 already uses {{pr_create_command}}. A {{pr_merge_command}} mirroring it would be ideal; if that turns out to be more than a small change, say so and keep the forge-neutral wording in the runnable block instead.
  3. issueNumberFromPorchId docstring. It returns a tracker key for other <prefix>-<N> ids (e.g. secfix-1234 gives SECFIX-1234). Now that it feeds prompt rendering, perhaps tighten the docstring to say what it does, or generalise the prefix match, whichever you judge safer.
  4. The hand-kept shipped list in the new test could glob {codev,codev-skeleton}/protocols/{pir,air,bugfix}/prompts/*.md so a new prompt file is covered automatically.

Not asking for: propagating the relay sentence into the other protocols' prompts. The sibling builder on the prompt-sweep issue owns those files.

waleedkadous and others added 2 commits November 15, 2026 22:05
…d}}, docstring, globbed test

1. Pin the PIR prompts. spec-1280-prompt-deletion-guard: pir joins the
   builder-prompt guard; new block guards pir plan/implement/review/
   pr-review on baselines captured from this PR (anti-vacuity: the Baked
   Decisions carveout, and for review.md the pr-gate rule plus both forge
   concepts). baked-decisions: PIR's builder-prompt, plan/implement,
   pr-review and protocol.md join Phases 1-4, mirror parity and the smoke
   renders (baselineName null: PIR postdates Spec 746). PIR plan/implement
   contradiction clause now says "pause, flag ... and wait" like AIR's.
   No retirement entry: nothing was removed.
2. porch substitutes {{pr_merge_command}} (forge pr-merge concept, failing
   form when disabled), sharing one resolver with {{pr_create_command}}.
   review.md step 9 runs it with CODEV_PR_NUMBER; no gh command in the
   runnable block.
3. issueNumberFromPorchId docstring states the real mapping, including
   that another protocol's <prefix>-<N> (secfix-1234) reads as a tracker
   key, and how the prompt renderer tolerates that.
4. The shipped-prompt test lists {codev,codev-skeleton}/protocols/
   {pir,air,bugfix}/prompts/*.md instead of a hand-kept list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@waleedkadous
waleedkadous merged commit 618612d into main Nov 16, 2026
8 checks passed
waleedkadous added a commit that referenced this pull request Nov 16, 2026
waleedkadous added a commit that referenced this pull request Nov 16, 2026
Conflict in porch/prompts.ts: both sides added a substituteVariables parameter (main: issue,
for {{issue.number}}; this branch: consultation). Kept both, consultation after issue, and
main's dotted-name regex now feeds this branch's unrendered-consult-token check.
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.

PIR prompt repair: review prompt disagrees with porch on reviewers, verdicts, the pr gate and post-approval steps; {{issue.number}} never substituted

1 participant