test(qa): two QA lab end-to-end tests fail on main (#198417)

* test(qa): find built Gateway chunks by exported bindings

The Telegram model-picker replacement proof located its hashed dist
chunks by whitespace-sensitive export text. #197801 (d8eca04bb3)
switched the build to compact codegen, so chunks now read
`export{startGatewayServer,truncateCloseReason}` and the markers no
longer match: the case failed with "Could not resolve built
prepared-model-runtime- module" before starting a Gateway.

Parse the candidate chunks and match the names the bootstrap script
imports, so formatting, export order and unrelated exports no longer
decide which module is found. Product behavior is unchanged; the case
passes again with its assertions untouched.

* test(qa): read the whole current turn in timeout-recovery mock

The mock provider in the timeout-recovery subagent proof treated the
last Responses input item as the current turn. #198100 (bf0b8002c2)
pins the system prompt on every route and appends prompt updates after
the turn's input, so the completion event was no longer last. The mock
answered the delivery turn as a plain retry and the reply sequence
assertion failed, although the Gateway still delivered the child
completion once.

Read everything after the previous assistant reply, the same rule
#198177 applied to the other subagent prompt tests. Assertions are
unchanged.
This commit is contained in:
Jason (Json) 2026-11-13 13:23:19 -06:00 • committed by GitHub
parent cda18427ad
commit 77a0a84265
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 10 deletions

View file

@ -197,7 +197,11 @@ async function startProofProvider() {
if (parentContinuationSeen) {
// Compacted history must neither respawn the child nor fabricate its completion.
// The "awaiting delivery" roster is status, not delivery; only the completion event counts.
const currentInput = JSON.stringify(Array.isArray(body.input) ? body.input.at(-1) : body);
// Prompt updates are appended after a turn's input, so read everything since the last reply.
const input = body.input as Array<{ role?: string }>;
const currentInput = JSON.stringify(
input.slice(input.findLastIndex((item) => item.role === "assistant") + 1),
);
const hasChildCompletion =
currentInput.includes("[Internal task completion event]") &&
currentInput.includes("qa-timeout-recovery-child") &&

View file

@ -5,6 +5,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
import net from "node:net";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { parse } from "@babel/parser";
import { withServer, withTempDir } from "openclaw/plugin-sdk/test-env";
import { expect, test } from "vitest";
import { createQaGatewayChild, writeJson } from "../../../../extensions/qa-lab/api.js";
@ -217,21 +218,40 @@ async function reservePort(): Promise<number> {
return address.port;
}
/** Finds a hashed chunk by the bindings it exports; bundler formatting is not a contract. */
async function resolveBuiltModule(params: {
distDir: string;
prefix: string;
exportMarker: string;
exports: string[];
}): Promise<string> {
for (const name of await fs.readdir(params.distDir)) {
if (!name.startsWith(params.prefix) || !/\.m?js$/u.test(name)) {
continue;
}
const filePath = path.join(params.distDir, name);
if ((await fs.readFile(filePath, "utf8")).includes(params.exportMarker)) {
const source = await fs.readFile(filePath, "utf8");
// Every exported name appears in the module text, so most chunks never need parsing.
if (!params.exports.every((binding) => source.includes(binding))) {
continue;
}
const exported = new Set(
parse(source, { sourceType: "module" }).program.body.flatMap((statement) =>
statement.type === "ExportNamedDeclaration"
? statement.specifiers.map((specifier) =>
specifier.exported.type === "Identifier"
? specifier.exported.name
: specifier.exported.value,
)
: [],
),
);
if (params.exports.every((binding) => exported.has(binding))) {
return pathToFileURL(filePath).href;
}
}
throw new Error(`Could not resolve built ${params.prefix} module`);
throw new Error(
`Could not resolve a built ${params.prefix} module exporting ${params.exports.join(", ")}`,
);
}
async function startControlledSourceGateway(params: {
@ -246,15 +266,15 @@ async function startControlledSourceGateway(params: {
const port = await reservePort();
const distDir = path.join(params.repoRoot, "dist");
const [serverUrl, runtimeUrl] = await Promise.all([
resolveBuiltModule({
distDir,
prefix: "server-",
exportMarker: "startGatewayServer, truncateCloseReason",
}),
resolveBuiltModule({ distDir, prefix: "server-", exports: ["startGatewayServer"] }),
resolveBuiltModule({
distDir,
prefix: "prepared-model-runtime-",
exportMarker: "export { PreparedModelRuntimeOwnerNotPublishedError",
exports: [
"markPreparedModelRuntimeSnapshotsStale",
"refreshPreparedModelRuntimeSnapshots",
"rejectPendingPreparedModelRuntimeReplacement",
],
}),
]);
await fs.writeFile(