From d0acb02e4baed14fed86ba8b2380f56232e81c5d Mon Sep 17 00:00:00 2001 From: yunyingk Date: Tue, 15 Sep 2026 16:21:01 +0800 Subject: [PATCH] Pin bun-version and gate dist/mcp/server.js freshness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The committed MCP bundle is the only thing that ships, but nothing checked that it matched src/. The gate could not be added while CI ran 'bun-version: latest': that resolved to 1.4.2, and the minifier allocates identifiers differently across Bun releases, so the runner rebuilt the macOS/1.3.14-built bundle into different bytes — identical code, renamed variables (N/S, A/I, q/p). Measured on #116. Pin bun-version to 1.3.14 in both workflows, matching the local toolchain and the @types/bun/bun-types already declared in package.json, then add the diff gate alongside the existing boot check. The boot check stays: a bundle that cannot start is invisible to a byte diff when it is in sync with its broken source, which is exactly how #114 shipped. --- .github/workflows/ci.yml | 11 ++++++----- .github/workflows/release.yml | 2 +- CHANGELOG.md | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 151b2c3..82e5a67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - name: Setup Bun uses: oven-sh/setup-bun@v2 with: - bun-version: latest + bun-version: 1.3.14 - name: Install dependencies run: bun install --frozen-lockfile @@ -48,16 +48,17 @@ jobs: - name: Build MCP Plugin & Verify run: | bun run build:plugin + git diff --exit-code dist/mcp/server.js || (echo "::error::dist/mcp/server.js is out of sync with src/. Run 'bun run build:plugin' and commit changes." && exit 1) # Boot the freshly built bundle and complete an MCP handshake. A bundle that cannot start # is invisible to source-level tests — this has regressed before, when circular imports # scrambled zod's initialisation order and shipped an entry point that never answered. # Re-running the server tests here points them at the artifact just built, not the # committed one. # - # Deliberately no byte-for-byte check that the committed bundle matches a fresh build: - # the minifier allocates identifiers differently across platforms and Bun versions, so it - # is not reproducible across runners. Measured on this PR: an ubuntu rebuild of the - # macOS-built committed file differed only by renamed minified variables (N/S, A/I, q/p). + # The diff gate above depends on bun-version being pinned: the minifier allocates + # identifiers differently across Bun releases, so an unpinned runner rebuilds to + # different bytes (measured: a bun 1.4.2 rebuild of a 1.3.14-built bundle differed only + # by renamed minified variables). Keep the pin in step with the committed bundle. bun test src/server.test.ts - name: Verify Binary Compilation diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index daa2efa..b9486aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: - name: Setup Bun uses: oven-sh/setup-bun@v2 with: - bun-version: latest + bun-version: 1.3.14 - name: Install dependencies run: bun install --frozen-lockfile diff --git a/CHANGELOG.md b/CHANGELOG.md index effddd8..f9bb439 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- **`dist/mcp/server.js` Freshness Gate, Enabled by Pinning Bun**: CI now fails when the committed MCP bundle does not match a fresh build from `src/`, mirroring the `dist/openapi.json` gate. This needed `bun-version` pinned to `1.3.14` in both workflows first — previously `latest`, which resolved to 1.4.2 on the runner, and the minifier allocates identifiers differently across Bun releases, so an unpinned rebuild never matched the committed bytes (measured: identical code, only renamed minified variables). The pin also makes release binaries reproducible and matches the `@types/bun`/`bun-types` already declared in `package.json`. - **CI Boots the Packaged MCP Bundle**: the MCP build step now starts the freshly built `dist/mcp/server.js` and completes a handshake, instead of only checking that it compiles. The artifact is the only thing that ships, so an unbootable bundle is now caught in CI rather than at runtime. Deliberately **not** a byte-for-byte freshness diff: the minifier allocates identifiers differently across platforms and Bun versions, so the bundle is not reproducible across runners — measured, an ubuntu rebuild of the macOS-built committed file differs only in renamed minified variables with identical code. ### Fixed