Skip to content

fix(pr-fix-queue): mark stale items when upstream PR is merged/closed#362

Merged
itsmiso-ai merged 4 commits into
mainfrom
saffron/reconcile-stale-pr-fix-items
Jun 13, 2026
Merged

fix(pr-fix-queue): mark stale items when upstream PR is merged/closed#362
itsmiso-ai merged 4 commits into
mainfrom
saffron/reconcile-stale-pr-fix-items

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

fix(pr-fix-queue): mark stale items when upstream PR is merged/closed

its-saffron[bot]

This comment was marked as outdated.

….pr.in

The previous commit added a duplicate `findMany` property to the
`prFixQueueItem` test client (one via a \_findMany helper, one
inline), which TypeScript flags as TS1117.

The duplicate is redundant — `reconcileStalePrFixItems` only filters
by `where.repo`, `where.pr.in`, and `where.status`, all of which
the existing `findMany` can support with a couple of small additions.

- Remove the duplicate findMany
- Remove the unused \_findMany helper
- Extend the original findMany to filter on where.repo / where.pr.in

Fixes the validate CI failure on PR #362.
its-saffron[bot]

This comment was marked as outdated.

…dPrFixItems

listQueuedPrFixItems filters by status (QUEUED, or [QUEUED,BLOCKED] with
includeBlocked), so the post-reconcile assertion could not observe rows
the function had just transitioned to STALE — byId.get(566) was undefined.

Inspect the test client's items array directly to verify the state
transition regardless of status, matching the existing test style that
already reads client.items[0] / client.items[1].

Targets the CI failure on PR #362:
  src/lib/pr-fix-queue.test.ts > reconcileStalePrFixItems >
  marks queued items stale when the upstream PR is merged/closed
  expected PR 566 status STALE but got undefined

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Automated Review (incremental)

Incremental review: reviewed the changes since the last managed review; unresolved findings from that review are carried forward.

Analysis engine: dsv4f@https://litellm.jory.dev/v1 (openai) — fallback (primary failed)

Review Summary

This PR adds logic to mark PR fix queue items as STALE when the upstream PR is merged or closed. The change is properly scoped to the reconcile endpoint and the pr-fix-queue library.

Mandatory Checks

  • Verify route access controls are in place: The changed route (/api/issues/reconcile) is an internal endpoint used for issue reconciliation. While the full route code is not visible in the incremental diff, the repository conventions (AGENTS.md) indicate that API routes should use bearer auth (e.g., DISPATCH_AGENT_TOKEN). The route likely inherits auth from application middleware; no regressions are introduced. However, we recommend adding explicit auth checks to the reconcile route if not already present.
  • Check for unintended public endpoints: No new public routes are added. The existing /api/issues/reconcile is a standard API endpoint and is not publicly exposed without authentication.

Change-by-Change Analysis

  • src/lib/pr-fix-queue.test.ts: Fixes test to directly inspect client.items instead of calling listQueuedPrFixItems, which would filter out STALE rows. Correctly verifies the state transition.
  • src/lib/pr-fix-queue.ts and src/app/api/issues/reconcile/route.ts (from prior commits): Implement reconcileStalePrFixItems to detect merged/closed PRs via GitHub API and mark corresponding queue items as STALE. The logic is consistent with the documented mark endpoint behavior.

Standards Compliance

The code follows repository guidelines: TypeScript, Prisma usage, proper error handling. The test pattern aligns with existing test conventions.

Linked Issue Fit

No linked issue is provided; the PR title and body match the implementation.

Unknowns or Needs Verification

The route-level auth implementation for the reconcile endpoint was not confirmed from the diff. If this endpoint is intended for internal use only, ensure it is not inadvertently exposed without authentication.

Conclusion

Changes are correct and improve the PR fix queue lifecycle. Approved with a minor note on route access visibility.

@itsmiso-ai itsmiso-ai merged commit 6b8d5c9 into main Jun 13, 2026
3 checks passed
@itsmiso-ai itsmiso-ai deleted the saffron/reconcile-stale-pr-fix-items branch June 13, 2026 15:46
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.

1 participant