Skip to content

Commit e5fe4be

Browse files
committed
test(qa): derive planning scenarios from coverage
1 parent 71b97e0 commit e5fe4be

2 files changed

Lines changed: 97 additions & 61 deletions

File tree

‎extensions/qa-lab/src/scenario-flow-runner.test.ts‎

Lines changed: 88 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// Qa Lab tests cover scenario flow runner plugin behavior.
22
import { describe, expect, it } from "vitest";
33
import { createQaBusState } from "./bus-state.js";
4-
import { readQaScenarioById, type QaScenarioFlow } from "./scenario-catalog.js";
4+
import {
5+
readQaScenarioById,
6+
readQaScenarioPack,
7+
type QaScenarioExecution,
8+
type QaScenarioFlow,
9+
type QaSeedScenarioWithSource,
10+
} from "./scenario-catalog.js";
511
import { runScenarioFlow } from "./scenario-flow-runner.js";
612

713
type QaFlowStep = {
@@ -207,20 +213,31 @@ async function runWebchatTranscriptWait(
207213
});
208214
}
209215

210-
type PlanningScenarioId =
211-
| "codex-harness-no-meta-leak"
212-
| "medium-game-plan-codex-harness"
213-
| "medium-game-plan-openclaw-harness";
216+
const planningEvidenceCoverageIds = new Set(["runtime.no-meta-leak", "workspace.planning"]);
217+
218+
type PlanningEvidenceScenario = QaSeedScenarioWithSource & {
219+
execution: Extract<QaScenarioExecution, { kind: "flow" }> & { flow?: QaScenarioFlow };
220+
};
221+
222+
function isPlanningEvidenceScenario(
223+
scenario: QaSeedScenarioWithSource,
224+
): scenario is PlanningEvidenceScenario {
225+
return (
226+
scenario.execution.kind === "flow" &&
227+
[...(scenario.coverage?.primary ?? []), ...(scenario.coverage?.secondary ?? [])].some(
228+
(coverageId) => planningEvidenceCoverageIds.has(coverageId),
229+
)
230+
);
231+
}
214232

215233
type PlanningEvidenceFixture = {
216234
currentSummary: Record<string, unknown>;
217235
failureMessage: string;
218236
outboundText: string;
219-
scenarioId: PlanningScenarioId;
237+
scenario: PlanningEvidenceScenario;
220238
};
221239

222-
function readPlanningEvidenceFlow(scenarioId: PlanningScenarioId): QaScenarioFlow {
223-
const scenario = readQaScenarioById(scenarioId);
240+
function readPlanningEvidenceFlow(scenario: PlanningEvidenceScenario): QaScenarioFlow {
224241
const step = scenario.execution.flow?.steps.find((candidate) =>
225242
candidate.actions.some(
226243
(action) =>
@@ -231,7 +248,7 @@ function readPlanningEvidenceFlow(scenarioId: PlanningScenarioId): QaScenarioFlo
231248
),
232249
);
233250
if (!step) {
234-
throw new Error(`planning scenario has no agent turn: ${scenarioId}`);
251+
throw new Error(`planning scenario has no agent turn: ${scenario.id}`);
235252
}
236253
const artifactIndex = step.actions.findIndex(
237254
(action) =>
@@ -254,6 +271,60 @@ function readPlanningEvidenceFlow(scenarioId: PlanningScenarioId): QaScenarioFlo
254271
};
255272
}
256273

274+
function createPlanningEvidenceFixture(
275+
scenario: PlanningEvidenceScenario,
276+
): PlanningEvidenceFixture {
277+
const config = scenario.execution.config ?? {};
278+
const artifactFile = typeof config.artifactFile === "string" ? config.artifactFile : undefined;
279+
const expectedReply = typeof config.expectedReply === "string" ? config.expectedReply : undefined;
280+
const internalMarker =
281+
typeof config.internalMarker === "string" ? config.internalMarker : undefined;
282+
283+
if (scenario.execution.runtime === "codex" && expectedReply && internalMarker) {
284+
return {
285+
scenario,
286+
outboundText: expectedReply,
287+
failureMessage: "missing marked Codex internal plan/reasoning mirror evidence",
288+
currentSummary: {
289+
eventCursor: 9,
290+
assistantMirrors: [
291+
{ identity: "current-turn:plan", text: `Codex plan:\n${internalMarker}` },
292+
{ identity: "current-turn:assistant", text: expectedReply },
293+
],
294+
successfulToolCallCounts: {},
295+
},
296+
};
297+
}
298+
if (scenario.execution.runtime === "codex" && artifactFile) {
299+
const outboundText = `Built ${artifactFile}`;
300+
return {
301+
scenario,
302+
outboundText,
303+
failureMessage: "missing Codex App Server plan signal",
304+
currentSummary: {
305+
eventCursor: 9,
306+
assistantMirrors: [
307+
{ identity: "current-turn:plan", text: "Codex plan:\n- build the game" },
308+
{ identity: "current-turn:assistant", text: outboundText },
309+
],
310+
successfulToolCallCounts: {},
311+
},
312+
};
313+
}
314+
if (scenario.execution.runtime === "openclaw" && artifactFile) {
315+
return {
316+
scenario,
317+
outboundText: `Built ${artifactFile}`,
318+
failureMessage: "missing OpenClaw update_plan signal",
319+
currentSummary: {
320+
eventCursor: 9,
321+
successfulToolCallCounts: { update_plan: 1 },
322+
},
323+
};
324+
}
325+
throw new Error(`unsupported planning evidence metadata: ${scenario.id}`);
326+
}
327+
257328
function runPlanningEvidenceFixture(
258329
fixture: PlanningEvidenceFixture,
259330
currentSummary = fixture.currentSummary,
@@ -272,8 +343,8 @@ function runPlanningEvidenceFixture(
272343
currentSummary,
273344
];
274345
let readIndex = 0;
275-
const result = runLoadedScenarioFlow(fixture.scenarioId, {
276-
flow: readPlanningEvidenceFlow(fixture.scenarioId),
346+
const result = runLoadedScenarioFlow(fixture.scenario.id, {
347+
flow: readPlanningEvidenceFlow(fixture.scenario),
277348
state,
278349
onWaitForOutboundMessage: ({ state: currentState }) => {
279350
currentState.addOutboundMessage({
@@ -305,50 +376,13 @@ function runPlanningEvidenceFixture(
305376
return { readOptions, result };
306377
}
307378

308-
const planningEvidenceFixtures: PlanningEvidenceFixture[] = [
309-
{
310-
scenarioId: "codex-harness-no-meta-leak",
311-
outboundText: "QA_LEAK_OK",
312-
failureMessage: "missing marked Codex internal plan/reasoning mirror evidence",
313-
currentSummary: {
314-
eventCursor: 9,
315-
assistantMirrors: [
316-
{ identity: "current-turn:plan", text: "Codex plan:\nQA_INTERNAL_PLAN_DO_NOT_SEND" },
317-
{ identity: "current-turn:assistant", text: "QA_LEAK_OK" },
318-
],
319-
successfulToolCallCounts: {},
320-
},
321-
},
322-
{
323-
scenarioId: "medium-game-plan-codex-harness",
324-
outboundText: "Built star-garden-defenders-codex.html",
325-
failureMessage: "missing Codex App Server plan signal",
326-
currentSummary: {
327-
eventCursor: 9,
328-
assistantMirrors: [
329-
{ identity: "current-turn:plan", text: "Codex plan:\n- build the game" },
330-
{
331-
identity: "current-turn:assistant",
332-
text: "Built star-garden-defenders-codex.html",
333-
},
334-
],
335-
successfulToolCallCounts: {},
336-
},
337-
},
338-
{
339-
scenarioId: "medium-game-plan-openclaw-harness",
340-
outboundText: "Built star-garden-defenders-openclaw.html",
341-
failureMessage: "missing OpenClaw update_plan signal",
342-
currentSummary: {
343-
eventCursor: 9,
344-
successfulToolCallCounts: { update_plan: 1 },
345-
},
346-
},
347-
];
379+
const planningEvidenceFixtures = readQaScenarioPack()
380+
.scenarios.filter(isPlanningEvidenceScenario)
381+
.map(createPlanningEvidenceFixture);
348382

349383
describe("scenario-flow-runner", () => {
350384
it.each(planningEvidenceFixtures)(
351-
"accepts current-attempt planning evidence for $scenarioId",
385+
"accepts current-attempt planning evidence for $scenario.id",
352386
async (fixture) => {
353387
const { readOptions, result } = runPlanningEvidenceFixture(fixture);
354388

@@ -358,11 +392,11 @@ describe("scenario-flow-runner", () => {
358392
);
359393

360394
it.each(planningEvidenceFixtures)(
361-
"rejects stale prior-attempt planning evidence for $scenarioId",
395+
"rejects stale prior-attempt planning evidence for $scenario.id",
362396
async (fixture) => {
363397
const currentSummary = {
364398
eventCursor: 8,
365-
...(fixture.scenarioId.includes("codex")
399+
...(fixture.scenario.execution.runtime === "codex"
366400
? {
367401
assistantMirrors: [
368402
{ identity: "current-turn:assistant", text: fixture.outboundText },

‎extensions/qa-lab/src/scenario-lane.test.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
// Qa Lab tests cover canonical scenario lane matching behavior.
22
import { describe, expect, it } from "vitest";
3-
import { readQaScenarioById } from "./scenario-catalog.js";
3+
import { readQaScenarioPack } from "./scenario-catalog.js";
44
import {
55
describeQaProviderLaneMismatches,
66
scenarioMatchesQaProviderLane,
77
} from "./scenario-lane.js";
88
import { makeQaSuiteTestScenario } from "./suite-test-helpers.js";
99

1010
describe("QA scenario lane matching", () => {
11-
it.each([
12-
"codex-harness-no-meta-leak",
13-
"medium-game-plan-codex-harness",
14-
"medium-game-plan-openclaw-harness",
15-
])("selects %s for the GPT-5.6 Luna live lane", (scenarioId) => {
16-
const scenario = readQaScenarioById(scenarioId);
11+
const planningCoverageIds = new Set(["runtime.no-meta-leak", "workspace.planning"]);
12+
const planningScenarios = readQaScenarioPack().scenarios.filter((scenario) =>
13+
[...(scenario.coverage?.primary ?? []), ...(scenario.coverage?.secondary ?? [])].some(
14+
(coverageId) => planningCoverageIds.has(coverageId),
15+
),
16+
);
17+
18+
it.each(planningScenarios)("selects $id for the GPT-5.6 Luna live lane", (scenario) => {
1719
expect(
1820
scenarioMatchesQaProviderLane({
1921
scenario,

0 commit comments

Comments
 (0)