chore(husky): add pre-commit guard for pinned @biomejs/biome version#1404
Conversation
The sister recce-cloud-infra repo has now been bitten twice (PRs #1333, #1376, #1382) by Dependabot consolidations silently re-bumping a deliberate @biomejs/biome pin past a known Mac arm64 stack-overflow bug in 2.4.12 through 2.4.15. The js/biome.json in this repo does not currently enable the affected nursery rules (noFloatingPromises, noMisusedPromises, noUnnecessaryConditions), so the bug has not bitten here yet, but the same consolidation pattern applies, and silent bumps are easy to miss in lockfile-heavy PRs. Add a pre-commit guard that reads the staged content of js/package.json, checks the @biomejs/biome version against an EXPECTED_BIOME constant (currently 2.4.15, the version this repo runs on today), and blocks the commit on a mismatch with a clear remediation message. Override with ALLOW_BIOME_BUMP=1 after verifying biome runs cleanly on macOS arm64 with the nursery rules enabled. No biome version change here, only the guard. When biome is deliberately bumped, update EXPECTED_BIOME in this hook in the same commit. Signed-off-by: Jared Scott <jared.scott@datarecce.io>
3a80a1a to
e0a000c
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a Husky pre-commit safeguard in the js/ workspace to prevent silent Dependabot-driven bumps of the deliberately pinned @biomejs/biome version, reducing the risk of reintroducing the known macOS arm64 stack overflow regression.
Changes:
- Add a pre-commit guard that inspects the staged
js/package.jsonand blocks commits when@biomejs/biomediffers from the expected pinned version (unless explicitly overridden). - Provide a documented override mechanism (
ALLOW_BIOME_BUMP=1) to allow intentional bumps after verification.
Code Review: PR #1404SHA Issues
Notes
Verification performed
|
even-wei
left a comment
There was a problem hiding this comment.
Code Review: PR #1404
SHA e0a000c80 · Verdict NO-GO
Issues
js/.husky/pre-commit:13,52— Hook referencesPR #1376as the sister-repo dependabot-consolidation incident, but PR #1376 in recce-cloud-infra is "docs: add Even Wei contributor stats and shared skills to ONBOARDING.md" — unrelated. The actual consolidation re-bump isrecce-cloud-infra#1374(correctly cited in this PR's body table).
Evidence:gh pr view 1376 --repo DataRecce/recce-cloud-infrareturns the ONBOARDING.md docs PR; the PR body table here listsDataRecce/recce-cloud-infra#1374 — consolidation re-bumped to 2.4.15. Line 13 (PR #1333, PR #1376) and line 52 (PRs #1333 and #1376) both need#1374.
Pass F.
Notes
-
js/.husky/pre-commit:35-37— Extractiongrep | sedreturns multi-line output if@biomejs/biomeappears twice (e.g., a futurepnpm.overridesentry). The subsequent equality check would then block with a confusing error. Not exploitable today (only one occurrence), but ahead -1would harden against future structure changes.
Evidence:printf '"@biomejs/biome": "2.4.15",\n"@biomejs/biome": "9.9.9",\n' | grep -E '"@biomejs/biome":' | sed -E 's/.*"([^"]+)".*/\1/'emits two lines.
Pass F. -
js/.husky/pre-commit:18— Uses--diff-filter=ACMRwhile the existing JS lint detector on line 69 uses--diff-filter=ACM. Renames ofjs/package.jsonare vanishingly unlikely; flag for consistency only.
Pass F.
Verification performed
- Confirmed
js/package.jsonpins@biomejs/biome: 2.4.15(matchesEXPECTED_BIOME). - Confirmed
js/biome.jsondoes NOT enablenoFloatingPromises,noMisusedPromises, ornoUnnecessaryConditions(only one biome config exists in the repo; no nursery section). Pin-without-bump rationale is sound. - Manually staged a fake
2.4.99version and ran the hook: blocks with exit 1 and the documented error message. WithALLOW_BIOME_BUMP=1set: passes. With nopackage.jsonchange: silent, existingpnpm lint:stagedpath runs. bash -nsyntax check: clean.shellcheckon the file emits only pre-existing findings on lines 84/88/90/92; the new guard block (lines 10–66) is shellcheck-clean.- Confirmed
set -edoes NOT abort on a no-match grep inside$(...)(bash behavior; pipefail not set). The[ -n "$STAGED_BIOME" ]guard correctly handles the no-match path.
…me extraction - Correct sister-repo PR references: #1376 → #1374 on lines 13 and 66. (#1376 is an unrelated docs PR; #1374 is the actual Dependabot consolidation re-bump.) Spotted by Copilot and @even-wei. - Harden the staged-version extraction (Copilot, @even-wei Note 1): add `head -1` so a future second `"@biomejs/biome":` occurrence (e.g., a pnpm.overrides entry) doesn't yield multi-line output, and fail-loud when extraction is empty so a package.json reformat or intentional dep removal can no longer silently disable the guard. `ALLOW_BIOME_BUMP=1` still overrides both the mismatch and the empty-extraction paths. - Align `--diff-filter=ACM` with the existing JS lint detector below for consistency (@even-wei Note 2). Verified locally via index-blob swap on macOS arm64: 1. 2.4.99 staged, no override → exit 1, updated error cites #1374 2. 2.4.99 staged + ALLOW_BIOME_BUMP=1 → exit 0 3. 2.4.15 staged (current) → exit 0 4. @biomejs/biome key removed → exit 1, "Could not extract" message 5. @biomejs/biome key removed + ALLOW_BIOME_BUMP=1 → exit 0 `bash -n` clean; `shellcheck -S warning` silent on the guard block. Signed-off-by: Jared Scott <jared.scott@reccehq.com> Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Jared Scott <jared.scott@datarecce.io>
|
@even-wei All three findings addressed in 967b1e0. Summary table:
Verification on macOS arm64 (synthetic blob staged via
Inline replies posted to each of Copilot's three comments. Ready for re-review. |
Code Review: PR #1404SHA Defensive single-file change to BlockersNone. IssuesNone. Notes
What was verified
Out-of-scope observationsThe new block uses 4-space indentation while the surrounding shell uses tabs. Minor, not worth changing. |
Summary
The sister
recce-cloud-infrarepo has been bitten twice by Dependabot consolidations silently re-bumping a deliberate@biomejs/biomepin past a known macOS arm64 stack-overflow bug:Biome 2.4.12 through 2.4.15 hit a deterministic Rust stack overflow on macOS arm64 when running the TS-aware nursery rules (
noFloatingPromises,noMisusedPromises,noUnnecessaryConditions).Upstream status
Important: 2.4.16 was tested on the sister recce-cloud-infra repo and still crashes — the upstream fix is partial. Details in DataRecce/recce-cloud-infra#1382.
The
js/biome.jsonin this repo does not currently enable those rules, so we haven't been bitten here yet — but the same consolidation pattern applies, and silent bumps are easy to miss in lockfile-heavy PRs.Changes
js/.husky/pre-commit— new pinned-dep guard, no functional change otherwise.The guard
When
js/package.jsonis part of the staged commit, the hook reads its staged content viagit show :js/package.json, extracts the@biomejs/biomeversion, and compares againstEXPECTED_BIOME=2.4.15. On mismatch it blocks the commit with a clear error pointing at the upstream issue, the infra-repo PRs, and the 2.4.16 testing finding, plus a 3-step Mac arm64 verification recipe.Override for intentional bumps:
Then update
EXPECTED_BIOMEin the hook to the new pinned version in the same commit.Test plan
ALLOW_BIOME_BUMP=1— hook passes, exit 0pnpm lint:stagedflow runs normally