From c2aa9d3e11171b2ac5c2cf0c8184c87d965cf513 Mon Sep 17 00:00:00 2001 From: Henry Chu Date: Wed, 28 Oct 2026 07:03:51 -0400 Subject: [PATCH 1/2] Let delegate_task name its own environment Upstream's remoteTarget treats a target.environmentId equal to the caller's own environment as a local task. The stage 2 seam refused any environmentId, unlike McpToolAccess's seam for the other tools; it now refuses only another environment. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/mcp/OrchestratorMcpService.ts | 8 ++++++-- docs/internals/coder-only.md | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts index 93b1bfccfb325..d0954ad582af2 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.ts @@ -2052,8 +2052,12 @@ const make = Effect.gen(function* () { }; }), delegateTask: Effect.fn("OrchestratorMcpService.delegateTask")(function* (callerScope, input) { - // Coder: peer links are not carried, so a task cannot run in another environment. - if (input.target?.environmentId !== undefined) { + // Coder: peer links are not carried, so a task cannot run in another environment; naming + // this one runs it here, as upstream's remoteTarget does. + if ( + input.target?.environmentId !== undefined && + input.target.environmentId !== callerScope.environmentId + ) { return yield* failure( "invalid_request", "This environment cannot reach linked environments.", diff --git a/docs/internals/coder-only.md b/docs/internals/coder-only.md index a9caa229f4918..91ec3dda0030d 100644 --- a/docs/internals/coder-only.md +++ b/docs/internals/coder-only.md @@ -522,8 +522,8 @@ listed here is drift to remove rather than fork behavior to keep. task read, wait, delegate, and cancel paths, `ThreadManagementService`'s remote task stop, and `ProjectionStore`'s `getOpenRemoteDelegatedTasks`. `McpToolAccess.toLayer` refuses any tool call whose `environmentId` names another environment with upstream's "This environment - cannot reach linked environments." error, and `delegate_task` refuses `target.environmentId` - the same way. Migrations 070 and 071 keep their IDs and create nothing; 072's index stays, + cannot reach linked environments." error, and `delegate_task` refuses a `target.environmentId` + naming another environment the same way. Migrations 070 and 071 keep their IDs and create nothing; 072's index stays, because `ProjectionStore`'s waiting-card reads name it. `peerLinks`, `mcpModeLimitHeader`, and `linkFence` are in `CODER_OMITTED_CAPABILITIES`. The contracts (`peerLink.ts`, the `environmentId` tool fields the bridge advertises, `remoteChild`, `linkOrigin`, From eff63babbf541bdd87d529be7c8cb9e73da8abd8 Mon Sep 17 00:00:00 2001 From: Henry Chu Date: Wed, 28 Oct 2026 07:04:20 -0400 Subject: [PATCH 2/2] Record the 67661cfbb5 sync's lessons in sync.md Renamed patches for cut packages, deletion sweeps that break fork-only tests at runtime, and dependency lines the merge adds back. Co-Authored-By: Claude Opus 5.5 --- docs/internals/sync.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/internals/sync.md b/docs/internals/sync.md index e2e50d7a3b997..184fa419598bc 100644 --- a/docs/internals/sync.md +++ b/docs/internals/sync.md @@ -107,6 +107,13 @@ only fork behavior to keep. Commands run from the repository root of the sync wo parsing moved to client-runtime's `pullRequestLinkInput.ts`), move the fork's test adaptations with it, keep the moved module upstream's apart from wording, and keep a seam that needs web code (`gitLabMergeRequestBrowserUrl`) as a wrapper at the web caller. +- An upstream sweep that deletes code nothing upstream reaches (67661cfbb5's #26238) also removes + helpers, mock-agent options, and guards that only fork-only tests (tests the fork kept after + upstream deleted its copy) or fork modules still use. Typecheck misses most of these, since + the tests mock by name or spawn scripts; only the full suite finds them (that sync: + `GitWorkflowService.test.ts`'s `jj` guard, `useThreadActionMenu.test.tsx`'s entity mocks, + the Kilo adapter test's `acp-mock-agent.ts` option). Keep a piece a fork module needs as a + `Coder:` seam; adapt a fork-only test to the remaining behavior. - Upstream code the fork carries can start importing a module the fork deleted (in 2a7bd1673c, `ThreadManagementService.ts` imports `environment/ServerEnvironment.ts` for `ServerEnvironmentIdentity`). Declare the piece it needs in the matching Coder module @@ -138,7 +145,10 @@ repro fixtures and seed scripts under `scripts` (eb1510d249: `fixtures/issue-165 `fixtures/issue-18188`, `fixtures/issue-21397.json`, `seed-issue-21397.py` and its test) are upstream tooling; delete them. Upstream's patches for mobile or desktop packages land in `patches/` (2a7bd1673c: `@expo__ui@58.0.18.patch`); -delete any that `pnpm-workspace.yaml`'s `patchedDependencies` does not list. A fork-deleted file +delete any that `pnpm-workspace.yaml`'s `patchedDependencies` does not list. An upstream bump +of a patched package the fork cut renames its patch, so the new file arrives as an addition +outside any deleted path (67661cfbb5: `alchemy@2.0.0-beta.84.patch`); compare `ls patches` with +`patchedDependencies` after every stage. A fork-deleted file outside those paths that upstream modified (a cut surface's test or settings panel) is listed as "deleted by fork"; keep it deleted unless the seams doc says otherwise. An upstream rename out of a deleted directory into a kept one (in this batch, @@ -224,6 +234,9 @@ git -c diff.renameLimit=0 diff --no-renames --name-status "$MB" origin/coder-onl license step). List the newly added package versions that differ from upstream's lockfile and replace their `packages:` and `snapshots:` entries and references with upstream's, then confirm `pnpm install --frozen-lockfile` passes. +- When upstream moves a dependency line within a `package.json` (67661cfbb5: `@opencode-ai/sdk` + from `dependencies` to `devDependencies` in `apps/server`), the merge can add it back for a + package the fork cut. Review `git diff HEAD -- '*package.json'` after resolving manifests. - New upstream code can import a dependency the fork had removed with an old cut (7df7cb9999: `yauzl` for document text, `jszip` for office previews). Typecheck reports the missing module; restore upstream's dependency entry rather than adapting the code.