feat(binstat): track build mode (release/dev) in size stats and comparison#778
Open
Alan Wisper (wisper-dev) wants to merge 2 commits into
Open
feat(binstat): track build mode (release/dev) in size stats and comparison#778Alan Wisper (wisper-dev) wants to merge 2 commits into
Alan Wisper (wisper-dev) wants to merge 2 commits into
Conversation
Alan Wisper (wisper-dev)
requested a review
from Sam Gammon (sgammon)
as a code owner
June 23, 2026 21:38
Sam Gammon (sgammon)
approved these changes
Jun 23, 2026
There was a problem hiding this comment.
Pull request overview
This PR adds an optional build-mode dimension (release | dev) to binstat records and query/comparison flows to avoid mixing dev vs. release binaries in size reporting, while keeping legacy records/clients working.
Changes:
- Extend the shared binstat model/schema to include optional
mode, plus tests. - Persist and query
modein thedevstatworker (D1 insert + optional query filter), with query SQL extracted tobuildBinstatQueryand covered by tests. - Add a
--modeoption to the CLI (binstats+bincompare) and thread it through URL building and comparisons, with tests and a client version bump.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| services/devstat/tsconfig.json | Excludes test files from TS compilation for the devstat package. |
| services/devstat/package.json | Adds a bun test script for devstat. |
| services/devstat/handlers/stats.mts | Persists mode to D1 when inserting binstat records. |
| services/devstat/handlers/query.mts | Adds optional mode filtering and extracts SQL construction into buildBinstatQuery. |
| services/devstat/handlers/query.test.mts | Adds unit tests for query SQL/parameter construction including mode. |
| services/commons/tsconfig.json | Excludes test files from TS compilation for the commons package. |
| services/commons/package.json | Adds a bun test script for commons. |
| services/commons/api.mts | Introduces BuildMode and adds optional mode to BinstatInfo + schema. |
| services/commons/api.test.mts | Adds schema tests verifying mode is optional and validated. |
| services/client/tsconfig.json | Excludes test files from TS compilation for the client package. |
| services/client/package.json | Bumps client version to 0.1.2 and adds a bun test script. |
| services/client/client.mts | Adds --mode CLI options for binstats and bincompare. |
| services/client/actions/binstats.mts | Validates and includes mode in posted binstat payloads. |
| services/client/actions/bincompare.mts | Threads mode into query URL construction and fetches; exports helpers for testing. |
| services/client/actions/bincompare.test.mts | Adds unit tests for URL building and per-platform deduplication behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why
The PR "Binary Size Report" compares size stats without accounting for the build
mode. A release build (small) and a dev build (large) are indistinguishable, so
when a commit has stats for both modes the comparison picks the most recent by
timestamp and reports a large bogus delta.
What changes
Adds a
modedimension (release | dev), optional at every layer — fullybackward compatible:
modefield onBinstatInfoand the zod schema (z.optional).modeto D1 (binstats-v1); filterAND mode = ?onlywhen the param is supplied; SQL extracted into a pure
buildBinstatQuery.--modeoption onbinstatsandbincompare, threaded into thequery URL, with value validation; version
0.1.1 -> 0.1.2.Tests
bun test(10/10): schema (mode optional / invalid rejected), query building(filter only when mode is present, os/arch/mode ordering), client (URL with/without
mode, per-platform dedup).
Compatibility
Rows without
mode(NULL) do not match amode=...filter; a platform with nosame-mode baseline renders
N/Aand self-heals as new stats accrue. Existingclients and queries behave as before.
Deployment (out of CI, in order)
ALTER TABLE 'binstats-v1' ADD COLUMN mode TEXT;devstatworker.0.1.2to npm.A companion change in the consuming CI threads
--modeand pins the client version.