Files
CatoandClaude Opus 5.5 319da42e0a feat(ai): readers first — background jobs draw from a capped, reserved slice of the free budget (#93)
ai-kit 1.13.0 classBudget: drafting may spend <=25% of the day and never below
a 50% floor kept for Ask (env-tunable); spend recorded per class per UTC day
(research_ai_spend) and shown on /data#ai-budget with its method.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 15:02:28 -07:00

20 lines
793 B
PL/PgSQL

BEGIN;
-- Model spend on this app's free keys, per UTC day and per class: 'interactive'
-- (a reader waiting on Ask) and 'background' (scheduled jobs such as event
-- drafting). Background may only spend from a capped slice and never below the
-- floor kept for readers (lib/ai-budget.ts). Tokens are the vendor's count when
-- it reports one, otherwise a characters/4 estimate.
CREATE TABLE IF NOT EXISTS research_ai_spend (
day date NOT NULL,
class text NOT NULL,
tokens bigint NOT NULL DEFAULT 0,
calls integer NOT NULL DEFAULT 0,
held integer NOT NULL DEFAULT 0,
PRIMARY KEY (day, class)
);
COMMENT ON TABLE research_ai_spend IS 'Per-day AI token spend by class (interactive/background) on the shared free keys; held = background calls refused to protect readers.';
COMMIT;