Skip to content

fix(pr-fix-queue): PrFixType enum not populated — every item defaults to OTHER #365

@itsmiso-ai

Description

@itsmiso-ai

Bug

The PrFixType enum and type field on PrFixQueueItem are not being populated by the ingest path. Every item in the queue has type=null or type=OTHER, even when the underlying event is clearly a merge conflict or a CHANGES_REQUESTED review.

This is visible in the queue response:

type=OTHER: 9
type=REVIEW_FEEDBACK: 1

of 10 items, even though 6 of those items are real merge conflicts (the reason field said "PR review: CHANGES_REQUESTED" because stale review feedback overwrote the merge-state data, but the events themselves were merge_state).

Why this matters

PR #356 added the PrFixType enum with the explicit goal of priority ordering:

"feat: surface merge conflicts as PR review-fix items with priority ordering"

The whole point of PrFixType is to let the worker and the agent queue sort by type — MERGE_CONFLICT first, then REVIEW_FEEDBACK, then OTHER. With every item defaulting to OTHER, the priority ordering is meaningless, and the agent queue just returns items in arbitrary order.

Likely root cause

Two things stacked:

  1. The Prisma migration that adds the type field (20260611000000_add_pr_fix_type per PR feat: surface merge conflicts as PR review-fix items with priority ordering #356's description) is not in the local clone's prisma/migrations/ directory. The local working tree on the fix/unify-health-version branch pre-dates that migration. So prisma migrate dev and prisma generate may not have the new field available, and any data: { type: "MERGE_CONFLICT" } writes fail silently or get coerced to null.

  2. The ingest path (ingestMergeStateEvent, ingestReviewEvent, ingestCheckRunEvent) never passes a type value to enqueuePrFixItem. The library accepts it (the type is in the Prisma schema), but the call sites don't supply it.

Suggested fix

In each ingest function in src/lib/pr-followup-ingestion.ts, pass the right type to enqueuePrFixItem:

  • ingestMergeStateEventtype: "MERGE_CONFLICT"
  • ingestReviewEvent (CHANGES_REQUESTED) → type: "REVIEW_FEEDBACK"
  • ingestReviewEvent (COMMENTED) → type: "REVIEW_FEEDBACK"
  • ingestCheckRunEvent (failure) → type: "CI_FAILURE"
  • Anything else → type: "OTHER"

Also verify the Prisma migration 20260611000000_add_pr_fix_type exists in prisma/migrations/ and applies cleanly. If it doesn't exist, write it: ALTER TABLE "PrFixQueueItem" ADD COLUMN "type" "PrFixType" NOT NULL DEFAULT 'OTHER'.

Test

it("populates PrFixType on enqueue from merge_state events", async () => {
  // setup: ingest a merge_state event for a bot-authored DIRTY PR
  // assert: the resulting prFixQueueItem has type === "MERGE_CONFLICT"
});

The existing tests in src/lib/pr-fix-queue.test.ts and src/lib/pr-followup-ingestion.test.ts don't cover this path.

Observed impact

This session, I had to reclassify 9 pr-fix items by hand because their type was OTHER instead of MERGE_CONFLICT / REVIEW_FEEDBACK. The agent queue's priority ordering isn't effective until this is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions