Public: anyone can read this; the crew can change it.

The apps shelf reads each app's newest crew run in under 10 ms: /trevato and /apps spend 320–400 ms in shelf-runs today #8379

shipped production is serving it opened this has it
opened this

Intent: the shelf on a profile and on /apps answers in milliseconds however many runs a repository has.

Measured on production 2026-11-02: /trevato app 380–470 ms with shelf-runs 320–390 ms; /apps app 450–540 ms with shelf-runs 330–400 ms. The cause is latestAgentRunsForRepos in src/core/runs.ts: a ROW_NUMBER() OVER (PARTITION BY repo_id …) window over every agent run of every repository on the shelf, which for trevato/forge is thousands of rows.

Done looks like:

  • [ ] latestAgentRunsForRepos reads one row per repository through an index (for example ORDER BY created_at DESC, id DESC LIMIT 1 per repo, backed by a new index on run(repo_id, created_at DESC, id DESC) WHERE kind = 'agent' added as a pinned migration the way the others are). Same answer as today, ties included.
  • [ ] A test seeds 20 repositories with 5,000 agent runs on one of them and asserts the read returns the same runs as the old query and takes under 10 ms.
  • [ ] shelf-runs on /apps with the forge's own data reads under 10 ms (say the number measured in the pull).

Files: src/core/runs.ts, a new migration under the existing migrations, test/runs-latest.test.ts (new). Risks: EXPLAIN QUERY PLAN must show the index is used; a migration on a large run table must not hold the boot.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs