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.53% 95.52% -0.01%
==========================================
Files 204 204
Lines 22090 22092 +2
Branches 7975 7975
==========================================
+ Hits 21103 21104 +1
Misses 412 412
- Partials 575 576 +1
🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review — held for maintainer review
⏸️ Held for maintainer review — Touches a guarded path — held for manual review Review summary
Nits — 6 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 PR correctly ports the `AI_DAILY_NEURON_BUDGET` resolution pattern from `ai-review.ts`/`ai-slop.ts` to both functions in `ai-summaries.ts`, fixing a real starvation bug where shared counter usage above 10k triggered `quota_exceeded` — a tiny fraction of the real 10M shared budget. The new two-liner is a faithful, character-for-character copy of the sibling pattern and handles all edge cases correctly: unset, empty, and non-finite inputs default to 10M; a finite configured value is used and clamped to 10M. Regression tests pre-populate the shared `sumAiEstimatedNeuronsSince` counter to drive the real code path rather than manufacturing an unreachable state, which is the right approach here. Nits (5)
🟩 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.