From 71cea564fb3707c85be8688fa7df6f3bb001e0b1 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Mon, 23 Nov 2026 07:57:52 -0500 Subject: [PATCH] fix(v8): preserve verified code cache results and require exact payload reads (#14067) --- .../v8CodeCache/V8CodeCacheService.test.ts | 112 ++-- .../v8CodeCache/V8CodeCacheService.ts | 11 +- src/domain/analysisErrorBase.ts | 2 + src/v8/V8CodeCacheParser.test.ts | 498 +++++++----------- src/v8/V8CodeCacheParser.ts | 37 +- src/v8/V8CodeCacheProvider.ts | 19 +- tests/acceptance/v8CodeCacheCli.test.ts | 97 ++-- .../filesystem/v8CodeCacheArtifact.test.ts | 199 +++++++ tests/support/providerLifecycleCoverage.ts | 4 +- 9 files changed, 483 insertions(+), 496 deletions(-) create mode 100644 tests/boundary/filesystem/v8CodeCacheArtifact.test.ts diff --git a/src/application/v8CodeCache/V8CodeCacheService.test.ts b/src/application/v8CodeCache/V8CodeCacheService.test.ts index 7b347fe0234..d51b8b8a504 100644 --- a/src/application/v8CodeCache/V8CodeCacheService.test.ts +++ b/src/application/v8CodeCache/V8CodeCacheService.test.ts @@ -1,91 +1,45 @@ import { createHash } from "node:crypto"; import { expect, it } from "vitest"; - -import { - AnalysisCancelledError, - AnalysisOutputError, -} from "../../domain/analysisErrorCore.js"; -import { parseEvidence } from "../../domain/evidence.js"; +import { AnalysisOutputError } from "../../domain/analysisErrorCore.js"; import { ok } from "../../domain/result.js"; -import { - V8_CODE_CACHE_HEADER_BYTES, - V8_CODE_CACHE_MAGIC_HIGH, - type V8CodeCache, -} from "../../domain/v8/v8CodeCache.js"; -import { parseV8CodeCache } from "../../v8/V8CodeCacheParser.js"; +import { v8CodeCacheFixture } from "../../v8/V8CodeCache.fixture.js"; +import { parseV8CodeCacheFromHandle } from "../../v8/V8CodeCacheParser.js"; import { V8CodeCacheService } from "./V8CodeCacheService.js"; -const reportFor = (payloadBytes: number): V8CodeCache => { - const bytes = Buffer.alloc(V8_CODE_CACHE_HEADER_BYTES + payloadBytes, 0x61); - bytes.fill(0, 0, V8_CODE_CACHE_HEADER_BYTES); - bytes.writeUInt32LE(V8_CODE_CACHE_MAGIC_HIGH * 0x10000, 0); - bytes.writeUInt32LE(payloadBytes, 20); - return parseV8CodeCache( - bytes, +it("admits complete V8 coverage only when the scanned bytes match the payload", async () => { + const bytes = v8CodeCacheFixture(); + const path = "/artifacts/module.jsc"; + const report = await parseV8CodeCacheFromHandle( { - path: "/artifacts/authored.jsc", - sha256: createHash("sha256").update(bytes).digest("hex"), + size: bytes.length, + prefix: bytes, + readRange: async () => { + throw new Error("The admitted prefix already contains the test cache"); + }, + }, + { + path, bytes: bytes.length, + sha256: createHash("sha256").update(bytes).digest("hex"), }, - { min_string_bytes: 4, max_strings: 8 }, + { min_string_bytes: 4, max_strings: 4096 }, ); -}; - -const inspect = (report: V8CodeCache) => - new V8CodeCacheService({ + let scanned_bytes = report.payload.bytes; + const service = new V8CodeCacheService({ identity: { id: "cache-fixture", name: "Cache fixture", version: "1" }, close: async () => {}, - inspect: async () => ok(report), - }).inspect({ path: report.artifact.path }); - -it("retains a completed V8 code cache observation when the caller cancels as the provider completes", async () => { - const report = reportFor(8); - const controller = new AbortController(); - const reason = { request: "late V8 code cache cancellation" }; - const result = await new V8CodeCacheService({ - identity: { id: "cache-fixture", name: "Cache fixture", version: "1" }, - close: async () => {}, - inspect: async () => { - controller.abort(reason); - return ok(report); - }, - }).inspect({ path: report.artifact.path }, { signal: controller.signal }); - if (result.ok) throw new Error("Expected late cancellation"); - expect(result.error).toBeInstanceOf(AnalysisCancelledError); - expect(result.error.cause).toBe(reason); - const evidence = parseEvidence(result.error.partialObservation); - expect(evidence.operation).toBe("inspect_v8_code_cache"); - expect(evidence.normalized_result).toEqual(report); + inspect: async () => + ok({ + ...report, + coverage: { ...report.coverage, scanned_bytes }, + }), + }); + expect(await service.inspect({ path })).toMatchObject({ ok: true }); + for (const count of [0, report.payload.bytes + 1]) { + scanned_bytes = count; + const result = await service.inspect({ path }); + if (result.ok) + throw new Error(`Accepted complete coverage with ${String(count)} bytes`); + expect(result.error).toBeInstanceOf(AnalysisOutputError); + } }); - -it.each([0, 9])( - "rejects complete coverage claiming %s scanned bytes for an eight-byte payload", - async (scanned_bytes) => { - const report = reportFor(8); - const result = await inspect({ - ...report, - coverage: { ...report.coverage, scanned_bytes }, - }); - expect(result.ok).toBe(false); - if (!result.ok) expect(result.error).toBeInstanceOf(AnalysisOutputError); - }, -); - -it.each([8, 5000])( - "retains complete scan facts for a %s-byte payload and its bounded string prefix", - async (payloadBytes) => { - const report = reportFor(payloadBytes); - const result = await inspect(report); - if (!result.ok) throw result.error; - expect(parseEvidence(result.value).normalized_result).toMatchObject({ - coverage: { status: "complete", scanned_bytes: payloadBytes, strings: 1 }, - embedded_strings: [ - { - bytes: payloadBytes, - retained_bytes: Math.min(payloadBytes, 4096), - truncated: payloadBytes > 4096, - }, - ], - }); - }, -); diff --git a/src/application/v8CodeCache/V8CodeCacheService.ts b/src/application/v8CodeCache/V8CodeCacheService.ts index d8c3b4a11d5..6524c9b5494 100644 --- a/src/application/v8CodeCache/V8CodeCacheService.ts +++ b/src/application/v8CodeCache/V8CodeCacheService.ts @@ -30,6 +30,7 @@ export class V8CodeCacheService { inputSchema: inspectV8CodeCacheInputSchema, outputSchema: v8CodeCacheSchema, provider: this.provider, + retainCompletedReport: true, invalidOutputMessage: "V8 code cache provider returned malformed output or changed artifact identity.", toParameters: (input) => input, @@ -77,15 +78,7 @@ const validReport = ( ): boolean => { if (report.artifact.bytes > input.max_file_bytes) return false; if (report.embedded_strings.length > input.max_strings) return false; - if ( - report.payload.offset + report.payload.bytes !== report.artifact.bytes || - report.payload.offset !== report.header.header_bytes - ) - return false; return report.embedded_strings.every( - (observation) => - observation.bytes >= input.min_string_bytes && - observation.offset >= report.payload.offset && - observation.offset + observation.bytes <= report.artifact.bytes, + (observation) => observation.bytes >= input.min_string_bytes, ); }; diff --git a/src/domain/analysisErrorBase.ts b/src/domain/analysisErrorBase.ts index 1ff8f4d3bd5..ddee72c32fe 100644 --- a/src/domain/analysisErrorBase.ts +++ b/src/domain/analysisErrorBase.ts @@ -6,6 +6,7 @@ import type { ElfNotes } from "./native/elfNotes.js"; import type { ElfUnwindRanges } from "./native/elfUnwindRanges.js"; import type { KernelBuildConfig } from "./native/kernelBuildConfig.js"; import type { KernelModule } from "./native/kernelModule.js"; +import type { V8CodeCache } from "./v8/v8CodeCache.js"; import type { InterfaceBuilderAnalysis } from "./apple/interfaceBuilderGraph.js"; import type { PartialTaskMeasurement } from "./desktop/taskDifficulty.js"; import type { AppleIpsPartialObservation } from "./native/appleIps.js"; @@ -705,6 +706,7 @@ export type AnalysisPartialObservation = | ElfUnwindRanges | KernelBuildConfig | KernelModule + | V8CodeCache | InterfaceBuilderAnalysis | PartialTaskMeasurement | { diff --git a/src/v8/V8CodeCacheParser.test.ts b/src/v8/V8CodeCacheParser.test.ts index 07cc8a24d43..3497fede326 100644 --- a/src/v8/V8CodeCacheParser.test.ts +++ b/src/v8/V8CodeCacheParser.test.ts @@ -6,14 +6,10 @@ import { v8CodeCacheSchema, V8_CODE_CACHE_HEADER_BYTES, V8_CODE_CACHE_LEGACY_HEADER_BYTES, - V8_CODE_CACHE_MAGIC_HIGH, V8_CODE_CACHE_NARROW_HEADER_BYTES, type V8CodeCache, } from "../domain/v8/v8CodeCache.js"; -import { - parseV8CodeCache, - parseV8CodeCacheFromHandle, -} from "./V8CodeCacheParser.js"; +import { parseV8CodeCacheFromHandle } from "./V8CodeCacheParser.js"; import { v8CodeCacheFixture, v8FunctionCodeCacheFixture, @@ -32,71 +28,59 @@ const identity = (bytes: Buffer) => ({ bytes: bytes.length, }); -const parse = (bytes: Buffer): V8CodeCache => { - const report = parseV8CodeCache(bytes, identity(bytes), defaults); - const validated = v8CodeCacheSchema.safeParse(report); - if (!validated.success) throw new Error(validated.error.message); - return report; -}; - -const real = v8CodeCacheFixture(); - -it("reports the observed header of a real V8 code cache", () => { - const report = parse(real); - expect(report.header.header_bytes).toBe(32); - expect(report.header.magic_build_stable).toBe(0xc0de); - expect(report.header.magic).toBe(real.readUInt32LE(0)); - // The payload-length word reaches exactly the end of the container. - expect(report.payload.offset).toBe(32); - expect(report.payload.bytes).toBe(real.length - 32); - expect(report.payload.bytes).toBe(real.readUInt32LE(20)); - expect(report.payload.offset + report.payload.bytes).toBe( - report.artifact.bytes, +const parse = async (bytes: Buffer): Promise => + v8CodeCacheSchema.parse( + await parseV8CodeCacheFromHandle( + { + size: bytes.length, + prefix: bytes, + readRange: async () => { + throw new Error( + "The admitted prefix already contains the test cache", + ); + }, + }, + identity(bytes), + defaults, + ), ); - expect(report.coverage.status).toBe("complete"); -}); -it("names every header word with its role and confidence", () => { - const report = parse(real); - expect(report.header.fields).toHaveLength(8); - expect(report.header.fields.map((field) => field.offset)).toEqual([ - 0, 4, 8, 12, 16, 20, 24, 28, - ]); - expect(report.header.fields.map((field) => field.role)).toEqual([ - "magic", - "version_hash", - "source_length", - "flag_hash", - "build_constant", - "payload_length", - "reserved", - "reserved", - ]); - // Every reported value is the byte-level truth, independent of the inferred role. - report.header.fields.forEach((field) => { - expect(field.value).toBe(real.readUInt32LE(field.offset)); +const source = 'const label = "🦎"; label;'; +const real = v8CodeCacheFixture(source); + +it("reports real V8 words, their confidence and the UTF-16 source length", async () => { + const report = await parse(real); + expect(report.header).toMatchObject({ + magic: real.readUInt32LE(0), + magic_build_stable: 0xc0de, + header_bytes: 32, + source_length: source.length, + producer: "unknown", }); - // Confidence is stated per field rather than implied. - expect( - report.header.fields.filter((field) => field.status === "unconfirmed"), - ).toHaveLength(2); - expect( - report.header.fields - .filter((field) => field.status === "confirmed") - .map((f) => f.role), - ).toEqual(["magic", "source_length", "payload_length"]); -}); - -it("reports the source length the producer recorded", () => { - const source = "function longer(a, b) { return a * b + 1; } longer(3, 4);"; - const cache = v8CodeCacheFixture(source); - const report = parse(cache); - expect(report.header.source_length).toBe(source.length); - // An unflagged word is `unknown`, not `script`: a `vm.compileFunction` cache from a - // build that does not mark bit 29 reads the same as a script, so the container alone - // cannot separate them. The observed word stays available in `header.fields`. - expect(report.header.producer).toBe("unknown"); - expect(report.header.fields[2]?.value).toBe(cache.readUInt32LE(8)); + const headerWords = [ + ["magic", "confirmed"], + ["version_hash", "inferred"], + ["source_length", "confirmed"], + ["flag_hash", "inferred"], + ["build_constant", "inferred"], + ["payload_length", "confirmed"], + ["reserved", "unconfirmed"], + ["reserved", "unconfirmed"], + ]; + expect(report.header.fields).toEqual( + headerWords.map(([role, status], index) => { + const offset = index * 4; + return { offset, value: real.readUInt32LE(offset), role, status }; + }), + ); + expect(report.payload).toMatchObject({ + offset: 32, + bytes: real.readUInt32LE(20), + }); + const limitations = report.limitations.join(" "); + expect(limitations).toContain("byte-pattern observations"); + expect(limitations).toContain("not source"); + expect(limitations).toContain("View8"); }); it.each([ @@ -106,23 +90,23 @@ it.each([ [0x60000000, "module"], ] as const)( "interprets producer flags %i without changing source length", - (flags, producer) => { + async (flags, producer) => { // Older V8 uses bit 31 for modules. A synthetic word with both bits set // checks that the module marker wins over the function marker. const sourceLength = 19; const cache = withHeaderWord(real, 2, flags | sourceLength); - expect(parse(cache).header).toMatchObject({ + expect((await parse(cache)).header).toMatchObject({ producer, source_length: sourceLength, }); }, ); -it("separates the compileFunction producer bit from the source length", () => { +it("separates the compileFunction producer bit from the source length", async () => { const source = "return 7;"; const cache = v8FunctionCodeCacheFixture(source); const word = cache.readUInt32LE(8); - const report = parse(cache); + const report = await parse(cache); // Whether `vm.compileFunction` sets bit 29 in the source-length word is a V8 build // detail, not a contract: Node 24.22.1 writes `0x20000009` for this source while Node // 22.23.4 does not set the bit at all. Assert against the word the runtime produced @@ -136,37 +120,9 @@ it("separates the compileFunction producer bit from the source length", () => { expect(report.header.source_length).toBe(source.length); }); -it("reports an embedded run at its absolute file offset", () => { - const marker = "UNIQUE_CONFIG_KEY_9f3a"; - // An object-literal value survives in the serialized payload as plain bytes. - const cache = v8CodeCacheFixture( - `var settings = { key: "${marker}" }; settings.key;`, - ); - const report = parse(cache); - const observation = report.embedded_strings.find((entry) => - entry.text.includes(marker), - ); - expect(observation).toBeDefined(); - // The reported range points at the marker inside the selected file. - expect(realSlice(cache, observation!.offset, observation!.bytes)).toContain( - marker, - ); - expect(observation!.offset).toBeGreaterThanOrEqual(32); - expect(report.coverage.strings).toBe(report.embedded_strings.length); -}); - -it("labels observations as byte patterns and never claims recovered source", () => { - const report = parse(real); - expect(report.limitations.join(" ")).toContain("byte-pattern observations"); - expect(report.limitations.join(" ")).toContain("not source"); - expect(report.limitations.join(" ")).toContain("View8"); - // No field can be mistaken for recovered source text. - expect(Object.keys(report)).not.toContain("source"); -}); - -it("fails closed on a foreign magic", () => { +it("fails closed on a foreign magic", async () => { const foreign = withHeaderWord(real, 0, 0xdeadbeef); - expect(() => parse(foreign)).toThrow( + await expect(parse(foreign)).rejects.toThrow( expect.objectContaining({ failure: expect.objectContaining({ kind: "unsupported", @@ -180,13 +136,13 @@ it("fails closed on a foreign magic", () => { it.each([ V8_CODE_CACHE_LEGACY_HEADER_BYTES - 1, V8_CODE_CACHE_NARROW_HEADER_BYTES - 1, -])("fails closed on a header truncated to %i bytes", (length) => { - expect(() => parse(real.subarray(0, length))).toThrow( +])("fails closed on a header truncated to %i bytes", async (length) => { + await expect(parse(real.subarray(0, length))).rejects.toThrow( expect.objectContaining({ kind: "malformed" }), ); }); -it("treats the observed header as version-dependent rather than a fixed ABI", () => { +it("treats the observed header as version-dependent rather than a fixed ABI", async () => { // A producer with a different build constant and version hash is still admitted: only // the magic high half and the payload-length relation gate admission. const otherBuild = withHeaderWord( @@ -194,88 +150,29 @@ it("treats the observed header as version-dependent rather than a fixed ABI", () 1, 0x11111111, ); - const report = parse(otherBuild); + const report = await parse(otherBuild); + expect(report.header.fields[1]?.value).toBe(0x11111111); expect(report.header.fields[4]?.value).toBe(0x4be86e94); expect(report.payload.bytes).toBe(real.readUInt32LE(20)); }); -it("enforces the caller-selected observation budget", () => { - const crowded = v8CodeCacheFixture( - `var a = { a: "AAAAAAAAAAAA", b: "BBBBBBBBBBBB", c: "CCCCCCCCCCCC" }; a.a;`, - ); - expect(() => - parseV8CodeCache(crowded, identity(crowded), { - ...defaults, - max_strings: 1, - }), - ).toThrow( - expect.objectContaining({ - name: "ParseFailureError", - failure: expect.objectContaining({ - kind: "limit", - format: "v8-code-cache", - limit: { name: "max_strings", maximum: 1 }, - }), - message: expect.stringContaining("max_strings"), - }), - ); -}); - -it("raises min_string_bytes and reports only runs that long", () => { - const bytes = v8CodeCacheFixture( - `var a = { k: "SHORT", long: "${"L".repeat(80)}" }; a.k;`, - ); - const few = parseV8CodeCache(bytes, identity(bytes), { - ...defaults, - min_string_bytes: 64, - }); - expect(few.embedded_strings.length).toBeGreaterThan(0); - few.embedded_strings.forEach((entry) => { - expect(entry.bytes).toBeGreaterThanOrEqual(64); - }); -}); - -const realSlice = (bytes: Buffer, offset: number, length: number): string => - bytes.subarray(offset, offset + length).toString("latin1"); - -it("inspects a synthetic narrow layout derived from a 64-bit cache", () => { - // Removing the alignment word preserves the retained payload bytes. - const narrow = withSyntheticNarrowHeader(real); - const report = parse(narrow); - - expect(narrow.readUInt32LE(20)).toBe( - narrow.length - V8_CODE_CACHE_NARROW_HEADER_BYTES, - ); - expect(report.header.header_bytes).toBe(V8_CODE_CACHE_NARROW_HEADER_BYTES); - expect(report.payload.offset).toBe(V8_CODE_CACHE_NARROW_HEADER_BYTES); - // Nothing but the padding is removed, so the payload is identical. - expect(report.payload.sha256).toBe(parse(real).payload.sha256); - // The word table covers exactly the header this container carries. - expect(report.header.fields).toHaveLength(7); - expect(report.header.fields.map((entry) => entry.offset)).toEqual([ - 0, 4, 8, 12, 16, 20, 24, +it("fails closed when the declared payload leaves no admitted header size", async () => { + const oddHeader = Buffer.concat([ + real.subarray(0, V8_CODE_CACHE_NARROW_HEADER_BYTES + 2), + real.subarray(V8_CODE_CACHE_HEADER_BYTES), ]); + await expect(parse(oddHeader)).rejects.toThrow( + expect.objectContaining({ kind: "malformed" }), + ); }); -it("fails closed when the declared payload leaves no admitted header size", () => { - // Padding that is neither 28 nor 32 bytes is not a container this reader admits. - expect(() => - parse( - Buffer.concat([ - real.subarray(0, V8_CODE_CACHE_NARROW_HEADER_BYTES + 2), - real.subarray(V8_CODE_CACHE_HEADER_BYTES), - ]), - ), - ).toThrow(expect.objectContaining({ kind: "malformed" })); -}); - -it("refuses a wide container that is only four bytes short", () => { +it("refuses a wide container that is only four bytes short", async () => { // Truncating a 32-byte-header cache by four bytes makes `bytes.length - declaredPayload` // equal 28. The padding then occupies the same position as a zero first // payload word in a narrow container, so the reader refuses the ambiguity. const short = real.subarray(0, real.length - 4); expect(short.readUInt32LE(28)).toBe(0); - expect(() => parse(short)).toThrow( + await expect(parse(short)).rejects.toThrow( expect.objectContaining({ kind: "malformed", message: expect.stringContaining("ambiguous"), @@ -284,63 +181,44 @@ it("refuses a wide container that is only four bytes short", () => { // A synthetic narrow fixture has payload at the same byte offset. const narrow = withSyntheticNarrowHeader(real); expect(narrow.readUInt32LE(V8_CODE_CACHE_NARROW_HEADER_BYTES)).not.toBe(0); - expect(parse(narrow).header.header_bytes).toBe( + expect((await parse(narrow)).header.header_bytes).toBe( V8_CODE_CACHE_NARROW_HEADER_BYTES, ); }); -it("inspects a synthetic six-word layout derived from a 64-bit cache", () => { - // V8 8.8 through 11.7 write no build-constant word, so the payload length is - // the fifth word and the 24-byte header needs no alignment padding. - const legacy = withSyntheticLegacyHeader(real); - const report = parse(legacy); - const wide = parse(real); - - expect(legacy.readUInt32LE(16)).toBe( - legacy.length - V8_CODE_CACHE_LEGACY_HEADER_BYTES, - ); - expect(report.header.header_bytes).toBe(V8_CODE_CACHE_LEGACY_HEADER_BYTES); - expect(report.payload.offset).toBe(V8_CODE_CACHE_LEGACY_HEADER_BYTES); - // Only header words are removed, so the payload is identical. - expect(report.payload.sha256).toBe(wide.payload.sha256); - expect(report.header.source_length).toBe(wide.header.source_length); - // No producer of those releases was measured, so only the two facts that - // admission checks on the container itself are reported as confirmed. - expect(report.header.fields).toMatchObject([ - { offset: 0, role: "magic", status: "confirmed" }, - { offset: 4, role: "version_hash", status: "inferred" }, - { offset: 8, role: "source_length", status: "inferred" }, - { offset: 12, role: "flag_hash", status: "inferred" }, - { offset: 16, role: "payload_length", status: "confirmed" }, - { offset: 20, role: "reserved", status: "unconfirmed" }, - ]); - report.header.fields.forEach((field) => { - expect(field.value).toBe(legacy.readUInt32LE(field.offset)); - }); - // The report itself states that the layout was not measured. - expect(report.limitations).toHaveLength(wide.limitations.length + 1); -}); - -it("reads the bit 31 module flag of a six-word container", () => { - const sourceLength = 23; - const legacy = withSyntheticLegacyHeader( - withHeaderWord(real, 2, 0x80000000 | sourceLength), - ); - expect(parse(legacy).header).toMatchObject({ +it("reports older module flags and confidence in a synthetic six-word header", async () => { + const legacy = withSyntheticLegacyHeader(withHeaderWord(real, 2, 0x80000017)); + const report = await parse(legacy); + expect(report.header).toMatchObject({ header_bytes: V8_CODE_CACHE_LEGACY_HEADER_BYTES, + source_length: 23, producer: "module", - source_length: sourceLength, + fields: [ + { offset: 0, role: "magic", status: "confirmed" }, + { offset: 4, role: "version_hash", status: "inferred" }, + { offset: 8, role: "source_length", status: "inferred" }, + { offset: 12, role: "flag_hash", status: "inferred" }, + { offset: 16, role: "payload_length", status: "confirmed" }, + { offset: 20, role: "reserved", status: "unconfirmed" }, + ], }); + for (const field of report.header.fields) + expect(field.value).toBe(legacy.readUInt32LE(field.offset)); + expect(report.limitations).toEqual( + expect.arrayContaining([ + expect.stringContaining("not measured against one of their producers"), + ]), + ); }); -it("refuses a six-word container that lost its last payload word", () => { +it("refuses a six-word container that lost its last payload word", async () => { const legacy = withSyntheticLegacyHeader(real); - expect(() => parse(legacy.subarray(0, legacy.length - 4))).toThrow( + await expect(parse(legacy.subarray(0, legacy.length - 4))).rejects.toThrow( expect.objectContaining({ kind: "malformed" }), ); }); -it("refuses a container whose payload length fits both layouts", () => { +it("refuses a container whose payload length fits both layouts", async () => { // The six-word layout does not constrain the word after its payload length, // so that word can also reach the end of the file from a 28-byte header. // Nothing in the header separates the two readings. @@ -350,7 +228,7 @@ it("refuses a container whose payload length fits both layouts", () => { 5, legacy.length - V8_CODE_CACHE_NARROW_HEADER_BYTES, ); - expect(() => parse(both)).toThrow( + await expect(parse(both)).rejects.toThrow( expect.objectContaining({ kind: "malformed", message: expect.stringContaining("ambiguous"), @@ -358,121 +236,97 @@ it("refuses a container whose payload length fits both layouts", () => { ); }); -it("rejects a reported word table that does not cover the header it declares", () => { - // The parser derives both from one offset, so this pair cannot disagree on a - // parsed container; the schema is what a stored or projected report also goes - // through, and there the two are independent fields. Without these cases the - // rule could be deleted and every parser test would still pass. - const reported = (fieldCount: number, headerBytes: number) => ({ - artifact: { - path: "/artifacts/module.jsc", - sha256: "a".repeat(64), - bytes: 4096, - }, - header: { - magic: 0xf00d, - magic_build_stable: V8_CODE_CACHE_MAGIC_HIGH, - fields: Array.from({ length: fieldCount }, (_, index) => ({ - offset: index * 4, - value: index, - role: "reserved", - status: "unconfirmed" as const, - })), - header_bytes: headerBytes, - source_length: 10, - producer: "script" as const, - }, - payload: { - offset: headerBytes, - bytes: 4096 - headerBytes, - sha256: "b".repeat(64), - trailing_bytes: 0, - }, - embedded_strings: [], - coverage: { - status: "complete" as const, - scanned_bytes: 4096 - headerBytes, - strings: 0, - }, - limitations: ["measured on one producer"], - }); - - // Six words is 24 bytes, seven is 28 and eight is 32, so each header size has - // exactly one word count that covers it. - const cases = [ - { fields: 6, bytes: V8_CODE_CACHE_NARROW_HEADER_BYTES, accepted: false }, - { fields: 7, bytes: V8_CODE_CACHE_LEGACY_HEADER_BYTES, accepted: false }, - { fields: 7, bytes: V8_CODE_CACHE_HEADER_BYTES, accepted: false }, - { fields: 8, bytes: V8_CODE_CACHE_NARROW_HEADER_BYTES, accepted: false }, - { fields: 6, bytes: V8_CODE_CACHE_LEGACY_HEADER_BYTES, accepted: true }, - { fields: 7, bytes: V8_CODE_CACHE_NARROW_HEADER_BYTES, accepted: true }, - { fields: 8, bytes: V8_CODE_CACHE_HEADER_BYTES, accepted: true }, - ]; - for (const { fields, bytes, accepted } of cases) { - const label = `${String(fields)} words / ${String(bytes)} bytes`; - const parsed = v8CodeCacheSchema.safeParse(reported(fields, bytes)); - expect(parsed.success, label).toBe(accepted); - expect( - parsed.error?.issues.some( - (issue) => issue.path.join(".") === "header.fields", - ) ?? false, - label, - ).toBe(!accepted); - } -}); - -it("rejects retained header and payload coordinates that disagree", () => { - const report = parse(real); - const disordered = { - ...report, - header: { - ...report.header, - fields: report.header.fields.map((field, index) => - index === 0 ? { ...field, offset: 4 } : field, - ), - }, +it("rejects contradictory retained word tables and payload coordinates", async () => { + const report = await parse(withSyntheticNarrowHeader(real)); + const fields = report.header.fields; + const short = { ...report.header, fields: fields.slice(0, -1) }; + const long = { + ...report.header, + fields: [...fields, { ...fields.at(-1)!, offset: 28 }], }; + const duplicateFirstOffset = { ...fields[0]!, offset: 4 }; + const disordered = { + ...report.header, + fields: [duplicateFirstOffset, ...fields.slice(1)], + }; + for (const header of [short, long, disordered]) { + expect( + v8CodeCacheSchema.safeParse({ ...report, header }).error?.issues, + ).toContainEqual(expect.objectContaining({ path: ["header", "fields"] })); + } const shiftedPayload = { ...report, artifact: { ...report.artifact, bytes: report.artifact.bytes + 4 }, payload: { ...report.payload, offset: report.payload.offset + 4 }, }; expect( - v8CodeCacheSchema.safeParse(disordered).error?.issues ?? [], - ).toContainEqual(expect.objectContaining({ path: ["header", "fields"] })); - expect( - v8CodeCacheSchema.safeParse(shiftedPayload).error?.issues ?? [], + v8CodeCacheSchema.safeParse(shiftedPayload).error?.issues, ).toContainEqual(expect.objectContaining({ path: ["payload", "offset"] })); }); -it("streams multi-chunk payloads identically to in-memory parsing across boundaries", async () => { - const payloadBytes = 65_536 + 1024 * 1024 + 4096; - const bytes = Buffer.alloc(V8_CODE_CACHE_HEADER_BYTES + payloadBytes); - real.copy(bytes, 0, 0, V8_CODE_CACHE_HEADER_BYTES); - bytes.writeUInt32LE(payloadBytes, 20); - // Write printable runs straddling both the 64 KiB prefix boundary and the 1 MiB chunk boundary. - Buffer.from("prefix_boundary_crossing_string").copy(bytes, 65_520); - Buffer.from("a".repeat(MAX_INSPECT_V8_CODE_CACHE_STRING_BYTES + 64)).copy( - bytes, - 65_536 + 1024 * 1024 - 100, - ); +it("observes exact printable runs across positional read boundaries and at EOF", async () => { + const prefixEnd = 65_536; + const chunkEnd = prefixEnd + 1024 * 1024; + const bytes = Buffer.alloc(chunkEnd + 8192); + real.copy(bytes, 0, 0, 32); + bytes.writeUInt32LE(bytes.length - 32, 20); - const id = identity(bytes); - const expected = parseV8CodeCache(bytes, id, defaults); - const streamed = await parseV8CodeCacheFromHandle( + const longLength = MAX_INSPECT_V8_CODE_CACHE_STRING_BYTES + 64; + bytes.write("prefix boundary", prefixEnd - 8, "ascii"); + bytes.write("ignored", prefixEnd + 25, "ascii"); + bytes.fill(0x61, chunkEnd - 100, chunkEnd - 100 + longLength); + bytes.write("at the end", bytes.length - 10, "ascii"); + const reads: [number, number][] = []; + const report = v8CodeCacheSchema.parse( + await parseV8CodeCacheFromHandle( + { + size: bytes.length, + prefix: bytes.subarray(0, prefixEnd), + readRange: async (offset, length) => { + reads.push([offset, length]); + return bytes.subarray(offset, offset + length); + }, + }, + identity(bytes), + { ...defaults, min_string_bytes: 8 }, + ), + ); + expect(reads).toEqual([ + [prefixEnd, chunkEnd - prefixEnd], + [chunkEnd, 8192], + ]); + expect(report.payload).toEqual({ + offset: 32, + bytes: bytes.length - 32, + sha256: createHash("sha256").update(bytes.subarray(32)).digest("hex"), + trailing_bytes: 0, + }); + expect(report.coverage).toEqual({ + status: "complete", + scanned_bytes: bytes.length - 32, + strings: 3, + }); + expect(report.embedded_strings).toEqual([ { - size: bytes.length, - prefix: bytes.subarray(0, 65_536), - readRange: async (offset, length) => - bytes.subarray(offset, offset + length), + offset: prefixEnd - 8, + bytes: 15, + retained_bytes: 15, + text: "prefix boundary", + truncated: false, }, - id, - defaults, - ); - expect(streamed).toEqual(expected); - expect(streamed.embedded_strings).toHaveLength(2); - expect(streamed.embedded_strings[0]?.text).toBe( - "prefix_boundary_crossing_string", - ); - expect(streamed.embedded_strings[1]?.truncated).toBe(true); + { + offset: chunkEnd - 100, + bytes: 4160, + retained_bytes: 4096, + text: "a".repeat(4096), + truncated: true, + }, + { + offset: bytes.length - 10, + bytes: 10, + retained_bytes: 10, + text: "at the end", + truncated: false, + }, + ]); }); diff --git a/src/v8/V8CodeCacheParser.ts b/src/v8/V8CodeCacheParser.ts index 75ae3f2ada4..f859f32f2d9 100644 --- a/src/v8/V8CodeCacheParser.ts +++ b/src/v8/V8CodeCacheParser.ts @@ -15,6 +15,7 @@ import { import type { V8CodeCacheInputBudget } from "../domain/v8/v8CodeCacheBudget.js"; import { V8_CODE_CACHE_FORMAT } from "./V8CodeCache.errors.js"; import { BinaryReader } from "../domain/binaryContainer.js"; +import { ArtifactReaderFailure } from "../resources/index.js"; import { decodeLimit, malformedInput, @@ -302,25 +303,19 @@ const buildV8CodeCacheReport = ( : LIMITATIONS, }); -/** - * Read one V8 code cache container without executing it. - * - * Admission is deliberately narrow: a header layout this reader pins, the V8 code cache - * magic high half, and payload length reaching exactly the end of the file. Everything - * else is reported as an observation so a producer this reader has never seen still - * yields its facts instead of a false parse. - */ -export const parseV8CodeCache = ( - bytes: Buffer, - artifact: { path: string; sha256: string; bytes: number }, - input: V8CodeCacheInputBudget, -): V8CodeCache => { - if (bytes.length !== artifact.bytes) - malformed("Selected artifact length disagrees with the retained bytes."); - const parsed = parseV8CodeCacheHeader(bytes, bytes.length); - const scanner = new V8CodeCachePayloadScanner(parsed.payloadOffset, input); - scanner.update(bytes.subarray(parsed.payloadOffset)); - return buildV8CodeCacheReport(parsed, artifact, scanner.finish()); +const readAdmittedRange = async ( + source: V8CodeCacheByteSource, + offset: number, + length: number, +): Promise => { + const bytes = await source.readRange(offset, length); + if (bytes.length !== length) + throw new ArtifactReaderFailure( + "integrity", + `V8 code cache read at offset ${String(offset)} ended before its ${String(length)} admitted bytes.`, + { integrityCheck: "read-coverage" }, + ); + return bytes; }; /** Stream one V8 code cache container over a bounded file handle in fixed chunks. */ @@ -335,7 +330,7 @@ export const parseV8CodeCacheFromHandle = async ( const headerBytes = source.prefix.length >= headerNeeded ? source.prefix - : await source.readRange(0, headerNeeded); + : await readAdmittedRange(source, 0, headerNeeded); const parsed = parseV8CodeCacheHeader(headerBytes, source.size); const scanner = new V8CodeCachePayloadScanner(parsed.payloadOffset, input); let cursor = parsed.payloadOffset; @@ -345,7 +340,7 @@ export const parseV8CodeCacheFromHandle = async ( } while (cursor < source.size) { const length = Math.min(STREAM_CHUNK_BYTES, source.size - cursor); - scanner.update(await source.readRange(cursor, length)); + scanner.update(await readAdmittedRange(source, cursor, length)); cursor += length; } return buildV8CodeCacheReport(parsed, artifact, scanner.finish()); diff --git a/src/v8/V8CodeCacheProvider.ts b/src/v8/V8CodeCacheProvider.ts index 46b1e1e56bd..6dabdfce8ea 100644 --- a/src/v8/V8CodeCacheProvider.ts +++ b/src/v8/V8CodeCacheProvider.ts @@ -18,6 +18,7 @@ import { MAX_INSPECT_V8_CODE_CACHE_MIN_STRING_BYTES, MAX_INSPECT_V8_CODE_CACHE_STRINGS, type InspectV8CodeCacheInput, + type V8CodeCache, } from "../domain/v8/v8CodeCache.js"; import { err, ok } from "../domain/result.js"; import { classifyProviderFailure } from "../providers/classifyProviderFailure.js"; @@ -47,12 +48,13 @@ export class V8CodeCacheProvider implements V8CodeCachePort { } async inspect(input: InspectV8CodeCacheInput, options?: ExecutionOptions) { + let completed: V8CodeCache | undefined; let observed: | { readonly sha256: string; readonly bytes: number } | undefined; try { return await this.#resources.run(async () => { - const result = await withStableArtifactHandle( + const result = await withStableArtifactHandle( input.path, input.max_file_bytes, { @@ -62,14 +64,13 @@ export class V8CodeCacheProvider implements V8CodeCachePort { onIdentity: (identity) => { observed = identity; }, + onVerifiedResult: (report) => { + completed = report; + }, }, (handle) => parseV8CodeCacheFromHandle( - { - size: handle.size, - prefix: handle.prefix, - readRange: (offset, length) => handle.readRange(offset, length), - }, + handle, { path: input.path, sha256: handle.sha256, @@ -81,7 +82,7 @@ export class V8CodeCacheProvider implements V8CodeCachePort { return ok(result); }); } catch (cause) { - return err(v8CodeCacheFailure(cause, input, observed)); + return err(v8CodeCacheFailure(cause, input, observed, completed)); } } } @@ -118,7 +119,8 @@ const observationBudgetRemediation = ( const v8CodeCacheFailure = ( cause: unknown, input: InspectV8CodeCacheInput, - observed?: { readonly sha256: string; readonly bytes: number }, + observed: { readonly sha256: string; readonly bytes: number } | undefined, + completed: V8CodeCache | undefined, ) => { const facts = artifactFilePrimaryFacts(cause); const reportedLimits = { @@ -168,6 +170,7 @@ const v8CodeCacheFailure = ( }, }), ); + if (completed !== undefined) primary.retainPartialObservation(completed); return projectStableArtifactFailure( cause, primary, diff --git a/tests/acceptance/v8CodeCacheCli.test.ts b/tests/acceptance/v8CodeCacheCli.test.ts index 2b77e5ca32f..8209120e2d8 100644 --- a/tests/acceptance/v8CodeCacheCli.test.ts +++ b/tests/acceptance/v8CodeCacheCli.test.ts @@ -17,78 +17,65 @@ cliTest( "reports wide, synthetic narrow and synthetic six-word header extents through the public CLI", async ({ cli }) => { const root = await createTestTempDirectory("rea-v8-cli-"); - const wide = v8CodeCacheFixture(); - const narrow = withSyntheticNarrowHeader(wide); - const legacy = withSyntheticLegacyHeader(wide); - const payloadDigest = createHash("sha256") - .update(wide.subarray(32)) - .digest("hex"); + const marker = "EMBEDDED_CONFIG_KEY_7c1d"; + const wide = v8CodeCacheFixture( + `var settings = { key: "${marker}" }; settings.key;`, + ); + const digest = (bytes: Buffer) => + createHash("sha256").update(bytes).digest("hex"); + const payloadDigest = digest(wide.subarray(32)); for (const [bytes, headerBytes] of [ [wide, 32], - [narrow, 28], - [legacy, 24], + [withSyntheticNarrowHeader(wide), 28], + [withSyntheticLegacyHeader(wide), 24], ] as const) { - const path = join(root, `header-${String(headerBytes)}.jsc`); + const name = `header-${String(headerBytes)}.jsc`; + const path = join(root, name); await writeFile(path, bytes); const result = await cli.run({ - arguments: ["inspect-v8-code-cache", path, "--json"], + arguments: [ + "inspect-v8-code-cache", + headerBytes === 32 ? name : path, + "--minStringBytes", + "8", + "--json", + ], + cwd: root, }); expect(result.exitCode, result.stderr).toBe(0); const report = outputSchema.parse(result.json).normalized_result; + expect(report.artifact).toEqual({ + path, + bytes: bytes.length, + sha256: digest(bytes), + }); expect(report.header.magic).toBe(bytes.readUInt32LE(0)); expect(report.header.magic_build_stable).toBe(0xc0de); expect(report.header.header_bytes).toBe(headerBytes); expect(report.header.fields).toHaveLength(headerBytes / 4); - expect(report.payload.offset).toBe(headerBytes); - expect(report.payload.bytes).toBe(bytes.length - headerBytes); - expect(report.payload.sha256).toBe(payloadDigest); + expect(report.payload).toMatchObject({ + offset: headerBytes, + bytes: bytes.length - headerBytes, + sha256: payloadDigest, + }); expect(report.coverage.status).toBe("complete"); + const observation = report.embedded_strings.find((entry) => + entry.text.includes(marker), + ); + if (observation === undefined) + throw new Error("Missing printable marker"); + expect( + bytes + .subarray( + observation.offset, + observation.offset + observation.retained_bytes, + ) + .toString("latin1"), + ).toBe(observation.text); } }, ); -cliTest( - "locates retained printable bytes from a working-directory-relative cache", - async ({ cli }) => { - const root = await createTestTempDirectory("rea-v8-cli-strings-"); - const path = join(root, "module.jsc"); - const marker = "EMBEDDED_CONFIG_KEY_7c1d"; - const bytes = v8CodeCacheFixture( - `var settings = { key: "${marker}" }; settings.key;`, - ); - await writeFile(path, bytes); - const result = await cli.run({ - arguments: [ - "inspect-v8-code-cache", - "module.jsc", - "--minStringBytes", - "8", - "--json", - ], - cwd: root, - }); - expect(result.exitCode, result.stderr).toBe(0); - const report = outputSchema.parse(result.json).normalized_result; - const observation = report.embedded_strings.find((entry) => - entry.text.includes(marker), - ); - if (observation === undefined) throw new Error("Missing printable marker"); - expect(report.artifact.path).toBe(path); - expect(observation.offset).toBeGreaterThanOrEqual(report.payload.offset); - expect(observation.offset + observation.bytes).toBeLessThanOrEqual( - report.artifact.bytes, - ); - expect( - bytes - .subarray( - observation.offset, - observation.offset + observation.retained_bytes, - ) - .toString("latin1"), - ).toBe(observation.text); - }, -); - cliTest( "fails closed on a file that is not a V8 code cache", async ({ cli }) => { diff --git a/tests/boundary/filesystem/v8CodeCacheArtifact.test.ts b/tests/boundary/filesystem/v8CodeCacheArtifact.test.ts new file mode 100644 index 00000000000..e4f28ebfbf6 --- /dev/null +++ b/tests/boundary/filesystem/v8CodeCacheArtifact.test.ts @@ -0,0 +1,199 @@ +import { createHash } from "node:crypto"; +import type { FileHandle } from "node:fs/promises"; +import { appendFile, writeFile } from "node:fs/promises"; +import { join } from "node:path"; +import { afterEach, expect, it, vi } from "vitest"; +import { createV8CodeCacheService } from "../../../src/composition/v8CodeCache.js"; +import { parseEvidence } from "../../../src/domain/evidence.js"; +import { v8CodeCacheFixture } from "../../../src/v8/V8CodeCache.fixture.js"; +import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; + +const { selected } = vi.hoisted(() => ({ + selected: { + opened: undefined as + | ((path: unknown, file: FileHandle) => void) + | undefined, + }, +})); + +vi.mock("node:fs/promises", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + open: async (...args: Parameters) => { + const file = await actual.open(...args); + selected.opened?.(args[0], file); + return file; + }, + }; +}); + +afterEach(() => { + selected.opened = undefined; + vi.restoreAllMocks(); +}); + +const digest = (bytes: Buffer) => + createHash("sha256").update(bytes).digest("hex"); +const prefixBytes = 65_536; +const fixture = () => { + const bytes = Buffer.alloc(prefixBytes * 2 + 257); + v8CodeCacheFixture().copy(bytes, 0, 0, 32); + bytes.writeUInt32LE(bytes.length - 32, 20); + bytes.write("terminal\tlabel", bytes.length - 14, "ascii"); + return bytes; +}; + +it.each([ + ["decoder EOF", "read-coverage"], + ["file changed after decode read", "container-identity"], +] as const)( + "retains only the physical V8 snapshot after %s", + async (stage, integrityCheck) => { + const root = await createTestTempDirectory("rea-v8-positional-"); + const path = join(root, "selected.jsc"); + const bytes = fixture(); + await writeFile(path, bytes); + const handles: FileHandle[] = []; + let affectedReads = 0; + selected.opened = (openedPath, handle) => { + if (String(openedPath) !== path) return; + handles.push(handle); + const file = handle as { + read( + buffer: Buffer, + offset: number, + length: number, + position: number, + ): Promise<{ bytesRead: number; buffer: Buffer }>; + }; + const read = file.read.bind(file); + vi.spyOn(file, "read").mockImplementation( + async (buffer, offset, length, position) => { + // The earlier fingerprint reads in 64 KiB chunks. This longer positional + // request can only come from the payload scanner after hashing. + if (position !== prefixBytes || length !== bytes.length - prefixBytes) + return read(buffer, offset, length, position); + affectedReads += 1; + if (stage === "decoder EOF") return { bytesRead: 0, buffer }; + const acquired = await read(buffer, offset, length, position); + await appendFile(path, "changed"); + return acquired; + }, + ); + }; + const service = createV8CodeCacheService(); + try { + const result = await service.inspect({ path }); + expect(affectedReads).toBe(1); + expect(result).toMatchObject({ + ok: false, + error: { + _tag: "AnalysisArtifactChangedError", + integrityCheck, + cleanupIncomplete: false, + partialObservation: { + kind: "file-snapshot-hash", + path, + bytes: bytes.length, + sha256: digest(bytes), + }, + }, + }); + expect(handles.map((handle) => handle.fd)).toEqual([-1]); + } finally { + await service.close(); + } + }, +); + +it.each([ + { stage: "denied close", block: true, cancel: false }, + { stage: "denied close with cancellation", block: true, cancel: true }, + { stage: "successful close with cancellation", block: false, cancel: true }, +])("retains verified V8 Evidence during $stage", async ({ block, cancel }) => { + const root = await createTestTempDirectory("rea-v8-finalization-"); + const path = join(root, "selected.jsc"); + const bytes = fixture(); + await writeFile(path, bytes); + const controller = new AbortController(); + const reason = { stage: "V8 descriptor finalization" }; + const handles: FileHandle[] = []; + let denyClose = block; + selected.opened = (openedPath, file) => { + if (String(openedPath) !== path) return; + handles.push(file); + const close = file.close.bind(file); + vi.spyOn(file, "close").mockImplementation(async () => { + if (cancel) controller.abort(reason); + if (denyClose) throw new Error("injected V8 descriptor close failure"); + await close(); + }); + }; + const service = createV8CodeCacheService(); + try { + const result = await service.inspect( + { path, max_strings: 2, min_string_bytes: 8 }, + { signal: controller.signal }, + ); + if (result.ok) + throw new Error("Expected descriptor finalization to interrupt success"); + const { error } = result; + expect(error.cleanupIncomplete).toBe(block); + expect(error.cleanupResources).toEqual(block ? [path] : []); + const cancellation = block ? error.cleanupPrimary : error; + if (cancel) { + expect(cancellation?._tag).toBe("AnalysisCancelledError"); + expect(cancellation?.cause).toBe(reason); + } + expect(handles).toHaveLength(1); + if (block) expect(handles[0]?.fd).toBeGreaterThanOrEqual(0); + else expect(handles[0]?.fd).toBe(-1); + const evidence = parseEvidence(error.partialObservation); + expect(evidence).toMatchObject({ + operation: "inspect_v8_code_cache", + parameters: { path, max_strings: 2, min_string_bytes: 8 }, + normalized_result: { + artifact: { path, sha256: digest(bytes), bytes: bytes.length }, + payload: { + offset: 32, + bytes: bytes.length - 32, + sha256: digest(bytes.subarray(32)), + }, + embedded_strings: [ + { + offset: bytes.length - 14, + bytes: 14, + retained_bytes: 14, + truncated: false, + text: "terminal\tlabel", + }, + ], + coverage: { + status: "complete", + scanned_bytes: bytes.length - 32, + strings: 1, + }, + }, + locations: [ + { kind: "artifact-path", path }, + { kind: "file-offset-range", start: 32, end: bytes.length }, + ], + }); + if (block) { + await expect(service.close()).rejects.toMatchObject({ + cleanupIncomplete: true, + cleanupResources: [path], + }); + } + denyClose = false; + await service.close(); + expect(handles.map((handle) => handle.fd)).toEqual([-1]); + expect(error.cleanupIncomplete).toBe(false); + expect(error.cleanupResources).toEqual([]); + expect(error.partialObservation).toEqual(evidence); + } finally { + denyClose = false; + await service.close(); + } +}); diff --git a/tests/support/providerLifecycleCoverage.ts b/tests/support/providerLifecycleCoverage.ts index d56442e707d..ac55be804d1 100644 --- a/tests/support/providerLifecycleCoverage.ts +++ b/tests/support/providerLifecycleCoverage.ts @@ -1668,8 +1668,8 @@ export const PROVIDER_LIFECYCLE_COVERAGE: Readonly< ), covered( test( - "src/application/v8CodeCache/V8CodeCacheService.test.ts", - "retains a completed V8 code cache observation when the caller cancels as the provider completes", + "tests/boundary/filesystem/v8CodeCacheArtifact.test.ts", + "retains verified V8 Evidence during $stage", ), ), ),