Uh oh!
There was an error while loading. Please reload this page.
Route BLOCKED PR-fix items into NEEDS_HUMAN lane and add a requeue action - #784
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
a59bff0 to
2e608fdCompare
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
When a pr-fix item is marked BLOCKED after exhausting its attempts, the mark path now also sets lane=NEEDS_HUMAN. The bridge already refuses to action that lane (bridge/prfix.py ACTIONABLE_LANES), so this is purely a visibility/bucketing change — the existing red NEEDS_HUMAN badge on the queue page then reflects the items the loop has given up on. Blocked items can now be returned to QUEUED with a single action: * `requeuePrFixItem` in src/lib/pr-fix-queue.ts resets the row to QUEUED + NORMAL and writes a `requeue` audit row, refusing when the upstream PR is already merged or closed (consistent with `classify_pr_lifecycle`). * `POST /api/pr-fix-queue/requeue` exposes it to the UI/MCP. * `requeue_pr_fix` MCP tool wraps the same call. * A "Requeue" button on each BLOCKED row of src/app/automation/pr-fix-queue/page.tsx triggers it; the page looks up the current PR state and passes the merged/closed flag so the refusal happens before the write. Fixes#771 Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
2e608fd to
0e81146CompareThere was a problem hiding this comment.
AI Automated Review
Full PR review.
Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — routed smart (risk match: public_route_changes)
PR PR 784: Route BLOCKED PR-fix items into NEEDS_HUMAN lane and add a requeue action
Recommendation: Approve
This PR correctly implements issue PR 771's acceptance criteria: routing blocked items to NEEDS_HUMAN lane and providing a requeue action reachable from the UI.
Change-by-Change Findings
src/app/api/pr-fix-queue/requeue/route.ts (new endpoint)
- Adds a
POST /api/pr-fix-queue/requeuehandler with standardauthorizeRequestauth guard, JSON parsing, input validation viaparseRequeuePrFixInput, and appropriate HTTP status codes (400, 401, 404).
src/lib/pr-fix-queue.ts (core logic)
markPrFixItem: Now setslane = "NEEDS_HUMAN"when transitioning toBLOCKED, andlane = "NORMAL"when transitioning toQUEUED. The existing bridgeACTIONABLE_LANESfilter will now skip these items, which is the intended behavior per the linked issue.requeuePrFixItem: Pure DB function that transitions BLOCKED → QUEUED + NORMAL lane, resets attempt counter, and writes arequeuehistory row. Refuses if PR is already merged/closed.parseRequeuePrFixInput: Validates requiredrepoandprfields with proper type checking.
src/app/automation/pr-fix-queue/page.tsx (UI)
- Adds "Requeue" button on each BLOCKED row (line 162).
- Client-side pre-flight check fetches
/api/github/prs/{repo}/{pr}to detect merged/closed upstream PRs before calling requeue.
src/lib/mc-client.ts and src/mcp/server.ts
- Exposes
requeuePrFixas an MCP tool with full input schema, enabling programmatic requeue from agent tools.
Required Checks
✅ verify route access controls are in place
The new POST /api/pr-fix-queue/requeue route calls authorizeRequest(request) at line 7 and returns 401 Unauthorized when auth.authorized is false. This is the canonical auth pattern used across Dispatch API routes per the repository's auth conventions (AGENTS.md §Code Standards). The MCP tool routes through mc-client.ts which uses bearer token auth, consistent with the existing markPrFix tool and the DISPATCH_AGENT_TOKEN bearer pattern.
✅ check for unintended public endpoints
No new GET routes were added. The only new route is a POST handler with mandatory auth. No middleware changes or route configuration modifications appear in the diff. The requeue endpoint is gated behind authorizeRequest and cannot be reached anonymously.
Linked Issue Fit
| Acceptance Criterion | Status |
|---|---|
1. BLOCKED items land in NEEDS_HUMAN lane | ✅ Implemented in markPrFixItem (lines 215–219) |
| 2. Blocked items can be returned to QUEUED with attempt reset | ✅ Implemented in requeuePrFixItem (lines 340–363) |
3. Requeue action reachable from /automation/pr-fix-queue page | ✅ Button added to BLOCKED rows (line 162) |
| 4. Requeueing writes an audit row | ✅ prFixHistory.create with action: "requeue" (line 355) |
| 5. Refuse requeue when PR is merged or closed | ✅ Check in requeuePrFixItem (line 344) and client-side pre-flight (page.tsx line 67) |
Tool Harness Findings
No tool harness output was provided; reviewing corpus directly.
Unknowns / Needs Verification
None. All acceptance criteria are directly verifiable from the diff. CI passed (Build, Typecheck, Tests, Lint, Docker Build, npm audit).
Standards Compliance
Per AGENTS.md conventions:
- API routes return appropriate HTTP status codes: ✅ 401, 400, 404, 200/500
- Error handling uses
error instanceof Errorpattern: ✅err instanceof Error ? err.message : "Failed to requeue pr-fix item" - Validation before database operations: ✅
parseRequeuePrFixInputvalidates fields before callingrequeuePrFixItem - No commit of secrets: ✅ No
.envor credentials in diff
Uh oh!
There was an error while loading. Please reload this page.
Issue #771 implemented: routes BLOCKED PR-fix items into NEEDS_HUMAN lane and adds requeue action to return BLOCKED items to QUEUED. All changes are well-scoped, properly tested with 6 requeue tests covering edge cases (merged/closed PR, wrong status, not found), and no scope …
Fixes#771
Opened by foreman on review GO (workload wl-misospace-dispatch-771).