fix: reconcile the observability series with the rebased v2 base
The base rebased onto main again, renumbering migrations (subagent observability moves 045 to 046) and reworking three paths this series extends: Claude's background-task lookup, ACP's terminal-status helper, and turn-item routing for inherited background items. Each merge keeps both intents — the base's newer mechanism with this branch's activation, identity-proof, and completedAt semantics. ProviderTurnStartService.test.ts was added on both sides as different files; rebuilt as the base's suite plus this branch's rehydration tests. Test mocks and fixtures gain the members the observability types now require. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
4b3f8be173
commit
1391f94470
8 files changed
+79
-57
No files matched your search
@@ -3,6 +3,7 @@ import * as NodeFS from "node:fs";
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import {
|
||||
orchestrationV2SubagentStatusAsTurnItemStatus,
|
||||
type ChatAttachment,
|
||||
type ModelSelection,
|
||||
type OrchestrationV2ConversationMessage,
|
||||
@@ -4043,7 +4044,7 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV
|
||||
parentNodeId: subagent.task.parentNodeId,
|
||||
rootNodeId: subagent.task.parentNodeId,
|
||||
kind: "subagent",
|
||||
status,
|
||||
status: orchestrationV2SubagentStatusAsTurnItemStatus[status],
|
||||
countsForRun: false,
|
||||
providerThreadId: parentProviderThreadId,
|
||||
providerTurnId: subagent.providerTurnId,
|
||||
@@ -4064,7 +4065,7 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV
|
||||
parentNodeId: null,
|
||||
rootNodeId: subagent.childRootNodeId,
|
||||
kind: "root_turn",
|
||||
status,
|
||||
status: orchestrationV2SubagentStatusAsTurnItemStatus[status],
|
||||
countsForRun: false,
|
||||
providerThreadId: subagent.task.providerThreadId,
|
||||
providerTurnId: null,
|
||||
@@ -4093,7 +4094,7 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV
|
||||
nativeItemRef,
|
||||
parentItemId: null,
|
||||
ordinal: subagent.turnItemOrdinal,
|
||||
status,
|
||||
status: orchestrationV2SubagentStatusAsTurnItemStatus[status],
|
||||
title: subagent.task.title,
|
||||
startedAt: subagent.task.startedAt,
|
||||
completedAt,
|
||||
|
||||
@@ -1679,6 +1679,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
|
||||
offer: () => Effect.void,
|
||||
setModel: () => Effect.void,
|
||||
interrupt: Effect.void,
|
||||
stopTask: () => Effect.void,
|
||||
// End the message stream so interruptTurn's closed wait resolves
|
||||
// via stream exit finalize (interrupted status clears roster).
|
||||
close: Queue.shutdown(sdkMessages),
|
||||
@@ -1804,6 +1805,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
|
||||
offer: () => Effect.void,
|
||||
setModel: () => Effect.void,
|
||||
interrupt: Effect.void,
|
||||
stopTask: () => Effect.void,
|
||||
close: Queue.shutdown(queue),
|
||||
};
|
||||
}),
|
||||
@@ -3798,6 +3800,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
|
||||
offer: () => Effect.void,
|
||||
setModel: () => Effect.void,
|
||||
interrupt: Effect.void,
|
||||
stopTask: () => Effect.void,
|
||||
// End this process stream so openQuery can replace it.
|
||||
close: Queue.shutdown(sdkMessages),
|
||||
};
|
||||
@@ -4064,6 +4067,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
|
||||
offer: () => Effect.void,
|
||||
setModel: () => Effect.void,
|
||||
interrupt: Effect.void,
|
||||
stopTask: () => Effect.void,
|
||||
close: Queue.shutdown(sdkMessages),
|
||||
};
|
||||
}),
|
||||
@@ -4296,6 +4300,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
|
||||
offer: () => Effect.void,
|
||||
setModel: () => Effect.void,
|
||||
interrupt: Effect.void,
|
||||
stopTask: () => Effect.void,
|
||||
close: Queue.shutdown(sdkMessages),
|
||||
};
|
||||
}),
|
||||
@@ -4492,6 +4497,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
|
||||
offer: () => Effect.void,
|
||||
setModel: () => Effect.void,
|
||||
interrupt: Effect.void,
|
||||
stopTask: () => Effect.void,
|
||||
close: Queue.shutdown(sdkMessages),
|
||||
};
|
||||
});
|
||||
@@ -4628,6 +4634,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
|
||||
offer: () => Effect.void,
|
||||
setModel: () => Effect.void,
|
||||
interrupt: Effect.void,
|
||||
stopTask: () => Effect.void,
|
||||
close: Queue.shutdown(sdkMessages),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -246,6 +246,14 @@ const seedParentWithTerminalTask = (input: {
|
||||
occurredAt: input.now,
|
||||
payload: {
|
||||
id: input.taskId,
|
||||
kind: "subagent" as const,
|
||||
role: { name: "general-purpose", source: "app_default" as const },
|
||||
usage: null,
|
||||
currentActivationId: null,
|
||||
activationCount: 1,
|
||||
workflow: null,
|
||||
workflowMembership: null,
|
||||
recentActivity: [],
|
||||
threadId: input.threadId,
|
||||
runId: input.runId,
|
||||
parentNodeId: input.rootNodeId,
|
||||
|
||||
@@ -214,6 +214,14 @@ it.layer(TestLayer)("ProjectionStoreV2", (it) => {
|
||||
};
|
||||
const task = {
|
||||
id: taskId,
|
||||
kind: "subagent" as const,
|
||||
role: { name: "general-purpose", source: "app_default" as const },
|
||||
usage: null,
|
||||
currentActivationId: null,
|
||||
activationCount: 1,
|
||||
workflow: null,
|
||||
workflowMembership: null,
|
||||
recentActivity: [],
|
||||
threadId,
|
||||
runId,
|
||||
parentNodeId: rootNodeId,
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
RunAttemptId,
|
||||
RunId,
|
||||
TurnItemId,
|
||||
RunId,
|
||||
SubagentActivationId,
|
||||
} from "@t3tools/contracts";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { expect, it, vi } from "vite-plus/test";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import {
|
||||
CheckpointScopeId,
|
||||
@@ -12,19 +11,35 @@ import {
|
||||
RunAttemptId,
|
||||
RunId,
|
||||
ThreadId,
|
||||
type OrchestrationV2ThreadProjection,
|
||||
TurnItemId,
|
||||
} from "@t3tools/contracts";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Ref from "effect/Ref";
|
||||
import { expect, vi } from "vite-plus/test";
|
||||
|
||||
import * as ContextHandoffService from "./ContextHandoffService.ts";
|
||||
import { ContextHandoffServiceV2 } from "./ContextHandoffService.ts";
|
||||
import * as EventSink from "./EventSink.ts";
|
||||
import { EventSinkV2 } from "./EventSink.ts";
|
||||
import * as IdAllocator from "./IdAllocator.ts";
|
||||
import type { ProviderAdapterV2SessionRuntime } from "./ProviderAdapter.ts";
|
||||
import * as ProjectionStore from "./ProjectionStore.ts";
|
||||
import {
|
||||
ProjectionStoreReadError,
|
||||
ProjectionStoreThreadNotFoundError,
|
||||
ProjectionStoreV2,
|
||||
type ProjectionStoreV2Error,
|
||||
} from "./ProjectionStore.ts";
|
||||
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
|
||||
import { ProviderSessionManagerV2 } from "./ProviderSessionManager.ts";
|
||||
import * as ProviderTurnStart from "./ProviderTurnStartService.ts";
|
||||
import * as ProviderTurnStartService from "./ProviderTurnStartService.ts";
|
||||
import * as RunExecutionService from "./RunExecutionService.ts";
|
||||
import { RunExecutionServiceV2 } from "./RunExecutionService.ts";
|
||||
import * as RuntimePolicy from "./RuntimePolicy.ts";
|
||||
import { RuntimePolicyV2 } from "./RuntimePolicy.ts";
|
||||
|
||||
it("does not commit running state when inherited background routing cannot be read", async () => {
|
||||
const threadId = ThreadId.make("thread_provider_turn_start_projection_failure");
|
||||
@@ -46,55 +61,6 @@ it("does not commit running state when inherited background routing cannot be re
|
||||
runs: [
|
||||
{
|
||||
id: runId,
|
||||
TurnItemId,
|
||||
} from "@t3tools/contracts";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Ref from "effect/Ref";
|
||||
|
||||
import { ContextHandoffServiceV2 } from "./ContextHandoffService.ts";
|
||||
import { EventSinkV2 } from "./EventSink.ts";
|
||||
import * as IdAllocator from "./IdAllocator.ts";
|
||||
import type { ProviderAdapterV2SessionRuntime } from "./ProviderAdapter.ts";
|
||||
import {
|
||||
ProjectionStoreReadError,
|
||||
ProjectionStoreThreadNotFoundError,
|
||||
ProjectionStoreV2,
|
||||
type ProjectionStoreV2Error,
|
||||
} from "./ProjectionStore.ts";
|
||||
import { ProviderSessionManagerV2 } from "./ProviderSessionManager.ts";
|
||||
import * as ProviderTurnStartService from "./ProviderTurnStartService.ts";
|
||||
import { RunExecutionServiceV2 } from "./RunExecutionService.ts";
|
||||
import { RuntimePolicyV2 } from "./RuntimePolicy.ts";
|
||||
|
||||
const driver = ProviderDriverKind.make("codex");
|
||||
const threadId = ThreadId.make("thread:provider-turn-start");
|
||||
const childThreadId = ThreadId.make("thread:provider-turn-start:child");
|
||||
const runId = RunId.make("run:provider-turn-start");
|
||||
const rootNodeId = NodeId.make("node:provider-turn-start:root");
|
||||
const subagentId = NodeId.make("node:provider-turn-start:subagent");
|
||||
const attemptId = RunAttemptId.make("attempt:provider-turn-start");
|
||||
const providerThreadId = ProviderThreadId.make("provider-thread:provider-turn-start");
|
||||
const childProviderThreadId = ProviderThreadId.make("provider-thread:provider-turn-start:child");
|
||||
const providerSessionId = ProviderSessionId.make("provider-session:provider-turn-start");
|
||||
const providerInstanceId = ProviderInstanceId.make("codex");
|
||||
const messageId = MessageId.make("message:provider-turn-start");
|
||||
const checkpointScopeId = CheckpointScopeId.make("checkpoint-scope:provider-turn-start");
|
||||
|
||||
function makeRootProjection(now: DateTime.Utc): OrchestrationV2ThreadProjection {
|
||||
return {
|
||||
thread: {
|
||||
id: threadId,
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
worktreePath: "/tmp/provider-turn-start",
|
||||
},
|
||||
runs: [
|
||||
{
|
||||
id: runId,
|
||||
threadId,
|
||||
ordinal: 1,
|
||||
status: "starting",
|
||||
rootNodeId,
|
||||
activeAttemptId: attemptId,
|
||||
@@ -154,6 +120,38 @@ function makeRootProjection(now: DateTime.Utc): OrchestrationV2ThreadProjection
|
||||
expect(startRootRun).not.toHaveBeenCalled();
|
||||
}).pipe(Effect.provide(layer), Effect.runPromise);
|
||||
});
|
||||
|
||||
const driver = ProviderDriverKind.make("codex");
|
||||
const threadId = ThreadId.make("thread:provider-turn-start");
|
||||
const childThreadId = ThreadId.make("thread:provider-turn-start:child");
|
||||
const runId = RunId.make("run:provider-turn-start");
|
||||
const rootNodeId = NodeId.make("node:provider-turn-start:root");
|
||||
const subagentId = NodeId.make("node:provider-turn-start:subagent");
|
||||
const attemptId = RunAttemptId.make("attempt:provider-turn-start");
|
||||
const providerThreadId = ProviderThreadId.make("provider-thread:provider-turn-start");
|
||||
const childProviderThreadId = ProviderThreadId.make("provider-thread:provider-turn-start:child");
|
||||
const providerSessionId = ProviderSessionId.make("provider-session:provider-turn-start");
|
||||
const providerInstanceId = ProviderInstanceId.make("codex");
|
||||
const messageId = MessageId.make("message:provider-turn-start");
|
||||
const checkpointScopeId = CheckpointScopeId.make("checkpoint-scope:provider-turn-start");
|
||||
|
||||
function makeRootProjection(now: DateTime.Utc): OrchestrationV2ThreadProjection {
|
||||
return {
|
||||
thread: {
|
||||
id: threadId,
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
worktreePath: "/tmp/provider-turn-start",
|
||||
},
|
||||
runs: [
|
||||
{
|
||||
id: runId,
|
||||
threadId,
|
||||
ordinal: 1,
|
||||
status: "starting",
|
||||
rootNodeId,
|
||||
activeAttemptId: attemptId,
|
||||
providerThreadId,
|
||||
providerInstanceId,
|
||||
userMessageId: messageId,
|
||||
modelSelection: { instanceId: providerInstanceId },
|
||||
|
||||
@@ -578,7 +578,8 @@ export function routeProviderEvent(
|
||||
ownsChildThread(event.turnItem.threadId) ||
|
||||
// A reused subagent's row and its timeline item are emitted together;
|
||||
// routing only the row would advance the agent while its item stayed
|
||||
// frozen on the spawning run.
|
||||
// frozen on the spawning run. Proof of driving is required for the
|
||||
// same reason as the row route.
|
||||
(event.turnItem.type === "subagent" && drivesSubagent(event.turnItem.subagentId))
|
||||
) {
|
||||
return [true, state];
|
||||
|
||||
@@ -13,7 +13,7 @@ layer("038_039_OrchestrationV2", (it) => {
|
||||
Effect.sync(() => {
|
||||
assert.deepStrictEqual(
|
||||
migrationEntries.map(([id]) => id),
|
||||
Array.from({ length: 49 }, (_, index) => index + 1),
|
||||
Array.from({ length: 50 }, (_, index) => index + 1),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user