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

fix: address review (opencode): bound periodHours and preserve scope in sanitizeLimit

[._.]/ Adam Eivyec32294490d8
diff --git a/server/lib/fleetQuotas.js b/server/lib/fleetQuotas.js
index db528d957a..f53d0d4ab2 100644
--- a/server/lib/fleetQuotas.js
+++ b/server/lib/fleetQuotas.js
@@ -50,10 +50,14 @@ function sanitizeLimit(raw) {
const key = str(raw?.key, 120);
if (!key) return null;
const percentUsed = pct(raw?.percentUsed);
- const periodHours = Number.isFinite(raw?.periodHours) && raw.periodHours > 0 ? raw.periodHours : null;
+ const periodHours = Number.isFinite(raw?.periodHours) && raw.periodHours > 0 && raw.periodHours <= 366 * 24
+ ? raw.periodHours
+ : null;
+ const scope = str(raw?.scope, 60);
return {
key,
label: str(raw?.label, 200) || key,
+ ...(scope ? { scope } : {}),
percentUsed,
percentRemaining: percentUsed === null ? null : 100 - percentUsed,
resetsAt: str(raw?.resetsAt, 60),
diff --git a/server/lib/fleetQuotas.test.js b/server/lib/fleetQuotas.test.js
index 98364f425b..d85a8a278e 100644
--- a/server/lib/fleetQuotas.test.js
+++ b/server/lib/fleetQuotas.test.js
@@ -56,18 +56,21 @@ describe('sanitizeQuotaCards', () => {
// #7662: periodHours has to survive the wire rebuild, or a federated merge
// can only classify a peer's window from its scope/label text.
- it('carries a stated periodHours through, and omits it when absent', () => {
+ it('carries a stated periodHours through, and omits it when absent or excessive', () => {
const [card] = sanitizeQuotaCards([{
family: 'codex', label: 'Codex', fetchedAt: '2026-09-03T10:00:00.000Z',
limits: [
- { key: 'session', percentUsed: 10, periodHours: 7 },
+ { key: 'session', percentUsed: 10, periodHours: 7, scope: 'session' },
{ key: 'week', percentUsed: 10 },
{ key: 'burst', percentUsed: 10, periodHours: 0 },
+ { key: 'millennium', percentUsed: 10, periodHours: 1e9 },
],
}]);
- expect(card.limits[0]).toMatchObject({ key: 'session', periodHours: 7 });
+ expect(card.limits[0]).toMatchObject({ key: 'session', periodHours: 7, scope: 'session' });
expect(Object.hasOwn(card.limits[1], 'periodHours')).toBe(false);
+ expect(Object.hasOwn(card.limits[1], 'scope')).toBe(false);
expect(Object.hasOwn(card.limits[2], 'periodHours')).toBe(false);
+ expect(Object.hasOwn(card.limits[3], 'periodHours')).toBe(false);
});
});