From 2a613d0be81932a1b5fee791ef53e0df4a9abafa Mon Sep 17 00:00:00 2001 From: MOLW <85048713+MatrixAdventurer@users.noreply.github.com> Date: Thu, 22 Oct 2026 00:54:30 +0800 Subject: [PATCH] fix(openclaw): skip unused historical snapshot counts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid historical count backfills during metadata-only automatic discovery. Preserve explicit page requests and verify every automatic page over real HTTP. Related to matrixorigin/memoria#354. 由 LW 授权的 ChatGPT Personal 智能体提交。 --- .../openclaw/__tests__/snapshot-pagination.test.ts | 7 ++++++- plugins/openclaw/openclaw/http-client.ts | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/openclaw/openclaw/__tests__/snapshot-pagination.test.ts b/plugins/openclaw/openclaw/__tests__/snapshot-pagination.test.ts index 97b872af..7008dff5 100644 --- a/plugins/openclaw/openclaw/__tests__/snapshot-pagination.test.ts +++ b/plugins/openclaw/openclaw/__tests__/snapshot-pagination.test.ts @@ -9,6 +9,7 @@ const servers: Server[] = []; async function serveSnapshots(total: number, mode = "normal") { const offsets: number[] = []; + const countResolution: (string | null)[] = []; const snapshots = Array.from({ length: total }, (_, i) => ({ name: `release_${i}`, snapshot_name: `mem_snap_release_${i}`, timestamp: "2026-10-21T00:00:00Z", @@ -27,6 +28,7 @@ async function serveSnapshots(total: number, mode = "normal") { const offset = Number(url.searchParams.get("offset") ?? 0); const limit = Number(url.searchParams.get("limit") ?? 20); offsets.push(offset); + countResolution.push(url.searchParams.get("resolve_memory_counts")); if (mode === "fail-later" && offset > 0) { response.writeHead(503); response.end("unavailable"); @@ -42,7 +44,7 @@ async function serveSnapshots(total: number, mode = "normal") { await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve)); return { apiUrl: `http://127.0.0.1:${(server.address() as AddressInfo).port}`, - offsets, snapshots, + offsets, snapshots, countResolution, }; } @@ -64,6 +66,8 @@ describe("snapshot discovery pagination (real HTTP)", () => { .toEqual(fixture.snapshots.map((s) => s.name)); expect(fixture.offsets).toEqual([0, 20, 40]); expect((await client.stats("u")).snapshotCount).toBe(45); + // Both discovery and stats need metadata, not per-snapshot historical counts. + expect(fixture.countResolution).toEqual(Array(6).fill("false")); } finally { client.close(); } @@ -112,5 +116,6 @@ describe("snapshot discovery pagination (real HTTP)", () => { expect(JSON.stringify(result)).toContain("release_20"); expect(JSON.stringify(result)).not.toContain("release_22"); expect(fixture.offsets).toEqual([20]); + expect(fixture.countResolution).toEqual([null]); }); }); diff --git a/plugins/openclaw/openclaw/http-client.ts b/plugins/openclaw/openclaw/http-client.ts index 18213dd8..1f59274a 100644 --- a/plugins/openclaw/openclaw/http-client.ts +++ b/plugins/openclaw/openclaw/http-client.ts @@ -300,7 +300,8 @@ export class MemoriaHttpTransport { } const snapshots: unknown[] = []; for (let page = 0; page < this.maxListPages; page++) { - const data = await this.get(`/v1/snapshots?limit=${limit}&offset=${offset}`); + // Discovery only uses snapshot metadata, so avoid historical count backfills. + const data = await this.get(`/v1/snapshots?limit=${limit}&offset=${offset}&resolve_memory_counts=false`); const rec = this.asRecord(data); if (!Array.isArray(rec?.snapshots)) { // Preserve older unpaginated response formats on the first request.