Skip to content

porch: emit explicit pr_ready_for_human state field when CMAP completes #872

Closed

Description

@waleedkadous

Context

PR #844 (shipped in v3.1.3) tried to gate the dashboard's Needs Attention list on "CMAP done, PR ready for human review". The check it used — b.blocked === 'PR review' — was a derivation that worked for protocols with an explicit pr gate (SPIR/ASPIR/PIR/AIR) but silently failed for BUGFIX (no pr gate, transitions straight to phase: verified after CMAP).

The underlying issue is that "CMAP complete for the PR-creating phase" has one true definition in porch's state machine but two different surface manifestations today, depending on whether the protocol's PR-creating phase carries a gate. Anyone consuming "is this PR ready for a human" has to know the protocol-specific derivation, and the only way to find out you got it wrong is to ship a regression (which we did).

This issue proposes making the signal canonical: porch writes an explicit pr_ready_for_human: true to status.yaml when it transitions out of the CMAP-emitting state for the PR-creating phase, regardless of whether the protocol uses a gate. Consumers (Needs Attention filter, VS Code extension, future dashboards) read one boolean.

A parallel bug ([linked issue for the B path]) covers the immediate filter-side patch in overview.ts as a fast fix; this issue tracks the canonical state-machine change.

Design questions for the spec/plan

These are the questions that motivate using PIR rather than BUGFIX/AIR — they want pre-PR review:

  1. Field name and shape. pr_ready_for_human: boolean is the narrowest framing. Broader alternatives: cmap_complete: boolean (covers any CMAP-emitting phase, not just PR phases) or a typed enum pr_state: 'no-pr' | 'cmap-running' | 'cmap-complete' | 'merged'. Each has different consumer implications.

  2. Per-phase vs single boolean. Some protocols have multiple CMAP-emitting phases (SPIR's specify, plan, review). Do we set the flag only for the PR-creating phase, or maintain a per-phase map? The Needs Attention use case wants only "PR-creating phase done", so per-phase may be overkill — but other consumers might want richer state.

  3. Re-iter handling. When CMAP returns REQUEST_CHANGES and porch enters the rebuttal cycle, does pr_ready_for_human go back to false until the next iteration's CMAP completes? (Yes — it should reflect current state, not "ever was complete.")

  4. Identification of the CMAP-emitting phase. Today the consultation block lives in the phase definition (e.g. BUGFIX's pr phase has consultation.on: 'review'). Does porch infer the PR-creating phase from the consultation block presence, or do we add an explicit is_pr_phase: true marker to protocol.json? The former is cheaper and works retroactively; the latter is more explicit and lets a protocol have CMAP without it being PR-creating.

  5. Backward compat. Existing in-flight projects (status.yaml without the new field) need a fallback. The simplest: if the field is absent, fall back to the current derived logic (blocked === 'PR review' || (phase === 'verified' && has_open_pr)). This lets us ship the canonical signal without forcing a migration on every running builder.

  6. Surface change in OverviewBuilder. Add prReady: boolean derived from the new status.yaml field (with the v3.1.3 fallback). The Needs Attention filter consumes only this field.

Acceptance criteria

  • status.yaml gains a pr_ready_for_human: boolean field (or whichever shape the plan settles on).
  • Porch sets it to true when transitioning out of the CMAP-emitting state for the PR-creating phase, for ALL protocols (SPIR, ASPIR, PIR, AIR, BUGFIX).
  • Porch sets it back to false (or removes the field) when entering the rebuttal cycle on REQUEST_CHANGES.
  • OverviewBuilder.prReady is computed from this field with a fallback for legacy state files lacking the field.
  • NeedsAttentionList.tsx gates on prReady alone, no protocol-specific derivation.
  • Tests: each of the five protocols gets a porch-state test verifying the field's lifecycle.
  • Migration note: in-flight projects on v3.1.x continue working (fallback to current derived logic until they reach the CMAP-done state under the new code).

References

Activity

  1. added
    bug
    on May 26, 2026
  2. waleedkadous commented on May 26, 2026

    @waleedkadous
    ContributorAuthor

    On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).

  3. waleedkadous commented on May 26, 2026

    @waleedkadous
    ContributorAuthor

    On it! Working on a fix now.

  4. added 6 commits that reference this issue on May 26, 2026
  5. added a commit that references this issue on May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions