Skip to content

fix(sandbox): refresh install fingerprint after boot fast-forward - #5410

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/orchestrator-stale-install-fingerprint-w1
Jul 30, 2026
Merged

fix(sandbox): refresh install fingerprint after boot fast-forward#5410
pedrofrxncx merged 1 commit into
mainfrom
fix/orchestrator-stale-install-fingerprint-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Bug found while reading packages/sandbox/daemon/setup/orchestrator.ts after the recent auto-fast-forward feature (#5390) and the no-install reporting fix (#5398).

Bug: stepClone() calls gitSetup(config) (which checks out the branch and calls refreshBranchHead() to snapshot currentBranchHead) and only afterward calls maybeFastForwardToBase(config.repoDir). stepInstall()'s install-skip cache (installState.isInstalledFor(config, this.currentBranchHead)) and its markInstallSucceeded call both key off that same currentBranchHead field. Since the field is captured before the fast-forward runs, it's fingerprinting against the pre-fast-forward commit even though the fast-forward may have just advanced the branch (and its lockfile) further.

Failure scenario: an idle sandbox on branch feat/x (no local commits) resumes on boot. feat/x is behind origin/main. The fast-forward advances feat/x to origin/main before install runs, and install correctly picks up the new lockfile from disk — but the success is recorded under the stale, pre-fast-forward commit SHA. On a later boot/resume cycle where feat/x lands back at that same pre-ff commit (e.g. base hasn't moved further yet), the install-skip cache matches that stale fingerprint and skips the install entirely, even though a fresh fast-forward in that same cycle may have just changed the lockfile again.

Fix: move the refreshBranchHead() call to run after maybeFastForwardToBase() in stepClone, so the fingerprint reflects the actual commit that was installed against (removed the now-redundant call inside gitSetup, its only caller).

Regression test: added SetupOrchestrator install fingerprint after boot fast-forward in orchestrator.test.ts — sets up a real local bare repo with main two commits ahead of feat/x, clones feat/x, drives the orchestrator through a branch-change transition, and asserts the branch-head value passed into installState.isInstalledFor equals the actual post-fast-forward git rev-parse HEAD. Verified the test fails (captures the pre-fast-forward SHA) on the pre-fix code and passes after the fix.

To verify: cd packages/sandbox/daemon && bun test setup/orchestrator.test.ts -t "post-fast-forward"

Checks run locally: bun run fmt, bunx tsc --noEmit in packages/sandbox (clean), and the single targeted test file above (14/15 pass; the one pre-existing failure — "reinstalls the pre-push hook after an install script clobbers it" — fails identically on main due to a missing corepack binary in this local sandbox, unrelated to this change). Full CI runs the rest of the suite.


Summary by cubic

Fixes a stale install fingerprint after boot-time fast-forward by re-reading HEAD after the fast-forward. This ensures the install cache keys off the post-FF commit and avoids skipping needed installs when the lockfile changes.

  • Bug Fixes
    • In stepClone(), run maybeFastForwardToBase() before refreshBranchHead(), and remove the redundant refresh in gitSetup(), so the fingerprint uses the post-fast-forward SHA.
    • Added a regression test that verifies installState.isInstalledFor receives the post-FF HEAD.

Written for commit e2dd153. Summary will update on new commits.

Review in cubic

stepClone captured currentBranchHead (via gitSetup's checkout) before
maybeFastForwardToBase ran, so the install-skip cache fingerprinted
against the pre-fast-forward commit. A later cycle landing back on that
same pre-ff commit would then match the stale fingerprint and skip a
needed install, even though the fast-forward had since moved the
lockfile forward.

Move the HEAD refresh to after the fast-forward so the fingerprint
reflects what was actually installed against.
@pedrofrxncx
pedrofrxncx merged commit 1304909 into main Jul 30, 2026
29 of 30 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/orchestrator-stale-install-fingerprint-w1 branch July 30, 2026 05:48
decocms Bot pushed a commit that referenced this pull request Jul 30, 2026
PR: #5410 fix(sandbox): refresh install fingerprint after boot fast-forward
Bump type: patch

- @decocms/sandbox (packages/sandbox/package.json): 1.28.2 -> 1.28.3
- deploy/helm/sandbox-env (chart 0.9.50) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.28.3

Deploy-Scope: both
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