Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

clarify quota-burn dispatch source naming in the pre-agent hook

[._.]/ Adam Eivya26ebb3fe4fa
diff --git a/server/services/autonomousJobs/quotaBurnHooks.js b/server/services/autonomousJobs/quotaBurnHooks.js
index 1fbd7df224..05afbf3b08 100644
--- a/server/services/autonomousJobs/quotaBurnHooks.js
+++ b/server/services/autonomousJobs/quotaBurnHooks.js
@@ -43,11 +43,12 @@ function renderPrompt(candidate) {
export async function buildTaskInput({ app } = {}) {
if (!app) return { skip: { reason: 'no-app' } };
const config = quotaBurnConfig(app);
- // Ledger + in-flight: a quota-burn task already queued or running holds its
- // window slot even though its ledger write lands post-agent (#3179).
- const ledger = await getEffectiveQuotaBurnDispatches();
+ // Ledger + in-flight, NOT the bare ledger: a quota-burn task already queued or
+ // running holds its window slot even though its ledger write lands post-agent
+ // (#3179).
+ const dispatches = await getEffectiveQuotaBurnDispatches();
const quotas = await getProviderQuotas({ refresh: true });
- const candidates = selectBurnCandidates(quotas, config, { dispatches: ledger });
+ const candidates = selectBurnCandidates(quotas, config, { dispatches });
const candidate = candidates[0];
if (!candidate) return { skip: { reason: 'no-burnable-provider-quota' } };
diff --git a/server/services/autonomousJobs/quotaBurnHooks.test.js b/server/services/autonomousJobs/quotaBurnHooks.test.js
index 7ab6e18725..ab69b34a24 100644
--- a/server/services/autonomousJobs/quotaBurnHooks.test.js
+++ b/server/services/autonomousJobs/quotaBurnHooks.test.js
@@ -6,7 +6,9 @@
* gating — so any downstream skip (perpetual-work, branch-/issue-reconcile,
* reference-watch, PLAN.md) permanently consumed a slot of
* `family.maxDispatchesPerWindow` for an agent that never ran. The write now
- * happens once, post-agent, in `processTaskOutput`.
+ * happens once, post-agent, in `processTaskOutput` — and because that leaves a
+ * gap where a created burn isn't in the ledger yet, candidate selection counts
+ * in-flight burns alongside it so the window cap still holds.
*/
import { describe, it, expect, vi, beforeEach } from 'vitest';