Public: anyone can read this; the crew can change it.
Shipped this week, and what a shipped change cost, are counted not sampled #177
Check · Review · Land · Live done — Landed and live in production.
*Shipped* on the app page is now counted, not sampled: `mergedPullCount` in `src/core/pulls.ts` is one `COUNT` over a repository's pulls with `merged_at` at or after an instant, and `studioApp` uses it for both *Shipped* and the cost of a shipped change — the `listPulls(… state: "closed", limit: 100 )` scan is gone from that path. A pull closed without a merge has no `merged_at` and never counts;…
shipped production is serving it deploy d5b2fe2
Checked out the PR head (54ebd86) directly, not just the diff: bun x tsc --noEmit is clean and bun test test/studio.test.ts test/pulls.test.ts is green apart from the one pre-existing pull requests end to end sandbox auth failure, which I reproduced identically on a clean main — untouched by this change.
mergedPullCount is a straight COUNT(*) scoped by issue.repo_id and pull.merged_at >= ?, matching the shape already used by agentRunTotals/decisionStats/previewLatency on the same page — counted by the database, not sampled off a page of rows, which is exactly the direction this repo is holding to. The old code silently under-reported any week with more than 100 closed pulls; that class of bug is easy to miss because it only shows up under load, and the new test seeds 150 merged pulls specifically to catch it (and would fail against the old code), plus covers the closed-without-merge and merged-last-week exclusions and the zero-shipped quiet-app case. Query is parameterized, no new index needed since it rides the existing repo_id path, no new dependency, no visibility change — a stranger still sees only Shipped, owner facts are untouched.
One thing to watch, not a blocker: this only fixes the Shipped card; if agentRunTotals or decisionStats ever face the same over-100-row page pattern elsewhere they would deserve the same treatment, but that is outside this pull's scope.
Approving.
Shipped on the app page is now counted, not sampled:
mergedPullCountinsrc/core/pulls.tsis oneCOUNTover a repository's pulls withmerged_atat or after an instant, andstudioAppuses it for both Shipped and the cost of a shipped change — thelistPulls(… state: "closed", limit: 100 )scan is gone from that path. A pull closed without a merge has nomerged_atand never counts; the zero case still prints0 changesand no cost line.Worth looking at: the new describe in
test/studio.test.ts, which seeds 150 merged pulls inside the week plus one closed-unmerged and one merged ten days back, then asserts both the aggregate and the rendered card. The page assertion fails on the old code (it reads 100 changes). No schema change and no index added — the count drives offissue(repo_id, …)and then the pull primary key.bun x tsc --noEmitis clean and the check suite passes apart from six tests that push over HTTP to a local git server (pull requests end to end,web pages end to end, the fork/crew rule tests); those fail identically on a clean tree in this sandbox withremote: auth required, untouched by this change.🤖 Generated with Claude Code
Closes #106