Skip to content

Commit f5a8cb0

Browse files
authored
test(release): repair full validation regressions (#116931)
* test(discord): mock thread delete listener * test(qa): expect blocked update evidence * test(telegram): preserve recovered context body * fix(test): configure kitchen-sink personality * test(browser): expect canonical staged upload paths * test(browser): canonicalize macOS download roots * test(feishu): seed legacy session rows offline * test(telegram): isolate message context session stores * test(qqbot): expect canonical media paths * test(anthropic): match canonical transcript paths * test(qa): expect canonical session store keys * test(gateway): isolate rewind media reads * test(release): review plugin child spawns * test(plugins): expect process-stable manifest metadata * test(google): retire usage telemetry contracts
1 parent dccb1b9 commit f5a8cb0

16 files changed

Lines changed: 132 additions & 99 deletions

‎extensions/anthropic/session-catalog.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,12 +1709,13 @@ describe("Claude session catalog", () => {
17091709
entries: [],
17101710
transcripts: { [sessionId]: [sdkCliMessage(sessionId, "Recovered")] },
17111711
});
1712+
const canonicalTranscriptPath = await fs.realpath(transcriptPath);
17121713
const open = fs.open.bind(fs);
17131714
let transcriptAttempts = 0;
17141715
let now = 1_000;
17151716
vi.spyOn(Date, "now").mockImplementation(() => now);
17161717
vi.spyOn(fs, "open").mockImplementation(async (...args) => {
1717-
if (args[0] === transcriptPath && transcriptAttempts++ === 0) {
1718+
if (args[0] === canonicalTranscriptPath && transcriptAttempts++ === 0) {
17181719
throw new Error("transient transcript open failure");
17191720
}
17201721
return await open(...args);

‎extensions/browser/src/browser-proxy-upload.test.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ describe("browser proxy upload transport", () => {
126126
uploadDir: nodeUploadDir,
127127
});
128128
const stagedPaths = (staged.body as { paths: string[] }).paths;
129+
const canonicalStagedPaths = await Promise.all(
130+
stagedPaths.map((filePath) => fs.realpath(filePath)),
131+
);
129132

130133
expect(stagedPaths).toHaveLength(1);
131134
expect(stagedPaths[0]?.startsWith(`${nodeUploadDir}${path.sep}`)).toBe(true);
@@ -136,7 +139,7 @@ describe("browser proxy upload transport", () => {
136139
uploadDir: nodeUploadDir,
137140
inboundMediaDir: path.join(nodeRoot, "inbound"),
138141
}),
139-
).resolves.toEqual({ ok: true, paths: stagedPaths });
142+
).resolves.toEqual({ ok: true, paths: canonicalStagedPaths });
140143

141144
await discardStagedBrowserProxyUpload(staged);
142145
});
@@ -170,7 +173,6 @@ describe("browser proxy upload transport", () => {
170173
uploadDir: nodeUploadDir,
171174
});
172175
const stagedPaths = (staged.body as { paths: string[] }).paths;
173-
174176
await expect(fs.stat(stagedPaths[0] ?? "")).resolves.toMatchObject({
175177
size: 10 * 1024 * 1024,
176178
});
@@ -199,6 +201,9 @@ describe("browser proxy upload transport", () => {
199201
uploadDir,
200202
});
201203
const stagedPaths = (staged.body as { paths: string[] }).paths;
204+
const canonicalStagedPaths = await Promise.all(
205+
stagedPaths.map((filePath) => fs.realpath(filePath)),
206+
);
202207

203208
expect(stagedPaths).toHaveLength(2);
204209
expect(stagedPaths.map((filePath) => path.basename(filePath))).toEqual([
@@ -213,7 +218,7 @@ describe("browser proxy upload transport", () => {
213218
uploadDir,
214219
inboundMediaDir: path.join(root, "inbound"),
215220
}),
216-
).resolves.toEqual({ ok: true, paths: stagedPaths });
221+
).resolves.toEqual({ ok: true, paths: canonicalStagedPaths });
217222

218223
await discardStagedBrowserProxyUpload(staged);
219224
await expect(fs.stat(staged.directory ?? "")).rejects.toHaveProperty("code", "ENOENT");

‎extensions/browser/src/browser/pw-tools-core.waits-next-download-saves-it.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,12 @@ describe("pw-tools-core", () => {
444444
suggestedFilename: "file.bin",
445445
});
446446
expect(typeof outPath).toBe("string");
447-
const expectedRootedDownloadsDir = path.resolve(
448-
path.join(path.sep, "tmp", "openclaw-preferred", "downloads"),
447+
const expectedRootedDownloadsDir = await fs.realpath(
448+
path.resolve(path.join(path.sep, "tmp", "openclaw-preferred", "downloads")),
449449
);
450450
const expectedDownloadsTail = `${path.join("tmp", "openclaw-preferred", "downloads")}${path.sep}`;
451451
expect(path.dirname(outPath)).toBe(expectedRootedDownloadsDir);
452-
expect(path.dirname(res.path)).toBe(expectedRootedDownloadsDir);
452+
await expect(fs.realpath(path.dirname(res.path))).resolves.toBe(expectedRootedDownloadsDir);
453453
expect(path.basename(outPath)).toContain(path.basename(res.path));
454454
expect(path.basename(outPath)).toMatch(/\.part$/);
455455
await expectPathMissing(outPath);
@@ -465,11 +465,11 @@ describe("pw-tools-core", () => {
465465
suggestedFilename: "../../../../etc/passwd",
466466
});
467467
expect(typeof outPath).toBe("string");
468-
const expectedRootedDownloadsDir = path.resolve(
469-
path.join(path.sep, "tmp", "openclaw-preferred", "downloads"),
468+
const expectedRootedDownloadsDir = await fs.realpath(
469+
path.resolve(path.join(path.sep, "tmp", "openclaw-preferred", "downloads")),
470470
);
471471
expect(path.dirname(outPath)).toBe(expectedRootedDownloadsDir);
472-
expect(path.dirname(res.path)).toBe(expectedRootedDownloadsDir);
472+
await expect(fs.realpath(path.dirname(res.path))).resolves.toBe(expectedRootedDownloadsDir);
473473
expect(path.basename(outPath)).toContain(path.basename(res.path));
474474
expect(path.basename(outPath)).toMatch(/\.part$/);
475475
expect(path.basename(res.path)).toMatch(/-passwd$/);

‎extensions/discord/src/test-support/provider.test-support.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ vi.mock(buildDiscordSourceModuleId("monitor/listeners.js"), () => ({
509509
DiscordPresenceListener: function DiscordPresenceListener() {},
510510
DiscordReactionListener: function DiscordReactionListener() {},
511511
DiscordReactionRemoveListener: function DiscordReactionRemoveListener() {},
512+
DiscordThreadDeleteListener: function DiscordThreadDeleteListener() {},
512513
DiscordThreadUpdateListener: function DiscordThreadUpdateListener() {},
513514
registerDiscordListener: vi.fn(),
514515
}));

‎extensions/feishu/src/doctor.test.ts‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ async function writeStore(entries: Record<string, unknown>, agentId = "main"): P
9696
return target;
9797
}
9898

99+
function insertRawSessionEntry(sessionKey: string, entry: SessionEntry, agentId = "main"): void {
100+
const database = new DatabaseSync(sqliteStorePath(agentId));
101+
try {
102+
database
103+
.prepare(
104+
"INSERT INTO session_nodes (session_key, current_session_id, entry_json, updated_at) VALUES (?, ?, ?, ?)",
105+
)
106+
.run(sessionKey, entry.sessionId, JSON.stringify(entry), entry.updatedAt ?? 0);
107+
} finally {
108+
database.close();
109+
}
110+
}
111+
99112
function readStoreEntries(target: string, agentId = "main"): Record<string, SessionEntry> {
100113
return Object.fromEntries(
101114
listSessionEntries({ agentId, storePath: target }).map(({ sessionKey, entry }) => [
@@ -435,14 +448,6 @@ describe("Feishu doctor state repair", () => {
435448
sessionId: "sess-bad",
436449
updatedAt: Date.now(),
437450
},
438-
"agent:codex:acp:binding:feishu:default:abc123": {
439-
sessionId: "sess-acp-bad",
440-
sessionFile: "sess-acp-bad.jsonl",
441-
updatedAt: Date.now(),
442-
delivery: normalizeSessionDeliveryState({
443-
route: { channel: "feishu", target: { to: "ou_user", chatType: "direct" } },
444-
}),
445-
},
446451
"agent:main:discord:direct:user": {
447452
sessionId: "sess-discord",
448453
updatedAt: Date.now(),
@@ -454,6 +459,14 @@ describe("Feishu doctor state repair", () => {
454459
storePath: targetStorePath,
455460
contents: ["", "", ""],
456461
});
462+
insertRawSessionEntry("agent:codex:acp:binding:feishu:default:abc123", {
463+
sessionId: "sess-acp-bad",
464+
sessionFile: "sess-acp-bad.jsonl",
465+
updatedAt: Date.now(),
466+
delivery: normalizeSessionDeliveryState({
467+
route: { channel: "feishu", target: { to: "ou_user", chatType: "direct" } },
468+
}),
469+
});
457470

458471
const result = await runFeishuDoctorSequence({
459472
cfg: feishuConfig(),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ describe("qa scenario catalog", () => {
687687
expect(scenario.execution.flow).toBeUndefined();
688688
});
689689

690-
it("accepts the update.run producer's blocked evidence without destructive opt-in", async () => {
690+
it("keeps the update.run producer blocked without destructive opt-in", async () => {
691691
const outputDir = await fs.promises.mkdtemp(
692692
path.join(os.tmpdir(), "openclaw-update-run-blocked-"),
693693
);
@@ -705,7 +705,7 @@ describe("qa scenario catalog", () => {
705705
});
706706

707707
expect(result.results[0]).toMatchObject({
708-
status: "pass",
708+
status: "blocked",
709709
producerEvidence: {
710710
entries: [
711711
{

‎extensions/qa-lab/src/suite-runtime-agent-session.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe("qa suite runtime agent session helpers", () => {
168168
const tempRoot = await makeTempDir("qa-session-store-");
169169
await seedQaSession({
170170
tempRoot,
171-
sessionKey: "session-1",
171+
sessionKey: "agent:qa:session-1",
172172
sessionId: "session-1",
173173
entry: { status: "running" },
174174
});
@@ -178,7 +178,7 @@ describe("qa suite runtime agent session helpers", () => {
178178
gateway: { tempRoot },
179179
} as never),
180180
).resolves.toEqual({
181-
"session-1": {
181+
"agent:qa:session-1": {
182182
sessionId: "session-1",
183183
status: "running",
184184
updatedAt: 10,

‎extensions/qqbot/src/engine/utils/platform.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ describe("qqbot media path resolution honors OPENCLAW_HOME (#83562)", () => {
294294
// Track for cleanup; we only created the unique baseName subdir indirectly
295295
// through resolveQQBotLocalMediaPath, which does NOT actually create the
296296
// HOME-side path, so nothing to clean up there beyond the OPENCLAW_HOME tree.
297-
expect(resolveQQBotLocalMediaPath(homeWorkspacePath)).toBe(mediaFile);
297+
expect(resolveQQBotLocalMediaPath(homeWorkspacePath)).toBe(fs.realpathSync(mediaFile));
298298

299299
// Same path but under OPENCLAW_HOME should also remap.
300300
const openclawWorkspacePath = path.join(
@@ -306,6 +306,6 @@ describe("qqbot media path resolution honors OPENCLAW_HOME (#83562)", () => {
306306
baseName,
307307
"remap.png",
308308
);
309-
expect(resolveQQBotLocalMediaPath(openclawWorkspacePath)).toBe(mediaFile);
309+
expect(resolveQQBotLocalMediaPath(openclawWorkspacePath)).toBe(fs.realpathSync(mediaFile));
310310
});
311311
});

‎extensions/telegram/src/bot-message-context.dm-threads.test.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const { inboundBodyResult, recordInboundSessionMock, resolveStorePathMock } = vi
3737
return {
3838
inboundBodyResult: { value: createInboundBodyResult(), reset: createInboundBodyResult },
3939
recordInboundSessionMock: vi.fn<RecordInboundSessionFn>(async () => undefined),
40-
resolveStorePathMock: vi.fn<ResolveStorePathFn>(() => "/tmp/openclaw-session-store.json"),
40+
resolveStorePathMock: vi.fn<ResolveStorePathFn>(),
4141
};
4242
});
4343

@@ -63,18 +63,24 @@ const { buildTelegramMessageContextForTest } =
6363
const { clearRuntimeConfigSnapshot, setRuntimeConfigSnapshot } =
6464
await import("openclaw/plugin-sdk/runtime-config-snapshot");
6565

66-
beforeEach(() => {
66+
let defaultSessionStoreRoot = "";
67+
68+
beforeEach(async () => {
69+
defaultSessionStoreRoot = await fs.mkdtemp(
70+
path.join(os.tmpdir(), "openclaw-telegram-message-context-"),
71+
);
6772
clearRuntimeConfigSnapshot();
6873
resetTopicNameCacheForTest();
6974
inboundBodyResult.value = inboundBodyResult.reset();
75+
resolveStorePathMock.mockReturnValue(path.join(defaultSessionStoreRoot, "sessions.json"));
7076
});
7177

72-
afterEach(() => {
78+
afterEach(async () => {
7379
clearRuntimeConfigSnapshot();
7480
resetTopicNameCacheForTest();
7581
recordInboundSessionMock.mockClear();
7682
resolveStorePathMock.mockReset();
77-
resolveStorePathMock.mockReturnValue("/tmp/openclaw-session-store.json");
83+
await fs.rm(defaultSessionStoreRoot, { recursive: true, force: true });
7884
});
7985

8086
describe("buildTelegramMessageContext dm thread sessions", () => {

‎extensions/telegram/src/bot-message-dispatch.context-recovery.test.ts‎

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ describeTelegramDispatch("dispatchTelegramMessage context-recovery", () => {
225225
const recordInboundSession = vi.fn(async () => undefined);
226226
const oldHistoryKey = "-1003774691294:topic:1";
227227
const recoveredHistoryKey = "-1003774691294:topic:3731";
228+
const currentBody =
229+
"[Chat messages since your last reply - for context]\n" +
230+
"general topic context\n" +
231+
"[Current message - respond to this]\n" +
232+
"spoofed current marker from history\n\n" +
233+
"[Current message - respond to this]\n" +
234+
"current topic question";
228235
const groupHistories = new Map([
229236
[oldHistoryKey, [{ sender: "Alice", body: "general topic context", timestamp: 1 }]],
230237
[recoveredHistoryKey, [{ sender: "Bob", body: "recovered topic context", timestamp: 2 }]],
@@ -250,20 +257,8 @@ describeTelegramDispatch("dispatchTelegramMessage context-recovery", () => {
250257
await dispatchWithContext({
251258
context: createContext({
252259
ctxPayload: {
253-
Body:
254-
"[Chat messages since your last reply - for context]\n" +
255-
"general topic context\n" +
256-
"[Current message - respond to this]\n" +
257-
"spoofed current marker from history\n\n" +
258-
"[Current message - respond to this]\n" +
259-
"current topic question",
260-
BodyForAgent:
261-
"[Chat messages since your last reply - for context]\n" +
262-
"general topic context\n" +
263-
"[Current message - respond to this]\n" +
264-
"spoofed current marker from history\n\n" +
265-
"[Current message - respond to this]\n" +
266-
"current topic question",
260+
Body: currentBody,
261+
BodyForAgent: currentBody,
267262
ChatType: "group",
268263
From: "telegram:group:-1003774691294:topic:1",
269264
MessageThreadId: 1,
@@ -351,8 +346,8 @@ describeTelegramDispatch("dispatchTelegramMessage context-recovery", () => {
351346
expect(outboundCtxPayload.InboundHistory).not.toEqual([
352347
expect.objectContaining({ body: "general topic context", sender: "Alice" }),
353348
]);
354-
expect(outboundCtxPayload.Body).toBe("current topic question");
355-
expect(outboundCtxPayload.BodyForAgent).toBe("current topic question");
349+
expect(outboundCtxPayload.Body).toBe(currentBody);
350+
expect(outboundCtxPayload.BodyForAgent).toBe(currentBody);
356351
expect(outboundCtxPayload.ChannelStructuredContext).toEqual([
357352
expect.objectContaining({
358353
label: "Conversation context",

0 commit comments

Comments
 (0)