Repository navigation
fix(sandbox): serialize git/discard on the same claim lock as publish/rebase - #5118
Merged
Merged
Conversation
pedrofrxncx
enabled auto-merge (squash)
July 23, 2026 19:17
decocms Bot
pushed a commit
that referenced
this pull request
Jul 23, 2026
PR: #5118 fix(sandbox): serialize git/discard on the same claim lock as publish/rebase Bump type: patch - decocms (apps/mesh/package.json): 4.109.5 -> 4.109.6 Deploy-Scope: server
pedrofrxncx
pushed a commit
that referenced
this pull request
Jul 27, 2026
#5240) Reverts #5112 (share agent sandboxes by branch), #5116 (always share agent sandboxes) and #5132 (use shared staging branch), restoring the pre-#5112 behaviour: hosted agent sandboxes are per-user again, and a new GitHub-backed thread gets a generated branch instead of `staging`. Reconstructed against current paths rather than reverted: #5120 split apps/mesh into apps/api + apps/web and hoisted branch-name.ts, runtime-defaults.ts and thread/schema.ts into packages/shared, and #5174 deleted vm-events.ts outright, so none of the three commits reverse-apply. Core change: SandboxId goes back to a flat `{ userId, projectRef }` and sandboxIdKey back to `userId:projectRef`, so every hosted claim handle changes. Live shared claims must be drained BEFORE this deploys. Also reverted, because they only exist inside the shared model: - #5225 withoutLegacyAgentSandboxEntries — left in place it would strip the sandboxMap entries the reverted server writes back, leaving shouldAutoStart permanently true (silent, compiles fine) - #5219 resolveSharedThreadVm and the shared-scope branch - #5183 stale-provisioning reset (lived inside the deleted storage) Deliberately preserved: - migrations 137/138 and their index.ts entries — Kysely's #ensureNoMissingMigrations runs unconditionally, so deleting an applied migration crash-loops every pod. The tables are dropped by a follow-up forward migration after the drain, not by this commit. - #5114/#5118 withClaimGitLock, #5126 org-context guard, #5143 analytics gate, #5171 owner-keyed thread graft, #5195/#5207/#5210/#5221 client auto-retry, the daemon status-code train and the settings-validation train - #5112's org-fs least-privilege narrowing and the start dedup key fix - #5116's squashed queue-tray pluralization (en + pt-br) - the remote-branch-name validations #5132 deleted, since this restores the dynamic origin/HEAD lookup that made them load-bearing Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Pedro França <[email protected]>
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.
Follows #5114, which added
withClaimGitLockto serializepublish/rebaseper claim on shared agent sandboxes so concurrent requests can't interleavegit commit/pushagainst the same working tree.discardwas left unwrapped even though it also mutates the same working tree (git checkout --to restore tracked files, plus unlinking untracked ones) — so on a sandbox shared by two teammates (#5112), adiscardracing a concurrentpublishcan still interleave:discard'sgit checkoutcan revert files mid-way throughpublish'sgit add/commit, or a discard-drivenunlinkcan delete a filepublishjust staged, either silently dropping a teammate's in-flight change or corrupting the commit.Fix: wrap the
git/discardroute in the samewithClaimGitLock(claimName, ...)used bypublish/rebase, so only one of publish/rebase/discard runs against a given claim's working tree at a time.No new test added —
withClaimGitLockitself is already exhaustively unit-tested (serializes same-claim calls, doesn't block different claims, rejections don't wedge the queue) insandbox-proxy.test.ts; this change is pure wiring of the existing, already-verified lock into one more route, not new locking logic.Reviewer check:
cd apps/mesh && bunx tsc --noEmitandbun test apps/mesh/src/api/routes/sandbox-proxy.test.ts(both pass locally). Full CI validates the rest.Locally ran:
bun run fmt, targetedtsc --noEmitin apps/mesh, and the single test file above.Summary by cubic
Wrap the
git/discardroute withwithClaimGitLockto serialize per-claim operations, matchingpublish/rebase. This prevents discard from racing with add/commit/push on shared sandboxes and avoids dropped files or corrupt commits.Written for commit 52712cf. Summary will update on new commits.