Skip to content

fix(update): scope bootstrap-cache refresh to the target ref + match installer pin rules (follow-up to #82229) - #82247

Merged
teknium1 merged 1 commit into
mainfrom
fix/bootstrap-cache-key-scoping
Aug 9, 2026
Merged

fix(update): scope bootstrap-cache refresh to the target ref + match installer pin rules (follow-up to #82229)#82247
teknium1 merged 1 commit into
mainfrom
fix/bootstrap-cache-key-scoping

Conversation

@teknium1

@teknium1 teknium1 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Implements both cache-key follow-ups from the review feedback on #82229:

1. Abbreviated commit pins are immutable too

install_script.rs::is_valid_commit() treats 7–40 hex chars as an immutable commit pin, but _refresh_bootstrap_cache_scripts() exempted only exactly-40-hex names — an abbreviated pin like install-4ce1994.ps1 could be overwritten with a branch script. The Python predicate now mirrors the Rust rule: the sanitized target ref matching [0-9a-fA-F]{7,40} is never rewritten.

2. Refresh only the update-target ref's cache key

The helper rewrote every mutable-ref entry with the active checkout's script: with install-main.ps1 and install-bb_gui.ps1 coexisting, updating main replaced both with main's script — cross-branch cache poisoning in the other direction. It now computes the single cache key for the branch being updated, using the installer's own ref sanitization (sanitize_ref: non-[A-Za-z0-9._-]_, so bb/guiinstall-bb_gui.ps1), and touches nothing else. Refs the bootstrapper never cached are not created.

The branch is threaded from the existing branch = _resolve_update_branch(args) at all three call sites (both _cmd_update_impl completion paths + _update_via_zip, which is main-only by its own guard).

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

How to Test

pytest tests/hermes_cli/test_update_bootstrap_cache_refresh.py -o "addopts=--timeout-method=thread"12 passed, including the two requested regressions:

  • test_abbreviated_commit_pin_left_alone — 7-hex pin untouched, even when passed as the branch
  • test_only_target_branch_key_is_refreshed — coexisting install-main.ps1 + install-bb_gui.ps1: main refresh heals main, leaves bb_gui byte-identical
  • plus test_branch_ref_is_sanitized_like_the_installer (bb/guiinstall-bb_gui.ps1) and test_uncached_branch_is_noop

E2E verification (real incident machine's bootstrap-cache)

Planted stale install-main.ps1 + sibling install-bb_gui.ps1 + abbreviated pin install-4ce1994.ps1 in the real %LOCALAPPDATA%\hermes\bootstrap-cache: refresh("main") healed main byte-exact (BOM intact) and left both others untouched; refresh("4ce1994") was a no-op. The pre-existing real 40-hex pin entry was untouched throughout.

Rollout note (from the same review)

Acknowledged and inherent: the first update that pulls this change still runs pre-change bytecode, so existing installs need one subsequent hermes update before the refresh executes — and this mitigates stale scripts only, not the staged hermes-setup.exe binary itself. Refreshing the staged binary is a separate follow-up if wanted.

…match installer pin rules

Two cache-key correctness follow-ups to #82229 (review feedback):

1. Abbreviated commit pins are immutable too. The installer's
   is_valid_commit() accepts 7-40 hex chars, but the Python refresh
   exempted only exactly-40-hex names — an abbreviated pin like
   install-4ce1994.ps1 could be overwritten with a branch script. The
   predicate now mirrors the Rust rule (7-40 hex = immutable, never
   rewritten), applied to the sanitized target ref.

2. Refresh only the update-target ref's cache key. The helper rewrote
   EVERY mutable-ref entry with the active checkout's script: with
   install-main.ps1 and install-bb_gui.ps1 coexisting, updating main
   replaced both with main's script — cross-branch cache poisoning in
   the other direction. It now computes the single cache key for the
   branch being updated, using the installer's own ref sanitization
   (sanitize_ref: non [A-Za-z0-9._-] -> '_', so bb/gui ->
   install-bb_gui.ps1), and touches nothing else. Entries the
   bootstrapper never wrote are not created.

The branch is threaded from the existing `branch =
_resolve_update_branch(args)` in both _cmd_update_impl call sites and
_update_via_zip (main-only by its own guard).

Regression tests lock down both invariants: abbreviated-SHA pin
untouched (including when passed as the branch), coexisting mutable
refs (main refresh leaves install-bb_gui.ps1 byte-identical),
sanitize_ref parity, and uncached-ref no-op.

E2E on the incident machine's real bootstrap-cache: planted a stale
install-main.ps1 + sibling install-bb_gui.ps1 + abbreviated pin
install-4ce1994.ps1; refresh("main") healed main byte-exact and left
both others untouched; refresh("4ce1994") was a no-op. The pre-existing
40-hex pin entry in the real cache was also untouched.
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 57a0bb1

⚠️ Warnings

OSV vulnerability scan · View job

21 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 3m23s vs 7m2s (-51.9%). 14 job(s) slower, 7 faster, 2 unchanged.

  • Python tests / Run tests slice 8/12: +24.0s
  • Python tests / Run tests slice 9/12: -19.0s
  • Python tests / Run tests slice 2/12: +15.0s
  • Python tests / Run tests slice 6/12: -13.0s
  • Python tests / Run tests slice 1/12: -13.0s

@teknium1
teknium1 merged commit 3a915c4 into main Aug 9, 2026
43 checks passed
@teknium1
teknium1 deleted the fix/bootstrap-cache-key-scoping branch August 9, 2026 04:18
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.

1 participant