Repository navigation
fix(sandbox): reinstall pre-push branch-protection hook after install - #4440
Merged
Merged
Conversation
installProtectedBranchHook() runs once during gitSetup(), before stepInstall() runs the repo's own install command (npm/bun/yarn/pnpm install). A postinstall/prepare script in the target repo (lefthook, husky, etc.) can rewrite .git/hooks/pre-push during that install, silently dropping the hook that blocks pushing to main/master from a sandbox — with no re-check afterward. Reinstall the hook right after a real install succeeds, so branch protection survives whatever the repo's own install scripts did to .git/hooks.
decocms Bot
pushed a commit
that referenced
this pull request
Jul 10, 2026
PR: #4440 fix(sandbox): reinstall pre-push branch-protection hook after install Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.13.0 -> 1.13.1 Deploy-Scope: both
pedrofrxncx
added a commit
that referenced
this pull request
Jul 11, 2026
mkdirSync/writeFileSync/chmodSync block the daemon's single event loop (CONTRIBUTING.md rule #4) — a single missed health probe flips a healthy sandbox to crashed and tears the pod down mid-session. #4440 just added a second call site for this function (after every real install), doubling the exposure. Switch to node:fs/promises and await both call sites.
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.
Source
A bug found while reading recently-changed sandbox daemon code (
packages/sandbox/daemon/git/protect-branch.ts,packages/sandbox/daemon/setup/orchestrator.ts).Why a maintainer wants this
installProtectedBranchHook()writes apre-pushhook that blocks pushing tomain/masterfrom a sandbox — the guard that stops an agent (or a buggy publish flow) from pushing straight to the protected branch. It only runs once, duringgitSetup(), beforestepInstall()runs the target repo's own install command (npm install/bun install/ etc.).Failure scenario
Any target repo whose
package.jsonhas apostinstall/preparescript that (re)installs its own git hooks —lefthook install,husky install,husky,pre-commit install, etc., all common in the JS ecosystem — will overwrite.git/hooks/pre-pushduring that install step, silently removing Studio's branch-protection hook with no re-check afterward. From that point on, a push tomain/masterfrom the sandbox succeeds instead of being rejected.Verified locally: a
package.jsonwith apostinstallscript that rewrites.git/hooks/pre-pushoverwrites it during a real (offline, dependency-free)bun installin well under a second.Fix
Reinstall the hook right after a real install completes successfully in
stepInstall(), so branch protection survives whatever the repo's own install scripts did to.git/hooks.Regression test
packages/sandbox/daemon/setup/orchestrator.test.ts— "reinstalls the pre-push hook after an install script clobbers it". Installs the hook, drives a realpm-change→ install step against a fixture repo whosepostinstalloverwrites the hook, and asserts the hook is restored afterward. Confirmed this test fails on the pre-fix code (hook stays clobbered) and passes after the fix.Verify
Checks run locally
bun run fmtbunx tsc --noEmitinpackages/sandboxbun test packages/sandbox/daemon/setup/orchestrator.test.ts(12/12 pass)Full CI will run the broader suite.
Summary by cubic
Reinstalls the
pre-pushbranch-protection hook right after a successful install so postinstall tools don’t clobber it. Keeps sandbox pushes tomain/masterblocked as intended.SetupOrchestrator.stepInstall()after real installs complete.Written for commit 73befdd. Summary will update on new commits.