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

推荐订阅源

博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
爱范儿
爱范儿
月光博客
月光博客
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog
T
Tailwind CSS Blog
美团技术团队
D
Docker
V
Visual Studio Blog
Martin Fowler
Martin Fowler
博客园 - 聂微东
The Cloudflare Blog

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: capture session cleanup json · openclaw/openclaw@f7...
shakkernerd · 2026-05-12 · via Recent Commits to openclaw:main

@@ -221,16 +221,31 @@ describe("sessionsCleanupCommand", () => {

221221

);

222222223223

expect(logs).toHaveLength(1);

224-

const payload = JSON.parse(logs[0] ?? "{}") as Record<string, unknown>;

225-

expect(payload.applied).toBe(true);

226-

expect(payload.mode).toBe("enforce");

227-

expect(payload.beforeCount).toBe(3);

228-

expect(payload.appliedCount).toBe(1);

229-

expect(payload.pruned).toBe(0);

230-

expect(payload.capped).toBe(2);

231-

const diskBudget = payload.diskBudget as Record<string, unknown>;

232-

expect(diskBudget.removedFiles).toBe(0);

233-

expect(diskBudget.removedEntries).toBe(0);

224+

expect(JSON.parse(logs[0] ?? "{}")).toEqual({

225+

agentId: "main",

226+

storePath: "/resolved/sessions.json",

227+

mode: "enforce",

228+

dryRun: false,

229+

beforeCount: 3,

230+

afterCount: 1,

231+

missing: 0,

232+

dmScopeRetired: 0,

233+

pruned: 0,

234+

capped: 2,

235+

diskBudget: {

236+

totalBytesBefore: 1200,

237+

totalBytesAfter: 800,

238+

removedFiles: 0,

239+

removedEntries: 0,

240+

freedBytes: 400,

241+

maxBytes: 1000,

242+

highWaterBytes: 800,

243+

overBudget: true,

244+

},

245+

wouldMutate: true,

246+

applied: true,

247+

appliedCount: 1,

248+

});

234249

expect(mocks.runSessionsCleanup).toHaveBeenCalledOnce();

235250

const cleanupCall = mocks.runSessionsCleanup.mock.calls[0]?.[0];

236251

expect(cleanupCall?.cfg).toEqual({ session: { store: "/cfg/sessions.json" } });

@@ -274,7 +289,23 @@ describe("sessionsCleanupCommand", () => {

274289

expect(gatewayCall?.params.enforce).toBe(true);

275290

expect(gatewayCall?.requiredMethods).toEqual(["sessions.cleanup"]);

276291

expect(mocks.updateSessionStore).not.toHaveBeenCalled();

277-

expect(JSON.parse(logs[0] ?? "{}").appliedCount).toBe(1);

292+

expect(logs).toHaveLength(1);

293+

expect(JSON.parse(logs[0] ?? "{}")).toEqual({

294+

agentId: "main",

295+

storePath: "/resolved/sessions.json",

296+

mode: "enforce",

297+

dryRun: false,

298+

beforeCount: 3,

299+

afterCount: 1,

300+

missing: 0,

301+

dmScopeRetired: 0,

302+

pruned: 2,

303+

capped: 0,

304+

diskBudget: null,

305+

wouldMutate: true,

306+

applied: true,

307+

appliedCount: 1,

308+

});

278309

});

279310280311

it("returns dry-run JSON without mutating the store", async () => {

@@ -326,14 +357,31 @@ describe("sessionsCleanupCommand", () => {

326357

);

327358328359

expect(logs).toHaveLength(1);

329-

const payload = JSON.parse(logs[0] ?? "{}") as Record<string, unknown>;

330-

expect(payload.dryRun).toBe(true);

331-

expect(payload.applied).toBeUndefined();

360+

expect(JSON.parse(logs[0] ?? "{}")).toEqual({

361+

agentId: "main",

362+

storePath: "/resolved/sessions.json",

363+

mode: "warn",

364+

dryRun: true,

365+

beforeCount: 2,

366+

afterCount: 1,

367+

missing: 0,

368+

dmScopeRetired: 0,

369+

pruned: 1,

370+

capped: 0,

371+

diskBudget: {

372+

totalBytesBefore: 1000,

373+

totalBytesAfter: 700,

374+

removedFiles: 1,

375+

removedEntries: 1,

376+

freedBytes: 300,

377+

maxBytes: 900,

378+

highWaterBytes: 700,

379+

overBudget: true,

380+

},

381+

wouldMutate: true,

382+

});

332383

expect(mocks.runSessionsCleanup).toHaveBeenCalled();

333384

expect(mocks.updateSessionStore).not.toHaveBeenCalled();

334-

const diskBudget = payload.diskBudget as Record<string, unknown>;

335-

expect(diskBudget.removedFiles).toBe(1);

336-

expect(diskBudget.removedEntries).toBe(1);

337385

});

338386339387

it("counts missing transcript entries when --fix-missing is enabled in dry-run", async () => {

@@ -378,10 +426,20 @@ describe("sessionsCleanupCommand", () => {

378426

);

379427380428

expect(logs).toHaveLength(1);

381-

const payload = JSON.parse(logs[0] ?? "{}") as Record<string, unknown>;

382-

expect(payload.beforeCount).toBe(1);

383-

expect(payload.afterCount).toBe(0);

384-

expect(payload.missing).toBe(1);

429+

expect(JSON.parse(logs[0] ?? "{}")).toEqual({

430+

agentId: "main",

431+

storePath: "/resolved/sessions.json",

432+

mode: "warn",

433+

dryRun: true,

434+

beforeCount: 1,

435+

afterCount: 0,

436+

missing: 1,

437+

dmScopeRetired: 0,

438+

pruned: 0,

439+

capped: 0,

440+

diskBudget: null,

441+

wouldMutate: true,

442+

});

385443

});

386444387445

it("renders a dry-run action table with keep/prune actions", async () => {

@@ -512,9 +570,40 @@ describe("sessionsCleanupCommand", () => {

512570

);

513571514572

expect(logs).toHaveLength(1);

515-

const payload = JSON.parse(logs[0] ?? "{}") as Record<string, unknown>;

516-

expect(payload.allAgents).toBe(true);

517-

expect(Array.isArray(payload.stores)).toBe(true);

518-

expect((payload.stores as unknown[]).length).toBe(2);

573+

expect(JSON.parse(logs[0] ?? "{}")).toEqual({

574+

allAgents: true,

575+

mode: "warn",

576+

dryRun: true,

577+

stores: [

578+

{

579+

agentId: "main",

580+

storePath: "/resolved/main-sessions.json",

581+

mode: "warn",

582+

dryRun: true,

583+

beforeCount: 1,

584+

afterCount: 0,

585+

missing: 0,

586+

dmScopeRetired: 0,

587+

pruned: 1,

588+

capped: 0,

589+

diskBudget: null,

590+

wouldMutate: true,

591+

},

592+

{

593+

agentId: "work",

594+

storePath: "/resolved/work-sessions.json",

595+

mode: "warn",

596+

dryRun: true,

597+

beforeCount: 1,

598+

afterCount: 0,

599+

missing: 0,

600+

dmScopeRetired: 0,

601+

pruned: 1,

602+

capped: 0,

603+

diskBudget: null,

604+

wouldMutate: true,

605+

},

606+

],

607+

});

519608

});

520609

});