fix(workspaces): skip workspace provision command when reusing existing workspace (#8484) - #11091
Open
wakqasahmed wants to merge 2 commits into
Open
Conversation
|
Hey @wakqasahmed! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
… and stale-worktree provisioning Adversarial review of paperclipai#11091 found two real regressions in the "skip provision on reuse" fix: 1. environment-run-orchestrator.ts gated the remote provision command on `executionWorkspace.created`, but that flag is hardcoded `false` for the `project_primary` (shared workspace) strategy — it's the project's long-lived primary checkout, not something created per run. That meant provisioning would silently never run again for any shared-workspace remote/sandbox environment, not even on the very first run. The `workspaceRealization.isNew`/`created` fields the gate also checked are never actually populated by any real driver (only by the added unit test's mock), so in production the gate reduced entirely to the always- false local flag. Fixed by only applying the reuse-skip to the `git_worktree` strategy, where "created" is a well-defined signal; `project_primary` keeps its prior always-provision behavior. 2. The pre-existing test "reprovisions an existing persisted git worktree before manual control starts it" encoded the old provision-on-every-reuse behavior the PR is fixing, and was left failing by the original change. Updated it to assert the new intended behavior: a reused worktree is not reprovisioned, so a manually removed marker file stays gone. Also fixed a latent type error in the orchestrator test helper (`makeRealizeInput`) that let the PR's own added test pass an `executionWorkspace` override property `tsc` would have rejected, and added a regression test locking in the shared-workspace fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Fixes #8484
Summary
When an agent was assigned to an issue using an existing workspace, Paperclip executed the project's workspace
provisionCommandon every run, even when reusing a previously provisioned workspace (isNew === false).Fix
server/src/services/workspace-runtime.ts):if (!input.created) return;inprovisionExecutionWorktreesoprovisionCommandis executed strictly wheninput.created === true(new workspace setup) and skipped on workspace reuse.created = truehandling when missing worktrees are recreated viagit worktree add.server/src/services/environment-run-orchestrator.ts):provisionCommandexecution is guarded byexecutionWorkspace.created === true || workspaceRealization.isNew === true.server/src/__tests__/workspace-runtime.test.ts&server/src/__tests__/environment-run-orchestrator.test.ts):provisionCommandexecutes on initial workspace creation, but is skipped when reusing an existing workspace.