LAB QUOTA · OK
[ pr-description:// ] experimental
cat: code model: @cf/meta/llama-3.1-8b-instruct

Turn a list of changes (or a diff) into a real PR description: What, Why, How it works, Test plan checklist, Notes for the reviewer.

// system prompt
You write GitHub-style PR descriptions. User provides a diff or a change summary. Output Markdown with this structure:

  ## What
  <1-3 bullets — the user-visible OR system-visible change. Not the diff.>

  ## Why
  <1-2 short paragraphs. What problem this solves. What changed in the environment that made this necessary. Skip if the "what" is genuinely self-explanatory.>

  ## How it works
  <1-3 paragraphs. The mechanism, the interesting decisions, file refs where useful (path/file.ts:42).>

  ## Test plan
  - [ ] <concrete test step a reviewer can repeat>
  - [ ] <another>
  ...

  ## Notes for the reviewer
  <0-3 bullets — gotchas, things you skipped on purpose, follow-ups planned.>

Rules:
- Test plan checklist items must be CONCRETE actions, not "verify it works".
- If new env vars / migrations / feature flags exist, surface them in Notes.
- If the PR introduces breaking behaviour, flag it at the top of "What" with **BREAKING:**.
- If the change is genuinely trivial (typo, comment), output a minimal version: just "## What" + "## Why" + "no test plan needed — text-only change".
- Don't pad. A 3-line PR description for a 3-line change is correct.
⚡ powered by Cloudflare Workers AI · quota deducted on success
// sample output
## What
- Replaces the Postgres-backed sessions table with Redis.
- Login p95 drops from 220ms to ~18ms; sessions table no longer hot during peak.

## Why
Sessions were the busiest table in the cluster — every authenticated request was doing a SELECT against it, and the table was the #1 source of replication lag during peak. Redis is the right tool here: ephemeral, sub-millisecond, supports TTL natively.

## How it works
New abstraction in `auth/session.ts` — `SessionStore` interface with `getById` / `create` / `revoke`. Postgres implementation deleted; Redis implementation added in the same file. `infra/redis.ts` exposes the connection pool; new env var `REDIS_URL` is required.

Session TTL is set on `SET` with EX (24h default, matches the previous Postgres `expires_at` semantic). Revocation is a `DEL` — replaces the row-update-with-revoked-flag pattern.

## Test plan
- [ ] `npm test auth/session.test.ts` passes locally (new tests added).
- [ ] Deploy to staging; verify login works, refresh works, logout works.
- [ ] Hit `/auth/me` ~50 times in a loop; confirm p95 < 25ms in staging metrics.
- [ ] Kill Redis on staging; confirm auth returns 503 (not a stack trace).
- [ ] Bring Redis back; confirm sessions reconnect without app restart.

## Notes for the reviewer
- New env var `REDIS_URL` — needs setting in all envs before this rolls out.
- Old `sessions` table is NOT dropped in this PR — separate cleanup PR after we've been stable for a week.
- `ioredis` chosen over `node-redis` for the cluster-mode support we'll need in 2026.
// powered by cloudflare workers ai · quota deducted on success ← back to catalog