Skip to content

Commit 73fd2cb

Browse files
committed
feat(qa): add multipass mock channel foundation
1 parent a58a6f6 commit 73fd2cb

14 files changed

Lines changed: 431 additions & 7 deletions
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Qa Lab tests cover mock channel capability matrix behavior.
2+
import { describe, expect, it } from "vitest";
3+
import {
4+
buildQaChannelCapabilityMatrix,
5+
getQaMockChannelDriver,
6+
listQaMockChannelIds,
7+
} from "./channel-capability-matrix.js";
8+
9+
describe("channel capability matrix", () => {
10+
it("declares the first concrete mock upstream driver for Telegram", () => {
11+
const driver = getQaMockChannelDriver("telegram");
12+
13+
expect(driver).toMatchObject({
14+
channelId: "telegram",
15+
mockDriverId: "telegram-normalized-bus-v1",
16+
channelLive: false,
17+
runtimePluginIds: ["qa-channel"],
18+
});
19+
expect(driver?.capabilities.dm.status).toBe("covered");
20+
expect(driver?.capabilities["group-mention"].status).toBe("covered");
21+
expect(driver?.capabilities["outbound-transcript"].status).toBe("covered");
22+
expect(driver?.capabilities.thread.status).toBe("planned");
23+
});
24+
25+
it("keeps missing channel drivers visible as planned rows", () => {
26+
const matrix = buildQaChannelCapabilityMatrix();
27+
28+
expect(listQaMockChannelIds()).toEqual(["telegram"]);
29+
expect(matrix.channels.map((entry) => entry.channelId)).toEqual([
30+
"telegram",
31+
"discord",
32+
"slack",
33+
"whatsapp",
34+
]);
35+
expect(getQaMockChannelDriver("discord")).toBeUndefined();
36+
expect(matrix.channels.find((entry) => entry.channelId === "discord")).toMatchObject({
37+
mockDriverId: null,
38+
capabilities: {
39+
dm: {
40+
status: "planned",
41+
coverageId: "channels.discord.dm",
42+
},
43+
},
44+
});
45+
});
46+
});
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Qa Lab plugin module defines mock channel coverage for scorecard ingestion.
2+
3+
export type QaMockChannelId = "telegram";
4+
5+
export type QaChannelId = QaMockChannelId | "discord" | "slack" | "whatsapp";
6+
7+
export type QaChannelCapabilityId =
8+
| "dm"
9+
| "group-mention"
10+
| "thread"
11+
| "media-metadata"
12+
| "native-approval"
13+
| "reconnect"
14+
| "outbound-transcript";
15+
16+
export type QaChannelCapabilityStatus = "covered" | "planned";
17+
18+
export type QaChannelCapabilityMatrixEntry = {
19+
channelId: QaChannelId;
20+
label: string;
21+
mockDriverId: string | null;
22+
channelLive: false;
23+
runtimePluginIds: readonly string[];
24+
coverageIds: readonly string[];
25+
capabilities: Readonly<
26+
Record<
27+
QaChannelCapabilityId,
28+
{
29+
status: QaChannelCapabilityStatus;
30+
coverageId: string;
31+
}
32+
>
33+
>;
34+
};
35+
36+
export type QaChannelCapabilityMatrix = {
37+
version: 1;
38+
channels: readonly QaChannelCapabilityMatrixEntry[];
39+
};
40+
41+
export type QaMockChannelDriver = QaChannelCapabilityMatrixEntry & {
42+
channelId: QaMockChannelId;
43+
mockDriverId: string;
44+
};
45+
46+
export const QA_CHANNEL_CAPABILITY_MATRIX_PATH = "channel-capability-matrix.json";
47+
48+
const qaChannelCapabilityIds = [
49+
"dm",
50+
"group-mention",
51+
"thread",
52+
"media-metadata",
53+
"native-approval",
54+
"reconnect",
55+
"outbound-transcript",
56+
] as const satisfies readonly QaChannelCapabilityId[];
57+
58+
function buildCapabilitySet(
59+
channelId: QaChannelId,
60+
coveredCapabilityIds: readonly QaChannelCapabilityId[] = [],
61+
) {
62+
const covered = new Set<QaChannelCapabilityId>(coveredCapabilityIds);
63+
return Object.fromEntries(
64+
qaChannelCapabilityIds.map((capabilityId) => [
65+
capabilityId,
66+
{
67+
status: covered.has(capabilityId) ? "covered" : "planned",
68+
coverageId: `channels.${channelId}.${capabilityId}`,
69+
},
70+
]),
71+
) as QaChannelCapabilityMatrixEntry["capabilities"];
72+
}
73+
74+
const channelCapabilityMatrix: QaChannelCapabilityMatrix = {
75+
version: 1,
76+
channels: [
77+
{
78+
channelId: "telegram",
79+
label: "Telegram",
80+
mockDriverId: "telegram-normalized-bus-v1",
81+
channelLive: false,
82+
runtimePluginIds: ["qa-channel"],
83+
coverageIds: [
84+
"channels.telegram.mock-upstream",
85+
"channels.telegram.dm",
86+
"channels.telegram.group-mention",
87+
"channels.telegram.outbound-transcript",
88+
],
89+
capabilities: buildCapabilitySet("telegram", ["dm", "group-mention", "outbound-transcript"]),
90+
},
91+
{
92+
channelId: "discord",
93+
label: "Discord",
94+
mockDriverId: null,
95+
channelLive: false,
96+
runtimePluginIds: [],
97+
coverageIds: ["channels.discord.mock-upstream"],
98+
capabilities: buildCapabilitySet("discord"),
99+
},
100+
{
101+
channelId: "slack",
102+
label: "Slack",
103+
mockDriverId: null,
104+
channelLive: false,
105+
runtimePluginIds: [],
106+
coverageIds: ["channels.slack.mock-upstream"],
107+
capabilities: buildCapabilitySet("slack"),
108+
},
109+
{
110+
channelId: "whatsapp",
111+
label: "WhatsApp",
112+
mockDriverId: null,
113+
channelLive: false,
114+
runtimePluginIds: [],
115+
coverageIds: ["channels.whatsapp.mock-upstream"],
116+
capabilities: buildCapabilitySet("whatsapp"),
117+
},
118+
],
119+
};
120+
121+
export function buildQaChannelCapabilityMatrix(): QaChannelCapabilityMatrix {
122+
return channelCapabilityMatrix;
123+
}
124+
125+
export function listQaMockChannelIds(): readonly QaMockChannelId[] {
126+
return channelCapabilityMatrix.channels
127+
.filter((entry): entry is QaMockChannelDriver => entry.mockDriverId !== null)
128+
.map((entry) => entry.channelId);
129+
}
130+
131+
export function getQaMockChannelDriver(channelId: string): QaMockChannelDriver | undefined {
132+
return channelCapabilityMatrix.channels.find(
133+
(entry): entry is QaMockChannelDriver =>
134+
entry.channelId === channelId && entry.mockDriverId !== null,
135+
);
136+
}

‎extensions/qa-lab/src/cli.runtime.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,25 @@ describe("qa cli runtime", () => {
14641464
});
14651465
});
14661466

1467+
it("passes selected mock channel drivers through to the multipass runner", async () => {
1468+
await runQaSuiteCommand({
1469+
repoRoot: "/tmp/openclaw-repo",
1470+
runner: "multipass",
1471+
transportId: "telegram",
1472+
providerMode: "mock-openai",
1473+
allowFailures: true,
1474+
scenarioIds: ["channel-chat-baseline"],
1475+
});
1476+
1477+
expectFields(mockFirstObjectArg(runQaMultipass), {
1478+
repoRoot: path.resolve("/tmp/openclaw-repo"),
1479+
transportId: "telegram",
1480+
providerMode: "mock-openai",
1481+
allowFailures: true,
1482+
scenarioIds: ["channel-chat-baseline"],
1483+
});
1484+
});
1485+
14671486
it("sets a failing exit code when multipass summary reports failed scenarios", async () => {
14681487
const repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), "qa-multipass-summary-"));
14691488
const summaryPath = path.join(repoRoot, "qa-suite-summary.json");

‎extensions/qa-lab/src/cli.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
QA_FRONTIER_PARITY_BASELINE_LABEL,
1414
QA_FRONTIER_PARITY_CANDIDATE_LABEL,
1515
} from "./providers/live-frontier/parity.js";
16+
import { formatQaTransportIdHelp } from "./qa-transport-registry.js";
1617
import type { QaProviderMode, QaProviderModeInput } from "./run-config.js";
1718
import { hasQaScenarioPack } from "./scenario-catalog.js";
1819

@@ -299,7 +300,7 @@ export function registerQaLabCli(program: Command) {
299300
.option("--repo-root <path>", "Repository root to target when running from a neutral cwd")
300301
.option("--output-dir <path>", "Suite artifact directory")
301302
.option("--runner <kind>", "Execution runner: host or multipass", "host")
302-
.option("--transport <id>", "QA transport id", "qa-channel")
303+
.option("--transport <id>", formatQaTransportIdHelp(), "qa-channel")
303304
.option("--provider-mode <mode>", formatQaProviderModeHelp(), DEFAULT_QA_LIVE_PROVIDER_MODE)
304305
.option("--model <ref>", "Primary provider/model ref")
305306
.option("--alt-model <ref>", "Alternate provider/model ref")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Qa Lab tests cover mock channel transport behavior.
2+
import { describe, expect, it } from "vitest";
3+
import { createQaBusState } from "./bus-state.js";
4+
import { createQaMockChannelTransport } from "./mock-channel-transport.js";
5+
6+
describe("mock channel transport", () => {
7+
it("selects Telegram while routing through the normalized QA channel shim", () => {
8+
const transport = createQaMockChannelTransport({
9+
channelId: "telegram",
10+
state: createQaBusState(),
11+
});
12+
13+
expect(transport.id).toBe("telegram");
14+
expect(transport.channelId).toBe("telegram");
15+
expect(transport.channelLive).toBe(false);
16+
expect(transport.mockUpstreamDriverId).toBe("telegram-normalized-bus-v1");
17+
expect(transport.requiredPluginIds).toEqual(["qa-channel"]);
18+
expect(transport.buildAgentDelivery({ target: "qa-room" })).toEqual({
19+
channel: "qa-channel",
20+
replyChannel: "qa-channel",
21+
replyTo: "qa-room",
22+
});
23+
});
24+
});
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Qa Lab plugin module implements mock upstream channel transports.
2+
import type { QaBusState } from "./bus-state.js";
3+
import type { QaMockChannelDriver, QaMockChannelId } from "./channel-capability-matrix.js";
4+
import { getQaMockChannelDriver } from "./channel-capability-matrix.js";
5+
import { getQaProvider } from "./providers/index.js";
6+
import {
7+
createQaChannelGatewayConfig,
8+
handleQaChannelAction,
9+
QA_CHANNEL_ID,
10+
waitForQaChannelReady,
11+
} from "./qa-channel-transport.js";
12+
import { QaStateBackedTransportAdapter } from "./qa-transport.js";
13+
import type {
14+
QaTransportActionName,
15+
QaTransportGatewayConfig,
16+
QaTransportGatewayClient,
17+
QaTransportReportParams,
18+
} from "./qa-transport.js";
19+
20+
const QA_MOCK_CHANNEL_ACCOUNT_ID = "mock";
21+
22+
function createMockChannelReportNotes(
23+
driver: QaMockChannelDriver,
24+
params: QaTransportReportParams,
25+
) {
26+
const provider = getQaProvider(params.providerMode);
27+
const providerText =
28+
provider.kind === "mock"
29+
? `${params.providerMode} provider fixture`
30+
: `live frontier models (${params.primaryModel}, ${params.alternateModel})`;
31+
return [
32+
`Runs ${driver.label} through mock upstream driver ${driver.mockDriverId} backed by the qa-lab normalized bus.`,
33+
`Gateway transport execution uses the qa-channel shim while summary metadata records channel=${driver.channelId} and channel_live=false.`,
34+
`Model responses use ${providerText}${params.fastMode ? " with fast mode enabled" : ""}.`,
35+
];
36+
}
37+
38+
class QaMockChannelTransport extends QaStateBackedTransportAdapter {
39+
constructor(
40+
state: QaBusState,
41+
private readonly driver: QaMockChannelDriver,
42+
) {
43+
super({
44+
id: driver.channelId,
45+
channelId: driver.channelId,
46+
channelLive: false,
47+
mockUpstreamDriverId: driver.mockDriverId,
48+
label: `${driver.label} mock upstream + qa-lab bus`,
49+
accountId: QA_MOCK_CHANNEL_ACCOUNT_ID,
50+
requiredPluginIds: driver.runtimePluginIds,
51+
state,
52+
});
53+
}
54+
55+
createGatewayConfig = (params: { baseUrl: string }): QaTransportGatewayConfig =>
56+
createQaChannelGatewayConfig(params);
57+
58+
waitReady = (params: {
59+
gateway: QaTransportGatewayClient;
60+
timeoutMs?: number;
61+
pollIntervalMs?: number;
62+
}) => waitForQaChannelReady(params);
63+
64+
buildAgentDelivery = ({ target }: { target: string }) => ({
65+
channel: QA_CHANNEL_ID,
66+
replyChannel: QA_CHANNEL_ID,
67+
replyTo: target,
68+
});
69+
70+
handleAction = (params: {
71+
action: QaTransportActionName;
72+
args: Record<string, unknown>;
73+
cfg: Parameters<typeof handleQaChannelAction>[0]["cfg"];
74+
accountId?: string | null;
75+
}) => handleQaChannelAction(params);
76+
77+
createReportNotes = (params: QaTransportReportParams) =>
78+
createMockChannelReportNotes(this.driver, params);
79+
}
80+
81+
export function createQaMockChannelTransport(params: {
82+
channelId: QaMockChannelId;
83+
state: QaBusState;
84+
}) {
85+
const driver = getQaMockChannelDriver(params.channelId);
86+
if (!driver) {
87+
throw new Error(`unsupported QA mock channel: ${params.channelId}`);
88+
}
89+
return new QaMockChannelTransport(params.state, driver);
90+
}

‎extensions/qa-lab/src/multipass.runtime.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ describe("qa multipass runtime", () => {
147147
expect(plan.qaCommand).toContain("--allow-failures");
148148
});
149149

150+
it("forwards a selected mock channel driver into the guest qa suite command", () => {
151+
const plan = createQaMultipassPlan({
152+
repoRoot: process.cwd(),
153+
outputDir: path.join(process.cwd(), ".artifacts", "qa-e2e", "multipass-telegram-test"),
154+
transportId: "telegram",
155+
providerMode: "mock-openai",
156+
scenarioIds: ["channel-chat-baseline"],
157+
});
158+
159+
expect(plan.transportId).toBe("telegram");
160+
expect(plan.qaCommand).toEqual(expect.arrayContaining(["--transport", "telegram"]));
161+
expect(plan.qaCommand).toEqual(expect.arrayContaining(["--provider-mode", "mock-openai"]));
162+
});
163+
150164
it("forwards --runtime-pair into the guest qa suite command when requested", () => {
151165
const plan = createQaMultipassPlan({
152166
repoRoot: process.cwd(),

‎extensions/qa-lab/src/qa-channel-transport.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import type {
1313
} from "./qa-transport.js";
1414
import { qaChannelPlugin } from "./runtime-api.js";
1515

16-
const QA_CHANNEL_ID = "qa-channel";
16+
export const QA_CHANNEL_ID = "qa-channel";
1717
const QA_CHANNEL_ACCOUNT_ID = "default";
1818
export const QA_CHANNEL_REQUIRED_PLUGIN_IDS = Object.freeze([QA_CHANNEL_ID]);
1919
export const QA_CHANNEL_DEFAULT_SUITE_CONCURRENCY = 4;
2020

21-
async function waitForQaChannelReady(params: {
21+
export async function waitForQaChannelReady(params: {
2222
gateway: QaTransportGatewayClient;
2323
timeoutMs?: number;
2424
pollIntervalMs?: number;
@@ -110,7 +110,7 @@ function createQaChannelReportNotes(params: QaTransportReportParams) {
110110
];
111111
}
112112

113-
async function handleQaChannelAction(params: {
113+
export async function handleQaChannelAction(params: {
114114
action: QaTransportActionName;
115115
args: Record<string, unknown>;
116116
cfg: OpenClawConfig;
@@ -129,6 +129,8 @@ class QaChannelTransport extends QaStateBackedTransportAdapter {
129129
constructor(state: QaBusState) {
130130
super({
131131
id: QA_CHANNEL_ID,
132+
channelId: QA_CHANNEL_ID,
133+
channelLive: false,
132134
label: "qa-channel + qa-lab bus",
133135
accountId: QA_CHANNEL_ACCOUNT_ID,
134136
requiredPluginIds: QA_CHANNEL_REQUIRED_PLUGIN_IDS,

0 commit comments

Comments
 (0)