Lane 10: a test's AI usage counts, marked as a test (D227, #736) #917

Merged
claude-bot merged 6 commits from build/lane10-d227-test-usage into main 2026-09-29 05:16:57 +00:00
Collaborator

Part of #736 (lane 10). D227: a "Test the bot" run transcribes and summarises with the campaign's own models, so it counts in usage like any other run, marked as a test.

Migration 10e5f6a7b8c9 on 8c9d0e1f2a3b (#909's)

  • session_usage.session_id becomes nullable.
  • New columns:
    • recording_test_id: a foreign key to recording_tests, ON DELETE SET NULL, indexed;
    • purpose (session or test, with a CHECK). Existing rows backfill to session.
  • A second CHECK: a session row has a session_id, and a test row has none.
  • The downgrade deletes test rows before restoring NOT NULL.
  • Up → down → up with seeded session and test rows, on two fresh Postgres 16 databases. There is one head, and the pin has moved.

The writer

recording_test_service meters ASR and the LLM exactly as process_audio does. It writes a purpose='test' row on success and on every failure path, replacing the old log-only usage.

Every reader checked

  • usage_service._load_rows (Admin → AI usage & speed, and its per-campaign view) already outer-joins Session, so a NULL session_id gives a null title and still counts. Tested.
  • Preflight (measure_realtime_factor and measure_llm_tokens_per_run) and admin_overview_service don't join Session, so test rows count automatically.
  • Hosted entitlements have no SessionUsage reader (the credits live at the payment provider). CAMP-13 and HOME-7 don't read usage today.
  • Admin usage page: a test row reads "Test the bot" with a test chip.

Checks

  • Backend full suite: 5832 passed, 0 failed, on a fresh Postgres 16.
  • vitest: 2747 passed. eslint: 0 errors. ruff: clean.
  • Changelog: a changelog.d/ fragment.

🤖 Generated with Claude Code

Part of #736 (lane 10). **D227:** a "Test the bot" run transcribes and summarises with the campaign's own models, so it counts in usage like any other run, marked as a test. ## Migration `10e5f6a7b8c9` on `8c9d0e1f2a3b` (#909's) - `session_usage.session_id` becomes nullable. - **New columns:** - `recording_test_id`: a foreign key to `recording_tests`, `ON DELETE SET NULL`, indexed; - `purpose` (`session` or `test`, with a CHECK). Existing rows backfill to `session`. - **A second CHECK:** a `session` row has a `session_id`, and a `test` row has none. - **The downgrade** deletes `test` rows before restoring NOT NULL. - Up → down → up with seeded session and test rows, on two fresh Postgres 16 databases. There is one head, and the pin has moved. ## The writer `recording_test_service` meters ASR and the LLM exactly as `process_audio` does. It writes a `purpose='test'` row on success and on every failure path, replacing the old log-only usage. ## Every reader checked - **`usage_service._load_rows`** (Admin → AI usage & speed, and its per-campaign view) already outer-joins `Session`, so a NULL `session_id` gives a null title and still counts. Tested. - **Preflight** (`measure_realtime_factor` and `measure_llm_tokens_per_run`) and **`admin_overview_service`** don't join `Session`, so test rows count automatically. - **Hosted entitlements** have no `SessionUsage` reader (the credits live at the payment provider). CAMP-13 and HOME-7 don't read usage today. - **Admin usage page:** a test row reads "Test the bot" with a `test` chip. ## Checks - **Backend full suite:** 5832 passed, 0 failed, on a fresh Postgres 16. - **vitest:** 2747 passed. **eslint:** 0 errors. **ruff:** clean. - **Changelog:** a `changelog.d/` fragment. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
WIP checkpoint before merging origin/main: migration 10e5f6a7b8c9
makes session_usage.session_id nullable and adds recording_test_id
+ purpose columns; process_recording_test writes usage rows the same
way the session pipeline does; usage readers updated for NULL
session_id.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Re-chains 10e5f6a7b8c9 (D227: a test's usage counts, marked as a
test) onto 8c9d0e1f2a3b (#896: handout reveal messages) instead of
directly onto 8b8c9d0e1f2a (the map), so the chain stays
8b8c9d0e1f2a -> 8c9d0e1f2a3b -> 10e5f6a7b8c9 with a single head.
Moves the one-head pin accordingly and extends test_notifications'
history docstring with both migrations. Verified with a seeded
up/down/up against a fresh Postgres 16.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/main' into build/lane10-d227-test-usage
All checks were successful
CI / Summarisation accuracy eval harness (stub provider) (pull_request) Successful in 2m51s
CI / Bot tests and audit (pull_request) Successful in 5m13s
CI / Backend lint (ruff) (pull_request) Successful in 1m17s
CI / Feedback site tests (pull_request) Successful in 2m2s
CI / Bot/backend version sync (pull_request) Successful in 1m7s
CI / Docker image build (pull_request) Successful in 1m23s
CI / Does this change touch the recording path? (pull_request) Successful in 35s
CI / Synthetic session harness (no GPU, no LLM) (pull_request) Has been skipped
CI / Backend migration, tests, and audit (pull_request) Successful in 20m15s
CI / End-to-end journeys (desktop, phone, keyboard-only) (pull_request) Successful in 20m41s
CI / Frontend tests, audit, and build (pull_request) Successful in 50m51s
88f10b0b05
Merge remote-tracking branch 'origin/main' into build/lane10-d227-test-usage
Some checks failed
CI / Summarisation accuracy eval harness (stub provider) (pull_request) Successful in 1m43s
CI / Backend lint (ruff) (pull_request) Successful in 32s
CI / Bot/backend version sync (pull_request) Successful in 22s
CI / Does this change touch the recording path? (pull_request) Successful in 16s
CI / Synthetic session harness (no GPU, no LLM) (pull_request) Has been skipped
CI / Feedback site tests (pull_request) Successful in 1m16s
CI / Docker image build (pull_request) Successful in 46s
CI / Bot tests and audit (pull_request) Successful in 3m25s
CI / Backend migration, tests, and audit (pull_request) Failing after 12m46s
CI / Frontend tests, audit, and build (pull_request) Successful in 21m33s
CI / End-to-end journeys (desktop, phone, keyboard-only) (pull_request) Successful in 38m29s
ff444aefa3
Merge remote-tracking branch 'origin/main' into build/lane10-d227-test-usage
All checks were successful
CI / Summarisation accuracy eval harness (stub provider) (pull_request) Successful in 1m1s
CI / Backend lint (ruff) (pull_request) Successful in 41s
CI / Feedback site tests (pull_request) Successful in 47s
CI / Bot/backend version sync (pull_request) Successful in 36s
CI / Docker image build (pull_request) Successful in 29s
CI / Does this change touch the recording path? (pull_request) Successful in 23s
CI / Synthetic session harness (no GPU, no LLM) (pull_request) Has been skipped
CI / Bot tests and audit (pull_request) Successful in 2m59s
CI / Backend migration, tests, and audit (pull_request) Successful in 19m21s
CI / Frontend tests, audit, and build (pull_request) Successful in 22m27s
CI / End-to-end journeys (desktop, phone, keyboard-only) (pull_request) Successful in 14m50s
3c1ea1a6a5
Sign in to join this conversation.
No description provided.