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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: a repeat quota-burn refusal after an expired block now records a TTL-bounded block (#12604)
[._.]/ Adam Eivy787d490be6e7
diff --git a/server/services/quotaBurnDenials.js b/server/services/quotaBurnDenials.jsindex 798b57923f..18a7e89e50 100644--- a/server/services/quotaBurnDenials.js+++ b/server/services/quotaBurnDenials.js@@ -185,14 +185,19 @@ export async function recordQuotaBurnDenial({const signal = parseQuotaDenial(output, { now: at, errorAnalysis });if (!signal.denied) return null;const stated = signal.resetsAt ?? (Number.isFinite(limitingResetAt) && limitingResetAt > at ? limitingResetAt : null);- const ledger = await writeLedger((current) => ({- ...current,- [familyId]: {- at,- until: stated ?? current[familyId]?.until ?? null,- reason: errorAnalysis?.message || 'the provider refused the run as out of quota',- },- }));+ const ledger = await writeLedger((current) => {+ // A lapsed prior reset is not carried forward: isObservedBlockActive trusts+ // a present `until`, so it would hide this fresh refusal instead of TTL-bounding it.+ const prior = current[familyId]?.until;+ return {+ ...current,+ [familyId]: {+ at,+ until: stated ?? (Number.isFinite(prior) && prior > at ? prior : null),+ reason: errorAnalysis?.message || 'the provider refused the run as out of quota',+ },+ };+ });const entry = ledger?.[familyId] || null;if (entry) {console.log(`🛑 Quota-burn ${familyId} denied by the provider — blocked until ${entry.until ? new Date(entry.until).toISOString() : `+${UNKNOWN_BLOCK_TTL_MS / 3_600_000}h`}`);diff --git a/server/services/quotaBurnDenials.test.js b/server/services/quotaBurnDenials.test.jsindex 27a2460d24..5ef2ad14f3 100644--- a/server/services/quotaBurnDenials.test.js+++ b/server/services/quotaBurnDenials.test.js@@ -99,6 +99,14 @@ describe('recordQuotaBurnDenial', () => {expect(repeat.until).toBe(NOW + 3 * 3_600_000);});+ it('falls back to the TTL when the prior reset has already lapsed', async () => {+ await recordQuotaBurnDenial({ familyId: 'claude', output: 'hit your usage limit — try again in 3 hours', at: NOW });+ const later = NOW + 4 * 3_600_000;+ const repeat = await recordQuotaBurnDenial({ familyId: 'claude', output: 'usage limit reached', at: later });+ expect(repeat.until).toBeNull();+ await expect(getActiveQuotaBurnBlocks({ now: later + 1 })).resolves.toHaveProperty('claude');+ });+it('records nothing for a failure that is not a quota refusal', async () => {await expect(recordQuotaBurnDenial({ familyId: 'claude', output: 'ENOENT: no such file', at: NOW })).resolves.toBeNull();await expect(getQuotaBurnDenials()).resolves.toEqual({});