From ff876b607ff4c2fc362660bd05a036602ad5ec28 Mon Sep 17 00:00:00 2001 From: scuttletoby <123843277+scuttletoby@users.noreply.github.com> Date: Tue, 17 Nov 2026 23:24:40 +0100 Subject: [PATCH 1/3] fork seam check: refuse a pull request's own malformed list (format only) (#385) A pull request is judged by main's list, so its own list was never parsed before merge. A malformed one (bad JSON, the old plain-number "lost", an unknown kind, or a deleted list) then made every later pull request and fork-follow run exit 3, including the pull request that fixes it. The PR run now parses the head's list when the change edits it (format only, never its rules) and refuses a malformed one with exit 1. parseConfig also refuses unknown top-level keys and unknown seam-entry keys ("//..." keys stay comments), so a misspelt block cannot guard nothing. Co-Authored-By: Claude Opus 5.5 --- .github/scripts/fork-seam-check.cjs | 41 ++++++++++++++++- .github/scripts/fork-seam-check.test.cjs | 58 ++++++++++++++++++++++++ docs/fork/updates.md | 4 +- 3 files changed, 101 insertions(+), 2 deletions(-) diff --git a/.github/scripts/fork-seam-check.cjs b/.github/scripts/fork-seam-check.cjs index c61a432778c70..ca970aedb66d2 100644 --- a/.github/scripts/fork-seam-check.cjs +++ b/.github/scripts/fork-seam-check.cjs @@ -362,6 +362,18 @@ function findHiddenUpstreamFiles(upstreamFiles, isForkFile, atHead) { ); } +const KINDS = ["files", "pending", "forkFiles", "lost"]; +const SEAM_KEYS = ["why", "added"]; + +/** Refuses a key the check does not read (a misspelt block guards nothing); "//…" is a comment. */ +function refuseUnknownKeys(object, known, where) { + for (const key of Object.keys(object)) { + if (!key.startsWith("//") && !known.includes(key)) { + throw new Error(`${CONFIG}: ${where}unknown key "${key}" (known: ${known.join(", ")})`); + } + } +} + const isStringList = (value) => Array.isArray(value) && value.every((item) => typeof item === "string" && item.trim() !== ""); @@ -372,6 +384,7 @@ function parseConfig(text) { if (typeof files !== "object" || files === null || Array.isArray(files)) { throw new Error(`${CONFIG}: "files" must be an object`); } + refuseUnknownKeys(config, KINDS, ""); for (const [file, seam] of Object.entries(files)) { if (typeof seam?.why !== "string" || seam.why.trim() === "") { throw new Error(`${CONFIG}: ${file} needs a "why"`); @@ -379,6 +392,7 @@ function parseConfig(text) { if (!Array.isArray(seam.added) || seam.added.some((line) => typeof line !== "string")) { throw new Error(`${CONFIG}: ${file}: "added" must be a list of lines`); } + refuseUnknownKeys(seam, SEAM_KEYS, `${file}: `); } if (config.forkFiles !== undefined && !isStringList(config.forkFiles)) { throw new Error(`${CONFIG}: "forkFiles" must be a list of paths`); @@ -431,6 +445,21 @@ function parseConfig(text) { return { files, pending, forkFiles: config.forkFiles ?? [], lost }; } +/** + * Why a pull request's own list cannot become main's (its format only: its rules are not in force + * here), or undefined. Merged, a malformed list crashes every later run, the fix's run included. + */ +function ownListProblem(text) { + const own = `this change's own ${CONFIG}`; + if (text === undefined) return `${own}: this change deletes it.`; + try { + parseConfig(text); + return undefined; + } catch (error) { + return `${own} is malformed: ${error instanceof Error ? error.message : error}`; + } +} + const hasConfig = (rev) => entryAt(rev, CONFIG)?.type === "blob"; /** Reads `:.github/fork-seams.json`; throws when that commit has none. */ @@ -525,14 +554,24 @@ function main(argv) { const from = parsed.configRef ? `--config-ref ${configRef}` : upstream ? "the head" : "the base"; const notes = [...findListedGone(config, { atBase, atHead }), ...unlisted.notes, ...lost.notes]; for (const note of notes) console.log(`Note: ${note}`); - if (!upstream && textAt(head, CONFIG) !== textAt(mergeBase, CONFIG)) { + const ownList = textAt(head, CONFIG); + const editsList = !upstream && ownList !== textAt(mergeBase, CONFIG); + const listProblem = editsList ? ownListProblem(ownList) : undefined; + if (editsList) { console.log( `Note: this change edits ${CONFIG}; it is judged by the list in ${from}, not its own. ` + "A new seam or list entry takes effect once the owner merges it.", ); } const counted = upstream ? "every upstream file" : "every upstream file it changes"; + if (listProblem !== undefined) { + console.error(listProblem); + console.error( + `Fix the list in this change: merged, it is main's list, and a malformed one stops every later pull request and fork-follow run.`, + ); + } if (reasons.length === 0 && ceilings.length === 0) { + if (listProblem !== undefined) return 1; console.log( `Fork lines in upstream files: only the pinned seams (${counted}; list from ${from}).`, ); diff --git a/.github/scripts/fork-seam-check.test.cjs b/.github/scripts/fork-seam-check.test.cjs index 0084221c4f219..31e33ac001d5a 100644 --- a/.github/scripts/fork-seam-check.test.cjs +++ b/.github/scripts/fork-seam-check.test.cjs @@ -345,6 +345,10 @@ test("a malformed config throws instead of guarding nothing", () => { { files: SEAM, lost: { "a.ts": { lines: 2, gone: 3 } } }, { files: SEAM, lost: { "a.ts": { lines: 2, gone: 1, why: "x" } } }, { files: SEAM, lost: { "b.ts": { lines: 1, gone: 0 } } }, + // Unknown kinds: a misspelt block or seam key would silently guard nothing. + { files: SEAM, lsot: {} }, + { files: SEAM, Pending: { "p.ts": 1 } }, + { files: { "a.ts": { ...SEAM["a.ts"], add: ["x"] } } }, ...["/abs", "../up", "**", "*", "!", "a/../b"].map((pattern) => ({ files: {}, forkFiles: [pattern], @@ -352,6 +356,16 @@ test("a malformed config throws instead of guarding nothing", () => { ]) { assert.throws(() => parseConfig(JSON.stringify(bad)), JSON.stringify(bad)); } + // Keys that start with "//" are comments, at the top and in an entry. + assert.doesNotThrow(() => + parseConfig( + JSON.stringify({ + "//": "c", + "//pending": "c", + files: { "a.ts": { ...SEAM["a.ts"], "//": "c" } }, + }), + ), + ); assert.deepEqual(parseConfig(JSON.stringify({ files: SEAM })), { files: SEAM, pending: {}, @@ -503,6 +517,50 @@ test("a pull request that widens or drops its own list is judged by main's list" }); }); +// A pull request is judged by main's list, so its own list was never parsed before merge: a +// malformed one (bad JSON, the old plain-number "lost", an unknown kind, or none) then made every +// later pull request and fork-follow run crash (exit 3), the pull request that fixes it included. +test("a pull request's own list is parsed for its format (never its rules) and refused when malformed", () => { + withRepo(({ git, commit, run, fromUpstream }) => { + const main = commit({ ...seams({ files: SEAM }), ...BASE }, "main"); + const heads = { + 'old plain-number "lost"': [ + seams({ files: SEAM, lost: { "a.ts": 3 } }), + /"lost": a\.ts needs/, + ], + "bad JSON": [{ [CONFIG]: '{"files": {' }, /JSON/], + "an unknown kind": [seams({ files: SEAM, lsot: {} }), /unknown key "lsot"/], + "no list": [{ [CONFIG]: null }, /this change deletes it/], + }; + for (const [what, [files, message]] of Object.entries(heads)) { + git("checkout", "-q", "-f", "-B", "pr", main); + const pr = commit(files, what); + for (const args of [ + [main, pr], + ["--config-ref", main, main, pr], + ]) { + const result = run(...args); + assert.equal(result.status, 1, `${what}: ${result.stdout}${result.stderr}`); + assert.match(result.stderr, /this change's own \.github\/fork-seams\.json/, what); + assert.match(result.stderr, message, what); + assert.match(result.stderr, /Fix the list in this change/, what); + assert.doesNotMatch(result.stderr, /a file of the fork's own/, what); + } + } + // A well-formed list passes, whatever its rules (main's list judges the change). + git("checkout", "-q", "-f", "-B", "pr", main); + const wide = { + files: { "a.ts": { why: "mine", added: ["anything: 1,"] } }, + pending: { "z.ts": 9 }, + }; + const fine = commit(seams(wide), "a wider list"); + assert.equal(run(main, fine).status, 0); + // From upstream the head's list is the one in force: malformed, it is still a crash. + const broken = commit(seams({ files: SEAM, lost: { "a.ts": 3 } }), "broken"); + assert.equal(fromUpstream(main, broken).status, 3); + }); +}); + // Every upstream file on the command line, from upstream (no list there: the series' own list judges it) and // from main with a list that predates "pending" and "forkFiles" (the first run after this change). test("every upstream file counts on the command line, from upstream and from main", () => { diff --git a/docs/fork/updates.md b/docs/fork/updates.md index 0233d8ab6ec90..eb16a2e81cce9 100644 --- a/docs/fork/updates.md +++ b/docs/fork/updates.md @@ -44,7 +44,9 @@ watches; it changes nothing on the machine, and `0` turns it off. upstream file, listed or not. It runs on every pull request (Fork tests, "Workflow lint and upstream drift") and in fork-follow before and after each rebase, against the upstream commit the series sits on. A pull request is judged by its base's list, never by its own: a new seam, - `pending` or `forkFiles` entry counts once the owner merges it. `pending` maps upstream files + `pending` or `forkFiles` entry counts once the owner merges it. Its own list is only parsed: a + malformed one (bad JSON, an unknown key, a `lost` entry not in the form below, or none) is + refused, since once merged it would stop every later run. `pending` maps upstream files whose fork lines predate the rule to a ceiling: the most fork lines each may hold, counted from upstream (fork-follow fails above it and below it, so a pull request that moves fork lines out also lowers the ceiling in the same change). Right after a rebase, below the ceiling is only a From a7cdb88ebe2b7eb3d3718dd073bc887a4e12624b Mon Sep 17 00:00:00 2001 From: scuttletoby <123843277+scuttletoby@users.noreply.github.com> Date: Tue, 17 Nov 2026 23:30:32 +0100 Subject: [PATCH 2/3] fork: give upstream lines back in pending files (#385) From upstream (as fork-follow runs the seam check) these files lost upstream lines that the fork did not need to touch: - OrchestratorMcpService.ts: delegate_task's generator stays hugged by Effect.fn (Effect.scoped as its pipeable on the closing line), so upstream's 141 re-indented lines come back unchanged; the paced target is named pacedTarget so upstream's `target` lines stay. 147 lost lines -> 4. - EffectWorker.ts: the admitted claim is built first, so upstream's pipe chain keeps its indentation. 8 -> 2. - Imports the fork extended now add a line of their own beside upstream's (ChatMarkdown.tsx, cliRelease test; a split that would grow a file on a pull request is left for later), and runtimeLayer.test.ts keeps upstream's import order. No behaviour change. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/mcp/OrchestratorMcpService.ts | 340 +++++++++--------- .../src/orchestration-v2/EffectWorker.ts | 25 +- .../src/orchestration-v2/runtimeLayer.test.ts | 2 +- apps/web/src/components/ChatMarkdown.tsx | 17 +- packages/shared/src/cliRelease.test.ts | 11 +- 5 files changed, 190 insertions(+), 205 deletions(-) diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts index 89916114e4d06..258af7000c593 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.ts @@ -2553,188 +2553,184 @@ const make = Effect.gen(function* () { }, }; }), - delegateTask: Effect.fn("OrchestratorMcpService.delegateTask")( - function* (callerScope, input) { - const environmentId = - input.target === undefined - ? undefined - : PeerForwarding.remoteTarget(callerScope, input.target.environmentId); - if (input.target !== undefined && environmentId !== undefined) { - yield* requireCapability(callerScope); - const scope = yield* requireThreadScope(callerScope, "delegate_task"); - // The task's child runs as an ordinary thread there; this thread keeps the task. - const { taskId } = yield* remoteDelegation.delegate(scope, { - ...input, - target: { ...input.target, environmentId }, - }); - return yield* input.mode === "wait" - ? awaitTask(scope, taskId, taskId, input.timeoutMs) - : readTask(scope, taskId, false, true); - } - const { scope, parent } = yield* loadThreadCaller(callerScope, "delegate_task"); - if ( - input.target?.projectId !== undefined && - input.target.projectId !== parent.thread.projectId - ) { - return yield* failure( - "invalid_request", - "A local task runs in this thread's project. Omit target.projectId, or pass target.environmentId to run it in that environment's project.", - ); - } - const parentRun = parent.runs - .filter(ThreadManagementService.isActiveRun) - .toSorted((left, right) => right.ordinal - left.ordinal)[0]; - if ( - parentRun === undefined || - parentRun.rootNodeId === null || - parentRun.providerInstanceId !== scope.thread.providerInstanceId - ) { - return yield* failure( - "parent_not_active", - "Delegated tasks require an active run owned by this MCP provider session.", - ); - } - const providers = yield* loadProviders; - const key = yield* requestKey(input.clientRequestId); - const commandId = stableCommandId({ - scope, - requestKey: key, - operation: "delegate-task", - }); - const isRetryOfAcceptedDelegation = yield* threadManagement.hasReceipt(commandId); - const requestedTarget = yield* resolveTargetRechecking({ - parent, - target: input.target, - providers, - skipProjectEnablementFilter: isRetryOfAcceptedDelegation, + // Fork: `Effect.scoped` closes the hold of a call that stops half-way (fork/delegateChecks.ts). + delegateTask: Effect.fn("OrchestratorMcpService.delegateTask")(function* (callerScope, input) { + const environmentId = + input.target === undefined + ? undefined + : PeerForwarding.remoteTarget(callerScope, input.target.environmentId); + if (input.target !== undefined && environmentId !== undefined) { + yield* requireCapability(callerScope); + const scope = yield* requireThreadScope(callerScope, "delegate_task"); + // The task's child runs as an ordinary thread there; this thread keeps the task. + const { taskId } = yield* remoteDelegation.delegate(scope, { + ...input, + target: { ...input.target, environmentId }, }); - const runtimeMode = yield* resolveRuntimeMode( - parent.thread.runtimeMode, - input.runtimeMode, - requestedTarget, + return yield* input.mode === "wait" + ? awaitTask(scope, taskId, taskId, input.timeoutMs) + : readTask(scope, taskId, false, true); + } + const { scope, parent } = yield* loadThreadCaller(callerScope, "delegate_task"); + if ( + input.target?.projectId !== undefined && + input.target.projectId !== parent.thread.projectId + ) { + return yield* failure( + "invalid_request", + "A local task runs in this thread's project. Omit target.projectId, or pass target.environmentId to run it in that environment's project.", ); - const interactionMode = yield* resolveInteractionMode( - parent.thread.interactionMode, - input.interactionMode, + } + const parentRun = parent.runs + .filter(ThreadManagementService.isActiveRun) + .toSorted((left, right) => right.ordinal - left.ordinal)[0]; + if ( + parentRun === undefined || + parentRun.rootNodeId === null || + parentRun.providerInstanceId !== scope.thread.providerInstanceId + ) { + return yield* failure( + "parent_not_active", + "Delegated tasks require an active run owned by this MCP provider session.", ); - // Fork: seat 1 of the fork's delegation checks (fork/delegateChecks.ts), before the workspace. - const { target, note: usagePacingNote } = yield* delegateChecks.beforeWorkspace({ - isRetry: isRetryOfAcceptedDelegation, - parent, - requested: input.target, - runtimeMode: input.runtimeMode, - providers, - target: requestedTarget, - }); - let workspaceStrategy: OrchestrationV2ThreadLaunchWorkspaceStrategy | undefined; - if (input.isolation === "worktree" && !isRetryOfAcceptedDelegation) { - const project = yield* requireProject(parent.thread.projectId); - const base = yield* gitDriver - .resolveCommit({ - cwd: parent.thread.worktreePath ?? project.workspaceRoot, - revision: "HEAD", - }) + } + const providers = yield* loadProviders; + const key = yield* requestKey(input.clientRequestId); + const commandId = stableCommandId({ + scope, + requestKey: key, + operation: "delegate-task", + }); + const isRetryOfAcceptedDelegation = yield* threadManagement.hasReceipt(commandId); + const target = yield* resolveTargetRechecking({ + parent, + target: input.target, + providers, + skipProjectEnablementFilter: isRetryOfAcceptedDelegation, + }); + const runtimeMode = yield* resolveRuntimeMode( + parent.thread.runtimeMode, + input.runtimeMode, + target, + ); + const interactionMode = yield* resolveInteractionMode( + parent.thread.interactionMode, + input.interactionMode, + ); + // Fork: seat 1 of the fork's delegation checks (fork/delegateChecks.ts), before the workspace. + const { target: pacedTarget, note: usagePacingNote } = yield* delegateChecks.beforeWorkspace({ + isRetry: isRetryOfAcceptedDelegation, + parent, + requested: input.target, + runtimeMode: input.runtimeMode, + providers, + target, + }); + let workspaceStrategy: OrchestrationV2ThreadLaunchWorkspaceStrategy | undefined; + if (input.isolation === "worktree" && !isRetryOfAcceptedDelegation) { + const project = yield* requireProject(parent.thread.projectId); + const base = yield* gitDriver + .resolveCommit({ + cwd: parent.thread.worktreePath ?? project.workspaceRoot, + revision: "HEAD", + }) + .pipe( + Effect.mapError(() => + failure("invalid_request", "Unable to resolve the parent checkout commit."), + ), + ); + // Launch preparation creates the worktree from the project root, so a + // parent checkout in another repository (such as a Git folder inside + // Scratch) would hand it a commit it cannot find. + if (parent.thread.worktreePath !== null) { + yield* gitDriver + .resolveCommit({ cwd: project.workspaceRoot, revision: base.commitSha }) .pipe( Effect.mapError(() => - failure("invalid_request", "Unable to resolve the parent checkout commit."), + failure( + "invalid_request", + `Isolation "worktree" creates the child checkout in project "${project.title}" (${project.workspaceRoot}), which does not contain the parent checkout's commit. Use isolation "shared" to work in the parent's checkout.`, + ), ), ); - // Launch preparation creates the worktree from the project root, so a - // parent checkout in another repository (such as a Git folder inside - // Scratch) would hand it a commit it cannot find. - if (parent.thread.worktreePath !== null) { - yield* gitDriver - .resolveCommit({ cwd: project.workspaceRoot, revision: base.commitSha }) - .pipe( - Effect.mapError(() => - failure( - "invalid_request", - `Isolation "worktree" creates the child checkout in project "${project.title}" (${project.workspaceRoot}), which does not contain the parent checkout's commit. Use isolation "shared" to work in the parent's checkout.`, - ), - ), - ); - } - workspaceStrategy = { type: "worktree", baseRef: base.commitSha, startFromOrigin: false }; } - // Fork: seat 2 of the fork's delegation checks, last before the dispatch. Its hold lasts - // until the dispatch and the child's run preparation end, or the call's scope closes. - const forkHold = yield* delegateChecks.afterWorkspace({ - isRetry: isRetryOfAcceptedDelegation, - callerThreadId: scope.thread.threadId, - target, - }); - // ThreadManagementService.dispatch is the chokepoint for this command - // type's own enablement check, using the same command id and its - // receipt-replay exemption, so no separate assert runs here. - const result = yield* threadManagement - .dispatch({ - type: "delegated_task.request", - createdBy: "agent", - creationSource: "mcp", - commandId, - parentThreadId: scope.thread.threadId, - parentRunId: parentRun.id, - parentNodeId: parentRun.rootNodeId, - task: taskPrompt(input), - ...(input.title === undefined ? {} : { title: input.title }), - modelSelection: target.modelSelection, - runtimeMode, - interactionMode, - ...(workspaceStrategy === undefined ? {} : { workspaceStrategy }), - // Async delegations wake the parent on every child terminal; wait - // delegations deliver through the blocking tool call until `awaitTask` - // gives up the wait (timeout, cancelled call) and upgrades the wake. - completionWake: input.mode === "wait" ? "settled_only" : "always", - }) - .pipe( - Effect.mapError((error) => - error._tag === "ThreadManagementProviderInstanceDisabledError" - ? threadManagementFailure(error) - : failure( - "orchestration_error", - `Unable to create delegated task: ${userFacingDispatchErrorMessage(error) ?? errorMessage(error)}`, - ), - ), - ); - const taskEvent = result.storedEvents.find( - (stored) => - stored.event.type === "subagent.updated" && stored.event.payload.origin === "app_owned", + workspaceStrategy = { type: "worktree", baseRef: base.commitSha, startFromOrigin: false }; + } + // Fork: seat 2 of the fork's delegation checks, last before the dispatch. Its hold lasts + // until the dispatch and the child's run preparation end, or the call's scope closes. + const forkHold = yield* delegateChecks.afterWorkspace({ + isRetry: isRetryOfAcceptedDelegation, + callerThreadId: scope.thread.threadId, + target: pacedTarget, + }); + // ThreadManagementService.dispatch is the chokepoint for this command + // type's own enablement check, using the same command id and its + // receipt-replay exemption, so no separate assert runs here. + const result = yield* threadManagement + .dispatch({ + type: "delegated_task.request", + createdBy: "agent", + creationSource: "mcp", + commandId, + parentThreadId: scope.thread.threadId, + parentRunId: parentRun.id, + parentNodeId: parentRun.rootNodeId, + task: taskPrompt(input), + ...(input.title === undefined ? {} : { title: input.title }), + modelSelection: pacedTarget.modelSelection, + runtimeMode, + interactionMode, + ...(workspaceStrategy === undefined ? {} : { workspaceStrategy }), + // Async delegations wake the parent on every child terminal; wait + // delegations deliver through the blocking tool call until `awaitTask` + // gives up the wait (timeout, cancelled call) and upgrades the wake. + completionWake: input.mode === "wait" ? "settled_only" : "always", + }) + .pipe( + Effect.mapError((error) => + error._tag === "ThreadManagementProviderInstanceDisabledError" + ? threadManagementFailure(error) + : failure( + "orchestration_error", + `Unable to create delegated task: ${userFacingDispatchErrorMessage(error) ?? errorMessage(error)}`, + ), + ), ); - if (taskEvent?.event.type !== "subagent.updated") { - return yield* failure( - "orchestration_error", - "Delegated task command did not produce a task projection.", - ); - } - const taskId = taskEvent.event.payload.id; - const childThreadId = taskEvent.event.payload.childThreadId; - if (childThreadId !== null) yield* forkHold.started(childThreadId); - const childRunEvent = result.storedEvents.find( - (stored) => - stored.event.type === "run.created" && stored.event.threadId === childThreadId, + const taskEvent = result.storedEvents.find( + (stored) => + stored.event.type === "subagent.updated" && stored.event.payload.origin === "app_owned", + ); + if (taskEvent?.event.type !== "subagent.updated") { + return yield* failure( + "orchestration_error", + "Delegated task command did not produce a task projection.", ); - if ( - childThreadId !== null && - childRunEvent?.event.type === "run.created" && - childRunEvent.event.payload.workspacePreparation !== undefined - ) { - yield* threadLaunch.prepareRun({ - commandId, - threadId: childThreadId, - runId: childRunEvent.event.payload.id, - }); - } - // Fork: the dispatch is done; a named child keeps counting until its run shows. - yield* forkHold.release; - - const task = yield* input.mode === "wait" - ? awaitTask(scope, taskId, key, input.timeoutMs) - : readTask(scope, taskId, false, true); - return usagePacingNote === undefined ? task : { ...task, usagePacingNote }; - }, - // Fork: closes the hold of a call that stops half-way (fork/delegateChecks.ts). - Effect.scoped, - ), + } + const taskId = taskEvent.event.payload.id; + const childThreadId = taskEvent.event.payload.childThreadId; + if (childThreadId !== null) yield* forkHold.started(childThreadId); + const childRunEvent = result.storedEvents.find( + (stored) => stored.event.type === "run.created" && stored.event.threadId === childThreadId, + ); + if ( + childThreadId !== null && + childRunEvent?.event.type === "run.created" && + childRunEvent.event.payload.workspacePreparation !== undefined + ) { + yield* threadLaunch.prepareRun({ + commandId, + threadId: childThreadId, + runId: childRunEvent.event.payload.id, + }); + } + // Fork: the dispatch is done; a named child keeps counting until its run shows. + yield* forkHold.release; + + const task = yield* input.mode === "wait" + ? awaitTask(scope, taskId, key, input.timeoutMs) + : readTask(scope, taskId, false, true); + return usagePacingNote === undefined ? task : { ...task, usagePacingNote }; + }, Effect.scoped), taskStatus: Effect.fn("OrchestratorMcpService.taskStatus")(function* (callerScope, taskId) { const scope = yield* requireThreadScope(callerScope, "task_status"); return yield* readTask(scope, taskId, false, true); diff --git a/apps/server/src/orchestration-v2/EffectWorker.ts b/apps/server/src/orchestration-v2/EffectWorker.ts index fcdf5d9db91d3..737fe9c1dcd48 100644 --- a/apps/server/src/orchestration-v2/EffectWorker.ts +++ b/apps/server/src/orchestration-v2/EffectWorker.ts @@ -973,21 +973,18 @@ const runRegisteredDaemon = (options: OrchestrationEffectDaemonOptions) => // The slot wait starts once the gate admits the claim: a held gate keeps one waiting // claim per slot, not one more per wait. const admitted = yield* Deferred.make(); - const attempt = yield* admission - .admit( - Deferred.succeed(admitted, undefined).pipe( - Effect.andThen(worker.runOnce(claimLimits)), - ), - ) - .pipe( - Effect.map((worked) => (worked ? ("worked" as const) : ("idle" as const))), - Effect.catchCause((cause) => - Effect.logWarning("Orchestration effect worker failed", cause).pipe( - Effect.as("failed" as const), - ), + const admittedRunOnce = admission.admit( + Deferred.succeed(admitted, undefined).pipe(Effect.andThen(worker.runOnce(claimLimits))), + ); + const attempt = yield* admittedRunOnce.pipe( + Effect.map((worked) => (worked ? ("worked" as const) : ("idle" as const))), + Effect.catchCause((cause) => + Effect.logWarning("Orchestration effect worker failed", cause).pipe( + Effect.as("failed" as const), ), - Effect.forkIn(scope), - ); + ), + Effect.forkIn(scope), + ); yield* Effect.raceFirst( Deferred.await(admitted), Fiber.await(attempt).pipe(Effect.asVoid), diff --git a/apps/server/src/orchestration-v2/runtimeLayer.test.ts b/apps/server/src/orchestration-v2/runtimeLayer.test.ts index 4cd2f06852823..4b944b8cc1c28 100644 --- a/apps/server/src/orchestration-v2/runtimeLayer.test.ts +++ b/apps/server/src/orchestration-v2/runtimeLayer.test.ts @@ -42,9 +42,9 @@ import * as Effect from "effect/Effect"; import * as DateTime from "effect/DateTime"; import * as Deferred from "effect/Deferred"; import * as Fiber from "effect/Fiber"; +import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; import * as Option from "effect/Option"; -import * as FileSystem from "effect/FileSystem"; import * as Path from "effect/Path"; import * as Queue from "effect/Queue"; import * as Stream from "effect/Stream"; diff --git a/apps/web/src/components/ChatMarkdown.tsx b/apps/web/src/components/ChatMarkdown.tsx index 2651ba74d86ad..f1274c9de815c 100644 --- a/apps/web/src/components/ChatMarkdown.tsx +++ b/apps/web/src/components/ChatMarkdown.tsx @@ -114,7 +114,8 @@ import { import { ExpandedImageDialog } from "./chat/ExpandedImageDialog"; import { markdownImageGallery } from "./chat/markdownImageGallery"; import { type MediaActionSource } from "./media/MediaActions"; -import { downloadFile, resolveProtocolRelativeMediaUrl } from "./media/mediaContent"; +import { resolveProtocolRelativeMediaUrl } from "./media/mediaContent"; +import { downloadFile } from "./media/mediaContent"; // Fork import { revealInFileExplorerLabelForKind, revealInFileExplorerLabelForOs, @@ -157,12 +158,8 @@ import { readLocalApi } from "../localApi"; import { appAtomRegistry } from "../rpc/atomRegistry"; import { hostEnvironmentIdAtom } from "../state/primaryEnvironment"; import { cn } from "../lib/utils"; -import { - openRemoteEditorUrl, - resolveRemoteOpenState, - useRemoteCapableEditors, - useRemoteOpenResolution, -} from "../remoteOpen"; +import { resolveRemoteOpenState, useRemoteOpenResolution } from "../remoteOpen"; +import { openRemoteEditorUrl, useRemoteCapableEditors } from "../remoteOpen"; // Fork import { useRightPanelStore } from "../rightPanelStore"; import { readThreadShell, useProjects } from "../state/entities"; import { serverEnvironment } from "../state/server"; @@ -219,10 +216,8 @@ import { } from "./chat/ChatMarkdownMedia"; import { MarkdownExternalLinkContent } from "./chat/MarkdownExternalLink"; import { MarkdownFileLink } from "./chat/MarkdownFileLink"; -import { - canUseMarkdownFileShellActions, - markdownFileRemoteEditorUrl, -} from "./chat/MarkdownFileLink.logic"; +import { canUseMarkdownFileShellActions } from "./chat/MarkdownFileLink.logic"; +import { markdownFileRemoteEditorUrl } from "./chat/MarkdownFileLink.logic"; // Fork import { rehypeChipPunctuation } from "./chat/markdownChipPunctuation"; import { handleMarkdownFragmentClick, rehypeHeadingIds } from "./chat/markdownFragments"; import { rehypeTextDirection } from "./chat/markdownTextDirection"; diff --git a/packages/shared/src/cliRelease.test.ts b/packages/shared/src/cliRelease.test.ts index 5b59e3b767035..eb67549241dda 100644 --- a/packages/shared/src/cliRelease.test.ts +++ b/packages/shared/src/cliRelease.test.ts @@ -1,11 +1,8 @@ -import { afterEach, describe, expect, it, vi } from "vite-plus/test"; +import { describe, expect, it } from "vite-plus/test"; +import { afterEach, vi } from "vite-plus/test"; // Fork -import { - cliArchiveTarCommand, - newestCliReleaseVersion, - parseChecksums, - resolveCliReleaseRepository, -} from "./cliRelease.ts"; +import { cliArchiveTarCommand, newestCliReleaseVersion, parseChecksums } from "./cliRelease.ts"; +import { resolveCliReleaseRepository } from "./cliRelease.ts"; // Fork describe("cliRelease", () => { it("parses sha256sum output including binary-mode markers", () => { From 5c9ff938985425c585dd5912f921d59a7ac1bb13 Mon Sep 17 00:00:00 2001 From: scuttletoby <123843277+scuttletoby@users.noreply.github.com> Date: Tue, 17 Nov 2026 23:30:32 +0100 Subject: [PATCH 3/3] fork seams: the list fits main from upstream (lost block, ceilings, 3 files) (#385) `fork-seam-check.cjs --from-upstream HEAD` (fork-follow's run) refused main. Now it exits 0: - cli/connect.ts and cloud/CloudLink.ts (#313, also before #277) are seam files with their 5 fork lines each; cloud/linkEnvironment.test.ts (#313) is pending (34). - Pending ceilings set to the counts from upstream: raised where #318 and #332 grew a file before #277 set the counts (SettingsPanels, scopedSettings and its test, useScopedSettings, shared/package.json), lowered where the previous commit gave lines back. - A "lost" block in the {"lines", "gone"} form: 34 files, 20 lines that may move unseen (166 in the block #380 proposed). Co-Authored-By: Claude Opus 5.5 --- .github/fork-seams.json | 180 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 170 insertions(+), 10 deletions(-) diff --git a/.github/fork-seams.json b/.github/fork-seams.json index 80212515519c3..49e7018b17544 100644 --- a/.github/fork-seams.json +++ b/.github/fork-seams.json @@ -90,6 +90,26 @@ ": { unit: tracked.unit, slice: ownedSlice };", "})," ] + }, + "apps/server/src/cli/connect.ts": { + "why": "A server held with `serve --hold-work` shares the live server's environment id, so `t3 connect --disconnect` refuses before the relay delete (cloud/holdWorkConnect.ts).", + "added": [ + "import * as HoldWorkConnect from \"../cloud/holdWorkConnect.ts\";", + "// Fork: a held copy shares the live server's environment id; refuse before the relay delete.", + "yield* HoldWorkConnect.refuseCliUnlinkWhileHeld(", + "(yield* ServerConfig.ServerConfig).serverRuntimeStatePath,", + ");" + ] + }, + "apps/server/src/cloud/CloudLink.ts": { + "why": "unlink's error type takes the hold-work refusal (cloud/holdWorkConnect.ts); the one upstream line is split so the fork's error sits on its own line.", + "added": [ + "readonly unlink: () => Effect.Effect<", + "EnvironmentCloudRelayConfigResult,", + "// Fork: a server held with `serve --hold-work` refuses (cloud/holdWorkConnect.ts).", + "CloudLinkInternalError | ManagedLimits.ManagedPolicyRefusedError", + ">;" + ] } }, "//pending": "Upstream files whose fork lines predate counting every upstream file, each with its ceiling: the most fork lines it may hold against upstream (counted from upstream, as fork-follow runs the check). To move into fork files or pin as seams; lower a ceiling when lines move out and take a file off when none are left. A pull request may change them but not grow them.", @@ -106,10 +126,10 @@ "apps/server/src/cloud/selfUpdate.ts": 4, "apps/server/src/config.ts": 2, "apps/server/src/mcp/McpHttpServer.ts": 10, - "apps/server/src/mcp/OrchestratorMcpService.ts": 41, + "apps/server/src/mcp/OrchestratorMcpService.ts": 35, "apps/server/src/mcp/toolkits/environment/handlers.test.ts": 63, "apps/server/src/mcp/toolkits/project/handlers.test.ts": 48, - "apps/server/src/orchestration-v2/EffectWorker.ts": 31, + "apps/server/src/orchestration-v2/EffectWorker.ts": 28, "apps/server/src/orchestration-v2/ProjectionStore.ts": 7, "apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts": 435, "apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts": 152, @@ -132,17 +152,18 @@ "apps/server/src/serverRuntimeState.ts": 4, "apps/server/src/terminal/Manager.ts": 2, "apps/server/vite.config.ts": 2, + "apps/web/src/cloud/linkEnvironment.test.ts": 34, "apps/web/src/components/ChatMarkdown.permissions.browser.test.tsx": 277, - "apps/web/src/components/ChatMarkdown.tsx": 71, + "apps/web/src/components/ChatMarkdown.tsx": 63, "apps/web/src/components/chat/MarkdownFileLink.logic.ts": 74, "apps/web/src/components/chat/MarkdownFileLink.tsx": 148, "apps/web/src/components/media/mediaContent.ts": 8, "apps/web/src/components/settings/IntervalSecondsField.tsx": 4, - "apps/web/src/components/settings/SettingsPanels.tsx": 2, - "apps/web/src/components/settings/scopedSettings.test.ts": 57, - "apps/web/src/components/settings/scopedSettings.ts": 5, + "apps/web/src/components/settings/SettingsPanels.tsx": 4, + "apps/web/src/components/settings/scopedSettings.test.ts": 153, + "apps/web/src/components/settings/scopedSettings.ts": 9, "apps/web/src/components/settings/settingsSearch.ts": 25, - "apps/web/src/components/settings/useScopedSettings.ts": 14, + "apps/web/src/components/settings/useScopedSettings.ts": 27, "apps/web/src/index.css": 2, "apps/web/src/markdown-links.test.ts": 1, "apps/web/src/markdownFileHostPath.ts": 1, @@ -157,8 +178,8 @@ "packages/provider-core/src/server/managedProvider.test.ts": 39, "packages/provider-core/src/server/managedProvider.ts": 8, "packages/provider-core/src/server/snapshot.ts": 2, - "packages/shared/package.json": 28, - "packages/shared/src/cliRelease.test.ts": 43, + "packages/shared/package.json": 32, + "packages/shared/src/cliRelease.test.ts": 38, "packages/shared/src/cliRelease.ts": 11, "packages/shared/src/usageLimits.ts": 12, "vite.config.ts": 2 @@ -206,5 +227,144 @@ "packages/shared/src/waitFor*", "scripts/lib/release-repository.ts", "scripts/release-repository.test.ts" - ] + ], + "//lost": "Seam and pending files that lost upstream lines, counted from upstream (as fork-follow runs the check): \"lines\", the upstream lines not kept in order and indentation; \"gone\", those whose text is gone. Held exactly, like a ceiling; an unlisted file counts 0. Lower a count when a line comes back, and keep each one small: a line counted here may move unseen.", + "lost": { + "packages/shared/src/serverSettings.ts": { + "lines": 1, + "gone": 1 + }, + "apps/server/src/serverSettings.ts": { + "lines": 10, + "gone": 8 + }, + "apps/server/src/cloud/CloudLink.ts": { + "lines": 1, + "gone": 1 + }, + "apps/desktop/src/electron/ElectronShell.ts": { + "lines": 1, + "gone": 1 + }, + "apps/server/src/background/BackgroundPolicy.ts": { + "lines": 1, + "gone": 1 + }, + "apps/server/src/cli/server.ts": { + "lines": 4, + "gone": 4 + }, + "apps/server/src/mcp/McpHttpServer.ts": { + "lines": 1, + "gone": 1 + }, + "apps/server/src/mcp/OrchestratorMcpService.ts": { + "lines": 4, + "gone": 4 + }, + "apps/server/src/orchestration-v2/EffectWorker.ts": { + "lines": 2, + "gone": 1 + }, + "apps/server/src/orchestration-v2/ProjectionStore.ts": { + "lines": 1, + "gone": 1 + }, + "apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts": { + "lines": 1, + "gone": 1 + }, + "apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts": { + "lines": 5, + "gone": 5 + }, + "apps/server/src/orchestration-v2/ThreadLaunchService.ts": { + "lines": 7, + "gone": 3 + }, + "apps/server/src/orchestration-v2/ThreadManagementService.ts": { + "lines": 1, + "gone": 1 + }, + "apps/server/src/processRunner.ts": { + "lines": 2, + "gone": 2 + }, + "apps/server/src/scheduling/DueHint.ts": { + "lines": 1, + "gone": 1 + }, + "apps/server/src/server.ts": { + "lines": 6, + "gone": 6 + }, + "apps/server/src/serverRuntimeStartup.ts": { + "lines": 6, + "gone": 2 + }, + "apps/server/src/serverRuntimeState.ts": { + "lines": 1, + "gone": 1 + }, + "apps/server/src/terminal/Manager.ts": { + "lines": 1, + "gone": 1 + }, + "apps/web/src/components/ChatMarkdown.permissions.browser.test.tsx": { + "lines": 9, + "gone": 9 + }, + "apps/web/src/components/ChatMarkdown.tsx": { + "lines": 2, + "gone": 1 + }, + "apps/web/src/components/chat/MarkdownFileLink.logic.ts": { + "lines": 22, + "gone": 20 + }, + "apps/web/src/components/chat/MarkdownFileLink.tsx": { + "lines": 32, + "gone": 28 + }, + "apps/web/src/components/media/mediaContent.ts": { + "lines": 1, + "gone": 1 + }, + "apps/web/src/components/settings/IntervalSecondsField.tsx": { + "lines": 1, + "gone": 1 + }, + "apps/web/src/components/settings/scopedSettings.ts": { + "lines": 3, + "gone": 3 + }, + "apps/web/src/components/settings/useScopedSettings.ts": { + "lines": 5, + "gone": 5 + }, + "apps/web/src/remoteOpen.test.ts": { + "lines": 2, + "gone": 2 + }, + "apps/web/src/remoteOpen.ts": { + "lines": 1, + "gone": 1 + }, + "packages/contracts/src/editor.ts": { + "lines": 5, + "gone": 5 + }, + "packages/provider-core/src/server/managedProvider.ts": { + "lines": 10, + "gone": 8 + }, + "packages/shared/src/cliRelease.ts": { + "lines": 1, + "gone": 1 + }, + "packages/shared/src/usageLimits.ts": { + "lines": 1, + "gone": 1 + } + } }