Multiplayer agent harness for work.
Remove the run task list (#2274)
Regan Bell4875193840c2
diff --git a/src/api/app-turn.ts b/src/api/app-turn.tsindex 533423015..5fea26805 100644--- a/src/api/app-turn.ts+++ b/src/api/app-turn.ts@@ -725,7 +725,6 @@ export function createTurnMethods(const replying = deps.turnStream?.replying(runId) ?? false;const replyComplete = deps.turnStream?.isReplyDone(runId) ?? false;const activity = await deps.runActivity?.list(runId);- const tasks = await deps.tasks?.list({ originRunId: runId });const stale =run.status === "pending" ? run.attempts > 0 : !alive && leaseLapsed(run, Date.now() - STALE_LEASE_GRACE_MS);return {@@ -765,7 +764,6 @@ export function createTurnMethods(...(stale ? { stale: true } : {}),...(replying ? { replying: true } : {}),...(replyComplete ? { replyComplete: true } : {}),- ...(tasks?.length ? { tasks: tasks.map(({ id, title, status }) => ({ id, title, status })) } : {}),...(activity && activity.length ? { activity } : {}),};},diff --git a/src/api/app-types.ts b/src/api/app-types.tsindex bacabe411..d55f397b6 100644--- a/src/api/app-types.ts+++ b/src/api/app-types.ts@@ -39,7 +39,6 @@ import type { LedgerEventBus, OwnedLedgerEvent } from "../loops/ledger-events.tsimport type { SubscribeOptions } from "../util/event-bus.ts";import type { RunActivityEntry, RunActivityStore } from "../runs/run-activity-store.ts";import type { RunSignal, RunSignalStore } from "../runs/run-signal-store.ts";-import type { TaskStore, TaskStatus } from "../tasks/task-store.ts";import type { ModelGateway } from "../model/model-gateway.ts";import type { ModelCredentialStore } from "../model/model-credential-store.ts";import type { UserModelCredentialStore } from "../model/user-model-credential-store.ts";@@ -307,7 +306,6 @@ export interface App {firstBlock?: string;firstBlockClosed?: boolean;surfacePosted?: boolean;- tasks?: Array<{ id: string; title: string; status: TaskStatus }>;activity?: RunActivityEntry[];startedAt: number | null;finishedAt: number | null;@@ -643,7 +641,6 @@ export interface AppDeps {runStreamEvents?: EventBus<RunStreamEvent>;runActivity?: RunActivityStore;signals?: RunSignalStore;- tasks?: TaskStore;modelGateway: ModelGateway;modelCredentials?: ModelCredentialStore;userModelCredentials?: UserModelCredentialStore;diff --git a/src/api/slack-core-client.ts b/src/api/slack-core-client.tsindex c575aff47..9ca492a80 100644--- a/src/api/slack-core-client.ts+++ b/src/api/slack-core-client.ts@@ -41,7 +41,6 @@ import type { MetricsSink } from "../admin/metrics-sink.ts";import type { RunStore } from "../runs/run-store.ts";import { isTerminal } from "../runs/run-store.ts";import type { GoalView, TurnStream } from "../runs/turn-stream.ts";-import type { TaskStore, TaskStatus } from "../tasks/task-store.ts";import type { DurableMap } from "../persistence/durable-map.ts";import { swallowAs } from "../util/errors.ts";import { resolveRuntimeChoiceDurable } from "../harness/harness-router.ts";@@ -54,7 +53,6 @@ interface SlackRunHooks {onReplying?(): void;onFirstBlock?(text: string): void;onSurfacePosted?(): void;- onTasks?(tasks: Array<{ id: string; title: string; status: TaskStatus }>): void | Promise<void>;onGoal?(goal: GoalView): void | Promise<void>;}@@ -165,7 +163,6 @@ export interface SlackCoreClientDeps {metrics: MetricsSink;runs: RunStore;turnStream: TurnStream;- tasks: TaskStore;pickAckEmoji?(text: string, candidates: readonly string[]): Promise<string | undefined>;ackPicks?: AckEmojiPickStore;ackModelId?: () => string | undefined;@@ -324,7 +321,6 @@ export function createSlackCoreClient(deps: SlackCoreClientDeps): SlackCoreClien});let lastProgressAt = Date.now();let lastMark = "";- let taskSnapshot = "";let goalSnapshot = "";const emitGoal = async (): Promise<void> => {if (!hooks.onGoal) return;@@ -335,19 +331,6 @@ export function createSlackCoreClient(deps: SlackCoreClientDeps): SlackCoreCliengoalSnapshot = next;await hooks.onGoal(goal);};- const emitTasks = async (): Promise<void> => {- if (!hooks.onTasks) return;- const tasks = (await deps.tasks.list({ originRunId: runId })).map(({ id, title, status }) => ({- id,- title,- status,- }));- if (!tasks.length) return;- const next = JSON.stringify(tasks);- if (next === taskSnapshot) return;- taskSnapshot = next;- await hooks.onTasks(tasks);- };try {for (;;) {let run;@@ -362,13 +345,11 @@ export function createSlackCoreClient(deps: SlackCoreClientDeps): SlackCoreClienif (deps.turnStream.surfacePosted(runId)) signalSurface();if (isTerminal(run.status)) {const view = await deps.app.getRun(runId);- await emitTasks().catch(swallowAs("slack-core-client: terminal task refresh", undefined));await emitGoal().catch(swallowAs("slack-core-client: terminal goal refresh", undefined));if (view?.surfacePosted) signalSurface();return (view?.result as TurnResult | null | undefined) ?? null;}signalReplying(run.deliveryState?.replying === true);- await emitTasks();await emitGoal().catch(swallowAs("slack-core-client: goal refresh", undefined));const fb = deps.turnStream.firstBlock(runId);if (fb?.closed) signalFirstBlock(fb.text);diff --git a/src/core/orchestrator/surface-tools.ts b/src/core/orchestrator/surface-tools.tsindex f1312dd26..4f4a58143 100644--- a/src/core/orchestrator/surface-tools.ts+++ b/src/core/orchestrator/surface-tools.ts@@ -235,14 +235,12 @@ export function createSurfaceToolDeps(ctx: SurfaceToolsContext): SurfaceToolDepsif (!f.ok) return { ok: false, message: f.message };const footer = buildDebugFooter();const run = input.runId ? await deps.runs?.get(input.runId) : null;- const taskList = input.runId ? await deps.tasks?.list({ originRunId: input.runId }) : undefined;const editRef =!editRefConsumed && destination.target === currentDestination.target ? run?.deliveryState?.editRef : undefined;if (editRef) editRefConsumed = true;const projectedDestination = {...destination,...(editRef ? { editRef } : {}),- ...(taskList?.length ? { taskList: taskList.map(({ id, title, status }) => ({ id, title, status })) } : {}),...(footer ? { debugFooter: footer } : {}),};const sent = await enqueue(projectedDestination, postText, seq, f.attachments);diff --git a/src/core/orchestrator/types.ts b/src/core/orchestrator/types.tsindex 0d7e0b0a9..0eeab507a 100644--- a/src/core/orchestrator/types.ts+++ b/src/core/orchestrator/types.ts@@ -51,7 +51,6 @@ import type { RunSignalStore } from "../../runs/run-signal-store.ts";import type { TurnStream } from "../../runs/turn-stream.ts";import type { RunActivityStore } from "../../runs/run-activity-store.ts";import type { RunStore } from "../../runs/run-store.ts";-import type { TaskStore } from "../../tasks/task-store.ts";import type { MemoryService } from "../../memory/memory-service.ts";import type { McpToolService } from "../../mcp/mcp-tool-service.ts";import type { MemoryStrategy } from "../../memory/strategy.ts";@@ -174,7 +173,6 @@ export interface OrchestratorDeps {turnStream?: TurnStream;runActivity?: RunActivityStore;runs?: RunStore;- tasks?: TaskStore;blobTransfer?: BlobTransferStore;processes?: ProcessRegistry;monitors?: MonitorStore;diff --git a/src/delivery/run-result-delivery.ts b/src/delivery/run-result-delivery.tsindex a55a3b246..aaa63e400 100644--- a/src/delivery/run-result-delivery.ts+++ b/src/delivery/run-result-delivery.ts@@ -2,7 +2,6 @@ import { isSubagentThreadRef } from "../sessions/session-syscalls.ts";import type { DeliveryProvenance, Destination, OutgoingAttachment } from "../types.ts";import type { Run, RunStore } from "../runs/run-store.ts";import { turnDeliveryProvenance, type DeliveryStore } from "./delivery-store.ts";-import type { Task, TaskStore } from "../tasks/task-store.ts";import { resolveTurnOrigin } from "../core/turn-origin.ts";import type { TurnFailurePayload } from "../core/turn-error.ts";import { standaloneFailureText, userFacingFailureClause } from "../core/failure-copy.ts";@@ -35,11 +34,7 @@ function webTranscriptNote(run: Run, surface: string, failed: boolean): Destinatexport type AdminUrlFor = (sessionId: string) => string | undefined;-export function runResultDelivery(- run: Run,- taskList: Task[] = [],- adminUrlFor?: AdminUrlFor,-): RunResultDelivery | null {+export function runResultDelivery(run: Run, adminUrlFor?: AdminUrlFor): RunResultDelivery | null {if (isSubagentThreadRef(run.sessionId) || run.request.swarm || run.request.privateSessionMessage) return null;const target = run.request.deliveryTarget;const surface = run.request.surface;@@ -58,7 +53,6 @@ export function runResultDelivery(? { slackPolicyNamespace: run.request.slackSource.externalPolicyNamespace }: {}),...(editRef ? { editRef } : {}),- ...(taskList.length ? { taskList: taskList.map(({ id, title, status }) => ({ id, title, status })) } : {}),...(webTranscript ? { webTranscript } : {}),};const idempotencyKey = `run:${run.id}`;@@ -149,7 +143,6 @@ export interface RunResultRecovery {export function wireRunResultDeliveries(runs: Pick<RunStore, "onTerminal" | "terminalFinished">,deliveries: Pick<DeliveryStore, "enqueue" | "existingKeys">,- tasks?: TaskStore,adminUrlFor?: AdminUrlFor,sessions?: TurnFailureSessions,): RunResultRecovery {@@ -159,8 +152,7 @@ export function wireRunResultDeliveries(reportFailureAs("delivery: record turn_failure entry", undefined, `run=${run.id}`),);}- const taskList = tasks ? await tasks.list({ originRunId: run.id }) : [];- const delivery = runResultDelivery(run, taskList, adminUrlFor);+ const delivery = runResultDelivery(run, adminUrlFor);if (!delivery) return false;await deliveries.enqueue(delivery);return true;diff --git a/src/harness/claude-harness.ts b/src/harness/claude-harness.tsindex cdd42f95f..50053e946 100644--- a/src/harness/claude-harness.ts+++ b/src/harness/claude-harness.ts@@ -30,7 +30,6 @@ import {modelSupportsFastMode,} from "../model/pi-models.ts";import { startSignalPoll, type RunSignalStore } from "../runs/run-signal-store.ts";-import type { TaskStatus, TaskStore } from "../tasks/task-store.ts";import type { ScopeId } from "../types.ts";import { swallow } from "../util/errors.ts";import { summarizeHistory } from "./history-summary.ts";@@ -49,7 +48,6 @@ import {recordSteerIntake,recordStoppedReply,type SteerIntake,- transitionTask,type HarnessToolPlumbing,withResumedToolCall,} from "./harness-shared.ts";@@ -75,7 +73,6 @@ export interface ClaudeHarnessOptions extends HarnessToolPlumbing {*/authEnv?: () => Promise<NodeJS.ProcessEnv>;signals?: RunSignalStore;- tasks?: TaskStore;}export function claudeHarnessConfigOptions(config: Config): ClaudeHarnessOptions {@@ -404,7 +401,7 @@ export function createClaudeHarness(opts: ClaudeHarnessOptions = {}): Harness {for (const value of thinking.splice(0))await turn.emit({ type: "thinking", payload: { thinking: value }, scopeLabel: turn.scopeLabel });};- const taskStates = new Map<string, { callId: string; status: TaskStatus; resultEmitted: boolean }>();+ const taskStates = new Map<string, { callId: string; resultEmitted: boolean }>();const callUsage = new Map<string, { input: number; output: number; cacheRead: number; cacheWrite: number }>();let stepCallIds = new Set<string>();let recordedSteps = 0;@@ -683,15 +680,7 @@ export function createClaudeHarness(opts: ClaudeHarnessOptions = {}): Harness {if (message.type === "system" && message.subtype === "task_started") {const callId = message.tool_use_id ?? message.task_id;if (!taskStates.has(message.task_id)) {- if (opts.tasks)- await opts.tasks.create({- id: message.task_id,- sessionId: turn.session.id,- originRunId: turn.runId ?? turn.session.id,- title: message.description || message.prompt || "subagent task",- status: "in_progress",- });- taskStates.set(message.task_id, { callId, status: "in_progress", resultEmitted: false });+ taskStates.set(message.task_id, { callId, resultEmitted: false });if (!message.skip_transcript) {await turn.emit({type: "tool_call",@@ -706,25 +695,9 @@ export function createClaudeHarness(opts: ClaudeHarnessOptions = {}): Harness {}}}- if (message.type === "system" && message.subtype === "task_updated") {- const tracked = taskStates.get(message.task_id);- let next: TaskStatus | undefined;- if (message.patch.status === "completed") next = "completed";- else if (message.patch.status === "failed" || message.patch.status === "killed") next = "failed";- else if (message.patch.status === "running") next = "in_progress";- if (tracked && next && next !== tracked.status) {- await transitionTask(opts.tasks, message.task_id, tracked.status, next, turn.runId ?? turn.session.id);- tracked.status = next;- }- }if (message.type === "system" && message.subtype === "task_notification") {const tracked = taskStates.get(message.task_id);if (tracked) {- const next: TaskStatus = message.status === "completed" ? "completed" : "failed";- if (tracked.status !== next) {- await transitionTask(opts.tasks, message.task_id, tracked.status, next, turn.runId ?? turn.session.id);- tracked.status = next;- }if (!tracked.resultEmitted && !message.skip_transcript) {tracked.resultEmitted = true;await turn.emit({@@ -875,11 +848,6 @@ export function createClaudeHarness(opts: ClaudeHarnessOptions = {}): Harness {queue.close();if (!signalsStopped) await stopSignals?.();turn.cancel?.removeEventListener("abort", onCancel);- for (const [taskId, task] of taskStates) {- if (task.status === "pending" || task.status === "in_progress") {- await transitionTask(opts.tasks, taskId, task.status, "failed", turn.runId ?? turn.session.id);- }- }active.delete(sdkQuery);sdkQuery.close();rmSync(jail, { recursive: true, force: true });diff --git a/src/harness/codex-harness.ts b/src/harness/codex-harness.tsindex af5741995..a789e2151 100644--- a/src/harness/codex-harness.ts+++ b/src/harness/codex-harness.ts@@ -7,7 +7,6 @@ import { CONFIG_DEFAULTS, type Config } from "../config.ts";import { NonRetryableTurnError, ProviderTurnError, type ProviderErrorCode } from "../core/turn-error.ts";import { DEFAULT_CODEX_MODEL_ID, modelSupportedByHarness } from "../model/pi-models.ts";import { startSignalPoll, type RunSignalStore } from "../runs/run-signal-store.ts";-import type { TaskStatus, TaskStore } from "../tasks/task-store.ts";import type { LlmCallUsage } from "../sessions/session-store.ts";import type { ScopeId, SessionEntry } from "../types.ts";import { asError, swallow } from "../util/errors.ts";@@ -35,7 +34,6 @@ import {recordSteerIntake,recordStoppedReply,type SteerIntake,- transitionTask,type BridgedTool,type HarnessToolPlumbing,withResumedToolCall,@@ -60,7 +58,6 @@ export interface CodexHarnessOptions extends HarnessToolPlumbing {/** Custodian of the ChatGPT-subscription Codex login (keychain-backed in production). */authStore?: CodexAuthStore;signals?: RunSignalStore;- tasks?: TaskStore;}export function codexHarnessConfigOptions(config: Config): CodexHarnessOptions {@@ -146,7 +143,6 @@ type ActiveTurn = {publicMessages: Map<string, CodexItem & { complete?: boolean }>;stoppedReply?: string;taskIds: Map<string, string>;- taskStatuses: Map<string, TaskStatus>;taskResults: Set<string>;model: string;modelCalls: number;@@ -386,14 +382,6 @@ function reasoningFromTurn(turn: CodexTurn): string[] {);}-export function codexTaskTitle(prompt: unknown): string {- if (typeof prompt !== "string" || !prompt.trim()) return "subagent task";- const normalized = prompt.replace(/\s+/g, " ").trim();- const named = /\bYou are (?:the )?([^.!?]{1,80}? subagent)\b/i.exec(normalized)?.[1];- const title = named ?? normalized;- return title.length > 120 ? `${title.slice(0, 119).trimEnd()}…` : title;-}-export function codexReasoningEffort(value: string | undefined): "low" | "medium" | "high" | "xhigh" | undefined {return value === "low" || value === "medium" || value === "high" || value === "xhigh" ? value : undefined;}@@ -462,16 +450,7 @@ export function createCodexHarness(opts: CodexHarnessOptions = {}): Harness {for (const receiver of receivers) {if (state.taskIds.has(receiver)) continue;const taskId = `${String(item.id)}:${receiver}`;- if (opts.tasks)- await opts.tasks.create({- id: taskId,- sessionId: state.turn.session.id,- originRunId: state.turn.runId ?? state.turn.session.id,- title: codexTaskTitle(item.prompt),- status: "in_progress",- });state.taskIds.set(receiver, taskId);- state.taskStatuses.set(taskId, "in_progress");active.set(receiver, state);await state.turn.emit({type: "tool_call",@@ -487,17 +466,12 @@ export function createCodexHarness(opts: CodexHarnessOptions = {}): Harness {for (const [receiver, agent] of Object.entries(agents)) {const taskId = state.taskIds.get(receiver);if (!taskId) continue;- let next: TaskStatus | undefined;+ let next: "completed" | "failed" | undefined;if (agent.status === "completed" || agent.status === "shutdown") next = "completed";else if (agent.status === "errored" || agent.status === "interrupted" || agent.status === "notFound") {next = "failed";- } else if (agent.status === "running") next = "in_progress";- const prior = state.taskStatuses.get(taskId);- if (next && prior && next !== prior) {- await transitionTask(opts.tasks, taskId, prior, next, state.turn.runId ?? state.turn.session.id);- state.taskStatuses.set(taskId, next);}- if ((next === "completed" || next === "failed") && !state.taskResults.has(taskId)) {+ if (next && !state.taskResults.has(taskId)) {state.taskResults.add(taskId);await state.turn.emit({type: "tool_result",@@ -1112,7 +1086,6 @@ export function createCodexHarness(opts: CodexHarnessOptions = {}): Harness {seenUserItems: new Set(),publicMessages: new Map(),taskIds: new Map(),- taskStatuses: new Map(),taskResults: new Set(),model: selectedModel,modelCalls: 0,@@ -1384,15 +1357,6 @@ export function createCodexHarness(opts: CodexHarnessOptions = {}): Harness {cleanupErrors.push(error);}turn.cancel?.removeEventListener("abort", onCancel);- for (const [taskId, status] of state.taskStatuses) {- if (status === "pending" || status === "in_progress") {- try {- await transitionTask(opts.tasks, taskId, status, "failed", turn.runId ?? turn.session.id);- } catch (error) {- cleanupErrors.push(error);- }- }- }for (const [activeThreadId, activeState] of active) {if (activeState === state) active.delete(activeThreadId);}diff --git a/src/harness/harness-shared.ts b/src/harness/harness-shared.tsindex 494d1aa97..076c1e156 100644--- a/src/harness/harness-shared.ts+++ b/src/harness/harness-shared.ts@@ -5,7 +5,6 @@ import {SECURITY_SCREEN_STEP,SECURITY_SCREEN_SYSTEM_PROMPT,} from "../security/security-posture.ts";-import type { TaskStatus, TaskStore } from "../tasks/task-store.ts";import type { ScopeId, SessionEntry } from "../types.ts";import { createAgentTools, type AgentToolsOptions, type ToolContextRef } from "./agent-tools.ts";import { goalWorkFromEntries, rehydrateOpenGoal } from "./goal.ts";@@ -263,18 +262,6 @@ export function bridgedToolText(result: Awaited<ReturnType<BridgedTool["execute".join("\n");}-export async function transitionTask(- store: TaskStore | undefined,- id: string,- expected: TaskStatus,- next: TaskStatus,- runId: string,-): Promise<void> {- if (!store) return;- const updated = await store.transitionStatus(id, expected, next, runId);- if (!updated) throw new Error(`task ${id} was not ${expected} while transitioning to ${next}`);-}-export type OneShotRunner = (systemPrompt: string,prompt: string,diff --git a/src/harness/opencode-harness.ts b/src/harness/opencode-harness.tsindex ed413999c..aa0447035 100644--- a/src/harness/opencode-harness.ts+++ b/src/harness/opencode-harness.ts@@ -25,7 +25,6 @@ import {import { startSignalPoll, type RunSignalStore } from "../runs/run-signal-store.ts";import type { LlmCallUsage } from "../sessions/session-store.ts";import type { ScopeId } from "../types.ts";-import type { TaskStore } from "../tasks/task-store.ts";import { errMessage, swallow } from "../util/errors.ts";import { sleep } from "../util/async.ts";import { NonRetryableTurnError } from "../core/turn-error.ts";@@ -75,7 +74,6 @@ export interface OpenCodeHarnessOptions extends HarnessToolPlumbing {signals?: RunSignalStore;binaryPath?: string;startupTimeoutMs?: number;- tasks?: TaskStore;/*** Admin-registered custom providers, resolved (with keys) when the* opencode server starts. Registrations made while a server is already@@ -547,18 +545,6 @@ export function createOpenCodeHarness(opts: OpenCodeHarnessOptions = {}): Harnes(value) => typeof value === "string" && value.trim(),) as string | undefined;if (!suppliedTitle && status === "pending") return;- const initialStatus = status === "running" ? "in_progress" : "pending";- if (opts.tasks) {- await opts.tasks- .create({- id: partId,- sessionId: state.turn.session.id,- originRunId: state.turn.runId ?? state.turn.session.id,- title: suppliedTitle?.trim() ?? "subagent task",- status: initialStatus,- })- .catch(() => undefined);- }await state.turn.emit({type: "tool_call",payload: { tool: "task", callId: part.callID, ...(toolState?.input as object) },@@ -570,16 +556,6 @@ export function createOpenCodeHarness(opts: OpenCodeHarnessOptions = {}): Harnesif (prior !== status && (status === "completed" || status === "error")) {const result =status === "completed" ? String(toolState?.output ?? "") : String(toolState?.error ?? "task failed");- if (opts.tasks) {- const current = await opts.tasks.get(partId);- if (current)- await opts.tasks.transitionStatus(- partId,- current.status,- status === "completed" ? "completed" : "failed",- state.turn.runId ?? state.turn.session.id,- );- }await state.turn.emit({type: "tool_result",payload: { tool: "task", callId: part.callID, result, isError: status === "error" },@@ -1192,17 +1168,6 @@ export function createOpenCodeHarness(opts: OpenCodeHarnessOptions = {}): Harnesif (!signalsStopped) await stopSignals?.();await Promise.allSettled(queuedSignals);turn.cancel?.removeEventListener("abort", onCancel);- if (opts.tasks) {- const taskIds = [...state.seenTasks.keys()];- await Promise.all(- taskIds.map(async (taskId) => {- const task = await opts.tasks!.get(taskId);- if (task && (task.status === "pending" || task.status === "in_progress")) {- await opts.tasks!.transitionStatus(task.id, task.status, "failed", turn.runId ?? turn.session.id);- }- }),- );- }await flushLlmRequests();for (const [id, candidate] of active) if (candidate.turn === turn) active.delete(id);await rt.client.session.delete({ path: { id: sessionId } }).catch(() => undefined);diff --git a/src/sessions/postgres-session-store.ts b/src/sessions/postgres-session-store.tsindex 11f4fae9d..570dab54b 100644--- a/src/sessions/postgres-session-store.ts+++ b/src/sessions/postgres-session-store.ts@@ -832,6 +832,10 @@ export function createPostgresSessionStore(connectionString: string, opts: StoreON session_entries(session_id, created_at DESC) WHERE type IN ('assistant', 'delivery')`,],},+ {+ id: "sessions/store/0028-drop-run-tasks",+ statements: [`DROP TABLE IF EXISTS task_events`, `DROP TABLE IF EXISTS tasks`],+ },],[{diff --git a/src/slack/deliveries.ts b/src/slack/deliveries.tsindex e154ae98d..9a0cd8ff4 100644--- a/src/slack/deliveries.ts+++ b/src/slack/deliveries.ts@@ -19,7 +19,6 @@ import {statusPlaceholderKey,postWithVerify,recoveryVerifyOldest,- renderTaskList,slackReplyArgs,slackSectionBlocks,stripReactionDirectives,@@ -312,39 +311,11 @@ export function createDeliveryPoller(deps: {...messageFooter,...(d.destination.debugFooter ? [{ type: "mrkdwn", text: d.destination.debugFooter }] : []),];- const taskList = d.destination.taskList?.length ? renderTaskList(d.destination.taskList) : undefined;- const footerBlocks =- taskList || footer.length- ? [- ...(text.trim() ? slackSectionBlocks(text) : []),- ...(taskList ? [{ type: "section", text: { type: "mrkdwn", text: taskList } }] : []),- ...(footer.length ? [{ type: "context", elements: footer }] : []),- ]- : undefined;+ const footerBlocks = footer.length+ ? [...(text.trim() ? slackSectionBlocks(text) : []), { type: "context", elements: footer }]+ : undefined;if (!text.trim() && !(messageFooter.length && d.attachments?.length)) {- if (taskList) {- let preserved = false;- if (editRef) {- try {- await client.chat.update({- channel,- ts: editRef,- text: taskList,- blocks: [{ type: "section", text: { type: "mrkdwn", text: taskList } }],- ...botIdentityArgs(),- });- preserved = true;- } catch (error) {- swallow("slack: preserve recovered task list", error);- }- }- if (!preserved) {- await client.chat.postMessage({- ...slackReplyArgs(channel, taskList, threadTs, { threadOnly: Boolean(threadTs) }),- blocks: [{ type: "section", text: { type: "mrkdwn", text: taskList } }],- });- }- } else if (editRef) {+ if (editRef) {await client.chat.delete({ channel, ts: editRef }).catch(swallowAs("slack: delete status placeholder", undefined));diff --git a/src/slack/lib.ts b/src/slack/lib.tsindex 5d9260ab8..0afe629b2 100644--- a/src/slack/lib.ts+++ b/src/slack/lib.ts@@ -144,10 +144,6 @@ export {CURATED_ACK_EMOJI,stripAckPrefix,createAckPresenter,- type RunTaskView,- renderTaskList,- type TaskListPresenter,- createTaskListPresenter,renderGoalNotice,type GoalNoticeView,type GoalNoticePresenter,diff --git a/src/slack/presenters.ts b/src/slack/presenters.tsindex 754dd7e4d..591095140 100644--- a/src/slack/presenters.ts+++ b/src/slack/presenters.ts@@ -1,7 +1,3 @@-import { sleep } from "./util.ts";-import { slackSectionBlocks } from "./mrkdwn.ts";-import type { DeliveryMetadata } from "./delivery.ts";-export const DEFAULT_ACK_REACTIONS = ["eyes", "mag", "hourglass_flowing_sand", "telescope", "saluting_face"] as const;export const CURATED_ACK_EMOJI = [@@ -139,145 +135,6 @@ export function createAckPresenter(deps: {};}-type RunTaskStatus = "pending" | "in_progress" | "completed" | "skipped" | "failed";--export interface RunTaskView {- id: string;- title: string;- status: RunTaskStatus;-}--export function renderTaskList(tasks: RunTaskView[]): string {- const title = (value: string) => {- const oneLine = value- .replace(/[\r\n\t]+/g, " ")- .replace(/\s+/g, " ")- .trim();- const bounded = oneLine.length > 120 ? `${oneLine.slice(0, 119)}…` : oneLine;- return bounded.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");- };- const noun = tasks.length === 1 ? "task" : "tasks";- const shown = tasks.slice(0, 20);- const rows = shown.map((task) => {- const label = title(task.title);- if (task.status === "completed") return `✓ ~${label}~`;- if (task.status === "skipped") return `– ~${label}~`;- if (task.status === "failed") return `✕ ~${label}~`;- return `${task.status === "in_progress" ? "◐" : "○"} ${label}`;- });- if (shown.length < tasks.length) rows.push(`… ${tasks.length - shown.length} more`);- return `*${tasks.length} ${noun}*\n${rows.join("\n")}`;-}--export interface TaskListPresenter {- attach(ts: string, leadText: string): Promise<void>;- addLead(leadText: string): Promise<boolean>;- onTasks(tasks: RunTaskView[]): Promise<void>;- finalize(text: string, metadata?: DeliveryMetadata): Promise<boolean>;- settle(): Promise<void>;-}--export function createTaskListPresenter(deps: {- post(text: string, blocks: Array<Record<string, unknown>>): Promise<string | undefined>;- update(ts: string, text: string, blocks: Array<Record<string, unknown>>, metadata?: DeliveryMetadata): Promise<void>;- checkpoint(ts: string): Promise<void>;- remove(ts: string): Promise<void>;- onSurfacePosted(): void;- sleep?(ms: number): Promise<void>;- onError?(error: unknown): void;-}): TaskListPresenter {- let messageTs: string | undefined;- let leadText = "";- let tasks: RunTaskView[] = [];- let chain = Promise.resolve();- const sleepFor = deps.sleep ?? sleep;- const taskBlocks = (taskText: string): Array<Record<string, unknown>> => [- ...(leadText ? [{ type: "section", text: { type: "mrkdwn", text: leadText } }] : []),- { type: "section", text: { type: "mrkdwn", text: taskText } },- ];- const updateWithRetry = async (- ts: string,- text: string,- blocks: Array<Record<string, unknown>>,- metadata?: DeliveryMetadata,- ): Promise<boolean> => {- for (const delay of [0, 250, 750]) {- if (delay) await sleepFor(delay);- try {- await deps.update(ts, text, blocks, metadata);- return true;- } catch (error) {- if (delay === 750) deps.onError?.(error);- }- }- return false;- };- const render = async (): Promise<boolean> => {- if (!tasks.length) return false;- const taskText = renderTaskList(tasks);- const fallback = leadText ? `${leadText}\n\n${taskText}` : taskText;- if (messageTs) {- return updateWithRetry(messageTs, fallback, taskBlocks(taskText));- }- try {- const ts = await deps.post(fallback, taskBlocks(taskText));- if (!ts) return false;- try {- await deps.checkpoint(ts);- } catch (error) {- await deps.remove(ts).catch(() => {});- throw error;- }- messageTs = ts;- deps.onSurfacePosted();- return true;- } catch (error) {- deps.onError?.(error);- return false;- }- };- return {- async attach(ts, text) {- try {- await deps.checkpoint(ts);- } catch (error) {- await deps.remove(ts).catch(() => {});- throw error;- }- messageTs = ts;- leadText = text;- },- async addLead(text) {- await chain;- if (!messageTs) return false;- leadText = text;- const updated = await render();- if (updated) return true;- const staleTs = messageTs;- messageTs = undefined;- await deps.remove(staleTs).catch(() => {});- return false;- },- async onTasks(nextTasks) {- tasks = nextTasks.map((task) => ({ ...task }));- chain = chain.then(async () => {- await render();- });- await chain;- },- async finalize(text, metadata) {- await chain;- if (!messageTs || !tasks.length) return false;- const taskText = renderTaskList(tasks);- const finalBlocks = [...slackSectionBlocks(text), { type: "section", text: { type: "mrkdwn", text: taskText } }];- return updateWithRetry(messageTs, text || taskText, finalBlocks, metadata);- },- async settle() {- await chain;- },- };-}-export interface GoalNoticeView {objective: string;status: "active" | "paused" | "complete" | "cancelled";diff --git a/src/slack/turn-flow.ts b/src/slack/turn-flow.tsindex f0a7f0989..5d7117924 100644--- a/src/slack/turn-flow.ts+++ b/src/slack/turn-flow.ts@@ -1,5 +1,5 @@import { swallow } from "../util/errors.ts";-import { sleep, createInFlightThreadMap, type GoalNoticeView, type RunTaskView } from "./lib.ts";+import { sleep, createInFlightThreadMap, type GoalNoticeView } from "./lib.ts";import type { SlackCoreClient } from "../api/slack-core-client.ts";import type { TurnRequest, TurnResult } from "../types.ts";import { GENERIC_FAILURE_TEXT } from "../../plugins/chassis/src/failure-copy.ts";@@ -23,7 +23,6 @@ interface TurnHooks {onReplying?: () => void;onFirstBlock?: (text: string) => void;onSurfacePosted?: () => void;- onTasks?: (tasks: RunTaskView[]) => void;onGoal?: (goal: GoalNoticeView) => void;}@@ -110,7 +109,6 @@ export function createTurnFlow(core: SlackCoreClient): TurnFlow {...(hooks.onReplying ? { onReplying: hooks.onReplying } : {}),...(hooks.onFirstBlock ? { onFirstBlock: hooks.onFirstBlock } : {}),...(hooks.onSurfacePosted ? { onSurfacePosted: hooks.onSurfacePosted } : {}),- ...(hooks.onTasks ? { onTasks: hooks.onTasks } : {}),...(hooks.onGoal ? { onGoal: hooks.onGoal } : {}),});} catch (err) {diff --git a/src/slack/turn-handler.ts b/src/slack/turn-handler.tsindex bea22c302..4e8340a54 100644--- a/src/slack/turn-handler.ts+++ b/src/slack/turn-handler.ts@@ -15,12 +15,10 @@ import {type ConversationTurn,type OverheardMessage,type ReactionTally,- type RunTaskView,type GoalNoticeView,type GoalNoticePresenter,createGoalNoticePresenter,type SlackFile,- type TaskListPresenter,DEFAULT_ACK_REACTIONS,REACTION_DETECT_GUIDANCE,REACTION_INSTRUCTION,@@ -28,13 +26,11 @@ import {buildReactionTurnText,createAckPresenter,createDeduper,- createTaskListPresenter,createThreadTracker,decodeSlackEntities,dedupeKey,dedupedRun,deliveryCandidatesFor,- deliveryMetadata,statusPlaceholderKey,channelThreadRef,dmThreadRef,@@ -292,7 +288,6 @@ export function createTurnHandler(deps: {let queuedRunId: string | undefined;let accepted = false;- let taskList: TaskListPresenter | undefined;let goalNotice: GoalNoticePresenter | undefined;if (inc.kind === "channel") {@@ -390,10 +385,14 @@ export function createTurnHandler(deps: {taskManaged,postAck: async (text) => {const rendered = toSlackMrkdwn(text);- if (await taskList?.addLead(rendered)) return;const ts = await postReply(rendered, undefined, statusKey());- if (ts) {- await taskList?.attach(ts, rendered);+ if (ts && queuedRunId && !inc.unprompted) {+ try {+ await core.reportRunEditRef(queuedRunId, ts);+ } catch (error) {+ await client.chat.delete({ channel: inc.channel, ts }).catch(() => {});+ throw error;+ }}},addReaction: (name) => client.reactions.add({ channel: inc.channel, timestamp: inc.ts, name }).then(() => {}),@@ -412,28 +411,6 @@ export function createTurnHandler(deps: {}));const acknowledges = !inc.unprompted || !inc.synthetic;if (!inc.unprompted) startAck();- if (!inc.unprompted) {- taskList = createTaskListPresenter({- post: (text, blocks) => postReply(text, blocks, statusKey()),- update: (ts, text, blocks, metadata) =>- client.chat- .update({- channel: inc.channel,- ts,- text,- blocks,- ...(metadata ? { metadata } : {}),- ...botIdentityArgs(),- })- .then(() => {}),- checkpoint: async (ts) => {- if (queuedRunId) await core.reportRunEditRef(queuedRunId, ts);- },- remove: (ts) => client.chat.delete({ channel: inc.channel, ts }).then(() => {}),- onSurfacePosted: () => ack?.onSurfacePosted(),- onError: (error) => console.error("[slack-plugin] task-list update failed:", (error as Error).message),- });- }if (!inc.unprompted) {goalNotice = createGoalNoticePresenter({post: (text, blocks) => postReply(text, blocks),@@ -620,14 +597,6 @@ export function createTurnHandler(deps: {onSurfacePosted: () => startAck().onSurfacePosted(),}: {}),- ...(taskList- ? {- onTasks: async (tasks: RunTaskView[]) => {- await ack?.drain();- await taskList?.onTasks(tasks);- },- }- : {}),...(goalNotice? {onGoal: (goal: GoalNoticeView) => {@@ -637,7 +606,6 @@ export function createTurnHandler(deps: {: {}),},);- await taskList?.settle();await goalNotice?.settle();} catch (err) {await settleAck();@@ -713,10 +681,7 @@ export function createTurnHandler(deps: {}}await ack?.drain();- const finalizedTaskList = postText- ? ((await taskList?.finalize(postText, runKey ? deliveryMetadata(runKey) : undefined)) ?? false)- : false;- if (postText && !finalizedTaskList) await postReply(postText, undefined, runKey);+ if (postText) await postReply(postText, undefined, runKey);if (uploadError) await postReply(uploadFailureNote(uploadError));const { directives, dropped } = resolveReactionTargets(reactions, allowedTs);if (dropped) console.error(`[slack-plugin] dropped ${dropped} reaction(s) with an unresolvable message id`);diff --git a/src/tasks/memory-task-store.ts b/src/tasks/memory-task-store.tsdeleted file mode 100644index 64d351b2d..000000000--- a/src/tasks/memory-task-store.ts+++ /dev/null@@ -1,103 +0,0 @@-import { randomUUID } from "node:crypto";-import type {- CreateTaskInput,- OpenTaskFilter,- Task,- TaskEvent,- TaskFilter,- TaskStatus,- TaskStore,-} from "./task-store.ts";-import { isOpenTask } from "./task-store.ts";--export function createMemoryTaskStore(opts: { now?: () => number } = {}): TaskStore {- const now = opts.now ?? (() => Date.now());- const tasks = new Map<string, Task>();- const events = new Map<string, TaskEvent[]>();- let nextEventId = 1;-- function copyTask(task: Task): Task {- return { ...task };- }-- function appendEvent(- taskId: string,- runId: string,- fromStatus: TaskStatus | null,- toStatus: TaskStatus,- at: number,- ): void {- const taskEvents = events.get(taskId) ?? [];- taskEvents.push({- id: String(nextEventId++),- taskId,- runId,- type: fromStatus === null ? "created" : "status_changed",- fromStatus,- toStatus,- createdAt: at,- });- events.set(taskId, taskEvents);- }-- function matches(task: Task, filter: TaskFilter | OpenTaskFilter): boolean {- return (- (filter.sessionId === undefined || task.sessionId === filter.sessionId) &&- (filter.originRunId === undefined || task.originRunId === filter.originRunId)- );- }-- function ordered(values: Iterable<Task>): Task[] {- return [...values].sort((a, b) => a.createdAt - b.createdAt || a.id.localeCompare(b.id)).map(copyTask);- }-- return {- async create(input: CreateTaskInput): Promise<Task> {- const id = input.id ?? randomUUID();- if (tasks.has(id)) throw new Error(`task ${id} already exists`);- const at = now();- const task: Task = {- id,- sessionId: input.sessionId,- originRunId: input.originRunId,- title: input.title,- status: input.status ?? "pending",- createdAt: at,- updatedAt: at,- };- tasks.set(id, task);- appendEvent(id, input.originRunId, null, task.status, at);- return copyTask(task);- },-- async get(id): Promise<Task | null> {- const task = tasks.get(id);- return task ? copyTask(task) : null;- },-- async list(filter: TaskFilter = {}): Promise<Task[]> {- const statuses = filter.statuses ? new Set(filter.statuses) : null;- return ordered(- [...tasks.values()].filter((task) => matches(task, filter) && (!statuses || statuses.has(task.status))),- );- },-- async listOpen(filter: OpenTaskFilter = {}): Promise<Task[]> {- return ordered([...tasks.values()].filter((task) => matches(task, filter) && isOpenTask(task.status)));- },-- async transitionStatus(id, expectedStatus, nextStatus, runId): Promise<Task | null> {- const task = tasks.get(id);- if (!task || task.status !== expectedStatus) return null;- const at = now();- task.status = nextStatus;- task.updatedAt = at;- appendEvent(id, runId, expectedStatus, nextStatus, at);- return copyTask(task);- },-- async listEvents(taskId): Promise<TaskEvent[]> {- return (events.get(taskId) ?? []).map((event) => ({ ...event }));- },- };-}diff --git a/src/tasks/postgres-task-store.ts b/src/tasks/postgres-task-store.tsdeleted file mode 100644index 60e1aa68a..000000000--- a/src/tasks/postgres-task-store.ts+++ /dev/null@@ -1,179 +0,0 @@-import { randomUUID } from "node:crypto";-import { createPgPool } from "../persistence/pg-pool.ts";-import type {- OpenTaskFilter,- Task,- TaskEvent,- TaskEventType,- TaskFilter,- TaskStatus,- TaskStore,-} from "./task-store.ts";--const SCHEMA = [- `CREATE TABLE IF NOT EXISTS tasks(- id TEXT PRIMARY KEY,- session_id TEXT NOT NULL,- origin_run_id TEXT NOT NULL,- title TEXT NOT NULL,- status TEXT NOT NULL CHECK (status IN ('pending', 'in_progress', 'completed', 'skipped', 'failed')),- created_at BIGINT NOT NULL,- updated_at BIGINT NOT NULL- )`,- `CREATE INDEX IF NOT EXISTS idx_tasks_session_open- ON tasks(session_id, created_at, id) WHERE status IN ('pending', 'in_progress')`,- `CREATE INDEX IF NOT EXISTS idx_tasks_origin_run_open- ON tasks(origin_run_id, created_at, id) WHERE status IN ('pending', 'in_progress')`,- `CREATE INDEX IF NOT EXISTS idx_tasks_origin_run- ON tasks(origin_run_id, created_at, id)`,- `CREATE TABLE IF NOT EXISTS task_events(- id BIGSERIAL PRIMARY KEY,- task_id TEXT NOT NULL,- run_id TEXT NOT NULL,- type TEXT NOT NULL CHECK (type IN ('created', 'status_changed')),- from_status TEXT,- to_status TEXT NOT NULL,- created_at BIGINT NOT NULL- )`,- `DO $$ BEGIN- ALTER TABLE tasks ADD CONSTRAINT tasks_session_id_cascade_fkey- FOREIGN KEY(session_id) REFERENCES sessions(id) ON DELETE CASCADE NOT VALID;- EXCEPTION WHEN duplicate_object THEN NULL; END $$`,- `DO $$ BEGIN- ALTER TABLE task_events DROP CONSTRAINT IF EXISTS task_events_task_id_fkey;- EXCEPTION WHEN undefined_table THEN NULL; END $$`,- `DO $$ BEGIN- ALTER TABLE task_events ADD CONSTRAINT task_events_task_id_cascade_fkey- FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE NOT VALID;- EXCEPTION WHEN duplicate_object THEN NULL; END $$`,- `CREATE INDEX IF NOT EXISTS idx_task_events_task ON task_events(task_id, id)`,-];--function rowToTask(row: Record<string, unknown>): Task {- return {- id: row.id as string,- sessionId: row.session_id as string,- originRunId: row.origin_run_id as string,- title: row.title as string,- status: row.status as TaskStatus,- createdAt: Number(row.created_at),- updatedAt: Number(row.updated_at),- };-}--function rowToEvent(row: Record<string, unknown>): TaskEvent {- return {- id: String(row.id),- taskId: row.task_id as string,- runId: row.run_id as string,- type: row.type as TaskEventType,- fromStatus: row.from_status === null ? null : (row.from_status as TaskStatus),- toStatus: row.to_status as TaskStatus,- createdAt: Number(row.created_at),- };-}--function filterSql(filter: TaskFilter | OpenTaskFilter, open: boolean): { where: string; params: unknown[] } {- const clauses: string[] = [];- const params: unknown[] = [];- const add = (clause: string, value: unknown): void => {- params.push(value);- clauses.push(clause.replace("?", `$${params.length}`));- };- if (filter.sessionId !== undefined) add("session_id = ?", filter.sessionId);- if (filter.originRunId !== undefined) add("origin_run_id = ?", filter.originRunId);- if (open) clauses.push("status IN ('pending', 'in_progress')");- if (!open && "statuses" in filter && filter.statuses !== undefined) add("status = ANY(?)", [...filter.statuses]);- return { where: clauses.length ? ` WHERE ${clauses.join(" AND ")}` : "", params };-}--export function createPostgresTaskStore(connectionString: string, opts: { now?: () => number } = {}): TaskStore {- const now = opts.now ?? (() => Date.now());- const pg = createPgPool(connectionString, "tasks/store/0001", SCHEMA);- const q = pg.query;-- return {- async create(input): Promise<Task> {- const id = input.id ?? randomUUID();- const at = now();- const status = input.status ?? "pending";- const client = await (await pg.pool()).connect();- try {- await client.query("BEGIN");- const inserted = await client.query(- `INSERT INTO tasks(id, session_id, origin_run_id, title, status, created_at, updated_at)- VALUES ($1,$2,$3,$4,$5,$6,$6) RETURNING *`,- [id, input.sessionId, input.originRunId, input.title, status, at],- );- await client.query(- `INSERT INTO task_events(task_id, run_id, type, from_status, to_status, created_at)- VALUES ($1,$2,'created',NULL,$3,$4)`,- [id, input.originRunId, status, at],- );- await client.query("COMMIT");- return rowToTask(inserted.rows[0] as Record<string, unknown>);- } catch (error) {- await client.query("ROLLBACK");- throw error;- } finally {- client.release();- }- },-- async get(id): Promise<Task | null> {- const { rows } = await q("SELECT * FROM tasks WHERE id = $1", [id]);- return rows[0] ? rowToTask(rows[0]) : null;- },-- async list(filter: TaskFilter = {}): Promise<Task[]> {- const { where, params } = filterSql(filter, false);- const { rows } = await q(`SELECT * FROM tasks${where} ORDER BY created_at, id`, params);- return rows.map(rowToTask);- },-- async listOpen(filter: OpenTaskFilter = {}): Promise<Task[]> {- const { where, params } = filterSql(filter, true);- const { rows } = await q(`SELECT * FROM tasks${where} ORDER BY created_at, id`, params);- return rows.map(rowToTask);- },-- async transitionStatus(id, expectedStatus, nextStatus, runId): Promise<Task | null> {- const at = now();- const client = await (await pg.pool()).connect();- try {- await client.query("BEGIN");- const updated = await client.query(- `UPDATE tasks SET status = $3, updated_at = $4- WHERE id = $1 AND status = $2 RETURNING *`,- [id, expectedStatus, nextStatus, at],- );- const row = updated.rows[0] as Record<string, unknown> | undefined;- if (!row) {- await client.query("ROLLBACK");- return null;- }- await client.query(- `INSERT INTO task_events(task_id, run_id, type, from_status, to_status, created_at)- VALUES ($1,$2,'status_changed',$3,$4,$5)`,- [id, runId, expectedStatus, nextStatus, at],- );- await client.query("COMMIT");- return rowToTask(row);- } catch (error) {- await client.query("ROLLBACK");- throw error;- } finally {- client.release();- }- },-- async listEvents(taskId): Promise<TaskEvent[]> {- const { rows } = await q("SELECT * FROM task_events WHERE task_id = $1 ORDER BY id", [taskId]);- return rows.map(rowToEvent);- },-- async close(): Promise<void> {- await pg.close();- },- };-}diff --git a/src/tasks/task-store.ts b/src/tasks/task-store.tsdeleted file mode 100644index 91da6bd33..000000000--- a/src/tasks/task-store.ts+++ /dev/null@@ -1,59 +0,0 @@-export const TASK_STATUSES = ["pending", "in_progress", "completed", "skipped", "failed"] as const;--export type TaskStatus = (typeof TASK_STATUSES)[number];-export type TaskEventType = "created" | "status_changed";--export interface Task {- id: string;- sessionId: string;- originRunId: string;- title: string;- status: TaskStatus;- createdAt: number;- updatedAt: number;-}--export interface TaskEvent {- id: string;- taskId: string;- runId: string;- type: TaskEventType;- fromStatus: TaskStatus | null;- toStatus: TaskStatus;- createdAt: number;-}--export interface CreateTaskInput {- id?: string;- sessionId: string;- originRunId: string;- title: string;- status?: TaskStatus;-}--export interface TaskFilter {- sessionId?: string;- originRunId?: string;- statuses?: readonly TaskStatus[];-}--export interface OpenTaskFilter {- sessionId?: string;- originRunId?: string;-}--export interface TaskStore {- create(input: CreateTaskInput): Promise<Task>;- get(id: string): Promise<Task | null>;- list(filter?: TaskFilter): Promise<Task[]>;- listOpen(filter?: OpenTaskFilter): Promise<Task[]>;- transitionStatus(id: string, expectedStatus: TaskStatus, nextStatus: TaskStatus, runId: string): Promise<Task | null>;- listEvents(taskId: string): Promise<TaskEvent[]>;- close?(): Promise<void>;-}--const OPEN_STATUSES = new Set<TaskStatus>(["pending", "in_progress"]);--export function isOpenTask(status: TaskStatus): boolean {- return OPEN_STATUSES.has(status);-}diff --git a/src/types.ts b/src/types.tsindex 8ef54c14c..aed0d9b67 100644--- a/src/types.ts+++ b/src/types.ts@@ -223,11 +223,6 @@ export interface Destination {relaySender?: string;threadTs?: string;editRef?: string;- taskList?: Array<{- id: string;- title: string;- status: "pending" | "in_progress" | "completed" | "skipped" | "failed";- }>;unfurlLinks?: boolean;react?: { messageTs: string; emoji: string };delete?: { messageTs: string };diff --git a/src/wiring.ts b/src/wiring.tsindex 2816d3365..8f6e3e6b1 100644--- a/src/wiring.ts+++ b/src/wiring.ts@@ -323,9 +323,6 @@ import { createHarnessRouter, resolveRuntimeChoiceDurable } from "./harness/harnimport { selectableModelCatalog } from "./model/model-catalog.ts";import type { Harness } from "./harness/harness.ts";import { createSecurityScreenProxy, type SecurityScreener } from "./security/security-screener.ts";-import { createMemoryTaskStore } from "./tasks/memory-task-store.ts";-import { createPostgresTaskStore } from "./tasks/postgres-task-store.ts";-import type { TaskStore } from "./tasks/task-store.ts";import { createMemoryStrategy } from "./memory/strategy.ts";import { createOrchestrator, egressClaimAllowingControlPlane, type OrchestratorDeps } from "./core/orchestrator.ts";import {@@ -486,7 +483,6 @@ export interface BuiltApp {sessions: SessionStore;runs: RunStore;signals: RunSignalStore;- tasks: TaskStore;sessionStateBus: SessionStateBus;ledgerEventBus: LedgerEventBus;surfaceCache: SurfaceCache;@@ -1328,7 +1324,6 @@ export function buildApp(runStoreKind === "postgres"? createPostgresRunSignalStore(requireDbUrl("RUN_STORE")): createMemoryRunSignalStore();- const tasks = config.databaseUrl ? createPostgresTaskStore(config.databaseUrl) : createMemoryTaskStore();const writeModelRegistry = <T>(fn: () => Promise<T>): Promise<T> =>advisoryLock.withLock("model-registry", async () => {await refreshModels();@@ -1437,7 +1432,6 @@ export function buildApp(createOpenCodeHarness({...openCodeHarnessConfigOptions(config),signals: runSignals,- tasks,mcpTools,resolveCustomProviders: async () => {const enabled = await customProviders.enabled();@@ -1468,7 +1462,6 @@ export function buildApp(// runtime — resolution happens on every load....(companyCodexAuthStore ? { authStore: companyCodexAuthStore } : {}),signals: runSignals,- tasks,mcpTools,}),],@@ -1485,7 +1478,6 @@ export function buildApp(}: {}),signals: runSignals,- tasks,mcpTools,}),],@@ -2059,7 +2051,6 @@ export function buildApp(turnStream,runActivity,runs,- tasks,blobTransfer,featureFlags,teams,@@ -2098,7 +2089,7 @@ export function buildApp(? (sessionId: string): string | undefined =>uuidId.test(sessionId) ? adminSessionUrl(recoveryAdminBase, sessionId) : undefined: undefined;- const runResultRecovery = wireRunResultDeliveries(runs, deliveries, tasks, recoveryAdminUrlFor, sessions);+ const runResultRecovery = wireRunResultDeliveries(runs, deliveries, recoveryAdminUrlFor, sessions);const idempotency = createIdempotencyStore(artifactMap<IdempotencyRecord>("idempotency"));const skillFetcher = createGitFetcher(keychain@@ -2212,7 +2203,6 @@ export function buildApp(runStreamEvents,runActivity,signals: runSignals,- tasks,modelGateway,modelCredentials,userModelCredentials,@@ -2313,7 +2303,6 @@ export function buildApp(metrics,runs,turnStream,- tasks,ackPicks: ackEmojiPicks,ackModelId: () => auxiliaryModelForProvider("anthropic"),...(config.brandingDefault ? { brandingDefault: config.brandingDefault } : {}),@@ -2877,7 +2866,6 @@ export function buildApp(].map((closing) => closing?.catch(reportFailureAs("shutdown: close event stores", undefined))),);await harness.turns.close?.();- await tasks.close?.();await flyTunnel?.stop();},};@@ -2896,7 +2884,6 @@ export function buildApp(sessions,runs,signals: runSignals,- tasks,sessionStateBus,ledgerEventBus,surfaceCache,diff --git a/test/codex-harness.test.ts b/test/codex-harness.test.tsindex b8bb07f6a..0c92b6f70 100644--- a/test/codex-harness.test.ts+++ b/test/codex-harness.test.ts@@ -21,7 +21,6 @@ import {codexChildToolAllowed,codexReasoningEffort,codexReplayCallId,- codexTaskTitle,codexTokenUsageUpdate,codexTurnInputText,createCodexHarness,@@ -32,7 +31,6 @@ import { harnessToolContext } from "../src/harness/harness-shared.ts";import { createMemoryRunSignalStore } from "../src/runs/run-signal-store.ts";import { NonRetryableTurnError, ProviderTurnError } from "../src/core/turn-error.ts";import type { ScopeId, Session, SessionEntry } from "../src/types.ts";-import { createMemoryTaskStore } from "../src/tasks/memory-task-store.ts";import { CodexAppServer } from "../src/harness/codex-app-server.ts";import { redactSecrets } from "../src/harness/redact-secrets.ts";import { DEFAULT_CODEX_MODEL_ID } from "../src/model/pi-models.ts";@@ -491,8 +489,7 @@ test("Codex forwards tool-result screening into its native tool bridge", () => {test("Codex harness drives app-server JSON-RPC with a read-only jail", async (t) => {const dir = mkdtempSync(join(tmpdir(), "qm-codex-test-"));- const tasks = createMemoryTaskStore();- const harness = createCodexHarness({ binaryPath: fakeCodexBinary(dir), env: testHarnessEnv(dir), tasks });+ const harness = createCodexHarness({ binaryPath: fakeCodexBinary(dir), env: testHarnessEnv(dir) });t.after(async () => {await harness.turns.close?.();rmSync(dir, { recursive: true, force: true });@@ -526,10 +523,6 @@ test("Codex harness drives app-server JSON-RPC with a read-only jail", async (t)entries.map((entry) => entry.type),["user", "tool_call", "tool_result", "assistant"],);- assert.deepEqual(- (await tasks.list()).map(({ title, status }) => ({ title, status })),- [{ title: "return ALPHA", status: "completed" }],- );});test("Codex ignores continueTurn and still records the resume note as this attempt's user entry", async (t) => {@@ -565,14 +558,6 @@ test("Codex ignores continueTurn and still records the resume note as this attemassert.equal((entries[0]!.payload as { text: string }).text, note);});-test("Codex task titles stay concise when the provider includes the parent request", () => {- assert.equal(- codexTaskTitle("The user asked for two workers. You are the WEST subagent. Return a useful summary."),- "WEST subagent",- );- assert.equal(codexTaskTitle("Return ALPHA"), "Return ALPHA");-});-test("Codex maps the web effort control to native reasoning effort", () => {assert.equal(codexReasoningEffort("low"), "low");assert.equal(codexReasoningEffort("xhigh"), "xhigh");diff --git a/test/postgres-task-store.test.ts b/test/postgres-task-store.test.tsdeleted file mode 100644index f642241f5..000000000--- a/test/postgres-task-store.test.ts+++ /dev/null@@ -1,104 +0,0 @@-import assert from "node:assert/strict";-import { test } from "node:test";-import { createPostgresTaskStore } from "../src/tasks/postgres-task-store.ts";-import { createPostgresSessionStore } from "../src/sessions/postgres-session-store.ts";-import { scopeId } from "../src/types.ts";--const URL = process.env.DATABASE_URL;-const skip = URL ? false : "set DATABASE_URL (a Postgres) to run the pg task-store tests";--test("pg task store: tasks and events are durable across instances", { skip }, async () => {- const writer = createPostgresTaskStore(URL!);- const reader = createPostgresTaskStore(URL!);- const sessions = createPostgresSessionStore(URL!);- const key = `${Date.now()}-${Math.random().toString(36).slice(2)}`;- try {- const session = await sessions.getOrCreateByThread(`task-${key}`, "dm", scopeId("personal", `task-${key}`));- const task = await writer.create({- sessionId: session.id,- originRunId: `origin-${key}`,- title: "durable task",- });- assert.deepEqual(await reader.get(task.id), task);- assert.deepEqual(- (await reader.listOpen({ sessionId: task.sessionId })).map((row) => row.id),- [task.id],- );-- const transitioned = await reader.transitionStatus(task.id, "pending", "in_progress", `worker-${key}`);- assert.equal(transitioned?.status, "in_progress");- assert.deepEqual(- (await writer.listEvents(task.id)).map((event) => [event.type, event.runId, event.fromStatus, event.toStatus]),- [- ["created", task.originRunId, null, "pending"],- ["status_changed", `worker-${key}`, "pending", "in_progress"],- ],- );- } finally {- await writer.close?.();- await reader.close?.();- }-});--test("pg task store: concurrent status transitions use compare-and-set", { skip }, async () => {- const first = createPostgresTaskStore(URL!);- const second = createPostgresTaskStore(URL!);- const sessions = createPostgresSessionStore(URL!);- const key = `${Date.now()}-${Math.random().toString(36).slice(2)}`;- try {- const session = await sessions.getOrCreateByThread(- `task-race-${key}`,- "dm",- scopeId("personal", `task-race-${key}`),- );- const task = await first.create({ sessionId: session.id, originRunId: `origin-${key}`, title: "race" });- const results = await Promise.all([- first.transitionStatus(task.id, "pending", "completed", `winner-a-${key}`),- second.transitionStatus(task.id, "pending", "failed", `winner-b-${key}`),- ]);- assert.equal(results.filter(Boolean).length, 1);- const stored = await first.get(task.id);- assert.ok(stored);- assert.ok(stored.status === "completed" || stored.status === "failed");- const events = await second.listEvents(task.id);- assert.equal(events.length, 2, "the losing CAS does not append an event");- assert.equal(events[1]?.toStatus, stored.status);- } finally {- await first.close?.();- await second.close?.();- }-});--test("pg task store: open filters compose session and origin run", { skip }, async () => {- const tasks = createPostgresTaskStore(URL!);- const sessions = createPostgresSessionStore(URL!);- const key = `${Date.now()}-${Math.random().toString(36).slice(2)}`;- const originRunId = `origin-${key}`;- try {- const sessionId = (- await sessions.getOrCreateByThread(`task-filter-${key}`, "dm", scopeId("personal", `task-filter-${key}`))- ).id;- const otherSessionId = (- await sessions.getOrCreateByThread(- `task-filter-other-${key}`,- "dm",- scopeId("personal", `task-filter-other-${key}`),- )- ).id;- const wanted = await tasks.create({ sessionId, originRunId, title: "wanted", status: "in_progress" });- await tasks.create({ sessionId, originRunId: `other-${key}`, title: "other origin" });- await tasks.create({ sessionId: otherSessionId, originRunId, title: "other session" });- await tasks.create({ sessionId, originRunId, title: "closed", status: "skipped" });-- assert.deepEqual(- (await tasks.listOpen({ sessionId, originRunId })).map((task) => task.id),- [wanted.id],- );- assert.deepEqual(- (await tasks.list({ sessionId, statuses: ["skipped"] })).map((task) => task.title),- ["closed"],- );- } finally {- await tasks.close?.();- }-});diff --git a/test/run-result-delivery.test.ts b/test/run-result-delivery.test.tsindex 7b35d56f4..07cb9dfbe 100644--- a/test/run-result-delivery.test.ts+++ b/test/run-result-delivery.test.ts@@ -172,27 +172,12 @@ test("runResultDelivery carries the surface's edit checkpoint into the destinatiassert.equal(d?.destination.editRef, "171.002");});-test("runResultDelivery carries a durable terminal task projection", () => {- const d = runResultDelivery(run({ deliveryState: { editRef: "171.002" } }), [- {- id: "task-1",- sessionId: "s1",- originRunId: "r-1",- title: "research",- status: "failed",- createdAt: 1,- updatedAt: 2,- },- ]);- assert.deepEqual(d?.destination.taskList, [{ id: "task-1", title: "research", status: "failed" }]);-});-test("runResultDelivery links the admin error page when a resolver is wired", () => {const failed = run({status: "failed",result: { status: "failed", sessionId: "b6f3f9e2-0000-4000-8000-000000000001", reason: "boom" },});- const d = runResultDelivery(failed, [], (sessionId) => `https://portal.example.com/admin/?session=${sessionId}`);+ const d = runResultDelivery(failed, (sessionId) => `https://portal.example.com/admin/?session=${sessionId}`);assert.equal(d?.text,"⚠️ I couldn't finish that turn: something went wrong on my end — full error: https://portal.example.com/admin/?session=b6f3f9e2-0000-4000-8000-000000000001",@@ -442,7 +427,7 @@ test("wired stores: a parked Slack run gets both the durable session entry and tconst { sessions, session } = await failureSessions();const { runs } = createMemoryRunStore();const deliveries = createDeliveryStore();- wireRunResultDeliveries(runs, deliveries, undefined, undefined, sessions);+ wireRunResultDeliveries(runs, deliveries, undefined, sessions);const parked = (await runs.enqueue({ sessionId: "slack:D1", request: turn("p", "D1:171.001"), maxAttempts: 1 })).run;const claimed = await runs.claim("w1", 5_000);diff --git a/test/slack-presenters.test.ts b/test/slack-presenters.test.tsindex 37e91f7a6..09ef8b9f0 100644--- a/test/slack-presenters.test.ts+++ b/test/slack-presenters.test.ts@@ -1,195 +1,6 @@import { test } from "node:test";import assert from "node:assert/strict";-import {- renderTaskList,- createTaskListPresenter,- createAckPresenter,- stripAckPrefix,- renderGoalNotice,- createGoalNoticePresenter,- deliveryMetadata,-} from "../src/slack/lib.ts";--test("renderTaskList renders every terminal state", () => {- assert.equal(- renderTaskList([- { id: "a", title: "done", status: "completed" },- { id: "b", title: "omitted", status: "skipped" },- { id: "c", title: "broken", status: "failed" },- ]),- "*3 tasks*\n✓ ~done~\n– ~omitted~\n✕ ~broken~",- );-});--test("renderTaskList escapes task titles as Slack text", () => {- assert.equal(- renderTaskList([{ id: "a", title: "inspect <@U123> & report", status: "pending" }]),- "*1 task*\n○ inspect <@U123> & report",- );-});--test("renderTaskList preserves distinct tasks that share a title", () => {- assert.equal(- renderTaskList([- { id: "a", title: "research queue", status: "failed" },- { id: "b", title: "research queue", status: "in_progress" },- { id: "c", title: "write report", status: "completed" },- ]),- "*3 tasks*\n✕ ~research queue~\n◐ research queue\n✓ ~write report~",- );-});--test("renderTaskList bounds rows and normalizes titles to one line", () => {- const rendered = renderTaskList(- Array.from({ length: 25 }, (_, index) => ({- id: String(index),- title: `${index} ${"x".repeat(140)}\nforged row`,- status: "pending" as const,- })),- );- assert.ok(rendered.length < 3_000);- assert.match(rendered, /… 5 more$/);- assert.equal(rendered.includes("\nforged row"), false);-});--test("task presenter posts once, updates in place, checkpoints, and finalizes the same message", async () => {- const calls: string[] = [];- const presenter = createTaskListPresenter({- post: async (text) => {- calls.push(`post:${text}`);- return "171.2";- },- update: async (ts, text) => {- calls.push(`update:${ts}:${text}`);- },- checkpoint: async (ts) => {- calls.push(`checkpoint:${ts}`);- },- remove: async (ts) => {- calls.push(`remove:${ts}`);- },- onSurfacePosted: () => calls.push("surface"),- });-- await presenter.onTasks([{ id: "a", title: "research", status: "pending" }]);- await presenter.onTasks([{ id: "a", title: "research", status: "completed" }]);- assert.equal(await presenter.finalize("Final answer"), true);- assert.deepEqual(calls, [- "post:*1 task*\n○ research",- "checkpoint:171.2",- "surface",- "update:171.2:*1 task*\n✓ ~research~",- "update:171.2:Final answer",- ]);-});--test("finalize stamps the delivery marker on the task message; progress updates carry none", async () => {- const updates: Array<{ text: string; metadata?: unknown }> = [];- const presenter = createTaskListPresenter({- post: async () => "171.9",- update: async (_ts, text, _blocks, metadata) => {- updates.push({ text, ...(metadata ? { metadata } : {}) });- },- checkpoint: async () => {},- remove: async () => {},- onSurfacePosted: () => {},- });- await presenter.onTasks([{ id: "a", title: "research", status: "pending" }]);- await presenter.onTasks([{ id: "a", title: "research", status: "completed" }]);- assert.equal(await presenter.finalize("Final answer", deliveryMetadata("run:R7")), true);- assert.deepEqual(updates, [- { text: "*1 task*\n✓ ~research~" },- {- text: "Final answer",- metadata: { event_type: "qm_delivery", event_payload: { idempotency_key: "run:R7" } },- },- ]);-});--test("task presenter attaches beneath an existing ack and retries terminal updates", async () => {- const calls: string[] = [];- let attempts = 0;- const presenter = createTaskListPresenter({- post: async () => {- throw new Error("must not post");- },- update: async (ts, text) => {- attempts += 1;- calls.push(`${ts}:${text}`);- if (text === "Final" && attempts < 4) throw new Error("transient");- },- checkpoint: async (ts) => {- calls.push(`checkpoint:${ts}`);- },- remove: async (ts) => {- calls.push(`remove:${ts}`);- },- onSurfacePosted: () => calls.push("surface"),- sleep: async () => {},- });- await presenter.attach("171.3", "On it.");- await presenter.onTasks([{ id: "a", title: "consult", status: "in_progress" }]);- assert.equal(await presenter.finalize("Final"), true);- assert.deepEqual(calls, [- "checkpoint:171.3",- "171.3:On it.\n\n*1 task*\n◐ consult",- "171.3:Final",- "171.3:Final",- "171.3:Final",- ]);-});--test("task presenter merges a late ack into the existing task message", async () => {- const calls: string[] = [];- const presenter = createTaskListPresenter({- post: async () => "171.4",- update: async (ts, text) => {- calls.push(`${ts}:${text}`);- },- checkpoint: async () => {},- remove: async () => {},- onSurfacePosted: () => {},- });- await presenter.onTasks([{ id: "a", title: "research", status: "in_progress" }]);- assert.equal(await presenter.addLead("Still working."), true);- assert.deepEqual(calls, ["171.4:Still working.\n\n*1 task*\n◐ research"]);-});--test("task presenter removes an ack whose durable checkpoint fails", async () => {- const removed: string[] = [];- const presenter = createTaskListPresenter({- post: async () => undefined,- update: async () => {},- checkpoint: async () => {- throw new Error("core unavailable");- },- remove: async (ts) => {- removed.push(ts);- },- onSurfacePosted: () => {},- });- await assert.rejects(presenter.attach("171.5", "On it."), /core unavailable/);- assert.deepEqual(removed, ["171.5"]);-});--test("task presenter reports a failed late-ack merge", async () => {- const removed: string[] = [];- const presenter = createTaskListPresenter({- post: async () => "171.6",- update: async () => {- throw new Error("Slack unavailable");- },- checkpoint: async () => {},- remove: async (ts) => {- removed.push(ts);- },- onSurfacePosted: () => {},- sleep: async () => {},- });- await presenter.onTasks([{ id: "a", title: "research", status: "in_progress" }]);- assert.equal(await presenter.addLead("Still working."), false);- assert.deepEqual(removed, ["171.6"]);-});+import { createAckPresenter, stripAckPrefix, renderGoalNotice, createGoalNoticePresenter } from "../src/slack/lib.ts";function presenterHarness(opts: { reactionDelayMs?: number } = {}) {const calls: string[] = [];diff --git a/test/slack-session-status.test.ts b/test/slack-session-status.test.tsindex 2cb9e7a29..0035d0611 100644--- a/test/slack-session-status.test.ts+++ b/test/slack-session-status.test.ts@@ -358,7 +358,6 @@ test("core engagement is signaled once for local or durable replies, never quiet},},turnStream: stream,- tasks: { list: async () => [] },app: { getRun: async () => ({ result: { status: "silent" } }) },} as unknown as SlackCoreClientDeps);await core.waitRun("r1", {diff --git a/test/slack-unprompted-ack.test.ts b/test/slack-unprompted-ack.test.tsindex f4cced04b..e3babdd03 100644--- a/test/slack-unprompted-ack.test.ts+++ b/test/slack-unprompted-ack.test.ts@@ -85,20 +85,6 @@ function harness(run: (hooks: any) => Promise<unknown>) {return { handler, client, followup, reactions, posts, postArgs, turns };}-test("the task-list placeholder is posted with its run's status key so a recovered reply can find it", async () => {- const h = harness(async (hooks) => {- await hooks.onQueued?.("r1");- await hooks.onTasks?.([{ id: "t1", title: "Check staging", status: "in_progress" }]);- return { status: "ok", reply: "Staging is green." };- });- await h.handler.handleIncoming({ ...h.followup, unprompted: false, rawText: "<@UBOT> check staging" }, h.client);- const placeholder = h.postArgs.find((args) => String(args.text).includes("Check staging"));- assert.deepEqual(placeholder?.metadata, {- event_type: "qm_delivery",- event_payload: { idempotency_key: "status:run:r1" },- });-});-test("an unmentioned thread followup QM answers gets the ack reaction added then cleared", async () => {const h = harness(async (hooks) => {hooks.onReplying?.();@@ -178,7 +164,6 @@ test("waitRun signals replying only once the run has passed detection and begunreturn { id: "r1", status: polls >= 4 ? "done" : "running", attempts: 1 };},},- tasks: { list: async () => [] },app: { getRun: async () => ({ result: { status: "ok", reply: "done" } }) },} as any);await client.waitRun("r1", {diff --git a/test/task-store.test.ts b/test/task-store.test.tsdeleted file mode 100644index a6a099e87..000000000--- a/test/task-store.test.ts+++ /dev/null@@ -1,88 +0,0 @@-import assert from "node:assert/strict";-import { describe, it } from "node:test";-import { createMemoryTaskStore } from "../src/tasks/memory-task-store.ts";-import { TASK_STATUSES } from "../src/tasks/task-store.ts";--describe("memory task store", () => {- let time = 1_000;- const store = () => createMemoryTaskStore({ now: () => ++time });-- it("creates every supported status and records an initial event", async () => {- const tasks = store();- for (const status of TASK_STATUSES) {- const task = await tasks.create({ sessionId: "session", originRunId: `run-${status}`, title: status, status });- assert.equal(task.status, status);- assert.deepEqual(await tasks.listEvents(task.id), [- {- id: String(TASK_STATUSES.indexOf(status) + 1),- taskId: task.id,- runId: `run-${status}`,- type: "created",- fromStatus: null,- toStatus: status,- createdAt: task.createdAt,- },- ]);- }- });-- it("lists open tasks filtered by session and origin run", async () => {- const tasks = store();- const first = await tasks.create({ sessionId: "s1", originRunId: "r1", title: "first" });- const second = await tasks.create({ sessionId: "s1", originRunId: "r2", title: "second", status: "in_progress" });- await tasks.create({ sessionId: "s2", originRunId: "r1", title: "other session" });- await tasks.create({ sessionId: "s1", originRunId: "r1", title: "done", status: "completed" });-- assert.deepEqual(- (await tasks.listOpen({ sessionId: "s1" })).map((task) => task.id),- [first.id, second.id],- );- assert.deepEqual(- (await tasks.listOpen({ originRunId: "r1" })).map((task) => task.title),- ["first", "other session"],- );- assert.deepEqual(- (await tasks.listOpen({ sessionId: "s1", originRunId: "r1" })).map((task) => task.id),- [first.id],- );- assert.deepEqual(- (await tasks.list({ sessionId: "s1", statuses: ["completed"] })).map((task) => task.title),- ["done"],- );- });-- it("uses compare-and-set transitions and appends only successful events", async () => {- const tasks = store();- const task = await tasks.create({ sessionId: "s1", originRunId: "origin", title: "ship it" });-- const [won, lost] = await Promise.all([- tasks.transitionStatus(task.id, "pending", "in_progress", "worker-a"),- tasks.transitionStatus(task.id, "pending", "failed", "worker-b"),- ]);- assert.equal(won?.status, "in_progress");- assert.equal(lost, null);- assert.equal((await tasks.get(task.id))?.status, "in_progress");-- const completed = await tasks.transitionStatus(task.id, "in_progress", "completed", "worker-a");- assert.equal(completed?.status, "completed");- assert.deepEqual(- (await tasks.listEvents(task.id)).map((event) => [event.runId, event.fromStatus, event.toStatus]),- [- ["origin", null, "pending"],- ["worker-a", "pending", "in_progress"],- ["worker-a", "in_progress", "completed"],- ],- );- assert.deepEqual(await tasks.listOpen({ sessionId: "s1" }), []);- });-- it("returns copies that cannot mutate task or event state", async () => {- const tasks = store();- const task = await tasks.create({ sessionId: "s1", originRunId: "r1", title: "immutable reads" });- task.status = "failed";- const event = (await tasks.listEvents(task.id))[0]!;- event.toStatus = "failed";- assert.equal((await tasks.get(task.id))?.status, "pending");- assert.equal((await tasks.listEvents(task.id))[0]?.toStatus, "pending");- });-});diff --git a/test/turn-stream.test.ts b/test/turn-stream.test.tsindex 7a5aec0e9..a0c7b418f 100644--- a/test/turn-stream.test.ts+++ b/test/turn-stream.test.ts@@ -169,35 +169,6 @@ test("a queued tool-using run surfaces its activity + timings via getRun()", asy}});-test("getRun projects durable tasks for its surface poller", async () => {- const built = buildApp(- testConfig({- dataDir: mkdtempSync(join(tmpdir(), "ts-")),- workers: 0,- leaseTtlMs: 5_000,- reaperIntervalMs: 60_000,- }),- );- const ack = await built.app.turn({- surface: "test",- actor: { externalId: "U1" },- conversation: { kind: "dm", threadRef: "task-view" },- text: "hello",- async: true,- });- await built.tasks.create({- id: "task-1",- sessionId: "task-view",- originRunId: ack.runId!,- title: "research",- status: "in_progress",- });-- assert.deepEqual((await built.app.getRun(ack.runId!))?.tasks, [- { id: "task-1", title: "research", status: "in_progress" },- ]);-});-test("a queued run exposes the agent's in-flight reply via getRun().partial", async () => {const built = buildApp(testConfig({diff --git a/test/web-transcript-delivery.test.ts b/test/web-transcript-delivery.test.tsindex 6db325d17..d39395202 100644--- a/test/web-transcript-delivery.test.ts+++ b/test/web-transcript-delivery.test.ts@@ -328,7 +328,7 @@ test("an onTerminal-recorded failure entry suppresses the web drain's duplicateconst { sessions, inner, deliveries } = wired();const session = await webSession(sessions);const runs = createMemoryRunStore().runs;- wireRunResultDeliveries(runs, inner, undefined, undefined, sessions);+ wireRunResultDeliveries(runs, inner, undefined, sessions);const run = (await runs.enqueue({ sessionId: THREAD, request: webTurn(THREAD), maxAttempts: 1 })).run;const claimed = await runs.claim("w1", 5_000);await runs.fail(run.id, claimed?.leaseToken ?? "", "lease expired (reaped)", { retry: true });