Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
37bfabe
feat(contracts): fields and shared rules for child reports, access an…
badcuban Nov 23, 2026
1741985
feat(contracts): keep the access limit on linked sends and record owe…
badcuban Nov 23, 2026
077fd8a
feat(web): Stop counts every thread still going, and the family row g…
badcuban Nov 23, 2026
a28ddc1
fix(web): Stop counts what the stop settles, and a person's queued or…
badcuban Nov 23, 2026
47f50bc
feat(server): a child's later turns report to its parent
badcuban Nov 23, 2026
3ba72fe
fix(server): settle child reports only where turns are known, and kee…
badcuban Nov 23, 2026
34a4b7b
fix(server): bind a turn's message only when its writer names it, and…
badcuban Nov 23, 2026
3fddb66
fix(server): put a report whose start died back at the front, and kno…
badcuban Nov 23, 2026
393e13a
docs: note what was added to rule A while building, and the bind's field
badcuban Nov 23, 2026
c90d3d3
fix(server): the third review of step 2 (child reports)
badcuban Nov 23, 2026
a16e29d
fix(server): only the writer that sent a message names its turn
badcuban Nov 23, 2026
53e3ecf
feat(server): hold child thread requests and continues to the sender'…
badcuban Nov 23, 2026
ad4554e
feat(server): stop reaches families, loose threads, and saved check-b…
badcuban Nov 23, 2026
1340e5f
Merge branch 'feat/child-reports-stage-1-web' into feat/child-reports…
badcuban Nov 23, 2026
a56b804
test(server): expect saved check-backs to stay dormant without a capa…
badcuban Nov 23, 2026
e4852e8
fix(server): close Stage 1 access, dormant check-back, stop, and move…
badcuban Nov 23, 2026
ca9da4f
fix(server): emit session/exited when Codex app-server dies from a si…
badcuban Nov 23, 2026
1ea9bbc
Merge remote-tracking branch 'origin/main' into feat/child-reports-st…
badcuban Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ Whether the thread's agent may bring in another model on its own is {place:threa

Once a thread it started has finished, the agent can wrap it up itself (thread_wrap), so you don't have to. It moves to Wrapped as with your own Wrap up, and its answer counts as seen. You can reopen it, and it comes back by itself when it gets new work. A thread still working or waiting for you isn't wrapped up.

A thread that keeps working after its answer went back (a check-back woke it, or a reviewer it asked replied) doesn't wake the parent. Its latest reply is passed to the parent's agent at that agent's next turn, and the thread then wraps up by itself. A thread the agent stops with thread_stop wraps up by itself too, and its check-backs end, as with your Stop.
A thread that takes another turn on its own after its answer went back (a check-back woke it, or a reviewer it asked replied) wakes its parent with that reply too, and then wraps up by itself. A thread the agent stops with thread_stop wraps up by itself too, and its check-backs end, as with your Stop.

{place:threads.agentThreads} decides this: Off, Ask me first (a card in the chat lists the threads and you decide), or Automatic. The same setting covers agents creating or changing scheduled tasks. There's no limit on how many threads an agent starts or how many messages it sends them, so an agent can keep a team of threads going for hours without you writing. Stop on the parent stops its agent and its threads' answers coming back, but the threads keep working; "Stop N working threads" in the parent's menu stops them too.
{place:threads.agentThreads} decides this: Off, Ask me first (a card in the chat lists the threads and you decide), or Automatic. The same setting covers agents creating or changing scheduled tasks. There's no limit on how many threads an agent starts or how many messages it sends them, so an agent can keep a team of threads going for hours without you writing. Stop on a thread stops its agent and every thread under it that is still going (including a thread it started without report back until you write in it, and any thread that only holds a check-back); "Stop N working threads" in the thread's menu and the Stop button on the family tab row stop those threads while leaving the thread itself running. A thread can't be reverted while threads under it are still going.

A started thread works in a worktree of its own; in a project without git it shares the project's folder. With {place:threads.agentThreadsShareWorktrees} on, an agent can instead put a thread in a checkout that already exists: its own, or that of a thread it started. The new thread sees the files as they are there, uncommitted changes included, which suits a reviewer for work another thread just finished. An agent can also move an idle thread into such a checkout with a message, and the thread keeps its conversation. The thread the checkout belongs to must not be working at that moment. No worktree or branch is made and the project's setup script does not run. The two threads then share one set of files, so only one should work at a time. The thread's row under the message box reads Shared worktree. This works on one computer only, and not for threads an outside agent starts.

Expand Down Expand Up @@ -141,7 +141,7 @@ A project's lead chat is a thread set up to coordinate the project; see the lead

Any thread can be the lead. The first time a thread in a project with no lead starts threads of its own, a line under its tabs offers to make it the lead; close it and it doesn't come back for that project. Or use "Make this the lead chat" in a thread's menu (right-click its row, or click the title above the chat), or the command palette. The project's menu in the project picker has Open lead chat, or New lead chat, which starts a thread in the project folder and makes it the lead. "Go to lead chat" in the command palette opens it.

The lead can also pass a message to a thread you started by hand in the project. That is one-way: the thread works on it and answers there, not back in the lead, and it can't start threads of its own for it until you write there. The lead can't pass work into a room, a thread another thread still owns, or one you stopped. A pass never runs with more access than the lead had.
The lead can also pass a message to a thread you started by hand in the project. That is one-way: the thread works on it and answers there, not back in the lead, and it can't start threads of its own for it until you write there (and neither can the threads it messages). The lead can't pass work into a room, a thread another thread still owns, or one you stopped. A pass never runs with more access than the lead had.

When an agent asks to start several threads, the card has a checkbox per thread, so you can start some and leave the rest; the agent is told which.

Expand Down
4 changes: 4 additions & 0 deletions apps/server/src/links/LinkMoves.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,10 @@ describe("a thread moving across its link (Part 3f, (h))", () => {
environmentLabel: "Windows PC",
threadId: PARENT_THERE,
threadTitle: "Ship it",
launchedAccess: {
runtimeMode: "auto-accept-edits",
interactionMode: "default",
},
});
assert.equal(imported.movedFrom.environmentId, WINDOWS);
assert.equal(imported.movedFrom.environmentPinned, true);
Expand Down
6 changes: 6 additions & 0 deletions apps/server/src/links/LinkMoves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,10 @@ const make = Effect.gen(function* () {
projectId: string,
pinnedEnvironmentId: string | null,
fromLabel: string,
launchedAccess: {
readonly runtimeMode: RuntimeMode;
readonly interactionMode: ProviderInteractionMode;
},
) =>
Effect.gen(function* () {
const lineage = row.manifest.linkLineage;
Expand All @@ -2388,6 +2392,7 @@ const make = Effect.gen(function* () {
environmentLabel: fromLabel,
threadId: remoteParent.threadId,
threadTitle: remoteParent.title,
launchedAccess,
};
return { remoteOrigin };
}
Expand Down Expand Up @@ -2771,6 +2776,7 @@ const make = Effect.gen(function* () {
land.project.id,
authority.pinnedEnvironmentId,
fromLabel,
{ runtimeMode: capped.runtimeMode, interactionMode: capped.interactionMode },
);
if (across.left !== undefined) familyLeft.push(across.left);
// The threads it started here that may be its children again (Part 3f,
Expand Down
52 changes: 42 additions & 10 deletions apps/server/src/links/LinkRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import {
TurnId,
} from "@threadlines/contracts";
import { hasLiveCheckBack } from "@threadlines/shared/checkBacks";
import { sameRemoteThreadFiling } from "@threadlines/shared/childThreads";
import { requestCeilingRefusal, sameRemoteThreadFiling } from "@threadlines/shared/childThreads";
import { remoteThreadFilingOf } from "@threadlines/shared/threadFiling";
import * as Cause from "effect/Cause";
import * as Context from "effect/Context";
Expand Down Expand Up @@ -928,6 +928,10 @@ const make = Effect.gen(function* () {
environmentLabel: input.parent.environmentLabel,
threadId: input.parent.threadId,
threadTitle: input.parent.threadTitle,
launchedAccess: {
runtimeMode: launch.runtimeMode,
interactionMode: launch.interactionMode,
},
};
// Still open, and the link still lets it go on; a link that no
// longer does ends it here, with the reason.
Expand Down Expand Up @@ -957,6 +961,10 @@ const make = Effect.gen(function* () {
kind: "request",
environmentId: input.parent.environmentId,
},
requestCeiling: {
runtimeMode: launch.runtimeMode,
interactionMode: launch.interactionMode,
},
createdAt: row.createdAt,
checkpoint: () => mayGoOn,
}),
Expand Down Expand Up @@ -1130,6 +1138,7 @@ const make = Effect.gen(function* () {
kind: "request",
environmentId: origin.environmentId,
},
...(input.ceiling !== undefined ? { requestCeiling: input.ceiling } : {}),
createdAt: row.createdAt,
},
"queue a linked computer's message",
Expand Down Expand Up @@ -1269,6 +1278,8 @@ const make = Effect.gen(function* () {
const stopped = yield* engine
.dispatch({
type: "thread.session.stop",
// A link's stop leaves no Stop hold here.
cause: "cleanup",
commandId: CommandId.make(
`server:link-stop:${deviceId}:${thread.id}:${turnKeyOf(thread)}${
retry === undefined ? "" : `:retry:${retry}`
Expand Down Expand Up @@ -1340,6 +1351,7 @@ const make = Effect.gen(function* () {
const stopped = yield* dispatchUnlessRefused(
{
type: "thread.session.stop",
cause: "cleanup",
commandId: linkCommandId(
deviceId,
row.requestId,
Expand Down Expand Up @@ -1917,6 +1929,7 @@ const make = Effect.gen(function* () {
end: input.end,
pendingMessageId: input.pendingMessageId,
awaitedBackgroundTaskCount: input.child.session?.awaitedBackgroundTaskCount ?? 0,
continuesWaitingAnswer: true,
});
if (delivery === null) return;
const row = rows.find((entry) => entry.requestId === delivery.requestId);
Expand Down Expand Up @@ -2122,13 +2135,26 @@ const make = Effect.gen(function* () {
const deviceId = thread?.remoteOrigin?.linkDeviceId;
if (thread === undefined || deviceId === undefined) return;
const rows = yield* openRowsForThread(thread);
const storedMessage = thread.messages.find(
(entry) => entry.id === event.payload.messageId,
);
const ceilingRefusal = !thread.agentRequests.hold
? requestCeilingRefusal(
storedMessage?.requestCeiling ?? thread.remoteOrigin?.launchedAccess,
thread,
)
: null;
for (const row of rows) {
if (row.messageId !== event.payload.messageId) continue;
yield* settle(
row,
"cancelled",
`Your message to '${thread.title}' on ${ownLabel()} was taken back before it ran.`,
);
if (ceilingRefusal !== null) {
yield* settle(row, "failed", ceilingRefusal);
} else {
yield* settle(
row,
"cancelled",
`Your message to '${thread.title}' on ${ownLabel()} was taken back before it ran.`,
);
}
}
return;
}
Expand Down Expand Up @@ -2306,11 +2332,17 @@ const make = Effect.gen(function* () {
const childTurns = yield* turns
.listByThreadId({ threadId: thread.id })
.pipe(Effect.mapError(() => peerError(`${ownLabel()} couldn't read the thread's turns.`)));
const finishedTurnId = finishedTurnAfterRestart(childTurns, {
...request,
status: row.status === "awaiting_background" ? "awaiting_background" : "running",
const finishedTurnId = finishedTurnAfterRestart(
childTurns,
{
...request,
status: row.status === "awaiting_background" ? "awaiting_background" : "running",
},
{ continuesWaitingAnswer: true },
);
const delivery = childDeliveryAfterRestart(thread, request, finishedTurnId, {
continuesWaitingAnswer: true,
});
const delivery = childDeliveryAfterRestart(thread, request, finishedTurnId);
yield* settleOrFail(
row,
toOutcome(delivery.type === "thread.child-request.settle" ? delivery.outcome : "failed"),
Expand Down
117 changes: 117 additions & 0 deletions apps/server/src/links/RemoteChildReactor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ interface LinkedComputer {
readonly watch?: ReadonlyArray<PeerWatchEvent>;
/** It says how threads are filed and takes `peer.thread.wrap` (`PeerDescriptor.threadFiling`). */
readonly threadFiling?: boolean;
/** It enforces `PeerSendInput.ceiling` (`PeerDescriptor.enforcesRequestCeiling`). */
readonly enforcesRequestCeiling?: boolean;
}

/**
Expand Down Expand Up @@ -265,6 +267,9 @@ const makeComputer = Effect.gen(function* () {
linked.start ??
(() => Effect.succeed({ status: "started" as const, threadId: REMOTE_CHILD })),
),
"peer.request.send": answer("peer.request.send", () =>
Effect.succeed({ status: "queued" as const }),
),
} as unknown as PeerClient;
const layer = RemoteChildReactorLive.pipe(
Layer.provide(
Expand All @@ -278,6 +283,9 @@ const makeComputer = Effect.gen(function* () {
describe: () =>
Effect.succeed({
threadFiling: linked.threadFiling === true,
...(linked.enforcesRequestCeiling === true
? { enforcesRequestCeiling: true }
: {}),
} as unknown as PeerDescriptor),
noteRemoteLabel: () => undefined,
}),
Expand Down Expand Up @@ -758,4 +766,113 @@ it.layer(NodeServices.layer)("RemoteChildReactor", (it) => {
assert.lengthOf((yield* computer.stored).childRequests?.open ?? [], 1);
}),
);

it.effect(
"carries the sender's ceiling to an updated peer, and refuses a narrower sender to an older peer",
() =>
Effect.gen(function* () {
const submitSend = (
computer: Effect.Success<typeof makeComputer>,
requestId: ChildRequestId,
runtimeMode: "auto-accept-edits" | "full-access",
) =>
Effect.gen(function* () {
yield* computer.askForThread;
yield* computer.recordRemote("running", {
status: "accepted",
threadId: REMOTE_CHILD,
});
yield* computer.engine.dispatch({
type: "thread.remote-child.update",
commandId: CommandId.make(`record-${requestId}`),
threadId: PARENT,
child: {
environmentId: MAC_MINI,
label: "Mac mini",
threadId: REMOTE_CHILD,
title: "Remote worker",
handle: "Claude",
attachmentEpoch: 0,
cachedStatus: "idle",
updatedAt: AT,
},
createdAt: AT,
});
yield* computer.engine.dispatch({
type: "thread.runtime-mode.set",
commandId: CommandId.make(`mode-${requestId}`),
threadId: PARENT,
runtimeMode,
createdAt: AT,
});
yield* computer.engine.dispatch({
type: "thread.session.set",
commandId: CommandId.make(`session-${requestId}`),
threadId: PARENT,
session: {
threadId: PARENT,
status: "running",
providerName: "claudeAgent",
providerInstanceId: ProviderInstanceId.make("claudeAgent"),
runtimeMode,
activeTurnId: TurnId.make("turn-1"),
lastError: null,
updatedAt: AT,
},
createdAt: AT,
});
yield* computer.engine.dispatch({
type: "thread.child.send",
commandId: CommandId.make(`send-${requestId}`),
threadId: PARENT,
requestId,
from: { participantId: null },
callerTurnId: TurnId.make("turn-1"),
childThreadId: REMOTE_CHILD,
childMessageId: MessageId.make(`msg-${requestId}`),
text: "Check the build.",
createdAt: AT,
});
});

// Narrow sender -> older peer (no enforcesRequestCeiling): refused and settled failed.
const older = yield* makeComputer;
yield* submitSend(older, ChildRequestId.make("req-older-narrow"), "auto-accept-edits");
yield* older.boot({ enforcesRequestCeiling: false });
yield* eventually(
Effect.map(
older.stored,
(parent) =>
!(parent.childRequests?.open ?? []).some(
(entry) => entry.requestId === ChildRequestId.make("req-older-narrow"),
),
),
"narrow send to older peer settles failed",
);
assert.deepEqual(older.callsTo("peer.request.send"), []);

// Widest sender -> older peer: allowed, no ceiling can be broken.
const widest = yield* makeComputer;
yield* submitSend(widest, ChildRequestId.make("req-older-wide"), "full-access");
yield* widest.boot({ enforcesRequestCeiling: false });
yield* eventually(
Effect.sync(() => widest.callsTo("peer.request.send").length === 1),
"widest send to older peer goes through",
);

// Narrow sender -> updated peer: carries ceiling.
const updated = yield* makeComputer;
yield* submitSend(updated, ChildRequestId.make("req-updated-narrow"), "auto-accept-edits");
yield* updated.boot({ enforcesRequestCeiling: true });
yield* eventually(
Effect.sync(() => updated.callsTo("peer.request.send").length === 1),
"narrow send to updated peer goes through with ceiling",
);
assert.deepEqual(
(updated.callsTo("peer.request.send")[0]?.payload as { readonly ceiling?: unknown })
?.ceiling,
{ runtimeMode: "auto-accept-edits", interactionMode: "default" },
);
}),
);
});
31 changes: 29 additions & 2 deletions apps/server/src/links/RemoteChildReactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ import {
type ThreadId,
TurnId,
} from "@threadlines/contracts";
import { remoteChildOf, sameRemoteThreadFiling } from "@threadlines/shared/childThreads";
import {
effectiveRequestCeiling,
isWidestMode,
olderPeerCeilingRefusal,
remoteChildOf,
sameRemoteThreadFiling,
} from "@threadlines/shared/childThreads";
import * as Cause from "effect/Cause";
import * as Context from "effect/Context";
import * as Data from "effect/Data";
Expand Down Expand Up @@ -98,7 +104,10 @@ export class RemoteChildReactor extends Context.Service<
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);

/** What the reactor needs of a parent, read from its stored row. */
type Parent = Pick<OrchestrationThread, "id" | "title" | "participants" | "childRequests"> &
type Parent = Pick<
OrchestrationThread,
"id" | "title" | "runtimeMode" | "interactionMode" | "participants" | "childRequests"
> &
Pick<OrchestrationThread, "move" | "pendingMove"> & {
readonly archivedAt: string | null;
readonly deletedAt: string | null;
Expand Down Expand Up @@ -243,6 +252,8 @@ const make = Effect.gen(function* () {
: {
id: found.value.threadId,
title: found.value.title,
runtimeMode: found.value.runtimeMode,
interactionMode: found.value.interactionMode,
participants: found.value.participants ?? [],
childRequests: found.value.childRequests ?? EMPTY_CHILD_REQUEST_STATE,
move: found.value.move ?? null,
Expand Down Expand Up @@ -857,11 +868,27 @@ const make = Effect.gen(function* () {
});
return true;
}
const ceiling = request.requestCeiling ?? effectiveRequestCeiling(parent);
// An older peer can't enforce a ceiling: only a sender with the widest
// access sends it work (docs/design/agent-autonomy-no-limits.md, "Access").
if (!isWidestMode(ceiling)) {
const descriptor = yield* client.describe(environmentId as EnvironmentId);
if (descriptor.enforcesRequestCeiling !== true) {
const reason = olderPeerCeilingRefusal(remote.label);
yield* settleRequest(parent, request, {
outcome: "failed",
text: reason,
error: reason,
});
return true;
}
}
const answer = yield* client.withPeer(environmentId as EnvironmentId, (peer) =>
peer["peer.request.send"]({
requestId: request.requestId,
threadId: remote.threadId!,
text,
ceiling,
}),
);
if (answer.status === "queued") {
Expand Down
Loading
Loading