Skip to content

queue(processors): fix stale 'same head SHA' wording after #9499's per-PR regate-repair rekey #10320

Description

@JSONbored

⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.

Context

src/queue/processors.ts's regate-repair budget was deliberately rekeyed from per-head-SHA to per-PR-number
by #9499 (commit bef69d3dd, see #9497/#9498/#9499), specifically so a rebase (which mints a new
head SHA) can no longer reset the 5-attempt repair budget to zero:

// #9499: renamed from ..._PER_SHA -- the budget is now per PR, since SHA-keying let a rebase reset it.
const REGATE_REPAIR_MAX_ATTEMPTS_PER_PR = 5;

/**
 * #9499: keyed on PR NUMBER, not head SHA.
 * ...
 */
function regateRepairTargetKey(repoFullName: string, prNumber: number, _headSha: string): string {
  return `${repoFullName}#${prNumber}`;
}

regateRepairTargetKey itself was correctly updated and correctly documents the new per-PR semantics. But
several other places describing the SAME budget were never updated to match, and now contradict it:

  1. The comment directly above the constant declarations still says: "A new commit changes the head SHA, which resets the count naturally (the target key is scoped to repo+PR+SHA)." — describing the OLD,
    pre-queue: no 'current focus' concept exists, and oldest-first ordering is defeated by 5 of 8 regate producers omitting prCreatedAt #9499 behavior that regateRepairTargetKey no longer implements (the target key today is
    repo#prNumber only, with no SHA component at all).
  2. isRegateRepairExhausted's own doc comment still says: "True when \pr`'s current head SHA has
    already exhausted ... (at most once per SHA) ... they share one attempt budget per SHA"` — same stale
    per-SHA framing.
  3. Most importantly, the operator-facing audit event detail string actually written at runtime still
    claims the old per-SHA semantics:
    detail: `re-gate repair exhausted after ${attempts} attempt(s) for the same head SHA; falling back to ordinary staleness cadence`,
    This is the text an operator actually reads in the audit log when a PR's repair budget is exhausted. It
    is factually wrong post-queue: no 'current focus' concept exists, and oldest-first ordering is defeated by 5 of 8 regate producers omitting prCreatedAt #9499: a PR that gets rebased mid-budget can accumulate its 5 counted attempts
    across several DIFFERENT head SHAs (that's the entire point of the fix), but the log line tells the
    operator the attempts were "for the same head SHA" — actively misleading operator-facing text about why
    the repair budget was exhausted.

test/unit/queue-2.test.ts (around line 2230) even has a test comment noting "#9499: the repair budget is per PR, not per head SHA" immediately next to the code that still emits the stale string — confirming the
real semantics were understood at the time, but the prose was never updated to match.

Requirements

  • Every one of the three stale-wording locations above must be corrected to accurately describe the current
    per-PR-number budget semantics (not per-head-SHA):
    1. The comment above REGATE_REPAIR_ATTEMPT_EVENT_TYPE/REGATE_REPAIR_EXHAUSTED_EVENT_TYPE.
    2. isRegateRepairExhausted's doc comment.
    3. The detail string in the recordAuditEvent call inside isRegateRepairExhausted.
  • This is a documentation/observability-only fix — no change to regateRepairTargetKey,
    isRegateRepairExhausted's actual logic, REGATE_REPAIR_MAX_ATTEMPTS_PER_PR's value, or any decision
    behavior.
  • The corrected detail string must clearly state the budget is scoped per PR (not per head SHA), matching
    regateRepairTargetKey's own already-correct doc comment framing.

Deliverables

  • The stale "the target key is scoped to repo+PR+SHA" comment above the two event-type constants is
    corrected to describe the actual per-PR-number key.
  • isRegateRepairExhausted's doc comment no longer says "per SHA" / "at most once per SHA" — it
    describes the real per-PR-number budget.
  • The detail string written by recordAuditEvent inside isRegateRepairExhausted no longer says "for
    the same head SHA" — it accurately reflects that the budget is exhausted per PR (across however many
    head SHAs that PR has had within the lookback window), verified by a new or updated test asserting the
    exact corrected detail text is what gets recorded.

All three Deliverables are required in the same PR — they are the same underlying stale claim, repeated in
three places.

Test Coverage Requirements

This repo's Codecov patch gate requires 99%+ patch coverage on every changed line and branch under
src/**. src/queue/processors.ts is inside src/**. Since this changes only string literals/comments,
the main coverage requirement is that the existing test(s) asserting on the detail string's exact text
(if any exist — check test/unit/queue-2.test.ts and sibling queue test files for the
REGATE_REPAIR_EXHAUSTED_EVENT_TYPE audit event) are updated to assert the NEW corrected text, so the fix
is locked in and a future regression back to the stale wording would fail CI.

Expected Outcome

An operator reading the agent.sweep.regate.repair_exhausted audit event's detail text sees an accurate
description of why the repair budget was exhausted (per-PR, across however many head SHAs), matching the
real #9499 semantics regateRepairTargetKey already implements — instead of a misleading claim that the
attempts were all "for the same head SHA."

Links & Resources

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions