fix(maintainability): put the three paid advisories' universal spend stops behind one predicate (#9557) - #9558
Conversation
…stops behind one predicate (#9557)
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-28 09:15:18 UTC
Review summary Nits — 6 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9558 +/- ##
==========================================
- Coverage 89.60% 88.71% -0.90%
==========================================
Files 861 862 +1
Lines 110640 110646 +6
Branches 26341 26345 +4
==========================================
- Hits 99144 98159 -985
- Misses 10231 11513 +1282
+ Partials 1265 974 -291
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Summary
Deliverable 2 of #9541: the three paid per-PR advisories each hand-wrote their own spend gate, and they drifted.
Closes #9557
The drift, and why no reviewer could have caught it
ai_slop(slop-detection.ts),ai_review(ai-review-orchestration.ts) and the linked-issue satisfaction advisory (processors.ts) each make a paid LLM call per PR head, and each grew its own guard line. #9491 found the consequence: the linked-issue advisory had no per-PR commit cap at all, so a long-lived PR kept paying for a fresh assessment on every push long after its two siblings had stopped.That is not a mistake anyone catches by reading a function. The guards live in three files, and the incomplete one reads as complete on its own — you have to already know the other two exist to notice what is missing.
advisorySpendStopReasonmakes it structurally impossible for a fourth advisory to be written without those stops.What is deliberately NOT unified
!confirmedContributorappears in two of the three guards and looks shared. It isn't —ai_reviewdeliberately reviews some unconfirmed authors viaresolveAiReviewableAuthor'saiReviewAllAuthors/ gate-pack policy.Folding it in would either silently narrow
ai_review's audience or silently widen the other two's. A "shared" rule that is wrong for one caller is exactly how the next #9491 gets written, so the author gate stays per-feature and the module says so — with a test asserting the shared type has not grown aconfirmedContributorfield.ai_reviewkeeps its own richer gate (resolvePublicAiReviewGateSkipReason), which already returns a named reason and is the pattern this one follows.The caller's response to a stop also stays per-feature:
ai_sloprecords an audit event on the cap, the linked-issue advisory returns silently. Unifying the response would have been a behaviour change dressed up as a refactor.Behaviour-preserving, and pinned as such
The reported reason decides which audit event a PR emits, so a re-ordering would silently relabel real production history. Precedence (
paused→no_head_sha→commit_threshold_reached) matches the hand-written guards exactly and is asserted explicitly rather than assumed.A named reason rather than a boolean, mirroring
resolvePublicAiReviewGateSkipReason: callers usually want to audit which stop fired, and a barefalseforces every call site to re-derive it.Validation
npx tsc --noEmit,dead-source-files:check,git diff --check— all cleanai-slop,queue-4, advisory-routing call sites, and the linked-issue runnerRegression: the commit-cap stop — the one the linked-issue advisory shipped without — fires.
Invariants: each stop fires independently;
nullwhen all preconditions pass; empty-string/null/undefined head SHA all stop; precedence matches the replaced guards; the function is pure and never mutates its input.Adoption is pinned at the source, so "a fourth advisory cannot be written without these stops" stays true rather than aspirational — the same producer-drift-guard convention
db-parsers.test.tsalready uses. Tests assert both adopters route through the shared gate, that neither re-implements the commit-cap stop inline, and that the shared module has not grown the author field.One arm is annotated rather than tested: the
?? nullon the audit metadata is unreachable by construction (advisorySpendStopReasonchecksheadShabefore the cap, so reaching that branch proves it is a non-empty string) and exists only because TypeScript cannot narrow through the call.Scope
#9541's other two deliverables — the ~9 command/panel handlers behind one dispatch, and the plan-and-execute pass into its own typed-context module — are not here. They are large behaviour-preserving refactors of a 16.3k-line file, and bundling them with this would make all three unreviewable. #9541 stays open for them.
This one was taken first deliberately: it is the smallest of the three and the only one that directly closes a confirmed, already-shipped defect class rather than reducing the risk of a future one.