Skip to content

Add intelligent PR triage to replace rigid label-based routing #1

@jalemieux

Description

@jalemieux

Problem

The current route() function uses a rigid checklist of label + state queries to find actionable work. When a PR doesn't exactly match one of the expected states, the script silently reports "No actionable work found" and sleeps — even when the fix is trivial (e.g., a closed PR that should be open, a missing comment, a stale label).

Example: PR #17 on conversation_with_ai

A bot-authored draft PR had bot:plan-proposed label and a complete implementation plan in the body, but the script couldn't find it because:

  1. The PR had been closed (so gh pr list skipped it)
  2. Even after reopening, it had 0 comments — and check_plan_feedback requires comment_count > 0

This required manual debugging to figure out. The script should have been able to diagnose and resolve this itself.

Other failure modes this would catch

  • PR has the wrong label for its actual state
  • PR is closed but shouldn't be
  • Issue is assigned but the assignee's PR was abandoned
  • bot:in-progress label is stale (process crashed without cleanup)
  • PR has plan but no bot:plan-proposed label

Proposed Solution

Add a fallback step in the routing loop: when the rigid checks find nothing, pass all open bot PRs + unassigned issues to Claude Code for triage. Claude can inspect the actual state of each item and decide what action to take (reopen a PR, add a comment, fix a label, skip, etc.) rather than silently giving up.

This brings back Claude Code's judgment into the routing decision, so the system self-heals instead of getting stuck on small state mismatches.

Success Criteria

  • Script never silently skips work that a human would recognize as actionable
  • Triage step only fires when rigid routing finds nothing (no added cost in the happy path)
  • Actions taken by triage are logged clearly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions