Files
causius/lib/limits.ts
CatoandClaude Opus 5.5 40a5c4b05d Matters, the fleet design system and a technical narrative (#10)
* Matters: encrypted, agentic legal workspace behind OrangeCat sign-in

A matter is sealed per matter (AES-256-GCM data key under CAUSIUS_MASTER_KEY).
The agent works it with tools (search, read, deadlines, tasks, drafts,
approvals); every personal detail is swapped for a placeholder before a model
sees it, and the person's account name is always one of them. The database in
the clear holds no name, message, deadline or document.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ

* Fleet design system, a technical narrative, one account across the fleet, domain checks

- @bitbaum/design-tokens replaces the bespoke paper-and-ink theme; Solon's
  grammar (kicker, headline-caps, btn-frame) for every page, pinned dark.
- New Platform, Security and Ecosystem pages; the home page rebuilt around what
  works today (lib/capabilities.ts is the one place a status is decided).
- Sign-in and sign-up routes hand straight to OrangeCat; the account menu and
  the ecosystem page link the rest of the fleet, read from the fleet map.
- The agent can check domain names with the registries over RDAP.
- The i18n parity test reads ICU properly (select branches, apostrophes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ

* Provision matters on the host: database, OrangeCat client, runtime env

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-11 12:23:14 -07:00

30 lines
1.3 KiB
TypeScript

import { clientIp, slidingWindow, toHeaders } from "limitkit";
/**
* Rate limits, as limitkit decisions. In-memory and per process, which is the
* right size for blunting scripted abuse of a free tier on one box and the
* wrong size for billing — nothing here is billing.
*
* The free analysis is the scarce thing: it draws on a daily budget shared by
* every visitor, so one caller may not drain it. A reader on their own key
* spends their own budget and gets a much wider window.
*/
export const limits = {
analyzeFree: slidingWindow({ limit: 8, windowMs: 60 * 60_000 }),
analyzeOwn: slidingWindow({ limit: 60, windowMs: 60 * 60_000 }),
modelCheck: slidingWindow({ limit: 30, windowMs: 10 * 60_000 }),
// Keyed by actor, not IP: a signed-in person's budget follows them.
turnFree: slidingWindow({ limit: 30, windowMs: 60 * 60_000 }),
turnOwn: slidingWindow({ limit: 200, windowMs: 60 * 60_000 }),
matterCreate: slidingWindow({ limit: 20, windowMs: 60 * 60_000 }),
upload: slidingWindow({ limit: 60, windowMs: 60 * 60_000 }),
};
export function callerKey(request: Request, scope: string): string {
return `${scope}:${clientIp(request.headers)}`;
}
export function tooMany(result: Parameters<typeof toHeaders>[0]): Response {
return Response.json({ error: "rate_limited" }, { status: 429, headers: toHeaders(result) });
}