Open History to see the last commit
1import { expect, it } from "@effect/vitest";
2import {
3 CommandId,
4 type OrchestrationV2Command,
5 ProjectId,
6 ProviderInstanceId,
7 RunId,
8 ThreadId,
9} from "@t3tools/contracts";
10
11import { withCreationProvenance } from "./ThreadManagementService.ts";
12
13it("stamps authoritative provenance on commands that create threads or messages", () => {
14 const command: OrchestrationV2Command = {
15 type: "thread.create",
16 createdBy: "agent",
17 creationSource: "mcp",
18 commandId: CommandId.make("command:thread-management:create"),
19 threadId: ThreadId.make("thread:thread-management:create"),
20 projectId: ProjectId.make("project:thread-management"),
21 title: "Thread management",
22 modelSelection: {
23 instanceId: ProviderInstanceId.make("codex"),
24 model: "gpt-5-codex",
25 },
26 runtimeMode: "full-access",
27 interactionMode: "default",
28 branch: null,
29 worktreePath: null,
30 };
31
32 expect(
33 withCreationProvenance(command, {
34 createdBy: "user",
35 creationSource: "web",
36 }),
37 ).toMatchObject({
38 createdBy: "user",
39 creationSource: "web",
40 });
41});
42
43it("leaves commands that do not create durable authored content unchanged", () => {
44 const command: OrchestrationV2Command = {
45 type: "run.interrupt",
46 commandId: CommandId.make("command:thread-management:interrupt"),
47 threadId: ThreadId.make("thread:thread-management:interrupt"),
48 runId: RunId.make("run:thread-management:interrupt"),
49 };
50
51 expect(
52 withCreationProvenance(command, {
53 createdBy: "user",
54 creationSource: "web",
55 }),
56 ).toBe(command);
57});