Skip to content

feat(quota): add soft-threshold quota-warning evaluator#8602

Closed
jeffrey701 wants to merge 2 commits into
JSONbored:mainfrom
jeffrey701:feat-7662-tenant-quota-soft-warning
Closed

feat(quota): add soft-threshold quota-warning evaluator#8602
jeffrey701 wants to merge 2 commits into
JSONbored:mainfrom
jeffrey701:feat-7662-tenant-quota-soft-warning

Conversation

@jeffrey701

Copy link
Copy Markdown
Contributor

What

Adds the pure soft-warning evaluator #7662 needs: evaluateTenantQuotaWarning
(packages/loopover-engine/src/tenant-quota.ts) — the counterpart to the existing hard
evaluateTenantQuota. Today evaluateTenantQuota's per-dimension remaining figures are
never checked against any soft threshold; this reports the first dimension (same
compute→time→concurrency precedence as the hard check) whose headroom has fallen to or below
warnThreshold of its cap (default 0.2 ⇒ ≤20% left / ≥80% consumed) — the pre-exhaustion
band a "running low" notification fires in — or null when every bounded dimension is healthy.

  • A dimension already exhausted (remaining 0) is not warned on here — the hard block owns it.
  • A zero/undefined cap yields no meaningful fraction and is skipped.
  • Pure and side-effect-free: the caller decides whether/when to fire a notification from it.

Scope note

This is the evaluation half. The notification-event-kind + delivery wiring must hook into the
same admission-check point #7647 adds to src/queue/job-dispatch.ts (the issue is explicit:
do not invent a separate call site). That call site does not exist until #7647 lands
(evaluateTenantQuota is not yet called anywhere in job-dispatch.ts), so the firing is a
follow-up on top of this evaluator rather than a second invented mechanism — the evaluator lands
independently and is structurally ready for that wiring.

Validation

  • New tests in test/unit/tenant-quota.test.ts (imports the engine source directly, so Codecov
    sees the coverage): healthy → no warn; first low dimension warned at the threshold; precedence
    (time reported when compute healthy); an exhausted dimension not warned; a zero-cap dimension
    skipped; a custom threshold honored. 100% branch coverage on the new function (verified via lcov).
  • npx vitest run test/unit/tenant-quota.test.ts → 14/14 pass; @loopover/engine rebuilds clean.

Closes #7662

@jeffrey701
jeffrey701 requested a review from JSONbored as a code owner July 25, 2026 02:09
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.54%. Comparing base (afb9d3c) to head (36e692a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8602      +/-   ##
==========================================
- Coverage   92.55%   92.54%   -0.01%     
==========================================
  Files         796      796              
  Lines       79874    79862      -12     
  Branches    24138    24139       +1     
==========================================
- Hits        73924    73908      -16     
  Misses       4804     4804              
- Partials     1146     1150       +4     
Flag Coverage Δ
backend 93.72% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/loopover-engine/src/tenant-quota.ts 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 25, 2026
@loopover-orb

loopover-orb Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-25 02:27:00 UTC

2 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
Adds a pure `evaluateTenantQuotaWarning` function alongside the existing `evaluateTenantQuota`, correctly reusing its `remaining` output and applying the same compute→time→concurrency precedence to find the first dimension at or below a configurable soft threshold (default 20% headroom), excluding already-exhausted dimensions and zero-cap dimensions. Logic is correct and well-tested (6 new cases covering healthy, warn, precedence, exhausted-exclusion, zero-cap, and custom-threshold paths), and it closes #7662 as a self-contained evaluation-only building block, deferring the notification-firing wiring to #7647 as the description explains.

Nits — 4 non-blocking

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7662
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 (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 74 registered-repo PR(s), 34 merged, 18 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jeffrey701; Gittensor profile; 74 PR(s), 18 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Partially addressed
The PR adds only the pure evaluateTenantQuotaWarning function with solid test coverage, but does not add the quota-warning event kind to the notification union or wire it into job-dispatch.ts's admission-check point as the issue's deliverables explicitly require, deferring that to a follow-up.

Review context
  • Author: jeffrey701
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 74 PR(s), 18 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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.
🧪 Chat with LoopOver

Ask 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.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

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.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 25, 2026
@loopover-orb loopover-orb Bot closed this Jul 25, 2026
@loopover-orb

loopover-orb Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This repository reviews pull requests one-shot: the PR must be correct as originally opened. Pushing an additional commit closes it automatically instead of restarting review — open a fresh pull request with every fix included.

@loopover-orb loopover-orb Bot added the review-evasion Gittensor contributor context label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context review-evasion Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add soft quota-warning notifications before #7647's hard block

1 participant