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

address review (codex): exclude ollama-backed wrappers from all quota families; reject impossible calendar dates

[._.]/ Adam Eivy46f31eba338f
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 7fac65161f..588e8fd9eb 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -619,7 +619,14 @@ export const scaffoldSchema = z.object({
// USAGE (devtools usage reports)
// =============================================================================
-const isoDay = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Expected YYYY-MM-DD');
+// Shape AND calendar validity — the regex alone accepts impossible dates like
+// 2026-02-30, which would silently return an empty report instead of a 400.
+const isoDay = z.string()
+ .regex(/^\d{4}-\d{2}-\d{2}$/, 'Expected YYYY-MM-DD')
+ .refine((s) => {
+ const d = new Date(`${s}T00:00:00Z`);
+ return !Number.isNaN(d.getTime()) && d.toISOString().slice(0, 10) === s;
+ }, { message: 'Not a valid calendar date' });
/**
* Query params for GET /api/usage — either a preset period or an explicit
diff --git a/server/routes/usage.test.js b/server/routes/usage.test.js
index 49fcb5cc87..fa774a8734 100644
--- a/server/routes/usage.test.js
+++ b/server/routes/usage.test.js
@@ -78,6 +78,12 @@ describe('usage routes', () => {
expect(usage.getUsageSummary).not.toHaveBeenCalled();
});
+ it('GET /api/usage rejects an impossible calendar date', async () => {
+ const res = await request(buildApp()).get('/api/usage?from=2026-02-30');
+ expect(res.status).toBe(400);
+ expect(usage.getUsageSummary).not.toHaveBeenCalled();
+ });
+
it('GET /api/usage rejects from after to', async () => {
const res = await request(buildApp()).get('/api/usage?from=2026-03-01&to=2026-01-01');
expect(res.status).toBe(400);
diff --git a/server/services/providerUsage.js b/server/services/providerUsage.js
index 6bc57b71fc..6cdda83d73 100644
--- a/server/services/providerUsage.js
+++ b/server/services/providerUsage.js
@@ -226,7 +226,7 @@ const FAMILIES = [
{
id: 'claude',
label: 'Claude Code',
- matches: (p) => (p.type === 'cli' || p.type === 'tui') && !p.ollamaBacked && isClaudeCommand(p.command),
+ matches: (p) => (p.type === 'cli' || p.type === 'tui') && isClaudeCommand(p.command),
fetch: fetchClaudeQuota
},
{
@@ -249,9 +249,15 @@ const FAMILIES = [
}
];
-/** Distinct quota families among the enabled providers, in registry order. */
+/**
+ * Distinct quota families among the enabled providers, in registry order.
+ * Ollama-backed wrappers are excluded up front regardless of which CLI binary
+ * they launch — a local model has no subscription quota, so e.g. an enabled
+ * `claude-ollama` must not surface a Claude Code card (nor a codex/agy/grok
+ * wrapper its family's card).
+ */
export function resolveEnabledFamilies(providers) {
- const enabled = (providers || []).filter((p) => p?.enabled);
+ const enabled = (providers || []).filter((p) => p?.enabled && p.ollamaBacked !== true);
return FAMILIES.filter((family) => enabled.some((p) => family.matches(p)));
}
diff --git a/server/services/providerUsage.test.js b/server/services/providerUsage.test.js
index ac1e86ffb7..64474401bc 100644
--- a/server/services/providerUsage.test.js
+++ b/server/services/providerUsage.test.js
@@ -80,9 +80,11 @@ describe('resolveEnabledFamilies', () => {
expect(families).toEqual(['claude', 'codex', 'grok']); // agy disabled; ollama maps to no family
});
- it('does not map ollama-backed claude wrappers to the claude family', () => {
+ it('does not map ollama-backed wrappers to ANY family (local models have no subscription quota)', () => {
const families = resolveEnabledFamilies([
- { id: 'claude-ollama', enabled: true, type: 'cli', command: 'claude', ollamaBacked: true }
+ { id: 'claude-ollama', enabled: true, type: 'cli', command: 'claude', ollamaBacked: true },
+ { id: 'codex-ollama', enabled: true, type: 'cli', command: 'codex', ollamaBacked: true },
+ { id: 'grok-ollama', enabled: true, type: 'cli', command: 'grok', ollamaBacked: true }
]);
expect(families).toEqual([]);
});