mirror of
https://github.com/bitbaum/substrata.git
synced 2026-12-04 07:58:05 +01:00
* feat(ai): drafting runs only on readers' own keys; ratchet against free-tier background AI The hourly drafter spent the site's free models. Remove the free-chain path (freeAsk, backgroundMay); drafting now takes an Ask built from a reader key (lib/byok-ask.ts). /api/cron/drafts is gone; /api/cron/auto-updates drafts only for readers who opted in, on their stored key, capped per day (013). test/no-free-background-ai walks the import graph from every cron route and fails on any path to the free chain; proven by mutation. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(updates): Update news now for every reader; AI summaries and auto-updates on the reader's own key - Bottleneck, company and desk pages: "Update news now" sweeps the web (no AI, signed out too, rate-limited, 15-min cooldown) and lists the leads. - "Summarise with AI" drafts up to three on the reader's key (browser or sealed); without one it explains the free AI is kept for questions and opens the key panel. - /account/settings#auto-updates: opt-in hourly drafting on the stored key, daily cap with a token estimate (3.4k/draft, measured). - Honest copy: /data/freshness reports drafting as on demand, /review, /data AI spend, desk and docs say drafting runs only on readers' keys. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
22 lines
1.9 KiB
TypeScript
22 lines
1.9 KiB
TypeScript
/** The AI-budget numbers on /data, spread into METHODS in lib/methods.ts. */
|
|
import type { Method } from './methods';
|
|
|
|
export const AI_METHODS = {
|
|
'ai-spend': {
|
|
title: 'AI spend by class',
|
|
formula:
|
|
"Tokens per UTC day on this site's free AI keys, summed per class: interactive (Ask and fact-checks, a reader waiting) and background. Background is zero from 2026-09-25: no scheduled job may call the free models, and test/no-free-background-ai.test.ts fails the build if one tries. Drafting runs on readers' own keys and is not on this ledger.",
|
|
explanation:
|
|
"Capacity is the sum of each keyed free vendor's daily estimate in @bitbaum/ai-kit (set low on purpose). Tokens are the vendor's own count where it reports one and a characters÷4 estimate for streamed answers. Held = background calls refused to protect readers. The keys are shared with other apps, so a vendor can refuse before this ledger reaches capacity.",
|
|
code: ['lib/ai-budget.ts', 'test/no-free-background-ai.test.ts', 'lib/chat-agent/turn.ts'],
|
|
},
|
|
'ask-latency': {
|
|
title: 'Ask latency (p50 / p90)',
|
|
formula:
|
|
'Over every Ask question in the last 24 hours that got an answer: the 50th and 90th percentile (continuous, PostgreSQL percentile_cont) of milliseconds from the request reaching the server to the first answer text streamed, and to the finished answer.',
|
|
explanation:
|
|
"One row per question, holding only durations, the number of model calls, lookups planned before them, the serving model and how many free links refused first — never the question or who asked. Timed on the server, so the reader's network is not included. Questions the free budget refused are counted but kept out of the percentiles. Rows older than 30 days are deleted.",
|
|
code: ['lib/ask-timing.ts', 'lib/chat-agent/loop.ts', 'app/api/chat/route.ts'],
|
|
},
|
|
} satisfies Record<string, Method>;
|