Repository navigation
Conversation
[Medium impact] The PR reaches Git-based payload builds and several bounded issue and execution workflows. Do not merge yet: managed GitHub commands can still bypass their launchers, valid paths can break shell startup, and an accepted review transition can leave the reviewer asleep. Findings
Fix with agent prompt### Issue 1
packages/adapter-utils/src/execution-target.ts:1776-1777
If a login shell puts `/usr/bin` ahead of the launcher directory, this `case` guard leaves that order unchanged because the directory still appears in `PATH`. Then `git` and `gh` run the ordinary binaries instead of Paperclip's launchers. They miss the managed credentials and can fail authentication despite a configured GitHub connection.
Keep caller-added tool directories without letting an earlier `git` or `gh` hide the managed launchers.
### Issue 2
packages/adapter-utils/src/execution-target.ts:1772-1777
`launcherDirPattern` is inserted directly into shell source, but its escaping leaves quotes, dollar signs, and backticks untouched. The directory includes `remoteCwd` or the local temporary directory. If that path contains an apostrophe, such as `/srv/alice's-project`, every generated profile gets an unmatched quote. Child shells then cannot read the profile correctly, breaking shell setup and managed GitHub commands.
Match against the quoted `_paperclip_launcher_dir` variable instead of inserting the path as shell source.
### Issue 3
server/src/routes/issues.ts:4626-4635
The new guard accepts an unchanged assignee as a review handoff. An agent can PATCH an idle issue assigned to another agent from `todo` to `in_review`, without changing `assigneeAgentId` or adding a comment. This passes the ownership check, but the assignment wake requires a changed assignee, and the status wake does not cover this transition. The reviewer receives no request to act, so the issue can sit in review.
Require an actual handoff here, or wake the existing reviewer when accepting this transition.
### Issue 4
server/src/__tests__/execution-workspace-policy.test.ts:881-885
`execution-workspace-policy.test.ts` grows from 775 to 1,081 lines. The repository requires a concrete reason before a code file crosses 1,000 lines, and none is given here. Move the workspace inheritance tests into a focused test file, or explain why they must stay together. This repository requirement must be satisfied before merging.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
### Issue 5
server/src/__tests__/heartbeat-workspace-session.test.ts:1945-1954
The added dispatch tests call decision helpers but never run workspace preparation. They cannot show that a refused child gets separate files or that plugin preparation receives the corrected settings.
The heartbeat rule requires exercising the public heartbeat path and checking execution and saved outcomes, not only helper results. Add an assembled test that prepares a refused child's workspace and checks its saved workspace and files. This repository requirement must be satisfied before merging.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThe PR prepares UI files and skills before packing Git installs, skips lifecycle scripts for staged bundles, and separates child issues from another issue's isolated workspace.
Reviews (10) · Last reviewed commit: "Merge pull request #5 from jjude80/nexa/..." · Reviewed by Greptile |
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
|
Correction to the reply above about code comments: that claim was checked against an unpushed working tree, not the branch, and it was wrong. The branch history is rewritten and the head is now
|
|
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.
A git install stages the server package and packs it directly, which skips three steps scripts/release.sh performs before packing: - stage the repository-level skills tree into the packages that publish it, so prepare-bundled-package.mjs does not fail on a missing server/skills; - normalize workspace package versions, so a workspace dependency does not materialize to the depending package's version and fail npm install with ETARGET; - pass --ignore-scripts to npm pack on the staged bundled package, because the staged manifest keeps the server prepack and its script path does not exist beside the staged package. Tests assert each step and that both staging steps run before the first pack.
NEXA-482: base a child task on its parent integration branch
…isolation fix(workspace): base a child task on its parent's integration branch (NEXA-482)
| expect(reuseRequest.requestedShouldReuseExisting).toBe(false); | ||
| expect(resolveExecutionWorkspaceStrategyConfig({ | ||
| config: { | ||
| mode: "isolated_workspace", | ||
| workspaceStrategy: { type: "git_worktree", existingBranch: "holder-branch" }, | ||
| }, | ||
| conflictingWorkspaceOwnerIssueId: reuseRequest.conflictingWorkspaceOwnerIssueId, | ||
| })).toEqual({ | ||
| mode: "isolated_workspace", | ||
| workspaceStrategy: { type: "git_worktree", baseRef: "holder-branch" }, |
There was a problem hiding this comment.
Tests stop before workspace preparation
The added dispatch tests call decision helpers but never run workspace preparation. They cannot show that a refused child gets separate files or that plugin preparation receives the corrected settings.
The heartbeat rule requires exercising the public heartbeat path and checking execution and saved outcomes, not only helper results. Add an assembled test that prepares a refused child's workspace and checks its saved workspace and files. This repository requirement must be satisfied before merging.
File Used: rules/heartbeat-execution-boundaries.mdc (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: server/src/__tests__/heartbeat-workspace-session.test.ts
Line: 1945-1954
Comment:
**Tests stop before workspace preparation**
The added dispatch tests call decision helpers but never run workspace preparation. They cannot show that a refused child gets separate files or that plugin preparation receives the corrected settings.
The heartbeat rule requires exercising the public heartbeat path and checking execution and saved outcomes, not only helper results. Add an assembled test that prepares a refused child's workspace and checks its saved workspace and files. This repository requirement must be satisfied before merging.
**File Used:** `rules/heartbeat-execution-boundaries.mdc` ([source](https://github.com/paperclipai/paperclip/blob/7d4d66769006966ed37f7f9e812e7f84f368382e/rules/heartbeat-execution-boundaries.mdc))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
… owned target npm extracts the vendored @github/copilot-linux-x64 package using the ambient umask. Agent shells and paperclipai.service run with umask 0002, so the pinned executable lands 0775 and the payload postinstall rejected it before copying it anywhere: Error: Copilot executable has unsafe permissions The materializer verifies the source bytes against a SHA-256 pin and writes them to an output directory it exclusively creates, then fchmods 0755. In that path the source mode is not something the output inherits, so a group/world writable source is safe. The check still rejects a writable source for in-place materialization (the bytes are then launched from where they were found) and still rejects any source without an execute bit.
The managed GitHub launcher profile exported PATH as a fixed value, so every non-interactive bash that sourced it lost any directory the caller had prepended. Build steps that provision a tool by prepending a shim directory then failed with 'command not found' for an installed tool. Keep the inherited PATH and only move the launcher directory to the front, deduplicated so nested shells do not grow PATH. Fall back to the launch PATH only when the shell has no PATH at all. Regression test runs a real child bash and asserts a caller-prepended directory survives and the launcher directory appears once.
| `case ":\${PATH-}:" in`, | ||
| ` *:${launcherDirPattern}:*) ;;`, |
There was a problem hiding this comment.
GitHub commands skip managed credentials
If a login shell puts /usr/bin ahead of the launcher directory, this case guard leaves that order unchanged because the directory still appears in PATH. Then git and gh run the ordinary binaries instead of Paperclip's launchers. They miss the managed credentials and can fail authentication despite a configured GitHub connection.
Keep caller-added tool directories without letting an earlier git or gh hide the managed launchers.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/adapter-utils/src/execution-target.ts
Line: 1776-1777
Comment:
**GitHub commands skip managed credentials**
If a login shell puts `/usr/bin` ahead of the launcher directory, this `case` guard leaves that order unchanged because the directory still appears in `PATH`. Then `git` and `gh` run the ordinary binaries instead of Paperclip's launchers. They miss the managed credentials and can fail authentication despite a configured GitHub connection.
Keep caller-added tool directories without letting an earlier `git` or `gh` hide the managed launchers.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const launcherDirPattern = directory.replace(/[\\*?[\]]/g, "\\$&"); | ||
| const fallbackPath = basePath || "/usr/bin:/bin"; | ||
| const restoreLauncherPath = [ | ||
| `_paperclip_launcher_dir=${shellQuote(directory)}`, | ||
| `case ":\${PATH-}:" in`, | ||
| ` *:${launcherDirPattern}:*) ;;`, |
There was a problem hiding this comment.
Valid paths break shell startup
launcherDirPattern is inserted directly into shell source, but its escaping leaves quotes, dollar signs, and backticks untouched. The directory includes remoteCwd or the local temporary directory. If that path contains an apostrophe, such as /srv/alice's-project, every generated profile gets an unmatched quote. Child shells then cannot read the profile correctly, breaking shell setup and managed GitHub commands.
Match against the quoted _paperclip_launcher_dir variable instead of inserting the path as shell source.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/adapter-utils/src/execution-target.ts
Line: 1772-1777
Comment:
**Valid paths break shell startup**
`launcherDirPattern` is inserted directly into shell source, but its escaping leaves quotes, dollar signs, and backticks untouched. The directory includes `remoteCwd` or the local temporary directory. If that path contains an apostrophe, such as `/srv/alice's-project`, every generated profile gets an unmatched quote. Child shells then cannot read the profile correctly, breaking shell setup and managed GitHub commands.
Match against the quoted `_paperclip_launcher_dir` variable instead of inserting the path as shell source.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.buildInheritedExecutionWorkspaceSettings copied the parent workspace's current branch into a child issue's baseRef for every git_worktree parent. A runtime-created branch is deleted when the parent workspace is reclaimed, so a child dispatched after the parent lands fails pre-adapter with workspace_base_ref_unresolved and strands itself at blocked with no cause on the thread (NEXA-569/573/574). Only inherit the branch when it outlives the parent: an operator-owned branch (or a legacy unmarked row, whose branch cleanup deliberately skips). A runtime-owned branch now falls back to the source workspace's own durable baseRef, which is the same retarget a human performs by hand on a stranded child. Integration-branch inheritance is unchanged. Regression tests cover the transient-branch fallback at the policy level and through issueService.create.
An agent-authored update that moved an issue to in_review was refused unless one of five review paths was present, and none of them could name another agent. The NEXA-415 contract ends in a review by an agent (Part E), so the implementer either left the card in_progress or manufactured an unaddressed interaction to satisfy the validator. Accept an assignee agent other than the acting agent as a review path. That assignee is the owner shown on the card, and the existing assignee-change wake routes the hand-off to them, so the reviewer really is the next actor. A self-assignment is not a hand-off and still fails the check. The 422 now lists agent_assignee_agent_id among validReviewPaths and the message explains the assigneeAgentId hand-off. Co-Authored-By: Paperclip <noreply@paperclip.ing>
| const nextAssigneeAgentId = | ||
| input.updateFields.assigneeAgentId === undefined | ||
| ? input.existing.assigneeAgentId | ||
| : input.updateFields.assigneeAgentId; | ||
| if ( | ||
| typeof nextAssigneeAgentId === "string" && | ||
| nextAssigneeAgentId.trim().length > 0 && | ||
| nextAssigneeAgentId !== input.actorAgentId | ||
| ) | ||
| return null; |
There was a problem hiding this comment.
The new guard accepts an unchanged assignee as a review handoff. An agent can PATCH an idle issue assigned to another agent from todo to in_review, without changing assigneeAgentId or adding a comment. This passes the ownership check, but the assignment wake requires a changed assignee, and the status wake does not cover this transition. The reviewer receives no request to act, so the issue can sit in review.
Require an actual handoff here, or wake the existing reviewer when accepting this transition.
Knowledge Base Used: Issue execution and collaboration
Prompt To Fix With AI
This is a comment left during a code review.
Path: server/src/routes/issues.ts
Line: 4626-4635
Comment:
**Reviewer never gets woken**
The new guard accepts an unchanged assignee as a review handoff. An agent can PATCH an idle issue assigned to another agent from `todo` to `in_review`, without changing `assigneeAgentId` or adding a comment. This passes the ownership check, but the assignment wake requires a changed assignee, and the status wake does not cover this transition. The reviewer receives no request to act, so the issue can sit in review.
Require an actual handoff here, or wake the existing reviewer when accepting this transition.
**Knowledge Base Used:** [Issue execution and collaboration](https://app.greptile.com/paperclip-org-3/-/custom-context/knowledge-base/paperclipai/paperclip/-/docs/issue-execution.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.fix(workspace): stop basing a child on a branch the parent deletes
| it("bases a child on the parent's durable base, not a transient runtime branch", () => { | ||
| // The parent workspace created its own task branch. That branch is deleted | ||
| // when the parent is reclaimed, so a child that has not started yet would | ||
| // otherwise fail with workspace_base_ref_unresolved. Base it on the ref the | ||
| // parent itself started from instead. |
There was a problem hiding this comment.
execution-workspace-policy.test.ts grows from 775 to 1,081 lines. The repository requires a concrete reason before a code file crosses 1,000 lines, and none is given here. Move the workspace inheritance tests into a focused test file, or explain why they must stay together. This repository requirement must be satisfied before merging.
Context Used: CONTRIBUTING.md has a guide for a good PR message including a "thinking path". If the PR doesn't include a "thinking path" and "details about what you did, why you did it, why it matters & the benefits, how we can verify it works, and any risks", the... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: server/src/__tests__/execution-workspace-policy.test.ts
Line: 881-885
Comment:
**Tests cross the size limit**
`execution-workspace-policy.test.ts` grows from 775 to 1,081 lines. The repository requires a concrete reason before a code file crosses 1,000 lines, and none is given here. Move the workspace inheritance tests into a focused test file, or explain why they must stay together. This repository requirement must be satisfied before merging.
**Context Used:** CONTRIBUTING.md has a guide for a good PR message including a "thinking path". If the PR doesn't include a "thinking path" and "details about what you did, why you did it, why it matters & the benefits, how we can verify it works, and any risks", the... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Thinking Path
Linked Issues or Issue Description
What happened?
paperclipai install --repo <owner/name> --ref <branch>failed at the packaging step. The server package ships the built UI inside it.scripts/prepare-bundled-package.mjscopiesserver/ui-distinto the staged package. A clean git checkout has noserver/ui-dist. The file is produced byscripts/prepare-server-ui-dist.sh. The server package runs that script in itsprepackhook, andprepackonly runs onpnpm pack. The git install flow stages the server package directly withprepare-bundled-package.mjs, so the hook never runs and the file is missing.Expected behavior
The command builds a payload and activates it.
Steps to reproduce
paperclipai install --repo <owner/name> --ref <branch> -yon a host where no payload for that commit exists.Paperclip version or commit
masterat00818634.Deployment mode
A running deployment of this server.
Installation method
Managed install store, git source.
Agent adapter(s) involved
Not adapter-specific (core bug).
Database mode
Not adapter-specific (core bug).
Access context
Operator, on the host that runs the instance.
Node.js version
Node.js 24.
What Changed
This branch carries two changes, and both are needed for a deployable payload: the pull request's own subject (the CLI must be able to build a git payload at all) and the workspace-isolation change proposed separately as #17156 (a payload has to contain the whole fix, not half of it). Each is listed separately below with its own callers.
1. Prepare the server UI dist before staging a git payload
cli/src/commands/install.ts: build the server UI dist after the server build and before the workspace packages are staged. The flow usesscripts/prepare-server-ui-dist.sh, which is the same script thatscripts/release.shuses before it packs.cli/src/__tests__/install-command.test.ts: add a test. The test checks that the UI preparation runs, and that it runs beforeprepare-bundled-package.mjsstages the bundled package.paperclipai install --repo <owner/name> --ref <branch>only. The npm install path, the update path and the rollback path are untouched.2. Give each issue its own execution workspace (from #17156)
server/src/services/issues.ts: a child issue inherits its parent's workspace mode and settings, but not the parent's workspace row when that row is an isolated workspace. A shared workspace is still inherited, because sharing it is the point of it. A pinnedexistingBranchis stripped from inherited settings when the workspace is not bound.server/src/services/heartbeat/workspaces.tsandserver/src/services/execution-workspace-policy.ts: the reuse request carries the issue, the workspace mode and the workspace owner. Reusing an isolated workspace owned by another issue is refused, the refusal names the holder, and the pinned branch is dropped so a refused child derives its own branch and its own worktree.server/src/services/heartbeat/workspace-preparation.ts: one decision now feeds both preparation paths.resolveExecutionWorkspaceReuseWorkspaceIdreturns the reusable workspace when the issue owns it, the requested workspace when nobody else owns it, and no workspace at all when the request was refused, so the plugin preparation cannot restore the holder's row either.server/src/services/heartbeat/queue.ts: the admission notice is emitted only for a refused reuse request, it states the observed result instead of promising a replacement, and the duplicate check is a bounded query instead of a scan of every comment body.server/src/services/issues.ts), dispatch (server/src/services/heartbeat/queue.ts), workspace preparation (server/src/services/heartbeat/workspace-preparation.ts), plugin workspace preparation (server/src/services/plugin-workspaces.ts) and workspace realization (server/src/services/workspace-runtime.ts).Verification
For the CLI change:
pnpm --filter @paperclipai/cli test -- src/__tests__/install-command.test.ts. The new case fails without the change and passes with it.pnpm --filter @paperclipai/cli typecheck.paperclipai install --repo <owner/name> --ref <branch> -y. Before the change the command fails withENOENT ... server/ui-dist. After the change it printsActivated cachedorInstalled.For the workspace-isolation change:
server/src/__tests__/execution-workspace-policy.test.tscovers the inheritance decision, the strategy resolution for a refused child, the workspace id decision for both preparation paths and the admission-notice rule.server/src/__tests__/issues-service.test.tscovers issue creation: a child of an isolated parent gets its own workspace row, a child of a shared parent still shares, and a pinned branch does not travel with an unbound workspace.server/src/__tests__/heartbeat-workspace-session.test.tscovers the dispatch path, from the refusal through the effective strategy and the workspace id the preparation paths receive.Risks
The CLI change is low risk on its own. It adds one build step to the git install flow. It does not change any runtime behaviour of the installed payload. The step is skipped when the checkout has no
scripts/prepare-server-ui-dist.sh, so other repositories are not affected. The build takes a little longer because the UI is now built.The workspace-isolation change moves a boundary, so it is worth being explicit about what it refuses and what it does not:
Model Used
minimax-m3.1-flash-free)Related pull requests
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 details