Skip to content

Commit 2479415

Browse files
committed
refactor(qa): add canonical live channel adapters
1 parent 9606fe4 commit 2479415

37 files changed

Lines changed: 1711 additions & 151 deletions

‎docs/concepts/qa-e2e-automation.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,9 @@ The minimum adoption bar for a new channel:
11331133
competing root command. Runner plugins should declare `qaRunners` in
11341134
`openclaw.plugin.json` and export a matching `qaRunnerCliRegistrations`
11351135
array from `runtime-api.ts`. Keep `runtime-api.ts` light; lazy CLI and
1136-
runner execution should stay behind separate entrypoints.
1136+
runner execution should stay behind separate entrypoints. An optional
1137+
`adapterFactory` exposes the transport to shared scenarios without changing
1138+
the command's existing scenario catalog.
11371139
5. Author or adapt YAML scenarios under the themed `qa/scenarios/`
11381140
directories.
11391141
6. Use the generic scenario helpers for new scenarios.

‎docs/help/testing.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,9 @@ for Slack rows.
583583
The architecture and scenario-helper names for new channel adapters live in
584584
[QA overview - Adding a channel](/concepts/qa-e2e-automation#adding-a-channel).
585585
The minimum bar: implement the transport runner on the shared `qa-lab` host
586-
seam, declare `qaRunners` in the plugin manifest, mount as
587-
`openclaw qa <runner>`, and author scenarios under `qa/scenarios/`.
586+
seam, add an `adapterFactory` for shared scenarios, declare `qaRunners` in the
587+
plugin manifest, mount as `openclaw qa <runner>`, and author scenarios under
588+
`qa/scenarios/`.
588589

589590
## Test suites (what runs where)
590591

‎docs/plugins/manifest.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,12 @@ Planner diagnostics can distinguish explicit activation hints from manifest owne
405405

406406
## qaRunners reference
407407

408-
Use `qaRunners` when a plugin contributes one or more transport runners beneath the shared `openclaw qa` root. Keep this metadata cheap and static; the plugin runtime still owns actual CLI registration through a lightweight `runtime-api.ts` surface that exports `qaRunnerCliRegistrations`.
408+
Use `qaRunners` when a plugin contributes one or more transport runners beneath
409+
the shared `openclaw qa` root. Keep this metadata cheap and static; the plugin
410+
runtime still owns actual CLI registration through a lightweight
411+
`runtime-api.ts` surface that exports matching `qaRunnerCliRegistrations`. An
412+
optional `adapterFactory` exposes the transport to shared QA scenarios without
413+
changing the registered command's runner.
409414

410415
```json
411416
{
@@ -423,6 +428,9 @@ Use `qaRunners` when a plugin contributes one or more transport runners beneath
423428
| `commandName` | Yes | `string` | Subcommand mounted beneath `openclaw qa`, for example `matrix`. |
424429
| `description` | No | `string` | Fallback help text used when the shared host needs a stub command. |
425430

431+
The `adapterFactory` id must match `commandName`. Do not export registrations
432+
for commands absent from the manifest.
433+
426434
## setup reference
427435

428436
Use `setup` when setup and onboarding surfaces need cheap plugin-owned metadata before runtime loads.

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {
1010
runQaSuite,
1111
runQaCharacterEval,
1212
runQaMultipass,
13+
listLiveTransportQaAdapterFactories,
1314
listTelegramQaScenarioCatalog,
1415
runTelegramQaLive,
1516
startQaLabServer,
@@ -23,6 +24,7 @@ const {
2324
runQaSuite: vi.fn(),
2425
runQaCharacterEval: vi.fn(),
2526
runQaMultipass: vi.fn(),
27+
listLiveTransportQaAdapterFactories: vi.fn(),
2628
listTelegramQaScenarioCatalog: vi.fn(),
2729
runTelegramQaLive: vi.fn(),
2830
startQaLabServer: vi.fn(),
@@ -50,6 +52,10 @@ vi.mock("./multipass.runtime.js", () => ({
5052
runQaMultipass,
5153
}));
5254

55+
vi.mock("./live-transports/cli.js", () => ({
56+
listLiveTransportQaAdapterFactories,
57+
}));
58+
5359
vi.mock("./live-transports/telegram/telegram-live.runtime.js", () => ({
5460
listTelegramQaScenarioCatalog,
5561
runTelegramQaLive,
@@ -222,6 +228,7 @@ describe("qa cli runtime", () => {
222228
runQaCharacterEval.mockReset();
223229
runQaManualLane.mockReset();
224230
runQaMultipass.mockReset();
231+
listLiveTransportQaAdapterFactories.mockReset();
225232
listTelegramQaScenarioCatalog.mockReset();
226233
runTelegramQaLive.mockReset();
227234
startQaLabServer.mockReset();
@@ -282,6 +289,14 @@ describe("qa cli runtime", () => {
282289
regressionRefs: ["openclaw/openclaw#74698"],
283290
},
284291
]);
292+
listLiveTransportQaAdapterFactories.mockReturnValue([
293+
{
294+
id: "telegram",
295+
scenarioIds: ["channel-chat-baseline"],
296+
matches: vi.fn(),
297+
create: vi.fn(),
298+
},
299+
]);
285300
startQaLabServer.mockResolvedValue({
286301
baseUrl: "http://127.0.0.1:58000",
287302
runSelfCheck: vi.fn().mockResolvedValue({
@@ -644,6 +659,77 @@ describe("qa cli runtime", () => {
644659
});
645660
});
646661

662+
it("runs canonical scenarios through a discovered live adapter factory", async () => {
663+
await runQaSuiteCommand({
664+
repoRoot: "/tmp/openclaw-repo",
665+
outputDir: ".artifacts/qa/telegram-live",
666+
channelDriver: "live",
667+
channel: "telegram",
668+
providerMode: "mock-openai",
669+
scenarioIds: ["channel-chat-baseline"],
670+
});
671+
672+
expect(runQaSuite).toHaveBeenCalledWith(
673+
expect.objectContaining({
674+
adapterFactories: listLiveTransportQaAdapterFactories.mock.results[0]?.value,
675+
channelDriver: "live",
676+
channelId: "telegram",
677+
concurrency: 1,
678+
adapterOptions: expect.objectContaining({
679+
repoRoot: path.resolve("/tmp/openclaw-repo"),
680+
}),
681+
scenarioIds: ["channel-chat-baseline"],
682+
}),
683+
);
684+
});
685+
686+
it("uses the selected live adapter's declared scenarios by default", async () => {
687+
await runQaSuiteCommand({
688+
channelDriver: "live",
689+
channel: "telegram",
690+
});
691+
692+
expect(runQaSuite).toHaveBeenCalledWith(
693+
expect.objectContaining({
694+
scenarioIds: ["channel-chat-baseline"],
695+
}),
696+
);
697+
});
698+
699+
it("rejects live adapter selection under Multipass", async () => {
700+
await expect(
701+
runQaSuiteCommand({
702+
runner: "multipass",
703+
channelDriver: "live",
704+
channel: "telegram",
705+
scenarioIds: ["channel-chat-baseline"],
706+
}),
707+
).rejects.toThrow("--channel-driver live with --channel requires --runner host.");
708+
expect(runQaMultipass).not.toHaveBeenCalled();
709+
});
710+
711+
it("rejects runtime-pair execution for live adapters", async () => {
712+
await expect(
713+
runQaSuiteCommand({
714+
channelDriver: "live",
715+
channel: "telegram",
716+
runtimePair: "openclaw,codex",
717+
}),
718+
).rejects.toThrow("--runtime-pair is not supported with a live QA adapter.");
719+
expect(runQaSuite).not.toHaveBeenCalled();
720+
});
721+
722+
it("keeps live taxonomy metadata unchanged without an explicit adapter channel", async () => {
723+
await runQaSuiteCommand({
724+
channelDriver: "live",
725+
scenarioIds: ["channel-chat-baseline"],
726+
});
727+
728+
expect(runQaSuite).toHaveBeenCalledWith(
729+
expect.not.objectContaining({ adapterFactories: expect.anything() }),
730+
);
731+
});
732+
647733
it("uses the Crabline default channel when selected scenarios do not request one", async () => {
648734
await runQaSuiteCommand({
649735
repoRoot: "/tmp/openclaw-repo",

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

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ import {
4343
type JsonlReplayInput,
4444
} from "./jsonl-replay.js";
4545
import { startQaLabServer } from "./lab-server.js";
46-
import { runQaManualLane } from "./manual-lane.runtime.js";
46+
import { listLiveTransportQaAdapterFactories } from "./live-transports/cli.js";
4747
import { loadNonYamlScenarioRefs } from "./live-transports/shared/live-transport-scenarios.js";
48+
import { runQaManualLane } from "./manual-lane.runtime.js";
4849
import { runQaMultipass } from "./multipass.runtime.js";
4950
import { DEFAULT_QA_LIVE_PROVIDER_MODE, getQaProvider } from "./providers/index.js";
5051
import {
@@ -899,10 +900,23 @@ export async function runQaSuiteCommand(opts: QaSuiteCommandOptions) {
899900
const primaryModel = normalizeQaOptionalModelRef(opts.primaryModel);
900901
const alternateModel = normalizeQaOptionalModelRef(opts.alternateModel);
901902
const channelDriver = normalizeQaSuiteChannelDriver(opts.channelDriver);
902-
if (opts.channel?.trim() && channelDriver !== "crabline") {
903-
throw new Error(
904-
"--channel override is currently only supported with --channel-driver crabline.",
905-
);
903+
if (opts.channel?.trim() && channelDriver !== "crabline" && channelDriver !== "live") {
904+
throw new Error("--channel override requires --channel-driver crabline or live.");
905+
}
906+
const liveChannelId = channelDriver === "live" ? opts.channel?.trim() : undefined;
907+
const liveAdapterFactories = liveChannelId ? listLiveTransportQaAdapterFactories() : undefined;
908+
const liveAdapterFactory = liveChannelId
909+
? liveAdapterFactories?.find((factory) => factory.id === liveChannelId)
910+
: undefined;
911+
if (liveChannelId && !liveAdapterFactory) {
912+
throw new Error(`unknown live QA adapter: ${liveChannelId}`);
913+
}
914+
const liveScenarioIds =
915+
liveAdapterFactory && scenarioIds.length === 0
916+
? [...(liveAdapterFactory.scenarioIds ?? [])]
917+
: scenarioIds;
918+
if (liveAdapterFactory && liveScenarioIds.length === 0) {
919+
throw new Error(`live QA adapter ${liveChannelId} does not declare default scenarios`);
906920
}
907921
if (runner !== "host" && runner !== "multipass") {
908922
throw new Error(`--runner must be one of host or multipass, got "${opts.runner}".`);
@@ -938,6 +952,12 @@ export async function runQaSuiteCommand(opts: QaSuiteCommandOptions) {
938952
if (runner === "multipass" && opts.cliAuthMode !== undefined) {
939953
throw new Error("--cli-auth-mode requires --runner host.");
940954
}
955+
if (runner === "multipass" && liveChannelId) {
956+
throw new Error("--channel-driver live with --channel requires --runner host.");
957+
}
958+
if (runtimePair && liveChannelId) {
959+
throw new Error("--runtime-pair is not supported with a live QA adapter.");
960+
}
941961
if (runner === "multipass") {
942962
rejectNonFlowScenarioIdsForMultipass(scenarioIds);
943963
const thinkingDefault = parseQaThinkingLevel("--thinking", opts.thinking);
@@ -997,18 +1017,29 @@ export async function runQaSuiteCommand(opts: QaSuiteCommandOptions) {
9971017
evidenceMode: opts.evidenceMode,
9981018
transportId,
9991019
channelDriver,
1020+
...(liveChannelId
1021+
? {
1022+
adapterFactories: liveAdapterFactories,
1023+
channelId: liveChannelId,
1024+
adapterOptions: {
1025+
repoRoot,
1026+
},
1027+
}
1028+
: {}),
10001029
channelDriverSelection,
10011030
...(opts.providerMode !== undefined ? { providerMode } : {}),
10021031
primaryModel,
10031032
alternateModel,
10041033
fastMode: opts.fastMode,
10051034
...(thinkingDefault ? { thinkingDefault } : {}),
10061035
...(claudeCliAuthMode ? { claudeCliAuthMode } : {}),
1007-
scenarioIds,
1036+
scenarioIds: liveChannelId ? liveScenarioIds : scenarioIds,
10081037
...(opts.enabledPluginIds !== undefined ? { enabledPluginIds: opts.enabledPluginIds } : {}),
1009-
...(opts.concurrency !== undefined
1010-
? { concurrency: parseQaPositiveIntegerOption("--concurrency", opts.concurrency) }
1011-
: {}),
1038+
...(liveChannelId
1039+
? { concurrency: 1 }
1040+
: opts.concurrency !== undefined
1041+
? { concurrency: parseQaPositiveIntegerOption("--concurrency", opts.concurrency) }
1042+
: {}),
10121043
...(runtimePair ? { runtimePair } : {}),
10131044
}),
10141045
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ export function registerQaLabCli(program: Command) {
470470
.option("--channel-driver <id>", "QA channel driver: qa-channel, crabline, or live")
471471
.option(
472472
"--channel <id>",
473-
"Internal host QA channel override for --channel-driver; defaults to scenario/default",
473+
"Channel id for --channel-driver crabline or live",
474474
)
475475
.option("--provider-mode <mode>", formatQaProviderModeHelp())
476476
.option("--model <ref>", "Primary provider/model ref")
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Qa Lab tests cover live transport CLI and adapter contribution discovery.
2+
import { Command } from "commander";
3+
import type { QaRunnerCliContribution } from "openclaw/plugin-sdk/qa-runner-runtime";
4+
import { beforeEach, describe, expect, it, vi } from "vitest";
5+
6+
const { listQaRunnerCliContributions, runSlack, runTelegram, runWhatsApp } = vi.hoisted(() => ({
7+
listQaRunnerCliContributions: vi.fn<() => QaRunnerCliContribution[]>(() => []),
8+
runSlack: vi.fn(),
9+
runTelegram: vi.fn(),
10+
runWhatsApp: vi.fn(),
11+
}));
12+
13+
vi.mock("openclaw/plugin-sdk/qa-runner-runtime", () => ({ listQaRunnerCliContributions }));
14+
vi.mock("./slack/cli.runtime.js", () => ({ runQaSlackCommand: runSlack }));
15+
vi.mock("./telegram/cli.runtime.js", () => ({ runQaTelegramCommand: runTelegram }));
16+
vi.mock("./whatsapp/cli.runtime.js", () => ({ runQaWhatsAppCommand: runWhatsApp }));
17+
18+
import {
19+
listLiveTransportQaAdapterFactories,
20+
listLiveTransportQaCliRegistrations,
21+
} from "./cli.js";
22+
23+
const matrixFactory = {
24+
id: "matrix",
25+
scenarioIds: ["channel-chat-baseline"],
26+
matches: vi.fn(() => true),
27+
create: vi.fn(),
28+
};
29+
30+
describe("live transport QA contributions", () => {
31+
beforeEach(() => {
32+
vi.clearAllMocks();
33+
listQaRunnerCliContributions.mockReturnValue([
34+
{
35+
pluginId: "qa-matrix",
36+
commandName: "matrix",
37+
status: "available",
38+
registration: {
39+
commandName: "matrix",
40+
adapterFactory: matrixFactory,
41+
register(qa) {
42+
qa.command("matrix").action(() => undefined);
43+
},
44+
},
45+
},
46+
]);
47+
});
48+
49+
it("discovers all four canonical live adapter factories without changing CLI ownership", () => {
50+
expect(listLiveTransportQaAdapterFactories().map((factory) => factory.id)).toEqual([
51+
"telegram",
52+
"slack",
53+
"whatsapp",
54+
"matrix",
55+
]);
56+
});
57+
58+
it.each([
59+
["telegram", runTelegram],
60+
["slack", runSlack],
61+
["whatsapp", runWhatsApp],
62+
] as const)("keeps the shipped %s command runner", async (commandName, runCommand) => {
63+
const registration = listLiveTransportQaCliRegistrations().find(
64+
(candidate) => candidate.commandName === commandName,
65+
);
66+
const qa = new Command();
67+
registration?.register(qa);
68+
69+
await qa.parseAsync(["node", "openclaw", commandName, "--scenario", `${commandName}-canary`]);
70+
71+
expect(runCommand).toHaveBeenCalledWith(
72+
expect.objectContaining({ scenarioIds: [`${commandName}-canary`] }),
73+
);
74+
});
75+
});

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,9 @@ export function listLiveTransportQaCliRegistrations(): readonly LiveTransportQaC
5555

5656
return liveRegistrations;
5757
}
58+
59+
export function listLiveTransportQaAdapterFactories() {
60+
return listLiveTransportQaCliRegistrations().flatMap((registration) =>
61+
registration.adapterFactory ? [registration.adapterFactory] : [],
62+
);
63+
}

0 commit comments

Comments
 (0)