惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
博客园 - 聂微东
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
小众软件
小众软件
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
量子位
月光博客
月光博客
博客园 - 【当耐特】
博客园 - 叶小钗

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: tighten detached task runtime assertions · openclaw...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -53,6 +53,11 @@ function createFakeTaskRecord(overrides?: Partial<TaskRecord>): TaskRecord {

5353

};

5454

}

555556+

function findWarningPayload(message: string): Record<string, unknown> | undefined {

57+

const payload = mockLogWarn.mock.calls.find(([entry]) => entry === message)?.[1];

58+

return payload && typeof payload === "object" ? (payload as Record<string, unknown>) : undefined;

59+

}

60+5661

describe("detached-task-runtime", () => {

5762

afterEach(() => {

5863

resetDetachedTaskLifecycleRuntimeForTests();

@@ -125,30 +130,36 @@ describe("detached-task-runtime", () => {

125130

taskId: runningTask.taskId,

126131

});

127132128-

expect(fakeRuntime.createQueuedTaskRun).toHaveBeenCalledWith(

129-

expect.objectContaining({ runId: "run-queued", task: "Queue task" }),

130-

);

131-

expect(fakeRuntime.createRunningTaskRun).toHaveBeenCalledWith(

132-

expect.objectContaining({ runId: "run-running", task: "Run task" }),

133-

);

134-

expect(fakeRuntime.startTaskRunByRunId).toHaveBeenCalledWith(

135-

expect.objectContaining({ runId: "run-running", startedAt: 10 }),

136-

);

137-

expect(fakeRuntime.recordTaskRunProgressByRunId).toHaveBeenCalledWith(

138-

expect.objectContaining({ runId: "run-running", lastEventAt: 20 }),

139-

);

140-

expect(fakeRuntime.finalizeTaskRunByRunId).toHaveBeenCalledWith(

141-

expect.objectContaining({ runId: "run-running", status: "succeeded", endedAt: 25 }),

142-

);

143-

expect(fakeRuntime.completeTaskRunByRunId).toHaveBeenCalledWith(

144-

expect.objectContaining({ runId: "run-running", endedAt: 30 }),

145-

);

146-

expect(fakeRuntime.failTaskRunByRunId).toHaveBeenCalledWith(

147-

expect.objectContaining({ runId: "run-running", endedAt: 40 }),

148-

);

149-

expect(fakeRuntime.setDetachedTaskDeliveryStatusByRunId).toHaveBeenCalledWith(

150-

expect.objectContaining({ runId: "run-running", deliveryStatus: "delivered" }),

151-

);

133+

const queuedArgs = vi.mocked(fakeRuntime.createQueuedTaskRun).mock.calls[0]?.[0];

134+

expect(queuedArgs?.runId).toBe("run-queued");

135+

expect(queuedArgs?.task).toBe("Queue task");

136+

const runningArgs = vi.mocked(fakeRuntime.createRunningTaskRun).mock.calls[0]?.[0];

137+

expect(runningArgs?.runId).toBe("run-running");

138+

expect(runningArgs?.task).toBe("Run task");

139+

const startArgs = vi.mocked(fakeRuntime.startTaskRunByRunId).mock.calls[0]?.[0];

140+

expect(startArgs?.runId).toBe("run-running");

141+

expect(startArgs?.startedAt).toBe(10);

142+

const progressArgs = vi.mocked(fakeRuntime.recordTaskRunProgressByRunId).mock.calls[0]?.[0];

143+

expect(progressArgs?.runId).toBe("run-running");

144+

expect(progressArgs?.lastEventAt).toBe(20);

145+

const finalizeMock = fakeRuntime.finalizeTaskRunByRunId;

146+

if (!finalizeMock) {

147+

throw new Error("Expected fake runtime finalizer");

148+

}

149+

const finalizeArgs = vi.mocked(finalizeMock).mock.calls[0]?.[0];

150+

expect(finalizeArgs?.runId).toBe("run-running");

151+

expect(finalizeArgs?.status).toBe("succeeded");

152+

expect(finalizeArgs?.endedAt).toBe(25);

153+

const completeArgs = vi.mocked(fakeRuntime.completeTaskRunByRunId).mock.calls[0]?.[0];

154+

expect(completeArgs?.runId).toBe("run-running");

155+

expect(completeArgs?.endedAt).toBe(30);

156+

const failArgs = vi.mocked(fakeRuntime.failTaskRunByRunId).mock.calls[0]?.[0];

157+

expect(failArgs?.runId).toBe("run-running");

158+

expect(failArgs?.endedAt).toBe(40);

159+

const deliveryArgs = vi.mocked(fakeRuntime.setDetachedTaskDeliveryStatusByRunId).mock

160+

.calls[0]?.[0];

161+

expect(deliveryArgs?.runId).toBe("run-running");

162+

expect(deliveryArgs?.deliveryStatus).toBe("delivered");

152163

expect(fakeRuntime.cancelDetachedTaskRunById).toHaveBeenCalledWith({

153164

cfg: {} as never,

154165

taskId: runningTask.taskId,

@@ -165,17 +176,18 @@ describe("detached-task-runtime", () => {

165176166177

registerDetachedTaskRuntime("tests/detached-runtime", runtime);

167178168-

expect(getDetachedTaskLifecycleRuntimeRegistration()).toMatchObject({

169-

pluginId: "tests/detached-runtime",

170-

runtime,

171-

});

179+

const registration = getDetachedTaskLifecycleRuntimeRegistration();

180+

expect(registration?.pluginId).toBe("tests/detached-runtime");

181+

expect(registration?.runtime).toBe(runtime);

172182

expect(getDetachedTaskLifecycleRuntime()).toBe(runtime);

173183

});

174184175185

it("falls back to legacy complete and fail hooks when a runtime has no finalizer", () => {

176186

const defaultRuntime = getDetachedTaskLifecycleRuntime();

177-

const completeTaskRunByRunIdSpy = vi.fn(() => []);

178-

const failTaskRunByRunIdSpy = vi.fn(() => []);

187+

const completeTaskRunByRunIdSpy = vi.fn(

188+

(_params: Parameters<typeof completeTaskRunByRunId>[0]) => [],

189+

);

190+

const failTaskRunByRunIdSpy = vi.fn((_params: Parameters<typeof failTaskRunByRunId>[0]) => []);

179191

const legacyRuntime = {

180192

...defaultRuntime,

181193

completeTaskRunByRunId: completeTaskRunByRunIdSpy,

@@ -188,12 +200,16 @@ describe("detached-task-runtime", () => {

188200

finalizeTaskRunByRunId({ runId: "legacy-ok", status: "succeeded", endedAt: 10 });

189201

finalizeTaskRunByRunId({ runId: "legacy-timeout", status: "timed_out", endedAt: 20 });

190202191-

expect(completeTaskRunByRunIdSpy).toHaveBeenCalledWith(

192-

expect.objectContaining({ runId: "legacy-ok", status: "succeeded", endedAt: 10 }),

193-

);

194-

expect(failTaskRunByRunIdSpy).toHaveBeenCalledWith(

195-

expect.objectContaining({ runId: "legacy-timeout", status: "timed_out", endedAt: 20 }),

196-

);

203+

const completeArgs = completeTaskRunByRunIdSpy.mock.calls[0]?.[0] as

204+

| Parameters<typeof finalizeTaskRunByRunId>[0]

205+

| undefined;

206+

expect(completeArgs?.runId).toBe("legacy-ok");

207+

expect(completeArgs?.status).toBe("succeeded");

208+

expect(completeArgs?.endedAt).toBe(10);

209+

const failArgs = failTaskRunByRunIdSpy.mock.calls[0]?.[0];

210+

expect(failArgs?.runId).toBe("legacy-timeout");

211+

expect(failArgs?.status).toBe("timed_out");

212+

expect(failArgs?.endedAt).toBe(20);

197213

});

198214199215

describe("tryRecoverTaskBeforeMarkLost", () => {

@@ -253,17 +269,11 @@ describe("detached-task-runtime", () => {

253269

now: 1_000,

254270

});

255271

expect(result).toEqual({ recovered: false });

256-

expect(mockLogWarn).toHaveBeenCalledWith(

272+

const warningPayload = findWarningPayload(

257273

"Detached task recovery hook threw, proceeding with markTaskLost",

258-

expect.objectContaining({

259-

taskId: "task-throw",

260-

runtime: "acp",

261-

}),

262274

);

263-

const warningPayload = mockLogWarn.mock.calls.find(

264-

([message]) =>

265-

message === "Detached task recovery hook threw, proceeding with markTaskLost",

266-

)?.[1] as { elapsedMs?: unknown } | undefined;

275+

expect(warningPayload?.taskId).toBe("task-throw");

276+

expect(warningPayload?.runtime).toBe("acp");

267277

expect(typeof warningPayload?.elapsedMs).toBe("number");

268278

if (typeof warningPayload?.elapsedMs !== "number") {

269279

throw new Error("Expected detached task recovery warning elapsedMs");

@@ -284,10 +294,11 @@ describe("detached-task-runtime", () => {

284294

now: 2_000,

285295

});

286296

expect(result).toEqual({ recovered: false });

287-

expect(mockLogWarn).toHaveBeenCalledWith(

297+

const warningPayload = findWarningPayload(

288298

"Detached task recovery hook returned invalid result, proceeding with markTaskLost",

289-

expect.objectContaining({ taskId: "task-invalid", runtime: "cron" }),

290299

);

300+

expect(warningPayload?.taskId).toBe("task-invalid");

301+

expect(warningPayload?.runtime).toBe("cron");

291302

});

292303293304

it("logs when the recovery hook is slow", async () => {

@@ -305,10 +316,10 @@ describe("detached-task-runtime", () => {

305316

now: 3_000,

306317

});

307318

expect(result).toEqual({ recovered: true });

308-

expect(mockLogWarn).toHaveBeenCalledWith(

309-

"Detached task recovery hook was slow",

310-

expect.objectContaining({ taskId: "task-slow", runtime: "subagent", elapsedMs: 6_000 }),

311-

);

319+

const warningPayload = findWarningPayload("Detached task recovery hook was slow");

320+

expect(warningPayload?.taskId).toBe("task-slow");

321+

expect(warningPayload?.runtime).toBe("subagent");

322+

expect(warningPayload?.elapsedMs).toBe(6_000);

312323

dateNowSpy.mockRestore();

313324

});

314325

});