fix: drop stale pending reviews and scope assignment toggle to super admins - #161
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
fix: drop stale pending reviews and scope assignment toggle to super admins#161devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Audit of the review flow (submit → super-admin batch assign → admin vote → counters) against the "every submitted application gets
reviews_per_applicationdistinct reviews" guarantee. The coreBatchAssignalgorithm (least-pending-workload, self-review/duplicate exclusion,FOR UPDATEserialization, shortage reporting) holds up and the existing integration suite passes against a real Postgres. Three gaps found and fixed here, each reproduced first with a DB-backed test:Pending reviews on decided applications lingered forever.
setApplicationStatus(accepted/rejected/waitlisted) never touchedapplication_reviews, so admins kept getting asked to vote on applications that were already decided, and that dead work counted toward their workload in balancing.GetPendingByAdminIDnow addsAND a.status = 'submitted'so queues drop the app immediately.BatchAssigncleanup now also deletesvote IS NULLrows whose application is no longersubmitted(completed votes are kept). Counted inReviewsRemoved.A super admin who disabled their toggle and was then demoted to
adminwas excluded permanently. The toggle entry survived the demotion,BatchAssignhonored it for any role, andPUT /superadmin/settings/review-assignment-togglerefuses non-super-admins — so nothing could re-enable them. The toggle is documented as super-admin-only, soBatchAssignnow:u.role = 'super_admin'(both in the cleanupDELETEand the eligibility query);The existing
completed_ineligible_reviews_preserved/falsesubtest toggled a plainadminvia the store (unreachable through the API); it now promotes that user tosuper_adminfirst.GET /admin/reviews/next(AssignNextForAdmin) ignored the toggle. A disabled super admin could still self-assign. The handler now checksGetReviewAssignmentTogglefor super admins and returns 403. (The frontend doesn't call this endpoint; it's kept as-is otherwise.)New integration subtests:
decided_application_pending_reviews_removed,demoted_disabled_super_admin_becomes_eligible_admin; new handler test for the 403.docs/docs.goregenerated viaswag.Verified locally:
gofmt -l . && go vet ./...,go test ./cmd/api/ ./internal/...withHARP_TEST_DSNpointing at a migrated Postgres 16 container (integration suite run 4× for the concurrency subtests).Not changed (worth a product call): plain
adminusers cannot be paused from assignment at all — only super admins have a toggle.Link to Devin session: https://app.devin.ai/sessions/2b5cee5221ca42eea043044ce117ba47
Open in Devin Desktop: https://app.devin.ai/desktop/session/2b5cee5221ca42eea043044ce117ba47?variant=devin
Requested by: @balebbae