You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⚠️ 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.constREGATE_REPAIR_MAX_ATTEMPTS_PER_PR=5;/** * #9499: keyed on PR NUMBER, not head SHA. * ... */functionregateRepairTargetKey(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:
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.
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):
The comment above REGATE_REPAIR_ATTEMPT_EVENT_TYPE/REGATE_REPAIR_EXHAUSTED_EVENT_TYPE.
isRegateRepairExhausted's doc comment.
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
src/queue/processors.ts — the constant-block comment (around lines 1120-1129), regateRepairTargetKey
(around line 1130, already correct — the model to match), isRegateRepairExhausted (around lines
1143-1168, the doc comment and the detail string to fix).
Context
src/queue/processors.ts's regate-repair budget was deliberately rekeyed from per-head-SHA to per-PR-numberby
#9499(commitbef69d3dd, see#9497/#9498/#9499), specifically so a rebase (which mints a newhead SHA) can no longer reset the 5-attempt repair budget to zero:
regateRepairTargetKeyitself was correctly updated and correctly documents the new per-PR semantics. Butseveral other places describing the SAME budget were never updated to match, and now contradict it:
"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
regateRepairTargetKeyno longer implements (the target key today isrepo#prNumberonly, with no SHA component at all).isRegateRepairExhausted's own doc comment still says:"True when \pr`'s current head SHA hasalready exhausted ... (at most once per SHA) ... they share one attempt budget per SHA"` — same stale
per-SHA framing.
detailstring actually written at runtime stillclaims the old per-SHA semantics:
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 thereal semantics were understood at the time, but the prose was never updated to match.
Requirements
per-PR-number budget semantics (not per-head-SHA):
REGATE_REPAIR_ATTEMPT_EVENT_TYPE/REGATE_REPAIR_EXHAUSTED_EVENT_TYPE.isRegateRepairExhausted's doc comment.detailstring in therecordAuditEventcall insideisRegateRepairExhausted.regateRepairTargetKey,isRegateRepairExhausted's actual logic,REGATE_REPAIR_MAX_ATTEMPTS_PER_PR's value, or any decisionbehavior.
detailstring must clearly state the budget is scoped per PR (not per head SHA), matchingregateRepairTargetKey's own already-correct doc comment framing.Deliverables
corrected to describe the actual per-PR-number key.
isRegateRepairExhausted's doc comment no longer says "per SHA" / "at most once per SHA" — itdescribes the real per-PR-number budget.
detailstring written byrecordAuditEventinsideisRegateRepairExhaustedno longer says "forthe 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
detailtext 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.tsis insidesrc/**. Since this changes only string literals/comments,the main coverage requirement is that the existing test(s) asserting on the
detailstring's exact text(if any exist — check
test/unit/queue-2.test.tsand sibling queue test files for theREGATE_REPAIR_EXHAUSTED_EVENT_TYPEaudit event) are updated to assert the NEW corrected text, so the fixis locked in and a future regression back to the stale wording would fail CI.
Expected Outcome
An operator reading the
agent.sweep.regate.repair_exhaustedaudit event'sdetailtext sees an accuratedescription of why the repair budget was exhausted (per-PR, across however many head SHAs), matching the
real #9499 semantics
regateRepairTargetKeyalready implements — instead of a misleading claim that theattempts were all "for the same head SHA."
Links & Resources
src/queue/processors.ts— the constant-block comment (around lines 1120-1129),regateRepairTargetKey(around line 1130, already correct — the model to match),
isRegateRepairExhausted(around lines1143-1168, the doc comment and the
detailstring to fix).test/unit/queue-2.test.ts(around line 2230) — already has a comment describing the correct queue: no 'current focus' concept exists, and oldest-first ordering is defeated by 5 of 8 regate producers omitting prCreatedAt #9499semantics; the test asserting on the audit detail text (if any) needs updating alongside the fix.