Repository navigation
Conversation
|
✅ All checks passing — ready for Greptile review and maintainer approval. — commitperclip |
[Medium impact] The changes affect issue workspace creation, server dispatch, and managed Git installs. The PR should preserve the parent's intended commit before merging, so children do not start from older files. Findings
Fix with agent prompt### Issue 1
server/src/services/execution-workspace-policy.ts:449-450
The child now inherits the parent's branch name as `baseRef`, but `resolveAuthoritativeBaseRef` prefers `origin/<branch>` whenever that remote branch exists. If the parent has local commits that it has not pushed, the child starts from the older remote commit and misses the parent's latest work. Its run may fail or redo work already completed.
Preserve the intended parent commit, for example by resolving its local branch to a commit before saving the child's settings.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryGives isolated issues separate workspaces while preserving shared-workspace inheritance.
The earlier unnumbered findings are addressed: exact branch pins are removed before preparation, added code comments are gone, and the PR description includes the required sections. Reviews (5) · Last reviewed commit: "Merge pull request #3 from jjude80/fix/w..." · Reviewed by Greptile |
|
Both branches now carry the same head, and the head moved: What the earlier fix did. A child that carries a pinned What was still open. The refusal decided the local realization path only. What Two smaller things in the same commit, both raised by the review on the sibling branch: the admission notice is now emitted only for a reuse request that was actually refused, and it states the observed result instead of promising a replacement; and the duplicate-notice check is a bounded query in the database instead of a scan of every comment body of the issue. Tests. |
An isolated execution workspace is one issue's worktree: one directory, one branch, one index. A child of a decomposed parent inherited the parent's workspace row, so six children of one decomposed parent were dispatched into the parent's worktree and four runs were live in it at once. The cost was measured: a whole-file write deleted another run's edits, git commit published every staged path in the tree including another issue's, and the tree did not build for reasons that belonged to neither run. Two layers, because a creation-time rule alone does not cover an issue that already points at somebody else's workspace. 1. Creation time (issues.ts). A child inherits the parent's mode and settings, but not the parent's workspace row when that row is an isolated workspace. A shared workspace is still inherited: sharing it is the point of it. A pinned existingBranch is stripped from inherited settings when the workspace is not bound, because a branch is the thing two issues must not share. 2. Dispatch time (heartbeat/workspaces.ts). The reuse request now carries the issue, the workspace mode and the workspace owner. Reusing an isolated workspace owned by a different issue is refused, and the refusal names the holder through conflictingWorkspaceOwnerIssueId. Recovery keeps its own workspace: a run that continues work already done in a tree is not a second issue joining it. The refusal is loud. The queue preflight posts an issue comment naming the holder issue, deduplicated by an HTML marker, so the run learns whose tree it was about to write into instead of discovering it in a merge conflict. Tests: execution-workspace-policy (50 cases), issues-service (32 workspace cases), heartbeat-workspace-session (182 cases, including the new conflict cases). Typecheck clean.
`paperclipai install --repo <owner/name> --ref <branch>` could not build a
payload at all: the server package ships the built UI inside it, and
prepare-bundled-package.mjs copies server/ui-dist into the staged package.
A fresh git checkout has no server/ui-dist -- it is produced by
scripts/prepare-server-ui-dist.sh, which the server package's own prepack
hook runs, and prepack only runs on `pnpm pack`. This flow stages the server
package directly, so the hook never fires and the packaging step died with
Error: ENOENT: no such file or directory, lstat '.../source/server/ui-dist'
after the whole build had already run (~20 minutes).
Build the UI before the workspace packages are staged, the same way
scripts/release.sh does it before it packs. Without this, a fork branch
cannot be installed on an instance at all, which is the only supported way
to ship a fork build, and the managed install store's git source cannot be
used.
Test: cli/src/__tests__/install-command.test.ts now asserts the UI
preparation runs, and that it runs before prepare-bundled-package.mjs
stages the bundled package.
A review found a hole in the refusal: refusing the reuse of another issue's isolated workspace is not enough on its own. A child that carries a pinned workspaceStrategy.existingBranch still realizes into the holder's checkout, because realization finds the worktree registered for that branch and reuses it. The run was refused a workspace and then given the same tree by another door. The dispatch path now drops the pinned branch when the reuse was refused because the workspace belongs to another issue, so the child derives its own branch and its own worktree. The strategy config is resolved through resolveExecutionWorkspaceStrategyConfig, which the workspace preparation uses for the effective run config, the plugin preparation and the realization. Tests: execution-workspace-policy covers the strategy resolution (a pinned branch is dropped for a foreign owner, kept for the issue's own workspace, and the whole strategy is dropped when the branch was all it held); heartbeat-workspace-session covers the dispatch path, from the refusal through the effective strategy the run realizes with.
…pace The dispatch-time refusal stopped the local realization path from restoring another issue's isolated workspace, and the pinned branch is dropped so the child cannot find the holder's registered worktree by name. The plugin preparation path still adopted the holder's workspace row. prepareHeartbeatWorkspace passed issueRef.executionWorkspaceId to preparePluginWorkspace, which restores that row and its saved provider binding, so a refused child was handed the holder's storage through the other door. The refusal now decides the workspace id that both preparation paths use: a refused child gets no existing workspace id, and an issue that owns its workspace keeps it. The admission notice is emitted only for a refused reuse request, and it states what was observed instead of promising a replacement. The duplicate check asks the database for a bounded match instead of loading every comment body of the issue into the process. Tests: the policy suite covers the workspace id decision and the notice rule, and the workspace session suite covers the id the plugin preparation receives for a refused child and for an issue that owns its workspace.
56e170f to
774f7ae
Compare
|
Note for reviewers: the branch history was rewritten to reword the commit subjects, and the head is now The trees are unchanged apart from removed code comments, so the review findings discussed above still apply to the new head. CI is re-running on it. |
|
CI status on The tree is identical to |
A child task inherits its parent's workspace settings but gets its own worktree. The inherited strategy had no base ref, so the new worktree was cut from the project default (origin/main). When the parent's work lives on an integration branch, the child's tree cannot contain the files the task is about, and the child waits on a baseline that can never go red. Carry the parent workspace's branch to the child as workspaceStrategy.baseRef, and keep a pinned existingBranch as the base ref when the pin has to be dropped because the workspace belongs to another issue.
NEXA-482: base a child task on its parent integration branch
| if (parentIntegrationBranch) { | ||
| nextStrategy.baseRef = parentIntegrationBranch; |
There was a problem hiding this comment.
The child now inherits the parent's branch name as baseRef, but resolveAuthoritativeBaseRef prefers origin/<branch> whenever that remote branch exists. If the parent has local commits that it has not pushed, the child starts from the older remote commit and misses the parent's latest work. Its run may fail or redo work already completed.
Preserve the intended parent commit, for example by resolving its local branch to a commit before saving the child's settings.
Prompt To Fix With AI
This is a comment left during a code review.
Path: server/src/services/execution-workspace-policy.ts
Line: 449-450
Comment:
**Children miss parent commits**
The child now inherits the parent's branch name as `baseRef`, but `resolveAuthoritativeBaseRef` prefers `origin/<branch>` whenever that remote branch exists. If the parent has local commits that it has not pushed, the child starts from the older remote commit and misses the parent's latest work. Its run may fail or redo work already completed.
Preserve the intended parent commit, for example by resolving its local branch to a commit before saving the child's settings.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
Want your agent to iterate on Greptile's feedback? Try greploops. |
## Thinking Path > - Paperclip manages AI agents and their work. > - Task creation can bind a child to its parent's execution workspace. > - Native sandbox runs reserve that workspace before the provider starts. > - Remote reservation rejected inherited isolated workspaces and operator branches because the original source task differed. > - This check stopped valid child tasks before their existing access and writer checks could run. > - This pull request uses the persisted binding and existing source-access checks to admit that continuation. > - The benefit is that authorized child tasks can continue saved work while the single-writer lock stays effective. ## Linked Issues or Issue Description **What happened?** A child inherited an active isolated remote workspace through normal task creation. Its next run failed during setup with `Workspace ownership changed.` No provider work started. The reservation guard treated the original `sourceIssueId` as exclusive ownership, although task creation had persisted a valid child binding. **Expected behavior** A bound child or follow-up can reserve the workspace after the prior writer saves. Current task/run access, source visibility, trust, company scope, closed-workspace state, and writer checks must still apply. The original source task remains provenance. **Steps to reproduce** 1. Create a task with an active saved remote isolated workspace or operator branch. 2. Create a child without an explicit workspace override. 3. Confirm that the child inherited the execution workspace ID. 4. Start its native sandbox run. The old reservation guard rejects it before provider execution. **Paperclip version or commit** Reproduced on source based on `06bc8db75c71142ed108e0f331394c5187015d6a`. The same guard is present at `1a6017d6460267ad89d7e1784e2b521c28d8e9ac`. Related: #17156 proposes separate workspaces for child tasks. This repair preserves the current inheritance contract and enforces the remote writer lock. #16911 addresses child bindings across repositories. ## What Changed - Remove the original-task equality restriction for active remote workspaces. Keep the existing persisted-binding and retained-source authorization path. Explicit task-root selection follows the existing V1 filesystem contract; task-assignment grants do not define filesystem permissions. - Keep closed workspace rejection and unfinished-writer checks. - Add database-backed regressions for inheritance, replay, competing children, an unbound task, private source data, company isolation, and closed records. - Extend real save/restore tests for inherited isolated workspaces and operator branches. Keep shared-workspace discovery coverage. - Update the development guide and workspace maps. ## Verification - Red: before the repair, the inherited isolated/operator cases fail with `Workspace ownership changed.` The shared case passes. The unfixed suite has five failures and four passes. - Green: 11 reservation cases pass with real PostgreSQL 18 in an isolated Docker container. - An earlier run of the four affected workspace/preparation/trust suites passed 191 tests. The review follow-up passes all 15 selected reservation/save/restore cases. Inherited cases remove the original files, use a distinct allocation and target, restore the saved file, append child work, and independently read that work from the child's new snapshot. Shared-source discovery stays covered. The filter excludes 42 other integration cases. - `pnpm -r typecheck`, `pnpm build`, `node scripts/check-maps.mjs`, and `git diff --check` pass. A direct server typecheck also passes after the final test edit. - `pnpm test:run` stopped in its first chat shard: 338 passed, one Discord receiver-lease setup failure, 1,478 outside the shard. The failing test passes in isolation on both the unchanged baseline and the fix. Its suite-order failure is not explained by that retry and remains recorded. The unchanged baseline also fails three other Discord publication cases in that chat shard, while its next chat shard passes. This does not reproduce or explain the original lease failure; both results remain recorded. CI is complete on `e697f6e1b8`: 54 successful check runs, one successful legacy status, three skipped checks, and one neutral check. No check is pending or failed. Greptile gives this commit 5/5 with no remaining findings. The security reviewer accepted the V1-contract explanation; both review threads are resolved. - Live sandbox acceptance remains unverified. The available test credentials could not resolve the required sandbox snapshot. The provider rejected creation before workspace execution, and a scoped follow-up found no allocation. No live model turn, deployment, or original-task recovery is claimed. - Local environment: macOS arm64, Node 26.4.0, pnpm 9.15.4. Native PostgreSQL startup hit the host semaphore limit; tests use disposable Docker databases. No shared database was reset. ## Risks - A bound child can now write after the prior writer releases the workspace. Incorrect binding or access checks could expose source data. Regressions cover unbound, private-source, and foreign-company rejection. - Concurrent children must not become two writers. A real transaction race grants exactly one reservation; saved-file tests keep the second writer blocked until save completes. - No schema or migration changes. This PR does not change task-creation inheritance, requested models, credentials, trust, approval gates, or recovery budgets. ## Model Used - OpenAI Codex, based on GPT-6. The exact serving model ID and context window are not exposed in this session. Used reasoning, tool use, code execution, and browser diagnostics. No sub-agents were used. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass — the targeted workspace suites pass; the full local chat-suite failure and baseline comparison are documented above - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
## Thinking Path > - Paperclip manages AI agents and their work. > - A child task can inherit its parent's remote workspace. > - The remote workspace permits one writer until that writer saves its files. > - Reservation reports an active writer as a generic setup failure. > - The existing shared workspace wait does not cover inherited isolated workspaces or a race at reservation. > - This pull request sends verified active writer contention through the existing scheduled retry path. > - The child keeps a live execution path while unfinished files remain protected. ## Linked Issues or Issue Description **What happened?** A native sandbox task inherited an isolated remote workspace from its running parent. Setup failed with `The workspace still has an unfinished writer or save operation.` The child became blocked before provider execution and had no scheduled continuation after the parent saved. **Expected behavior** The child waits for the active writer through the existing workspace retry path. It keeps its workspace binding. A stale writer or a stopped writer with unfinished saves still requires reconciliation. **Steps to reproduce** 1. Start a native sandbox task with remote workspace storage. 2. Create a child that inherits its isolated workspace or operator branch while the parent is still writing. 3. Start the child. On the old code, atomic reservation raises a generic setup failure. **Paperclip version or commit** Observed on `410b0e27015495ab8951768b5b0b94727de33785`. Regression reproduced on source based on `554a770c6f8e48e327e19f5208b575a5ec5bce30`. **Deployment mode** Authenticated managed server, external PostgreSQL, native Codex with a Daytona sandbox. The failed attempt stopped before runtime selection or provider startup. Related: #18611 permits inherited remote bindings. #16371 adds waits for reused shared execution workspaces. This repair handles active writer contention at atomic remote reservation. #17156 proposes a separate change to task workspace inheritance. ## What Changed - Return a typed conflict with the exact active writer from the remote reservation owner. Keep company, binding, access, and writer checks in that transaction. - Translate a recent running writer into the existing heartbeat workspace wait. Keep stale, unknown, stopped, dirty, and uncertain save fences. The writer task lookup uses its primary key. - Preserve the admitted assignee role across preparation so reassignment cannot turn an old owner into a guest retry. - Add PostgreSQL regressions for isolated workspaces, operator branches, native writer identity, unchanged saved authority, admission after save, durable retry, Stop, and reassignment before contention reaches the wait handler. - Update the development guide and workspace verification recipes. ## Verification - Red: both inherited isolated/operator preparation cases fail on the old code. They receive `HttpError(remote_workspace_writer_pending)` instead of a workspace wait. No provider or allocation starts. - Green: those same cases pass after the repair. The assembled public heartbeat cases also pass: one scheduled retry owns the task lock, no sandbox lease is created, the original writer and saved authority remain unchanged, and Stop prevents retry promotion. - Ownership race red/green: changing the assignee during preparation produced `wasIssueAssignee: false` before the review fix. The same regression now preserves its original role. A real transaction fault boundary also reassigns the task after reservation rejects it and before the wait handler runs; promotion cancels that retry with `issue_reassigned`. - Test isolation: an initial combined placement cached the synthetic S3 run-log backend and failed twelve later preparation cases. The assembled native tests now have their own process. The ordered reproduction and all four complete affected suites pass after that change: 171 tests, zero skipped. - Four additional saved-file lifecycle cases pass against disposable Docker PostgreSQL 17 with independent filesystem execution and local object storage. They restore inherited shared, isolated, and operator-branch files on a new allocation and retain the second-writer fence. The other 42 cases in that file were outside the selection. - `pnpm -r typecheck`, `pnpm build`, `node scripts/check-maps.mjs`, and `git diff --check` pass on the final source. - The earlier `pnpm test:run` passed all six chat shards: 1,828 tests. Its remaining general-server phase was interrupted after final-head CI passed. That local command began before the review fix and is not a complete local full-suite pass. - Final head `096235d8fc80033f92d8de1fcfa9835795ba0456`: 54 successful checks/statuses, three skipped checks, and two neutral checks. None is pending or failed. All build, typecheck, general/serialized tests, Runner checks, and eight browser E2E shards pass in [CI](https://github.com/paperclipai/paperclip/actions/runs/41544310900). The PR is mergeable with no conflicts. - Greptile is 5/5 on that exact head. Its ownership finding is resolved and no review thread remains open. Paperclip Review also reports 5/5 with no findings; its check conclusion is neutral. Its earlier status-conflict recovery completed through the ordinary review request path. - Local environment: macOS arm64, Node 26.4.0, pnpm 9.15.4, isolated native PostgreSQL and the disposable PostgreSQL 17 lifecycle fixture. The acquisition boundary is controlled in the focused preparation cases. No live Codex/Daytona replay is claimed: the local environment and test configuration lack the required test credentials. - No deployment, merge, or original task recovery is claimed. ## Risks - Incorrect contention classification could retry a stopped or unverified writer. Only a running writer with a same-company task and recent activity enters the wait path. Stale and terminal dirty cases retain the conflict. - Retries must not start another executor or release unsaved files. Reservation remains atomic. The tests check unchanged writer authority, no allocation before release, one durable retry, retained binding, Stop, and reassignment before the conflict is caught. - No API schema, database migration, provider configuration, model, credential, trust, or approval changes. ## Model Used - OpenAI `gpt-6.1-sol` through Codex. The context window size is not exposed in this session. Used reasoning, tool use, code execution, and browser diagnostics. No sub-agents were used. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass — targeted and chat results are recorded above; the full local command was interrupted - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
Thinking Path
Linked Issues or Issue Description
What happened?
A child issue inherited the execution workspace row of its parent, not only the mode and the settings. The dispatch code reused any workspace the issue already pointed at. It did not check who owned that workspace.
When a feature was decomposed into six children, all six children carried the same
executionWorkspaceIdwith the preferencereuse_existing. Four runs were live in one worktree at the same time. The cost was measured:git commitpublished every staged path in the tree, including the paths of another issue.Expected behavior
A child of a decomposed parent gets its own execution workspace. A run never joins a worktree that another issue owns.
Steps to reproduce
isolated_workspacewithgit_worktree.executionWorkspaceId. Both children have the workspace of the parent.Paperclip version or commit
masterat00818634.Deployment mode
A running deployment of this server.
Installation method
Managed install store, npm source.
Agent adapter(s) involved
Not adapter-specific (core bug).
Database mode
Not adapter-specific (core bug).
Access context
Operator.
Node.js version
Node.js 24.
What Changed
The rule has two layers, because a creation-time rule alone does not cover an issue that already points at a foreign workspace.
Layer 1 — creation time (
server/src/services/issues.ts,server/src/services/execution-workspace-policy.ts)An
isolated_workspaceis a per-issue workspace: one git worktree, one branch, one index, cut for one issue. Binding a second issue to it does not make the tree shared in some softer sense. It puts two runs in the same working tree, where a whole-file write destroys the other run's edit,git commitpublishes the other run's staged paths, and the tree does not build for reasons that belong to neither run.A
shared_workspaceis a different animal. It is shared by design, it is not a per-issue branch, and inheriting it is how a child continues its parent's work in the project checkout. The rule therefore keys on the mode of the workspace being inherited, not on the relationship between the two issues.resolveExecutionWorkspaceInheritanceDecisiondecides whether a child binds the workspace row of its parent. An explicit workspace override on the child inherits nothing.buildInheritedExecutionWorkspaceSettingsbuilds the settings a child carries. The mode always travels: a child of an isolated parent is still an isolated task, it just gets an isolated workspace of its own. A pinned exact branch does not travel, for the same reason the workspace row does not:existingBranchnames one branch, and a branch is the thing two issues must not share.Layer 2 — dispatch time (
server/src/services/heartbeat/workspaces.ts,server/src/services/heartbeat/queue.ts,server/src/services/heartbeat/environment-selection.ts,server/src/services/heartbeat/workspace-preparation.ts)conflictingWorkspaceOwnerIssueId. Recovery keeps its own workspace: a run that continues work in a tree is not a second issue that joins it.resolveExecutionWorkspaceStrategyConfigdrops a pinnedworkspaceStrategy.existingBranchwhen the reuse was refused. Refusing the reuse is not enough on its own: a child that carries a pinned branch still realizes into the holder's checkout, because realization finds the worktree registered for that branch and reuses it. The run was refused a workspace and then given the same tree by another door. With the branch dropped, the child derives its own branch and its own worktree. The workspace preparation uses this for the effective run config, the plugin preparation and the realization.workspace_conflict:<workspaceId>, so the board does not repeat it. The run learns whose tree it was about to write into, before it writes.Comments
This branch adds no code comments.
CONTRIBUTING.mdsays "Do not submit a PR that includes code comments", so the reasoning above lives here instead.Tests
server/src/__tests__/execution-workspace-policy.test.ts— 53 cases: the inheritance decision, the inherited settings, and the strategy resolution (a pinned branch is dropped for a foreign owner, kept for the issue's own workspace, and the whole strategy is dropped when the branch was all it held).server/src/__tests__/issues-service.test.ts— 32 workspace cases: a child of an isolated parent does not get the parent's row, a child of a shared parent still does, a pinned branch is stripped, an explicit override is honoured.server/src/__tests__/heartbeat-workspace-session.test.ts— the dispatch path: the refusal names the holder, and a refused child does not carry a pinned branch into realization.Verification
pnpm --filter @paperclipai/server typecheck. The result is clean.pnpm --filter @paperclipai/server test -- src/__tests__/execution-workspace-policy.test.ts. The result is 53 cases passed.pnpm --filter @paperclipai/server test -- src/__tests__/issues-service.test.ts. The 32 workspace cases pass.pnpm --filter @paperclipai/server test -- src/__tests__/heartbeat-workspace-session.test.ts. The workspace session cases pass, including the new refusal cases.Risks
The behaviour change is narrow. A shared workspace is still inherited. An issue with an explicit workspace override inherits nothing. The dispatch refusal only applies to isolated workspaces. Recovery keeps its own workspace.
The one behaviour that changes for an existing issue is a child that carries a pinned branch inherited from its parent: it no longer realizes into the parent's checkout. That is the case the review flagged, and the child gets its own worktree instead.
The risk is that a workflow which relied on a child sharing the isolated worktree of its parent now gets a separate tree. That workflow is the bug this pull request fixes.
Model Used
minimax-m3.1-flash-free)Checklist
Fixes: #/Closes: #/Refs: #OR (b) described the issue in-PR following the relevant issue template#NNN/github.com/paperclipai/paperclipURLs)docs/...,fix/...) and contains no internal Paperclip ticket id or instance-derived detailsRelated pull requests