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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0b41cb38af
commit
55c0bf52bb
@@ -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,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user