fix(ai-summaries): resolve the shared daily neuron budget like the AI review path (10M)#1455
Conversation
… review path (10M) summarizeAgentBundleWithAi and rewriteSignalBundleWithAi resolved AI_DAILY_NEURON_BUDGET with a 10k default and a 1M ceiling, while ai-review.ts and ai-slop.ts (JSONbored#1369) resolve the SAME shared daily counter to a 10M default and 10M ceiling. Because all three Workers-AI features sum into one sumAiEstimatedNeuronsSince total, summaries were starved into quota_exceeded once shared usage crossed 10k neurons — a tiny fraction of the real budget — and a configured budget was capped at 1M. Mirror the sibling resolution (default 10M, finite-check, clamp to 10M) at both sites and add regression tests pinning the high default, the raised ceiling, and the invalid-to-default fallback for both the summarize and rewrite paths.
|
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 #1455 +/- ##
==========================================
- Coverage 95.37% 95.37% -0.01%
==========================================
Files 199 199
Lines 21546 21548 +2
Branches 7791 7791
==========================================
+ Hits 20550 20551 +1
Misses 416 416
- Partials 580 581 +1
🚀 New features to boost your workflow:
|
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review — blocked
🛑 Blocked Review summary CI checks failing
Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
Review detailsGenerated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative. This is a targeted two-site bug fix that aligns `AI_DAILY_NEURON_BUDGET` resolution in `summarizeAgentBundleWithAi` and `rewriteSignalBundleWithAi` with the already-proven pattern from `ai-review.ts` and `ai-slop.ts`. The old `|| 10000` / `1_000_000` ceiling starved the shared counter at 10k and hard-capped configured budgets at 1M; the new `&& Number.isFinite` / `10_000_000` pattern is logically correct for every input class (unset → 10M, valid number → raw clamped to 10M, truthy-but-non-finite → 10M). The test changes accurately invert the old regression assertion and add coverage for default-HIGH and ceiling-raised scenarios on both the summarize and rewrite paths. Nits (4)
🟩 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.
|
Summary
Fixes #1454.
summarizeAgentBundleWithAiandrewriteSignalBundleWithAi(src/services/ai-summaries.ts) resolvedAI_DAILY_NEURON_BUDGETwith a10000default and1_000_000ceiling, while the two sibling Workers-AI features that draw on the same shared daily counter (sumAiEstimatedNeuronsSince) use a10_000_000default and ceiling:Because all three features sum into one shared daily total, summaries were starved into
quota_exceededonce shared usage crossed 10k neurons (a tiny fraction of the real 10M budget), and a configured budget was capped at 1M. This applies the same resolution at both summary sites. The fix was applied to ai-slop in #1369 but never to ai-summaries.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally; both changedconst budgetlines have both sides of the new&&/ternary covered (unset→default, finite→raw, non-finite→default) for both the summarize and rewrite paths, with regression tests that fail before the fix.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run test:cigate locally; all checks green.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.Backend service-logic change with no UI/API surface impact, so the UI Evidence section is omitted.
Notes
const budgetresolutions inai-summaries.tsplus regression tests. No new env var (AI_DAILY_NEURON_BUDGETalready exists), no schema/OpenAPI/wrangler/migration impact. Mirrors merged fix(ai-slop): resolve the shared neuron budget like the AI review path (10M) #1369 exactly.