fix(mini-app): rank confirmed MATCH above REVIEW in the unreviewed review queue - #14
Merged
Merged
Conversation
The mixed Mini App unreviewed queue ordered by score alone, so a REVIEW vacancy scoring 99 outranked a confirmed MATCH scoring 44. In production the three unreviewed MATCH vacancies sat at positions 14, 18 and 42. findMiniAppReviewJobs() reused the shared ORDER, whose leading workflow-status bucket is constant under `w.job_id is null` — leaving pure score DESC. Give that one query its own MATCH_FIRST_ORDER: disposition first, then the score/recency/id tail every read model already shares, extracted as BY_SCORE. The rendered SQL of ORDER is unchanged, so Saved, Applied, the Telegram queues, notifications and job detail keep their exact ordering. No score is recomputed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Production evidence
A read-only audit of the live mixed Mini App review queue found confirmed MATCH vacancies buried under higher-scored REVIEW vacancies:
All three passed LOCATION, CAREER_LEVEL, ROLE_RELEVANCE and FINAL_MATCH screening.
Root cause
findMiniAppReviewJobs()delegated tofindMiniAppJobs(...), which hard-coded the sharedORDER. That clause sorts by workflow-status bucket → score → recency → id and carries no disposition term. Under the review predicatew.job_id is nullevery row is UNREVIEWED, so the bucket term is constant and the ordering collapsed to purescore DESC.Ordering invariant (this queue only)
score DESCscore DESCcoalesce(published_at, first_seen_at) DESCid DESCScope
findMiniAppReviewJobs()gets its ownMATCH_FIRST_ORDER. The score/recency/id tail shared by every read model is extracted intoBY_SCORE;ORDERnow concatenates it and its rendered SQL is byte-identical to before.Resolving both versions' compile-time string constants and diffing the SQL each method emits: 1 of 8 statements changed (
findMiniAppReviewJobs), and only itsORDER BY.findQueue×4,findNotifiable,findMiniAppJobsByIdsandfindMiniAppSavedJobsare identical strings.findDetailandstats()contain noORDER BYand were not touched.Bounded-window note
MAX_REVIEW_JOBS = 50. MATCH-first changes membership of the window, not just order: MATCH rows now take slots ahead of higher-scored REVIEW rows.totalandtruncatedcome fromstats(), whose predicate matches the list predicate, so page metadata stays accurate. Covered by a new test.If unreviewed MATCH ever exceeds 50 the window shows only MATCH until they are triaged. That is intentional under the current product rule.
RED evidence
Against the pre-fix implementation:
reviewQueuePrioritizesMatchBeforeHigherScoredReview— FAIL: order fully inverted by pure score DESCboundedReviewWindowAdmitsAMatchAheadOfHigherScoredReviews— FAIL: MATCH did not enter first in the bounded windowsavedQueueIgnoresDispositionAndStaysScoreOrdered— PASS: guards unchanged Saved behaviorGREEN verification
git diff --checkclean./mvnw -B -Dtest=MiniAppDurabilityIT test→ 16/16./mvnw -B -Dtest=JobReviewWorkflowIT test→ 23/23Tests prove that a lower-scored MATCH precedes a higher-scored REVIEW, score ordering remains correct inside both disposition buckets, bounded-window metadata remains correct, and the Saved queue stays score-ordered irrespective of disposition.
Explicitly out of scope — unchanged
Scoring weights · scoring bands · numeric score values · screening logic and stages · Telegram MATCH/REVIEW queues · Saved and Applied ordering · notification ordering · job detail · pagination totals · Mini App mutations · persistence · migrations · configuration · frontend · scheduler · infrastructure.
No score was recomputed or written. This is a read-model
ORDER BYchange only.Reviewer note
case j.screening_disposition when 'MATCH' then 0 else 1 endrelies on the existingACTIVEpredicate restricting rows toMATCH/REVIEW. If a third screened-in disposition is introduced later, the ordering semantics should be revisited at that time.