From 55c0bf52bbbf3fd9f9e48ab5f5f7b432d32a79a4 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sat, 26 Sep 2026 00:14:05 +0900 Subject: [PATCH] fix(cache-storage): verify candidate entries before inspect() reports verified (02-05) inspect() read only the marker and set verified to true for every candidate, even one whose entries the browser had evicted. It now runs the same entry check as activation, so the cost grows with the entry count. Co-Authored-By: Claude Opus 5.5 --- .../cache-storage/public-response-cache-adapter.ts | 11 ++++++++++- tests/unit/public-response-cache.test.ts | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/adapters/cache-storage/public-response-cache-adapter.ts b/src/adapters/cache-storage/public-response-cache-adapter.ts index 26fc4450..743ee6c2 100644 --- a/src/adapters/cache-storage/public-response-cache-adapter.ts +++ b/src/adapters/cache-storage/public-response-cache-adapter.ts @@ -866,10 +866,19 @@ export function createPublicResponseCacheAdapter( unreadableOwnedCacheCount += 1; continue; } + // 02-05. The marker only claims staging finished; `verified` means + // every entry is still present and matches, as activation checks. + const candidate = await verifyReleaseCandidate( + cache, + marker.value.assets, + policy, + dependencies.crypto, + undefined, + ); candidates.push( Object.freeze({ releaseRegistryId: marker.value.releaseRegistryId, - verified: true, + verified: candidate.kind === "VERIFIED", entryCount: marker.value.entryCount, }), ); diff --git a/tests/unit/public-response-cache.test.ts b/tests/unit/public-response-cache.test.ts index e0b2c0aa..7204eba6 100644 --- a/tests/unit/public-response-cache.test.ts +++ b/tests/unit/public-response-cache.test.ts @@ -208,12 +208,23 @@ describe("public response Cache Storage adapter", () => { ); expect(payloadIndex).toBeGreaterThanOrEqual(0); cache.responses.splice(payloadIndex, 1); + const candidates = async () => { + const inspection = await adapter.admin.inspect(); + return inspection.ok ? inspection.value.releaseCandidates : null; + }; + // 02-05. inspect() does not report the marker's claim as verified. + expect(await candidates()).toEqual([ + { releaseRegistryId: "evicted-release", verified: false, entryCount: 1 }, + ]); // A marker is a claim, not evidence: restaging must repair. expect(await adapter.admin.stageRelease(manifest)).toMatchObject({ ok: true, }); expect(fetches).toBe(2); + expect(await candidates()).toEqual([ + { releaseRegistryId: "evicted-release", verified: true, entryCount: 1 }, + ]); expect( await adapter.admin.activateRelease( manifest.releaseRegistryId,