Repository navigation
Make deploy.sh safe against rewriting itself during git pull - #101
Merged
Merged
Conversation
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.
Why
On 2026-09-25 the vex-agent API crash-looped in prod for about 8.5 hours. vex-agent-integration #87 added a
git submodule updatestep toscripts/deploy.sh, but the deploy that shipped #87 was already running the old copy of the script. Bash reads a script as it executes, so whengit pullrewrote the file mid-run, bash went on reading the new file at the old byte offset and skipped the inserted block. The image was built from the stale engine checkout and failed onImportError: RunDistanceStream. The stale submodule also left the tree dirty, so every later deploy would have aborted at the uncommitted-changes check.Both repos share this deploy script shape, so the same thing can happen to any commit that edits
scripts/deploy.sh.What
mainfunction, called on the last line (main "$@"; exit). Bash parses a function completely before running it, so a mid-run rewrite of the file can't change what executes.git pull, if the pull changedscripts/deploy.sh, the scriptexecs the new version. A new deploy step then ships on its first deploy, not the next one. The rerun pulls nothing, so it can't loop.The body keeps its original indentation to keep the diff reviewable.
Verified
A local harness builds a throwaway origin plus a deploy checkout, pushes a commit that inserts a step before "Building" (the shape of #87), and runs the checkout's
scripts/deploy.shwithdockerandcurlstubbed:deploy.sh(lm-dashboard and vex-agent-integration)The transition was also simulated with the exact bytes: the current script running while the pull brings in this version. Both repos finish the deploy normally, so this PR is safe to ship through the webhook.
🤖 Generated with Claude Code