Skip to content

fix(review): hold when unlinked verifier limits trip - #4645

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-vulnerability-in-unlinked-issue-guardrail
Jul 10, 2026
Merged

fix(review): hold when unlinked verifier limits trip#4645
JSONbored merged 1 commit into
mainfrom
codex/fix-vulnerability-in-unlinked-issue-guardrail

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • The per-actor rate ceiling and shared-budget gate previously returned undefined (a clean pass) when they tripped, allowing an attacker to exhaust verifier capacity and bypass the unlinked-issue guardrail.
  • The feature also recorded estimated AI spend before confirming a verifier invocation, which could burn the shared budget ledger even when no AI call occurred.

Description

  • Change cost-exhaustion behavior to return a manual-review hold disposition via unlinkedIssueVerifyCapacityHold(...) instead of undefined when the per-actor ceiling or shared budget gates trip.
  • Add hasUnlinkedIssueVerifyAiBinding(env) and defer recordUnlinkedIssueVerifyUsage(...) until after verifying an actual AI invocation was possible, so missing/no-op bindings do not record spurious ok usage.
  • Record verifier-attempt audit events as before, but keep shared-budget accounting aligned with real invocations and make the gates fail-safe (reads still fail open).
  • Update unit tests to cover rate-limit holds, budget-exhaustion holds, and the no-op-AI-binding accounting case; adjust expectations where gates now produce a hold disposition and reason text.

Testing

  • Ran unit tests: npx vitest run test/unit/unlinked-issue-guardrail.test.ts test/unit/unlinked-issue-match.test.ts --reporter=dot, resulting in 2 test files and 53 tests passing.
  • Ran git diff --check which reported no issues.
  • Typecheck (npm run typecheck) could not complete cleanly due to missing optional local package type dependencies (environment-only), and npm audit --audit-level=moderate failed against the registry with a 403 error; these are environmental and unrelated to the logic change.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.12%. Comparing base (3307ae0) to head (4398d11).
⚠️ Report is 36 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4645   +/-   ##
=======================================
  Coverage   94.12%   94.12%           
=======================================
  Files         430      430           
  Lines       38177    38182    +5     
  Branches    13920    13922    +2     
=======================================
+ Hits        35934    35939    +5     
  Misses       1585     1585           
  Partials      658      658           
Files with missing lines Coverage Δ
src/review/unlinked-issue-guardrail.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 10, 2026
@loopover-orb

loopover-orb Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-10 23:42:12 UTC

2 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR closes a real capacity-exhaustion bypass in the unlinked-issue guardrail: the per-actor rate ceiling and shared AI-budget gates previously returned bare `undefined` (a clean pass) when tripped, letting an attacker exhaust verifier capacity to slip an unlinked PR through with no hold — now both return a proper `hold` disposition via `unlinkedIssueVerifyCapacityHold`. It also correctly moves `recordUnlinkedIssueVerifyUsage` to after the verify call, gated on a real `hasUnlinkedIssueVerifyAiBinding` check that mirrors `verifyUnlinkedIssueMatch`'s own binding check, so a missing AI binding no longer burns the shared budget ledger for a call that never happened. The new/updated tests exercise the real reachable code paths (rate-limit hold, budget-exhaustion hold, no-AI-binding accounting) rather than fabricated states, and no schema or migration changes are involved.

Nits — 4 non-blocking
  • The PR description doesn't link or close a specific open issue — only cites prior PR fix(review): add a per-actor rate ceiling on the unlinked-issue-match AI verifier, ahead of its existing post-hoc repeat-escalation check #4515 as motivating context; worth adding an explicit issue reference per repo convention.
  • src/review/unlinked-issue-guardrail.ts: `recordUnlinkedIssueVerifyAttempt` is still called unconditionally before the `hadAiBinding` check inside the loop, so a rate-limit audit event is recorded even when no AI binding exists — intentional per the PR description ('as before'), but worth a one-line comment noting this is deliberate so a future reader doesn't 'fix' it to match the usage-recording gating.
  • Consider hoisting the `hasUnlinkedIssueVerifyAiBinding` check out of the per-candidate loop in resolveUnlinkedIssueMatchDisposition (src/review/unlinked-issue-guardrail.ts) since `env.AI` doesn't change between candidates — a minor micro-optimization, not required.
  • The duplicate binding-check logic (`hasUnlinkedIssueVerifyAiBinding` vs. the inline check in verifyUnlinkedIssueMatch, src/review/unlinked-issue-match.ts) could be unified into one shared helper to avoid future drift between the two conditions.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 48 registered-repo PR(s), 40 merged, 275 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 48 PR(s), 275 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 48 PR(s), 275 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 10, 2026
@JSONbored
JSONbored merged commit e8b0ced into main Jul 10, 2026
11 checks passed
@JSONbored
JSONbored deleted the codex/fix-vulnerability-in-unlinked-issue-guardrail branch July 10, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant