Repository navigation
fix(release): stop SIGPIPE failing the checks that just succeeded - #43
Merged
Merged
Conversation
v0.5.0-rc.4 built, signed, notarized, stapled and uploaded all four assets correctly, and the collect job still failed — at `echo "$ENTRIES" | head -5`, before any assertion ran. This job runs under `bash -eo pipefail`. Every reader in these pipelines exits before consuming its input: `head` after five lines, `grep -q` at the first match. The writer then takes SIGPIPE, and pipefail promotes that 141 to the status of the whole pipeline, so a check that SUCCEEDED reports failure. An Electron bundle lists thousands of entries, far past the 64K pipe buffer, so the write cannot complete first — reproduced at exit=141 with a 6006-entry listing, and at exit=0 after this change. Herestrings instead: a file, not a pipe, so there is no second exit status to inherit. The same hazard is documented at build.sh's sidecar-provenance check; this file reintroduced it. The asset-wait loop gets the same treatment for a worse reason. There a SIGPIPE would not fail the step: it would take the `||` branch and record an asset that IS attached as missing, then wait the full hour. Untouched: four pipelines whose input is a handful of short lines that fit in the pipe buffer in one write.
stuffbucket
added a commit
that referenced
this pull request
Sep 4, 2026
Closes #42. ## Summary Release verification logic moves out of `release.yml` into `scripts/release/`, and a fixture-driven self-test runs it in the normal PR gate. The goal is to make release shell testable before a tag is cut rather than only during a release. ## Background `release.yml` contained 522 lines of shell that executed for the first time during a real release. A single iteration costs a tag, a 20-40 minute signed build, Apple's notarization queue, and a manual approval. Two defects were found this way: - **v0.5.0-rc.3**: the builder produced and checksummed the zip but never uploaded it, because the workflow's upload allow-list omitted it. - **v0.5.0-rc.4**: all four assets were built, signed, notarized, stapled, and uploaded correctly, but the run failed on a debug line, `echo "$ENTRIES" | head -5`. `actionlint` and `shellcheck` both ran against this code and reported nothing. Neither defect is detectable by static analysis; both are detectable by execution. ## Changes ### New scripts | Script | Responsibility | |---|---| | `contract.sh` | Parse `.macos-builder/config`, cross-check `forge.config.ts`, expand `{tag}` and `{version}` | | `verify-assets.sh` | Checksums, size floor, UDIF `koly` trailer, PKZip magic, `Info.plist`, stapled-ticket marker | | `prev-tag.sh` | Resolve the previously released tag | | `selftest.sh` | Drive the above against fixtures, asserting both success and failure paths | `release.yml` retains only orchestration: the job graph, `gh` calls, output wiring, and the asset wait loop. It drops from 522 to roughly 430 lines. ### CI `selftest.sh` and `shellcheck` run in the `check` job, before the install step. They are placed inside that job rather than in a separate one because `build / typecheck / lint / test` is the only check required by main's ruleset; a separate job would run without gating merges. `shellcheck` coverage now includes `scripts/verify-dmg.sh`, which was 485 lines that no linter or test had previously exercised. It required no changes. ### Contract resolution The contract is now read from the tag via `git show`, while the scripts and workflow come from the checkout: | Source | Read from | Rationale | |---|---|---| | `release.yml`, `scripts/release/` | The dispatched branch | A fix to release machinery can reach an already-cut tag | | `.macos-builder/config`, `forge.config.ts` | The tag | The released contract is always the tag's own | On a tag push these are the same commit. On `workflow_dispatch` the checkout is a branch, and this split prevents building the tag's commit against `main`'s contract. This is the code-side prerequisite for #42; see Follow-ups. ### Previous-tag selection The prior implementation was: ```sh git tag --list 'v*' --sort=-creatordate | grep -vxF "$TAG" | head -1 ``` This returns the newest tag that is not `$TAG`, which is a *newer* tag whenever an older tag is re-released. Against the current tag list, re-releasing `v0.5.0-rc.3` would compare its bundle identity against `v0.5.0-rc.5`. The replacement takes the entry following `$TAG` in a newest-first listing, which is the previous release by construction. Covered by four test cases. ## Verification **Self-test**: 27 assertions, 0 failures, approximately 2 seconds. Identical results on macOS (bash 3.2) and on the Ubuntu runner. **Regression detection.** Reintroducing either failed form causes the suite to fail: | Reintroduced | Result | |---|---| | `echo "$ENTRIES" \| head -5` | Exit 141, matching the rc.4 failure | | `printf … \| grep -qxF …` | Reports a stapled app as unstapled | The second case is the more dangerous of the two: it does not crash, it inverts the verdict of the check that guards offline launch. **Real artifacts.** `verify-assets.sh` was run against the released `v0.5.0-rc.4` dmg and zip (320 MB): the computed sha256 matches what the release run reported, the UDIF trailer validates, and the zip's `Maximal.app` is confirmed stapled. Exit 0 in 0.83s, including the rewritten trailer read (`dd` at an offset, replacing `tail -c 512 | head -c 4`), which costs 0.13s of CPU on a 171 MB image. `shellcheck` and `actionlint` are clean. ## Correction to the rc.4 diagnosis The commit message for #43 stated that the zip listing was "thousands of entries, far past the 64K pipe buffer, so the write cannot complete." This was incorrect. The actual listing is 604 entries, 55,827 bytes, which is below a pipe's 64 KB capacity. The failure is a race rather than a size threshold: `head` closes the read end after five lines, and whether the writer has finished by then depends on scheduling. The Ubuntu runner lost the race; the same pipeline over the same artifact exits 0 on macOS. This makes the original defect intermittent and platform-dependent. The zip fixture is therefore sized at 6,009 entries (353,196 bytes), roughly six times the real listing, so that a reintroduced pipeline fails deterministically on any machine. `selftest.sh` asserts the fixture remains large enough, and fails if it does not. ## Follow-ups This PR completes only the code half of #42. Dispatch-based recovery additionally requires a branch to be added to the `release` environment's deployment policy, which is a repository setting and not changed here.
This was referenced Sep 6, 2026
stuffbucket
added a commit
that referenced
this pull request
Sep 8, 2026
## Summary - update the transitive `fast-uri` lockfile resolution from 3.1.5 to 3.1.6 - remediate Dependabot alerts #38, #39, #42, and #43 - retain `[email protected]`; its existing dependency range accepts the patched release ## Security GitHub reports four high-severity advisories affecting 3.1.5, covering malformed IPv6 normalization, percent-encoded scheme normalization, repeated hostname percent-decoding, and skipped IDN canonicalization. All identify 3.1.6 as the first patched version. ## Validation - `pnpm why fast-uri -r` resolves only `[email protected]` - `pnpm audit --audit-level high` reports no high-severity findings (three unrelated moderate findings remain) - `pnpm test` passes: 15/15 Turbo tasks
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.
v0.5.0-rc.4produced a complete and correct release and the run still went red.What actually failed
Not an assertion — the debug print above them:
The job runs under
bash -eo pipefail.headexits after five lines,echotakes SIGPIPE, andpipefailpromotes that 141 to the pipeline's status. The log shows exactly five entries printed and then the error — the tell.The two
printf … | grep -qxFassertions below it are the same bug and would have fired next:grep -qexits at the first match, so the closer a match is to the top of the listing, the more certainly the check fails. An Electron bundle lists thousands of entries, far past the 64K pipe buffer, so the writer can never finish first.The zip was fine.
Maximal.app/Contents/CodeResources— the stapled ticket — is right there in the listing the failing step printed.Reproduction
6006-entry listing (396 KB), under
bash -eo pipefail:echo "$ENTRIES" | head -5printf '%s\n' "$ENTRIES" | grep -qxF <early match>head -5 <<< "$ENTRIES"grep -qxF <early match> <<< "$ENTRIES"grep -qxF <absent> <<< "$ENTRIES"The fix
Herestrings. A herestring is a file, not a pipe, so there is no second exit status for
pipefailto inherit, and the reader may exit whenever it likes.The asset-wait loop gets the same treatment for a worse reason. There a SIGPIPE would not fail the step — it would take the
||branch and record an asset that is attached as missing, then wait the full hour for it to appear.Four pipelines are deliberately left alone: their input is a handful of short lines that fits in the pipe buffer in a single
write().Prior art
.macos-builder/build.shalready documents this exact hazard at its sidecar-provenance check, and uses process substitution to avoid it. This file reintroduced the pattern.Related: #42 — because this fix lives in
release.yml, it cannot apply to the already-cutv0.5.0-rc.4.