Skip to content

Commit a39a4e6

Browse files
test(server): drop replay tests duplicated by adapter coverage
The Muse and Pi replay tests asserted the same preserved answers that the adapter unit tests and the extended muse_permission fixture already catch on main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 5352e86 commit a39a4e6

2 files changed

Lines changed: 4 additions & 369 deletions

File tree

Lines changed: 2 additions & 269 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
import { projectionFor } from "./fixtures/shared.ts";
2-
import type { ProviderReplayEntry } from "@t3tools/contracts";
3-
import { assert, describe, it } from "@effect/vitest";
1+
import { describe } from "@effect/vitest";
42

53
import {
64
materializeMuseReplayWorkspace,
75
MuseOrchestratorReplayHarness,
86
} from "../Adapters/MuseAdapterV2.testkit.ts";
9-
import {
10-
findReplayFixture,
11-
itRunsReplayFixtures,
12-
runReplayFixture,
13-
} from "./ProviderReplayFixtures.ts";
7+
import { itRunsReplayFixtures, runReplayFixture } from "./ProviderReplayFixtures.ts";
148

159
describe("Muse replay fixtures", () => {
1610
itRunsReplayFixtures("muse", (input) =>
@@ -20,265 +14,4 @@ describe("Muse replay fixtures", () => {
2014
materializeWorkspace: materializeMuseReplayWorkspace,
2115
}),
2216
);
23-
it.effect(
24-
"keeps Muse answers and decisions across native acknowledgement and turn cleanup",
25-
() => {
26-
const fixture = findReplayFixture("simple");
27-
const provider = fixture?.providers.find((candidate) => candidate.driver === "muse");
28-
assert.isDefined(fixture);
29-
assert.isDefined(provider);
30-
const answers = { approach: ["Small", "Keep tests focused"] };
31-
return runReplayFixture({
32-
harness: MuseOrchestratorReplayHarness,
33-
materializeWorkspace: materializeMuseReplayWorkspace,
34-
fixtureName: fixture.name,
35-
buildInput: () => ({
36-
...fixture.buildInput(),
37-
steps: [
38-
...fixture.buildInput().steps,
39-
{ type: "answer_next_user_input_request", answers },
40-
{ type: "answer_next_user_input_request", answers },
41-
{ type: "approve_next_runtime_request", decision: "acceptForSession" },
42-
],
43-
}),
44-
driver: {
45-
...provider,
46-
assertOutput: (result) => {
47-
const projection = projectionFor(result, fixture.name);
48-
assert.equal(projection.runs.at(-1)?.status, "completed");
49-
assert.lengthOf(projection.runtimeRequests, 3);
50-
const observed = [];
51-
const expected = [];
52-
for (const nativeId of ["question-ack", "question-no-ack", "approval-no-ack"]) {
53-
const request = projection.runtimeRequests.find(
54-
(candidate) => candidate.nativeRequestRef?.nativeId === nativeId,
55-
);
56-
assert.isDefined(request);
57-
const card = projection.turnItems.find((item) => item.nodeId === request.nodeId);
58-
const node = projection.nodes.find((candidate) => candidate.id === request.nodeId);
59-
const isQuestion = request.kind === "user_input";
60-
const response = isQuestion ? { answers } : { decision: "acceptForSession" as const };
61-
const submitted = result.domainEvents.find(
62-
(event) =>
63-
event.type === "runtime-request.updated" &&
64-
event.payload.id === request.id &&
65-
event.payload.status === "resolved",
66-
);
67-
assert.isDefined(submitted, `${nativeId} was persisted before native delivery`);
68-
assert.deepInclude(submitted.payload, response);
69-
if (!isQuestion) {
70-
const assistantItemIndex = result.domainEvents.findIndex(
71-
(event) =>
72-
event.type === "turn-item.updated" &&
73-
event.payload.type === "assistant_message",
74-
);
75-
const submittedIndex = result.domainEvents.indexOf(submitted);
76-
assert.isAbove(assistantItemIndex, submittedIndex);
77-
// The next assistant item is persisted after stageResolved, before turn cleanup.
78-
const beforeAssistant = result.domainEvents.slice(0, assistantItemIndex);
79-
const requestAtUpdate = beforeAssistant.findLast(
80-
(event) =>
81-
event.type === "runtime-request.updated" && event.payload.id === request.id,
82-
);
83-
const nodeAtUpdate = beforeAssistant.findLast(
84-
(event) => event.type === "node.updated" && event.payload.id === request.nodeId,
85-
);
86-
const cardAtUpdate = beforeAssistant.findLast(
87-
(event) =>
88-
event.type === "turn-item.updated" && event.payload.nodeId === request.nodeId,
89-
);
90-
assert.deepInclude(
91-
requestAtUpdate?.payload,
92-
{ status: "resolved", decision: "acceptForSession" },
93-
"stageResolved must preserve the persisted T3 decision before turn cleanup",
94-
);
95-
assert.deepInclude(nodeAtUpdate?.payload, { status: "completed" });
96-
assert.deepInclude(cardAtUpdate?.payload, { status: "completed" });
97-
}
98-
observed.push({
99-
nativeId,
100-
status: request.status,
101-
answers: request.answers,
102-
decision: request.decision,
103-
nodeStatus: node?.status,
104-
cardStatus: card?.status,
105-
questionAnswer:
106-
card?.type === "user_input_request" ? card.questionAnswer : undefined,
107-
});
108-
expected.push({
109-
nativeId,
110-
status: "resolved",
111-
answers: isQuestion ? answers : undefined,
112-
decision: isQuestion ? undefined : "acceptForSession",
113-
nodeStatus: "completed",
114-
cardStatus: "completed",
115-
questionAnswer: isQuestion
116-
? {
117-
requestId: request.id,
118-
answers,
119-
attachmentsByQuestionId: {},
120-
questionTextById: { approach: "Which approach?" },
121-
}
122-
: undefined,
123-
} as const);
124-
}
125-
assert.deepEqual(observed, expected);
126-
},
127-
},
128-
transformTranscript: (transcript) => {
129-
const at = transcript.entries.findIndex(
130-
(entry) => entry.type === "emit_inbound" && entry.label === "turn/started",
131-
);
132-
const started = transcript.entries[at];
133-
assert.isDefined(started);
134-
if (started.type !== "emit_inbound") assert.fail("Missing Muse turn/started");
135-
const { sessionId, turnId } = (
136-
started.frame as {
137-
readonly params: { readonly sessionId: string; readonly turnId: string };
138-
}
139-
).params;
140-
const metadata = transcript.metadata as {
141-
readonly commandIds: ReadonlyArray<ReadonlyArray<string>>;
142-
};
143-
return {
144-
...transcript,
145-
metadata: {
146-
...transcript.metadata,
147-
commandIds: [
148-
[...metadata.commandIds[0]!, "answer-ack", "answer-no-ack", "approve-no-ack"],
149-
],
150-
},
151-
entries: [
152-
...transcript.entries.slice(0, at + 1),
153-
...["question-ack", "question-no-ack"].flatMap(
154-
(userInputId, index): ProviderReplayEntry[] => [
155-
{
156-
type: "emit_inbound",
157-
frame: {
158-
jsonrpc: "2.0",
159-
method: "userInput/requested",
160-
params: {
161-
sessionId,
162-
turnId,
163-
userInputId,
164-
questions: [
165-
{
166-
id: "approach",
167-
header: "Approach",
168-
question: "Which approach?",
169-
options: [{ label: "Small" }, { label: "Large" }],
170-
selection: { mode: "single" },
171-
},
172-
],
173-
},
174-
},
175-
},
176-
{
177-
type: "expect_outbound",
178-
frame: {
179-
jsonrpc: "2.0",
180-
id: 4 + index,
181-
method: "userInput/answer",
182-
params: {
183-
sessionId,
184-
userInputId,
185-
commandId: index === 0 ? "answer-ack" : "answer-no-ack",
186-
answers: [
187-
{
188-
questionId: "approach",
189-
selectedLabel: "Small",
190-
note: "Keep tests focused",
191-
},
192-
],
193-
},
194-
},
195-
},
196-
{ type: "emit_inbound", frame: { jsonrpc: "2.0", id: 4 + index, result: {} } },
197-
...(index === 0
198-
? [
199-
{
200-
type: "emit_inbound" as const,
201-
frame: {
202-
jsonrpc: "2.0",
203-
method: "userInput/settled",
204-
params: { sessionId, turnId, userInputId },
205-
},
206-
},
207-
]
208-
: []),
209-
],
210-
),
211-
{
212-
type: "emit_inbound",
213-
frame: {
214-
jsonrpc: "2.0",
215-
method: "approval/requested",
216-
params: {
217-
sessionId,
218-
turnId,
219-
approvalId: "approval-no-ack",
220-
currentRequirementId: { approvalId: "approval-no-ack", sourceIndex: 0 },
221-
availableChoices: [
222-
{
223-
choiceId: "session",
224-
label: "Allow for session",
225-
decision: "approvedForSession",
226-
scope: "session",
227-
},
228-
],
229-
subject: { kind: "shell", command: "touch result.txt" },
230-
},
231-
},
232-
},
233-
{
234-
type: "expect_outbound",
235-
frame: {
236-
jsonrpc: "2.0",
237-
id: 6,
238-
method: "approval/decide",
239-
params: {
240-
sessionId,
241-
approvalId: "approval-no-ack",
242-
commandId: "approve-no-ack",
243-
requirementId: { approvalId: "approval-no-ack", sourceIndex: 0 },
244-
choiceId: "session",
245-
},
246-
},
247-
},
248-
{ type: "emit_inbound", frame: { jsonrpc: "2.0", id: 6, result: {} } },
249-
{
250-
type: "emit_inbound",
251-
frame: {
252-
jsonrpc: "2.0",
253-
method: "approval/updated",
254-
params: {
255-
sessionId,
256-
turnId,
257-
approvalId: "approval-no-ack",
258-
currentRequirementId: { approvalId: "approval-no-ack", sourceIndex: 0 },
259-
availableChoices: [
260-
{
261-
choiceId: "session",
262-
label: "Allow for session",
263-
decision: "approvedForSession",
264-
scope: "session",
265-
},
266-
],
267-
subject: { kind: "shell", command: "touch result.txt" },
268-
change: {
269-
kind: "stageResolved",
270-
requirementId: { approvalId: "approval-no-ack", sourceIndex: 0 },
271-
choiceId: "session",
272-
decision: "approvedForSession",
273-
},
274-
},
275-
},
276-
},
277-
...transcript.entries.slice(at + 1),
278-
],
279-
};
280-
},
281-
});
282-
},
283-
);
28417
});
Lines changed: 2 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,10 @@
1-
import { projectionFor } from "./fixtures/shared.ts";
2-
import type { ProviderReplayEntry } from "@t3tools/contracts";
3-
import { assert, describe, it } from "@effect/vitest";
1+
import { describe } from "@effect/vitest";
42

53
import { PiOrchestratorReplayHarness } from "../Adapters/PiAdapterV2.testkit.ts";
6-
import {
7-
findReplayFixture,
8-
itRunsReplayFixtures,
9-
runReplayFixture,
10-
} from "./ProviderReplayFixtures.ts";
4+
import { itRunsReplayFixtures, runReplayFixture } from "./ProviderReplayFixtures.ts";
115

126
describe("Pi replay fixtures", () => {
137
itRunsReplayFixtures("pi", (input) =>
148
runReplayFixture({ ...input, harness: PiOrchestratorReplayHarness }),
159
);
16-
it.effect("keeps Pi decisions and text answers after the provider turn ends", () => {
17-
const fixture = findReplayFixture("simple");
18-
const provider = fixture?.providers.find((candidate) => candidate.driver === "pi");
19-
assert.isDefined(fixture);
20-
assert.isDefined(provider);
21-
const answers = { "ui-input": "Keep the existing tests" };
22-
return runReplayFixture({
23-
harness: PiOrchestratorReplayHarness,
24-
fixtureName: fixture.name,
25-
buildInput: () => ({
26-
...fixture.buildInput(),
27-
steps: [
28-
...fixture.buildInput().steps,
29-
{ type: "approve_next_runtime_request", decision: "accept" },
30-
{ type: "approve_next_runtime_request", decision: "decline" },
31-
{ type: "answer_next_user_input_request", answers },
32-
],
33-
}),
34-
driver: {
35-
...provider,
36-
assertOutput: (result) => {
37-
const projection = projectionFor(result, fixture.name);
38-
assert.lengthOf(projection.runtimeRequests, 3);
39-
for (const [nativeId, response, status] of [
40-
["ui-accept", { decision: "accept" }, "completed"],
41-
["ui-decline", { decision: "decline" }, "cancelled"],
42-
["ui-input", { answers }, "completed"],
43-
] as const) {
44-
const request = projection.runtimeRequests.find(
45-
(candidate) => candidate.nativeRequestRef?.nativeId === nativeId,
46-
);
47-
assert.isDefined(request);
48-
assert.deepInclude(request, { status: "resolved", ...response });
49-
assert.equal(
50-
projection.nodes.find((node) => node.id === request.nodeId)?.status,
51-
status,
52-
);
53-
assert.equal(
54-
projection.turnItems.find((item) => item.nodeId === request.nodeId)?.status,
55-
status,
56-
);
57-
}
58-
assert.equal(projection.runs.at(-1)?.status, "completed");
59-
},
60-
},
61-
transformTranscript: (transcript) => {
62-
const at = transcript.entries.findIndex(
63-
(entry) => entry.type === "emit_inbound" && entry.label === "turn_start",
64-
);
65-
assert.isAtLeast(at, 0, "Pi fixture must contain turn_start");
66-
return {
67-
...transcript,
68-
entries: [
69-
...transcript.entries.slice(0, at + 1),
70-
...(["accept", "decline"] as const).flatMap((decision): ProviderReplayEntry[] => [
71-
{
72-
type: "emit_inbound",
73-
frame: {
74-
type: "extension_ui_request",
75-
id: `ui-${decision}`,
76-
method: "confirm",
77-
title: "Allow bash?",
78-
},
79-
},
80-
{
81-
type: "expect_outbound",
82-
frame: {
83-
type: "extension_ui_response",
84-
id: `ui-${decision}`,
85-
confirmed: decision === "accept",
86-
},
87-
},
88-
]),
89-
{
90-
type: "emit_inbound",
91-
frame: {
92-
type: "extension_ui_request",
93-
id: "ui-input",
94-
method: "input",
95-
title: "How?",
96-
},
97-
},
98-
{
99-
type: "expect_outbound",
100-
frame: { type: "extension_ui_response", id: "ui-input", value: answers["ui-input"] },
101-
},
102-
...transcript.entries.slice(at + 1),
103-
],
104-
};
105-
},
106-
});
107-
});
10810
});

0 commit comments

Comments
 (0)