Skip to content

Fix #1759: porch pending hides stale gate records and counts each project once - #1760

Merged
waleedkadous merged 2 commits into
mainfrom
fix/porch-pending-stale-gates
Oct 1, 2026
Merged

waleedkadous merged 2 commits into
mainfrom
fix/porch-pending-stale-gates

Conversation

@waleedkadous

Copy link
Copy Markdown
Contributor

Fixes #1759.

What

porch pending listed every gate record still marked pending, regardless of whether the project had moved past that gate, finished, or merged its PR, and counted the same committed status.yaml once per builder worktree copy. A long-lived workspace showed 810 gates pending approval, none of them live.

Change (packages/codev/src/commands/porch/index.ts)

  • New isStalePendingGate(state, gate, protocol): stale when the phase is terminal (verified / complete), when pr_history records a merged PR, or when the protocol's phase index for the gate is behind the project's current phase (a phase not in the protocol at all counts as finished). Protocol load failures fall back to the terminal/merged rules only.
  • pending() dedupes by project id (root codev/projects copy wins; a worktree-only project is still listed), hides stale records, and prints how many it hid.
  • porch pending --all shows the raw view; help text updated.

Listing only: no record is written, and approval remains a human, named act.

Tests

__tests__/pending-stale-gates.test.ts: each stale rule, the no-protocol fallback, the hidden count, --all, and the worktree dedupe. Porch suite 502/502, tsc --noEmit clean.

…ject once

A pending gate record stays listed forever even when the project moved past
the gate's phase, finished (verified/complete), or recorded a merged PR;
and the same committed status.yaml is counted once per builder worktree.
One workspace showed 810 pending gates with none live.

pending() now skips those records (listing only — nothing is written and
approval stays a human, named act), dedupes by project id with the root
copy winning, reports how many stale records it hid, and takes --all for
the raw view. Tests cover each rule and the worktree dedupe.
@waleedkadous

Copy link
Copy Markdown
Contributor Author

Thank you for this. The worktree dedupe is the real win here: in this workspace every one of the 40 pending records with a requested_at is a pr gate sitting at its own phase, so the multiplier across worktree copies is what produced the 810, and the dedupe alone collapses it. Clean, listing-only, well tested.

3-way integration review: gemini APPROVE, codex REQUEST_CHANGES, claude REQUEST_CHANGES. I verified the two blocking findings against the code myself.

I would like to see three changes before merge:

  1. Dedupe precedence is inverted. findStatusPath() and listAllProjects() in porch/state.ts search .builders/ worktrees first and fall back to the root copy, with a Spec 653 comment explaining that root copies go stale in multi-PR flows. This PR makes the root copy win, so a stale root copy can suppress a live gate in the active worktree. Reuse listAllProjects() or match its worktree-first order, and add a test with divergent copies rather than identical ones.

  2. pr_history.some(merged) hides live gates. overview.ts (Needs Attention: merged PR with still-pending pr gate vanishes (derivePrReady ignores merged) #966) deliberately reads the LAST pr_history entry, because a merged checkpoint PR followed by a later open PR is a normal shape. Also, SPIR and ASPIR run the verify phase after the merge, so a merged PR must not stale verify-approval. Use last-entry semantics and scope the merged rule to the pr gate.

  3. Unknown phase should fail open. A phase missing from the resolved protocol can be a protocol upgrade, a custom protocol, or a legacy state, not just completion. When unsure, show the human ask rather than hide it.

Smaller, your call: the porch pending JSDoc now sits above isStalePendingGate and pending() is undocumented; and --all needs a mention in the four porch SKILL.md copies, commands/overview.md and the cheatsheet, mirrored in both trees.

Worth knowing for expectations: with merged: true recorded in only 22 of 305 root projects and porch only advancing a phase on approval, the three stale rules hide close to nothing in this workspace today. That is fine, they are correct guards once fixed, but the dedupe is what users will feel.

…, last-entry merged rule scoped to the pr gate, unknown phase fails open; --all in docs

- pending() now iterates listAllProjects() (Spec 653 order: builder worktrees
  first, root copy as fallback), so a stale root copy cannot hide a live gate
  in the active worktree. Test uses divergent copies.
- The merged rule reads the LAST pr_history entry (#966) and applies only to
  the pr gate: SPIR/ASPIR verify after the merge, so a merged PR never hides
  verify-approval. Tests for checkpoint-then-open and for verify-approval.
- A current phase the protocol does not list fails open (upgrade / custom /
  legacy state), as does an undeclared gate.
- JSDoc moved onto pending(); --all mentioned in the four porch SKILL.md
  copies, commands/overview.md and the cheatsheet.
@waleedkadous

Copy link
Copy Markdown
Contributor Author

Review addressed in cdcb0e5:

  1. Dedupe precedence — pending() now iterates listAllProjects() (worktree-first, root fallback, Spec 653 order) instead of its own root-first scan. Test rewritten with divergent copies: root at plan with plan-approval pending, worktree at implement with dev-approval pending → the listing shows dev-approval only.
  2. Merged rule — last pr_history entry (Needs Attention: merged PR with still-pending pr gate vanishes (derivePrReady ignores merged) #966), and only for the pr gate. Tests: merged checkpoint PR followed by an open PR keeps pr live; a merged PR never stales verify-approval.
  3. Unknown phase fails open — a current phase the protocol does not list, or an undeclared gate, keeps the ask visible.

Smaller items: JSDoc now sits on pending(); --all added to the four porch SKILL.md copies, commands/overview.md and the cheatsheet. Porch suite 503/503, tsc --noEmit clean.

@waleedkadous
waleedkadous merged commit 49d8b07 into main Oct 1, 2026
7 checks passed
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 pending lists dead gates: pending records on completed/merged projects, and the same project once per worktree copy

1 participant