Skip to content

ci: gate releases on executed candidate artifacts - #99

Merged
ElbertePlinio merged 6 commits into
mainfrom
ci/candidate-artifact-smokes
Sep 5, 2026
Merged

ElbertePlinio merged 6 commits into
mainfrom
ci/candidate-artifact-smokes

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

Closes #97
Refs #89

What was wrong

release.yml built the Rust assets and then published npm straight from the source tree. Nothing that shipped had ever been installed or executed: the alpha.1 macOS arm64 asset was never run, and the "clean Linux smoke" was a local substitute, not a gate. strip also invalidates the ad-hoc signature Apple silicon requires, so a stripped arm64 asset can fail to execute at all — exactly the class of defect the old ordering could not catch.

What this does

One smoke script, two real environments. scripts/candidate-smoke.sh installs only candidate artifacts — the packed npm tarball and the built Rust asset, through the public scripts/install.sh — into an isolated HOME/PICKFORGE_HOME, then asserts:

  • all three command versions (pickforge --version, pickforge-lab --version, and pickforge-mcp through a real MCP initialize, since it has no --version flag)
  • exact asset name and SHA-256 of the candidate asset
  • Flutter project detection and doctor (a clean image has no agent harness; that one gap is tolerated, every other check must pass, and doctor must exit non-zero rather than claim readiness)
  • init --dry-run writes nothing (home and state snapshots compared byte for byte)
  • init applies the Flutter integration, and a second init changes nothing and rewrites no file
  • a real Dart MCP handshake through the configuration init generated (initialize, notifications/initialized, tools/list)
  • evidence record lands under PICKFORGE_HOME, never in the project, with a planted token redacted and the artifact hash matching its copy
  • the project tree is byte-identical to what flutter create produced, with no Pickforge state
  • the caller's real home has no Pickforge or harness writes

Linux gate: the script runs inside ghcr.io/cirruslabs/flutter:stable against the candidate tarball and pickforge-linux-x86_64.

macOS gate: macos-14, asserts uname -m = arm64, verifies the exact asset's checksum, enforces the signing policy, executes the binary, and runs the same workflow with isolated homes. The Rust CLI only — the TypeScript lab stays Linux-only and is not installed there.

Ordering and permissions. publish needs both smokes plus the lab and Rust gates, and publishes the same tarball the smokes installed. The workflow default is contents: read; only publish gets contents: write and id-token: write, and it only runs when resolve says so: a tag push matching the package version, or a dispatch whose confirm is exactly v<version> on main. A dry run therefore has no token to publish with, not just a skipped step.

macOS signing, honestly. The asset is re-signed ad-hoc after strip, and scripts/smoke/macos-asset-policy.sh fails the gate if reality drifts from docs/releases/SIGNING.md in either direction: arm64-only, ad-hoc signature that verifies, not notarized. docs/releases/SIGNING.md records the decision (ship unsigned for the 0.4 train; integrity from checksums and npm provenance) and INSTALL.md documents the browser-download Gatekeeper workaround.

Docs. docs/releases/CHECKLIST.md is now version-parametric (export VERSION=...) and reusable, with the one-time npm/trusted-publisher steps moved to a recovery appendix. scripts/check-release-versions.mjs is the single version-consistency gate shared by the workflow and the checklist. docs/releases/UNRELEASED.md no longer carries drafting instructions or a "updated during release preparation" placeholder; it is publishable text passed to gh release create --notes-file, and docs/releases/TEMPLATE.md plus checklist step 11 close the lifecycle.

Evidence

The Linux smoke was run end to end locally against real candidate artifacts (npm pack of packages/cli plus a stripped cargo build --release asset) in the clean Flutter container. It passed: three versions verified, doctor reporting only the harness gap, init idempotent, a real dart mcp-server handshake returning 13 tools, evidence recorded under the isolated state root, project tree unchanged, real home untouched. A negative control with a tampered .sha256 fails at asset verification, as it should. Full logs: ~/Projects/Boards/pickforge/0.4-release/candidate-smokes/.

Local gates: bun run typecheck, bun run lint, bun run test (1229 passed, 4 skipped), bun run build, cargo fmt --check, cargo clippy -- -D warnings, cargo test --workspace --locked, PICKFORGE_LIVE_FLUTTER=1 cargo test --test live_flutter, complexity-gate check --changed (no FAIL; the two shell scripts are UNVERIFIED — no grammar for .sh), shellcheck and actionlint clean.

Not done here

  • The macOS job has not run yet; there is no Apple silicon machine here. candidate-smokes-pr.yml runs the whole candidate pipeline on this PR, so CI exercises it before merge.
  • No workflow_dispatch dry run was triggered: a dispatch runs release.yml from main, which is still the old workflow that carries contents: write and id-token: write on its only job. That would prove nothing about this change while granting publish permissions. After merge, the owner can dry-run it with checklist step 7 (gh workflow run release.yml --ref main -f confirm=).
  • npm publish <tarball> --provenance is the one step no gate can exercise before a real publish. The workflow comments say what to do if npm ever rejects it: fix the workflow, never fall back to publishing a rebuilt, unsmoked tree.

The release workflow built Rust assets and then published npm from the
source tree: nothing that shipped had ever been installed or run. The
macOS arm64 asset was never executed at all, and `strip` invalidates the
ad-hoc signature Apple silicon requires, so it may not have run.

Publishing now depends on two smokes over the exact candidate artifacts.
`scripts/candidate-smoke.sh` installs only the packed npm tarball and the
built Rust asset into an isolated home and checks all three command
versions, Flutter detection, `doctor`, `init` dry-run isolation, `init`
idempotency, a real Dart MCP handshake, evidence recording, an unchanged
project tree, and an untouched real home. It runs in a clean Flutter
container and on an Apple silicon runner, and both upload bounded logs
and evidence.

The publish job publishes the same tarball the smokes installed, and it
is the only job holding write or OIDC permissions: a dispatch without the
exact release tag in `confirm` has nothing to publish with.

Also: re-sign the macOS asset after `strip`, document and enforce the
signing/notarization policy, make the checklist version-parametric, and
keep UNRELEASED.md publishable rather than a drafting scratchpad.

Closes #97
Refs #89
@ElbertePlinio

Copy link
Copy Markdown
Member Author

CI evidence, run 33930949301: both gates green, including a real Apple silicon run.

macOS (macos-14, Darwin arm64, Flutter 3.47.2, Dart 3.13.2):

architectures: arm64        signature: ad-hoc (verified)     spctl: rejected
file: Mach-O 64-bit executable arm64
asset sha256: 93b3b0ee55772a8add554ff6848ca844d2c74cc6f5c86d783706110d09af2325
pickforge: pickforge 0.4.0-alpha.1        (the downloaded asset, executed)
MCP "dart and flutter tooling" 1.1.1 answered with 14 tools
checks: versions, flutter detection, doctor, init dry-run isolation, init apply,
Dart MCP handshake, init idempotency, evidence recording, clean project tree,
clean real home

Linux container: same script and checks, plus the candidate npm tarball install and all three command versions. CI is green too (gitleaks, dependency-audit, rust ubuntu/windows, test).

The first CI run caught a real bug in the gate: on macOS mktemp -d returns /var/... for /private/var/..., so the "inside the isolated home" assertions compared two spellings of the same path and the macOS smoke failed. Fixed in 380e94d by canonicalizing the smoke work directory; it passes on the runner now. Everything before that point had already passed on macOS, including the re-signed asset verifying and executing — which is the defect this PR exists to catch.

Evidence artifacts: candidate-smoke-linux, candidate-smoke-macos. Local copies under ~/Projects/Boards/pickforge/0.4-release/candidate-smokes/.

@ElbertePlinio

Copy link
Copy Markdown
Member Author

Heads-up on the red test check in the latest CI run (33930949179): it is the desktop integration lifecycle assertion, not this PR.

FAIL packages/desktop-linux/test/integration.test.ts > desktop integration (Xvfb + xdotool)
  > runs an xvfb session and screenshots the display
AssertionError: expected true to be false
  packages/desktop-linux/test/integration.test.ts:590:47
  expect(readProcessStartTicks(session.xvfbPid)).toBeUndefined();

The same test passed on the previous run of this branch (33930675933), and the only commit since then (380e94d) touches scripts/candidate-smoke.sh, which that suite never loads. It also passes locally (1229 passed, 4 skipped). This is the Xvfb teardown/reaping flake tracked by the CI reliability item in #89.

I have not re-run it, to avoid masking. Deciding whether to re-run or to fix the flake first is the owner's call.

Review findings on #99. Each one is a way the gate could pass, hang, or
publish something other than what was smoked.

- The MCP handshake now rejects on its own timeout, on spawn failure, and
  on child exit, and terminates and reaps the server it spawned. It
  previously only SIGKILLed the child and waited forever on a Promise that
  nothing could reject, so a hung server held a confirmed publish until
  GitHub's job timeout. Pinned by test/release/mcp-handshake-timeout.test.ts
  against real servers that never answer, answer once, or die.
- The checklist selects the release run by event, branch, and head SHA
  instead of `--limit 1`, which could watch step 7's dry run after a tag
  push, exit green immediately, and send step 9 at a draft that did not
  exist. It also reads each smoke summary from its own artifact
  subdirectory, where `gh run download` actually puts it.
- Sourcemaps are uploaded from inside the verified tarball, unmodified.
  Injecting debug IDs into a copy of `dist` after the smokes had installed
  the packed tarball meant Sentry held maps for bytes npm never received.
- The publish job refuses a GitHub release that is no longer a draft, so a
  re-run or second dispatch cannot replace public assets. The checklist
  already forbade this; the job now enforces it.
- The version must be semver and a tag must be `v<semver>` before either
  reaches a tarball name, a container environment, or a workflow output.
- The PR smoke runs for every input that can change the packed bytes: the
  CLI bundles all workspace packages, so `bun.lock`, the root manifest, the
  TypeScript build config, and `packages/**` all belong in the filter.
- The Linux gate's container is pinned by image digest and its Node.js by
  version and checksum, instead of a floating tag plus a remote setup
  script piped into a root shell.
- Both gates checksum every artifact before using it. The npm tarball is
  verified where it is installed and re-verified afterwards, not only in
  publish, long after the smokes have run.

Permissions and candidate identity are unchanged: the workflow default
stays `contents: read`, only publish holds write and OIDC, and the tarball
that is packed once is the one smoked and published. Dropping the unused
`candidate/dist` copy removes the last second copy of those bytes.
Pinning the image by digest was right; fetching a Node.js into it was not.
The bootstrap (apt update, apt install, a nodejs.org download) took 22 of
the gate's 24 minutes on the runner, and the PR filter now sends far more
pull requests through it.

None of it was necessary. The pinned image already ships curl, tar, xz and
CA certificates, and the runner is the same Ubuntu 24.04 (glibc 2.39) as
the image, so its Node is mounted read-only at /opt/node and the container
installs and downloads nothing at all. The smoke refuses to run if that
mount is not the expected Node major.

The checklist keeps downloading a pinned, checksummed Node for its local
run, because a maintainer's machine is not the runner. That difference,
and how to refresh the pin, are now written down next to the command.

Locally, against the pinned image: the full smoke runs in 13s, and a Node
20 mount is rejected.
@ElbertePlinio

Copy link
Copy Markdown
Member Author

Review findings from review-pr99.md are all fixed, in 63eb787 (the eight findings) and eebbc51 (a bootstrap regression the first commit introduced and CI caught). Base is 0d7e03d, a merge of current origin/main 4da0a33 (#92).

  • MCP handshake timeout now rejects on its own budget, on spawn failure, on a broken stdin pipe, and on child exit, and terminates then reaps the server. Pinned by test/release/mcp-handshake-timeout.test.ts against real servers that never answer, answer once then hang, or die. The pre-fix script was still hanging when timeout 25 killed it.
  • Checklist selects the release run by event, branch and head SHA (step 7 by HEAD_SHA, step 8 by TAG_SHA with a poll and an operator confirmation line) instead of --limit 1, and reads each smoke summary from its own artifact subdirectory.
  • Sentry no longer injects. The publish job extracts the checksum-verified tarball and uploads package/dist from it, unmodified — the maps that ship in the artifact npm receives. telemetry.ts already reports the same release, so they resolve without a debug ID. The unused candidate/dist copy is dropped.
  • Clobber: publish fails if gh release view --json isDraft is not true, before any upload.
  • Charset: the version must be semver and a tag must be v<semver> before either reaches a tarball name, container env or workflow output.
  • PR filter now covers packages/**, bun.lock, the root manifest and both tsconfigs — tsup bundles every workspace package into the packed bytes.
  • Container pinned by image digest in the workflow and the checklist. The nodesource pipe is gone; the image already ships curl/tar/xz/CA certs and the runner's Node is mounted read-only, so the container installs and downloads nothing.
  • Tarball checksum verified in the smoke where it is installed, and re-verified after, not only in publish.

Least privilege and candidate identity are unchanged: default contents: read, write and OIDC only on publish, one npm pack smoked and published, now with a checksum on both sides.

Verification: actionlint and shellcheck clean; typecheck, lint (complexity 15 / depth 4 / 100-line), 105 test files / 1318 tests, build, cargo fmt/clippy/test all pass; full local container smoke against the pinned image in 13s; 11 negative controls including tampered and missing checksums, a hung MCP server, and a wrong Node major. Details: review-pr99-fixes.md.

All 10 checks pass on eebbc51 first attempt, including the previously red required test. The Linux smoke is 1m30s (it was 24m10s on 63eb787 before the bootstrap fix).

#103 is still a dependency: test is green here, but #102's flake is fixed by #103, not by this PR.

@ElbertePlinio
ElbertePlinio merged commit fc170ea into main Sep 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gate releases on clean Linux and macOS candidate artifact smokes

1 participant