Skip to content

Commit 6a8e11e

Browse files
authored
fix(qa): repair release validation scenarios (#119150)
* fix(qa): repair parity and matrix media setup Punchcard-Session: silver-valley-valley-dt * test(qa): accept token-budgeted compaction suffix Punchcard-Session: silver-valley-valley-dt * test(qa): scope request diagnostics Punchcard-Session: silver-valley-valley-dt * test(qa): prove thread-memory causality Punchcard-Session: silver-valley-valley-dt * test(qa): configure Matrix image generation and fail fast Punchcard-Session: silver-valley-valley-dt * fix(qa): require memory get before thread recall Punchcard-Session: silver-valley-valley-dt * fix(qa): unify mock provider dispatch Punchcard-Session: silver-valley-valley-dt * fix(qa): repair Anthropic IDs and compaction causality Punchcard-Session: silver-valley-valley-dt * fix(qa): authenticate compaction wire causality Punchcard-Session: silver-valley-valley-dt * fix(qa): preserve Responses tool item identity Punchcard-Session: silver-valley-valley-dt * fix(qa): scope restart heartbeat proof Punchcard-Session: silver-valley-valley-dt * test(qa): assert causal traces before delivery Punchcard-Session: silver-valley-valley-dt * fix(qa): validate code mode completion evidence Punchcard-Session: silver-valley-valley-dt * test(qa): split causal catalog checks Punchcard-Session: silver-valley-valley-dt * style(qa): format matrix scenario tests Punchcard-Session: silver-valley-valley-dt
1 parent 8d29969 commit 6a8e11e

26 files changed

Lines changed: 1897 additions & 522 deletions

‎extensions/qa-lab/src/live-transports/matrix/matrix-scenario-flows.test.ts‎

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
readQaScenarioExecutionConfig,
66
} from "../../scenario-catalog.js";
77
import { requireFlowScenario } from "../../scenario-catalog.test-utils.js";
8+
import { collectQaSuitePluginIds } from "../../suite-planning.js";
89

910
const MATRIX_MENTION_GATE_PRIMARY_SCENARIOS = [
1011
"matrix-allowbots-default-block",
@@ -221,14 +222,17 @@ describe("Matrix QA Lab scenario flows", () => {
221222
});
222223

223224
it("loads the voice preflight provider and media overrides", () => {
224-
expect(readQaScenarioById("matrix-voice-preflight-mention").plugins).toEqual(["openai"]);
225-
expect(readQaScenarioById("matrix-voice-preflight-mention").execution).toMatchObject({
225+
const scenario = readQaScenarioById("matrix-voice-preflight-mention");
226+
227+
expect(scenario.execution).toMatchObject({
226228
kind: "flow",
227229
providerMode: "mock-openai",
228230
retryCount: 0,
229231
timeoutMs: 90_000,
230232
});
231-
expect(readQaScenarioById("matrix-voice-preflight-mention").gatewayConfigPatch).toMatchObject({
233+
expect(scenario.plugins).toEqual(["openai"]);
234+
expect(collectQaSuitePluginIds([scenario])).toEqual(["openai"]);
235+
expect(scenario.gatewayConfigPatch).toMatchObject({
232236
tools: {
233237
media: {
234238
models: [{ capabilities: ["audio"], model: "gpt-4o-transcribe", provider: "openai" }],
@@ -274,4 +278,37 @@ describe("Matrix QA Lab scenario flows", () => {
274278
},
275279
});
276280
});
281+
282+
it("configures image generation before the single generated-image flow call", () => {
283+
const scenario = requireFlowScenario(
284+
readQaScenarioById("matrix-room-generated-image-delivery"),
285+
);
286+
const actions = scenario.execution.flow?.steps[0]?.actions ?? [];
287+
288+
expect(scenario.execution).toMatchObject({
289+
channel: "matrix",
290+
retryCount: 0,
291+
timeoutMs: 180_000,
292+
config: {
293+
requiredChannelDriver: "live",
294+
},
295+
});
296+
expect(actions).toEqual([
297+
{
298+
call: "ensureImageGenerationConfigured",
299+
args: [{ ref: "env" }],
300+
},
301+
{
302+
set: "scenarioModule",
303+
value: {
304+
expr: "await qaImport('./live-transports/matrix/scenarios/scenario-runtime-media.js')",
305+
},
306+
},
307+
{
308+
call: "scenarioModule.runGeneratedImageDeliveryScenario",
309+
args: [{ expr: "scenarioContext" }],
310+
saveAs: "result",
311+
},
312+
]);
313+
});
277314
});

‎extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-runtime-media.test.ts‎

Lines changed: 130 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
import { describe, expect, it } from "vitest";
2-
import { testing } from "./scenario-runtime-media.js";
1+
import { afterEach, describe, expect, it, vi } from "vitest";
2+
3+
const advanceMatrixQaActorCursor = vi.hoisted(() => vi.fn());
4+
const primeMatrixQaActorCursor = vi.hoisted(() => vi.fn());
5+
6+
vi.mock("./scenario-runtime-shared.js", async (importOriginal) => ({
7+
...(await importOriginal<typeof import("./scenario-runtime-shared.js")>()),
8+
advanceMatrixQaActorCursor,
9+
primeMatrixQaActorCursor,
10+
}));
11+
12+
import { runGeneratedImageDeliveryScenario, testing } from "./scenario-runtime-media.js";
13+
import type { MatrixQaScenarioContext } from "./scenario-runtime-shared.js";
314

415
describe("Matrix voice preflight reply matching", () => {
516
it("accepts punctuation differences in the transcribed marker", () => {
@@ -10,3 +21,120 @@ describe("Matrix voice preflight reply matching", () => {
1021
).toBe(true);
1122
});
1223
});
24+
25+
const roomId = "!media:matrix-qa.test";
26+
27+
function createGeneratedImageContext(
28+
observedEvents: MatrixQaScenarioContext["observedEvents"] = [],
29+
): MatrixQaScenarioContext {
30+
return {
31+
baseUrl: "http://127.0.0.1:28008",
32+
driverAccessToken: "driver-token",
33+
driverUserId: "@driver:matrix-qa.test",
34+
observedEvents,
35+
observerAccessToken: "observer-token",
36+
observerUserId: "@observer:matrix-qa.test",
37+
roomId,
38+
sutAccessToken: "sut-token",
39+
sutUserId: "@sut:matrix-qa.test",
40+
syncState: {},
41+
timeoutMs: 180_000,
42+
topology: {
43+
defaultRoomId: roomId,
44+
defaultRoomKey: "media",
45+
rooms: [
46+
{
47+
encrypted: false,
48+
key: "media",
49+
kind: "group",
50+
memberRoles: ["driver", "observer", "sut"],
51+
memberUserIds: [
52+
"@driver:matrix-qa.test",
53+
"@observer:matrix-qa.test",
54+
"@sut:matrix-qa.test",
55+
],
56+
name: "Matrix QA Media Room",
57+
requireMention: true,
58+
roomId,
59+
},
60+
],
61+
},
62+
};
63+
}
64+
65+
describe("Matrix generated image delivery", () => {
66+
afterEach(() => {
67+
vi.clearAllMocks();
68+
});
69+
70+
it("sends one trigger and accepts one fresh top-level image", async () => {
71+
const sendTextMessage = vi.fn(async () => "$driver-trigger");
72+
const waitForOptionalRoomEvent = vi.fn(async ({ predicate }) => {
73+
const event = {
74+
attachment: { filename: "generated.png", kind: "image" as const },
75+
eventId: "$generated-image",
76+
kind: "message" as const,
77+
msgtype: "m.image",
78+
originServerTs: Date.now() + 1,
79+
roomId,
80+
sender: "@sut:matrix-qa.test",
81+
type: "m.room.message",
82+
};
83+
expect(predicate(event)).toBe(true);
84+
return { event, matched: true as const, since: "next" };
85+
});
86+
primeMatrixQaActorCursor.mockResolvedValue({
87+
client: { sendTextMessage, waitForOptionalRoomEvent },
88+
startSince: "start",
89+
});
90+
91+
const result = await runGeneratedImageDeliveryScenario(createGeneratedImageContext());
92+
93+
expect(sendTextMessage).toHaveBeenCalledTimes(1);
94+
expect(waitForOptionalRoomEvent).toHaveBeenCalledTimes(1);
95+
expect(result.artifacts?.driverEventId).toBe("$driver-trigger");
96+
expect(result.artifacts?.attachmentEventId).toBe("$generated-image");
97+
});
98+
99+
it("bounds timeout diagnostics to the last eight room events", async () => {
100+
const observedEvents = Array.from({ length: 10 }, (_, index) => ({
101+
body: `event body ${index + 1}`,
102+
eventId: `$event-${index + 1}`,
103+
kind: "message" as const,
104+
roomId,
105+
sender: "@sut:matrix-qa.test",
106+
type: "m.room.message",
107+
}));
108+
observedEvents.push({
109+
body: "other room",
110+
eventId: "$other-room",
111+
kind: "message",
112+
roomId: "!other:matrix-qa.test",
113+
sender: "@sut:matrix-qa.test",
114+
type: "m.room.message",
115+
});
116+
const sendTextMessage = vi.fn(async () => "$driver-trigger");
117+
primeMatrixQaActorCursor.mockResolvedValue({
118+
client: {
119+
sendTextMessage,
120+
waitForOptionalRoomEvent: vi.fn(async () => ({
121+
matched: false as const,
122+
since: "next",
123+
})),
124+
},
125+
startSince: "start",
126+
});
127+
128+
const error = await runGeneratedImageDeliveryScenario(
129+
createGeneratedImageContext(observedEvents),
130+
).catch((cause: unknown) => cause);
131+
const message = error instanceof Error ? error.message : String(error);
132+
133+
expect(sendTextMessage).toHaveBeenCalledTimes(1);
134+
expect(message).toContain("$event-3");
135+
expect(message).toContain("$event-10");
136+
expect(message).not.toContain('$event-1"');
137+
expect(message).not.toContain('$event-2"');
138+
expect(message).not.toContain("$other-room");
139+
});
140+
});

‎extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-runtime-media.ts‎

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -425,41 +425,43 @@ export async function runGeneratedImageDeliveryScenario(context: MatrixQaScenari
425425
const roomId = resolveMatrixQaScenarioRoomId(context, MATRIX_QA_MEDIA_ROOM_KEY);
426426
const { client, startSince } = await primeMatrixQaDriverMediaClient(context);
427427
const triggerBody = buildMatrixQaImageGenerationPrompt(context.sutUserId);
428-
const driverEventIds: string[] = [];
428+
const triggerSentAt = Date.now();
429+
const driverEventId = await client.sendTextMessage({
430+
body: triggerBody,
431+
mentionUserIds: [context.sutUserId],
432+
roomId,
433+
});
429434
const isGeneratedImageEvent = (event: MatrixQaObservedEvent) =>
430435
event.roomId === roomId &&
431436
event.sender === context.sutUserId &&
432437
event.type === "m.room.message" &&
433438
event.relatesTo === undefined &&
434439
event.msgtype === "m.image" &&
435-
event.attachment?.kind === "image";
436-
let matched: Awaited<ReturnType<typeof client.waitForOptionalRoomEvent>> | undefined;
437-
for (let attempt = 1; attempt <= 2; attempt += 1) {
438-
const triggerSentAt = Date.now();
439-
const driverEventId = await client.sendTextMessage({
440-
body: triggerBody,
441-
mentionUserIds: [context.sutUserId],
442-
roomId,
443-
});
444-
driverEventIds.push(driverEventId);
445-
matched = await client.waitForOptionalRoomEvent({
446-
observedEvents: context.observedEvents,
447-
// The start cursor can still receive delayed images from an earlier run.
448-
predicate: (event) =>
449-
isGeneratedImageEvent(event) &&
450-
typeof event.originServerTs === "number" &&
451-
event.originServerTs >= triggerSentAt,
452-
roomId,
453-
since: matched?.since ?? startSince,
454-
timeoutMs: context.timeoutMs,
455-
});
456-
if (matched.matched) {
457-
break;
458-
}
459-
}
460-
if (!matched?.matched) {
440+
event.attachment?.kind === "image" &&
441+
typeof event.originServerTs === "number" &&
442+
event.originServerTs >= triggerSentAt;
443+
const matched = await client.waitForOptionalRoomEvent({
444+
observedEvents: context.observedEvents,
445+
// The start cursor can still receive delayed images from an earlier run.
446+
predicate: isGeneratedImageEvent,
447+
roomId,
448+
since: startSince,
449+
timeoutMs: context.timeoutMs,
450+
});
451+
if (!matched.matched) {
452+
const recentRoomEvents = context.observedEvents
453+
.filter((event) => event.roomId === roomId)
454+
.slice(-8)
455+
.map((event) => ({
456+
body: truncateMatrixQaPreview(event.body),
457+
eventId: event.eventId,
458+
kind: event.kind,
459+
msgtype: event.msgtype,
460+
sender: event.sender,
461+
type: event.type,
462+
}));
461463
throw new Error(
462-
`timed out after ${context.timeoutMs}ms waiting for Matrix generated image after ${driverEventIds.length} attempt(s)`,
464+
`timed out after ${context.timeoutMs}ms waiting for Matrix generated image; recent room events: ${JSON.stringify(recentRoomEvents)}`,
463465
);
464466
}
465467
const matchedEvent = matched.event;
@@ -480,14 +482,13 @@ export async function runGeneratedImageDeliveryScenario(context: MatrixQaScenari
480482
attachmentFilename: attachment.filename,
481483
attachmentKind: attachment.kind,
482484
attachmentMsgtype: matchedEvent.msgtype,
483-
driverEventId: driverEventIds[0],
484-
driverEventIds,
485+
driverEventId,
485486
roomId,
486487
triggerBody,
487488
},
488489
details: [
489490
`room id: ${roomId}`,
490-
`driver events: ${driverEventIds.join(", ")}`,
491+
`driver event: ${driverEventId}`,
491492
...buildMatrixQaAttachmentDetailLines({
492493
attachmentEvent: matchedEvent,
493494
label: "generated image",

‎extensions/qa-lab/src/live-transports/matrix/substrate/config.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,35 @@ describe("matrix qa config", () => {
8383
expect(next.messages?.groupChat?.visibleReplies).toBe("automatic");
8484
});
8585

86+
it("preserves the scenario provider plugin without enabling unrelated plugins", () => {
87+
const next = buildMatrixQaConfig(
88+
{
89+
plugins: {
90+
allow: ["acpx", "memory-core", "qa-lab", "openai"],
91+
entries: {
92+
openai: { enabled: true },
93+
unrelated: { enabled: true },
94+
},
95+
},
96+
} as OpenClawConfig,
97+
{
98+
driverUserId: "@driver:matrix-qa.test",
99+
homeserver: "http://127.0.0.1:28008/",
100+
observerUserId: "@observer:matrix-qa.test",
101+
sutAccessToken: "sut-token",
102+
sutAccountId: "sut",
103+
sutUserId: "@sut:matrix-qa.test",
104+
topology,
105+
},
106+
);
107+
108+
expect(next.plugins?.allow).toEqual(["acpx", "memory-core", "qa-lab", "openai", "matrix"]);
109+
expect(next.plugins?.allow).not.toContain("unrelated");
110+
expect(next.plugins?.allow).not.toContain("anthropic");
111+
expect(next.plugins?.entries?.matrix).toEqual({ enabled: true });
112+
expect(next.plugins?.entries?.openai).toEqual({ enabled: true });
113+
});
114+
86115
it("honors an explicit DM disable with a provisioned DM room", () => {
87116
const next = buildMatrixQaConfig({} as OpenClawConfig, {
88117
driverUserId: "@driver:matrix-qa.test",

0 commit comments

Comments
 (0)