diff --git a/src/adb/AdbCommand.test.ts b/src/adb/AdbCommand.test.ts index 056b3734d6..3664389ded 100644 --- a/src/adb/AdbCommand.test.ts +++ b/src/adb/AdbCommand.test.ts @@ -233,7 +233,6 @@ it.each([true, false])( { timeoutMs: 100, maxOutputBytes: 1024, volatileOutput }, undefined, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a capture allowance refusal"); const projected = projectAnalysisError(result.error); expect(projected.retryable).toBe(volatileOutput); @@ -263,7 +262,6 @@ it("reports the effective fixed adb deadline", async () => { { timeoutMs: 600_000, maxOutputBytes: 1024 }, undefined, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an adb deadline"); const projected = projectAnalysisError(result.error); expect(projected).toMatchObject({ diff --git a/src/adb/AdbProvider.test.ts b/src/adb/AdbProvider.test.ts index 793c55cb4b..fcefbff92b 100644 --- a/src/adb/AdbProvider.test.ts +++ b/src/adb/AdbProvider.test.ts @@ -87,7 +87,6 @@ const refusedBy = async ( request: AdbRequest, ): Promise> => { const result = await provider.execute(request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected a refusal"); return projectAnalysisError(result.error); }; @@ -577,7 +576,6 @@ it.each([ await expect(lstat(packageDirectory)).rejects.toThrow(); return; } - expect(result.ok).toBe(true); if (!result.ok) throw new Error(result.error.message); expect( ( @@ -1463,7 +1461,6 @@ exit 1`, overwrite: false, }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected snapshot cleanup to be reported"); expect(result.error.cleanupResources).toHaveLength(1); expect(result.error.partialObservation).toMatchObject({ @@ -1523,7 +1520,6 @@ exit 1`, overwrite: false, }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected a changed-artifact result"); const evidence = parseEvidence(result.error.partialObservation); expect(evidence).toMatchObject({ @@ -1868,7 +1864,6 @@ it("reads Android 16 focus declarations from displays when windows omits them", operation: "inspect_adb_window", input: { serial: "emulator-5554" }, }); - expect(execution.ok).toBe(true); if (!execution.ok) throw execution.error; expect(execution.value.limitations).toContainEqual( expect.stringContaining("dumpsys window displays"), @@ -1891,7 +1886,6 @@ it("describes missing window focus as unknown after both sections omit declarati operation: "inspect_adb_window", input: { serial: "emulator-5554" }, }); - expect(execution.ok).toBe(true); if (!execution.ok) throw execution.error; expect(execution.value.limitations).toContainEqual( expect.stringContaining("focus is unknown"), @@ -1915,7 +1909,6 @@ it.each(["windows", "displays"])( operation: "inspect_adb_window", input: { serial: "emulator-5554" }, }); - expect(execution.ok).toBe(true); if (!execution.ok) throw execution.error; expect(execution.value.result).toMatchObject({ focused_window: null, diff --git a/src/apktool/ApktoolDecodeTimeout.test.ts b/src/apktool/ApktoolDecodeTimeout.test.ts index 14c9439616..3409851617 100644 --- a/src/apktool/ApktoolDecodeTimeout.test.ts +++ b/src/apktool/ApktoolDecodeTimeout.test.ts @@ -114,7 +114,6 @@ it("applies the omitted 600000 ms decode deadline and a selected value on the ne expect(outputBudgets).toEqual([4 * 1024 * 1024]); const timedOut = await decode(provider, path, 200); - expect(timedOut.ok).toBe(false); if (timedOut.ok) throw new Error("Expected a decode deadline"); const projected = projectAnalysisError(timedOut.error); expect(projected).toMatchObject({ @@ -144,7 +143,6 @@ it("applies the omitted 600000 ms decode deadline and a selected value on the ne ]); const maximum = await decode(provider, path, MAX_APKTOOL_DECODE_TIMEOUT_MS); - expect(maximum.ok).toBe(false); if (maximum.ok) throw new Error("Expected the maximum decode deadline"); expect(projectAnalysisError(maximum.error).remediation.action).toContain( "do not increase it further", diff --git a/src/apktool/ApktoolProvider.test.ts b/src/apktool/ApktoolProvider.test.ts index a79d2fcced..ac5e825f21 100644 --- a/src/apktool/ApktoolProvider.test.ts +++ b/src/apktool/ApktoolProvider.test.ts @@ -97,7 +97,6 @@ const refusedBy = async ( request: ApktoolRequest, ): Promise> => { const result = await provider.execute(request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected a refusal"); return projectAnalysisError(result.error); }; @@ -583,7 +582,6 @@ it("still refuses invalid UTF-8 bytes in decoded strings", async () => { operation: "decode_android_resources", input: { path: apk.path, include_strings: true }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected a refusal"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "unreadable_output", diff --git a/src/application/AppBundleExecutable.openStep.test.ts b/src/application/AppBundleExecutable.openStep.test.ts index 4a5aae87f8..cf8e8011a1 100644 --- a/src/application/AppBundleExecutable.openStep.test.ts +++ b/src/application/AppBundleExecutable.openStep.test.ts @@ -1,7 +1,6 @@ import { mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; -import { parseOpenStep } from "plist"; import { expect, it } from "vitest"; import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js"; @@ -19,7 +18,6 @@ it.each([ const executable = join(programs, "Fixture"); const infoPlist = join(bundle, "Contents", "Info.plist"); const source = `${prefix}{ CFBundleExecutable = Fixture; }`; - expect(parseOpenStep(source)).toEqual({ CFBundleExecutable: "Fixture" }); await mkdir(programs, { recursive: true }); await writeFile(infoPlist, source); await writeFile(executable, "fixture - never executed"); diff --git a/src/application/BrowserObservationService.test.ts b/src/application/BrowserObservationService.test.ts index 1cd7eb2609..d6326ecb0f 100644 --- a/src/application/BrowserObservationService.test.ts +++ b/src/application/BrowserObservationService.test.ts @@ -286,7 +286,6 @@ it("retains completed bundle facts as bundle Evidence after cancellation", async total_analysis_timeout_ms: 1000, }); const result = await analyzeWebBundle(browser, selected); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBe(failure); expect(result.error.cause).toBe(reason); @@ -313,7 +312,6 @@ it("preserves a prior caller reason without admitting browser work", async () => input, { signal: AbortSignal.abort(reason) }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancelled inventory"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); diff --git a/src/application/BrowserScenarioCaptureService.test.ts b/src/application/BrowserScenarioCaptureService.test.ts index c370e77ffa..49722d9445 100644 --- a/src/application/BrowserScenarioCaptureService.test.ts +++ b/src/application/BrowserScenarioCaptureService.test.ts @@ -48,7 +48,6 @@ const expectRetainedCapture = ( result: Awaited>, failure: AnalysisError, ) => { - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the retained capture"); expect(result.error).toBe(failure); expect(parseEvidence(result.error.partialObservation)).toMatchObject({ @@ -197,7 +196,6 @@ it("rejects a successful capture that is not a completed scenario", async () => captureScenario: async () => ok({} as BrowserScenarioCapture), }; const result = await captureBrowserScenario(provider, scenario); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a completed-capture refusal"); expect(result.error).toBeInstanceOf(AnalysisOutputError); expect(result.error.message).toContain( diff --git a/src/application/CallPathTracing.test.ts b/src/application/CallPathTracing.test.ts index 927057a187..fa5b538298 100644 --- a/src/application/CallPathTracing.test.ts +++ b/src/application/CallPathTracing.test.ts @@ -28,7 +28,6 @@ describe("call-path traversal cancellation ownership", () => { input, controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); diff --git a/src/application/ClientConfigurationDocument.repeatedMembers.test.ts b/src/application/ClientConfigurationDocument.repeatedMembers.test.ts index f245412401..d79cedaf70 100644 --- a/src/application/ClientConfigurationDocument.repeatedMembers.test.ts +++ b/src/application/ClientConfigurationDocument.repeatedMembers.test.ts @@ -59,7 +59,6 @@ describe("JSON client configuration repeated-member edits", () => { removeShadowedMembersAt: [path], }); - expect(result.ok).toBe(true); if (!result.ok) throw new Error("authorized repeats were refused"); expect(parseStrictJson(result.value)).toEqual({ mcpServers: { @@ -109,7 +108,6 @@ describe("JSON client configuration repeated-member edits", () => { "handles %s without losing peers", (_label, text, expectedServers, authority) => { const result = removeRea(text, "json", authority); - expect(result.ok).toBe(true); if (!result.ok) throw new Error("non-shadowed removal was refused"); expect(parseStrictJson(result.value)).toEqual({ mcpServers: expectedServers, @@ -127,7 +125,6 @@ describe("JSON client configuration repeated-member edits", () => { removeShadowedMembersAt: [["mcpServers", "rea"]], }); - expect(result.ok).toBe(true); if (!result.ok) throw new Error("authorized escaped repeat was refused"); expect(result.value).toContain(`"mcpServers":${inactive}`); expect(parseStrictJson(result.value)).toEqual({ @@ -146,7 +143,6 @@ describe("JSON client configuration repeated-member edits", () => { removeShadowedMembersAt: [["mcp", "rea"]], }); - expect(result.ok).toBe(true); if (!result.ok) throw new Error("authorized JSONC repeats were refused"); expect(result.value).toContain("// top comment"); expect(result.value).toContain("// first"); diff --git a/src/application/ClientConfigurationDocument.tomlComments.test.ts b/src/application/ClientConfigurationDocument.tomlComments.test.ts index 9f415643e6..edacc12ec4 100644 --- a/src/application/ClientConfigurationDocument.tomlComments.test.ts +++ b/src/application/ClientConfigurationDocument.tomlComments.test.ts @@ -42,7 +42,6 @@ for (const format of ["toml", "grok"] as const) format, source, ); - expect(result.ok).toBe(true); if (!result.ok) throw new Error("TOML edit was refused"); for (const comment of [ "# server header note", @@ -85,7 +84,6 @@ it("retains comments from dotted REA assignments and nested inline values", () = "toml", source, ); - expect(result.ok).toBe(true); if (!result.ok) throw new Error("TOML removal was refused"); expect(result.value).toContain( source.includes("# dotted note") diff --git a/src/application/EnhancedInputDiagnostics.test.ts b/src/application/EnhancedInputDiagnostics.test.ts index 4210013eb4..15750c1b31 100644 --- a/src/application/EnhancedInputDiagnostics.test.ts +++ b/src/application/EnhancedInputDiagnostics.test.ts @@ -6,7 +6,6 @@ it("preserves field diagnostics for rejected enhanced tool inputs", async () => const execute = vi.fn(); const tools = new EnhancedTools({ execute }); const result = await tools.execute("trace_native_values", { procedure: "" }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected an input failure"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "invalid_request", @@ -18,7 +17,6 @@ it("preserves field diagnostics for rejected enhanced tool inputs", async () => expect(execute).not.toHaveBeenCalled(); const sibling = await tools.execute("batch_decompile", { addresses: "bad" }); - expect(sibling.ok).toBe(false); if (sibling.ok) throw new Error("expected an input failure"); expect(projectAnalysisError(sibling.error)).toMatchObject({ details: { issues: [{ path: ["addresses"], reason: "invalid_type" }] }, diff --git a/src/application/EnhancedTools.objcClasses.test.ts b/src/application/EnhancedTools.objcClasses.test.ts index 3093fa6bbf..9067eb3c90 100644 --- a/src/application/EnhancedTools.objcClasses.test.ts +++ b/src/application/EnhancedTools.objcClasses.test.ts @@ -444,7 +444,6 @@ describe("EnhancedTools cancellation ownership", () => { controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Pre-cancelled observation was accepted"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); diff --git a/src/application/WebNetworkCaptureService.test.ts b/src/application/WebNetworkCaptureService.test.ts index bc9c660572..eef3156045 100644 --- a/src/application/WebNetworkCaptureService.test.ts +++ b/src/application/WebNetworkCaptureService.test.ts @@ -212,7 +212,6 @@ it("projects completed raw capture facts on failure through the caller's selecti record_ordinals: [0], sensitive_values: ["private-marker"], }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Cancellation must remain the primary result"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -270,7 +269,6 @@ it("keeps a redacted cleanup error linked to its live owner through service clos format: "har", sensitive_values: ["private-marker"], }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Retained cleanup must remain a failure"); const returnedError = result.error; expect(returnedError.cleanupIncomplete).toBe(true); diff --git a/src/application/WorkflowEvidence.test.ts b/src/application/WorkflowEvidence.test.ts index 1f3d647cc7..cffd1f5b6b 100644 --- a/src/application/WorkflowEvidence.test.ts +++ b/src/application/WorkflowEvidence.test.ts @@ -703,7 +703,6 @@ it("reports a retained workflow and the committed prefix when Unknown publicatio ? err(failure) : records.recordUnknown(input), }); - expect(outcome.ok).toBe(false); if (outcome.ok) throw new Error("expected failure"); const projected = projectAnalysisError(outcome.error); expect(projected.details?.workflow_unknown_publication).toEqual({ diff --git a/src/application/adb/AdbDeviceAnalysisService.test.ts b/src/application/adb/AdbDeviceAnalysisService.test.ts index 1760fafe26..9e0a08269a 100644 --- a/src/application/adb/AdbDeviceAnalysisService.test.ts +++ b/src/application/adb/AdbDeviceAnalysisService.test.ts @@ -53,7 +53,6 @@ it.each([ it("rejects an unknown operation before any effect", async () => { const service = new AdbDeviceAnalysisService(refusedPort); const result = await service.execute("unknown_adb_operation" as never, {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an unknown operation refusal"); expect(result.error).toBeInstanceOf(AnalysisInputError); if (!(result.error instanceof AnalysisInputError)) throw result.error; diff --git a/src/application/apiContract/ApiContractService.test.ts b/src/application/apiContract/ApiContractService.test.ts index dee612195d..651baa45d8 100644 --- a/src/application/apiContract/ApiContractService.test.ts +++ b/src/application/apiContract/ApiContractService.test.ts @@ -211,7 +211,6 @@ it("keeps native JSON source excerpts internal while preserving the failure caus const resources = new ArtifactResourceScope(); try { const result = await inspectApiContractEvidence({ path }, resources); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a syntax refusal"); expect(result.error.cause).toBeInstanceOf(SyntaxError); expect(JSON.stringify(result.error)).not.toContain("u:p@h"); @@ -257,7 +256,6 @@ it.each([ }); await new Promise((resolve) => setImmediate(resolve)); expect(controller.signal.aborted).toBe(true); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the parser failure"); expect(result.error._tag).toBe(tag); expect(result.error.partialObservation).toEqual({ diff --git a/src/application/apiContract/GraphqlContractService.test.ts b/src/application/apiContract/GraphqlContractService.test.ts index 2ab245c3e9..4a975e1fd7 100644 --- a/src/application/apiContract/GraphqlContractService.test.ts +++ b/src/application/apiContract/GraphqlContractService.test.ts @@ -84,7 +84,6 @@ it.each(["path", "operations_path"] as const)( ); await withScope(async (resources) => { const result = await inspectApiContractEvidence(input, resources); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected invalid UTF-8"); expect(result.error._tag).toBe("AnalysisInputError"); expect(projectAnalysisError(result.error)).toMatchObject({ @@ -148,7 +147,6 @@ it("attributes auxiliary file admission failures to operations_path and retains { ...input, operations_path: join(input.path, "missing") }, resources, ); - expect(missing.ok).toBe(false); if (missing.ok) throw new Error("Expected missing operation file"); expect(projectAnalysisError(missing.error)).toMatchObject({ details: { issues: [{ path: ["operations_path"] }] }, diff --git a/src/application/binary/BinarySessionBundleResources.test.ts b/src/application/binary/BinarySessionBundleResources.test.ts index f135eb2884..553705d522 100644 --- a/src/application/binary/BinarySessionBundleResources.test.ts +++ b/src/application/binary/BinarySessionBundleResources.test.ts @@ -394,7 +394,6 @@ it.each([false, true])( releaseClose(); const result = await opening; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed resource switch"); expect(result.error.cleanupPrimary).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cleanupPrimary?.cause).toBe(reason); @@ -480,7 +479,6 @@ it("keeps an earlier resource close failure primary when a later cleanup is canc releaseCandidateClose(); const result = await opening; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed resource switch"); expect(result.error).toBe(originalFailure); expect(result.error.cleanupPrimary).toBeUndefined(); @@ -569,7 +567,6 @@ it("keeps cancellation primary when binary retirement fails before opening resou releaseClose(); const result = await opening; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed resource open"); expect(result.error.cleanupPrimary).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cleanupPrimary?.cause).toBe(reason); @@ -661,7 +658,6 @@ it("keeps an earlier resource close failure primary when binary candidate cleanu releaseCandidateClose(); const result = await opening; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed binary open"); expect(result.selection).toEqual({ kind: "none" }); expect(result.error).toBe(originalFailure); @@ -765,7 +761,6 @@ it("keeps an earlier binary close failure primary when candidate cleanup is canc releaseCandidateClose(); const result = await opening; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed resource open"); expect(result.error).toBe(originalFailure); expect(result.error.cleanupPrimary).toBeUndefined(); @@ -866,7 +861,6 @@ it("cancels a binary switch during resource retirement and retains null-subject releaseResourceClose(); const result = await opening; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancelled binary open"); expect(result.error.cleanupPrimary).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cleanupPrimary?.cause).toBe(reason); diff --git a/src/application/binary/BundleResourceSession.test.ts b/src/application/binary/BundleResourceSession.test.ts index 4579bc5f58..8ef291200e 100644 --- a/src/application/binary/BundleResourceSession.test.ts +++ b/src/application/binary/BundleResourceSession.test.ts @@ -97,7 +97,6 @@ it("reports the first mixed child failure before awaiting the other owner and re await Promise.all([nativeStarted, failureObserved]); releaseNativeClose(); const first = await closing; - expect(first.ok).toBe(false); if (first.ok) throw new Error("Expected mixed close failure"); expect(first.error.cleanupIncomplete).toBe(true); diff --git a/src/application/binary/CompositeProvider.test.ts b/src/application/binary/CompositeProvider.test.ts index 174bed3716..5ce37cf672 100644 --- a/src/application/binary/CompositeProvider.test.ts +++ b/src/application/binary/CompositeProvider.test.ts @@ -113,7 +113,6 @@ it("retains every failed child resource across composite cleanup retries", async for (let attempt = 0; attempt < 2; attempt += 1) { const closed = await client.close(); - expect(closed.ok).toBe(false); if (closed.ok) throw new Error("Expected composite cleanup failure"); expect(closed.error).toMatchObject({ cleanupIncomplete: true, @@ -158,7 +157,6 @@ it("preserves one child's typed cleanup error unchanged", async () => { const closed = await client.close(); - expect(closed.ok).toBe(false); if (closed.ok) throw new Error("Expected child cleanup failure"); expect(closed.error).toBe(child.cleanupError); }); @@ -306,7 +304,6 @@ it.each([1, 2])( release(); } const first = await closing; - expect(first.ok).toBe(false); if (first.ok) throw new Error("Expected retained child cleanup"); expect(notifications).toEqual([ ...children.map((child) => child.cleanupError), @@ -318,7 +315,6 @@ it.each([1, 2])( notifications.length = 0; const retried = await closeAnalysisClient(client, "composite", options); - expect(retried.ok).toBe(false); if (retried.ok) throw new Error("Expected failed cleanup retry"); expect(notifications).toEqual([ ...children.map((child) => child.cleanupError), diff --git a/src/application/binaryDiagnostics/AppleIpsService.test.ts b/src/application/binaryDiagnostics/AppleIpsService.test.ts index 29ddea06df..868c9f181b 100644 --- a/src/application/binaryDiagnostics/AppleIpsService.test.ts +++ b/src/application/binaryDiagnostics/AppleIpsService.test.ts @@ -126,7 +126,6 @@ it.each(["288", "309 "])( identity, inspect: () => Promise.resolve(ok(malformed)), }).inspect({ path: report.artifact.path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected unsupported provider crash kind"); expect(result.error._tag).toBe("AnalysisOutputError"); }, diff --git a/src/application/binaryDiagnostics/PeResourcesService.test.ts b/src/application/binaryDiagnostics/PeResourcesService.test.ts index 3b08d79961..7457c8bb91 100644 --- a/src/application/binaryDiagnostics/PeResourcesService.test.ts +++ b/src/application/binaryDiagnostics/PeResourcesService.test.ts @@ -169,7 +169,6 @@ it.each([ }, }); const result = await service.inspect(null, { signal: controller.signal }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancelled admission"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); diff --git a/src/application/captures/PacketCaptureService.test.ts b/src/application/captures/PacketCaptureService.test.ts index d608ebc2e7..224b3cc965 100644 --- a/src/application/captures/PacketCaptureService.test.ts +++ b/src/application/captures/PacketCaptureService.test.ts @@ -90,7 +90,6 @@ it("retains provider metadata in a late-cancellation observation", async () => { const result = await service.inspect(input, { signal: controller.signal }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected late cancellation"); expect(result.error).toMatchObject({ _tag: "AnalysisCancelledError" }); expect(result.error.cause).toBe(reason); diff --git a/src/application/go/GoBinaryService.test.ts b/src/application/go/GoBinaryService.test.ts index e3109ed1e2..485728e875 100644 --- a/src/application/go/GoBinaryService.test.ts +++ b/src/application/go/GoBinaryService.test.ts @@ -254,7 +254,6 @@ it.each([ }, }); const result = await service.inspect(null, { signal: controller.signal }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancelled admission"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); diff --git a/src/application/il2cpp/Il2cppMetadataService.test.ts b/src/application/il2cpp/Il2cppMetadataService.test.ts index 3102609ffb..761902a572 100644 --- a/src/application/il2cpp/Il2cppMetadataService.test.ts +++ b/src/application/il2cpp/Il2cppMetadataService.test.ts @@ -171,7 +171,6 @@ it("preserves source Evidence and requested output choices when publication fail path: "/output/seeds.tsv", base: "0x2000", }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Failed publication accepted"); expect(result.error).toBe(failure); expect(result.error.partialObservation).toMatchObject({ @@ -213,7 +212,6 @@ it("retains a published seed receipt if cancellation arrives after the atomic wr { path: receipt.path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Cancellation ignored"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); diff --git a/src/application/investigation/EvidenceLedger.residualUnknown.test.ts b/src/application/investigation/EvidenceLedger.residualUnknown.test.ts index 422e7bd385..e8224debbe 100644 --- a/src/application/investigation/EvidenceLedger.residualUnknown.test.ts +++ b/src/application/investigation/EvidenceLedger.residualUnknown.test.ts @@ -449,7 +449,6 @@ describe("residual unknown registry resolution and history", () => { ).toBe(true); const before = serializeEvidenceBundle(base.export()); const conflict = base.import(branch.export()); - expect(conflict.ok).toBe(false); if (conflict.ok) throw new Error("Expected divergent history refusal"); expectHistoryConflict(conflict.error, created.value.unknown_id); expect(base.get(source.evidence_id)?.caller_input_path).toBe("./original"); diff --git a/src/application/investigation/recordEvidenceSources.test.ts b/src/application/investigation/recordEvidenceSources.test.ts index 63f15f3700..e0f77afed5 100644 --- a/src/application/investigation/recordEvidenceSources.test.ts +++ b/src/application/investigation/recordEvidenceSources.test.ts @@ -32,7 +32,6 @@ it.each([ withEvidenceSources(cancelled ? err(primary) : ok("complete"), [source]), sourceOwner === undefined ? undefined : { sourceOwner }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected recording failure"); expect(result.error).toBe(cancelled ? primary : failure); expect(primary.secondaryFailures).toEqual(cancelled ? [failure] : []); diff --git a/src/application/javascript/JavaScriptRuntimeObservationService.test.ts b/src/application/javascript/JavaScriptRuntimeObservationService.test.ts index 6ef97ff4c2..d172856c8b 100644 --- a/src/application/javascript/JavaScriptRuntimeObservationService.test.ts +++ b/src/application/javascript/JavaScriptRuntimeObservationService.test.ts @@ -75,7 +75,6 @@ it("preserves failed Inspector cleanup when cancellation occurs during observati { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed cleanup"); expect(result.error).toBe(failure); expect(result.error.cleanupIncomplete).toBe(true); diff --git a/src/application/javascript/JavaScriptSemanticGraphResources.test.ts b/src/application/javascript/JavaScriptSemanticGraphResources.test.ts index dd77388c12..a46a99ceb1 100644 --- a/src/application/javascript/JavaScriptSemanticGraphResources.test.ts +++ b/src/application/javascript/JavaScriptSemanticGraphResources.test.ts @@ -4,7 +4,7 @@ import { expect, it } from "vitest"; import { graphForJavaScript as graphFor } from "../../../tests/fixtures/javascriptSemanticGraph.js"; import { createJavaScriptSemanticGraphProjection } from "./JavaScriptSemanticGraphBuilder.js"; import { queryJavaScriptSemanticGraph } from "../../domain/javascript/javascriptSemanticQuery.js"; -import { resolveJavaScriptSemanticEvidence } from "../../domain/javascript/javascriptSemanticGraph.js"; +import { resolveJavaScriptSemanticEvidence } from "../../../tests/support/javascriptSemanticGraphFixture.js"; const SHA256 = "a".repeat(64); const GRAPH_ID = `jag_${"b".repeat(64)}`; diff --git a/src/application/native/NativeFunctionMatchingService.test.ts b/src/application/native/NativeFunctionMatchingService.test.ts index fb0652c184..f8be36848a 100644 --- a/src/application/native/NativeFunctionMatchingService.test.ts +++ b/src/application/native/NativeFunctionMatchingService.test.ts @@ -74,7 +74,6 @@ it("retains transitive provenance without treating dependencies as native observ undefined, (id) => (id === dependency.evidence_id ? dependency : undefined), ); - expect(missing.ok).toBe(false); if (missing.ok) throw new Error("Missing ancestor accepted"); expect(missing.error).toMatchObject({ evidenceId: ancestor.evidence_id, @@ -933,7 +932,6 @@ it("enforces the caller-resolved representation allowance and names its setting" const lowered = await matchNativeFunctions(small, { representationAllowance: { maximumBytes: 64 * 1024, source: "runtime" }, }); - expect(lowered.ok).toBe(false); if (lowered.ok) throw new Error("Lowered allowance admitted the request"); expect(lowered.error).toMatchObject({ _tag: "AnalysisResourceConstraintError", diff --git a/src/application/native/NativeValueTrace.test.ts b/src/application/native/NativeValueTrace.test.ts index d2b1e930bc..6ff3a1966c 100644 --- a/src/application/native/NativeValueTrace.test.ts +++ b/src/application/native/NativeValueTrace.test.ts @@ -164,7 +164,6 @@ describe("native value trace seed admission", () => { }, { procedure: "missing" }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected seed failure"); expect(result.error).toBe(failure); expect(attempted).toEqual([["analyze_function", { procedure: "missing" }]]); diff --git a/src/application/python/PythonPycService.test.ts b/src/application/python/PythonPycService.test.ts index 90d2c5b282..548c2fdb31 100644 --- a/src/application/python/PythonPycService.test.ts +++ b/src/application/python/PythonPycService.test.ts @@ -122,7 +122,6 @@ it("retains completed pyc Evidence and the opaque caller reason on late cancella { path: report.artifact.path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); diff --git a/src/application/rust/RustBinaryService.test.ts b/src/application/rust/RustBinaryService.test.ts index f855482410..c2a2be41ea 100644 --- a/src/application/rust/RustBinaryService.test.ts +++ b/src/application/rust/RustBinaryService.test.ts @@ -218,7 +218,6 @@ it.each([ }, }); const result = await service.inspect(null, { signal: controller.signal }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancelled admission"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); diff --git a/src/application/signals/SignalRecordingService.test.ts b/src/application/signals/SignalRecordingService.test.ts index 57a891d3ab..1fd3a30ccd 100644 --- a/src/application/signals/SignalRecordingService.test.ts +++ b/src/application/signals/SignalRecordingService.test.ts @@ -83,7 +83,6 @@ it("retains provider metadata in a late-cancellation observation", async () => { const result = await service.decode(input, { signal: controller.signal }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected late cancellation"); expect(result.error).toMatchObject({ _tag: "AnalysisCancelledError" }); expect(result.error.cause).toBe(reason); diff --git a/src/application/wasm/WasmInterfaceComparisonService.test.ts b/src/application/wasm/WasmInterfaceComparisonService.test.ts index 138f9de6ed..478377fb5e 100644 --- a/src/application/wasm/WasmInterfaceComparisonService.test.ts +++ b/src/application/wasm/WasmInterfaceComparisonService.test.ts @@ -290,7 +290,6 @@ it("refuses two admitted inventories that together exceed the comparison cap", a right: evidence(right), scope: "both", }); - expect(combined.ok).toBe(false); if (combined.ok) throw new Error("Expected comparison allowance refusal"); const projected = projectAnalysisError(combined.error); expect(projected.retryable).toBe(false); diff --git a/src/artifacts/ArtifactResourceScope.test.ts b/src/artifacts/ArtifactResourceScope.test.ts index 3292bdcff4..37c6efb6f2 100644 --- a/src/artifacts/ArtifactResourceScope.test.ts +++ b/src/artifacts/ArtifactResourceScope.test.ts @@ -84,7 +84,7 @@ it("stops a close hook even when retained cleanup is still failing", async () => (cause: unknown) => cause, ); expect(closeFailure).toMatchObject({ - message: "Artifact cleanup remains incomplete: stuck lease, close hook", + message: expect.stringContaining("stuck lease, close hook"), failedOwners: [owner], cleanup: { reason: "still owned; hook still stopping", @@ -305,7 +305,7 @@ it("retains the same failed reader owner in a retry failure and retries before a await expect(scope.run(async () => "must not run")).rejects.toMatchObject({ reason: "unavailable", - message: "Artifact cleanup remains incomplete: fixture reader", + message: expect.stringContaining("fixture reader"), failedOwners: [owner], }); expect(closeAttempts).toBe(2); diff --git a/src/artifacts/ArtifactSourceResolution.test.ts b/src/artifacts/ArtifactSourceResolution.test.ts index 3a87e57f0b..abd68f45aa 100644 --- a/src/artifacts/ArtifactSourceResolution.test.ts +++ b/src/artifacts/ArtifactSourceResolution.test.ts @@ -72,7 +72,6 @@ it.skipIf(process.platform === "win32")( max_entries: 32, max_probe_bytes: 4096, }); - expect(invalid.ok).toBe(false); if (invalid.ok) throw new Error("expected ENOTDIR refusal"); expect(projectAnalysisError(invalid.error)).toMatchObject({ code: "target_unavailable", @@ -83,7 +82,6 @@ it.skipIf(process.platform === "win32")( max_entries: 32, max_probe_bytes: 4096, }); - expect(valid.ok).toBe(true); if (!valid.ok) throw valid.error; expect( desktopApplicationSchema diff --git a/src/artifacts/FitArtifactReader.test.ts b/src/artifacts/FitArtifactReader.test.ts index 10c44f41e5..09e56fab0e 100644 --- a/src/artifacts/FitArtifactReader.test.ts +++ b/src/artifacts/FitArtifactReader.test.ts @@ -295,7 +295,7 @@ it("fails /images followed by a malformed structure, and leaves a plain DTB a fi scanCanonicalArtifactInventory(await writeFit("broken.itb", bytes)), ).rejects.toMatchObject({ reason: "format", - message: "FIT is malformed: Unknown FDT token 10", + message: expect.stringMatching(/FDT.*token 10/iu), }); const plain = await scanCanonicalArtifactInventory( await writeFit("board.dtb", devicetreeFixture()), diff --git a/src/artifacts/GodotPckArtifactReader.test.ts b/src/artifacts/GodotPckArtifactReader.test.ts index 40587a34bb..2d5e78906a 100644 --- a/src/artifacts/GodotPckArtifactReader.test.ts +++ b/src/artifacts/GodotPckArtifactReader.test.ts @@ -445,7 +445,7 @@ describe("GodotPckArtifactReader carrier truncation", () => { try { await expect(text(await reader.open(entry))).rejects.toMatchObject({ reason: "integrity", - message: "Godot PCK entry ended early: member.bin", + message: expect.stringContaining("member.bin"), }); expect(calls).toBe(2); } finally { diff --git a/src/artifacts/NodeSeaArtifactReader.test.ts b/src/artifacts/NodeSeaArtifactReader.test.ts index 45b6950f4a..b084e084b3 100644 --- a/src/artifacts/NodeSeaArtifactReader.test.ts +++ b/src/artifacts/NodeSeaArtifactReader.test.ts @@ -308,8 +308,7 @@ it.each([false, true])( if (sea) await expect(located).rejects.toMatchObject({ reason: "limit", - message: - "Node SEA PE inspection exceeds the 512 MiB PE parser input ceiling", + message: expect.stringMatching(/PE.*512 MiB/iu), }); else await expect(located).resolves.toBeUndefined(); } finally { @@ -659,7 +658,7 @@ it("rejects missing Mach-O load commands after a confirmed SEA section", async ( scanCanonicalArtifactInventory(await writeCarrier("commands", bytes)), ).rejects.toMatchObject({ reason: "format", - message: "Node SEA Mach-O load commands are truncated", + message: expect.stringMatching(/Mach-O.*load commands.*truncated/iu), }); }); @@ -708,7 +707,7 @@ it("reports a member that ends after the carrier recheck as an integrity failure try { await expect(buffer(await reader.open(entry))).rejects.toMatchObject({ reason: "integrity", - message: "Node SEA entry ended early: sea.js", + message: expect.stringContaining("sea.js"), }); expect(calls).toBe(2); } finally { diff --git a/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts b/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts index 7268a55ccd..2069fd18e2 100644 --- a/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts +++ b/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts @@ -558,8 +558,7 @@ it.each(["reported carutil", "tab-indented carutil", "observed assetutil"])( expect(error.cause).toBe(cause); expect(projectAnalysisError(error)).toMatchObject({ code: "artifact_operation_failed", - message: - "Artifact is invalid or has changed. Get a fresh copy and try again.", + message: expect.stringMatching(/invalid.*changed.*fresh copy/iu), details: { operation: "inspect_asset_catalog", reason: "format", diff --git a/src/artifacts/apple/InterfaceBuilderDecodeBudget.test.ts b/src/artifacts/apple/InterfaceBuilderDecodeBudget.test.ts index 314ec82b9f..c5a0a2e068 100644 --- a/src/artifacts/apple/InterfaceBuilderDecodeBudget.test.ts +++ b/src/artifacts/apple/InterfaceBuilderDecodeBudget.test.ts @@ -8,10 +8,8 @@ import { describe, expect, it } from "vitest"; import { analyzeInterfaceBuilderBundle } from "./InterfaceBuilderAnalysis.js"; import { interfaceBuilderDecodeBudgetFailure } from "./InterfaceBuilderDecodeBudget.js"; import { preflightPropertyListDecode } from "./PropertyListDecodeBudget.js"; -import { unknownDateLimitation } from "../../domain/apple/plistValue.js"; import { parseXmlPropertyList } from "../../domain/propertyListKeys.js"; import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js"; -import { scanBinaryPlistScalars } from "./PlistScalars.js"; import { readBinaryPlistObjectOffset, readBinaryPlistObjectTableLayout, @@ -181,8 +179,13 @@ it("retains explicit date uncertainty for an overlapping binary plist object", a "com.apple.ibtool.document.classes": {}, }), ); - const date = scanBinaryPlistScalars(bytes).dates[0]; - if (date === undefined) throw new Error("fixture lost its date"); + // The fixture date is 978307200 seconds before the 2001 plist epoch. + const encodedDate = Buffer.alloc(9); + encodedDate[0] = 0x33; + encodedDate.writeDoubleBE(-978307200, 1); + const dateOffset = bytes.indexOf(encodedDate); + expect(dateOffset).toBeGreaterThanOrEqual(0); + expect(bytes.indexOf(encodedDate, dateOffset + 1)).toBe(-1); const table = readBinaryPlistObjectTableLayout(bytes); let dataObjectId: number | undefined; for (let objectId = 0; objectId < table.objectCount; objectId += 1) { @@ -192,11 +195,11 @@ it("retains explicit date uncertainty for an overlapping binary plist object", a if (dataObjectId === undefined) throw new Error("fixture lost its empty data"); // Keep both objects reachable through a recognized archive while sharing source bytes. - bytes.writeDoubleBE(0.0005, date.offset + 1); - bytes[date.offset + 2] = 0x40; - writeBinaryPlistObjectOffset(bytes, table, dataObjectId, date.offset + 2); + bytes.writeDoubleBE(0.0005, dateOffset + 1); + bytes[dateOffset + 2] = 0x40; + writeBinaryPlistObjectOffset(bytes, table, dataObjectId, dateOffset + 2); expect(readBinaryPlistObjectOffset(bytes, table, dataObjectId)).toBe( - date.offset + 2, + dateOffset + 2, ); expect( preflightPropertyListDecode(bytes, 1024 * 1024, undefined, { @@ -204,7 +207,7 @@ it("retains explicit date uncertainty for an overlapping binary plist object", a }), ).toMatchObject({ datePrecisionOverlapCount: 1, - reachableDateOffsets: [date.offset], + reachableDateOffsets: [dateOffset], }); await writeFile(join(bundle, "Panel.nib"), bytes); @@ -306,8 +309,10 @@ describe("binary Interface Builder plist dates", () => { const offset = submillisecond.indexOf(marker); submillisecond.writeDoubleBE(0.1005, offset + 1); const unknown = await nib(submillisecond, "subms"); - expect(unknown.limitations).toContain( - `Panel.nib: ${unknownDateLimitation(1)}`, + expect(unknown.limitations).toContainEqual( + expect.stringMatching( + /Panel\.nib.*\b1 date value.*decoder could not represent.*timestamps/iu, + ), ); expect(JSON.stringify(unknown)).not.toContain("2001-01-01T00:00:00.100Z"); diff --git a/src/artifacts/apple/KeyedArchiveHostDenial.test.ts b/src/artifacts/apple/KeyedArchiveHostDenial.test.ts index 79a2d7445a..4d69021baf 100644 --- a/src/artifacts/apple/KeyedArchiveHostDenial.test.ts +++ b/src/artifacts/apple/KeyedArchiveHostDenial.test.ts @@ -95,7 +95,6 @@ it.skipIf(isRoot)( format: "plist", }) .execute("inspect_keyed_archive", {}); - expect(executed.ok).toBe(false); if (executed.ok) throw new Error("expected a denied read"); expect(executed.error).toBeInstanceOf(AnalysisAccessDeniedError); expect(projectAnalysisError(executed.error)).toMatchObject({ diff --git a/src/artifacts/apple/KeyedArchiveReader.test.ts b/src/artifacts/apple/KeyedArchiveReader.test.ts index 0bc815b1d9..ec90701fe7 100644 --- a/src/artifacts/apple/KeyedArchiveReader.test.ts +++ b/src/artifacts/apple/KeyedArchiveReader.test.ts @@ -10,13 +10,9 @@ import { decodeKeyedArchiveBytes, inspectBundleKeyedArchive, } from "./KeyedArchiveReader.js"; -import { - PlistNestingLimitError, - unknownDateLimitation, -} from "../../domain/apple/plistValue.js"; +import { PlistNestingLimitError } from "../../domain/apple/plistValue.js"; import { deeplyNestedXmlPlist } from "../../../tests/fixtures/keyedArchiveXmlNesting.js"; import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js"; -import { scanBinaryPlistScalars } from "./PlistScalars.js"; import { embedSubmillisecondDateInWideIntegerPayload } from "../../../tests/fixtures/binaryPlistScalarAlias.js"; import { readBinaryPlistObjectOffset, @@ -53,6 +49,17 @@ const binaryArchiveWithDate = (): Buffer => }), ); +// Locate the known binary date independently of the scanner under test. +const fixtureDateOffset = (bytes: Buffer, seconds: number): number => { + const encoded = Buffer.alloc(9); + encoded[0] = 0x33; + encoded.writeDoubleBE(seconds, 1); + const offset = bytes.indexOf(encoded); + if (offset < 0 || bytes.indexOf(encoded, offset + 1) !== -1) + throw new Error("binary archive fixture must contain exactly one date"); + return offset; +}; + const binaryArchiveWithOverlappingDate = (): Buffer => { const bytes = Buffer.from( buildBinary({ @@ -65,19 +72,17 @@ const binaryArchiveWithOverlappingDate = (): Buffer => { $top: { root: { UID: 1 } }, }), ); - const date = scanBinaryPlistScalars(bytes).dates[0]; - if (date === undefined) - throw new Error("binary archive fixture lost its date"); - bytes.writeDoubleBE(0.0005, date.payloadOffset); + const dateOffset = fixtureDateOffset(bytes, 0); + bytes.writeDoubleBE(0.0005, dateOffset + 1); const objectTable = readBinaryPlistObjectTableLayout(bytes); for (let objectId = 0; objectId < objectTable.objectCount; objectId += 1) { const offset = readBinaryPlistObjectOffset(bytes, objectTable, objectId); - if (offset !== date.offset && bytes[offset] === 0x40) { + if (offset !== dateOffset && bytes[offset] === 0x40) { writeBinaryPlistObjectOffset( bytes, objectTable, objectId, - date.payloadOffset + 1, + dateOffset + 2, ); return bytes; } @@ -87,14 +92,12 @@ const binaryArchiveWithOverlappingDate = (): Buffer => { const binaryArchiveDateCrossingOffsetTable = (): Buffer => { const bytes = Buffer.from(binaryArchiveWithDate()); - const date = scanBinaryPlistScalars(bytes).dates[0]; - if (date === undefined) - throw new Error("binary archive fixture lost its date"); + const dateOffset = fixtureDateOffset(bytes, 0.1); const objectTable = readBinaryPlistObjectTableLayout(bytes); let dateObjectId = -1; for (let objectId = 0; objectId < objectTable.objectCount; objectId += 1) { if ( - readBinaryPlistObjectOffset(bytes, objectTable, objectId) === date.offset + readBinaryPlistObjectOffset(bytes, objectTable, objectId) === dateOffset ) dateObjectId = objectId; } @@ -585,6 +588,9 @@ const dateScalar = (iso8601: string | null) => ({ value: { $plist_type: "date", iso8601 }, }); +const oneUnknownDate = /\b1 date value.*could not represent.*timestamps/iu; +const twoUnknownDates = /\b2 date value.*could not represent.*timestamps/iu; + describe("binary keyed archive dates", () => { const selection = { offset: 0, limit: 10 }; @@ -594,7 +600,11 @@ describe("binary keyed archive dates", () => { expect(graph.objects[1]).toMatchObject( dateScalar("2001-01-01T00:00:00.100Z"), ); - expect(graph.limitations).not.toContain(unknownDateLimitation(1)); + expect(graph.limitations).not.toContainEqual( + expect.stringMatching( + /date value.*decoder could not represent.*timestamps/iu, + ), + ); expect(Buffer.compare(bytes, pythonBinaryDateControl)).toBe(0); expect(createHash("sha256").update(bytes).digest("hex")).toBe( "39f08db8341bd74220352dfd559485515cce1e6035e08f27a59ab8f856374a30", @@ -609,7 +619,11 @@ describe("binary keyed archive dates", () => { expect(inspected.objects[1]).toMatchObject( dateScalar("2001-01-01T00:00:00.100Z"), ); - expect(inspected.limitations).not.toContain(unknownDateLimitation(1)); + expect(inspected.limitations).not.toContainEqual( + expect.stringMatching( + /date value.*decoder could not represent.*timestamps/iu, + ), + ); expect( Buffer.compare(await readFile(join(root, "archive.plist")), bytes), ).toBe(0); @@ -664,7 +678,9 @@ describe("binary keyed archive dates", () => { expect(JSON.stringify(graph.objects[1]?.value)).not.toContain( "2001-01-01T00:00:00.100Z", ); - expect(graph.limitations).toContain(unknownDateLimitation(1)); + expect(graph.limitations).toContainEqual( + expect.stringMatching(oneUnknownDate), + ); expect(graph.limitations).not.toContainEqual( expect.stringMatching(/number metadata.*could not.*observed/iu), ); @@ -680,7 +696,9 @@ describe("binary keyed archive dates", () => { parameters: { path: "archive.plist" }, }); expect(inspected.objects[1]).toMatchObject(dateScalar(null)); - expect(inspected.limitations).toContain(unknownDateLimitation(1)); + expect(inspected.limitations).toContainEqual( + expect.stringMatching(oneUnknownDate), + ); expect( Buffer.compare( await readFile(join(root, "archive.plist")), @@ -720,7 +738,9 @@ describe("binary keyed archive dates", () => { { $plist_type: "date", iso8601: null }, { $plist_type: "date", iso8601: null }, ]); - expect(mixedGraph.limitations).toContain(unknownDateLimitation(2)); + expect(mixedGraph.limitations).toContainEqual( + expect.stringMatching(twoUnknownDates), + ); expect(Buffer.compare(mixed, mixedOriginal)).toBe(0); }); }); diff --git a/src/artifacts/apple/MachoEncryptionReader.test.ts b/src/artifacts/apple/MachoEncryptionReader.test.ts index e550f55482..a4c0836b99 100644 --- a/src/artifacts/apple/MachoEncryptionReader.test.ts +++ b/src/artifacts/apple/MachoEncryptionReader.test.ts @@ -352,7 +352,9 @@ describe("Mach-O encryption reader: segment mapping", () => { range: { mapping: { status: "unknown", - reason: "load command 0 LC_SEGMENT_64 appears in a 32-bit image", + reason: expect.stringMatching( + /load command 0\b.*LC_SEGMENT_64.*appears.*32-bit/iu, + ), }, }, }); @@ -486,7 +488,9 @@ describe("Mach-O encryption reader: defects are never absent", () => { wide: false, commands: [encryption({ cryptoff: 0, cryptsize: 0, cryptid: 0 })], }), - reason: "load command 0 LC_ENCRYPTION_INFO_64 appears in a 32-bit image", + reason: expect.stringMatching( + /load command 0\b.*LC_ENCRYPTION_INFO_64.*appears.*32-bit/iu, + ), }, { name: "an unexpected cmdsize", @@ -496,8 +500,9 @@ describe("Mach-O encryption reader: defects are never absent", () => { encryption({ cryptoff: 0, cryptsize: 0, cryptid: 0 }, true, 32), ], }), - reason: - "load command 0 LC_ENCRYPTION_INFO_64 has cmdsize 32, expected 24", + reason: expect.stringMatching( + /load command 0\b.*LC_ENCRYPTION_INFO_64.*cmdsize 32\b.*expected 24\b/iu, + ), }, { name: "a range beyond the slice", @@ -669,12 +674,15 @@ describe("Mach-O encryption reader: universal files", () => { }, { status: "malformed", - reason: - "FAT architecture 1 CPU type/subtype disagrees with its Mach-O header", + reason: expect.stringMatching( + /FAT architecture 1\b.*CPU type\/subtype.*disagree.*Mach-O header/iu, + ), }, { status: "malformed", - reason: "FAT architecture 2 slice range extends beyond the file", + reason: expect.stringMatching( + /FAT architecture 2\b.*slice range.*beyond.*file/iu, + ), }, { status: "encrypted", reason: null }, ]); @@ -745,7 +753,9 @@ describe("Mach-O encryption reader: universal files", () => { { cpu_type: CPU.arm64.type, status: "malformed", - reason: "FAT architecture 1 slice range extends beyond the file", + reason: expect.stringMatching( + /FAT architecture 1\b.*slice range.*beyond.*file/iu, + ), commands: [], }, ], @@ -794,7 +804,9 @@ describe("Mach-O encryption reader: large universal files", () => { { container_file_offset: size, status: "malformed", - reason: "FAT architecture 1 slice range extends beyond the file", + reason: expect.stringMatching( + /FAT architecture 1\b.*slice range.*beyond.*file/iu, + ), }, ], }); @@ -802,7 +814,9 @@ describe("Mach-O encryption reader: large universal files", () => { // unresolved JVM identity. expect(await readMachoImage(sparseReadAt, size)).toEqual({ status: "malformed", - reason: "FAT architecture 1 slice range extends beyond the file", + reason: expect.stringMatching( + /FAT architecture 1\b.*slice range.*beyond.*file/iu, + ), }); }); }); @@ -909,8 +923,9 @@ describe("Mach-O encryption reader: mapping budget", () => { ]); expect(facts.slices[1]?.range?.mapping).toEqual({ status: "unknown", - reason: - "mapping needs more than the 5 segment and section records shared by all slices", + reason: expect.stringMatching( + /mapping.*more than.*5 segment and section records.*slices/iu, + ), }); }); }); diff --git a/src/artifacts/apple/MachoLoadCommandReader.test.ts b/src/artifacts/apple/MachoLoadCommandReader.test.ts index 912a6dfa90..3c29eb8387 100644 --- a/src/artifacts/apple/MachoLoadCommandReader.test.ts +++ b/src/artifacts/apple/MachoLoadCommandReader.test.ts @@ -1889,7 +1889,9 @@ describe("Mach-O load command reader failures", () => { view.setUint32(4, 8, true); expect(await read(machoImage({ commands: [short] }))).toMatchObject({ status: "malformed", - reason: "load command 0 is too short to hold a string offset", + reason: expect.stringMatching( + /load command 0\b.*too short.*string offset/iu, + ), }); view.setUint32(0, LC.CODE_SIGNATURE, true); expect(await read(machoImage({ commands: [short] }))).toMatchObject({ @@ -1943,7 +1945,9 @@ describe("Mach-O load command reader failures", () => { const fat = fatImage([{ cpu: CPU.arm64, bytes: machoImage({}) }]); expect(await read(fat.subarray(0, 4100))).toMatchObject({ status: "malformed", - reason: "FAT architecture 0 slice range extends beyond the file", + reason: expect.stringMatching( + /FAT architecture 0\b.*slice range.*beyond.*file/iu, + ), }); }); @@ -1968,7 +1972,9 @@ describe("Mach-O load command reader defect precedence", () => { new DataView(unsized.buffer).setUint32(0, LC.RPATH, true); const decodeFirst = { status: "malformed", - reason: "load command 0 is too short to hold a string offset", + reason: expect.stringMatching( + /load command 0\b.*too short.*string offset/iu, + ), }; // An earlier command's decode defect wins over a later framing defect, expect(await read(machoImage({ commands: [shortRpath, unsized] }))).toEqual( @@ -2019,7 +2025,9 @@ describe("Mach-O load command reader defect precedence", () => { new DataView(ranged.buffer).setUint32(8 + 20 + 12, ranged.length, false); expect(await read(ranged)).toEqual({ status: "unsupported", - reason: "FAT architecture 0 alignment exponent 53 is unsupported", + reason: expect.stringMatching( + /FAT architecture 0\b.*alignment exponent 53\b.*unsupported/iu, + ), }); }); }); diff --git a/src/artifacts/apple/PlistScalars.test.ts b/src/artifacts/apple/PlistScalars.test.ts index 869e1d2dfa..90359fbda9 100644 --- a/src/artifacts/apple/PlistScalars.test.ts +++ b/src/artifacts/apple/PlistScalars.test.ts @@ -540,8 +540,12 @@ describe("binary plist numeric association", () => { 9007199254740992, 9007199254740992, ]); expect(numbers.limitations()).toEqual([ - '1 observed integer literal(s) in the original archive exceed the exact range of a JSON number. Decoded numbers may lose integer precision unless represented as { "$plist_type": "integer", "decimal": "" }; the original archive bytes retain those literals.', - "2 number(s) beyond the exact integer range remain as decoded because their source integer/real type or reference marker cannot be associated unambiguously; integer precision loss remains possible.", + expect.stringMatching( + /\b1 observed integer literal.*original archive.*JSON number.*lose integer precision.*\$plist_type.*integer.*decimal.*original archive bytes retain/iu, + ), + expect.stringMatching( + /\b2 number.*integer range.*source integer\/real type.*cannot be associated unambiguously.*precision loss/iu, + ), ]); }); diff --git a/src/artifacts/apple/PropertyListDecodeBudget.test.ts b/src/artifacts/apple/PropertyListDecodeBudget.test.ts index e39b88868c..12206f0c36 100644 --- a/src/artifacts/apple/PropertyListDecodeBudget.test.ts +++ b/src/artifacts/apple/PropertyListDecodeBudget.test.ts @@ -14,7 +14,6 @@ it("refuses an XML plist whose DOM exceeds the native decode budget", () => { const parsed = parsePlistXmlSource( xmlPlist(`\n${"\n".repeat(100_000)}\n`), ); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected a decode budget refusal"); expect(parsed.error).toBeInstanceOf(AnalysisResourceConstraintError); expect(parsed.error.message).toContain("native plist decode budget"); @@ -28,7 +27,6 @@ it.each(["é", "_", ":", "雪", "\u{1d4b3}"])( const parsed = parsePlistXmlSource( xmlPlist(`${`<${name}/>`.repeat(100_000)}`), ); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected a decode budget refusal"); expect(parsed.error).toBeInstanceOf(AnalysisResourceConstraintError); }, @@ -38,7 +36,6 @@ it("refuses text whose entity references exceed the decode budget", () => { const parsed = parsePlistXmlSource( xmlPlist(`${"&".repeat(1_000_000)}`), ); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected a decode budget refusal"); expect(parsed.error).toBeInstanceOf(AnalysisResourceConstraintError); }); diff --git a/src/artifacts/bun/BunModuleGraph.test.ts b/src/artifacts/bun/BunModuleGraph.test.ts index 55e2aa8282..91c4fd2cd6 100644 --- a/src/artifacts/bun/BunModuleGraph.test.ts +++ b/src/artifacts/bun/BunModuleGraph.test.ts @@ -3,13 +3,13 @@ import { join } from "node:path"; import { expect, it, vi } from "vitest"; import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js"; import { - locateBunStandaloneGraph, probeBunStandaloneGraph, bunModuleCountLimit, BUN_GRAPH_SUFFIX_BYTES, } from "./BunModuleGraphLayout.js"; import { decodeBunModuleGraph } from "./BunModuleGraphMembers.js"; import { + locateBunGraphFixture, bunModuleGraphPayload, bunPrefixedPayload, machoBunSection, @@ -25,7 +25,7 @@ async function locate(bytes: Buffer) { await writeFile(path, bytes); const handle = await open(path, "r"); try { - const result = await locateBunStandaloneGraph(handle, bytes.length); + const result = await locateBunGraphFixture(handle, bytes.length); if (result.status === "present" && result.graph !== undefined) { const graph = result.graph; return { diff --git a/src/artifacts/bun/BunModuleGraphLayout.ts b/src/artifacts/bun/BunModuleGraphLayout.ts index 51e20e68e5..2b9270205f 100644 --- a/src/artifacts/bun/BunModuleGraphLayout.ts +++ b/src/artifacts/bun/BunModuleGraphLayout.ts @@ -124,17 +124,6 @@ interface SectionWindow { readonly truncated: boolean; } -/** Probe, then read the one claimed payload. */ -export const locateBunStandaloneGraph = async ( - handle: FileHandle, - fileSize: number, - signal?: AbortSignal, -): Promise => { - const probed = await probeBunStandaloneGraph(handle, fileSize, signal); - if (probed.status === "absent" || probed.claim === undefined) return probed; - return loadBunStandaloneGraph(handle, probed.claim, signal); -}; - /** * Locate at most one graph claim with bounded reads of headers, length * prefixes, and suffixes. Payload data is not read. Multiple real claims are diff --git a/src/artifacts/bun/BunStandalone.fixture.ts b/src/artifacts/bun/BunStandalone.fixture.ts index d770de6e9d..bc73f6b5db 100644 --- a/src/artifacts/bun/BunStandalone.fixture.ts +++ b/src/artifacts/bun/BunStandalone.fixture.ts @@ -1,12 +1,26 @@ +import type { FileHandle } from "node:fs/promises"; import { BUN_OFFSETS_BYTES, BUN_RECORD_BYTES_1_3_3, BUN_RECORD_BYTES_1_3_9, BUN_TRAILER, + loadBunStandaloneGraph, + probeBunStandaloneGraph, type BunLayoutRevision, + type BunStandaloneRecognition, type BunStringPointer, } from "./BunModuleGraphLayout.js"; +/** Exercise the same two-stage probe and payload read as the artifact reader. */ +export const locateBunGraphFixture = async ( + handle: FileHandle, + fileSize: number, +): Promise => { + const probed = await probeBunStandaloneGraph(handle, fileSize); + if (probed.status === "absent" || probed.claim === undefined) return probed; + return loadBunStandaloneGraph(handle, probed.claim); +}; + export interface BunFixtureModule { readonly name?: string | Buffer; readonly contents?: Buffer; diff --git a/src/artifacts/inventory/ArtifactInventoryFinalization.test.ts b/src/artifacts/inventory/ArtifactInventoryFinalization.test.ts index 1b484db159..6f5da4a287 100644 --- a/src/artifacts/inventory/ArtifactInventoryFinalization.test.ts +++ b/src/artifacts/inventory/ArtifactInventoryFinalization.test.ts @@ -194,7 +194,6 @@ it.each(["inventory_artifact", "inspect_artifact"] as const)( {}, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected provider cancellation"); expect(projectAnalysisError(result.error).code).toBe("cancelled"); expect(result.error.cause).toBe(reason); diff --git a/src/artifacts/pyinstaller/MarshalSubset.test.ts b/src/artifacts/pyinstaller/MarshalSubset.test.ts index ff91f16c71..62832ad7c0 100644 --- a/src/artifacts/pyinstaller/MarshalSubset.test.ts +++ b/src/artifacts/pyinstaller/MarshalSubset.test.ts @@ -83,7 +83,7 @@ it.each([ ok: false, error: { reason: "format", - message: "PYZ marshal string is not valid UTF-8", + message: expect.stringContaining("UTF-8"), }, }); }); @@ -127,7 +127,7 @@ it.each(["6c0200000003000000", "6cfeffffff03000000"])( ok: false, error: { reason: "format", - message: "PYZ marshal long is not normalized", + message: expect.stringMatching(/long.*not normalized/iu), }, }); }, diff --git a/src/artifacts/pyinstaller/PyInstallerArtifactReader.test.ts b/src/artifacts/pyinstaller/PyInstallerArtifactReader.test.ts index 7dc67426a2..98d850b1c6 100644 --- a/src/artifacts/pyinstaller/PyInstallerArtifactReader.test.ts +++ b/src/artifacts/pyinstaller/PyInstallerArtifactReader.test.ts @@ -922,7 +922,7 @@ it("retains the descriptor owner when admission cleanup fails", async () => { reader.entries()[Symbol.asyncIterator]().next(), ).rejects.toMatchObject({ reason: "format", - message: `PyInstaller source is not a regular file: ${directory}`, + message: expect.stringContaining(directory), cleanup: { reason: closeFailure.message, resources: [directory], diff --git a/src/artifacts/pyinstaller/PyInstallerBoundaries.test.ts b/src/artifacts/pyinstaller/PyInstallerBoundaries.test.ts index 2c948fcac4..4261486754 100644 --- a/src/artifacts/pyinstaller/PyInstallerBoundaries.test.ts +++ b/src/artifacts/pyinstaller/PyInstallerBoundaries.test.ts @@ -311,7 +311,7 @@ it.each(["ENOENT", "ENOTDIR"] as const)( ); expect(cause).toMatchObject({ reason: "integrity", - message: `PyInstaller source identity changed: ${path}`, + message: expect.stringContaining(path), }); expect( projectAnalysisError( @@ -321,7 +321,7 @@ it.each(["ENOENT", "ENOTDIR"] as const)( category: "integrity_mismatch", details: { reason: "integrity", - detail: `PyInstaller source identity changed: ${path}`, + detail: expect.stringContaining(path), }, }); } @@ -700,7 +700,6 @@ for (const cancel of [false, true]) { release.resolve(); const result = await reading; if (failClose || cancel) { - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected read failure"); expect(result.cause).toMatchObject( failClose @@ -709,7 +708,6 @@ for (const cancel of [false, true]) { ); if (failClose) expect(owner?.handle.fd).toBeGreaterThanOrEqual(0); } else { - expect(result.ok).toBe(true); if (!result.ok) throw result.cause; expect( Buffer.compare(result.value.subarray(16), Buffer.from("body")), diff --git a/src/artifacts/pyinstaller/PyInstallerFileAdmission.test.ts b/src/artifacts/pyinstaller/PyInstallerFileAdmission.test.ts index 13f4ec1afa..37be959f7b 100644 --- a/src/artifacts/pyinstaller/PyInstallerFileAdmission.test.ts +++ b/src/artifacts/pyinstaller/PyInstallerFileAdmission.test.ts @@ -20,7 +20,7 @@ it("classifies a source replacement during admission as an integrity failure", a await expect(reader.prepareContainer("0".repeat(64))).rejects.toMatchObject( { reason: "integrity", - message: `PyInstaller source changed during admission: ${path}`, + message: expect.stringContaining(path), }, ); expect(openRegularFile).toHaveBeenCalledWith(path, { diff --git a/src/artifacts/pyinstaller/PyzArchive.test.ts b/src/artifacts/pyinstaller/PyzArchive.test.ts index 51084534c6..a54dd7f6c4 100644 --- a/src/artifacts/pyinstaller/PyzArchive.test.ts +++ b/src/artifacts/pyinstaller/PyzArchive.test.ts @@ -176,7 +176,10 @@ it("reports a truncated table before deferred signature rejection", async () => header.writeUInt32BE(12, 8); expect(await readImage(header, 16)).toMatchObject({ ok: false, - error: { reason: "format", message: "PYZ table is truncated" }, + error: { + reason: "format", + message: expect.stringMatching(/table.*truncated/iu), + }, }); }); @@ -185,7 +188,10 @@ it("reports the signature after completing a readable table and image hash", asy image.write("BAD\0"); expect(await readImage(image)).toMatchObject({ ok: false, - error: { reason: "format", message: "PYZ archive magic does not match" }, + error: { + reason: "format", + message: expect.stringMatching(/magic.*match/iu), + }, }); }); diff --git a/src/browser/CdpBrowserProvider.admission.test.ts b/src/browser/CdpBrowserProvider.admission.test.ts index c5f4a4d0c3..d09c44aba0 100644 --- a/src/browser/CdpBrowserProvider.admission.test.ts +++ b/src/browser/CdpBrowserProvider.admission.test.ts @@ -26,7 +26,6 @@ it("shares a capture limit when browser providers use one admission", async () = const pending = first.analyzeBundle(input); const blocked = await second.analyzeBundle(input); try { - expect(blocked.ok).toBe(false); if (blocked.ok) throw new Error("expected the shared admission to refuse"); expect(projectAnalysisError(blocked.error)).toMatchObject({ code: "resource_constraint", @@ -52,7 +51,6 @@ it("does not share a capture limit across browser providers", async () => { const other = second.analyzeBundle(input); try { const blocked = await other; - expect(blocked.ok).toBe(false); if (blocked.ok) throw new Error("expected capture to fail closed"); expect(projectAnalysisError(blocked.error).code).not.toBe( "resource_constraint", diff --git a/src/browser/CdpDiscoveryTargets.test.ts b/src/browser/CdpDiscoveryTargets.test.ts index 3b7eabb892..5ad4fc41ea 100644 --- a/src/browser/CdpDiscoveryTargets.test.ts +++ b/src/browser/CdpDiscoveryTargets.test.ts @@ -203,7 +203,6 @@ it.each( target_id: "duplicate", observation_ms: 0, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected ambiguous target rejection"); expect(result.error).toBeInstanceOf(BrowserObservationError); expect(result.error.userMessage).toContain("ambiguous"); diff --git a/src/browser/ElectronFileScope.cleanup.test.ts b/src/browser/ElectronFileScope.cleanup.test.ts index a8c24631a0..54fa57d25f 100644 --- a/src/browser/ElectronFileScope.cleanup.test.ts +++ b/src/browser/ElectronFileScope.cleanup.test.ts @@ -140,7 +140,6 @@ it("retains Inspector scripts and contexts when final ASAR authorization cannot }; try { const control = await observeJavaScriptRuntime(provider, input); - expect(control.ok).toBe(true); if (!control.ok) throw control.error; expect(control.value.normalized_result).toMatchObject({ scripts: { observed_total: 1 }, @@ -149,7 +148,6 @@ it("retains Inspector scripts and contexts when final ASAR authorization cannot await prependAsarJsonWhitespace(archive, " "); handleState.failCloseCount = 1; const result = await observeJavaScriptRuntime(provider, input); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected descriptor close failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.partialObservation).toMatchObject({ diff --git a/src/browser/IsolatedWebBundleAnalyzer.test.ts b/src/browser/IsolatedWebBundleAnalyzer.test.ts index 560f2b6c91..cc13079386 100644 --- a/src/browser/IsolatedWebBundleAnalyzer.test.ts +++ b/src/browser/IsolatedWebBundleAnalyzer.test.ts @@ -63,7 +63,6 @@ it("preserves completed prefix and suffix facts when one script times out", asyn expect(calls).toEqual( captured.scripts.items.map(({ script_key }) => script_key), ); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect( result.value.observations.chunks.edges.map(({ specifier }) => specifier), @@ -114,7 +113,6 @@ it("marks the unstarted suffix when the aggregate deadline expires", async () => expect(calls).toEqual( captured.scripts.items.slice(0, 2).map(({ script_key }) => script_key), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected total deadline failure"); expect(result.error._tag).toBe("AnalysisTimeoutError"); expect(result.error.partialObservation).toMatchObject({ @@ -176,7 +174,6 @@ it("stops after a middle-script result-capacity failure and retains prefix facts expect(calls).toEqual( captured.scripts.items.slice(0, 2).map(({ script_key }) => script_key), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected result-capacity failure"); expect(result.error).toBe(primary); expect(result.error.partialObservation).toMatchObject({ @@ -234,7 +231,6 @@ it("carries the exact caller cancellation reason and completed prefix facts", as const result = await pending; analyzer.releaseReservation(); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(exactReason); @@ -276,7 +272,6 @@ it("retains all completed facts when cancellation arrives during worker close", const result = await pending; analyzer.releaseReservation(); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation during finalization"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.partialObservation).toMatchObject({ @@ -316,7 +311,6 @@ it("retains cleanup ownership after mixed worker/close failure and resolves it o expect((await analyzer.reserve()).ok).toBe(true); const result = await analyzer.analyze(captured, noSourceMaps, input); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected mixed failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupPrimary).toBe(primary); @@ -347,7 +341,6 @@ it("shares one capture reservation when analyzers use one admission", async () = const second = new IsolatedWebBundleAnalyzer(() => inertWorker(), admission); expect((await first.reserve()).ok).toBe(true); const blocked = await second.reserve(); - expect(blocked.ok).toBe(false); if (blocked.ok) throw new Error("Expected shared admission refusal"); expect(projectAnalysisError(blocked.error)).toMatchObject({ code: "resource_constraint", diff --git a/src/browser/PlaywrightElectronActiveProvider.test.ts b/src/browser/PlaywrightElectronActiveProvider.test.ts index e3f7ec6a19..f17f6ec38a 100644 --- a/src/browser/PlaywrightElectronActiveProvider.test.ts +++ b/src/browser/PlaywrightElectronActiveProvider.test.ts @@ -318,7 +318,6 @@ it("retains the partial capture without taskkill when Windows lineage is unavail application_root: dirname(process.execPath), }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected unverified cleanup to fail"); expect(terminateTree).not.toHaveBeenCalled(); expect(result.error).toMatchObject({ @@ -379,7 +378,6 @@ it("retains the initial snapshot when the final state read fails", async () => { application_root: dirname(process.execPath), }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected final state capture to fail"); const partialObservation = result.error.partialObservation; expect(partialObservation).toMatchObject({ @@ -412,7 +410,6 @@ it("rejects active capture before launch when EnableNodeCliInspectArguments fuse application_root: root, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected capture to fail"); expect(launchSpy).not.toHaveBeenCalled(); expect(result.error).toMatchObject({ @@ -509,7 +506,6 @@ it("cancels a windowless wait action and cleans up the owned application", async expect(application.firstWindow).toHaveBeenCalledOnce(); expect(application.close).toHaveBeenCalledOnce(); expect(cleanupSpies.some((spy) => spy.mock.calls.length > 0)).toBe(true); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the capture to be cancelled"); expect(result.error).toMatchObject({ _tag: "BrowserObservationError", @@ -621,7 +617,6 @@ it("cancels a pending initial state read and cleans up the owned application", a expect(application.close).toHaveBeenCalledOnce(); expect(cleanupSpies.some((spy) => spy.mock.calls.length > 0)).toBe(true); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the capture to be cancelled"); expect(result.error).toMatchObject({ _tag: "BrowserObservationError", @@ -666,7 +661,6 @@ it("observes an initial state read started after cancellation and rejected by cl expect(application.close).toHaveBeenCalledOnce(); expect(cleanupSpies.some((spy) => spy.mock.calls.length > 0)).toBe(true); expect(unhandled).toEqual([]); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the capture to be cancelled"); expect(result.error).toMatchObject({ _tag: "BrowserObservationError", @@ -703,7 +697,6 @@ it("keeps a failure observed with cancellation as the cancellation cause", async const result = await captureWithController(controller, application, []); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the capture to be cancelled"); expect(result.error).toMatchObject({ _tag: "BrowserObservationError", @@ -742,7 +735,6 @@ it("reports an expired final state grace period as the caller's cancellation", a await vi.advanceTimersByTimeAsync(5_000); const result = await capture; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the capture to be cancelled"); expect(result.error).toMatchObject({ _tag: "BrowserObservationError", @@ -795,7 +787,6 @@ it("cancels a completed capture when cancellation arrives during application clo const result = await captureWithController(controller, application, []); expect(application.close).toHaveBeenCalledOnce(); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the capture to be cancelled"); expect(result.error).toMatchObject({ _tag: "BrowserObservationError", @@ -838,7 +829,6 @@ it("cancels a completed capture when cancellation arrives during process cleanup const result = await captureWithController(controller, application, []); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the capture to be cancelled"); expect(result.error).toMatchObject({ _tag: "BrowserObservationError", @@ -873,7 +863,6 @@ it("keeps cleanup failure precedence over cancellation observed during cleanup", const result = await captureWithController(controller, application, []); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cleanup to fail"); expect(result.error).toMatchObject({ cleanupIncomplete: true, @@ -925,7 +914,6 @@ it.each(["process", "transport"] as const)( const result = await captureWithController(controller, application, []); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected incomplete cleanup"); expect(result.error).toMatchObject({ cleanupIncomplete: true, diff --git a/src/browser/WebBundleAnalysisWorker.test.ts b/src/browser/WebBundleAnalysisWorker.test.ts index 47770d9732..6d405f3e07 100644 --- a/src/browser/WebBundleAnalysisWorker.test.ts +++ b/src/browser/WebBundleAnalysisWorker.test.ts @@ -1019,7 +1019,6 @@ it("preserves literal replacement characters in valid UTF-8 worker facts", async makeScript("fetch('/literal-�');"), 10_000, ); - expect(result.ok).toBe(true); if (!result.ok) throw new Error(result.error.error.message); if (result.value.status !== "analyzed") throw new Error("Expected analyzed worker facts"); diff --git a/src/browser/WebBundleAnalysisWorkerCapacity.test.ts b/src/browser/WebBundleAnalysisWorkerCapacity.test.ts index 805fca7a61..4b79d190a6 100644 --- a/src/browser/WebBundleAnalysisWorkerCapacity.test.ts +++ b/src/browser/WebBundleAnalysisWorkerCapacity.test.ts @@ -48,7 +48,6 @@ it("refuses before spawning or reading source when no host result capacity remai try { const result = await worker.analyze(script, 10_000); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected result-capacity refusal"); const refusal = result.error.error; expect(refusal).toBeInstanceOf(AnalysisResourceConstraintError); diff --git a/src/browser/WebBundleAnalysisWorkerReadCompletion.test.ts b/src/browser/WebBundleAnalysisWorkerReadCompletion.test.ts index 66b6531c6b..08f009da7e 100644 --- a/src/browser/WebBundleAnalysisWorkerReadCompletion.test.ts +++ b/src/browser/WebBundleAnalysisWorkerReadCompletion.test.ts @@ -144,7 +144,6 @@ it("retains completed facts and resolves a result-file lease through another cle makeScript("fetch('/retained');"), 10_000, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained result cleanup failure"); expect(result.error.completed).toMatchObject({ status: "analyzed", diff --git a/src/browser/history/CaptureFailures.test.ts b/src/browser/history/CaptureFailures.test.ts index 7cc337a110..b0923ea67c 100644 --- a/src/browser/history/CaptureFailures.test.ts +++ b/src/browser/history/CaptureFailures.test.ts @@ -8,7 +8,7 @@ import { projectAnalysisError } from "../../domain/analysisErrorProjection.js"; import { analysisErrorProjectionSchema } from "../../contracts/errorSchemas.js"; import { inspectWebNetworkCaptureInputSchema } from "../../domain/webNetworkCapture.js"; import { historicalCaptureFailure } from "./CaptureFailures.js"; -import { NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES } from "./CaptureRelease.js"; +import { NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES } from "../../../tests/fixtures/captureDecoderLimits.js"; import { redactExplicitFailure } from "../../domain/explicitSensitiveFailure.js"; import { OwnedCommandFailure } from "../../process/OwnedCommand.js"; diff --git a/src/browser/history/CaptureRelease.ts b/src/browser/history/CaptureRelease.ts index 2702622e0e..dbb0c5fff6 100644 --- a/src/browser/history/CaptureRelease.ts +++ b/src/browser/history/CaptureRelease.ts @@ -24,10 +24,4 @@ export const captureDecoderProcessMemoryLimitBytes = ( export const NODE_CAPTURE_HEAP_ENFORCED = javaScriptRuntime(process.versions).id === "node"; -/** Commit limit for the default heap. A configured heap uses `captureDecoderProcessMemoryLimitBytes`. */ -export const NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES = - captureDecoderProcessMemoryLimitBytes( - NODE_CAPTURE_HEAP_LIMITS.oldGenerationMiB, - ); - /** Fixed offline interpretation profile, not an authenticated producer claim. */ diff --git a/src/browser/history/playwrightTrace/PlaywrightTraceDecoder.test.ts b/src/browser/history/playwrightTrace/PlaywrightTraceDecoder.test.ts index ab69545992..010ace91e7 100644 --- a/src/browser/history/playwrightTrace/PlaywrightTraceDecoder.test.ts +++ b/src/browser/history/playwrightTrace/PlaywrightTraceDecoder.test.ts @@ -217,7 +217,6 @@ it("refuses other declared trace versions with verified archive identity", async const result = await new PlaywrightTraceDecoder(resources).inspect( fixture.path, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected version refusal"); expect(result.error._tag).toBe("AnalysisUnsupportedTargetError"); expect( @@ -239,7 +238,6 @@ it("preserves opaque pre-cancellation without reading or claiming a source snaps "/unused.zip", controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -307,7 +305,6 @@ it("refuses oversized physical lines before parsing their representation", async const result = await new PlaywrightTraceDecoder(resources).inspect( fixture.path, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected line capacity refusal"); expect(result.error._tag).toBe("AnalysisResourceConstraintError"); expect(resources.hasPending).toBe(false); @@ -329,7 +326,6 @@ it("never promotes facts from a stream whose ZIP CRC fails", async () => { const result = await new PlaywrightTraceDecoder(resources).inspect( fixture.path, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected CRC refusal"); expect(result.error._tag).toBe("AnalysisInputError"); const partial = playwrightTraceSchema.parse( @@ -354,7 +350,6 @@ it("rejects a sparse over-budget archive before hashing or expansion", async () const result = await new PlaywrightTraceDecoder(resources).inspect( fixture.path, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected archive admission refusal"); expect(result.error._tag).toBe("AnalysisResourceConstraintError"); expect(result.error.partialObservation).toBeUndefined(); @@ -378,7 +373,6 @@ it("bounds JSON node expansion even when many tokens fit inside a small physical const result = await new PlaywrightTraceDecoder(resources).inspect( fixture.path, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected node admission refusal"); expect(result.error._tag).toBe("AnalysisResourceConstraintError"); expect(resources.hasPending).toBe(false); diff --git a/src/browser/history/playwrightTrace/PlaywrightTraceLifecycle.test.ts b/src/browser/history/playwrightTrace/PlaywrightTraceLifecycle.test.ts index 3ad648df98..cd24739c3d 100644 --- a/src/browser/history/playwrightTrace/PlaywrightTraceLifecycle.test.ts +++ b/src/browser/history/playwrightTrace/PlaywrightTraceLifecycle.test.ts @@ -26,7 +26,6 @@ it("preserves only fully verified streams when cancellation arrives before the n const result = await new PlaywrightTraceService( new PlaywrightTraceDecoder(resources), ).inspect({ path: fixture.path }, controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -61,7 +60,6 @@ it("retains complete Evidence and the exact failed reader owner when abort arriv const result = await new PlaywrightTraceService( new PlaywrightTraceDecoder(resources), ).inspect({ path: fixture.path }, controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected composed failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupPrimary?._tag).toBe("AnalysisCancelledError"); @@ -101,7 +99,6 @@ it("keeps completed Evidence on cancellation during the outer descriptor close", const result = await new PlaywrightTraceService( new PlaywrightTraceDecoder(resources), ).inspect({ path: fixture.path }, controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -136,7 +133,6 @@ it("keeps an existing unsupported-version failure ahead of cancellation during c fixture.path, controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected version refusal"); expect(controller.signal.aborted).toBe(true); expect(result.error._tag).toBe("AnalysisUnsupportedTargetError"); @@ -166,7 +162,6 @@ it("retains independent reader and file owners until both cleanup retries comple const result = await new PlaywrightTraceService( new PlaywrightTraceDecoder(resources), ).inspect({ path: fixture.path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cleanup failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(resources.cleanupResources).toHaveLength(2); @@ -216,7 +211,6 @@ it.skipIf(process.platform === "win32")( const result = await new PlaywrightTraceDecoder(resources).inspect( fixture.path, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected source identity refusal"); expect(result.error._tag).toBe("AnalysisArtifactChangedError"); expect((await readFile(held)).equals(original)).toBe(true); @@ -248,7 +242,6 @@ it("bounds active imports without an unbounded queue and releases admission afte try { await reached.promise; const second = await port.inspect(fixture.path); - expect(second.ok).toBe(false); if (second.ok) throw new Error("Expected capacity refusal"); expect(second.error._tag).toBe("AnalysisResourceConstraintError"); release.resolve(); diff --git a/src/cli/cliOutputFormatter.ts b/src/cli/cliOutputFormatter.ts index 7da8b79496..0e354ddaad 100644 --- a/src/cli/cliOutputFormatter.ts +++ b/src/cli/cliOutputFormatter.ts @@ -227,18 +227,6 @@ export const delimitedOutputInputError = ( { path, reason: "invalid_value", message }, ]); -/** Render a validated row page, preceded by a versioned metadata record. */ -export const formatDelimitedRows = ( - rows: unknown, - format: "csv" | "tsv", - options: CliDelimitedOutputOptions, -): Result => { - const prepared = prepareDelimitedOutput(rows, format, options); - return prepared.ok - ? ok([...formatDelimitedOutputParts(prepared.value)].join("")) - : prepared; -}; - /** Stream a page after its rows and cells have been validated and snapshotted. */ export function* formatDelimitedOutputParts({ encodedHeaders, diff --git a/src/config.test.ts b/src/config.test.ts index a9e3ea9661..ff9072a3b6 100644 --- a/src/config.test.ts +++ b/src/config.test.ts @@ -38,7 +38,6 @@ it.each([ REA_GHIDRA_CHECKPOINT_DIR: "/tmp/checkpoints", [setting]: value, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("conflicting inputs accepted"); expect(result.error.message).toContain("checkpoints"); expect(result.error).toMatchObject({ @@ -70,7 +69,6 @@ it.each([ parseEnvironmentValues(environment), parseConfig(environment), ]) { - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected invalid environment"); expect(result.error.settings).toHaveLength(1); expect(result.error.settings[0]?.constraint).toContain("NUL"); diff --git a/src/config/captureDecoderHeap.test.ts b/src/config/captureDecoderHeap.test.ts index 954851f7de..ecb47ee55d 100644 --- a/src/config/captureDecoderHeap.test.ts +++ b/src/config/captureDecoderHeap.test.ts @@ -20,7 +20,6 @@ import { parseConfig } from "./parseConfig.js"; import { CAPTURE_DECODER_OLD_GENERATION_SETTING, captureDecoderHeapConstraint, - captureDecoderHeapRecovery, DEFAULT_CAPTURE_DECODER_HEAP, parseCaptureDecoderHeap, } from "./captureDecoderHeap.js"; @@ -97,9 +96,15 @@ it("uses a valid REA_CAPTURE_DECODER_OLD_GENERATION_MIB override", async () => { code: "resource_constraint", details: { resource: "memory" }, }); - expect(projected.remediation.action).toContain( - captureDecoderHeapRecovery(configured(256)), + expect(projected.remediation.action).toMatch( + /REA_CAPTURE_DECODER_OLD_GENERATION_MIB.*256 MiB.*source setting/iu, ); + expect(projected.remediation.action).toContain("--max-old-space-size=256"); + expect(projected.remediation.action).toMatch( + /floor 8 MiB.*maximum 16384 MiB/iu, + ); + expect(projected.remediation.action).toContain("update_analysis_settings"); + expect(projected.remediation.action).toMatch(/restart REA/iu); if (process.versions.bun === undefined) expect(projected.details).toMatchObject({ limit: { @@ -163,16 +168,19 @@ it("reports the heap the selected adapter launches when decoder environment diff if (!reported.ok) throw new Error(projectAnalysisError(reported.error).message); const limitations = reported.value.limitations.join("\n"); - expect(limitations).toContain(captureDecoderHeapRecovery(launched.heap)); + expect(limitations).toMatch( + /REA_CAPTURE_DECODER_OLD_GENERATION_MIB.*256 MiB.*source setting/iu, + ); vi.spyOn(launched, "command").mockRejectedValue(heapExhaustion()); const exhausted = await decoder.inspect(input); if (exhausted.ok) throw new Error("Heap exhaustion must fail inspection"); const projected = projectAnalysisError(exhausted.error); expect(projected.code).toBe("resource_constraint"); - expect(projected.remediation.action).toContain( - captureDecoderHeapRecovery(launched.heap), + expect(projected.remediation.action).toMatch( + /REA_CAPTURE_DECODER_OLD_GENERATION_MIB.*256 MiB.*source setting/iu, ); + expect(projected.remediation.action).toContain("--max-old-space-size=256"); if (process.versions.bun === undefined) expect(projected.details).toMatchObject({ limit: { diff --git a/src/config/mcpInputBudget.test.ts b/src/config/mcpInputBudget.test.ts index 993ca2e08b..b0285610af 100644 --- a/src/config/mcpInputBudget.test.ts +++ b/src/config/mcpInputBudget.test.ts @@ -34,7 +34,6 @@ it.each([ "9007199254740992", ])("refuses invalid allowance %s without disabling admission", (value) => { const parsed = parseMcpInputBudget(value); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Invalid admission setting was accepted"); expect(parsed.error).toBeInstanceOf(ConfigurationError); expect(parsed.error.settings).toEqual([ diff --git a/src/config/regexMatchingDeadline.test.ts b/src/config/regexMatchingDeadline.test.ts index d9491d4539..b9042a0e78 100644 --- a/src/config/regexMatchingDeadline.test.ts +++ b/src/config/regexMatchingDeadline.test.ts @@ -5,10 +5,7 @@ import { KunaProvider } from "../kuna/KunaProvider.js"; import { silentLogger } from "../logger.js"; import { ConfigurationError } from "../domain/configurationErrors.js"; import { projectAnalysisError } from "../domain/analysisErrorProjection.js"; -import { - regexMatchingDeadlineError, - launchRegexMatchingLimitation, -} from "../process/RegexMatcher.js"; +import { regexMatchingDeadlineError } from "../process/RegexMatcher.js"; import { parseEnvironment } from "./environment.js"; import { parseConfig } from "./parseConfig.js"; import { @@ -85,12 +82,7 @@ it("uses a valid REA_REGEX_MATCHING_DEADLINE_MS override", () => { .capabilities() .find((capability) => capability.operation === "search_procedures") ?.limitations.join(" "); - expect(hopperText).toContain( - launchRegexMatchingLimitation( - parsed.value.regexMatchingDeadline, - parsed.value.regexWorkerHeapRequest, - ), - ); + expect(hopperText).toMatch(/10000 ms matching deadline.*source setting/iu); vi.stubEnv(REGEX_MATCHING_DEADLINE_SETTING, "1"); try { @@ -99,12 +91,7 @@ it("uses a valid REA_REGEX_MATCHING_DEADLINE_MS override", () => { .capabilities() .find((capability) => capability.operation === "search_strings") ?.limitations.join(" "); - expect(kunaText).toContain( - launchRegexMatchingLimitation( - parsed.value.regexMatchingDeadline, - parsed.value.regexWorkerHeapRequest, - ), - ); + expect(kunaText).toMatch(/10000 ms matching deadline.*source setting/iu); } finally { vi.unstubAllEnvs(); } @@ -115,7 +102,9 @@ it("uses a valid REA_REGEX_MATCHING_DEADLINE_MS override", () => { .capabilities() .find((capability) => capability.operation === "search_procedures") ?.limitations, - ).toContain(launchRegexMatchingLimitation()); + ).toContainEqual( + expect.stringMatching(/5000 ms matching deadline.*source default/iu), + ); }); it.each([ diff --git a/src/config/regexWorkerHeapRequest.test.ts b/src/config/regexWorkerHeapRequest.test.ts index 1a2b91b466..a5796572c9 100644 --- a/src/config/regexWorkerHeapRequest.test.ts +++ b/src/config/regexWorkerHeapRequest.test.ts @@ -5,10 +5,7 @@ import { KunaProvider } from "../kuna/KunaProvider.js"; import { silentLogger } from "../logger.js"; import { ConfigurationError } from "../domain/configurationErrors.js"; import { projectAnalysisError } from "../domain/analysisErrorProjection.js"; -import { - regexWorkerHeapError, - launchRegexMatchingLimitation, -} from "../process/RegexMatcher.js"; +import { regexWorkerHeapError } from "../process/RegexMatcher.js"; import { parseEnvironment } from "./environment.js"; import { parseConfig } from "./parseConfig.js"; import { @@ -99,12 +96,7 @@ it("uses a valid REA_REGEX_WORKER_HEAP_REQUEST_MIB override", () => { .capabilities() .find((capability) => capability.operation === "search_procedures") ?.limitations.join(" "); - expect(hopperText).toContain( - launchRegexMatchingLimitation( - parsed.value.regexMatchingDeadline, - parsed.value.regexWorkerHeapRequest, - ), - ); + expect(hopperText).toMatch(/256 MiB worker heap request.*source setting/iu); vi.stubEnv(REGEX_WORKER_HEAP_REQUEST_SETTING, "8"); try { @@ -115,12 +107,7 @@ it("uses a valid REA_REGEX_WORKER_HEAP_REQUEST_MIB override", () => { .capabilities() .find((capability) => capability.operation === "search_strings") ?.limitations.join(" "); - expect(kunaText).toContain( - launchRegexMatchingLimitation( - parsed.value.regexMatchingDeadline, - parsed.value.regexWorkerHeapRequest, - ), - ); + expect(kunaText).toMatch(/256 MiB worker heap request.*source setting/iu); } finally { vi.unstubAllEnvs(); } @@ -131,7 +118,9 @@ it("uses a valid REA_REGEX_WORKER_HEAP_REQUEST_MIB override", () => { .capabilities() .find((capability) => capability.operation === "search_procedures") ?.limitations, - ).toContain(launchRegexMatchingLimitation()); + ).toContainEqual( + expect.stringMatching(/128 MiB worker heap request.*source default/iu), + ); }); it.each([ diff --git a/src/config/windowsChangeTimeSettle.test.ts b/src/config/windowsChangeTimeSettle.test.ts index b41e8326c0..d9faf6e069 100644 --- a/src/config/windowsChangeTimeSettle.test.ts +++ b/src/config/windowsChangeTimeSettle.test.ts @@ -4,12 +4,10 @@ import { ConfigurationError } from "../domain/configurationErrors.js"; import { projectAnalysisError } from "../domain/analysisErrorProjection.js"; import { parseEnvironment } from "./environment.js"; import { - DEFAULT_WINDOWS_CHANGE_TIME_SETTLE_LIMITS, WINDOWS_CHANGE_TIME_DRIFT_MS, WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS, WINDOWS_CHANGE_TIME_SETTLE_POLL_MS, resolveWindowsChangeTimeSettle, - windowsChangeTimeSettleRecovery, windowsChangeTimeSettingFailure, windowsChangeTimeSettingMessage, } from "./windowsChangeTimeSettle.js"; @@ -37,7 +35,14 @@ const requiredFacts = ( it("keeps today's settle defaults when the settings are unset", () => { expect(resolveWindowsChangeTimeSettle({})).toEqual({ ok: true, - value: DEFAULT_WINDOWS_CHANGE_TIME_SETTLE_LIMITS, + value: { + driftMs: 2_000, + driftSource: "default", + pollMs: 25, + pollSource: "default", + maxPolls: 40, + maxPollsSource: "default", + }, }); const startup = parseEnvironment({}); if (!startup.ok) throw new Error("unset settle settings were rejected"); @@ -46,17 +51,6 @@ it("keeps today's settle defaults when the settings are unset", () => { expect( startup.value.REA_WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS, ).toBeUndefined(); - requiredFacts( - windowsChangeTimeSettleRecovery(DEFAULT_WINDOWS_CHANGE_TIME_SETTLE_LIMITS), - { - setting: WINDOWS_CHANGE_TIME_DRIFT_MS.setting, - currentValue: "2000", - source: "default", - defaultValue: 2_000, - floor: 1, - maximum: 60_000, - }, - ); }); it("uses valid settle overrides", () => { diff --git a/src/config/windowsChangeTimeSettle.ts b/src/config/windowsChangeTimeSettle.ts index c77d917a91..72134c6156 100644 --- a/src/config/windowsChangeTimeSettle.ts +++ b/src/config/windowsChangeTimeSettle.ts @@ -68,16 +68,6 @@ export interface WindowsChangeTimeSettleLimits { readonly maxPollsSource: "default" | "setting"; } -export const DEFAULT_WINDOWS_CHANGE_TIME_SETTLE_LIMITS: WindowsChangeTimeSettleLimits = - { - driftMs: WINDOWS_CHANGE_TIME_DRIFT_MS.defaultValue, - driftSource: "default", - pollMs: WINDOWS_CHANGE_TIME_SETTLE_POLL_MS.defaultValue, - pollSource: "default", - maxPolls: WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS.defaultValue, - maxPollsSource: "default", - }; - export const windowsChangeTimeSettingFailure = ( bound: WindowsChangeTimeBound, currentValue: string, @@ -183,17 +173,3 @@ export const resolveWindowsChangeTimeSettle = ( maxPollsSource: maxPolls === undefined ? "default" : "setting", }); }; - -/** - * Describe the effective budget. Admission still returns the last observation - * when the poll budget runs out; these settings only change how long it waits. - */ -export const windowsChangeTimeSettleRecovery = ( - limits: WindowsChangeTimeSettleLimits, -): string => - [ - `The effective ${WINDOWS_CHANGE_TIME_DRIFT_MS.setting} value is ${String(limits.driftMs)} ms (source ${limits.driftSource}; default ${String(WINDOWS_CHANGE_TIME_DRIFT_MS.defaultValue)} ms, floor ${String(WINDOWS_CHANGE_TIME_DRIFT_MS.floor)} ms, maximum ${String(WINDOWS_CHANGE_TIME_DRIFT_MS.maximum)} ms).`, - `The effective ${WINDOWS_CHANGE_TIME_SETTLE_POLL_MS.setting} value is ${String(limits.pollMs)} ms (source ${limits.pollSource}; default ${String(WINDOWS_CHANGE_TIME_SETTLE_POLL_MS.defaultValue)} ms, floor ${String(WINDOWS_CHANGE_TIME_SETTLE_POLL_MS.floor)} ms, maximum ${String(WINDOWS_CHANGE_TIME_SETTLE_POLL_MS.maximum)} ms).`, - `The effective ${WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS.setting} value is ${String(limits.maxPolls)} polls (source ${limits.maxPollsSource}; default ${String(WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS.defaultValue)} polls, floor ${String(WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS.floor)} polls, maximum ${String(WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS.maximum)} polls).`, - "Set them in the environment that starts REA, then restart REA. They do not change Windows ChangeTime itself.", - ].join(" "); diff --git a/src/contracts/workflowInputContracts.test.ts b/src/contracts/workflowInputContracts.test.ts index 5bab489318..87f74d3363 100644 --- a/src/contracts/workflowInputContracts.test.ts +++ b/src/contracts/workflowInputContracts.test.ts @@ -1,6 +1,5 @@ import { describe, expect, it } from "vitest"; -import { managedNativeVerificationInputSchema } from "../domain/managed/managedNativeVerificationSchemas.js"; import { toolContract } from "./toolContracts.js"; import { toolInputSchemaWithMetadata } from "./toolSchemaMetadata.js"; @@ -133,7 +132,6 @@ describe("workflow input contracts", () => { }; const contract = toolContract("verify_managed_native_boundaries"); for (const schema of [ - managedNativeVerificationInputSchema, contract.inputSchema, toolInputSchemaWithMetadata(contract), ]) { diff --git a/src/domain/analysisErrorProjection.test.ts b/src/domain/analysisErrorProjection.test.ts index 17cd7f92b6..e24a5009c2 100644 --- a/src/domain/analysisErrorProjection.test.ts +++ b/src/domain/analysisErrorProjection.test.ts @@ -355,11 +355,11 @@ it("projects a published file receipt alongside retained cleanup failure", () => ); expect(projected).toMatchObject({ code: "cleanup_incomplete", - message: - "The output file was published, but staging cleanup remains incomplete.", + message: expect.stringMatching(/published.*staging cleanup.*incomplete/iu), remediation: { - action: - "Use the published file at details.published_path and resolve the reported staging cleanup failure.", + action: expect.stringMatching( + /published.*details\.published_path.*cleanup/iu, + ), }, details: { operation: "write", @@ -1070,8 +1070,9 @@ describe("analysis error projection: caller contract", () => { category: "unavailable", retryable: false, remediation: { - action: - "Check the current process's read access to the selected path. Retry with a readable local file.", + action: expect.stringMatching( + /read access.*selected path.*readable local file/iu, + ), }, details: { path: "/local/targets/app", @@ -1141,11 +1142,11 @@ describe("analysis error projection: caller contract", () => { projectAnalysisError(new UnknownRegistryError("not-found")), ).toMatchObject({ code: "execution_failure", - message: - "The requested residual unknown does not exist in this session. Check the unknown_id and try again.", + message: expect.stringMatching( + /residual unknown.*does not exist.*unknown_id/iu, + ), remediation: { - action: - "Check that the unknown_id belongs to this session, then retry.", + action: expect.stringMatching(/unknown_id.*session.*retry/iu), }, details: { reason: "not-found" }, }); diff --git a/src/domain/analysisView/analysisView.test.ts b/src/domain/analysisView/analysisView.test.ts index 4e2ad7a3d9..ce28066fd0 100644 --- a/src/domain/analysisView/analysisView.test.ts +++ b/src/domain/analysisView/analysisView.test.ts @@ -23,7 +23,7 @@ import { } from "../javascript/javascriptApplicationGraph.js"; import { createJavaScriptSemanticGraph, - createImmutableJavaScriptSemanticGraphSteps, + sealTransferredJavaScriptSemanticGraphSteps, } from "../javascript/javascriptSemanticGraph.js"; import { sourceMapReference } from "../javascript/javascriptApplicationGraph.fixture.js"; import { createArtifactInspection } from "../artifactInspection.js"; @@ -1093,7 +1093,6 @@ it("rejects ambiguous JavaScript module paths with candidate node ids", () => { collection: "modules", selector: { path: "renderer.js" }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected ambiguous path"); expect(result.error).toMatchObject({ _tag: "AnalysisInputError", @@ -1282,7 +1281,7 @@ it("reuses authenticated graphs while rejecting malformed metadata and imported ); const { graph_id: _semanticId, ...semantic } = analysis.semantic_graph; const semanticGraph = complete( - createImmutableJavaScriptSemanticGraphSteps({ + sealTransferredJavaScriptSemanticGraphSteps({ ...semantic, application_graph_id: graph.graph_id, }), diff --git a/src/domain/analysisView/environmentStateWriteApply.test.ts b/src/domain/analysisView/environmentStateWriteApply.test.ts index 33f0937519..e2e84fd59f 100644 --- a/src/domain/analysisView/environmentStateWriteApply.test.ts +++ b/src/domain/analysisView/environmentStateWriteApply.test.ts @@ -787,7 +787,6 @@ it.each(["__proto__", "constructor"])( generator().generate, ); for (const result of [created, updated]) { - expect(result.ok).toBe(true); if (!result.ok) throw new Error(result.error); expect( Object.getOwnPropertyDescriptor(result.value, field)?.value, diff --git a/src/domain/analysisView/javascriptRoutesView.test.ts b/src/domain/analysisView/javascriptRoutesView.test.ts index 7b09e25b82..fd3b5532bd 100644 --- a/src/domain/analysisView/javascriptRoutesView.test.ts +++ b/src/domain/analysisView/javascriptRoutesView.test.ts @@ -266,7 +266,6 @@ it("returns a typed retained-parent resource error when even a summary identity collection: "summary", }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a resource error"); expect(result.error.message).toContain("cannot fit"); }); @@ -288,7 +287,6 @@ it("explains how to recover an oversized route row without changing the parent", ...selection, }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an oversized-row refusal"); const projected = projectAnalysisError(result.error); expect(projected).toMatchObject({ @@ -338,7 +336,6 @@ it.each(["summary", "routes"] as const)( ...selection, }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a sealed-page resource error"); expect(result.error.message).toContain("cannot fit"); }, diff --git a/src/domain/analysisView/webBundleView.test.ts b/src/domain/analysisView/webBundleView.test.ts index c277b39683..782c657e1e 100644 --- a/src/domain/analysisView/webBundleView.test.ts +++ b/src/domain/analysisView/webBundleView.test.ts @@ -412,7 +412,6 @@ it("returns typed AnalysisResourceConstraintError when a single record exceeds 1 }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected resource error"); expect(result.error._tag).toBe("AnalysisResourceConstraintError"); expect(result.error.message).toContain("byte budget"); @@ -492,7 +491,6 @@ it("rejects non-web-bundle parent operation with invalid_value", () => { }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failure"); if (!(result.error instanceof AnalysisInputError)) throw result.error; expect(result.error.issues[0]!.message).toContain( diff --git a/src/domain/analysisView/webNetworkApiSurfaceView.test.ts b/src/domain/analysisView/webNetworkApiSurfaceView.test.ts index 617811f81b..74215d1e7f 100644 --- a/src/domain/analysisView/webNetworkApiSurfaceView.test.ts +++ b/src/domain/analysisView/webNetworkApiSurfaceView.test.ts @@ -232,7 +232,6 @@ it.each(["api-surface", "environment-manifest", "environment-state"])( }, analysisViewRequestSchema.parse({ kind }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected parent admission to fail"); expect(result.error.cause).toMatchObject({ name: "ZodError" }); expect(projectAnalysisError(result.error)).toMatchObject({ diff --git a/src/domain/apiContract/parseGraphqlContract.test.ts b/src/domain/apiContract/parseGraphqlContract.test.ts index b4c997e7d5..98e5fe24af 100644 --- a/src/domain/apiContract/parseGraphqlContract.test.ts +++ b/src/domain/apiContract/parseGraphqlContract.test.ts @@ -225,7 +225,6 @@ it("retains partial source metadata and source-located neutral diagnostics on sc const result = parse( 'type Query { field: "https://name:FAKE_GQL_SECRET@example.invalid" }', ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected syntax refusal"); expect(result.error._tag).toBe("AnalysisInputError"); const partial = graphqlContractSchema.parse(result.error.partialObservation); @@ -256,7 +255,6 @@ it("refuses deep ASTs through a typed resource result with retained schema facts "type Query { child: Query }", "{ child ".repeat(90) + "}".repeat(90), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected nesting admission refusal"); expect(result.error._tag).toBe("AnalysisResourceConstraintError"); expect( diff --git a/src/domain/apple/appleApplication.test.ts b/src/domain/apple/appleApplication.test.ts index 9afbe8cde6..b8f2852d9b 100644 --- a/src/domain/apple/appleApplication.test.ts +++ b/src/domain/apple/appleApplication.test.ts @@ -540,8 +540,9 @@ describe("Apple bundle layouts and containers", () => { "manifest", "root_format", ], - message: - "Apple application projection requires IPA, directory, ZIP, or DMG inventory Evidence (got asar)", + message: expect.stringMatching( + /requires.*IPA.*directory.*ZIP.*DMG.*inventory Evidence.*got.*asar/iu, + ), }), ], }); diff --git a/src/domain/dosMz.test.ts b/src/domain/dosMz.test.ts index 77fc62099a..7c3d578a07 100644 --- a/src/domain/dosMz.test.ts +++ b/src/domain/dosMz.test.ts @@ -8,15 +8,17 @@ import { dosMzDeclaredImageByteLength, parseDeclaredMzHeaderEvidence, withMzWindowsHeaderSignature, - parseDosMzHeader, parseMzHeaderEvidence, } from "./dosMz.js"; +const dosHeader = (bytes: Buffer, fileSize = bytes.length) => + parseMzHeaderEvidence(bytes, fileSize).dos; + describe("DOS MZ load-module validation", () => { it("separates initialized module and appended overlay bytes", () => { const image = dosMz(480); const bytes = Buffer.concat([image, Buffer.from("overlay")]); - expect(parseDosMzHeader(bytes)).toEqual({ + expect(dosHeader(bytes)).toEqual({ ok: true, value: { headerBytes: 32, @@ -47,7 +49,7 @@ describe("DOS MZ load-module validation", () => { ok: true, value: { format: "dos-mz" }, }); - expect(parseDosMzHeader(bytes)).toMatchObject({ + expect(dosHeader(bytes)).toMatchObject({ ok: true, value: { headerBytes: 96, relocationCount: 2, moduleBytes: 128 }, }); @@ -55,8 +57,8 @@ describe("DOS MZ load-module validation", () => { it("uses the actual file length rather than the bounded prefix length", () => { const bytes = dosMz(8192); - expect(parseDosMzHeader(bytes.subarray(0, 64), bytes.length).ok).toBe(true); - expect(parseDosMzHeader(bytes.subarray(0, 64))).toMatchObject({ + expect(dosHeader(bytes.subarray(0, 64), bytes.length).ok).toBe(true); + expect(dosHeader(bytes.subarray(0, 64))).toMatchObject({ ok: false, error: "truncated DOS MZ load module", }); @@ -114,7 +116,7 @@ describe("DOS MZ load-module validation", () => { ok: true, value: { format: "pe", architecture: "x86_64" }, }); - expect(parseDosMzHeader(bytes).ok).toBe(false); + expect(dosHeader(bytes).ok).toBe(false); }); it.each([ @@ -156,18 +158,16 @@ describe("DOS MZ load-module validation", () => { ] as const)("rejects invalid %s", (_name, damage, error) => { const bytes = dosMz(); damage(bytes); - expect(parseDosMzHeader(bytes)).toEqual({ ok: false, error }); + expect(dosHeader(bytes)).toEqual({ ok: false, error }); }); it("rejects a truncated relocation table even when the file size is known", () => { const bytes = dosMz(); bytes.writeUInt16LE(1, 6); - expect(parseDosMzHeader(bytes.subarray(0, 30), bytes.length)).toMatchObject( - { - ok: false, - error: "truncated DOS MZ relocation table", - }, - ); + expect(dosHeader(bytes.subarray(0, 30), bytes.length)).toMatchObject({ + ok: false, + error: "truncated DOS MZ relocation table", + }); }); }); @@ -402,7 +402,7 @@ it("retains ordered DOS relocation aliases and their source/module target coordi bytes.writeUInt16LE(0, 38); bytes.writeUInt16LE(17, 40); bytes.writeUInt16LE(0, 42); - const parsed = parseDosMzHeader(bytes); + const parsed = dosHeader(bytes); if (!parsed.ok) throw new Error(parsed.error); expect(parsed.value.relocations).toEqual([ { segment: 1, offset: 0, moduleOffset: 16, fileOffset: 80 }, @@ -418,7 +418,7 @@ it("retains ordered DOS relocation aliases and their source/module target coordi moduleOffset: 16, fileOffset: 80, }); - expect(parseDosMzHeader(bytes)).toEqual({ + expect(dosHeader(bytes)).toEqual({ ok: false, error: "DOS MZ relocation 1 points outside its load module", }); @@ -436,10 +436,11 @@ it("retains fixed declarations while requesting only a source-bounded relocation const bytes = extendedRelocationImage(); const prefix = bytes.subarray(0, 64); const evidence = parseMzHeaderEvidence(prefix, bytes.length); - expect(evidence.declarations).toEqual(readDosMzDeclarations(prefix)); expect(evidence.declarations).toMatchObject({ ok: true, value: { + lastPageBytes: 32, + pages: 17, headerBytes: 4112, relocationCount: 2, relocationTableOffset: 4096, @@ -470,7 +471,7 @@ it("does not request absent or out-of-bounds relocation records", () => { parseMzHeaderEvidence(zero.subarray(0, 64), zero.length) .relocationTableRead, ).toBeUndefined(); - expect(parseDosMzHeader(zero).ok).toBe(true); + expect(dosHeader(zero).ok).toBe(true); const outsideHeader = extendedRelocationImage(); outsideHeader.writeUInt16LE(5000, 24); const headerEvidence = parseMzHeaderEvidence( @@ -505,16 +506,16 @@ it("keeps independent malformed declarations and the established DOS error prece ok: false, error: "invalid DOS MZ page count or final-page size", }); - expect(parseDosMzHeader(bytes, bytes.length - 1)).toEqual({ + expect(dosHeader(bytes, bytes.length - 1)).toEqual({ ok: false, error: "invalid DOS MZ file length", }); bytes.writeUInt16LE(17, 4); - expect(parseDosMzHeader(bytes.subarray(0, 64), bytes.length)).toEqual({ + expect(dosHeader(bytes.subarray(0, 64), bytes.length)).toEqual({ ok: false, error: "truncated DOS MZ relocation table", }); - expect(parseDosMzHeader(bytes)).toEqual({ + expect(dosHeader(bytes)).toEqual({ ok: false, error: "DOS MZ entry point lies outside its initialized load module", }); diff --git a/src/domain/dosMz.ts b/src/domain/dosMz.ts index c0c96702bb..2c7c1d2350 100644 --- a/src/domain/dosMz.ts +++ b/src/domain/dosMz.ts @@ -195,17 +195,6 @@ const windowsHeaderSignature = ( return bytes[2] === 0 && bytes[3] === 0 ? "PE" : "other"; }; -/** - * Validate a DOS MZ load module using a bounded header/table and the actual - * file length. Appended overlay bytes are retained separately; they are not - * silently included in the initialized load module. - */ -export const parseDosMzHeader = ( - bytes: Buffer, - fileSize = bytes.length, -): Result => - parseDeclaredDosMzHeader(bytes, fileSize, readDosMzDeclarations(bytes)); - const parseDeclaredDosMzHeader = ( bytes: Buffer, fileSize: number, diff --git a/src/domain/elfFixedHeader.test.ts b/src/domain/elfFixedHeader.test.ts index 00572006d5..8154603c04 100644 --- a/src/domain/elfFixedHeader.test.ts +++ b/src/domain/elfFixedHeader.test.ts @@ -140,7 +140,6 @@ it("keeps framing failures ahead of version and declared-size admission", () => }); bytes[6] = 1; const truncated = readElfFixedHeader(bytes, 63); - expect(truncated).toEqual(readElfHeaderFacts(bytes, 63)); expect(truncated).toMatchObject({ ok: false, error: expect.stringContaining("truncated ELF header"), diff --git a/src/domain/explicitSensitiveFailure.test.ts b/src/domain/explicitSensitiveFailure.test.ts index 3a1d81b1f7..96c5dca904 100644 --- a/src/domain/explicitSensitiveFailure.test.ts +++ b/src/domain/explicitSensitiveFailure.test.ts @@ -16,10 +16,7 @@ import { ProviderAdapterError } from "./providerAdapterError.js"; import { analysisErrorWithCleanupFailure } from "./analysisErrorCleanup.js"; import { resolvedAnalysisError } from "./analysisErrorBase.js"; import { createEvidence } from "./evidence.js"; -import { - redactExplicitFailure, - redactExplicitPointer, -} from "./explicitSensitiveFailure.js"; +import { redactExplicitFailure } from "./explicitSensitiveFailure.js"; const context = { diagnostics: { @@ -95,7 +92,13 @@ it.each([ ])( "preserves a real parent for excluded pointer identities: %s", (pointer, values, expected) => { - expect(redactExplicitPointer(pointer, values)).toBe(expected); + const failure = new AnalysisInputError("inspect", undefined, [ + { path: ["capture_path", pointer], reason: "invalid_format" }, + ]); + const redacted = redactExplicitFailure(failure, values); + if (!(redacted instanceof AnalysisInputError)) + throw new Error("Expected a redacted input error"); + expect(redacted.issues[0]?.path).toEqual(["capture_path", expected]); }, ); diff --git a/src/domain/explicitSensitiveFailure.ts b/src/domain/explicitSensitiveFailure.ts index bbd0e43140..205dc88118 100644 --- a/src/domain/explicitSensitiveFailure.ts +++ b/src/domain/explicitSensitiveFailure.ts @@ -48,13 +48,6 @@ const excludeSnapshotIdentity = ( return { ...snapshot, path, admitted_sha256 }; }; -/** Keep a real JSON-pointer ancestor when a property identity is explicitly excluded. */ -export const redactExplicitPointer = ( - pointer: string, - values: readonly string[], -): string => - redactSensitivePointer(pointer, (value) => redactExplicitText(value, values)); - const redactSensitivePointer = ( pointer: string, text: (value: string) => string, diff --git a/src/domain/firmware/hexRecords.test.ts b/src/domain/firmware/hexRecords.test.ts index 1479c60dbd..de67cbdccd 100644 --- a/src/domain/firmware/hexRecords.test.ts +++ b/src/domain/firmware/hexRecords.test.ts @@ -136,8 +136,9 @@ describe("Intel HEX decoding", () => { ok: false, error: { kind: "format", - message: - "address 0x00000003 written with different values at line 1 (0x04) and line 2 (0x99)", + message: expect.stringMatching( + /0x00000003\b.*different values.*line 1\b.*0x04\b.*line 2\b.*0x99\b/iu, + ), }, }); }); diff --git a/src/domain/firmware/uf2.test.ts b/src/domain/firmware/uf2.test.ts index ff5fb41070..4fa3c39f2b 100644 --- a/src/domain/firmware/uf2.test.ts +++ b/src/domain/firmware/uf2.test.ts @@ -185,8 +185,9 @@ it("counts identical rewrites and refuses a conflicting rewrite of one address", ok: false, error: { kind: "format", - message: - "family 0xe48bff56 (RP2040) address 0x20000003 is written with different values by block 0 (0x04) and block 1 (0x09)", + message: expect.stringMatching( + /0xe48bff56\b.*RP2040.*0x20000003\b.*different values.*block 0\b.*0x04\b.*block 1\b.*0x09\b/iu, + ), }, }); }); diff --git a/src/domain/fixedAllowanceRemediation.test.ts b/src/domain/fixedAllowanceRemediation.test.ts index c3e26b2859..fd430ad46d 100644 --- a/src/domain/fixedAllowanceRemediation.test.ts +++ b/src/domain/fixedAllowanceRemediation.test.ts @@ -112,6 +112,17 @@ describe("fixed allowance recovery", () => { expect(projected.remediation.action).toContain(allowance); for (const pattern of forbidden[kind]) expect(projected.remediation.action).not.toMatch(pattern); + if (kind === "parser") { + expect(projected.remediation.action).toMatch( + /worker memory limits.*host memory do not raise/iu, + ); + expect(projected.remediation.action).toMatch( + /complete input.*allowance/iu, + ); + expect(projected.remediation.action).toMatch( + /unchanged request.*fails/iu, + ); + } if (kind === "live") expect(projected.remediation.action).toContain( "live output may change between requests", diff --git a/src/domain/gamecubeDol.test.ts b/src/domain/gamecubeDol.test.ts index 562e6fde4d..e5ea4c81f5 100644 --- a/src/domain/gamecubeDol.test.ts +++ b/src/domain/gamecubeDol.test.ts @@ -184,7 +184,6 @@ describe("DOL header parsing", () => { 0x140, ); const result = parseDolHeader(bytes); - expect(result.ok).toBe(true); if (!result.ok) throw new Error(result.error); expect(result.value.sections).toHaveLength(1); }); @@ -418,7 +417,6 @@ describe("DOL entry point and BSS (rules 7 and 8)", () => { 0x140, ); const result = parseDolHeader(bytes); - expect(result.ok).toBe(true); if (!result.ok) throw new Error(result.error); expect(result.value.bss.size).toBe(0); }); @@ -492,7 +490,6 @@ describe("DOL entry point and BSS (rules 7 and 8)", () => { 0x200, ); const result = parseDolHeader(bytes); - expect(result.ok).toBe(true); if (!result.ok) throw new Error(result.error); expect(result.value.bssOverlaps).toEqual([0, 1]); }); @@ -508,7 +505,6 @@ describe("DOL entry point and BSS (rules 7 and 8)", () => { 0x180, ); const result = parseDolHeader(bytes); - expect(result.ok).toBe(true); if (!result.ok) throw new Error(result.error); expect(result.value.bssOverlaps).toEqual([]); }); diff --git a/src/domain/inputIssueProjection.test.ts b/src/domain/inputIssueProjection.test.ts index 5e2385cc4d..35411deec0 100644 --- a/src/domain/inputIssueProjection.test.ts +++ b/src/domain/inputIssueProjection.test.ts @@ -4,7 +4,7 @@ import { z } from "zod"; import { analysisInputErrorFromIssues, projectInputIssues, - projectInputIssuesWithinBudget, + projectInputIssueGroupsWithinBudget, } from "./inputIssueProjection.js"; import { projectAnalysisError } from "./analysisErrorProjection.js"; import { processScenarioSchema } from "./process/processScenario.js"; @@ -13,6 +13,10 @@ import { APPLICATION_TOOL_CONTRACTS } from "../contracts/applicationToolContract import { ENHANCED_TOOL_CONTRACTS } from "../contracts/enhancedToolContracts.js"; import { knownArgumentMistakeGuidance } from "./inputArgumentGuidance.js"; +const projectFlattenedIssueGroups = ( + ...args: Parameters +) => projectInputIssueGroupsWithinBudget(...args)?.flat(); + const officialContract = ( name: (typeof OFFICIAL_TOOL_CONTRACTS)[number]["name"], ) => { @@ -322,7 +326,7 @@ describe("input issue argument guidance suppression", () => { expect(action).not.toContain(suppressedGuidance!.remediation); expect(action).toContain("annotate_native_function"); - const budgeted = projectInputIssuesWithinBudget( + const budgeted = projectFlattenedIssueGroups( parsed.error.issues, inputWithBoth, 1024, @@ -371,10 +375,10 @@ describe("bounded input issue projection", () => { const parsed = schema.safeParse(input); if (parsed.success) throw new Error("expected invalid input"); expect( - projectInputIssuesWithinBudget(parsed.error.issues, input, 32_768), + projectFlattenedIssueGroups(parsed.error.issues, input, 32_768), ).toEqual(projectInputIssues(parsed.error.issues, input)); expect( - projectInputIssuesWithinBudget(parsed.error.issues, input, 300), + projectFlattenedIssueGroups(parsed.error.issues, input, 300), ).toBeUndefined(); }); @@ -411,7 +415,7 @@ describe("bounded input issue projection", () => { errors: [[{ ...child, path }]], }; expect( - projectInputIssuesWithinBudget([largePathIssue], input, 1024), + projectFlattenedIssueGroups([largePathIssue], input, 1024), ).toBeUndefined(); expect(copied).toBe(false); }); @@ -424,10 +428,10 @@ describe("bounded input issue projection", () => { message: "Unrecognized keys", }; expect(projectInputIssues([issue], {})).toHaveLength(10); - expect(projectInputIssuesWithinBudget([issue], {}, 5000)).toBeUndefined(); - expect(projectInputIssuesWithinBudget([issue], {}, 32_000)).toHaveLength( - 10, - ); + expect(projectFlattenedIssueGroups([issue], {}, 5000)).toBeUndefined(); + const groups = projectInputIssueGroupsWithinBudget([issue], {}, 32_000); + expect(groups).toHaveLength(1); + expect(groups?.[0]).toHaveLength(10); }); it("bounds pre-allocation budget accounting for guided unrecognized keys", () => { @@ -437,12 +441,12 @@ describe("bounded input issue projection", () => { keys: ["address"], message: "Unrecognized keys: address", }; - expect(projectInputIssuesWithinBudget([issue], {}, 800)).toEqual([ + expect(projectFlattenedIssueGroups([issue], {}, 800)).toEqual([ { path: ["address"], reason: "unknown_argument" }, ]); expect( - projectInputIssuesWithinBudget( + projectFlattenedIssueGroups( [issue], {}, 800, @@ -456,7 +460,7 @@ describe("bounded input issue projection", () => { ); expect(guidance).toBeDefined(); expect( - projectInputIssuesWithinBudget( + projectFlattenedIssueGroups( [issue], {}, 2000, diff --git a/src/domain/inputIssueProjection.ts b/src/domain/inputIssueProjection.ts index f7aed8b34e..03496f9675 100644 --- a/src/domain/inputIssueProjection.ts +++ b/src/domain/inputIssueProjection.ts @@ -62,21 +62,6 @@ const projectionBudgetExceeded = Symbol( "input issue projection budget exceeded", ); -/** Bound representation expansion before constructing projected diagnostics. */ -export const projectInputIssuesWithinBudget = ( - issues: readonly z.core.$ZodIssue[], - input: unknown, - budgetBytes: number, - operation?: string, -): readonly AnalysisInputIssue[] | undefined => { - return projectInputIssueGroupsWithinBudget( - issues, - input, - budgetBytes, - operation, - )?.flat(); -}; - /** Field diagnostics that fit a byte allowance, plus what was dropped. */ export interface BoundedInputIssues { readonly issues: readonly AnalysisInputIssue[]; diff --git a/src/domain/javascript/javascriptApplicationAnalysisSteps.test.ts b/src/domain/javascript/javascriptApplicationAnalysisSteps.test.ts index 04ec344d45..38425345c7 100644 --- a/src/domain/javascript/javascriptApplicationAnalysisSteps.test.ts +++ b/src/domain/javascript/javascriptApplicationAnalysisSteps.test.ts @@ -15,7 +15,6 @@ import { } from "./javascriptApplicationGraph.js"; import { createJavaScriptSemanticGraph, - createImmutableJavaScriptSemanticGraphSteps, isValidatedImmutableJavaScriptSemanticGraph, sealTransferredJavaScriptSemanticGraphSteps, } from "./javascriptSemanticGraph.js"; @@ -41,7 +40,7 @@ const ownedExample = () => { createImmutableJavaScriptApplicationGraphSteps(application), ), semantic_graph: complete( - createImmutableJavaScriptSemanticGraphSteps(semantic), + sealTransferredJavaScriptSemanticGraphSteps(semantic), ), }; }; @@ -179,7 +178,7 @@ describe("owned JavaScript graph validation", () => { ).toBe(false); }); - it("keeps ordinary constructors mutable and clones inputs before sealing", () => { + it("keeps ordinary constructors mutable and seals independently owned inputs", () => { const input = example(); const { graph_id: _applicationId, ...application } = input.graph; const { graph_id: _semanticId, ...semantic } = input.semantic_graph; @@ -189,7 +188,9 @@ describe("owned JavaScript graph validation", () => { expect(Object.isFrozen(ordinarySemantic)).toBe(false); const applicationSteps = createImmutableJavaScriptApplicationGraphSteps(application); - const semanticSteps = createImmutableJavaScriptSemanticGraphSteps(semantic); + const semanticSteps = sealTransferredJavaScriptSemanticGraphSteps( + structuredClone(semantic), + ); application.limitations.push("Changed after factory input was cloned."); semantic.limitations.push("Changed after factory input was cloned."); expect(complete(applicationSteps)).toEqual(ordinaryApplication); @@ -270,12 +271,16 @@ describe("owned JavaScript graph validation", () => { }; const mutable = createJavaScriptSemanticGraph(semantic); const { graph_id: _mutableId, ...mutableInput } = mutable; - const steps = createImmutableJavaScriptSemanticGraphSteps(mutableInput); + const steps = sealTransferredJavaScriptSemanticGraphSteps( + structuredClone(mutableInput), + ); expect(steps.next().done).toBe(false); steps.return(mutable); expect(isValidatedImmutableJavaScriptSemanticGraph(mutable)).toBe(false); const sealed = complete( - createImmutableJavaScriptSemanticGraphSteps(mutableInput), + sealTransferredJavaScriptSemanticGraphSteps( + structuredClone(mutableInput), + ), ); expect(sealed).toEqual(mutable); expect(isValidatedImmutableJavaScriptSemanticGraph(sealed)).toBe(true); @@ -301,7 +306,7 @@ describe("owned JavaScript result bindings", () => { ]; } input.semantic_graph = complete( - createImmutableJavaScriptSemanticGraphSteps(semantic), + sealTransferredJavaScriptSemanticGraphSteps(semantic), ); } expect( @@ -332,7 +337,7 @@ describe("owned JavaScript result bindings", () => { ...semantic.nodes.slice(1), ]; input.semantic_graph = complete( - createImmutableJavaScriptSemanticGraphSteps(semantic), + sealTransferredJavaScriptSemanticGraphSteps(semantic), ); freezeJsonSnapshot(input); const steps = parseOwnedJavaScriptApplicationAnalysisSteps(input); diff --git a/src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.ts b/src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.ts index 83f157dc9c..0f04b4ebb8 100644 --- a/src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.ts +++ b/src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.ts @@ -25,7 +25,6 @@ import { type JavaScriptRuntimeTargetLocation, } from "./javascriptRuntimeObservation.js"; import { digestCanonicalValue } from "../canonicalDigest.js"; -import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js"; import type { Evidence } from "../evidence.js"; import { parseActiveElectronCapture } from "./javascriptRuntimeReconciliationActive.js"; import { @@ -124,22 +123,6 @@ export type ParsedRuntimeCapture = }; }); -/** Parse only supported passive web/Electron inspection Evidence. */ -export const parseRuntimeCaptures = ( - observations: readonly unknown[], - path: readonly (string | number)[] = ["runtime_observations"], -): ParsedRuntimeCapture[] => - observations - .map((observation, index) => - parseRuntimeCapture(observation, [...path, index]), - ) - .sort((left, right) => - compareUnicodeCodePoints( - left.evidence.evidence_id, - right.evidence.evidence_id, - ), - ); - /** Authenticate one source before interpreting its runtime capture. */ export const parseRuntimeCapture = ( input: unknown, diff --git a/src/domain/javascript/javascriptSemanticGraph.ts b/src/domain/javascript/javascriptSemanticGraph.ts index 9900bfca16..c9eafc671f 100644 --- a/src/domain/javascript/javascriptSemanticGraph.ts +++ b/src/domain/javascript/javascriptSemanticGraph.ts @@ -752,20 +752,6 @@ export type JavaScriptSemanticGraph = z.infer< typeof javaScriptSemanticGraphSchema >; -/** Resolve one fact's compact provenance without changing its stored shape. */ -export const resolveJavaScriptSemanticEvidence = ( - graph: Pick, - reference: JavaScriptSemanticEvidenceReference, -): ApplicationGraphEvidence => { - const context = graph.evidence_contexts.find( - ({ context_id }) => context_id === reference.context_id, - ); - if (context === undefined) - throw new TypeError("Semantic evidence reference names an absent context"); - const { context_id: _contextId, ...evidenceContext } = context; - return { ...evidenceContext, location: reference.location }; -}; - const normalizeGraphInput = ( parsed: JavaScriptSemanticGraphInput, ): JavaScriptSemanticGraphInput => ({ @@ -853,14 +839,6 @@ const semanticGraphContainerSchema = javaScriptSemanticGraphInputSchema.extend({ unknowns: arrayContainerSchema(semanticGraphShape.unknowns), }); -/** Clone input synchronously; commit, check and seal the owned graph in steps. */ -export const createImmutableJavaScriptSemanticGraphSteps = ( - input: unknown, -): Generator => - validateAndSealSemanticGraphSteps( - normalizeGraphInput(javaScriptSemanticGraphInputSchema.parse(input)), - ); - /** * Seal a graph whose input the caller transfers: the caller neither retains nor * mutates any part of it afterwards. Only the graph's own fields are validated diff --git a/src/domain/javascript/javascriptSemanticGraphQuery.test.ts b/src/domain/javascript/javascriptSemanticGraphQuery.test.ts index deb23e9edc..f0b128ac2e 100644 --- a/src/domain/javascript/javascriptSemanticGraphQuery.test.ts +++ b/src/domain/javascript/javascriptSemanticGraphQuery.test.ts @@ -1,5 +1,6 @@ import { javaScriptSemanticQueryInputSchema } from "./javascriptSemanticQuerySchemas.js"; import { + resolveJavaScriptSemanticEvidence, semanticFixtureGraph, semanticFixtureInput, semanticGraphTestEvidence, @@ -24,11 +25,10 @@ import { createJavaScriptSemanticGraphNode, createJavaScriptSemanticGraphRelation, createJavaScriptSemanticGraphUnknown, - createImmutableJavaScriptSemanticGraphSteps, + sealTransferredJavaScriptSemanticGraphSteps, isValidatedImmutableJavaScriptSemanticGraph, JavaScriptSemanticEvidenceContextRegistry, javaScriptSemanticGraphSchema, - resolveJavaScriptSemanticEvidence, type JavaScriptSemanticGraph, } from "./javascriptSemanticGraph.js"; import { queryJavaScriptSemanticGraph } from "./javascriptSemanticQuery.js"; @@ -744,7 +744,7 @@ const complete = (steps: Iterator): Value => { } }; -it("captures nested input before yielding and preserves the synchronous graph commitment", () => { +it("preserves a transferred graph independent of the caller retained copy", () => { const input = semanticFixtureInput(true); const node = input.nodes[0]; if (node === undefined) throw new Error("Expected fixture node"); @@ -754,7 +754,9 @@ it("captures nested input before yielding and preserves the synchronous graph co input.relations.reverse(); input.coverage.families.reverse(); const expected = createJavaScriptSemanticGraph(input); - const steps = createImmutableJavaScriptSemanticGraphSteps(input); + const steps = sealTransferredJavaScriptSemanticGraphSteps( + structuredClone(input), + ); expect(steps.next().done).toBe(false); nested.text = "Changed while the owned graph is being hashed."; nested.rows.push(4); @@ -854,7 +856,9 @@ it.each(invalidGraphCases)( }; const expected = issues(() => createJavaScriptSemanticGraph(input)); expect(expected.map(({ message }) => message)).toContain(message); - const steps = createImmutableJavaScriptSemanticGraphSteps(input); + const steps = sealTransferredJavaScriptSemanticGraphSteps( + structuredClone(input), + ); expect(steps.next().done).toBe(false); expect(issues(() => complete(steps))).toEqual(expected); }, diff --git a/src/domain/javascript/javascriptSemanticGraphTraversal.test.ts b/src/domain/javascript/javascriptSemanticGraphTraversal.test.ts index 1b731ca877..8d030b3941 100644 --- a/src/domain/javascript/javascriptSemanticGraphTraversal.test.ts +++ b/src/domain/javascript/javascriptSemanticGraphTraversal.test.ts @@ -1,4 +1,5 @@ import { + resolveJavaScriptSemanticEvidence, semanticFixtureGraph, semanticGraphTestEvidence, unknownSemanticGraphTestEvidence, @@ -20,7 +21,6 @@ import { createJavaScriptSemanticGraphRelation, createJavaScriptSemanticGraphUnknown, JavaScriptSemanticEvidenceContextRegistry, - resolveJavaScriptSemanticEvidence, type JavaScriptSemanticGraph, } from "./javascriptSemanticGraph.js"; import { queryJavaScriptSemanticGraph } from "./javascriptSemanticQuery.js"; diff --git a/src/domain/javascript/javascriptSourceParser.test.ts b/src/domain/javascript/javascriptSourceParser.test.ts index 64ab0f3534..39c3219a19 100644 --- a/src/domain/javascript/javascriptSourceParser.test.ts +++ b/src/domain/javascript/javascriptSourceParser.test.ts @@ -7,7 +7,7 @@ import { parserPluginsForPath, javaScriptRuntimeContext, javaScriptProgramStrictness, - javaScriptTopLevelThisMayBeGlobal, + javaScriptThisOwner, } from "./javascriptSourceParser.js"; import { traverseJavaScriptAst } from "./javascriptSemanticTraversal.js"; import { analyzeParsedJavaScriptStaticSource } from "./javascriptStaticAnalysis.js"; @@ -39,7 +39,7 @@ it.each([ }); if (selected === undefined) throw new Error("Missing this fixture"); expect( - javaScriptTopLevelThisMayBeGlobal(selected, parsed.program, parents), + javaScriptThisOwner(selected, parsed.program, parents) === "global", ).toBe(expected); }, ); diff --git a/src/domain/javascript/javascriptSourceParser.ts b/src/domain/javascript/javascriptSourceParser.ts index 43c3be3ba5..7f4ef4ce16 100644 --- a/src/domain/javascript/javascriptSourceParser.ts +++ b/src/domain/javascript/javascriptSourceParser.ts @@ -351,9 +351,3 @@ export const javaScriptThisOwner = ( ? "global" : "isolated"; }; - -export const javaScriptTopLevelThisMayBeGlobal = ( - node: t.ThisExpression, - program: t.Program, - parents: WeakMap, -): boolean => javaScriptThisOwner(node, program, parents) === "global"; diff --git a/src/domain/managed/managedMemberComparison.ts b/src/domain/managed/managedMemberComparison.ts index 4717898c21..2023b523a0 100644 --- a/src/domain/managed/managedMemberComparison.ts +++ b/src/domain/managed/managedMemberComparison.ts @@ -2,7 +2,6 @@ import { z } from "zod"; import { digestCanonicalValue } from "../canonicalDigest.js"; import { emptyArraySchema } from "../emptyArraySchema.js"; -import { evidenceSchema } from "../evidence.js"; import { evidenceInputSchema } from "../evidenceReference.js"; import { cliMetadataGuidSchema, @@ -53,11 +52,6 @@ const distinctMemberSources = ( }); }; -/** Two complete managed member observations for semantic consumers. */ -export const compareManagedMembersInputSchema = z - .strictObject(memberComparisonShape(evidenceSchema)) - .superRefine(distinctMemberSources); - /** Public member comparison selects records inline or by exact retained identity. */ export const compareManagedMembersRequestSchema = z .strictObject(memberComparisonShape(evidenceInputSchema)) diff --git a/src/domain/managed/managedNativeVerificationSchemas.ts b/src/domain/managed/managedNativeVerificationSchemas.ts index 1fa2f461b2..b322552aad 100644 --- a/src/domain/managed/managedNativeVerificationSchemas.ts +++ b/src/domain/managed/managedNativeVerificationSchemas.ts @@ -1,7 +1,6 @@ import { z } from "zod"; import { emptyArraySchema } from "../emptyArraySchema.js"; -import { evidenceSchema } from "../evidence.js"; import { evidenceInputSchema } from "../evidenceReference.js"; import { cliMetadataGuidSchema, @@ -138,11 +137,6 @@ const distinctNativeSources = ( } }; -/** Complete record inputs used by the managed semantic owner and fixture builders. */ -export const managedNativeVerificationInputSchema = z - .strictObject(nativeVerificationShape(evidenceSchema)) - .superRefine(distinctNativeSources); - /** Public workflow sources may be inline records or exact retained identities. */ export const managedNativeVerificationRequestSchema = z .strictObject(nativeVerificationShape(evidenceInputSchema)) diff --git a/src/domain/process/processScenario.test.ts b/src/domain/process/processScenario.test.ts index 965bf23347..7e14dbd2de 100644 --- a/src/domain/process/processScenario.test.ts +++ b/src/domain/process/processScenario.test.ts @@ -310,12 +310,12 @@ it("identifies each event scheduled after the scenario timeout", () => { expect.objectContaining({ code: "custom", path: ["events", 1], - message: "event at 1500 ms occurs after the 1000 ms scenario timeout", + message: expect.stringMatching(/1500.*1000/u), }), expect.objectContaining({ code: "custom", path: ["events", 2], - message: "event at 2000 ms occurs after the 1000 ms scenario timeout", + message: expect.stringMatching(/2000.*1000/u), }), ]); }); diff --git a/src/domain/process/processTraceComparison.test.ts b/src/domain/process/processTraceComparison.test.ts index 5f43a3a7ef..27dfa13f7f 100644 --- a/src/domain/process/processTraceComparison.test.ts +++ b/src/domain/process/processTraceComparison.test.ts @@ -15,10 +15,14 @@ import { import { compareProcessCaptures } from "./processComparison.js"; import { - compareProcessTraces, + evaluateProcessTraceComparison, processTraceOutcomesDiffer, } from "./processTraceComparison.js"; +const compareProcessTraces = ( + ...args: Parameters +) => evaluateProcessTraceComparison(...args).result; + const traced = ( left: ReturnType, right: ReturnType, diff --git a/src/domain/process/processTraceComparison.ts b/src/domain/process/processTraceComparison.ts index b831e475a0..9ec1b387ef 100644 --- a/src/domain/process/processTraceComparison.ts +++ b/src/domain/process/processTraceComparison.ts @@ -57,14 +57,6 @@ export const evaluateProcessTraceComparison = ( }; }; -/** Compare two captures against an explicit finite trace language. */ -export const compareProcessTraces = ( - left: ProcessCapture, - right: ProcessCapture, - specification: ProcessTraceSpecification, -): ProcessTraceComparisonResult => - evaluateProcessTraceComparison(left, right, specification).result; - /** Whether trace conformance or raw declared order differs across captures. */ export const processTraceOutcomesDiffer = ( comparison: Pick, diff --git a/src/domain/process/processTraceSpecification.test.ts b/src/domain/process/processTraceSpecification.test.ts index edb1520792..2eec3c207d 100644 --- a/src/domain/process/processTraceSpecification.test.ts +++ b/src/domain/process/processTraceSpecification.test.ts @@ -59,7 +59,7 @@ describe("process trace specification", () => { expect(result.error.issues).toEqual( expect.arrayContaining([ expect.objectContaining({ - message: "happens-before graph must be acyclic", + message: expect.stringMatching(/happens-before.*acyclic/u), }), expect.objectContaining({ path: ["language", "not_before", 0, "event"], @@ -133,11 +133,11 @@ describe("process trace ordering validation", () => { expect(rejected.error.issues).toEqual([ expect.objectContaining({ path: ["language", "not_before", 0], - message: "not-before constraint conflicts with happens-before order", + message: expect.stringMatching(/not-before.*happens-before/u), }), expect.objectContaining({ path: ["language", "unordered_groups", 0], - message: "ordered events cannot also be declared unordered", + message: expect.stringMatching(/ordered.*unordered/u), }), ]); }); @@ -166,7 +166,7 @@ describe("process trace ordering validation", () => { expect(result.error.issues).toEqual([ expect.objectContaining({ path: ["language"], - message: "event pair b/d must be explicitly ordered or unordered", + message: expect.stringContaining("b/d"), }), ]); }); @@ -192,7 +192,7 @@ describe("process trace ordering validation", () => { expect(result.error.issues).toEqual([ expect.objectContaining({ path: ["language", "unordered_groups", 1], - message: "unordered event pairs must be declared once", + message: expect.stringMatching(/unordered.*once/u), }), ]); }); @@ -226,11 +226,11 @@ describe("malformed process trace declarations", () => { expect.arrayContaining([ expect.objectContaining({ path: ["events", 1, "id"], - message: "event ids must be unique", + message: expect.stringMatching(/event ids.*unique/u), }), expect.objectContaining({ path: ["language", "unordered_groups", 0, "events", 1], - message: "unknown event id: b", + message: expect.stringMatching(/unknown.*\bb\b/u), }), ]), ); @@ -256,15 +256,15 @@ describe("malformed process trace declarations", () => { expect.arrayContaining([ expect.objectContaining({ path: ["language", "happens_before", 0, "after"], - message: "unknown event id: missing", + message: expect.stringMatching(/unknown.*missing/u), }), expect.objectContaining({ path: ["language", "not_before", 0, "anchor"], - message: "unknown event id: missing", + message: expect.stringMatching(/unknown.*missing/u), }), expect.objectContaining({ path: ["language", "not_before", 0], - message: "not-before constraint conflicts with happens-before order", + message: expect.stringMatching(/not-before.*happens-before/u), }), ]), ); @@ -347,7 +347,7 @@ describe("finite trace specification validation", () => { ).toEqual( [1, 5].map((index) => ({ path: ["language", "variants", index, "trace"], - message: "finite trace variants must not duplicate a trace", + message: expect.stringMatching(/duplicate.*trace/u), })), ); }); diff --git a/src/domain/propertyListOpenStep.test.ts b/src/domain/propertyListOpenStep.test.ts index 32e13c73bf..03c1ef3e2f 100644 --- a/src/domain/propertyListOpenStep.test.ts +++ b/src/domain/propertyListOpenStep.test.ts @@ -136,11 +136,6 @@ it.each(["\n", "\r\n", "\r", "\u2028", "\u2029"])( "hidden = second;\n items = (one, // array" + newline + "two,); }"; - expect( - decodeOpenStepPropertyList( - "{ kept = first; // inline" + newline + "hidden = second;\n }", - ), - ).toEqual({ kept: "first", hidden: "second" }); expect(startsOpenStepPropertyList(text)).toBe(true); expect(decodeOpenStepPropertyList(text)).toEqual({ kept: "first", @@ -159,14 +154,11 @@ it("does not treat nonterminating whitespace or quoted comment text as line ends expect(startsOpenStepPropertyList("// comment without a line end")).toBe( false, ); - expect(() => + const error = syntaxFailure(() => decodeOpenStepPropertyList("// comment without a line end"), - ).toThrow(OpenStepPropertyListError); - expect( - syntaxFailure(() => - decodeOpenStepPropertyList("// comment without a line end"), - ), - ).toMatchObject({ code: "unexpected_end" }); + ); + expect(error).toBeInstanceOf(OpenStepPropertyListError); + expect(error).toMatchObject({ code: "unexpected_end" }); }); it.each([ diff --git a/src/domain/rawBinary.test.ts b/src/domain/rawBinary.test.ts index 72da0f6dc0..708cb72748 100644 --- a/src/domain/rawBinary.test.ts +++ b/src/domain/rawBinary.test.ts @@ -117,7 +117,6 @@ describe("raw-binary admission", () => { entryPoint: "0xfffffffc", fileBytes: 8, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected overflow rejection"); expect(result.error.reason).toContain("arm address width"); expect(result.error.constraint).toBe("load_selection_rejected"); @@ -157,7 +156,6 @@ describe("raw-binary admission", () => { ["mismatched family name", { architecture: "68000", entryPoint: "0x1000" }], ])("classifies a %s as caller input", (_name, selection) => { const result = admitRawBinary({ ...selection, fileBytes: 4 }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected caller-input rejection"); expect(result.error.constraint).toBe("load_selection_rejected"); }); diff --git a/src/domain/xmlDocument.test.ts b/src/domain/xmlDocument.test.ts index ff6c26380c..d029d9928e 100644 --- a/src/domain/xmlDocument.test.ts +++ b/src/domain/xmlDocument.test.ts @@ -43,7 +43,6 @@ it.each([ doctype: "allow", lineEndings: "preserve", }); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected refusal"); expect(parsed.error.reason).toBe("malformed"); expect(parsed.error.cause).toBeDefined(); @@ -94,7 +93,6 @@ it("applies the consumer's explicit DTD policy", () => { ']>', { doctype: "reject", lineEndings: "preserve" }, ); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected unsupported DTD"); expect(parsed.error.reason).toBe("doctype"); }); diff --git a/src/dotnet/ManagedMemberTypeInventory.test.ts b/src/dotnet/ManagedMemberTypeInventory.test.ts index 032c665258..28208de7e4 100644 --- a/src/dotnet/ManagedMemberTypeInventory.test.ts +++ b/src/dotnet/ManagedMemberTypeInventory.test.ts @@ -308,7 +308,6 @@ it("does not turn an unreadable requested type name into observed absence during expect(result.types.map((type) => type.full_name)).toEqual([ "Fixture.Program", ]); - expect(result.limitations.join(" ")).toContain("absence is not observed"); }); it("keeps later type identity, member ownership and constructor names at their original row", () => { @@ -364,7 +363,6 @@ it("keeps later type identity, member ownership and constructor names at their o expect(result.artifact.sha256).toBe(target.sha256); expect(result.coverage.state).toBe("partial"); expect(result.selection?.unmatched_type_names).toEqual(["Fixture.Empty0"]); - expect(result.limitations.join(" ")).toContain("absence is not observed"); // Member inspection uses the parsed-type name owner for its metadata // inventory, whose attribute names are not included in the member report. diff --git a/src/dotnet/ManagedMetadataExtraData.test.ts b/src/dotnet/ManagedMetadataExtraData.test.ts index 012e8d3352..80117d6b54 100644 --- a/src/dotnet/ManagedMetadataExtraData.test.ts +++ b/src/dotnet/ManagedMetadataExtraData.test.ts @@ -46,6 +46,15 @@ describe("CLR metadata tables ExtraData extension", () => { const plainTarget = managedPeFixtureTarget(plain); const baseline = inspectManagedArtifactBytes(plain, plainTarget); const baselineMembers = inspectManagedMembersBytes(plain, plainTarget); + expect(baselineMembers.coverage).toEqual({ + state: "complete", + issues: [], + }); + expect(baselineMembers.types.map(({ full_name }) => full_name)).toEqual([ + "Fixture.Program", + ]); + expect(baselineMembers.fields).toHaveLength(1); + expect(baselineMembers.methods).toMatchObject([{ name: "Main" }]); const bytes = buildManagedPeFixture( metadataExtraData === undefined ? {} : { metadataExtraData }, ); @@ -134,6 +143,13 @@ describe("CLR ExtraData index widths and boundaries", () => { const baselineTarget = managedPeFixtureTarget(bytes); const baseline = inspectManagedArtifactBytes(bytes, baselineTarget); const baselineMembers = inspectManagedMembersBytes(bytes, baselineTarget); + expect(baseline.module?.name).toBe("Fixture.dll"); + expect(baseline.assembly).not.toBeNull(); + expect(baselineMembers.types).toMatchObject([ + { full_name: "Fixture.Program" }, + ]); + expect(baselineMembers.fields).toHaveLength(1); + expect(baselineMembers.methods).toMatchObject([{ name: "Main" }]); const { streamHeader } = fixtureTablesStream(bytes); bytes.write("#-", streamHeader + 8, "ascii"); const target = managedPeFixtureTarget(bytes); diff --git a/src/electron/ElectronFuseCleanup.test.ts b/src/electron/ElectronFuseCleanup.test.ts index 9833db8dbc..5ef6b2811e 100644 --- a/src/electron/ElectronFuseCleanup.test.ts +++ b/src/electron/ElectronFuseCleanup.test.ts @@ -49,7 +49,6 @@ it("retains the exact rejected fuse descriptor until its owner can close it", as const provider = new ElectronFuseProvider(); try { const result = await provider.inspect({ path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected incomplete descriptor cleanup"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toEqual([path]); diff --git a/src/electron/ElectronFuseReaderCleanup.test.ts b/src/electron/ElectronFuseReaderCleanup.test.ts index 7468e2e914..9c6e1fdf16 100644 --- a/src/electron/ElectronFuseReaderCleanup.test.ts +++ b/src/electron/ElectronFuseReaderCleanup.test.ts @@ -160,7 +160,6 @@ describe("electron fuse final-close failures", () => { const result = await new ElectronFuseProvider().inspect({ path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an error result"); // A close failure with errno EACCES must not surface as a read denial. expect(result.error).not.toBeInstanceOf(AnalysisAccessDeniedError); @@ -192,7 +191,6 @@ describe("electron fuse final-close failures", () => { const result = await new ElectronFuseProvider().inspect({ path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an error result"); // The close errno must not replace the original read classification. expect(result.error).not.toBeInstanceOf(AnalysisAccessDeniedError); @@ -227,7 +225,6 @@ describe("electron fuse final-close failures", () => { { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an error result"); // Typed cancellation composed with the incomplete-cleanup report instead // of a bare cancellation that would drop the descriptor owner. @@ -255,7 +252,6 @@ describe("electron fuse final-close failures", () => { const result = await new ElectronFuseProvider().inspect({ path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an error result"); expect(result.error.cleanupIncomplete).toBe(true); // The successfully read fuse evidence survives as an explicitly partial @@ -297,7 +293,6 @@ describe("electron fuse read failure precedence", () => { { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an error result"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toContain(path); diff --git a/src/erlang/BeamParser.test.ts b/src/erlang/BeamParser.test.ts index ce304aa202..8f0ede25ec 100644 --- a/src/erlang/BeamParser.test.ts +++ b/src/erlang/BeamParser.test.ts @@ -57,6 +57,22 @@ it("selects the last table and Code payload for every repeated chunk name", () = repeated.writeUInt32BE(repeated.length - 8, 4); const report = parse(repeated); const control = parse(original); + expect(control.module).toBe("selected"); + expect(control.atoms?.map(({ name }) => name)).toEqual([ + "selected", + "module_info", + "start", + "erlang", + "get_module_info", + ]); + expect(control.exports).toHaveLength(3); + expect(control.imports).toHaveLength(1); + expect(control.lambdas).toHaveLength(1); + expect(control.code).toMatchObject({ + opcode_max: 169, + labels: 4, + functions: 2, + }); expect(report.atoms).toEqual(control.atoms); expect(report.exports).toEqual(control.exports); expect(report.imports).toEqual(control.imports); diff --git a/src/flutter/DartElf.test.ts b/src/flutter/DartElf.test.ts index a38381a7c0..8ac9c4e911 100644 --- a/src/flutter/DartElf.test.ts +++ b/src/flutter/DartElf.test.ts @@ -107,8 +107,13 @@ describe("readElfSymbol", () => { strippedImageWithSections([[tag, 0n]]), names, ); - expect(control.failures).toEqual([]); - expect(control.symbols).toHaveLength(2); + expect(control).toEqual({ + symbols: [ + { name: names[0], offset: 0x400, size: 52 }, + { name: names[1], offset: 0x800, size: 52 }, + ], + failures: [], + }); const image = strippedImageWithSections([[tag, 0xffffffffffffffffn]]); const original = Buffer.from(image); expect(await readElfSymbols(image, names)).toEqual(control); @@ -198,8 +203,13 @@ describe("dynamic symbols without a SHT_DYNSYM section", () => { ); const names = ["_kDartVmSnapshotData", "_kDartIsolateSnapshotData"]; const control = await readElfSymbols(original, names); - expect(control.failures).toEqual([]); - expect(control.symbols).toHaveLength(2); + expect(control).toEqual({ + symbols: [ + { name: names[0], offset: 0x400, size: 52 }, + { name: names[1], offset: 0x800, size: 52 }, + ], + failures: [], + }); const before = Buffer.from(image); expect(await readElfSymbols(image, names)).toEqual(control); expect(Buffer.compare(image, before)).toBe(0); @@ -555,12 +565,14 @@ it("checks raw symbol precision only after definition and requested-name selecti { name: "unselected", value: 64, size: 4 }, { name: "selected", value: 64, size: 4 }, ]); - const expected = await readElfSymbols(bytes, ["selected"]); const sectionTable = Number(bytes.readBigUInt64LE(0x28)); const symbols = Number(bytes.readBigUInt64LE(sectionTable + 64 + 0x18)); bytes.writeBigUInt64LE(0xffffffffffffffffn, symbols + 8); bytes.writeBigUInt64LE(0xffffffffffffffffn, symbols + 16); - expect(await readElfSymbols(bytes, ["selected"])).toEqual(expected); + expect(await readElfSymbols(bytes, ["selected"])).toEqual({ + symbols: [{ name: "selected", offset: 64, size: 4 }], + failures: [], + }); expect(await readElfSymbols(bytes, ["unselected"])).toEqual({ symbols: [], failures: [{ reason: "Symbol unselected has unrepresentable bounds" }], @@ -576,7 +588,6 @@ it("checks raw symbol precision only after definition and requested-name selecti it("keeps precision admission limited to consumed ELF program fields and types", async () => { const original = buildElf64Image([{ name: "selected", value: 64, size: 4 }]); - const expected = await readElfSymbols(original, ["selected"]); const bytes = appendElfRanges(original, "program", [ { type: 0x70000001, offset: 0, size: 0 }, ]); @@ -587,7 +598,10 @@ it("keeps precision admission limited to consumed ELF program fields and types", // The load mapping does not consume physical address, memory size or alignment. for (const relative of [24, 40, 48]) bytes.writeBigUInt64LE(0xffffffffffffffffn, table + relative); - expect(await readElfSymbols(bytes, ["selected"])).toEqual(expected); + expect(await readElfSymbols(bytes, ["selected"])).toEqual({ + symbols: [{ name: "selected", offset: 64, size: 4 }], + failures: [], + }); bytes.writeBigUInt64LE(0xffffffffffffffffn, table + 32); expect(await readElfSymbols(bytes, ["selected"])).toEqual({ symbols: [], @@ -597,14 +611,16 @@ it("keeps precision admission limited to consumed ELF program fields and types", it("keeps section precision checks on consumed declarations and mapping fields", async () => { const bytes = buildElf64Image([{ name: "selected", value: 64, size: 4 }]); - const expected = await readElfSymbols(bytes, ["selected"]); const table = Number(bytes.readBigUInt64LE(40)); // An unrelated null record may carry uninterpreted declaration words. for (const relative of [8, 16, 24, 32, 48, 56]) bytes.writeBigUInt64LE(0xffffffffffffffffn, table + relative); // Alignment is not consumed for this symbol-table mapping. bytes.writeBigUInt64LE(0xffffffffffffffffn, table + 64 + 48); - expect(await readElfSymbols(bytes, ["selected"])).toEqual(expected); + expect(await readElfSymbols(bytes, ["selected"])).toEqual({ + symbols: [{ name: "selected", offset: 64, size: 4 }], + failures: [], + }); bytes.writeBigUInt64LE(0xffffffffffffffffn, table + 64 + 8); expect(await readElfSymbols(bytes, ["selected"])).toEqual({ symbols: [], @@ -617,7 +633,10 @@ it("keeps section precision checks on consumed declarations and mapping fields", it("keeps ignored DT_NULL payloads separate from unsigned tag precision admission", async () => { const names = ["_kDartVmSnapshotData"]; const control = await readElfSymbols(strippedImageWithSections(), names); - expect(control.failures).toEqual([]); + expect(control).toEqual({ + symbols: [{ name: names[0], offset: 0x400, size: 52 }], + failures: [], + }); expect( await readElfSymbols( strippedImageWithSections([[0, 0xffffffffffffffffn]]), diff --git a/src/ghidra/GhidraInventoryValues.test.ts b/src/ghidra/GhidraInventoryValues.test.ts index d11449babe..9d0e3197a5 100644 --- a/src/ghidra/GhidraInventoryValues.test.ts +++ b/src/ghidra/GhidraInventoryValues.test.ts @@ -108,7 +108,6 @@ describe("native load-image result projection", () => { "inspect_native_load_image", observations, ); - expect(parsed.ok).toBe(true); if (!parsed.ok) throw parsed.error; expect(parsed.value.value).toEqual(observations); expect(parsed.value.rawResult).toBeUndefined(); @@ -125,7 +124,6 @@ describe("native load-image result projection", () => { "inspect_native_load_image", observations, ); - expect(parsed.ok).toBe(true); if (!parsed.ok) throw parsed.error; expect(parsed.value.value).toMatchObject({ entry_context: [] }); }); @@ -137,7 +135,6 @@ it("validates large masked byte queries at the provider boundary without changin mask: "ff00".repeat(1024 * 1024), }; const parsed = parseGhidraInventoryInput("search_bytes", input); - expect(parsed.ok).toBe(true); if (!parsed.ok) throw parsed.error; expect(parsed.value.pattern === input.pattern).toBe(true); expect(parsed.value.mask === input.mask).toBe(true); @@ -405,7 +402,6 @@ it.each([ throw new Error("Expected an address fixture"); Reflect.set(object as object, field, address.replace("%3A", "%3a")); const result = parseGhidraInventoryResult("search_bytes", value); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected canonical-address refusal"); expect(result.error.cause).toBeInstanceOf(z.ZodError); if (!(result.error.cause instanceof z.ZodError)) diff --git a/src/ghidra/GhidraLaunchFailure.test.ts b/src/ghidra/GhidraLaunchFailure.test.ts index 7a7bf7e5aa..1dcb25bf23 100644 --- a/src/ghidra/GhidraLaunchFailure.test.ts +++ b/src/ghidra/GhidraLaunchFailure.test.ts @@ -72,7 +72,6 @@ describe("Ghidra launch failure diagnostics", () => { const launched = await probeLauncher(javaHome, runtimeRoot).launch( launchSession(runtimeRoot), ); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("expected the launch to fail"); expect(launched.error).toBeInstanceOf(GhidraLaunchError); expect(launched.error.message).toBe("Ghidra headless launch failed"); @@ -106,7 +105,6 @@ describe("Ghidra launch failure diagnostics", () => { const launched = await probeLauncher(javaHome, runtimeRoot).launch( launchSession(runtimeRoot), ); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("expected the launch to fail"); const outcome = launchOutcomeOf(launched.error); expect(outcome?.["stderrTruncated"]).toBe(true); @@ -134,7 +132,6 @@ describe("Ghidra launch failure diagnostics", () => { bridgeScriptPath: join(runtimeRoot, "bridge", "ReaGhidraBridge.java"), }); const launched = await launcher.launch(launchSession(runtimeRoot)); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("expected the launch to fail"); expect(launched.error).toBeInstanceOf(GhidraLaunchError); expect(launched.error.message).toBe("Ghidra headless launch failed"); diff --git a/src/ghidra/GhidraLoadImageValues.test.ts b/src/ghidra/GhidraLoadImageValues.test.ts index 6b4c1f5efd..fd3e57bb12 100644 --- a/src/ghidra/GhidraLoadImageValues.test.ts +++ b/src/ghidra/GhidraLoadImageValues.test.ts @@ -367,7 +367,6 @@ it("preserves zero-padded, qualified, and large observation addresses", () => { "inspect_native_load_image", jsonValueSchema.parse(observation), ); - expect(parsed.ok).toBe(true); if (!parsed.ok) throw parsed.error; expect(parsed.value.value).toEqual(observation); }); diff --git a/src/ghidra/GhidraProvider.behavior.test.ts b/src/ghidra/GhidraProvider.behavior.test.ts index 281fb16c07..2f8542e089 100644 --- a/src/ghidra/GhidraProvider.behavior.test.ts +++ b/src/ghidra/GhidraProvider.behavior.test.ts @@ -2482,7 +2482,6 @@ it.each([ const detail = await client.execute("inspect_native_data_type", { address, }); - expect(detail.ok).toBe(true); if (!detail.ok) throw detail.error; expect(detail.value.result).toMatchObject({ address: resolvedAddress }); if (expectedTable === null) { diff --git a/src/ghidra/GhidraRiscvProfile.test.ts b/src/ghidra/GhidraRiscvProfile.test.ts index 6d679db0b4..3851a99ecd 100644 --- a/src/ghidra/GhidraRiscvProfile.test.ts +++ b/src/ghidra/GhidraRiscvProfile.test.ts @@ -278,7 +278,6 @@ const registerRiscvAdmissionAndCapabilityCases = () => { const resolved = await ghidra({ REA_GHIDRA_LANGUAGE_ID: "RISCV:LE:32:AndeStar_v5", }).resolveAnalysisProfile(target({ elfClass: 32 })); - expect(resolved.ok).toBe(false); if (resolved.ok) throw new Error("expected a refusal"); expect(resolved.error.message).toContain("generic little-endian RISC-V"); expect(resolved.error).toMatchObject({ diff --git a/src/hopper/HopperAnalysisProfile.test.ts b/src/hopper/HopperAnalysisProfile.test.ts index 4dbc491000..7546f6b282 100644 --- a/src/hopper/HopperAnalysisProfile.test.ts +++ b/src/hopper/HopperAnalysisProfile.test.ts @@ -211,7 +211,6 @@ it("commits a thin header selection only for derived Hopper loader arguments", a provider, resourceScope: inspectionResources.owner, }); - expect(staleAdmission.ok).toBe(false); if (staleAdmission.ok) throw new Error("stale thin admission was accepted"); expect(staleAdmission.error.message).toContain( "Thin Mach-O source changed after target admission", @@ -354,7 +353,6 @@ it("keeps failed Mach-O preflight cleanup attached to the supplied profile owner }, ); - expect(resolved.ok).toBe(false); if (resolved.ok) throw new Error("Failed preflight cleanup was accepted"); expect(resolved.error._tag).toBe("BinaryTargetError"); expect(resolved.error.cause).toBe(closeFailure); @@ -489,7 +487,6 @@ it.each([ ...options, signal: controller.signal, }); - expect(first.ok).toBe(false); if (first.ok) throw new Error("Failed close was accepted"); expect(first.error.cleanupIncomplete).toBe(true); expect(first.error.cleanupResources).toEqual([path]); @@ -521,7 +518,6 @@ it.each([ : "AnalysisCancelledError", ); const retry = await resolveHopperAnalysisProfile(target, options); - expect(retry.ok).toBe(false); if (retry.ok) throw new Error("Failed cleanup retry was accepted"); expect(retry.error.cleanupIncomplete).toBe(true); expect(retry.error.cleanupResources).toEqual([path]); diff --git a/src/hopper/HopperMachOImage.copyLifecycle.test.ts b/src/hopper/HopperMachOImage.copyLifecycle.test.ts index 2da4c55d48..548ad5d0aa 100644 --- a/src/hopper/HopperMachOImage.copyLifecycle.test.ts +++ b/src/hopper/HopperMachOImage.copyLifecycle.test.ts @@ -86,7 +86,6 @@ it("keeps an observer failure primary and closes real source handles", async () resourceScope: new ArtifactResourceScope(), }); - expect(prepared.ok).toBe(false); if (prepared.ok) throw new Error("A failed copy was accepted"); expect(prepared.error.cause).toBe(writeFailure); expect(prepared.error.cleanupIncomplete).toBe(false); @@ -117,7 +116,6 @@ it("keeps a copy failure primary while retaining and retrying a real source hand fileSystem, }); - expect(prepared.ok).toBe(false); if (prepared.ok) throw new Error("A failed copy was accepted"); expect(prepared.error.cause).toBe(writeFailure); expect(prepared.error.cleanupIncomplete).toBe(true); @@ -158,7 +156,6 @@ it("keeps an output-close failure primary when cancellation first arrives during { fileSystem, resourceScope, signal: controller.signal }, ); - expect(prepared.ok).toBe(false); if (prepared.ok) throw new Error("Failed output closure was accepted"); expect(prepared.error).toBeInstanceOf(HopperStartError); expect(prepared.error.cause).toBe(outputCloseFailure); @@ -203,7 +200,6 @@ it("keeps cancellation observed before close primary and retains an output-close }, ); - expect(prepared.ok).toBe(false); if (prepared.ok) throw new Error("Cancelled copy was accepted"); expect(prepared.error).toBeInstanceOf(HopperCancelledError); expect(prepared.error.cause).toBe(reason); @@ -247,7 +243,6 @@ it("preserves a physical preflight read failure and retains the handle after clo fileSystem, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Read failure was accepted"); expect(result.error).toBeInstanceOf(BinaryTargetError); expect(result.error.cause).toBe(readFailure); @@ -293,7 +288,6 @@ it("retains exact cancellation during preflight close without replacing its clos signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Close failure was accepted"); expect(result.error).toBeInstanceOf(BinaryTargetError); expect(result.error.cause).toBe(closeFailure); diff --git a/src/hopper/HopperMachOImage.test.ts b/src/hopper/HopperMachOImage.test.ts index e947b09d2a..b8245d50a4 100644 --- a/src/hopper/HopperMachOImage.test.ts +++ b/src/hopper/HopperMachOImage.test.ts @@ -454,7 +454,6 @@ it("retains the caller reason when a FAT copy is cancelled after its final write }, ); - expect(prepared.ok).toBe(false); if (prepared.ok) throw new Error("Cancelled FAT copy was accepted"); expect(prepared.error._tag).toBe("HopperCancelledError"); expect(prepared.error.cause).toBe(reason); @@ -526,7 +525,6 @@ it("retains a failed prepared-image close through launcher cleanup and blocks an token: "fixture-token", runId: "fixture-run-1", }); - expect(initial.ok).toBe(false); if (initial.ok) throw new Error("A copy with failed close was accepted"); expect(initial.error._tag).toBe("HopperStartError"); expect(initial.error.cause).toBe(firstCloseFailure); @@ -540,7 +538,6 @@ it("retains a failed prepared-image close through launcher cleanup and blocks an token: "fixture-token", runId: "fixture-run-2", }); - expect(blocked.ok).toBe(false); if (blocked.ok) throw new Error("A launch bypassed retained file cleanup"); expect(blocked.error.cleanupIncomplete).toBe(true); expect(blocked.error.cleanupResources).toEqual([ @@ -614,7 +611,6 @@ it("observes caller cancellation that arrives during final source-handle cleanup }, ); - expect(prepared.ok).toBe(false); if (prepared.ok) throw new Error("Finalization cancellation was ignored"); expect(prepared.error._tag).toBe("HopperCancelledError"); expect(prepared.error.cause).toBe(reason); @@ -729,7 +725,6 @@ it("does not launch a thin selection when its admitted source changes before cop token: "fixture-token", runId: "fixture-run", }); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("Changed source reached Hopper launch"); expect(launched.error.userMessage).toContain( "no longer agrees with its admitted digest, size, or selected header", @@ -817,7 +812,6 @@ it("retains an owned partial thin image and exact cancellation reason after a wr finishWrite(); const prepared = await preparing; - expect(prepared.ok).toBe(false); if (prepared.ok) throw new Error("Cancelled partial copy was accepted"); expect(prepared.error._tag).toBe("HopperCancelledError"); expect(prepared.error.cause).toBe(reason); @@ -837,7 +831,6 @@ it.each([0, 129])( const result = await resolveHopperMachOImage( fat32Target(path, fixture, "arm64"), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Invalid FAT count was admitted"); expect(result.error).toMatchObject({ _tag: "BinaryTargetError", diff --git a/src/hopper/HopperRequestQueue.test.ts b/src/hopper/HopperRequestQueue.test.ts index 6e2aa6a950..657ecc30c2 100644 --- a/src/hopper/HopperRequestQueue.test.ts +++ b/src/hopper/HopperRequestQueue.test.ts @@ -313,7 +313,6 @@ describe("HopperRequestQueue caller abort reasons", () => { {}, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(HopperCancelledError); expect(result.error.cause).toBe(reason); @@ -326,7 +325,6 @@ describe("HopperRequestQueue caller abort reasons", () => { const pending = queue.run(1, "echo", {}, { signal: controller.signal }); controller.abort(reason); const result = await pending; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error.cause).toBe(reason); expect(sent).toEqual([1]); @@ -343,7 +341,6 @@ describe("HopperRequestQueue caller abort reasons", () => { const queued = queue.run(2, "queued", {}, { signal: controller.signal }); controller.abort(reason); const result = await queued; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error.cause).toBe(reason); expect(queue.hasQueued(2)).toBe(false); diff --git a/src/hopper/HopperSocketConnection.test.ts b/src/hopper/HopperSocketConnection.test.ts index 0d67984da5..15c0eab532 100644 --- a/src/hopper/HopperSocketConnection.test.ts +++ b/src/hopper/HopperSocketConnection.test.ts @@ -15,7 +15,6 @@ it("retains the caller abort reason when the socket signal is already aborted", controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(HopperCancelledError); expect(result.error.cause).toBe(reason); diff --git a/src/ida/IdaConfiguration.test.ts b/src/ida/IdaConfiguration.test.ts index 92317c2e5f..41c50bdf88 100644 --- a/src/ida/IdaConfiguration.test.ts +++ b/src/ida/IdaConfiguration.test.ts @@ -137,7 +137,6 @@ describe("IDA registration descriptor ownership", () => { const result = await readIdaConfiguration(path, { resourceScope: owner, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected close failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(retained).toHaveLength(1); @@ -298,7 +297,6 @@ it.each(["env", "headers"] as const)( : { url: "http://127.0.0.1:8745/mcp" }; await writeFile(path, JSON.stringify({ ...transport, [field]: mapping })); const result = await read(path); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; const parsed = field === "env" && "env" in result.value diff --git a/src/ida/IdaSessionClient.test.ts b/src/ida/IdaSessionClient.test.ts index 0b96a4b83e..e5f8d6be85 100644 --- a/src/ida/IdaSessionClient.test.ts +++ b/src/ida/IdaSessionClient.test.ts @@ -127,7 +127,6 @@ it.each([ producer, ); const result = await client.execute("list_procedures", {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected connection failure"); expect(result.error.diagnostics).toMatchObject({ endpoint: selected }); expect(JSON.stringify(projectAnalysisError(result.error))).not.toContain( @@ -162,7 +161,6 @@ it.each([ producer, ); const result = await client.execute("list_procedures", {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected connection failure"); const output = JSON.stringify(projectAnalysisError(result.error)); expect(output).not.toContain("fixture-secret"); @@ -196,7 +194,6 @@ it.each(["initialize", "transport"])( const connect = vi.spyOn(producer, "connect").mockRejectedValue(source); for (const requested of ["list_procedures", "list_strings"] as const) { const result = await client.execute(requested, {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected startup failure"); expect(result.error).toBeInstanceOf(ProviderAdapterError); expect(result.error).toMatchObject({ @@ -1214,7 +1211,6 @@ describe("IDA compatibility profile mismatch", () => { const { producer, client } = await fixture("attached", 1000, "native"); producer.tools = []; const result = await client.execute("health", {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected incompatible native catalog"); expect(projectAnalysisError(result.error).details).toMatchObject({ diagnostics: { @@ -2015,7 +2011,6 @@ it.each(["unavailable", "malformed"] as const)( throw new Error("inventory unavailable"); }; const result = await client.close(); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained cleanup"); expect(result.error).not.toHaveProperty("diagnostics.upstream_sessions"); }, diff --git a/src/inspector/JavaScriptRuntimeScope.cancellation.test.ts b/src/inspector/JavaScriptRuntimeScope.cancellation.test.ts index 2beed047f3..822fe091d6 100644 --- a/src/inspector/JavaScriptRuntimeScope.cancellation.test.ts +++ b/src/inspector/JavaScriptRuntimeScope.cancellation.test.ts @@ -139,7 +139,6 @@ it("stops Inspector target authorization after the current stat settles", async { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected Inspector listing cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); @@ -181,7 +180,6 @@ it("stops Electron target authorization after the current stat settles", async ( { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected Electron listing cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); @@ -220,7 +218,6 @@ it("retains a target whose authorization completes before the next abort check", { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected Electron listing cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); diff --git a/src/inspector/V8InspectorEndpoint.test.ts b/src/inspector/V8InspectorEndpoint.test.ts index 63eb761e01..f92b969267 100644 --- a/src/inspector/V8InspectorEndpoint.test.ts +++ b/src/inspector/V8InspectorEndpoint.test.ts @@ -72,7 +72,6 @@ it.each([ runtime_kind: kind, observation_ms: 0, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected Inspector admission refusal"); const diagnostic = projectAnalysisError(result.error); expect(diagnostic).toMatchObject({ diff --git a/src/inspector/V8InspectorProvider.closeOwnership.test.ts b/src/inspector/V8InspectorProvider.closeOwnership.test.ts index ef592d4996..01202aaf0c 100644 --- a/src/inspector/V8InspectorProvider.closeOwnership.test.ts +++ b/src/inspector/V8InspectorProvider.closeOwnership.test.ts @@ -181,7 +181,6 @@ it("retains cancelled final-close ownership and retries the exact transport befo await observing; }, ]); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cleanup-incomplete cancellation"); const error = result.error; expect(error.cleanupIncomplete).toBe(true); @@ -212,7 +211,6 @@ it("retains cancelled final-close ownership and retries the exact transport befo closeFailures.add(5); const cleanupOnly = await observeJavaScriptRuntime(provider(), input); - expect(cleanupOnly.ok).toBe(false); if (cleanupOnly.ok) throw new Error("Expected close-only cleanup failure"); expect(cleanupOnly.error.cleanupIncomplete).toBe(true); expect(cleanupOnly.error.cleanupResources).toEqual(["browser_transport"]); diff --git a/src/javascript/analysis/JavaScriptAnalysisTransfer.recovery.test.ts b/src/javascript/analysis/JavaScriptAnalysisTransfer.recovery.test.ts index cac61f54b1..9a107cc514 100644 --- a/src/javascript/analysis/JavaScriptAnalysisTransfer.recovery.test.ts +++ b/src/javascript/analysis/JavaScriptAnalysisTransfer.recovery.test.ts @@ -6,7 +6,6 @@ import { projectAnalysisError } from "../../domain/analysisErrorProjection.js"; import { javaScriptForwardedTransferRemediation, javaScriptTransferByteBudget, - javaScriptTransferCeilingRemediation, measureJavaScriptModuleTransfer, } from "./JavaScriptAnalysisTransfer.js"; @@ -35,9 +34,15 @@ it("distinguishes the adjustable transfer file ceiling from the fixed record and }, }, }); - expect(projected.remediation.action).toBe( - javaScriptTransferCeilingRemediation(measured.bytes - 1), + expect(projected.remediation.action).toContain(String(measured.bytes - 1)); + expect(projected.remediation.action).toMatch( + /8388608.byte.*2147483648.byte.*no runtime override/iu, ); + expect(projected.remediation.action).toMatch( + /source_paths.*effective file allowance/iu, + ); + expect(projected.remediation.action).toMatch(/max_heap_mb does not raise/iu); + expect(projected.remediation.action).toMatch(/repeated unchanged/iu); const forwarded = javaScriptForwardedTransferRemediation( caught.reportedLimits, ); @@ -45,7 +50,10 @@ it("distinguishes the adjustable transfer file ceiling from the fixed record and const recordOnly = javaScriptForwardedTransferRemediation({ transfer_record_bytes: 8_388_608, }); - expect(recordOnly).toBe(javaScriptTransferCeilingRemediation(undefined)); + expect(recordOnly).toMatch( + /effective transfer file ceiling follows.*parent.*heap/iu, + ); + expect(recordOnly).toMatch(/record ceiling.*maximum.*no runtime override/iu); expect(javaScriptForwardedTransferRemediation(null)).toBeUndefined(); }); @@ -53,7 +61,9 @@ it("keeps the 2 GiB transfer file maximum fixed", () => { const maximum = 2_147_483_648; expect(javaScriptTransferByteBudget(maximum * 8)).toBe(maximum); expect(javaScriptTransferByteBudget(maximum * 16)).toBe(maximum); - expect( - javaScriptForwardedTransferRemediation({ transfer_file_bytes: maximum }), - ).toBe(javaScriptTransferCeilingRemediation(maximum)); + const recovery = javaScriptForwardedTransferRemediation({ + transfer_file_bytes: maximum, + }); + expect(recovery).toMatch(/2147483648.byte.*maximum.*no runtime override/iu); + expect(recovery).toMatch(/fewer source_paths does not raise.*maximum/iu); }); diff --git a/src/javascript/sourceMaps/SourceMapCommand.test.ts b/src/javascript/sourceMaps/SourceMapCommand.test.ts index 669a632742..81d7bbebe0 100644 --- a/src/javascript/sourceMaps/SourceMapCommand.test.ts +++ b/src/javascript/sourceMaps/SourceMapCommand.test.ts @@ -99,7 +99,6 @@ it("preserves the exact object reason for an already-aborted caller", async () = }, unexpectedCleanup, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); @@ -178,7 +177,6 @@ it("preserves exact caller reason when cancellation precedes process exit", asyn }, () => setTimeout(() => controller.abort(reason), 0), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); @@ -222,7 +220,6 @@ it("preserves an observed nonzero exit before caller cancellation during output waitSpy.mockRestore(); } expect(observedBeforeAbort).toEqual({ code: 7, signal: null }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected physical failure"); expect(result.error._tag).toBe("ProviderAdapterError"); expect(result.error.diagnostics).toMatchObject({ @@ -236,7 +233,6 @@ it("preserves an observed nonzero exit before caller cancellation during output it("classifies the same nonzero exit without cancellation", async () => { const result = await runChild(undefined, exitsAfterHoldingOutput); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected physical failure"); expect(result.error).toMatchObject({ _tag: "ProviderAdapterError", @@ -255,7 +251,6 @@ it("stops a held drain after late output exceeds budget but keeps the exit prima exitsThenDescendantExceedsStderrBudget, ); const elapsedMs = performance.now() - startedAt; - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected physical failure"); expect(result.error._tag).toBe("ProviderAdapterError"); expect(result.error.diagnostics).toMatchObject({ @@ -322,7 +317,6 @@ it("preserves an observed process-memory limit over the codec exit status", asyn waitSpy.mockRestore(); } expect(observedBeforeAbort).toEqual({ code: 3, signal: null }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected memory-limit failure"); expect(result.error).toBeInstanceOf(AnalysisResourceConstraintError); expect(result.error).toMatchObject({ @@ -363,7 +357,6 @@ it("keeps a timeout distinct from caller cancellation", async () => { }, unexpectedCleanup, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected timeout"); expect(result.error).toBeInstanceOf(AnalysisTimeoutError); if (runtimePath === undefined) throw new Error("runtime was not acquired"); @@ -400,7 +393,6 @@ it("applies a non-default decode deadline and releases its runtime", async () => unexpectedCleanup, 250, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected timeout"); expect(result.error).toBeInstanceOf(AnalysisTimeoutError); expect(result.error.userMessage).toContain("250"); diff --git a/src/javascript/sourceMaps/SourceMapDecoder.test.ts b/src/javascript/sourceMaps/SourceMapDecoder.test.ts index 7e08c96d4f..31c8eeb7cc 100644 --- a/src/javascript/sourceMaps/SourceMapDecoder.test.ts +++ b/src/javascript/sourceMaps/SourceMapDecoder.test.ts @@ -30,7 +30,6 @@ it("preserves the exact caller reason before source-map admission", async () => const response = await new SourceMapDecoder().trace(input, { signal: controller.signal, }); - expect(response.ok).toBe(false); if (response.ok) throw new Error("expected cancellation"); expect(response.error).toBeInstanceOf(AnalysisCancelledError); expect(response.error.cause).toBe(reason); diff --git a/src/jeb/JebProvider.test.ts b/src/jeb/JebProvider.test.ts index 8acdad1702..270922996e 100644 --- a/src/jeb/JebProvider.test.ts +++ b/src/jeb/JebProvider.test.ts @@ -643,7 +643,6 @@ it("project-open refusal retains the selected engine-host artifact path", async operation: "open_jeb_project", input: { path: "/targets/Example.apk" }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Refused artifact accepted"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "execution_failure", @@ -712,7 +711,6 @@ it.each([ const result = await provider.execute(request, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Cancelled metadata lookup accepted"); expect(result.error).toMatchObject({ _tag: "AnalysisCancelledError", @@ -740,7 +738,6 @@ it.each([ }), ); const completed = await control.execute(request); - expect(completed.ok).toBe(true); if (!completed.ok) throw completed.error; expect(completed.value.result).toMatchObject({ engine: { version: "5.48.0" }, diff --git a/src/mcpDoctor.ts b/src/mcpDoctor.ts index 35e61bb7a4..a1a808e6c1 100644 --- a/src/mcpDoctor.ts +++ b/src/mcpDoctor.ts @@ -69,7 +69,6 @@ interface McpDoctorOptions { readonly args: readonly string[]; readonly cwd: string; readonly environment: Readonly>; - readonly deadlineMs?: number; } interface InventoryComparison { @@ -112,10 +111,7 @@ export const runProductionMcpDoctor = async (options: McpDoctorOptions) => { }, }; const expectation = doctorExpectationForEnvironment(options.environment); - const budget = appliedDoctorBudget( - parsedBudgets.value.doctor, - options.deadlineMs, - ); + const budget = parsedBudgets.value.doctor; const budgetMs = budget.milliseconds; const deadline = performance.now() + budgetMs; const controller = new AbortController(); @@ -685,23 +681,3 @@ const doctorTransportDetail = ( (cause instanceof SdkError && cause.code === SdkErrorCode.RequestTimeout); return timedOut ? `${message} ${mcpDoctorDeadlineRecovery(budget)}` : message; }; - -/** - * `deadlineMs` is a caller-selected applied deadline, used by tests. Omitted - * means the budget resolved from `REA_MCP_DOCTOR_DEADLINE_MS`. - */ -const appliedDoctorBudget = ( - resolved: McpPhaseBudget, - deadlineMs: number | undefined, -): McpPhaseBudget => - deadlineMs === undefined - ? resolved - : { - ...resolved, - milliseconds: deadlineMs, - source: - deadlineMs === resolved.defaultMilliseconds && - resolved.source === "default" - ? "default" - : "setting", - }; diff --git a/src/native/AppleMachoFixups.test.ts b/src/native/AppleMachoFixups.test.ts index 16accc9a10..d44825707f 100644 --- a/src/native/AppleMachoFixups.test.ts +++ b/src/native/AppleMachoFixups.test.ts @@ -1149,7 +1149,7 @@ describe("bounded chained page facts", () => { { facet: "pointer_fixups", code: "chained_pointer_walk_failed", - message: "Chained pointer link leaves its file-backed page", + message: expect.stringContaining("file-backed page"), location: "0x100004000", }, ]); @@ -1351,7 +1351,7 @@ describe("malformed chained pointer coverage", () => { { facet: "pointer_fixups", code: "chained_pointer_walk_failed", - message: "Chained pointer link leaves its file-backed page", + message: expect.stringContaining("file-backed page"), location: "0x100005000", }, ]); diff --git a/src/native/NativeCallObservation.test.ts b/src/native/NativeCallObservation.test.ts index b7f71e1a9a..a64dc667ee 100644 --- a/src/native/NativeCallObservation.test.ts +++ b/src/native/NativeCallObservation.test.ts @@ -60,7 +60,6 @@ it.each([null, 0, new ProviderCleanupError("foreign", ["unowned"], {})])( resources, controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected owned hash cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); @@ -92,7 +91,6 @@ it.each([false, true])( resources, controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected physical read failure"); expect(result.error).toMatchObject({ _tag: "ProviderAdapterError", diff --git a/src/native/NativeCommandDeadline.test.ts b/src/native/NativeCommandDeadline.test.ts index dc391f9ce5..9925d5eb2a 100644 --- a/src/native/NativeCommandDeadline.test.ts +++ b/src/native/NativeCommandDeadline.test.ts @@ -91,7 +91,6 @@ describe("native_command_timeout_ms", () => { const result = await runner.run("lipo", ["-info", "/fixture/app"], { timeoutMs: 120_000, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected resolution timeout"); expect(result.error.reason).toBe("timeout"); expect(calls).toEqual([ diff --git a/src/native/NativeMachoOperand.test.ts b/src/native/NativeMachoOperand.test.ts index 828b1be89d..5ac7a6b85c 100644 --- a/src/native/NativeMachoOperand.test.ts +++ b/src/native/NativeMachoOperand.test.ts @@ -195,7 +195,6 @@ describe("private operand command cleanup", () => { ).createClient((await parenthesizedTarget()).target); try { const result = await client.execute("inspect_macho", {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cleanup failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.partialObservation).toMatchObject({ @@ -257,7 +256,6 @@ describe("private otool operand cleanup", () => { ).createClient((await parenthesizedTarget()).target); try { const result = await client.execute("inspect_macho", {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected native failure"); expect(result.error.capturedOutput?.stderr).toBe(message); expect(result.error.cleanupIncomplete).toBe(cleanupFails); @@ -291,7 +289,6 @@ describe("private otool operand cleanup", () => { ).createClient((await parenthesizedTarget()).target); try { const result = await client.execute("inspect_macho", {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cleanup failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toContain(path); @@ -326,7 +323,6 @@ describe("private otool operand cleanup", () => { {}, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.partialObservation).toMatchObject({ diff --git a/src/native/NativeUiObservation.test.ts b/src/native/NativeUiObservation.test.ts index 88a6165c0d..8ecf8ed90b 100644 --- a/src/native/NativeUiObservation.test.ts +++ b/src/native/NativeUiObservation.test.ts @@ -248,7 +248,6 @@ describe("native UI capture selection and budgets", () => { }, }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected scenario cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(controller.signal.reason); @@ -274,7 +273,6 @@ describe("native UI capture selection and budgets", () => { invoke: async () => ({ ok: true, result: largeSnapshot }), }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected scenario output limit failure"); expect(result.error._tag).toBe("AnalysisCapabilityUnavailableError"); expect(result.error.partialObservation).toMatchObject({ @@ -311,7 +309,6 @@ describe("native UI deadline execution", () => { }, }, ); - expect(result.ok).toBe(true); if (!result.ok) throw new Error("expected a completed scenario"); const limitation = result.value.limitations.join("\n"); expect(limitation).toContain("selected native_ui_deadline_ms of 2500 ms"); @@ -327,7 +324,6 @@ describe("native UI deadline execution", () => { environment: {}, invoke: async () => ({ ok: true, result: snapshot }), }); - expect(result.ok).toBe(true); if (!result.ok) throw new Error("expected a completed observation"); const limitation = result.value.limitations.join("\n"); expect(limitation).toContain("selected native_ui_deadline_ms of 180000 ms"); @@ -354,7 +350,6 @@ describe("native UI deadline execution", () => { throw new ExecFileOutputCancelledError(reason); }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected deadline timeout"); expect(result.error).toBeInstanceOf(AnalysisTimeoutError); expect(result.error.cause).toBe(reason); @@ -377,7 +372,6 @@ describe("native UI deadline execution", () => { throw new ExecFileOutputCancelledError(producerReason); }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected producer cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(producerReason); @@ -409,7 +403,6 @@ describe("native UI deadline execution", () => { }, }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected deadline timeout"); expect(result.error).toBeInstanceOf(AnalysisTimeoutError); expect(result.error.cause).toBe(reason); @@ -442,7 +435,6 @@ it("classifies a helper subprocess timeout as the selected UI deadline", async ( }, }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected helper deadline timeout"); expect(result.error).toBeInstanceOf(AnalysisTimeoutError); const projected = projectAnalysisError(result.error); @@ -476,7 +468,6 @@ describe("native UI interruption provenance", () => { }, ); clearTimeout(timer); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected deadline timeout"); expect(result.error).toBeInstanceOf(AnalysisTimeoutError); expect(result.error.cause).toBe(reason); @@ -494,7 +485,6 @@ describe("native UI interruption provenance", () => { signal: caller.signal, invoke: async () => ({ ok: true, result: snapshot }), }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected caller cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -517,7 +507,6 @@ describe("native UI interruption provenance", () => { throw failure; }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected helper failure"); expect(result.error._tag).toBe("ProviderAdapterError"); expect(result.error.cause).toBe(failure); @@ -539,7 +528,6 @@ describe("native UI interruption provenance", () => { return { ok: true, result: { malformed: true } }; }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected schema failure"); expect(result.error._tag).toBe("ProviderAdapterError"); expect(result.error.cause).toMatchObject({ name: "ZodError" }); @@ -629,7 +617,6 @@ describe("native UI target and cancellation failures", () => { launch_time: 1, action: { kind: "scroll", path: [1] }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed action"); expect(result.error._tag).toBe("AnalysisCapabilityUnavailableError"); expect(result.error.partialObservation).toMatchObject({ @@ -661,7 +648,6 @@ describe("native UI target and cancellation failures", () => { }, ); expect(calls).toBe(1); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected scenario cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(controller.signal.reason); diff --git a/src/native/SignatureTargetBinding.test.ts b/src/native/SignatureTargetBinding.test.ts index f6ca2b5553..aa9db2a9e9 100644 --- a/src/native/SignatureTargetBinding.test.ts +++ b/src/native/SignatureTargetBinding.test.ts @@ -313,7 +313,6 @@ it("releases retained descriptors before retrying their containing root", async undefined, () => createRoot(1), ); - expect(first.ok).toBe(false); if (first.ok) throw new Error("Expected both retained owners"); const snapshot = join(roots[0]!, "target.bin"); expect(new Set(first.error.cleanupResources)).toEqual( @@ -326,7 +325,6 @@ it("releases retained descriptors before retrying their containing root", async undefined, createRoot, ); - expect(retried.ok).toBe(false); if (retried.ok) throw new Error("Expected retained root retry failure"); expect(first.error.cleanupIncomplete).toBe(true); expect(first.error.cleanupResources).toEqual([roots[0]!]); @@ -374,7 +372,6 @@ it("retains the snapshot root until its failed descriptor owner confirms release undefined, async () => ({ path: root.path, close: removeRoot }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained snapshot descriptor"); expect(removeRoot).not.toHaveBeenCalled(); expect((await stat(root.path)).isDirectory()).toBe(true); @@ -428,7 +425,6 @@ for (const cleanupFails of [false, true]) }, }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected finalization cancellation"); expect(result.error.partialObservation).toEqual(facts); expect(result.error.cleanupIncomplete).toBe(cleanupFails); @@ -517,7 +513,6 @@ it("keeps a physical source read failure primary when the caller also aborts", a controller.signal, createRoot, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected physical failure"); expect(result.error._tag).toBe("ProviderAdapterError"); expect(result.error.cause).toBe(failure); @@ -547,7 +542,6 @@ for (const cleanupFails of [false, true]) }, }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed inspection"); expect(result.error.cleanupIncomplete).toBe(cleanupFails); await resources.close(); @@ -567,7 +561,6 @@ it.each(opaqueReasons)( AbortSignal.abort(reason), makeRoot, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected pre-entry cancellation"); expect(result.error).toMatchObject({ _tag: "AnalysisCancelledError", @@ -595,7 +588,6 @@ it("does not replace a failed root creation with a simultaneous abort", async () throw failure; }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected root creation failure"); expect(result.error).toMatchObject({ _tag: "ProviderAdapterError", @@ -621,7 +613,6 @@ it("releases a late root when cancellation arrives during creation", async () => return root; }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected root handoff cancellation"); expect(result.error).toMatchObject({ _tag: "AnalysisCancelledError", @@ -645,7 +636,6 @@ it("does not adopt an inspection's arbitrary thrown cleanup marker", async () => undefined, createRoot, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected opaque producer failure"); expect(result.error).toMatchObject({ _tag: "AnalysisOutputError", diff --git a/src/native/elf/ElfNotesProvider.test.ts b/src/native/elf/ElfNotesProvider.test.ts index bd199cb07c..e810250b0e 100644 --- a/src/native/elf/ElfNotesProvider.test.ts +++ b/src/native/elf/ElfNotesProvider.test.ts @@ -52,7 +52,6 @@ describe("ELF note provider failures", () => { const path = join(root, "program"); await writeFile(path, elfNoteTablePastEnd()); const result = await inspect(path); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected invalid input"); expect(result.error).toBeInstanceOf(AnalysisInputError); expect(result.error).toMatchObject({ @@ -74,7 +73,6 @@ describe("ELF note provider failures", () => { const path = join(root, "extended-count.elf"); await writeFile(path, elfExtendedSectionCountFixture()); const result = await inspect(path); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an unsupported target"); expect(result.error).toBeInstanceOf(AnalysisUnsupportedTargetError); expect(result.error.message).toMatch(/extended.*number/iu); @@ -95,7 +93,6 @@ describe("ELF note provider failures", () => { }), ); const result = await inspect(path); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a text budget refusal"); const error = result.error as AnalysisResourceConstraintError; expect(error.resource).toBe("memory"); @@ -115,7 +112,6 @@ describe("ELF note provider failures", () => { const path = join(root, "program"); await writeFile(path, elfNoteFixture({ ownership: "program" })); const result = await inspect(path, { max_file_bytes: 64 }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a file-size refusal"); const error = result.error as AnalysisResourceConstraintError; expect(error.resource).toBe("file-size"); @@ -137,7 +133,6 @@ describe("ELF note provider failures", () => { await writeFile(path, bytes); const refused = await inspect(path, { max_file_bytes: bytes.length + 1 }); - expect(refused.ok).toBe(false); if (refused.ok) throw new Error("Expected section-name admission refusal"); expect(refused.error).toBeInstanceOf(AnalysisResourceConstraintError); if (!(refused.error instanceof AnalysisResourceConstraintError)) diff --git a/src/native/metadata/PeImage.test.ts b/src/native/metadata/PeImage.test.ts index 8db7150c02..60174ff0fb 100644 --- a/src/native/metadata/PeImage.test.ts +++ b/src/native/metadata/PeImage.test.ts @@ -83,7 +83,7 @@ it.each([32, 64] as const)( for (const encoding of ["inline", "pointer"] as const) { const fixture = createGoBinaryFixture({ format: "pe", bits, encoding }); const expected = readGoBinaryImage(fixture.bytes).build_info; - expect(expected).not.toBeNull(); + expect(expected).toMatchObject({ go_version: "go1.26.0" }); setGoPeVirtualSize(fixture.bytes, 0); const container = readPeImage(fixture.bytes); @@ -136,6 +136,7 @@ it.each([32, 64] as const)( it("keeps Go fallback candidates when a PE section has no printable name", () => { const fixture = createGoBinaryFixture({ format: "pe", bits: 64 }); const expected = readGoBinaryImage(fixture.bytes).build_info; + expect(expected).toMatchObject({ go_version: "go1.26.0" }); const pe = fixture.bytes.readUInt32LE(0x3c); const section = pe + 24 + fixture.bytes.readUInt16LE(pe + 20); fixture.bytes.fill(0, section, section + 8); diff --git a/src/native/parsers/plist.test.ts b/src/native/parsers/plist.test.ts index eda100fcdd..68f594b1d1 100644 --- a/src/native/parsers/plist.test.ts +++ b/src/native/parsers/plist.test.ts @@ -4,11 +4,7 @@ import { MAX_JSON_DEPTH, jsonValueSchema } from "../../domain/jsonValue.js"; import { projectAnalysisError } from "../../domain/analysisErrorProjection.js"; import { plistUidValue } from "../../domain/apple/plistUid.js"; import { createPlistNumberProjection } from "../../domain/apple/plistNumbers.js"; -import { - nonFiniteRealLimitation, - projectPlistValue, - unknownScalarLimitation, -} from "../../domain/apple/plistValue.js"; +import { projectPlistValue } from "../../domain/apple/plistValue.js"; import { parseXmlPropertyList } from "../../domain/propertyListKeys.js"; import { decodeBinaryPlistScalars, @@ -88,7 +84,6 @@ it.each([ : undefined, ); if (depth > maximum) { - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected nesting refusal"); if (parsed.error instanceof UnsupportedBinaryPlistUidError) throw parsed.error; @@ -127,7 +122,6 @@ it.each(["", "AAE="])( "keeps malformed XML conversion %s separate from nesting refusal", (source) => { const parsed = parsePlistXml(source); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected malformed conversion failure"); expect(projectAnalysisError(parsed.error)).toMatchObject({ code: "unreadable_output", @@ -148,7 +142,6 @@ it("keeps malformed XML source structure separate from retained unknown scalars" const parsed = parsePlistXmlSource( Buffer.from("missing"), ); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected malformed source structure"); expect(parsed.error.message).toContain("Missing value for key"); }); @@ -384,7 +377,6 @@ it("rejects a reachable date with a malformed marker", () => { const parsed = parsePlistBinary(bytes); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected malformed reachable date rejection"); expect(parsed.error.message).toContain("date marker 0x30 is invalid"); }); @@ -558,7 +550,6 @@ it("keeps binary plist source values lost by XML conversion", () => { it("rejects a truncated binary plist source", () => { const parsed = parsePlistBinary(Buffer.from("bplist00bad")); - expect(parsed.ok).toBe(false); if (parsed.ok) throw new Error("Expected malformed binary plist"); expect(parsed.error.message).toContain("trailer is truncated"); }); @@ -880,12 +871,11 @@ it("keeps CFPropertyList's non-finite real spellings in XML evidence", () => { ); expect(parsed.value.limitations).toEqual([ expect.stringContaining("XML conversion"), - nonFiniteRealLimitation(3), - unknownScalarLimitation(1), + expect.stringMatching(/\b3 non-finite real value.*JSON number/iu), + expect.stringMatching( + /\b1 XML scalar value.*not be established.*literal.*reason/iu, + ), ]); - expect(unknownScalarLimitation(1)).toMatch( - /scalar.*not be established.*literal.*reason/iu, - ); }); it("retains nested own dictionary names consistently in native JSON, XML and binary projections", () => { diff --git a/src/native/pe/PeResourceParser.test.ts b/src/native/pe/PeResourceParser.test.ts index ecf8b0a17d..99ef05b079 100644 --- a/src/native/pe/PeResourceParser.test.ts +++ b/src/native/pe/PeResourceParser.test.ts @@ -358,8 +358,8 @@ describe("PE resource section virtual extent", () => { }; it.each([ - [0, "Resource RVA has missing or overlapping section mappings."], - [-2, "Resource range leaves its section's virtual size."], + [0, /RVA.*(?:missing|overlapping).*section/iu], + [-2, /range.*virtual size/iu], ])( "rejects a payload reaching raw alignment padding past VirtualSize (start %i)", async (start, message) => { @@ -370,7 +370,7 @@ describe("PE resource section virtual extent", () => { fixture.bytes.writeUInt32LE(4, (fixture.dataOffsets[0] ?? 0) + 4); await expect(parse(fixture.bytes)).rejects.toMatchObject({ reason: "format", - message, + message: expect.stringMatching(message), }); }, ); @@ -405,7 +405,7 @@ describe("PE resource section virtual extent", () => { fixture.bytes.writeUInt32LE(0, (fixture.dataOffsets[0] ?? 0) + 4); await expect(parse(fixture.bytes)).rejects.toMatchObject({ reason: "format", - message: "Resource RVA has missing or overlapping section mappings.", + message: expect.stringMatching(/RVA.*(?:missing|overlapping).*section/iu), }); }); @@ -417,7 +417,7 @@ describe("PE resource section virtual extent", () => { fixture.bytes.writeUInt32LE(0, (fixture.dataOffsets[0] ?? 0) + 4); await expect(parse(fixture.bytes)).rejects.toMatchObject({ reason: "format", - message: "Resource range is not entirely file-backed in one section.", + message: expect.stringMatching(/range.*file-backed/iu), }); }); @@ -517,7 +517,7 @@ describe("PE resource ownership boundaries", () => { const bytes = secondSection(fixture, 4, 0x2001, 0); await expect(parse(bytes)).rejects.toMatchObject({ reason: "format", - message: "Resource interval intersects overlapping virtual sections.", + message: expect.stringMatching(/interval.*overlapping.*sections/iu), }); }); @@ -544,7 +544,7 @@ describe("PE resource ownership boundaries", () => { const bytes = secondSection(fixture, 4, 0x100, 4); await expect(parse(bytes)).rejects.toMatchObject({ reason: "format", - message: "Ambiguous resource header RVA mapping.", + message: expect.stringMatching(/ambiguous.*header.*RVA/iu), }); }); @@ -623,7 +623,7 @@ it("keeps name probing independent of full resource name/ID partition admission" expect(await probeSeaName(fixture.bytes)).toBe(true); await expect(parse(fixture.bytes)).rejects.toMatchObject({ reason: "format", - message: "Resource name/ID entry counts disagree with encoded identities.", + message: expect.stringMatching(/name\/ID.*counts.*encoded identities/iu), }); }); diff --git a/src/native/pe/PeResourcesProvider.test.ts b/src/native/pe/PeResourcesProvider.test.ts index 62d7502d68..071ac07bc0 100644 --- a/src/native/pe/PeResourcesProvider.test.ts +++ b/src/native/pe/PeResourcesProvider.test.ts @@ -41,7 +41,6 @@ describe("PE resource provider budget reporting", () => { const path = join(root, "resource.exe"); await writeFile(path, peResourceFixture().bytes); const result = await inspect(path, { max_file_bytes: 64 }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a refusal"); expect(result.error).toBeInstanceOf(AnalysisResourceConstraintError); expect(result.error).toMatchObject({ @@ -61,7 +60,6 @@ describe("PE resource provider budget reporting", () => { const path = join(root, "resource.exe"); await writeFile(path, peResourceFixture().bytes); const result = await inspect(path, { max_entries: 1 }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a refusal"); expect(result.error).toMatchObject({ _tag: "AnalysisResourceConstraintError", diff --git a/src/process/ArtifactAnalysisResources.test.ts b/src/process/ArtifactAnalysisResources.test.ts index 08abc2ea86..8d029f3e59 100644 --- a/src/process/ArtifactAnalysisResources.test.ts +++ b/src/process/ArtifactAnalysisResources.test.ts @@ -479,7 +479,6 @@ it.each([ calls++; return ok("unexpected"); }, AbortSignal.abort(reason)); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancelled admission"); expect(result.error.cause).toBe(reason); expect(result.error.cleanupResources).toEqual([]); diff --git a/src/process/capture/ProcessNormalization.test.ts b/src/process/capture/ProcessNormalization.test.ts index 49827a8460..c671276fd9 100644 --- a/src/process/capture/ProcessNormalization.test.ts +++ b/src/process/capture/ProcessNormalization.test.ts @@ -205,6 +205,7 @@ it("counts UTF-8 bytes across replacement boundaries like the final JavaScript s "/temporary", rootPid, ); + expect(expected).toBe("\ude00😀"); expect( createBoundedProcessTextNormalizer( emptyPattern, @@ -237,6 +238,7 @@ it("counts UTF-8 bytes across replacement boundaries like the final JavaScript s "/temporary", rootPid, ); + expect(loneExpected).toBe("\ud83dy"); expect( createBoundedProcessTextNormalizer( loneSurrogate, diff --git a/src/process/capture/ProcessScenarioRuntimeValidation.test.ts b/src/process/capture/ProcessScenarioRuntimeValidation.test.ts index 47b8db2097..b1d94df534 100644 --- a/src/process/capture/ProcessScenarioRuntimeValidation.test.ts +++ b/src/process/capture/ProcessScenarioRuntimeValidation.test.ts @@ -106,6 +106,7 @@ it("reports a working-directory file as invalid input", async () => { executable: process.execPath, working_directory: selectedFile, }); + expect(failure.issues[0]?.message).toContain("not a directory"); expect(projectAnalysisError(failure)).toMatchObject({ code: "invalid_request", details: { @@ -114,7 +115,7 @@ it("reports a working-directory file as invalid input", async () => { { path: ["working_directory"], reason: "invalid_value", - message: `working directory is not a directory: ${selectedFile}`, + message: expect.stringContaining(selectedFile), }, ], }, @@ -136,6 +137,7 @@ it.skipIf(process.platform === "win32")( executable: process.execPath, working_directory: aliasFile, }); + expect(failure.issues[0]?.message).toContain("not a directory"); expect(projectAnalysisError(failure)).toMatchObject({ code: "invalid_request", details: { @@ -144,7 +146,7 @@ it.skipIf(process.platform === "win32")( { path: ["working_directory"], reason: "invalid_value", - message: `working directory is not a directory: ${aliasFile}`, + message: expect.stringContaining(aliasFile), }, ], }, @@ -163,13 +165,14 @@ it("reports an executable directory as invalid input", async () => { executable: directory, working_directory: root, }); + expect(directoryFailure.issues[0]?.message).toContain("not a regular file"); expect(projectAnalysisError(directoryFailure)).toMatchObject({ code: "invalid_request", details: { issues: [ { path: ["executable"], - message: `executable could not be resolved: ${directory}; checked ${directory} (not a regular file)`, + message: expect.stringContaining(directory), }, ], }, @@ -191,13 +194,14 @@ it.skipIf(process.platform === "win32")( executable: selected, working_directory: root, }); + expect(failure.issues[0]?.message).toContain("EACCES"); expect(projectAnalysisError(failure)).toMatchObject({ code: "invalid_request", details: { issues: [ { path: ["executable"], - message: `executable could not be resolved: ${selected}; checked ${selected} (EACCES)`, + message: expect.stringContaining(selected), }, ], }, @@ -306,13 +310,14 @@ it.skipIf(SKIP_PERMISSIONS)( }); expect(failure).toBeInstanceOf(AnalysisInputError); if (!(failure instanceof AnalysisInputError)) return; + expect(failure.issues[0]?.message).toContain("EACCES"); expect(projectAnalysisError(failure)).toMatchObject({ code: "invalid_request", details: { issues: [ { path: ["executable"], - message: `executable could not be resolved: tool; checked ${join(denied, "tool")} (EACCES)`, + message: expect.stringContaining(join(denied, "tool")), }, ], }, diff --git a/src/server/environment/environmentCapacity.test.ts b/src/server/environment/environmentCapacity.test.ts index ab1300b11d..d6e0934e9c 100644 --- a/src/server/environment/environmentCapacity.test.ts +++ b/src/server/environment/environmentCapacity.test.ts @@ -60,7 +60,6 @@ it("charges environment identity, aggregate tools and escaped text before produc ).ok, ).toBe(false); const normal = environmentToolDefinitions(source); - expect(normal.ok).toBe(true); if (!normal.ok) throw normal.error; expect( Buffer.byteLength( diff --git a/tests/acceptance/applications/binaryPlistDates.test.ts b/tests/acceptance/applications/binaryPlistDates.test.ts index 80f756eeca..010d128f7e 100644 --- a/tests/acceptance/applications/binaryPlistDates.test.ts +++ b/tests/acceptance/applications/binaryPlistDates.test.ts @@ -116,8 +116,10 @@ cliTest( { $plist_type: "date", iso8601: null }, ]), ); - expect(archiveResult.limitations).toContain( - '1 date value(s) are reported as { "$plist_type": "date", "iso8601": null } because the decoder could not represent their timestamps.', + expect(archiveResult.limitations).toContainEqual( + expect.stringMatching( + /\b1 date value.*iso8601.*null.*decoder could not represent.*timestamps/iu, + ), ); const malformedOutput = await cli.run({ @@ -157,8 +159,10 @@ cliTest( reason: "one_or_more_archives_invalid", }), ); - expect(ibResult.limitations).toContain( - 'Contents/Resources/Main.nib: 1 date value(s) are reported as { "$plist_type": "date", "iso8601": null } because the decoder could not represent their timestamps.', + expect(ibResult.limitations).toContainEqual( + expect.stringMatching( + /Contents\/Resources\/Main\.nib.*\b1 date value.*iso8601.*null.*decoder could not represent.*timestamps/iu, + ), ); expect(ibResult.limitations).toContainEqual( expect.stringContaining( diff --git a/tests/acceptance/applications/keyedArchiveScalarKinds.test.ts b/tests/acceptance/applications/keyedArchiveScalarKinds.test.ts index b98ff23adf..294ed50ec0 100644 --- a/tests/acceptance/applications/keyedArchiveScalarKinds.test.ts +++ b/tests/acceptance/applications/keyedArchiveScalarKinds.test.ts @@ -1,4 +1,3 @@ -import { nonFiniteRealLimitation } from "../../../src/domain/apple/plistValue.js"; import { createHash } from "node:crypto"; import { readFile, writeFile } from "node:fs/promises"; import { join } from "node:path"; @@ -133,7 +132,9 @@ cliTest.for(["xml", "binary"] as const)( status: "resolved", }), ); - expect(result.limitations).toContainEqual(nonFiniteRealLimitation(1)); + expect(result.limitations).toContainEqual( + expect.stringMatching(/\b1 non-finite real value.*JSON number/iu), + ); const page = await run(["--root", "data", "--offset", "1", "--limit", "2"]); expect(page.objects).toEqual(result.objects.slice(1, 3)); @@ -412,7 +413,9 @@ cliTest( expect(JSON.stringify(result.objects.map(({ value }) => value))).toBe( '["$null",{"$plist_type":"real","value":"+infinity"},{"$plist_type":"real","value":"-infinity"},{"$plist_type":"real","value":"nan"},1.25]', ); - expect(result.limitations).toContain(nonFiniteRealLimitation(3)); + expect(result.limitations).toContainEqual( + expect.stringMatching(/\b3 non-finite real value.*JSON number/iu), + ); expect(result.limitations).not.toContainEqual( expect.stringContaining('"value": null'), ); diff --git a/tests/acceptance/tools/historicalCaptureResources.test.ts b/tests/acceptance/tools/historicalCaptureResources.test.ts index d50f05fc62..b5ee9c6e75 100644 --- a/tests/acceptance/tools/historicalCaptureResources.test.ts +++ b/tests/acceptance/tools/historicalCaptureResources.test.ts @@ -9,7 +9,7 @@ import { fileURLToPath } from "node:url"; import { promisify } from "node:util"; import { expect, it } from "vitest"; -import { NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES } from "../../../src/browser/history/CaptureRelease.js"; +import { NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES } from "../../fixtures/captureDecoderLimits.js"; import { WEB_NETWORK_CAPTURE_LIMITS } from "../../../src/domain/webNetworkCapture.js"; import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js"; import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; diff --git a/tests/acceptance/tools/qlogCapture.test.ts b/tests/acceptance/tools/qlogCapture.test.ts index cc0c739e2a..f492d987de 100644 --- a/tests/acceptance/tools/qlogCapture.test.ts +++ b/tests/acceptance/tools/qlogCapture.test.ts @@ -4,10 +4,8 @@ import { join } from "node:path"; import { fileURLToPath } from "node:url"; import { promisify } from "node:util"; import { expect, it as runtimeTest } from "vitest"; -import { - NODE_CAPTURE_HEAP_ENFORCED, - NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES, -} from "../../../src/browser/history/CaptureRelease.js"; +import { NODE_CAPTURE_HEAP_ENFORCED } from "../../../src/browser/history/CaptureRelease.js"; +import { NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES } from "../../fixtures/captureDecoderLimits.js"; import { webNetworkCaptureSummaryViewResultSchema } from "../../../src/domain/analysisView/analysisView.js"; import { parseEvidence } from "../../../src/domain/evidence.js"; import { diff --git a/tests/boundary/android/androidJniLibrary.test.ts b/tests/boundary/android/androidJniLibrary.test.ts index 7998e9ddea..cdd7a16c43 100644 --- a/tests/boundary/android/androidJniLibrary.test.ts +++ b/tests/boundary/android/androidJniLibrary.test.ts @@ -108,7 +108,6 @@ it.each([ const fixture = jniElfFixture({ bits, machine, encoding }); const original = Buffer.from(fixture.bytes); const result = await inspectAndroidJniLibrary(fixture.bytes); - expect(result.ok).toBe(true); if (!result.ok) throw new Error(result.error.message); expect(androidJniLibraryFactsSchema.safeParse(result.value).success).toBe( true, diff --git a/tests/boundary/browser/callerCancellationReason.test.ts b/tests/boundary/browser/callerCancellationReason.test.ts index e28fa26bfa..773c21bb15 100644 --- a/tests/boundary/browser/callerCancellationReason.test.ts +++ b/tests/boundary/browser/callerCancellationReason.test.ts @@ -31,7 +31,6 @@ it.each([ }, }, }); - expect(cancelled.ok).toBe(false); if (cancelled.ok) throw new Error("Expected cancellation at arming"); expect(cancelled.error._tag).toBe("AnalysisCancelledError"); expect(cancelled.error.cause).toBe(controller.signal.reason); @@ -82,7 +81,6 @@ it("preserves the caller reason when a navigation observation is cancelled at ar }, }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancelled navigation observation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); diff --git a/tests/boundary/browser/cdpElectronProvider.test.ts b/tests/boundary/browser/cdpElectronProvider.test.ts index b088ddb429..de312341ff 100644 --- a/tests/boundary/browser/cdpElectronProvider.test.ts +++ b/tests/boundary/browser/cdpElectronProvider.test.ts @@ -473,7 +473,6 @@ describe("CdpElectronProvider target access", () => { { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected late cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.partialObservation).toMatchObject({ diff --git a/tests/boundary/browser/cdpScriptMetadata.test.ts b/tests/boundary/browser/cdpScriptMetadata.test.ts index 5ca2de86e9..2507f279be 100644 --- a/tests/boundary/browser/cdpScriptMetadata.test.ts +++ b/tests/boundary/browser/cdpScriptMetadata.test.ts @@ -13,7 +13,7 @@ import { ArtifactResourceScope } from "../../../src/artifacts/ArtifactResourceSc import { selectScriptCapture } from "../../../src/browser/assets/ScriptCaptureAdapters.js"; import { inspectWebPageInputSchema } from "../../../src/domain/browserObservation.js"; import { inspectElectronPageInputSchema } from "../../../src/domain/javascript/electronObservation.js"; -import { parseRuntimeCaptures } from "../../../src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js"; +import { parseRuntimeCapture } from "../../../src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js"; import { projectRuntimeCaptures } from "../../../src/domain/javascript/javascriptRuntimeReconciliationRuntime.js"; import { V8InspectorProvider } from "../../../src/inspector/V8InspectorProvider.js"; import { startFakeCdpBrowser } from "../../fixtures/fakeCdpBrowser.js"; @@ -186,9 +186,9 @@ describe("Inspector script metadata", () => { result.value, provider.identity(), ); - const projected = projectRuntimeCaptures( - parseRuntimeCaptures([evidence]), - ); + const projected = projectRuntimeCaptures([ + parseRuntimeCapture(evidence, ["runtime_observations", 0]), + ]); const scriptNode = projected.nodes.find( ({ kind }) => kind === "runtime-script-instance", ); @@ -215,14 +215,15 @@ describe("Inspector script exclusions", () => { const provider = new V8InspectorProvider(); const result = await provider.observe(input); if (!result.ok) throw result.error; - const [parsed] = parseRuntimeCaptures([ + const parsed = parseRuntimeCapture( createJavaScriptRuntimeObservationEvidence( "observe_javascript_runtime", input, result.value, provider.identity(), ), - ]); + ["runtime_observations", 0], + ); return { producer: result.value.scripts.excluded, completeness: parsed?.inspection.completeness, diff --git a/tests/boundary/browser/cdpTargetDeadlines.test.ts b/tests/boundary/browser/cdpTargetDeadlines.test.ts index acdbc7aa2a..6bca62351a 100644 --- a/tests/boundary/browser/cdpTargetDeadlines.test.ts +++ b/tests/boundary/browser/cdpTargetDeadlines.test.ts @@ -696,7 +696,6 @@ it("names the fixed cleanup grace when runtime restoration stalls", async () => expect(activeTimers(commandTimeoutMs)).toHaveLength(0); expireEveryTimer(WEB_RUNTIME_LIMITS.cleanupTimeoutMs); const result = await pending; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cleanup grace failure"); const text = JSON.stringify(result.error.diagnostics); expect(text).toContain("5000 ms"); diff --git a/tests/boundary/browser/historicalCaptureDecoder.test.ts b/tests/boundary/browser/historicalCaptureDecoder.test.ts index dfb62de77a..3683ca9b34 100644 --- a/tests/boundary/browser/historicalCaptureDecoder.test.ts +++ b/tests/boundary/browser/historicalCaptureDecoder.test.ts @@ -428,7 +428,6 @@ it("applies a non-default capture deadline and releases its runtime", async () = capture_timeout_ms: 250, }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected capture timeout"); expect(result.error._tag).toBe("AnalysisTimeoutError"); expect(result.error.userMessage).toContain("250"); @@ -554,14 +553,12 @@ it("retains a failed capture reader and retries it before a fresh load", async ( }); try { const first = await decoder.inspect(input); - expect(first.ok).toBe(false); if (first.ok) throw new Error("Reader close failure must fail inspection"); expect(first.error.cleanupIncomplete).toBe(true); expect(first.error.cleanupResources).toContain(path); expect(decoderCalls).toBe(0); const refused = await decoder.inspect(input); - expect(refused.ok).toBe(false); if (refused.ok) throw new Error("Fresh read must wait for owner cleanup"); expect(refused.error.cleanupIncomplete).toBe(true); expect(refused.error.cleanupResources).toContain(path); @@ -848,7 +845,6 @@ it("retains completed capture facts and binds final root cleanup to its retry le format: "har", }), ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Root close failure must be reported"); expect(result.error.cleanupIncomplete).toBe(true); expect(runtimePath).toBeDefined(); diff --git a/tests/boundary/browser/sazWebCapture.test.ts b/tests/boundary/browser/sazWebCapture.test.ts index a6339fe8c5..59803eb57b 100644 --- a/tests/boundary/browser/sazWebCapture.test.ts +++ b/tests/boundary/browser/sazWebCapture.test.ts @@ -26,10 +26,8 @@ import { parseMcpToolError } from "../../fixtures/mcpToolError.js"; import { protobufFrame } from "../../fixtures/protobufCapture.js"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; -import { - NODE_CAPTURE_HEAP_ENFORCED, - NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES, -} from "../../../src/browser/history/CaptureRelease.js"; +import { NODE_CAPTURE_HEAP_ENFORCED } from "../../../src/browser/history/CaptureRelease.js"; +import { NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES } from "../../fixtures/captureDecoderLimits.js"; const hasMemoryBound = NODE_CAPTURE_HEAP_ENFORCED || NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES !== null; diff --git a/tests/boundary/cli/analysisViewCli.test.ts b/tests/boundary/cli/analysisViewCli.test.ts index bb0ed5d80f..c1dc58a5b9 100644 --- a/tests/boundary/cli/analysisViewCli.test.ts +++ b/tests/boundary/cli/analysisViewCli.test.ts @@ -554,7 +554,6 @@ cliTest( }); continue; } - expect(application.ok).toBe(false); if (application.ok) throw new Error("Expected an invalid parent"); expect(application.error.cause).toBeInstanceOf(z.ZodError); expect(reply.exitCode).toBe(1); @@ -590,7 +589,6 @@ cliTest( view: { kind: "summary" as const }, }; const application = await inspectAnalysisView(request); - expect(application.ok).toBe(false); if (application.ok) throw new Error("Expected invalid nested Evidence"); expect(application.error.cause).toMatchObject({ cause: expect.any(z.ZodError), diff --git a/tests/boundary/cli/cliEvidenceCallerPath.test.ts b/tests/boundary/cli/cliEvidenceCallerPath.test.ts index f9bde75805..e18f911c34 100644 --- a/tests/boundary/cli/cliEvidenceCallerPath.test.ts +++ b/tests/boundary/cli/cliEvidenceCallerPath.test.ts @@ -27,7 +27,6 @@ it("retains the original file selection when final cleanup fails", async () => { "inspect", new AbortController().signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cleanup failure"); expect(result.error).toMatchObject({ code: "cleanup_incomplete", @@ -80,7 +79,6 @@ it("binds authenticated partial Evidence but preserves raw partial observations" "inspect", new AbortController().signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error.details?.partial_observation).toMatchObject(expected); if ("kind" in expected) diff --git a/tests/boundary/cli/cliOutputFormatter.test.ts b/tests/boundary/cli/cliOutputFormatter.test.ts index 7aba1e58ab..d34a528962 100644 --- a/tests/boundary/cli/cliOutputFormatter.test.ts +++ b/tests/boundary/cli/cliOutputFormatter.test.ts @@ -2,7 +2,8 @@ import { expect, it } from "vitest"; import { encodeMarkdownTableCell, - formatDelimitedRows, + formatCliOutput, + prepareDelimitedOutput, } from "../../../src/cli/cliOutputFormatter.js"; it.each([ @@ -84,7 +85,7 @@ it.each([ { name: "", note: "", count: false }, { name: "欠", count: null }, ]; - const output = formatDelimitedRows(rows, format, { + const output = formatCliOutput(rows, format, { fields: ["name", "note", "count"], metadata: { version: 1, @@ -92,12 +93,10 @@ it.each([ view: { offset: 0, limit: 3 }, }, }); - expect(output.ok).toBe(true); - if (!output.ok) throw output.error; const lineEnding = format === "csv" ? "\r\n" : "\n"; - const metadataEnd = output.value.indexOf(lineEnding); - const metadataLine = output.value.slice(0, metadataEnd); - const records = output.value + const metadataEnd = output.indexOf(lineEnding); + const metadataLine = output.slice(0, metadataEnd); + const records = output .slice(metadataEnd + lineEnding.length) .replace(/\r?\n$/u, ""); expect( @@ -118,7 +117,7 @@ it.each([ it("does not flatten nested selected field values", () => { expect( - formatDelimitedRows([{ details: { name: "nested" } }], "csv", { + prepareDelimitedOutput([{ details: { name: "nested" } }], "csv", { fields: ["details"], metadata: {}, }), @@ -132,7 +131,7 @@ it.each(["=1+1", " =1+1", "+1", "-1", "@SUM(A1:A2)"])( "refuses formula-leading string cells without changing the source value %j", (value) => { const row = { target: value }; - const result = formatDelimitedRows([row], "csv", { + const result = prepareDelimitedOutput([row], "csv", { fields: ["target"], metadata: {}, }); @@ -149,7 +148,7 @@ it.each(["=1+1", " =1+1", "+1", "-1", "@SUM(A1:A2)"])( it("refuses formula-leading column headers", () => { expect( - formatDelimitedRows([{ value: "safe" }], "csv", { + prepareDelimitedOutput([{ value: "safe" }], "csv", { fields: ["=header"], metadata: {}, }), diff --git a/tests/boundary/cli/debuggerOneShotExit.test.ts b/tests/boundary/cli/debuggerOneShotExit.test.ts index b5d8b949f4..44d38848ab 100644 --- a/tests/boundary/cli/debuggerOneShotExit.test.ts +++ b/tests/boundary/cli/debuggerOneShotExit.test.ts @@ -216,10 +216,15 @@ const expectRetainedOutcome = ( result: ProcessResult, pid: number, ): void => { - expect(JSON.parse(result.stdout)).toMatchObject({ + const output = JSON.parse(result.stdout) as { + remediation: { action: string }; + }; + expect(output).toMatchObject({ code: "cleanup_incomplete", retryable: false, - remediation: { action: retainedDebuggerRemediation([pid]) }, + remediation: { + action: retainedDebuggerRemediation([pid]), + }, details: { operation: debuggers[name].operation, cleanup: "incomplete", @@ -229,7 +234,7 @@ const expectRetainedOutcome = ( }, }, }); - expectNamesProcess(retainedDebuggerRemediation([pid]), pid); + expectNamesProcess(output.remediation.action, pid); expect(result.stdout).toContain(`"retained_debugger_pids":[${String(pid)}]`); }; @@ -400,10 +405,14 @@ describe.skipIf(process.platform === "win32")( .toBe(1); const pid = await launch.debuggerPid(); // Nothing else reports these once the server has exited. + const guidance = () => + stderr() + .split("\n") + .find((line) => line === retainedDebuggerRemediation([pid])); await expect - .poll(stderr, { timeout: EXIT_DEADLINE_MS }) - .toContain(`${retainedDebuggerRemediation([pid])}\n`); - expectNamesProcess(retainedDebuggerRemediation([pid]), pid); + .poll(guidance, { timeout: EXIT_DEADLINE_MS }) + .toBeDefined(); + expectNamesProcess(guidance()!, pid); const logs = stderr() .split("\n") .filter((line) => line.startsWith("{")) diff --git a/tests/boundary/cli/nativePlistSelectionFailureCli.test.ts b/tests/boundary/cli/nativePlistSelectionFailureCli.test.ts index 14317c3ec1..a12eab44e1 100644 --- a/tests/boundary/cli/nativePlistSelectionFailureCli.test.ts +++ b/tests/boundary/cli/nativePlistSelectionFailureCli.test.ts @@ -128,8 +128,8 @@ describe.skipIf(process.platform !== "darwin")( code: "capability_unavailable", message: expect.stringContaining("(CLI: --relative-path)"), remediation: { - action: expect.stringContaining( - "Select another plist in the target with the path input (CLI: --relative-path).", + action: expect.stringMatching( + /select another plist.*path input.*--relative-path/iu, ), }, details: { @@ -398,8 +398,9 @@ describe.skipIf(process.platform !== "darwin")( code: "resource_constraint", retryable: false, remediation: { - action: - "The 64 MiB (67108864-byte) native binary plist decode allowance (no runtime override) is a fixed allowance. Worker memory limits, inherited limits, and additional host memory do not raise it. Select another complete input within the allowance when that preserves the needed observation. Repeating the unchanged request fails the same way.", + action: expect.stringMatching( + /64 MiB.*67108864.byte.*decode allowance.*no runtime override.*do not raise.*complete input.*unchanged request fails/iu, + ), }, details: { operation: "inspect_plist", @@ -427,8 +428,8 @@ describe.skipIf(process.platform !== "darwin")( code: "resource_constraint", retryable: false, remediation: { - action: expect.stringContaining( - "Select a suitable complete artifact within the fixed 64 MiB (67108864-byte) native plist input allowance (no runtime override).", + action: expect.stringMatching( + /complete artifact.*64 MiB.*67108864.byte.*input allowance.*no runtime override/iu, ), }, details: { diff --git a/tests/boundary/evm/evmCleanupRetry.test.ts b/tests/boundary/evm/evmCleanupRetry.test.ts index 46e68f690f..dd031fa0d9 100644 --- a/tests/boundary/evm/evmCleanupRetry.test.ts +++ b/tests/boundary/evm/evmCleanupRetry.test.ts @@ -219,7 +219,6 @@ it.each([ ? { signal: controller.signal } : undefined, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the first root close to fail"); const originalError = result.error; if (scenario === "physical-before-late-cancel") @@ -286,7 +285,6 @@ it("keeps descriptor cleanup in close aggregates until the exact file lease rele }); try { const result = await provider.inspect({ path: input, encoding: "hex" }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an artifact descriptor failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.partialObservation).toEqual({ @@ -380,7 +378,6 @@ it("keeps a mixed root and reply-descriptor aggregate pending until both owners ); try { const result = await provider.inspect({ path: input, encoding: "hex" }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected reply descriptor cleanup failure"); const original = result.error; expect(original.cleanupIncomplete).toBe(true); @@ -503,7 +500,6 @@ it("releases a retained process independently while a root cleanup retry remains ); try { const result = await provider.inspect({ path: input, encoding: "hex" }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained process cleanup failure"); const original = result.error; expect(original.cleanupIncomplete).toBe(true); @@ -617,7 +613,6 @@ it("preserves an active cancellation through denied owned-group cleanup and late { path: input, encoding: "hex" }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancelled worker cleanup failure"); const original = result.error; expect(original.cleanupIncomplete).toBe(true); diff --git a/tests/boundary/filesystem/binaryTarget.test.ts b/tests/boundary/filesystem/binaryTarget.test.ts index b25d603cd3..e3dafaf3fe 100644 --- a/tests/boundary/filesystem/binaryTarget.test.ts +++ b/tests/boundary/filesystem/binaryTarget.test.ts @@ -1097,7 +1097,6 @@ describe("binary target I/O: explicit kinds and executable headers", () => { cwd: directory, hostArchitecture: "x64", }); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value).toMatchObject({ format: "pe", @@ -1126,7 +1125,6 @@ describe("binary target I/O: explicit kinds and executable headers", () => { cwd: directory, hostArchitecture: "ia32", }); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value).toMatchObject({ format: "pe", diff --git a/tests/boundary/filesystem/bunMetadataReadBudget.test.ts b/tests/boundary/filesystem/bunMetadataReadBudget.test.ts index 019f75d9b7..e79ab0342d 100644 --- a/tests/boundary/filesystem/bunMetadataReadBudget.test.ts +++ b/tests/boundary/filesystem/bunMetadataReadBudget.test.ts @@ -1,12 +1,12 @@ import { open, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { expect, it } from "vitest"; -import { - BUN_TRAILER, - locateBunStandaloneGraph, -} from "../../../src/artifacts/bun/BunModuleGraphLayout.js"; +import { BUN_TRAILER } from "../../../src/artifacts/bun/BunModuleGraphLayout.js"; import { decodeBunModuleGraph } from "../../../src/artifacts/bun/BunModuleGraphMembers.js"; -import { elfAppendedBunPayload } from "../../../src/artifacts/bun/BunStandalone.fixture.js"; +import { + elfAppendedBunPayload, + locateBunGraphFixture, +} from "../../../src/artifacts/bun/BunStandalone.fixture.js"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; it("keeps scattered tiny metadata reads proportional to the graph instead of cache pages", async () => { @@ -59,7 +59,7 @@ it("keeps scattered tiny metadata reads proportional to the graph instead of cac : Reflect.get(target, key), }); try { - const located = await locateBunStandaloneGraph(counted, bytes.length); + const located = await locateBunGraphFixture(counted, bytes.length); if (located.status !== "present" || located.graph === undefined) throw new Error("Missing graph"); const decoded = await decodeBunModuleGraph(located.graph); @@ -99,7 +99,7 @@ it("refuses cumulative uncached metadata work before the next file read", async : Reflect.get(target, key), }); try { - const located = await locateBunStandaloneGraph(counted, bytes.length); + const located = await locateBunGraphFixture(counted, bytes.length); if (located.status !== "present" || located.graph === undefined) throw new Error("Missing graph"); const graph = located.graph; diff --git a/tests/boundary/filesystem/bunStandaloneIntegration.test.ts b/tests/boundary/filesystem/bunStandaloneIntegration.test.ts index 0302f04acd..367bc9d918 100644 --- a/tests/boundary/filesystem/bunStandaloneIntegration.test.ts +++ b/tests/boundary/filesystem/bunStandaloneIntegration.test.ts @@ -9,6 +9,7 @@ import { ArtifactResourceScope } from "../../../src/artifacts/ArtifactResourceSc import * as layout from "../../../src/artifacts/bun/BunModuleGraphLayout.js"; import { decodeBunModuleGraph } from "../../../src/artifacts/bun/BunModuleGraphMembers.js"; import { + locateBunGraphFixture, bunModuleGraphPayload, bunPrefixedPayload, peBunSection, @@ -44,10 +45,7 @@ it("reads bounded metadata instead of the stored Bun asset body", async () => { : Reflect.get(target, key), }); try { - const located = await layout.locateBunStandaloneGraph( - counted, - bytes.length, - ); + const located = await locateBunGraphFixture(counted, bytes.length); if (located.status !== "present" || located.graph === undefined) throw new Error("Missing graph"); const decoded = await decodeBunModuleGraph(located.graph); diff --git a/tests/boundary/filesystem/clientConfigurationEnvironment.test.ts b/tests/boundary/filesystem/clientConfigurationEnvironment.test.ts index 6c0d5cdc4c..70ba7e072b 100644 --- a/tests/boundary/filesystem/clientConfigurationEnvironment.test.ts +++ b/tests/boundary/filesystem/clientConfigurationEnvironment.test.ts @@ -189,7 +189,6 @@ it.skipIf(process.platform !== "win32").each([ const env = clientRegistrationEnvironmentDetails( parseClientConfiguration(text, "dsh"), ); - expect(env.ok).toBe(true); if (!env.ok) throw env.error; expect(env.value.values).toHaveProperty(override, value); expect( @@ -271,7 +270,6 @@ it const details = clientRegistrationEnvironmentDetails( parseClientConfiguration(text, "dsh"), ); - expect(details.ok).toBe(true); if (!details.ok) throw details.error; expect(details.value.timeoutInputs?.analysisProvider).toBe("ghidra"); expect( @@ -301,7 +299,6 @@ it.skipIf(process.platform !== "win32").each([ "json", ); const result = clientRegistrationEnvironmentDetails(parsed, overrides); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value.timeoutInputs?.analysisProvider).toBe(expected); expect(snapshotEnvironment(result.value.values).REA_ANALYSIS_PROVIDER).toBe( @@ -454,7 +451,6 @@ it.each(["linux", "win32"] as const)( "effective", platform, ); - expect(details.ok).toBe(true); if (!details.ok) throw details.error; expect(Object.entries(details.value.values)).toEqual([ ["__proto__", "selected"], @@ -482,7 +478,6 @@ it("retains an unresolved JEB endpoint expression until a selected literal repla "effective", undefined, ); - expect(unresolved.ok).toBe(true); if (!unresolved.ok) throw unresolved.error; expect(unresolved.value.unresolvedSettings).toEqual( new Set(["REA_JEB_MCP_URL"]), @@ -491,7 +486,6 @@ it("retains an unresolved JEB endpoint expression until a selected literal repla const selected = clientRegistrationEnvironmentDetails(parsed, { REA_JEB_MCP_URL: endpoint, }); - expect(selected.ok).toBe(true); if (!selected.ok) throw selected.error; expect(selected.value.values.REA_JEB_MCP_URL).toBe(endpoint); expect(selected.value.unresolvedSettings.size).toBe(0); @@ -537,7 +531,6 @@ it.each( "effective", platform, ); - expect(details.ok).toBe(true); if (!details.ok) throw details.error; expect(details.value.values).toEqual({ CALLER_SETTING: "retained" }); expect(details.value.unresolvedSettings).toEqual(new Set([setting])); @@ -566,7 +559,6 @@ it.each( "effective", platform, ); - expect(overridden.ok).toBe(true); if (!overridden.ok) throw overridden.error; expect(overridden.value.unresolvedSettings.size).toBe(0); expect(overridden.value.timeoutInputs).toBeDefined(); @@ -587,7 +579,6 @@ it("retains an unknown companion while deriving unrelated literal timeout facts" "dsh", ); const details = clientRegistrationEnvironmentDetails(parsed); - expect(details.ok).toBe(true); if (!details.ok) throw details.error; expect(details.value.unresolvedSettings).toEqual( new Set(["REA_GHIDRA_LANGUAGE_ID"]), diff --git a/tests/boundary/filesystem/clientConfigurationLayeredEnvironment.test.ts b/tests/boundary/filesystem/clientConfigurationLayeredEnvironment.test.ts index 5fe1a046ff..acd197c831 100644 --- a/tests/boundary/filesystem/clientConfigurationLayeredEnvironment.test.ts +++ b/tests/boundary/filesystem/clientConfigurationLayeredEnvironment.test.ts @@ -76,7 +76,6 @@ it.each(["missing", "empty", "legacy", "native"] as const)( await configureClientConfiguration(client, {}, command), ).toMatchObject({ status: "configured" }); const files = await readClientConfigurationFiles(client); - expect(files.ok).toBe(true); if (!files.ok) throw new Error(files.error.detail); const effective = effectiveClientConfiguration(files.value); expect(effective?.dialect).toBe("opencode_v2"); @@ -162,12 +161,10 @@ it.skipIf(process.platform !== "win32").each([ ), ).toMatchObject({ status: "configured" }); const sources = await readClientConfigurationFiles(fixture.client); - expect(sources.ok).toBe(true); if (!sources.ok) throw new Error(sources.error.detail); const environment = clientRegistrationEnvironmentDetails( effectiveClientConfiguration(sources.value), ); - expect(environment.ok).toBe(true); if (!environment.ok) throw environment.error; expect(environment.value.timeoutInputs?.analysisProvider).toBe("ghidra"); expect(environment.value.values).toHaveProperty( diff --git a/tests/boundary/filesystem/desktopApplication.test.ts b/tests/boundary/filesystem/desktopApplication.test.ts index 054157520c..d497b4ce2a 100644 --- a/tests/boundary/filesystem/desktopApplication.test.ts +++ b/tests/boundary/filesystem/desktopApplication.test.ts @@ -714,7 +714,6 @@ it("retains complete observations through cancellation during directory finaliza { path: root }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toMatchObject({ reason: "cancelled", cause: reason }); const retained = parseEvidence(result.error.partialObservation); diff --git a/tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts b/tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts index 9b1d7fed80..704cbc44fb 100644 --- a/tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts +++ b/tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts @@ -625,7 +625,6 @@ describe("snapshot output cleanup lifecycle", () => { fixture.snapshotPath, false, ); - expect(closed.ok).toBe(false); if (closed.ok) throw new Error("Expected close failure"); const committed = await readFile(fixture.snapshotPath); const snapshot = await readAnalysisSnapshot(fixture.snapshotPath); diff --git a/tests/boundary/filesystem/directoryRootIdentity.test.ts b/tests/boundary/filesystem/directoryRootIdentity.test.ts index de1555def2..8e6a03ebbc 100644 --- a/tests/boundary/filesystem/directoryRootIdentity.test.ts +++ b/tests/boundary/filesystem/directoryRootIdentity.test.ts @@ -91,7 +91,6 @@ it("discards unverified desktop byte facts when the admitted root changes during ); try { const result = await service.inspect({ path: original }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected root identity failure"); const report = desktopApplicationSchema.parse( parseEvidence(result.error.partialObservation).normalized_result, diff --git a/tests/boundary/filesystem/flutterBuildProvider.test.ts b/tests/boundary/filesystem/flutterBuildProvider.test.ts index 3c437d9535..e575850728 100644 --- a/tests/boundary/filesystem/flutterBuildProvider.test.ts +++ b/tests/boundary/filesystem/flutterBuildProvider.test.ts @@ -595,7 +595,6 @@ it("rejects a target that is not a readable file", async () => { operation: "identify_flutter_build", input: { path: "/nonexistent/app.apk" }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected a refusal"); return projectAnalysisError(result.error); })(); @@ -1202,7 +1201,6 @@ it.each(["identify_flutter_build", "inspect_dart_aot"] as const)( close.mockRestore(); }); const result = await provider.execute({ operation, input: { path } }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained reader cleanup"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.partialObservation).toMatchObject({ operation }); @@ -1658,7 +1656,6 @@ it.each([false, true])( { operation: "identify_flutter_build", input: { path } }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected owned cleanup failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toEqual([retainedRoot]); @@ -1759,7 +1756,6 @@ it("preserves source admission failure when cancellation arrives during its root }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected missing selected source"); expect(result.error).not.toBeInstanceOf(AnalysisCancelledError); expect(result.error).toMatchObject({ _tag: "AnalysisInputError" }); @@ -1896,7 +1892,6 @@ it("does not create a replacement snapshot when cancelled during cleanup retry", const cancelled = await provider.execute(request, { signal: controller.signal, }); - expect(cancelled.ok).toBe(false); if (cancelled.ok) throw new Error("Expected cancellation"); expect(projectAnalysisError(cancelled.error).code).toBe("cancelled"); expect(cancelled.error.cause).toBe(reason); diff --git a/tests/boundary/filesystem/ghidraExecutableHeader.test.ts b/tests/boundary/filesystem/ghidraExecutableHeader.test.ts index bf2b2f4aa4..e42d5950aa 100644 --- a/tests/boundary/filesystem/ghidraExecutableHeader.test.ts +++ b/tests/boundary/filesystem/ghidraExecutableHeader.test.ts @@ -171,7 +171,6 @@ it.each(["completed", "physical", "close"] as const)( resourceOwner: resources.owner, signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toEqual([path]); diff --git a/tests/boundary/filesystem/ghidraPspExtension.test.ts b/tests/boundary/filesystem/ghidraPspExtension.test.ts index 4428fb7f1f..df92e6758c 100644 --- a/tests/boundary/filesystem/ghidraPspExtension.test.ts +++ b/tests/boundary/filesystem/ghidraPspExtension.test.ts @@ -267,7 +267,6 @@ describe.skipIf(process.platform === "win32")( if (!before.ok) throw before.error; await rename(root, `${root}-removed`); const missing = await provider.resolveAnalysisProfile(target); - expect(missing.ok).toBe(false); if (missing.ok) throw new Error("Missing installation was accepted"); expect(missing.error.message).toContain("PSP_EXTENSION_UNAVAILABLE"); }); @@ -392,7 +391,6 @@ describe.skipIf(process.platform === "win32")( const result = await provider.resolveAnalysisProfile(target, { signal: AbortSignal.abort(), }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Cancellation was ignored"); expect(result.error._tag).toBe("AnalysisCancelledError"); }); @@ -431,7 +429,6 @@ describe.skipIf(process.platform === "win32")( "unsupported", ); const result = await provider.resolveAnalysisProfile(altered); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Invalid target was admitted"); expect(result.error._tag).toBe("AnalysisUnsupportedTargetError"); }, @@ -559,7 +556,6 @@ describe.skipIf(process.platform === "win32")( "unsupported", ); const result = await provider.resolveAnalysisProfile(altered); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Invalid ABI was admitted"); expect(result.error._tag).toBe("AnalysisUnsupportedTargetError"); expect(result.error.message).toContain( @@ -585,7 +581,6 @@ describe.skipIf(process.platform === "win32")( }, }; const result = await provider.resolveAnalysisProfile(altered); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Missing ABI was inferred"); expect(result.error._tag).toBe("AnalysisUnsupportedTargetError"); expect(result.error.message).toContain( @@ -751,7 +746,6 @@ describe.skipIf(process.platform === "win32")( const result = await provider.resolveAnalysisProfile(target, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Failed read admitted"); expect(result.error._tag).toBe("AnalysisCapabilityUnavailableError"); expect(result.error.message).toContain(readFailure.message); @@ -791,7 +785,6 @@ describe.skipIf(process.platform === "win32")( const result = await provider.resolveAnalysisProfile(target, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Cancelled inspection admitted"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -825,7 +818,6 @@ describe.skipIf(process.platform === "win32")( const result = await provider.resolveAnalysisProfile(target, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Failed directory admitted"); expect(result.error._tag).toBe("AnalysisCapabilityUnavailableError"); expect(result.error.message).toContain(readFailure.message); @@ -892,7 +884,6 @@ describe.skipIf(process.platform === "win32")( }); try { const result = await client.start(controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Failed PSP inspection started"); expect(result.error.kind).toBe("start"); expect(result.error.cleanupFailure?.cleanupIncomplete).toBe(true); @@ -970,7 +961,6 @@ describe.skipIf(process.platform === "win32")( }); }; const result = await provider.resolveAnalysisProfile(target); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Changed file admitted"); expect(result.error).toMatchObject({ diagnostics: { @@ -1089,7 +1079,6 @@ describe.skipIf(process.platform === "win32")( providerId: "ghidra", signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Failed profile admitted"); expect(result.error._tag).toBe("AnalysisCapabilityUnavailableError"); expect(result.error.message).toContain(readFailure.message); diff --git a/tests/boundary/filesystem/javascript-applications/javascriptApplicationService.test.ts b/tests/boundary/filesystem/javascript-applications/javascriptApplicationService.test.ts index 677ec2631f..3fe68d932e 100644 --- a/tests/boundary/filesystem/javascript-applications/javascriptApplicationService.test.ts +++ b/tests/boundary/filesystem/javascript-applications/javascriptApplicationService.test.ts @@ -572,7 +572,6 @@ describe("JavaScript application symbolic coverage", () => { format: "directory", source_paths: ["self.js", "mutual.js"], }); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; const normalized = javascriptApplicationAnalysisResultSchema.parse( result.value.normalized_result, diff --git a/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts b/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts index 83519455f4..6b6cdc49ce 100644 --- a/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts +++ b/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts @@ -11,7 +11,7 @@ import { reconcileJavaScriptRuntimeEvidence } from "../../../../src/application/ import { createEvidence } from "../../../../src/domain/evidence.js"; import { mappedRuntimePaths } from "../../../../src/domain/javascript/javascriptRuntimeStaticCandidates.js"; import { projectRuntimeCaptures } from "../../../../src/domain/javascript/javascriptRuntimeReconciliationRuntime.js"; -import { parseRuntimeCaptures } from "../../../../src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js"; +import { parseRuntimeCapture } from "../../../../src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js"; import { electronPageInspectionSchema } from "../../../../src/domain/javascript/electronObservation.js"; import { readRuntimeReconciliationInput, @@ -377,7 +377,7 @@ it("preserves unknown Electron frame provenance without linking it to an authori }, }, }); - const captures = parseRuntimeCaptures([evidence]); + const captures = [parseRuntimeCapture(evidence, ["runtime_observations", 0])]; expect(captures[0]?.scriptsCompleteWithinScope).toBe(false); const projected = projectRuntimeCaptures(captures); const script = projected.entities.find(({ kind }) => kind === "script"); diff --git a/tests/boundary/filesystem/jsonFileResourceOwnership.test.ts b/tests/boundary/filesystem/jsonFileResourceOwnership.test.ts index 5468550ae9..e5c2763985 100644 --- a/tests/boundary/filesystem/jsonFileResourceOwnership.test.ts +++ b/tests/boundary/filesystem/jsonFileResourceOwnership.test.ts @@ -56,7 +56,6 @@ it("retains and retries a JSON file owner after a persistent close failure", asy }); try { const result = await readJsonFile(path, undefined, resources); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a typed JSON cleanup failure"); expect(result.error).toBeInstanceOf(EvidenceFileError); expect(result.error.cleanupIncomplete).toBe(true); diff --git a/tests/boundary/filesystem/keyedArchiveXmlNesting.test.ts b/tests/boundary/filesystem/keyedArchiveXmlNesting.test.ts index f81c6637c0..5a0611e718 100644 --- a/tests/boundary/filesystem/keyedArchiveXmlNesting.test.ts +++ b/tests/boundary/filesystem/keyedArchiveXmlNesting.test.ts @@ -31,14 +31,8 @@ it.each([129, 3000])( ); it.each([ - ["(}", "unexpected_character", 1], - ["{)", "unexpected_character", 1], - ["(@", "unexpected_character", 1], ["{key @", "expected_equals", 5], - ["(x @", "expected_separator", 3], ["(x ", "expected_separator", 3], - ["{key ", "expected_equals", 5], - ["{key = x,", "unexpected_character", 8], ] as const)( "reports OpenStep %s before a deep suffix as %s at %s", async (prefix, code: OpenStepPropertyListCode, position) => { diff --git a/tests/boundary/filesystem/referenceSourceImport.test.ts b/tests/boundary/filesystem/referenceSourceImport.test.ts index 0abeb1fde5..477606dd94 100644 --- a/tests/boundary/filesystem/referenceSourceImport.test.ts +++ b/tests/boundary/filesystem/referenceSourceImport.test.ts @@ -234,7 +234,6 @@ describe("reference source ignore policy read failures", () => { new ArtifactResourceScope(), ); expect(intercepted).toBe(true); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected ignore policy read failure"); expect(result.error.code).toBe(expected); expect(result.error.cause).toBe( @@ -309,7 +308,6 @@ describe("reference source ignore policy cleanup ownership", () => { resources, ); expect(interceptedRead).toBe(true); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected ignore policy read failure"); expect(result.error.code).toBe("io"); expect(result.error.cause).toBe(physical); @@ -373,7 +371,6 @@ describe("reference source ignore policy cleanup ownership", () => { new ArtifactResourceScope(), ); expect(intercepted).toBe(true); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected ignore policy read failure"); expect(result.error.code).toBe("io"); expect(result.error.cause).toBe(reason); diff --git a/tests/boundary/filesystem/setupConfig.test.ts b/tests/boundary/filesystem/setupConfig.test.ts index 4a0acf0c7f..f2b1940df4 100644 --- a/tests/boundary/filesystem/setupConfig.test.ts +++ b/tests/boundary/filesystem/setupConfig.test.ts @@ -610,7 +610,6 @@ describe("JSON client configuration shape diagnostics", () => { }; await writeFile(configPath, original); const read = await readConfigurationFile(configPath, "json"); - expect(read.ok).toBe(false); if (read.ok) throw new Error("expected malformed configuration"); expect(read.error.detail).toBe( `Configuration ${configPath} is malformed: ${problem}`, diff --git a/tests/boundary/filesystem/stableFileHashOwnership.test.ts b/tests/boundary/filesystem/stableFileHashOwnership.test.ts index f7c6f45ac0..b14d680d47 100644 --- a/tests/boundary/filesystem/stableFileHashOwnership.test.ts +++ b/tests/boundary/filesystem/stableFileHashOwnership.test.ts @@ -706,7 +706,6 @@ it.each(["physical", "completed"] as const)( ); try { const result = await publisher.inspectLauncher(path, controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Injected hash outcome passed"); expect(result.error.reason).toBe( outcome === "physical" ? "verification_unavailable" : "cancelled", diff --git a/tests/boundary/filesystem/webArtifactReadOwnership.test.ts b/tests/boundary/filesystem/webArtifactReadOwnership.test.ts index eeb2a2a945..78677fc5a3 100644 --- a/tests/boundary/filesystem/webArtifactReadOwnership.test.ts +++ b/tests/boundary/filesystem/webArtifactReadOwnership.test.ts @@ -123,7 +123,6 @@ it("retains cancelled source read ownership until service close retries it", asy }); const cancelled = await service.trace(input, { signal: controller.signal }); - expect(cancelled.ok).toBe(false); if (cancelled.ok) throw new Error("Expected cancelled source read"); const expectedAcquisition: WebArtifactAcquisition = { kind: "web-artifact-acquisition", @@ -151,7 +150,6 @@ it("retains cancelled source read ownership until service close retries it", asy injected.abortController = undefined; const blocked = await service.trace(input); - expect(blocked.ok).toBe(false); if (blocked.ok) throw new Error("Expected retained cleanup to block load"); expect(blocked.error.cleanupIncomplete).toBe(true); expect(injected.closeAttempts).toBe(2); diff --git a/tests/boundary/firmware/firmwareValidationProjection.test.ts b/tests/boundary/firmware/firmwareValidationProjection.test.ts index 6678997f78..97d1ce9853 100644 --- a/tests/boundary/firmware/firmwareValidationProjection.test.ts +++ b/tests/boundary/firmware/firmwareValidationProjection.test.ts @@ -31,7 +31,6 @@ describe("firmware request validation projection", () => { const service = new FirmwareAnalysisService({ execute }); const result = await service.execute("extract_firmware", input); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected request validation to fail"); const projected = projectAnalysisError(result.error); expect(analysisErrorProjectionSchema.safeParse(projected).success).toBe( diff --git a/tests/boundary/go/goBinaryProvider.test.ts b/tests/boundary/go/goBinaryProvider.test.ts index ccd4c575d7..053c235c17 100644 --- a/tests/boundary/go/goBinaryProvider.test.ts +++ b/tests/boundary/go/goBinaryProvider.test.ts @@ -82,7 +82,6 @@ it("keeps the header-search budget distinct from a worker CPU limit", async () = const path = join(root, "overlapping.elf"); await writeFile(path, createGoOverlappingElfFixture()); const result = await new GoBinaryProvider().inspect({ path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Overlapping header search must be refused"); const projected = projectAnalysisError(result.error); expect(projected).toMatchObject({ diff --git a/tests/boundary/goRustSubjectArchitecture.test.ts b/tests/boundary/goRustSubjectArchitecture.test.ts index bc2ff6b02e..7c7ee3b050 100644 --- a/tests/boundary/goRustSubjectArchitecture.test.ts +++ b/tests/boundary/goRustSubjectArchitecture.test.ts @@ -27,7 +27,6 @@ it.each([ new RustBinaryService(new RustBinaryProvider()), ]) { const result = await service.inspect({ path }); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value.subject).toMatchObject({ architecture: canonical, diff --git a/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts b/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts index e97f4d9d52..8b4a6f537c 100644 --- a/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts +++ b/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts @@ -93,7 +93,6 @@ it("bounds repeated literal output during decoding and reuses one span instead o await writeFile(path, sharedLiteralMetadata(Buffer.alloc(4096, 65), 20)); const decode = vi.spyOn(TextDecoder.prototype, "decode"); const result = await inspectMetadata(path, 12_000); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expanded literals accepted"); expect(result.error).toBeInstanceOf(AnalysisResourceConstraintError); expect(result.error.partialObservation).toMatchObject({ @@ -206,7 +205,6 @@ it("keeps observed source facts with a complete-report refusal", async () => { const bytes = createIl2cppMetadataFixture().bytes; await writeFile(path, bytes); const result = await inspectMetadata(path, 256); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected report allowance refusal"); expect(result.error).toBeInstanceOf(AnalysisResourceConstraintError); expect(result.error.partialObservation).toMatchObject({ @@ -275,7 +273,6 @@ it.each([ { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); @@ -440,7 +437,6 @@ it.each([false, true])( { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the independent failure"); expect(result.error).not.toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(failure); @@ -455,7 +451,6 @@ it("retains the exact empty source observation without claiming a decoded invent const path = join(root, "empty.dat"); await writeFile(path, Buffer.alloc(0)); const result = await inspectMetadata(path); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected unsupported empty metadata"); expect(result.error.message).toContain("unrecognized-magic"); expect(result.error.partialObservation).toMatchObject({ @@ -479,7 +474,6 @@ it("retains the exact source when recognized magic has no complete version", asy await writeFile(path, bytes); const result = await inspectMetadata(path); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected truncated metadata prefix"); expect(result.error).toMatchObject({ _tag: "AnalysisInputError", @@ -516,7 +510,6 @@ it("keeps the metadata source observation when the selected binary does not link const provider = new Il2cppMetadataProvider(); try { const result = await provider.inspect({ path, binary_path: binaryPath }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the binary to be refused"); expect(result.error.partialObservation).toMatchObject({ operation: "observe_il2cpp_metadata_source", @@ -562,7 +555,6 @@ it("accepts cancellation between binary linking batches and keeps the metadata s { path, binary_path: binaryPath }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(yields).toBe(decodeYields + 2); @@ -622,7 +614,6 @@ it("refuses duplicate MethodDef tokens before publishing linked Evidence or Ghid { path, binary_path: binaryPath, detail: "complete" }, { path: foldedSeeds }, ); - expect(accepted.ok).toBe(true); if (!accepted.ok) throw accepted.error; const result = il2cppMetadataSchema.parse(accepted.value.normalized_result); expect(result.method_addresses[0]?.address).toBe( @@ -644,7 +635,6 @@ it("retains both observed file identities and the selected architecture when nat const provider = new Il2cppMetadataProvider(); try { const result = await provider.inspect({ path, binary_path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Unresolved registration accepted"); expect(result.error.partialObservation).toMatchObject({ normalized_result: { @@ -820,7 +810,6 @@ it("names the metadata, not the binary, when linking reads a malformed metadata const provider = new Il2cppMetadataProvider(); try { const result = await provider.inspect({ path, binary_path: binaryPath }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the metadata name to be refused"); expect(result.error).toMatchObject({ _tag: "AnalysisInputError", @@ -879,7 +868,6 @@ it("refuses generic rows that exceed the report budget and keeps the requested p binary_path, generic_instances: true, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected report allowance refusal"); expect(result.error).toBeInstanceOf(AnalysisResourceConstraintError); expect(result.error.partialObservation).toMatchObject({ diff --git a/tests/boundary/inspector/javascriptRuntimeObservation.test.ts b/tests/boundary/inspector/javascriptRuntimeObservation.test.ts index 1719680245..987026bb9a 100644 --- a/tests/boundary/inspector/javascriptRuntimeObservation.test.ts +++ b/tests/boundary/inspector/javascriptRuntimeObservation.test.ts @@ -26,7 +26,7 @@ import { import { inspectWebPageInputSchema } from "../../../src/domain/browserObservation.js"; import { createEvidence } from "../../../src/domain/evidence.js"; import { javascriptRuntimeReconciliationResultSchema } from "../../../src/domain/javascript/javascriptRuntimeReconciliationSchemas.js"; -import { parseRuntimeCaptures } from "../../../src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js"; +import { parseRuntimeCapture } from "../../../src/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js"; import { startFakeV8Inspector } from "../../fixtures/inspector/fakeV8Inspector.js"; import { startFakeCdpBrowser } from "../../fixtures/fakeCdpBrowser.js"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; @@ -867,7 +867,10 @@ test("keeps Inspector parse failures separate and preserves file URL script iden ); expect(new Set(scriptKeys).size).toBe(2); - const parsedCapture = parseRuntimeCaptures([evidence])[0]; + const parsedCapture = parseRuntimeCapture(evidence, [ + "runtime_observations", + 0, + ]); if (parsedCapture?.kind !== "v8-inspector") throw new Error("Expected the Inspector Evidence to parse as V8 capture"); expect( diff --git a/tests/boundary/javascript/javascriptStaticProjectionReclamation.test.ts b/tests/boundary/javascript/javascriptStaticProjectionReclamation.test.ts index 11b78f9819..aec4c32b6b 100644 --- a/tests/boundary/javascript/javascriptStaticProjectionReclamation.test.ts +++ b/tests/boundary/javascript/javascriptStaticProjectionReclamation.test.ts @@ -387,7 +387,6 @@ it("does not discard earlier projections when live heap, not reservations, block if (phase === "static") heap.remainingBytes = 192 * 1024 * 1024; }, ); - expect(second.ok).toBe(false); if (second.ok) throw new Error("Expected live heap refusal"); expect(second.error.error).toMatchObject({ reportedLimits: { parent_result_budget_exhausted: true }, diff --git a/tests/boundary/javascript/workerFailureComposition.test.ts b/tests/boundary/javascript/workerFailureComposition.test.ts index cbe6a4914d..444b95ef30 100644 --- a/tests/boundary/javascript/workerFailureComposition.test.ts +++ b/tests/boundary/javascript/workerFailureComposition.test.ts @@ -112,7 +112,6 @@ it.each([ { nodes: 100, unknowns: 100 }, controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected worker failure"); const failure = result.error.error.cleanupPrimary ?? result.error.error; expect(result.error.error.cleanupIncomplete).toBe(deniedCleanup); diff --git a/tests/boundary/javascriptSemanticTraceEvidence.test.ts b/tests/boundary/javascriptSemanticTraceEvidence.test.ts index 7d3e9f5a72..afea617a1c 100644 --- a/tests/boundary/javascriptSemanticTraceEvidence.test.ts +++ b/tests/boundary/javascriptSemanticTraceEvidence.test.ts @@ -14,7 +14,6 @@ import { analysisCliErrorEnvelopeSchema } from "../../src/contracts/errorSchemas import { toolContract } from "../../src/contracts/toolContracts.js"; import { javascriptApplicationAnalysisResultSchema } from "../../src/domain/javascript/javascriptApplicationAnalysis.js"; import { javaScriptSemanticTraceResultSchema } from "../../src/domain/javascript/javascriptSemanticTraceSchemas.js"; -import { resolveJavaScriptSemanticEvidence } from "../../src/domain/javascript/javascriptSemanticGraph.js"; const SEMANTIC_GRAPH_ID = `jsrg_${"0".repeat(64)}`; @@ -443,17 +442,6 @@ const assertTraceContextsResolve = ( expect(context, reference.context_id).toBeDefined(); if (context === undefined) continue; referencedIds.add(reference.context_id); - expect( - resolveJavaScriptSemanticEvidence( - { evidence_contexts: result.evidence_contexts }, - reference, - ), - ).toMatchObject({ - ...Object.fromEntries( - Object.entries(context).filter(([key]) => key !== "context_id"), - ), - location: reference.location, - }); } expect([...referencedIds].toSorted()).toEqual( [...contexts.keys()].toSorted(), diff --git a/tests/boundary/mcp/commandObservationViews.test.ts b/tests/boundary/mcp/commandObservationViews.test.ts index a5e092e024..dcd4b867b0 100644 --- a/tests/boundary/mcp/commandObservationViews.test.ts +++ b/tests/boundary/mcp/commandObservationViews.test.ts @@ -315,7 +315,6 @@ it.each([true, false, null])( source: { kind: "inline", evidence: parent }, view: { kind: "summary" }, }); - expect(selected.ok).toBe(true); if (!selected.ok) throw selected.error; expect(selected.value.normalized_result).toMatchObject({ summary: report }); if (changed !== null) { diff --git a/tests/boundary/mcp/evidenceRetentionRecovery.test.ts b/tests/boundary/mcp/evidenceRetentionRecovery.test.ts index 7f48d46992..457eb2327d 100644 --- a/tests/boundary/mcp/evidenceRetentionRecovery.test.ts +++ b/tests/boundary/mcp/evidenceRetentionRecovery.test.ts @@ -94,7 +94,6 @@ it.each(["compact", "full"] as const)( evidence: unknown; }; const authenticated = safeParseEvidence(partial.evidence); - expect(authenticated.ok).toBe(true); if (!authenticated.ok) throw authenticated.error; expect(session.hasEvidence(authenticated.value.evidence_id)).toBe(false); expect(records.statistics().evidenceRecords).toBe(0); diff --git a/tests/boundary/mcp/mcpDoctor.test.ts b/tests/boundary/mcp/mcpDoctor.test.ts index 88c96ddf07..9da70535b3 100644 --- a/tests/boundary/mcp/mcpDoctor.test.ts +++ b/tests/boundary/mcp/mcpDoctor.test.ts @@ -656,8 +656,7 @@ describe("production MCP doctor child lifecycle", () => { command: process.execPath, args: [resolve("tests/fixtures/mcpDoctorExit.mjs")], cwd: process.cwd(), - environment: process.env, - deadlineMs: 2_000, + environment: { ...process.env, REA_MCP_DOCTOR_DEADLINE_MS: "2000" }, }); expect(result).toMatchObject({ healthy: false, @@ -726,7 +725,7 @@ describe("production MCP doctor child lifecycle", () => { }); }); - it("kills a child that misses the absolute startup deadline", async () => { + it("applies the configured startup deadline and kills the child", async () => { const root = await createTestTempDirectory("rea-mcp-doctor-"); const pidPath = join(root, "pid"); // Keep filesystem/process I/O real. Advance only the deadline timers, @@ -736,8 +735,11 @@ describe("production MCP doctor child lifecycle", () => { command: process.execPath, args: [resolve("tests/fixtures/mcpDoctorHang.mjs")], cwd: process.cwd(), - environment: { ...process.env, REA_MCP_DOCTOR_PID_PATH: pidPath }, - deadlineMs: 60_000, + environment: { + ...process.env, + REA_MCP_DOCTOR_PID_PATH: pidPath, + REA_MCP_DOCTOR_DEADLINE_MS: "60000", + }, }); const pid = await vi.waitFor( async () => { @@ -770,8 +772,8 @@ describe("production MCP doctor request-flow deadline", () => { ...process.env, REA_MCP_PROBE_MODE: "hang-on-call", REA_MCP_PROBE_READY_PATH: readyPath, + REA_MCP_DOCTOR_DEADLINE_MS: "60000", }, - deadlineMs: 60_000, }); await vi.waitFor( async () => { @@ -807,8 +809,8 @@ describe("production MCP doctor request-flow deadline", () => { ...process.env, REA_MCP_PROBE_MODE: "refuse-call", REA_MCP_PROBE_ERROR_MESSAGE: message, + REA_MCP_DOCTOR_DEADLINE_MS: "5000", }, - deadlineMs: 5_000, }); expect(result.server).not.toBeNull(); const requestFlow = result.checks.find( @@ -821,36 +823,6 @@ describe("production MCP doctor request-flow deadline", () => { 10_000, ); - it("uses REA_MCP_DOCTOR_DEADLINE_MS when no caller deadline is passed", async () => { - const root = await createTestTempDirectory("rea-mcp-doctor-setting-"); - const pidPath = join(root, "pid"); - vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] }); - const pending = runProductionMcpDoctor({ - command: process.execPath, - args: [resolve("tests/fixtures/mcpDoctorHang.mjs")], - cwd: process.cwd(), - environment: { - ...process.env, - REA_MCP_DOCTOR_PID_PATH: pidPath, - REA_MCP_DOCTOR_DEADLINE_MS: "2000", - }, - }); - const pid = await vi.waitFor( - async () => { - const value = Number.parseInt(await readFile(pidPath, "utf8"), 10); - expect(Number.isSafeInteger(value) && value > 0).toBe(true); - return value; - }, - { timeout: 10_000 }, - ); - await vi.advanceTimersByTimeAsync(2_000); - const result = await vi.waitFor(() => pending, { timeout: 10_000 }); - vi.useRealTimers(); - expect(result.healthy).toBe(false); - expectDoctorDeadline(result.checks[0]?.detail, 2_000); - await expect(waitForExit(pid)).resolves.toBeUndefined(); - }, 10_000); - it("refuses an invalid phase budget before starting a child", async () => { const result = await runProductionMcpDoctor({ command: process.execPath, @@ -884,8 +856,7 @@ const runNoisyDoctorChild = async (body: string) => { command: process.execPath, args: [scriptPath], cwd: root, - environment: process.env, - deadlineMs: 5_000, + environment: { ...process.env, REA_MCP_DOCTOR_DEADLINE_MS: "5000" }, }); }; diff --git a/tests/boundary/mcp/mcpFixtureLifecycle.test.ts b/tests/boundary/mcp/mcpFixtureLifecycle.test.ts index 4f8becd064..eeaa2d8815 100644 --- a/tests/boundary/mcp/mcpFixtureLifecycle.test.ts +++ b/tests/boundary/mcp/mcpFixtureLifecycle.test.ts @@ -118,7 +118,6 @@ it("registers acquisition before a producer can reenter shutdown and attach its expect(fixture.clientCloses).not.toHaveBeenCalled(); release.resolve(); const outcome = await opening; - expect(outcome.ok).toBe(false); if (outcome.ok) throw new Error("Shutdown published a late MCP client"); expect(outcome.reason).toMatchObject({ message: expect.stringMatching(/closed/iu), diff --git a/tests/boundary/mcp/mcpHttpOptions.test.ts b/tests/boundary/mcp/mcpHttpOptions.test.ts index b6b8b3b163..154e6eebbf 100644 --- a/tests/boundary/mcp/mcpHttpOptions.test.ts +++ b/tests/boundary/mcp/mcpHttpOptions.test.ts @@ -241,7 +241,6 @@ describe("MCP_ALLOWED_HOSTS", () => { MCP_HOST: "0.0.0.0", MCP_ALLOWED_HOSTS: invalidHost, }); - expect(endpoint.ok).toBe(false); if (endpoint.ok) throw new Error("Expected a configuration refusal"); expect(endpoint.error.settings.map(({ setting }) => setting)).toEqual([ "MCP_ALLOWED_HOSTS", diff --git a/tests/boundary/mcp/mcpStartupPolicy.test.ts b/tests/boundary/mcp/mcpStartupPolicy.test.ts index 04e0657cfc..5adb5dc50e 100644 --- a/tests/boundary/mcp/mcpStartupPolicy.test.ts +++ b/tests/boundary/mcp/mcpStartupPolicy.test.ts @@ -13,8 +13,6 @@ import { profileMcpModuleLoading, } from "../../../scripts/lib/mcp-startup-probe.mjs"; import { - MCP_PHASE_BUDGET_FLOOR_MS, - MCP_PHASE_BUDGET_MAXIMUM_MS, mcpPhaseBudgetRecovery, resolveMcpStartupBudgets, type McpPhaseBudget, @@ -28,9 +26,16 @@ const errorMessage = (cause: unknown): string => cause instanceof Error ? cause.message : String(cause); const expectPhaseText = (text: string, budget: McpPhaseBudget) => { - expect(budget.floorMilliseconds).toBe(MCP_PHASE_BUDGET_FLOOR_MS); - expect(budget.maximumMilliseconds).toBe(MCP_PHASE_BUDGET_MAXIMUM_MS); expect(text).toContain(mcpPhaseBudgetRecovery(budget)); + expect(budget.floorMilliseconds).toBe(1); + expect(budget.maximumMilliseconds).toBe(2_147_483_647); + expect(text).toContain(budget.setting); + expect(text).toContain(budget.phase); + expect(text).toContain(`${String(budget.milliseconds)} ms`); + expect(text).toContain(`source ${budget.source}`); + expect(text).toContain(`default ${String(budget.defaultMilliseconds)} ms`); + expect(text).toContain(`floor ${String(budget.floorMilliseconds)} ms`); + expect(text).toContain(`maximum ${String(budget.maximumMilliseconds)} ms`); }; const expectThrownBudget = async ( @@ -58,8 +63,11 @@ describe("MCP startup policy", () => { expect(budgets.firstCatalog.milliseconds).toBe(20_000); expect(budgets.doctor.milliseconds).toBe(30_000); const initialize = mcpPhaseBudgetRecovery(budgets.initialize); - expect(initialize).toBe(mcpStartupPhaseBudgetRecovery(budgets.initialize)); expectPhaseText(initialize, budgets.initialize); + expectPhaseText( + mcpStartupPhaseBudgetRecovery(budgets.initialize), + budgets.initialize, + ); expectPhaseText( mcpStartupPhaseBudgetRecovery(budgets.toolsList), budgets.toolsList, @@ -70,6 +78,8 @@ describe("MCP startup policy", () => { ); const doctor = mcpDoctorDeadlineRecovery(budgets.doctor); expectPhaseText(doctor, budgets.doctor); + expect(doctor).toMatch(/Codex.*startup_timeout_sec.*client guidance/iu); + expect(doctor).toMatch(/REA does not enforce/iu); const selected = resolveMcpStartupBudgets({ REA_MCP_INITIALIZE_BUDGET_MS: "16000", }); diff --git a/tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts b/tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts index 040441a9e7..bccb6e7446 100644 --- a/tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts +++ b/tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts @@ -9,10 +9,7 @@ import { z } from "zod"; import { toolContract } from "../../../src/contracts/toolContracts.js"; import { MANAGED_NATIVE_VERIFICATION_EXAMPLE } from "../../../src/contracts/managed/managedWorkflowExamples.js"; import { EMPTY_PROCESS_CAPTURE_EXAMPLE } from "../../../src/domain/process/processCaptureExample.js"; -import { - managedNativeVerificationInputSchema, - managedNativeVerificationResultSchema, -} from "../../../src/domain/managed/managedNativeVerificationSchemas.js"; +import { managedNativeVerificationResultSchema } from "../../../src/domain/managed/managedNativeVerificationSchemas.js"; import { nativeUiResultSchema } from "../../../src/domain/native/nativeUiObservation.js"; import { nativeLoadImageSchema } from "../../../src/domain/native/nativeLoadImage.js"; import { createEvidence } from "../../../src/domain/evidence.js"; @@ -175,9 +172,7 @@ it("advertises semantic output invariants and keeps producers aligned with Zod", "accepted plus unsupported equals total", ); const verificationSource = readManagedNativeVerificationSource( - managedNativeVerificationInputSchema.parse( - MANAGED_NATIVE_VERIFICATION_EXAMPLE, - ), + MANAGED_NATIVE_VERIFICATION_EXAMPLE, ); if (!verificationSource.ok) throw verificationSource.error; const validVerification = verifyManagedNativeVerificationSource( diff --git a/tests/boundary/mcp/rizinPendingOutput.test.ts b/tests/boundary/mcp/rizinPendingOutput.test.ts index 4486bee9d0..ede862f3de 100644 --- a/tests/boundary/mcp/rizinPendingOutput.test.ts +++ b/tests/boundary/mcp/rizinPendingOutput.test.ts @@ -258,7 +258,6 @@ test("retains partial bytes and uncertainty when exited output never closes", as }); if (!started.ok) throw started.error; const result = await manager.execute(started.value.session_id, "dr"); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained cleanup uncertainty"); expect(result.error.partialObservation).toMatchObject({ normalized_result: { @@ -309,7 +308,6 @@ test.each(["cancel", "overflow", "cancel-overflow"] as const)( "dr", controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected interrupted command"); const expected = mode.includes("overflow") ? [ @@ -359,7 +357,6 @@ test.each(["before-wait", "during-wait"])( }); if (!started.ok) throw started.error; const result = await manager.execute(started.value.session_id, "dr"); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected stdin protocol failure"); expect(result.error.partialObservation).toMatchObject({ normalized_result: { @@ -403,7 +400,6 @@ test("marks output discarded by the byte queue limit during exit drainage", asyn }); if (!started.ok) throw started.error; const result = await manager.execute(started.value.session_id, "dr"); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected bounded queue failure"); const observation = result.error.partialObservation; expect(observation).toMatchObject({ diff --git a/tests/boundary/mcp/shutdown.test.ts b/tests/boundary/mcp/shutdown.test.ts index bf01cebbd2..663a27c803 100644 --- a/tests/boundary/mcp/shutdown.test.ts +++ b/tests/boundary/mcp/shutdown.test.ts @@ -122,11 +122,9 @@ it("names retained debuggers in stderr and every log level when shutdown ends", requests[0]?.(); await new Promise((resolve) => setImmediate(resolve)); - expect(output).toEqual([ - `${MCP_SHUTDOWN_FAILED}\n`, - `${retainedDebuggerRemediation([4242])}\n`, - ]); - // Comparing with the formatter alone would still pass if it dropped the process. + expect(output).toHaveLength(2); + expect(output[0]).toBe(`${MCP_SHUTDOWN_FAILED}\n`); + expect(output[1]).toBe(`${retainedDebuggerRemediation([4242])}\n`); expect(output[1]).toMatch(/\b4242\b/u); const parsed = logs.map((line) => JSON.parse(line)); expect(parsed).toContainEqual( diff --git a/tests/boundary/model/modelArtifact.test.ts b/tests/boundary/model/modelArtifact.test.ts index f181bb6a62..9d2957706a 100644 --- a/tests/boundary/model/modelArtifact.test.ts +++ b/tests/boundary/model/modelArtifact.test.ts @@ -210,7 +210,6 @@ it.each([ const fixture = ggufFixture({ tensors: [{ ...tensor, offset: 0n }] }); const { provider, path } = await providerAt(fixture.bytes); const result = await provider.inspect({ path, hash: "header" }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected format refusal"); expect(result.error).toMatchObject({ constraint: "file_format_rejected", @@ -611,7 +610,6 @@ it.each(ggufKLayouts)( }).bytes, ); const rejected = await provider.inspect({ path, hash: "header" }); - expect(rejected.ok).toBe(false); if (rejected.ok) throw new Error("Incomplete common K row admitted"); expect(rejected.error).toMatchObject({ constraint: "file_format_rejected", @@ -1143,7 +1141,6 @@ it("classifies over-depth Safetensors extension JSON as a resource limit", async ); const { provider, path } = await providerAt(fixture.bytes); const result = await provider.inspect({ path, hash: "header" }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Over-depth JSON was accepted"); expect(result.error).toMatchObject({ _tag: "AnalysisResourceConstraintError", diff --git a/tests/boundary/native/pwntoolsArtifactCleanup.test.ts b/tests/boundary/native/pwntoolsArtifactCleanup.test.ts index 359b42ec67..3538a38f32 100644 --- a/tests/boundary/native/pwntoolsArtifactCleanup.test.ts +++ b/tests/boundary/native/pwntoolsArtifactCleanup.test.ts @@ -104,7 +104,6 @@ it("reports the read failure without stale incomplete-cleanup state when close r const decoder = makeDecoder(); try { const result = await decoder.inspect({ path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Injected close failure was not returned"); expect(result.error.partialObservation).toEqual({ kind: "file-snapshot-hash", @@ -152,7 +151,6 @@ it("retains a persistent failed input descriptor and refuses the next acquisitio const openedAfterFailure = closeState.opened; const retry = await decoder.inspect({ path }); - expect(retry.ok).toBe(false); if (retry.ok) throw new Error("Retained descriptor was not retried"); expect(projectAnalysisError(retry.error).code).toBe("cleanup_incomplete"); expect(closeState.opened).toBe(openedAfterFailure); diff --git a/tests/boundary/pcap/pcapProvider.test.ts b/tests/boundary/pcap/pcapProvider.test.ts index e9ac466a76..3a368fbb69 100644 --- a/tests/boundary/pcap/pcapProvider.test.ts +++ b/tests/boundary/pcap/pcapProvider.test.ts @@ -212,7 +212,6 @@ it.each(["stdout", "stderr"] as const)( operation: "inspect_pcap_capture", input: { path }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected malformed producer encoding"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "unreadable_output", @@ -244,7 +243,6 @@ posixIt.each(["stdout", "stderr"] as const)( operation: "inspect_pcap_client", input: {}, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected malformed version output"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "unreadable_output", @@ -266,7 +264,6 @@ it.each(["stdout", "stderr"] as const)( operation: "inspect_pcap_capture", input: { path }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected malformed producer encoding"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "unreadable_output", @@ -926,7 +923,6 @@ it.each([false, true])( input: { path }, }); try { - expect(result.ok).toBe(false); if (result.ok) throw new Error("Cleanup failure cannot return success"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "cleanup_incomplete", diff --git a/tests/boundary/process/ghidraJavaProbePreparation.test.ts b/tests/boundary/process/ghidraJavaProbePreparation.test.ts index d64d359714..79f4aef4b1 100644 --- a/tests/boundary/process/ghidraJavaProbePreparation.test.ts +++ b/tests/boundary/process/ghidraJavaProbePreparation.test.ts @@ -129,7 +129,6 @@ it.skipIf(process.platform === "win32")( controller.abort(); const result = await outcome; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a cancelled Java probe"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); await expect(access(java.launched)).rejects.toThrow(); @@ -156,7 +155,6 @@ it.skipIf(process.platform === "win32")( const result = await probe(java.command); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a failed Java probe"); expect(result.error).toBeInstanceOf(ProviderAdapterError); expect(result.error).toMatchObject({ diff --git a/tests/boundary/process/ownedDebuggerSession.test.ts b/tests/boundary/process/ownedDebuggerSession.test.ts index c46a66d7ab..acb51a1344 100644 --- a/tests/boundary/process/ownedDebuggerSession.test.ts +++ b/tests/boundary/process/ownedDebuggerSession.test.ts @@ -1556,6 +1556,7 @@ it("finds retained debugger IDs through composed failures without looping on cyc it("names every retained debugger in its remediation", () => { const remediation = retainedDebuggerRemediation([4242, 4243]); + expect(remediation).toMatch(/no later REA command can retry this cleanup/iu); expect(remediation).toMatch(/\b4242\b/u); expect(remediation).toMatch(/\b4243\b/u); }); diff --git a/tests/boundary/process/processCaptureLifecycle.test.ts b/tests/boundary/process/processCaptureLifecycle.test.ts index 598e14c9f4..a9a0e81cc4 100644 --- a/tests/boundary/process/processCaptureLifecycle.test.ts +++ b/tests/boundary/process/processCaptureLifecycle.test.ts @@ -246,7 +246,6 @@ itWithCaptureCapability( }, }, ); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value.frames.length).toBeGreaterThan(0); expect(Date.parse(result.value.manifest.completed_at)).toBeLessThan( diff --git a/tests/boundary/process/processTruncationAdapters.test.ts b/tests/boundary/process/processTruncationAdapters.test.ts index 3fab345416..a44005378c 100644 --- a/tests/boundary/process/processTruncationAdapters.test.ts +++ b/tests/boundary/process/processTruncationAdapters.test.ts @@ -9,7 +9,7 @@ import { compareProcessCaptures } from "../../../src/domain/process/processCompa import { parseProcessCapture } from "../../../src/domain/process/processCaptureParsing.js"; import { processCaptureSchema } from "../../../src/domain/process/processCapture.js"; import { processSourceTruncated } from "../../../src/domain/process/processCaptureCoverage.js"; -import { compareProcessTraces } from "../../../src/domain/process/processTraceComparison.js"; +import { evaluateProcessTraceComparison } from "../../../src/domain/process/processTraceComparison.js"; import { createServer } from "../../../src/server/createServer.js"; import { createTestBinarySession } from "../../fixtures/binarySession.js"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; @@ -110,9 +110,10 @@ itWithCaptureCapability.each(["cli", "mcp"] as const)( variants: [{ id: "observed", trace: events.map(({ id }) => id) }], }, }; - expect(compareProcessTraces(result, result, specification).verdict).toBe( - "equivalent", - ); + expect( + evaluateProcessTraceComparison(result, result, specification).result + .verdict, + ).toBe("equivalent"); const { truncation_details: _details, ...withoutCoverage } = result; expect(() => parseProcessCapture(withoutCoverage)).toThrow( "truncation_details", diff --git a/tests/boundary/process/verifierCommandSemantics.test.ts b/tests/boundary/process/verifierCommandSemantics.test.ts index 3624b93eb3..dbeedc9523 100644 --- a/tests/boundary/process/verifierCommandSemantics.test.ts +++ b/tests/boundary/process/verifierCommandSemantics.test.ts @@ -454,7 +454,6 @@ it.skipIf(process.platform === "win32")( expect(closeSettled).toBe(false); release.resolve(); const [execution, close] = await Promise.all([running, closeOutcome]); - expect(execution.ok).toBe(false); if (execution.ok) throw new Error("Expected cancelled execution"); const failure = z .object({ diff --git a/tests/boundary/providers/CutterBridgeClient.test.ts b/tests/boundary/providers/CutterBridgeClient.test.ts index ee58b4d366..d008c66a42 100644 --- a/tests/boundary/providers/CutterBridgeClient.test.ts +++ b/tests/boundary/providers/CutterBridgeClient.test.ts @@ -1488,7 +1488,6 @@ describe("CutterBridgeClient: scenario group 9", () => { expected_generation: 7, command: "pd 4", }); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value.limitations).toContainEqual( expect.stringMatching(/output.*transport limit.*omitted/iu), diff --git a/tests/boundary/providers/GdbSessionReviewRegressions.test.ts b/tests/boundary/providers/GdbSessionReviewRegressions.test.ts index eb0b00634b..efbbd86516 100644 --- a/tests/boundary/providers/GdbSessionReviewRegressions.test.ts +++ b/tests/boundary/providers/GdbSessionReviewRegressions.test.ts @@ -470,7 +470,6 @@ process.stdin.resume(); } const started = await starting; await closing; - expect(started.ok).toBe(false); if (started.ok) throw new Error("GDB unexpectedly started"); expect(started.error._tag).toBe("AnalysisCancelledError"); expect(await readFile(signalPath, "utf8")).toBe("SIGTERM"); diff --git a/tests/boundary/providers/adb/adbBugreportPublication.test.ts b/tests/boundary/providers/adb/adbBugreportPublication.test.ts index 4abb1be624..3387e57d2b 100644 --- a/tests/boundary/providers/adb/adbBugreportPublication.test.ts +++ b/tests/boundary/providers/adb/adbBugreportPublication.test.ts @@ -179,7 +179,6 @@ test("retains final and producer paths when digest verification is cancelled", a const result = await f.provider.execute(f.request, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.partialObservation).toMatchObject({ @@ -201,7 +200,6 @@ test("returns staging allocation failures without invoking device collection", a const f = await fixture(); vi.mocked(mkdtemp).mockRejectedValueOnce(new Error("staging denied")); const result = await f.provider.execute(f.request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected output failure"); expect(result.error._tag).toBe("AnalysisOutputError"); expect(execFileBytes).not.toHaveBeenCalled(); @@ -212,7 +210,6 @@ test("retains published evidence and retries failed staging cleanup", async () = const f = await fixture(); vi.mocked(rm).mockRejectedValueOnce(new Error("cleanup denied")); const result = await f.provider.execute(f.request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cleanup failure"); expect(result.error.cleanupResources).toContain(dirname(f.reportedPath())); expect(result.error.partialObservation).toMatchObject({ @@ -252,7 +249,6 @@ test("provider close resolves the exact bugreport digest cleanup error", async ( }); const result = await f.provider.execute(f.request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected retained digest close failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.partialObservation).toMatchObject({ @@ -301,7 +297,6 @@ test("keeps a bugreport error unresolved until digest and staging owners recover }); const result = await f.provider.execute(f.request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected digest and staging cleanup failure"); const originatingError = result.error; const stagingDirectory = dirname(f.reportedPath()); @@ -350,7 +345,6 @@ test("refuses an archive reported outside the owned staging directory", async () stderr: Buffer.alloc(0), }); const result = await f.provider.execute(f.request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected protocol refusal"); expect(result.error._tag).toBe("AnalysisProtocolError"); expect(await readFile(existing, "utf8")).toBe("existing evidence"); @@ -366,7 +360,6 @@ test("preserves the primary protocol failure when staging cleanup also fails", a }); vi.mocked(rm).mockRejectedValueOnce(new Error("cleanup denied")); const result = await f.provider.execute(f.request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected protocol and cleanup failure"); expect(result.error.cause).toMatchObject({ errors: [ diff --git a/tests/boundary/providers/adb/adbCommandFinalization.test.ts b/tests/boundary/providers/adb/adbCommandFinalization.test.ts index 73d6339277..52397f92a1 100644 --- a/tests/boundary/providers/adb/adbCommandFinalization.test.ts +++ b/tests/boundary/providers/adb/adbCommandFinalization.test.ts @@ -76,7 +76,6 @@ const capture = async ( const failureOf = async (result: ReturnType) => { const completed = await result; - expect(completed.ok).toBe(false); if (completed.ok) throw new Error("Expected command failure"); return completed.error; }; @@ -191,7 +190,6 @@ nativeClientTest( operation: "inspect_adb_client", input: {}, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected capture overflow"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "resource_constraint", @@ -241,7 +239,6 @@ nativeClientTest.each([ {}, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected completion cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -287,7 +284,6 @@ nativeClientTest.each([false, true])( { operation: "inspect_adb_client", input: {} }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected version timeout"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "provider_timeout", diff --git a/tests/boundary/providers/adb/adbHashCleanupConsumers.test.ts b/tests/boundary/providers/adb/adbHashCleanupConsumers.test.ts index b697d70f00..f67e296cad 100644 --- a/tests/boundary/providers/adb/adbHashCleanupConsumers.test.ts +++ b/tests/boundary/providers/adb/adbHashCleanupConsumers.test.ts @@ -132,7 +132,6 @@ test.each(digestCases)( const f = await fixture(); f.failFirstClose(); const result = await f.provider.execute(request(f.root)); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected hash descriptor cleanup failure"); const returnedError = result.error; const originalCause = returnedError.cause; @@ -212,7 +211,6 @@ for (const closeFails of [false, true]) { const result = await f.provider.execute(request(f.root), { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected digest read failure"); expect(projectAnalysisError(result.error).code).not.toBe("cancelled"); expect( @@ -272,7 +270,6 @@ for (const closeFails of [false, true]) { const result = await f.provider.execute(request(f.root), { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected completion cancellation"); expect(projectAnalysisError(result.error).code).toBe( closeFails ? "cleanup_incomplete" : "cancelled", diff --git a/tests/boundary/providers/adb/adbInputSnapshotOwnership.test.ts b/tests/boundary/providers/adb/adbInputSnapshotOwnership.test.ts index e99702ff39..623b3c2194 100644 --- a/tests/boundary/providers/adb/adbInputSnapshotOwnership.test.ts +++ b/tests/boundary/providers/adb/adbInputSnapshotOwnership.test.ts @@ -129,7 +129,6 @@ test("retains failed snapshot cleanup ownership and retries it on close", async }); const result = await f.provider.execute(f.request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected snapshot cleanup failure"); expect(result.error.cleanupResources).toContain(dirname(f.snapshotPath())); const evidence = parseEvidence(result.error.partialObservation); @@ -359,7 +358,6 @@ test.each([ const result = await f.provider.execute(f.request, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected snapshot operation failure"); expect(result.error._tag).toBe(tag); expect(result.error.cleanupIncomplete).toBe(false); @@ -437,7 +435,6 @@ test.each([ }, cancelDuringClose ? { signal: controller.signal } : undefined, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected retained digest cleanup failure"); expect(result.error._tag).toBe( cancelDuringClose ? "AnalysisCancelledError" : "ProviderAdapterError", @@ -613,7 +610,6 @@ test("resolves package-directory cleanup on the originating pull error", async ( output_directory: outputDirectory, }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected pull and cleanup failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toContain(packageDirectory); @@ -652,7 +648,6 @@ test.each([false, true])( const result = await f.provider.execute(f.request, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); if (failCleanup) { @@ -717,7 +712,6 @@ test("cancels after the input snapshot copy and before contacting the device", a const result = await f.provider.execute(f.request, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(execFileOutput).toHaveBeenCalledTimes(1); @@ -744,7 +738,6 @@ test("reports input snapshot capacity failures before contacting the device", as }); const result = await f.provider.execute(f.request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected snapshot capacity failure"); expect(result.error._tag).toBe("AnalysisOutputError"); expect(result.error.cause).toBe(capacityFailure); diff --git a/tests/boundary/providers/adb/adbScreenPublicationCancellation.test.ts b/tests/boundary/providers/adb/adbScreenPublicationCancellation.test.ts index e3b87cfa02..a1cd6b1abc 100644 --- a/tests/boundary/providers/adb/adbScreenPublicationCancellation.test.ts +++ b/tests/boundary/providers/adb/adbScreenPublicationCancellation.test.ts @@ -72,7 +72,6 @@ test("does not publish a screen capture cancelled before the commit point", asyn }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(abortReason); @@ -106,7 +105,6 @@ test("retains a committed screen capture receipt when cancellation arrives after }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(abortReason); @@ -173,7 +171,6 @@ test.each([1, 2])( operation: "capture_adb_screen", input: { serial: "device", output_directory: output }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected staged screen cleanup failure"); const originatingError = result.error; const originatingCause = originatingError.cause; @@ -264,7 +261,6 @@ test("retains the committed receipt and cleanup observation when cancellation ra }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cleanupIncomplete).toBe(true); @@ -357,7 +353,6 @@ test("cancellation after a failed hard link but before exclusive creation does n }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(abortReason); @@ -396,7 +391,6 @@ test("retains a receipt when cancellation arrives after exclusive output creatio }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(abortReason); @@ -456,7 +450,6 @@ test("closes and retains ownership when exclusive output stat fails", async () = operation: "capture_adb_screen", input: { serial: "device", output_directory: output }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected stat failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toContain(destination); @@ -529,7 +522,6 @@ test("waits for descriptor close before rolling back an incomplete exclusive out operation: "capture_adb_screen", input: { serial: "device", output_directory: output }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected write failure"); expect(result.error.cleanupIncomplete).toBe(false); expect(result.error.cause).toBeInstanceOf(AggregateError); @@ -593,7 +585,6 @@ test.each([false, true])( operation: "capture_adb_screen", input: { serial: "device", output_directory: f.output }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected close failure"); expect(parseEvidence(result.error.partialObservation)).toMatchObject({ operation: "capture_adb_screen", @@ -620,7 +611,6 @@ test("keeps a sticky publication close failure until provider close retries its operation: "capture_adb_screen", input: { serial: "device", output_directory: f.output }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected close failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toContain( @@ -652,7 +642,6 @@ test("resolves an admission cleanup error when the retained runtime-root lease c operation: "capture_adb_screen", input: { serial: "device", output_directory: f.output }, }); - expect(first.ok).toBe(false); if (first.ok) throw new Error("expected publication close failure"); expect(first.error.cleanupIncomplete).toBe(true); expect(f.closeAttempts()).toBe(2); @@ -661,7 +650,6 @@ test("resolves an admission cleanup error when the retained runtime-root lease c operation: "capture_adb_screen", input: { serial: "device", output_directory: f.output }, }); - expect(admission.ok).toBe(false); if (admission.ok) throw new Error("expected retained cleanup refusal"); const admissionError = admission.error; expect(admissionError.cleanupIncomplete).toBe(true); @@ -682,7 +670,6 @@ test("resolves the provider close aggregate after its failed root owner recovers operation: "capture_adb_screen", input: { serial: "device", output_directory: f.output }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected publication close failure"); expect(result.error.cleanupIncomplete).toBe(true); @@ -730,7 +717,6 @@ test("retains incomplete cleanup on a cancelled capture while keeping cancellati }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cleanupIncomplete).toBe(true); diff --git a/tests/boundary/providers/artifactReadCleanupRetry.test.ts b/tests/boundary/providers/artifactReadCleanupRetry.test.ts index 1903ca368a..5fac7c3edd 100644 --- a/tests/boundary/providers/artifactReadCleanupRetry.test.ts +++ b/tests/boundary/providers/artifactReadCleanupRetry.test.ts @@ -79,7 +79,6 @@ it.each(["go", "pe"] as const)( const first = await provider.inspect(input, { signal: controller.signal, }); - expect(first.ok).toBe(false); if (first.ok) throw new Error("Injected close failure was not returned"); expect(projectAnalysisError(first.error)).toMatchObject({ code: "cleanup_incomplete", diff --git a/tests/boundary/providers/desktopExportJsonDepth.test.ts b/tests/boundary/providers/desktopExportJsonDepth.test.ts index 357c615eef..0dc7a65864 100644 --- a/tests/boundary/providers/desktopExportJsonDepth.test.ts +++ b/tests/boundary/providers/desktopExportJsonDepth.test.ts @@ -98,6 +98,7 @@ print(json.dumps(_text_view("state.json", text, len(text.encode("utf-8"))))) expect(output.format).toBe(format); if (native.ok) { expect(output.error).toBeUndefined(); + if (format === "json") expect(output).toMatchObject({ truncated: false }); // Compare JSON values on their wire form, independent of object prototypes. expect(JSON.stringify(output.view)).toBe(JSON.stringify(native.value)); if ( diff --git a/tests/boundary/providers/desktopExportPython.test.ts b/tests/boundary/providers/desktopExportPython.test.ts index 4d832ee668..5254963836 100644 --- a/tests/boundary/providers/desktopExportPython.test.ts +++ b/tests/boundary/providers/desktopExportPython.test.ts @@ -262,24 +262,6 @@ it("refuses the JSON numbers REA's state view refuses, as JSON with an error rat }); }); -it("refuses JSON nested deeper than the 500 levels REA's view keeps, reading the boundary itself", () => { - const nested = (levels: number) => - `${"[".repeat(levels)}${"]".repeat(levels)}`; - const texts = [nested(501), nested(502), nested(1100)]; - - const python = pythonJson(texts); - - expect(texts.map((text) => jsonView(text).ok)).toEqual([true, false, false]); - texts.forEach((text, index) => { - const typescript = jsonView(text); - expect(python[index]).toEqual( - typescript.ok - ? { format: "json", view: typescript.value, truncated: false } - : { format: "json", view: null, error: typescript.error }, - ); - }); -}); - /** The exported module's format, view and error for each named text, and REA's for the same bytes. */ const textViews = (files: readonly (readonly [string, string])[]) => { const imports = PYTHON_IMPORTS.split("\n") diff --git a/tests/boundary/providers/ghidra/ghidraClient.test.ts b/tests/boundary/providers/ghidra/ghidraClient.test.ts index 6e481ad4af..594b4bca9e 100644 --- a/tests/boundary/providers/ghidra/ghidraClient.test.ts +++ b/tests/boundary/providers/ghidra/ghidraClient.test.ts @@ -499,7 +499,6 @@ it("reports snapshot descriptor cleanup immediately and resolves its exact error await client.close(); }); const result = await client.hashTargetSnapshot(); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected snapshot final close failure"); expect(result.error.cleanupFailure?.cleanupIncomplete).toBe(true); expect(result.error.partialObservation).toMatchObject({ @@ -537,7 +536,6 @@ it("preserves completed snapshot hashing and exact cancellation during descripto }); onTestFinished(() => close.mockRestore()); const result = await client.hashTargetSnapshot(controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected final-close cancellation"); expect(result.error.kind).toBe("cancelled"); expect(result.error.cancellation?.reason).toBe(reason); @@ -662,7 +660,6 @@ it("preserves snapshot cancellation and completed hash while final close also fa close.mockRestore(); }); const result = await client.hashTargetSnapshot(controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation and cleanup failure"); expect(result.error.kind).toBe("cancelled"); expect(result.error.cancellation?.reason).toBe(reason); @@ -769,7 +766,6 @@ it("keeps a snapshot read failure primary across late cancellation and failed cl close.mockRestore(); }); const result = await client.hashTargetSnapshot(controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected read and cleanup failure"); expect(result.error.kind).toBe("protocol"); expect(result.error.cancellation).toBeUndefined(); diff --git a/tests/boundary/providers/ghidra/ghidraJavaLaunch.test.ts b/tests/boundary/providers/ghidra/ghidraJavaLaunch.test.ts index ca7d30603d..7a7c8c37cf 100644 --- a/tests/boundary/providers/ghidra/ghidraJavaLaunch.test.ts +++ b/tests/boundary/providers/ghidra/ghidraJavaLaunch.test.ts @@ -411,7 +411,6 @@ describe.skipIf(process.platform === "win32")( async (mode) => { const { session, launcher, analysisArguments } = await fixture(mode); const launched = await launcher.launch(session); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("Expected a helper failure"); expect(analysisArguments).toEqual([]); const failure = bindGhidraSessionFailure(() => ({}))( @@ -947,7 +946,6 @@ describe.skipIf(process.platform === "win32")( {}, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected interrupted startup"); const projected = analysisErrorProjectionSchema.parse( JSON.parse(JSON.stringify(projectAnalysisError(result.error))), diff --git a/tests/boundary/providers/ghidra/ghidraLauncher.test.ts b/tests/boundary/providers/ghidra/ghidraLauncher.test.ts index 38875cd4e3..f33e3ddfd6 100644 --- a/tests/boundary/providers/ghidra/ghidraLauncher.test.ts +++ b/tests/boundary/providers/ghidra/ghidraLauncher.test.ts @@ -868,7 +868,6 @@ describe("Ghidra existing project launcher", () => { join(parent, "absent-project"), spawned, ); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("launch unexpectedly succeeded"); // The launcher wraps the copy failure; the reason stays on the cause. expect(String(launched.error.cause)).toMatch(/does not exist/u); @@ -895,7 +894,6 @@ describe("Ghidra existing project launcher", () => { sourceProject, spawned, ); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("launch unexpectedly succeeded"); expect(String(launched.error.cause)).toMatch(/rea-project\.gpr/u); expect(spawned).toHaveLength(0); @@ -922,7 +920,6 @@ describe("Ghidra existing project launcher", () => { runtime.path, spawned, ); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("launch unexpectedly succeeded"); expect(String(launched.error.cause)).toMatch( /overlaps the REA runtime directory/u, @@ -947,7 +944,6 @@ describe("Ghidra existing project launcher", () => { join(runtime.path, "project"), spawned, ); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("launch unexpectedly succeeded"); expect(String(launched.error.cause)).toMatch( /overlaps the REA runtime directory/u, @@ -983,7 +979,6 @@ describe("Ghidra existing project symlink overlap", () => { alias, spawned, ); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("launch unexpectedly succeeded"); expect(String(launched.error.cause)).toMatch( /overlaps the REA runtime directory/u, @@ -1016,7 +1011,6 @@ describe("Ghidra expanded project admission", () => { sourceProject, spawned, ); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("launch unexpectedly succeeded"); expect(String(launched.error.cause)).toMatch( /restore saved \.grez archives/u, diff --git a/tests/boundary/providers/hopper/bridgeBootstrapCleanup.test.ts b/tests/boundary/providers/hopper/bridgeBootstrapCleanup.test.ts index 447fe7c504..e059ebebc8 100644 --- a/tests/boundary/providers/hopper/bridgeBootstrapCleanup.test.ts +++ b/tests/boundary/providers/hopper/bridgeBootstrapCleanup.test.ts @@ -78,7 +78,6 @@ it.each(["bootstrap", "launch"] as const)( removal.failBootstrapWrite = false; }); const started = await client.start(); - expect(started.ok).toBe(false); if (started.ok) throw new Error("Expected failed fixture launch"); expect(removal.bootstrapAttempts).toBe(1); expect(started.error.cleanupIncomplete).toBe(true); @@ -132,7 +131,6 @@ it.each(["failed", "cancelled"] as const)( ); expect(result.ok).toBe(false); if (outcome === "cancelled") { - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(HopperCancelledError); expect(result.error.cause).toBe(reason); diff --git a/tests/boundary/providers/hopper/bridgeLauncher.test.ts b/tests/boundary/providers/hopper/bridgeLauncher.test.ts index ac72a5b3a2..0e9a9b24b6 100644 --- a/tests/boundary/providers/hopper/bridgeLauncher.test.ts +++ b/tests/boundary/providers/hopper/bridgeLauncher.test.ts @@ -119,7 +119,6 @@ for (const deniedStops of [0, 2]) token: "fixture-token", runId: randomUUID(), }); - expect(launched.ok).toBe(false); if (launched.ok) throw new Error("Expected private-display timeout"); const original = launched.error; expect(projectAnalysisError(original).details).toMatchObject({ diff --git a/tests/boundary/providers/hopper/hopperClient.startupWaiters.test.ts b/tests/boundary/providers/hopper/hopperClient.startupWaiters.test.ts index 4863cb5199..49692a81f0 100644 --- a/tests/boundary/providers/hopper/hopperClient.startupWaiters.test.ts +++ b/tests/boundary/providers/hopper/hopperClient.startupWaiters.test.ts @@ -23,7 +23,6 @@ it("preserves a warm provider when an already cancelled caller joins", async () const reason = { source: "caller", opaque: 7 }; controller.abort(reason); const joined = await client.start(controller.signal); - expect(joined.ok).toBe(false); if (joined.ok) throw new Error("Expected cancellation"); expect(joined.error).toBeInstanceOf(HopperCancelledError); expect(joined.error.cause).toBe(reason); diff --git a/tests/boundary/providers/kuna/kunaCommandCancellation.test.ts b/tests/boundary/providers/kuna/kunaCommandCancellation.test.ts index 8f4cb76bfb..0be2039e16 100644 --- a/tests/boundary/providers/kuna/kunaCommandCancellation.test.ts +++ b/tests/boundary/providers/kuna/kunaCommandCancellation.test.ts @@ -146,7 +146,6 @@ it("keeps cancellation output and primary reason while exact command cleanup is client.close(), client.close(), ]); - expect(rootFailure.ok).toBe(false); if (rootFailure.ok) throw new Error("Expected workspace cleanup failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toEqual([workspace.path]); diff --git a/tests/boundary/providers/kuna/kunaHashOwnerPropagation.test.ts b/tests/boundary/providers/kuna/kunaHashOwnerPropagation.test.ts index 589626d420..840aa8fdc5 100644 --- a/tests/boundary/providers/kuna/kunaHashOwnerPropagation.test.ts +++ b/tests/boundary/providers/kuna/kunaHashOwnerPropagation.test.ts @@ -413,7 +413,6 @@ it.skipIf(process.platform === "win32")( outputBytes: 1024 * 1024, signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Kuna command unexpectedly ran"); const originatingError = result.error; const originalCause = originatingError.cause; @@ -473,11 +472,9 @@ it.skipIf(process.platform === "win32")( if (first.ok) throw new Error("hash descriptor close unexpectedly passed"); const blocked = await request(); - expect(blocked.ok).toBe(false); if (blocked.ok) throw new Error("Kuna ran with retained hash cleanup"); expect(blocked.error).toMatchObject({ cleanupIncomplete: true }); const prepared = await commands.prepare(); - expect(prepared.ok).toBe(false); if (prepared.ok) throw new Error("prepare passed retained hash cleanup"); expect(prepared.error).toMatchObject({ cleanupIncomplete: true }); @@ -535,7 +532,6 @@ it.skipIf(process.platform === "win32")( }); const blocked = await request(); - expect(blocked.ok).toBe(false); if (blocked.ok) throw new Error("Kuna ran with retained hash cleanup"); expect(blocked.error).toMatchObject({ cleanupIncomplete: true }); expect(injected.closeCalls).toBe(2); @@ -607,7 +603,6 @@ it.skipIf(process.platform === "win32")( injected.releaseCloseFailures = false; const resolved = await binary.previewTarget(fixture.target); - expect(resolved.ok).toBe(false); if (resolved.ok) throw new Error("Kuna readiness unexpectedly succeeded"); expect(resolved.error).toMatchObject({ cleanupIncomplete: true, diff --git a/tests/boundary/providers/kuna/kunaProjectCache.test.ts b/tests/boundary/providers/kuna/kunaProjectCache.test.ts index 311a97ea8d..8ca83f3682 100644 --- a/tests/boundary/providers/kuna/kunaProjectCache.test.ts +++ b/tests/boundary/providers/kuna/kunaProjectCache.test.ts @@ -594,7 +594,6 @@ it("blocks repeated cache reads while a retained hash descriptor cannot close", expect(originals.size).toBe(1); } const closed = await warmCache.close(); - expect(closed.ok).toBe(false); if (closed.ok) throw new Error("Close lost the retained hash owner"); expect(closed.error.cleanupIncomplete).toBe(true); expect(new Set(closed.error.cleanupResources).size).toBe(2); @@ -641,7 +640,6 @@ it("keeps hash cleanup aggregates pending through retained staging removal", asy installation, ...(await target("program")), }); - expect(built.ok).toBe(false); if (built.ok) throw new Error("Expected the retained hash close to fail"); expect(built.error).toBeInstanceOf(ProviderCleanupError); if (!(built.error instanceof ProviderCleanupError)) throw built.error; @@ -654,13 +652,11 @@ it("keeps hash cleanup aggregates pending through retained staging removal", asy await chmod(stagingPath, 0o500); const firstClose = await cache.close(); - expect(firstClose.ok).toBe(false); if (firstClose.ok) throw new Error("Close lost the retained descriptor"); aggregates.push(firstClose.error); close.mockRestore(); const stagingClose = await cache.close(); - expect(stagingClose.ok).toBe(false); if (stagingClose.ok) throw new Error("Close lost the retained staging"); aggregates.push(stagingClose.error); retainedPath = stagingClose.error.cleanupResources[0]; diff --git a/tests/boundary/providers/kuna/kunaSpanCloseOwnership.test.ts b/tests/boundary/providers/kuna/kunaSpanCloseOwnership.test.ts index 52e570eefd..02ee7f0a33 100644 --- a/tests/boundary/providers/kuna/kunaSpanCloseOwnership.test.ts +++ b/tests/boundary/providers/kuna/kunaSpanCloseOwnership.test.ts @@ -260,7 +260,6 @@ it.each( { procedure: "main" }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected physical span failure"); const primary = closeFails ? result.error.cleanupPrimary : result.error; expect(primary?._tag).toBe("ProviderAdapterError"); @@ -325,7 +324,6 @@ it.each([false, true])( { procedure: "main" }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected continued-read cancellation"); const primary = closeFails ? result.error.cleanupPrimary : result.error; expect(primary).toBeInstanceOf(AnalysisCancelledError); diff --git a/tests/boundary/providers/kuna/kunaStringInventory.test.ts b/tests/boundary/providers/kuna/kunaStringInventory.test.ts index 6fc83e0067..58ea041ecf 100644 --- a/tests/boundary/providers/kuna/kunaStringInventory.test.ts +++ b/tests/boundary/providers/kuna/kunaStringInventory.test.ts @@ -155,7 +155,6 @@ it("indexes canonical u64 addresses and keeps each encoding at the same address" wire({ ...document(), count: rows.length, strings: rows }), 3, ); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value.items.map(({ address }) => address)).toEqual([ "0x0", @@ -192,7 +191,6 @@ it("indexes canonical u64 addresses and keeps each encoding at the same address" it("looks up an empty validated inventory", async () => { const { result } = await read(wire({ ...document(), count: 0, strings: [] })); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(kunaStringsAtAddress(result.value, "0x0")).toEqual([]); }); diff --git a/tests/boundary/providers/managed/managedMemberComparison.test.ts b/tests/boundary/providers/managed/managedMemberComparison.test.ts index dcf442a063..e055a3ff73 100644 --- a/tests/boundary/providers/managed/managedMemberComparison.test.ts +++ b/tests/boundary/providers/managed/managedMemberComparison.test.ts @@ -12,10 +12,7 @@ import { compareManagedMemberPaths, } from "../../../../src/application/managed/ManagedMemberComparisonService.js"; import { parseBinaryTarget } from "../../../../src/application/BinaryTargetResolver.js"; -import { - managedMemberComparisonResultSchema, - compareManagedMembersInputSchema, -} from "../../../../src/domain/managed/managedMemberComparison.js"; +import { managedMemberComparisonResultSchema } from "../../../../src/domain/managed/managedMemberComparison.js"; import { readManagedMemberEvidence } from "../../../../src/domain/managed/managedMemberComparisonMatch.js"; import { comparisonLimitations } from "../../../../src/domain/managed/managedMemberComparisonCoverage.js"; import { createEvidence } from "../../../../src/domain/evidence.js"; @@ -230,12 +227,10 @@ const compare = ( authority: "shipped-artifact", }, ); - const result = executeManagedMemberComparison( - compareManagedMembersInputSchema.parse({ - left: observe(left, edit.left), - right: observe(right, edit.right), - }), - ); + const result = executeManagedMemberComparison({ + left: observe(left, edit.left), + right: observe(right, edit.right), + }); if (!result.ok) throw result.error; return managedMemberComparisonResultSchema.parse( result.value.evidence.normalized_result, @@ -688,12 +683,10 @@ describe("managed call-target comparison", () => { : edge, ), ); - const result = executeManagedMemberComparison( - compareManagedMembersInputSchema.parse({ - left, - right: rightWithOneUnknownTarget, - }), - ); + const result = executeManagedMemberComparison({ + left, + right: rightWithOneUnknownTarget, + }); if (!result.ok) throw result.error; const report = managedMemberComparisonResultSchema.parse( result.value.evidence.normalized_result, @@ -709,9 +702,10 @@ describe("managed call-target comparison", () => { "/fixture/no-edges.dll", () => [], ); - const unknown = executeManagedMemberComparison( - compareManagedMembersInputSchema.parse({ left, right: unavailableEdges }), - ); + const unknown = executeManagedMemberComparison({ + left, + right: unavailableEdges, + }); if (!unknown.ok) throw unknown.error; expect( managedMemberComparisonResultSchema.parse( @@ -744,10 +738,10 @@ describe("managed member comparison path workflow", () => { }, ); }; - const input = compareManagedMembersInputSchema.parse({ + const input = { left: observe(0xff, "/tmp/partial-left.dll"), right: observe(0xfe, "/tmp/partial-right.dll"), - }); + }; const result = executeManagedMemberComparison(input); if (!result.ok) throw result.error; const comparison = managedMemberComparisonResultSchema.parse( diff --git a/tests/boundary/providers/native/LldbCallTracer.cleanup.test.ts b/tests/boundary/providers/native/LldbCallTracer.cleanup.test.ts index f9d0302acd..4dde3ed90f 100644 --- a/tests/boundary/providers/native/LldbCallTracer.cleanup.test.ts +++ b/tests/boundary/providers/native/LldbCallTracer.cleanup.test.ts @@ -131,7 +131,6 @@ it.skipIf(process.platform === "win32")( try { const trace = await tracer.trace(request); - expect(trace.ok).toBe(false); if (trace.ok) throw new Error("Expected incomplete cleanup"); expect(trace.error).toBeInstanceOf(ProviderCleanupError); if (!(trace.error instanceof ProviderCleanupError)) return; @@ -167,7 +166,6 @@ it.skipIf(process.platform === "win32")( }, ); const result = await cancelledTracer.trace(request, controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancelled trace"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect((await cancelledTracer.close()).ok).toBe(true); @@ -193,7 +191,6 @@ it.skipIf(process.platform === "win32")( try { const trace = await tracer.trace(request); - expect(trace.ok).toBe(false); if (trace.ok) throw new Error("Expected unverified target cleanup"); expect(trace.error).toBeInstanceOf(ProviderCleanupError); if (!(trace.error instanceof ProviderCleanupError)) return; @@ -236,7 +233,6 @@ it.skipIf(process.platform === "win32")( try { const trace = await tracer.trace(request); - expect(trace.ok).toBe(false); if (trace.ok) throw new Error("Expected malformed PID cleanup failure"); expect(trace.error).toBeInstanceOf(ProviderCleanupError); if (!(trace.error instanceof ProviderCleanupError)) return; diff --git a/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts b/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts index dd406e1bb5..a064acf1fc 100644 --- a/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts +++ b/tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts @@ -115,8 +115,9 @@ it("extracts case-distinct names only when the destination can preserve them", a if (!caseSensitive) { if (extracted.ok) throw new Error("expected a destination case collision"); expect(projectAnalysisError(extracted.error)).toMatchObject({ - message: - "Destination filesystem cannot store both main.js and Main.js; inventory retains both logical names.", + message: expect.stringMatching( + /[Cc]annot store both main\.js and Main\.js.*inventory retains both/u, + ), details: { operation: "extract_artifact", reason: "path" }, }); await expect(lstat(output)).rejects.toMatchObject({ code: "ENOENT" }); diff --git a/tests/boundary/providers/native/artifactProvider.capacity.test.ts b/tests/boundary/providers/native/artifactProvider.capacity.test.ts index 357a1d631a..91fa8b384b 100644 --- a/tests/boundary/providers/native/artifactProvider.capacity.test.ts +++ b/tests/boundary/providers/native/artifactProvider.capacity.test.ts @@ -44,8 +44,7 @@ it.each([1, 129])( expect(projected).toMatchObject({ code: "truncated", retryable: false, - message: - "PyInstaller compressed PYZ images exceed the 128-file private storage budget", + message: expect.stringMatching(/PyInstaller.*PYZ.*128.file.*budget/iu), details: { boundary: "capacity" }, remediation: { action: expect.stringContaining( diff --git a/tests/boundary/providers/native/artifactProvider.cleanupRetry.test.ts b/tests/boundary/providers/native/artifactProvider.cleanupRetry.test.ts index 629159bd0e..94305038ab 100644 --- a/tests/boundary/providers/native/artifactProvider.cleanupRetry.test.ts +++ b/tests/boundary/providers/native/artifactProvider.cleanupRetry.test.ts @@ -86,7 +86,6 @@ it("retains a failed reader close, blocks new work, and retries the same reader" expect(closeOwners[2]).toBe(closeOwners[1]); const incompleteClose = await client.close(); - expect(incompleteClose.ok).toBe(false); if (incompleteClose.ok) throw new Error("Expected reader cleanup failure"); expect(incompleteClose.error).toBeInstanceOf(ProviderCleanupError); expect(closeOwners).toHaveLength(4); diff --git a/tests/boundary/providers/native/artifactProvider.extractionCompleteness.test.ts b/tests/boundary/providers/native/artifactProvider.extractionCompleteness.test.ts index 2ef366f3bb..26fa178edc 100644 --- a/tests/boundary/providers/native/artifactProvider.extractionCompleteness.test.ts +++ b/tests/boundary/providers/native/artifactProvider.extractionCompleteness.test.ts @@ -104,8 +104,7 @@ it.each(["file", "directory"] as const)( ); await expect(materialize()).rejects.toMatchObject({ reason: "integrity", - message: - "Inventoried regular artifact entries were not materialized: z/missing.txt", + message: expect.stringMatching(/not materialized.*z\/missing\.txt/iu), }); await expect(access(output)).rejects.toThrow(); expect( @@ -130,8 +129,9 @@ it.skipIf(process.platform === "win32" || process.getuid?.() === 0)( onTestFinished(() => chmod(child, 0o755)); await expect(materialize()).rejects.toMatchObject({ reason: "integrity", - message: - "Inventoried regular artifact entries were not materialized: child/selected.txt", + message: expect.stringMatching( + /not materialized.*child\/selected\.txt/iu, + ), }); await expect(access(output)).rejects.toThrow(); await chmod(child, 0o755); diff --git a/tests/boundary/providers/native/lipoFieldOwnership.test.ts b/tests/boundary/providers/native/lipoFieldOwnership.test.ts index df4eb6eac1..151019efb5 100644 --- a/tests/boundary/providers/native/lipoFieldOwnership.test.ts +++ b/tests/boundary/providers/native/lipoFieldOwnership.test.ts @@ -167,7 +167,6 @@ it("refuses retained raw-field expansion as capacity rather than a malformed lip "list_architectures", path, ); - expect(refused.ok).toBe(false); if (refused.ok) throw new Error("Expected lipo field retention refusal"); expect(refused.error).toMatchObject({ _tag: "AnalysisResourceConstraintError", diff --git a/tests/boundary/providers/native/lldbCallTracerFailures.test.ts b/tests/boundary/providers/native/lldbCallTracerFailures.test.ts index 53b74aa0bf..4e35f7fb78 100644 --- a/tests/boundary/providers/native/lldbCallTracerFailures.test.ts +++ b/tests/boundary/providers/native/lldbCallTracerFailures.test.ts @@ -393,7 +393,6 @@ describe("LLDB completed trace retention after process cleanup", () => { complete: true, }; if (phase === "clean") { - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value.run).toEqual(completed); expect(result.value.stdout).toEqual(stdout); @@ -403,7 +402,6 @@ describe("LLDB completed trace retention after process cleanup", () => { }); return; } - expect(result.ok).toBe(false); if (result.ok) throw new Error("expected cleanup failure"); expect(result.error).toBeInstanceOf(ProviderCleanupError); expect(result.error.cleanupIncomplete).toBe(true); @@ -568,7 +566,6 @@ describe("LLDB failure retention through the production tracer", () => { const result = await tracer.trace(request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected unavailable tracer result"); expect(result.error).toMatchObject({ _tag: "ProviderAdapterError", @@ -754,7 +751,6 @@ describe("LLDB primary outcome during owned process cleanup", () => { expect(observedStop?.status).toMatch( /^(already-exited|verified-cleanup|terminated|killed)$/u, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the bridge target error"); expect(result.error).toBeInstanceOf(AnalysisCapabilityUnavailableError); if (!(result.error instanceof AnalysisCapabilityUnavailableError)) @@ -840,7 +836,6 @@ describe("LLDB process exit while output is still open", () => { expect(stopReceipt?.status).toMatch( /^(already-exited|verified-cleanup|terminated|killed)$/u, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the bridge target error"); expect(result.error).toBeInstanceOf(AnalysisCapabilityUnavailableError); if (!(result.error instanceof AnalysisCapabilityUnavailableError)) @@ -963,7 +958,6 @@ describe("LLDB target proof published before interruption", () => { const result = await tracer.trace(request, controller.signal); expect(leader.interrupted).toBe(true); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an interrupted trace"); expect(result.error).toBeInstanceOf( interruption === "caller cancellation" @@ -1044,7 +1038,6 @@ describe("LLDB target proof read by cleanup retry", () => { try { const result = await tracer.trace(request, controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a cancelled trace"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cleanupIncomplete).toBe(true); @@ -1270,7 +1263,6 @@ describe("LLDB process exit at output-close loop completion", () => { expect(stopReceipt?.status).toMatch( /^(already-exited|verified-cleanup|terminated|killed)$/u, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the bridge target error"); expect(result.error).toBeInstanceOf(AnalysisCapabilityUnavailableError); if (!(result.error instanceof AnalysisCapabilityUnavailableError)) @@ -1323,7 +1315,6 @@ describe("LLDB late timeout publication", () => { const result = await tracer.trace(request); if (runtime === undefined) throw new Error("LLDB fixture did not run"); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the late deadline to be retained"); expect(result.error).toBeInstanceOf(AnalysisTimeoutError); if (!(result.error instanceof AnalysisTimeoutError)) return; @@ -1381,7 +1372,6 @@ describe("LLDB pre-target phase proof", () => { ); try { const rejected = await tracer.trace(request); - expect(rejected.ok).toBe(false); if (rejected.ok) throw new Error("Expected launch refusal"); expect(projectAnalysisError(rejected.error)).toMatchObject({ code: "capability_unavailable", @@ -1395,7 +1385,6 @@ describe("LLDB pre-target phase proof", () => { code: "ENOENT", }); const completed = await tracer.trace(request); - expect(completed.ok).toBe(true); if (!completed.ok) throw completed.error; expect(completed.value.run).toMatchObject(successfulTracerOutput); expect(launches).toBe(2); @@ -1664,7 +1653,6 @@ it("retains journal descriptor cleanup after a cancelled run instead of removing await release?.(); }); const result = await tracer.trace(request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancelled controlled run"); const partial = nativeCallPartialObservationSchema.parse( result.error.partialObservation, @@ -1939,7 +1927,6 @@ for (const { await descriptorControl?.closeCaptured(); }); const result = await tracer.trace(request, controller.signal); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained readback cleanup"); expect(result.error.cleanupIncomplete).toBe(true); const partial = nativeCallPartialObservationSchema.parse( diff --git a/tests/boundary/providers/native/lldbDiscovery.test.ts b/tests/boundary/providers/native/lldbDiscovery.test.ts index e524425941..457a732968 100644 --- a/tests/boundary/providers/native/lldbDiscovery.test.ts +++ b/tests/boundary/providers/native/lldbDiscovery.test.ts @@ -70,7 +70,6 @@ for (const [reason, code] of [ }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected discovery failure"); expect(launch).not.toHaveBeenCalled(); expect(result.error.cause).toBe( diff --git a/tests/boundary/providers/native/lldbLauncherBoundary.test.ts b/tests/boundary/providers/native/lldbLauncherBoundary.test.ts index 0ae261a5f3..7071faf969 100644 --- a/tests/boundary/providers/native/lldbLauncherBoundary.test.ts +++ b/tests/boundary/providers/native/lldbLauncherBoundary.test.ts @@ -180,7 +180,6 @@ setTimeout(() => process.exit(0), 10000); expect(identity?.state).toBe("readable"); controller.abort(reason); const result = await pending; - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected caller cancellation"); expect(result.error).toMatchObject({ _tag: "AnalysisCancelledError", diff --git a/tests/boundary/providers/native/lldbPrelaunchCleanup.test.ts b/tests/boundary/providers/native/lldbPrelaunchCleanup.test.ts index 201256e3fa..dd58ac1b65 100644 --- a/tests/boundary/providers/native/lldbPrelaunchCleanup.test.ts +++ b/tests/boundary/providers/native/lldbPrelaunchCleanup.test.ts @@ -242,7 +242,6 @@ it.each([ const tracer = new LldbCallTracer({}, undefined, async () => err(failure)); try { const result = await tracer.trace(request); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected preparation failure"); expect(result.error._tag).toBe(tag); expect(result.error.cause).toBe(abortReason); diff --git a/tests/boundary/providers/native/lldbRetainedObservations.test.ts b/tests/boundary/providers/native/lldbRetainedObservations.test.ts index 0c29c8b147..7fe6273e07 100644 --- a/tests/boundary/providers/native/lldbRetainedObservations.test.ts +++ b/tests/boundary/providers/native/lldbRetainedObservations.test.ts @@ -217,7 +217,6 @@ describe("LLDB retained observation read failures", () => { ); const result = await readLldbObservationJournal("journal", files); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value.status).toBe("read-failure"); if (result.value.status !== "read-failure") @@ -237,7 +236,6 @@ describe("LLDB retained observation read failures", () => { "stdout", readbackFilesFailingAfter(source, Buffer.byteLength(prefix), failure), ); - expect(partial.ok).toBe(true); if (!partial.ok) throw partial.error; expect(partial.value.status).toBe("read-failure"); if (partial.value.status !== "read-failure") diff --git a/tests/boundary/providers/native/nativeCallObservation.test.ts b/tests/boundary/providers/native/nativeCallObservation.test.ts index 9bc21d92e0..aa17d7fdeb 100644 --- a/tests/boundary/providers/native/nativeCallObservation.test.ts +++ b/tests/boundary/providers/native/nativeCallObservation.test.ts @@ -574,7 +574,6 @@ it("retains completed call facts when cancellation arrives with the tracer resul undefined, controller.signal, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected completion cancellation"); expect(result.error).toMatchObject({ _tag: "AnalysisCancelledError", diff --git a/tests/boundary/providers/native/nativeCallTargetCleanup.test.ts b/tests/boundary/providers/native/nativeCallTargetCleanup.test.ts index 74781d143c..d71313c46a 100644 --- a/tests/boundary/providers/native/nativeCallTargetCleanup.test.ts +++ b/tests/boundary/providers/native/nativeCallTargetCleanup.test.ts @@ -56,7 +56,6 @@ it("retains preflight read failure and exact descriptor across failed client cle await client.close(); }); const result = await client.execute("observe_native_calls", parameters); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained descriptor cleanup"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toEqual([path]); @@ -194,7 +193,6 @@ for (const readFails of [false, true]) const result = await client.execute("observe_native_calls", parameters, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained hash close failure"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toEqual([path]); @@ -242,7 +240,6 @@ it("retains a completed hash when cancellation arrives after successful descript const result = await client.execute("observe_native_calls", parameters, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected final hash cancellation"); expect(result.error).toMatchObject({ _tag: "AnalysisCancelledError", @@ -271,7 +268,6 @@ it("does not adopt an arbitrary thrown tracer cleanup marker", async () => { await client.close(); }); const result = await client.execute("observe_native_calls", parameters); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected opaque tracer failure"); expect(result.error).toMatchObject({ _tag: "ProviderAdapterError", diff --git a/tests/boundary/providers/native/nativeDispatchFormatFailures.test.ts b/tests/boundary/providers/native/nativeDispatchFormatFailures.test.ts index 9f3300fd8f..a58ffc252d 100644 --- a/tests/boundary/providers/native/nativeDispatchFormatFailures.test.ts +++ b/tests/boundary/providers/native/nativeDispatchFormatFailures.test.ts @@ -71,7 +71,6 @@ it.each(sectionCases)( bytes.write(section, 104); bytes.writeBigUInt64LE(BigInt(size), 144); const { path, result } = await inspect(bytes); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected malformed target refusal"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "unsupported_target", @@ -87,7 +86,6 @@ it("keeps an unsupported big-endian CPU declaration distinct from provider failu bytes.writeUInt32BE(0x0100000c, 4); bytes.writeUInt32BE(2, 12); const { path, result } = await inspect(bytes); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected unsupported target refusal"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "unsupported_target", @@ -98,7 +96,6 @@ it("keeps an unsupported big-endian CPU declaration distinct from provider failu it("continues decoding the well-formed eight-byte class-list control", async () => { const { result } = await inspect(objcRecordBudgetMacho("class")); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; expect(result.value.result).toMatchObject({ result: { @@ -112,7 +109,6 @@ it.each([1n, 20001n])( async (count) => { const bytes = objcAdoptedProtocolCountMacho(count); const { result } = await inspect(bytes); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; const report = nativeDispatchMetadataResultSchema.parse( result.value.result, diff --git a/tests/boundary/providers/native/nativeDispatchMetadataFileCleanup.test.ts b/tests/boundary/providers/native/nativeDispatchMetadataFileCleanup.test.ts index 2be5071fad..e888dfa5ac 100644 --- a/tests/boundary/providers/native/nativeDispatchMetadataFileCleanup.test.ts +++ b/tests/boundary/providers/native/nativeDispatchMetadataFileCleanup.test.ts @@ -56,7 +56,6 @@ it("keeps the integrity failure primary and retains the target descriptor when c const { client, path, state } = await fixture(false); const result = await client.execute("inspect_native_dispatch_metadata", {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected integrity and close failures"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toEqual([path]); @@ -79,7 +78,6 @@ it("reports a completed read whose close rejects as retained cleanup", async () const { client, path, state } = await fixture(true); const result = await client.execute("inspect_native_dispatch_metadata", {}); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the close failure"); expect(result.error).toBeInstanceOf(ProviderCleanupError); expect(result.error.cleanupIncomplete).toBe(true); diff --git a/tests/boundary/providers/native/nativeMachoEncryptionBinding.test.ts b/tests/boundary/providers/native/nativeMachoEncryptionBinding.test.ts index 7474f1cb3b..1a495ea7d4 100644 --- a/tests/boundary/providers/native/nativeMachoEncryptionBinding.test.ts +++ b/tests/boundary/providers/native/nativeMachoEncryptionBinding.test.ts @@ -86,7 +86,6 @@ class MutatingRunner extends NativeFixtureRunner { it("refuses facts when the file changes while the tools inspect it", async () => { const path = await writeTarget(); const { result } = await inspect(path, new MutatingRunner(path)); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a changed-artifact refusal"); expect(result.error).toMatchObject({ _tag: "AnalysisArtifactChangedError", @@ -139,7 +138,6 @@ it("retains the target descriptor when close rejects and retries it on client cl const path = await writeTarget(); const state = await failingClose(); const { client, result } = await inspect(path); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected the close failure"); expect(result.error).toBeInstanceOf(ProviderCleanupError); expect(result.error.cleanupIncomplete).toBe(true); @@ -159,7 +157,6 @@ it("keeps the inspection failure primary when the descriptor close also rejects" const path = await writeTarget(); const state = await failingClose(); const { client, result } = await inspect(path, new MutatingRunner(path)); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected change and close failures"); expect(result.error).toBeInstanceOf(ProviderCleanupError); expect(result.error.cleanupIncomplete).toBe(true); @@ -192,7 +189,6 @@ it("reports cancellation that arrives during the final close without retaining t {}, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected final-close cancellation"); expect(result.error).toMatchObject({ _tag: "AnalysisCancelledError", diff --git a/tests/boundary/providers/native/nativePlistBinarySource.test.ts b/tests/boundary/providers/native/nativePlistBinarySource.test.ts index a21b9efe01..d75bc79308 100644 --- a/tests/boundary/providers/native/nativePlistBinarySource.test.ts +++ b/tests/boundary/providers/native/nativePlistBinarySource.test.ts @@ -9,7 +9,6 @@ import { AnalysisResourceConstraintError, } from "../../../../src/domain/analysisErrorCore.js"; import { ArtifactFileCleanupFailure } from "../../../../src/artifacts/ArtifactFileOperation.js"; -import { scanBinaryPlistScalars } from "../../../../src/artifacts/apple/PlistScalars.js"; import { ProviderAdapterError } from "../../../../src/domain/providerAdapterError.js"; import { buildBinary, type PlistValue } from "plist"; import { NativeMacOSProvider } from "../../../../src/native/NativeMacOSProvider.js"; @@ -57,7 +56,6 @@ it("reports a binary source-size refusal as a typed resource limit", async () => const client = binaryClient(root, runner); const result = await client.execute("inspect_plist", { path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected file-size refusal"); expect(result.error).toBeInstanceOf(AnalysisResourceConstraintError); expect(result.error).toMatchObject({ @@ -89,18 +87,17 @@ it.each([ // Three times the source length exceeds the 64 MiB decode estimate while // the source stays below the separate 64 MiB input ceiling. value: { data: Buffer.alloc(22 * 1024 * 1024, 0x78) }, - reason: "binary plist object table exceeds the native plist decode budget", + reason: /binary plist object table.*decode budget/iu, limits: { maximum_decoded_bytes: 64 * 1024 * 1024 }, allowance: - "The 64 MiB (67108864-byte) native binary plist decode allowance (no runtime override)", + /64 MiB.*67108864-byte.*binary plist decode.*no runtime override/iu, }, { budget: "nesting", value: nested(MAX_JSON_DEPTH - 1), - reason: "binary plist nesting exceeds the native plist decode budget", + reason: /binary plist nesting.*decode budget/iu, limits: { maximum_nesting_depth: MAX_JSON_DEPTH - 2 }, - allowance: - "The 998-level native plist nesting allowance (no runtime override)", + allowance: /998-level.*plist nesting.*no runtime override/iu, }, ])( "names the fixed binary plist $budget allowance instead of host memory", @@ -113,15 +110,17 @@ it.each([ const client = binaryClient(root, runner); const result = await client.execute("inspect_plist", { path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected decode allowance refusal"); expect(result.error).toBeInstanceOf(AnalysisResourceConstraintError); expect(result.error).toMatchObject({ resource: "memory", - reason, + reason: expect.stringMatching(reason), reportedLimits: limits, retryable: false, - fixedAllowance: { name: allowance, kind: "parser" }, + fixedAllowance: { + name: expect.stringMatching(allowance), + kind: "parser", + }, }); const projected = projectAnalysisError(result.error); expect(projected).toMatchObject({ @@ -129,9 +128,8 @@ it.each([ retryable: false, details: { resource: "memory", reported_limits: limits }, }); - expect(projected.remediation.action).toBe( - `${allowance} is a fixed allowance. Worker memory limits, inherited limits, and additional host memory do not raise it. Select another complete input within the allowance when that preserves the needed observation. Repeating the unchanged request fails the same way.`, - ); + expect(projected.remediation.action).toMatch(allowance); + expect(projected.remediation.action).toMatch(/complete input.*allowance/iu); expect(runner.tools).toEqual(["file"]); }, ); @@ -145,7 +143,6 @@ it("keeps a malformed binary plist as a selected-input failure", async () => { const client = binaryClient(root, runner); const result = await client.execute("inspect_plist", { path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected malformed input failure"); expect(result.error).toBeInstanceOf(AnalysisInputError); expect(runner.tools).toEqual(["file"]); @@ -156,9 +153,12 @@ it("rejects a reachable binary date with an invalid marker before projection", a const bytes = Buffer.from( buildBinary({ date: new Date("2001-01-01T00:00:00.100Z") }), ); - const date = scanBinaryPlistScalars(bytes).dates[0]; - if (date === undefined) throw new Error("binary plist fixture lost its date"); - bytes[date.offset] = 0x30; + // Date marker followed by 0.1 seconds since the 2001 plist epoch. + const encodedDate = Buffer.from("333fb999999999999a", "hex"); + const offset = bytes.indexOf(encodedDate); + expect(offset).toBeGreaterThanOrEqual(0); + expect(bytes.indexOf(encodedDate, offset + 1)).toBe(-1); + bytes[offset] = 0x30; await writeFile(path, bytes); const runner = new BinaryNativeRunner({ file: "Apple binary property list\n", @@ -167,7 +167,6 @@ it("rejects a reachable binary date with an invalid marker before projection", a const result = await client.execute("inspect_plist", { path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected malformed date input failure"); expect(result.error).toBeInstanceOf(AnalysisInputError); expect(result.error).toMatchObject({ @@ -210,7 +209,6 @@ it("preserves the exact caller cancellation reason during a binary read", async { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); @@ -244,7 +242,6 @@ it("preserves a physical EIO when a pending binary read is then aborted", async { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected physical read failure"); expect(result.error).toBeInstanceOf(ProviderAdapterError); expect(result.error.cause).toBe(primary); @@ -282,7 +279,6 @@ it("retains the exact binary descriptor owner when reading and closing fail", as ); const result = await client.execute("inspect_plist", { path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed read and close"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupResources).toContain(path); diff --git a/tests/boundary/providers/native/nativePlistFileCleanup.test.ts b/tests/boundary/providers/native/nativePlistFileCleanup.test.ts index 6058ff033b..ac1c55c6b6 100644 --- a/tests/boundary/providers/native/nativePlistFileCleanup.test.ts +++ b/tests/boundary/providers/native/nativePlistFileCleanup.test.ts @@ -47,7 +47,6 @@ it("does not adopt a command's arbitrary thrown cleanup marker as a file owner", const run = vi.spyOn(runner, "run").mockRejectedValueOnce(foreign); onTestFinished(() => run.mockRestore()); const result = await client.execute("inspect_plist", { path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected opaque command failure"); expect(result.error.cause).toBe(foreign); expect(result.error.cleanupIncomplete).toBe(false); @@ -110,7 +109,6 @@ it("keeps mixed client cleanup live until both file and tracer owners resolve", }); expect((await client.execute("inspect_plist", { path })).ok).toBe(false); const first = await client.close(); - expect(first.ok).toBe(false); if (first.ok) throw new Error("Expected both pending owners"); expect(new Set(first.error.cleanupResources)).toEqual( new Set([path, "trace-owner"]), @@ -170,7 +168,6 @@ it.for(["path-input", "target"] as const)( "inspect_plist", selection === "target" ? {} : { path }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained cleanup failure"); expect(result.error).toMatchObject({ cleanupIncomplete: true, @@ -238,7 +235,6 @@ for (const readFails of [false, true]) { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected retained close failure"); const failure = result.error.cause; expect(failure).toBeInstanceOf(ArtifactFileCleanupFailure); @@ -270,7 +266,6 @@ it.each([null, 0, new ProviderCleanupError("foreign", ["unowned"], {})])( { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected pre-admission cancellation"); expect(result.error.cause).toBe(reason); expect(result.error.cleanupIncomplete).toBe(false); @@ -290,7 +285,6 @@ it("retains a failed admission close before any native command", async () => { run.mockRestore(); }); const result = await client.execute("inspect_plist", { path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failed admission close"); expect(result.error.cleanupResources).toContain(path); expect(result.error.cleanupIncomplete).toBe(true); @@ -323,7 +317,6 @@ it("preserves an opaque cancellation observed during successful prefix close", a { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected late cancellation"); expect(result.error).toMatchObject({ operation: "inspect_plist", diff --git a/tests/boundary/providers/native/nativeProvider.test.ts b/tests/boundary/providers/native/nativeProvider.test.ts index a19206cfd1..e8c89fdae1 100644 --- a/tests/boundary/providers/native/nativeProvider.test.ts +++ b/tests/boundary/providers/native/nativeProvider.test.ts @@ -838,7 +838,6 @@ describe("native returned cleanup ownership", () => { // aggregate marker when that retry is still incomplete. const closed = await client.close(); expect(cleanupCalls).toBe(2); - expect(closed.ok).toBe(false); if (closed.ok) throw new Error("Expected cleanup to remain incomplete"); expect(closed.error.cleanupIncomplete).toBe(true); expect(closed.error.cleanupResources).toEqual( @@ -1231,7 +1230,6 @@ describe("native command failure projection", () => { ]); const closed = await client.close(); - expect(closed.ok).toBe(false); if (closed.ok) throw new Error("Expected unknown owner cleanup facts"); expect(closed.error.cleanupIncomplete).toBe(true); expect(closed.error.cleanupResources).toEqual([ diff --git a/tests/boundary/providers/native/nativeUiFinalization.test.ts b/tests/boundary/providers/native/nativeUiFinalization.test.ts index bdf2d0df0a..9ead2d933c 100644 --- a/tests/boundary/providers/native/nativeUiFinalization.test.ts +++ b/tests/boundary/providers/native/nativeUiFinalization.test.ts @@ -55,7 +55,6 @@ it("preserves the exact native UI admission cancellation reason", async () => { signal: controller.signal, invoke, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -70,7 +69,6 @@ it("uses the command owner's cancellation fact without guessing from ambient sig throw new ExecFileOutputCancelledError(reason); }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected command cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -86,7 +84,6 @@ it("preserves malformed helper output when a later abort is already visible", as return { ok: true, result: {} }; }, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected invalid output"); expect(result.error._tag).toBe("ProviderAdapterError"); expect(result.error.cause).toMatchObject({ name: "ZodError" }); @@ -113,7 +110,6 @@ it("retains native UI facts and caller reason when cancellation arrives during f const result = await client.execute("observe_native_ui", input, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected finalization cancellation"); expect(result.error._tag).toBe("AnalysisCancelledError"); expect(result.error.cause).toBe(reason); @@ -144,14 +140,12 @@ it("resolves every native UI cleanup error only after its exact runtime releases factory.mockRestore(); }); const observed = await client.execute("observe_native_ui", input); - expect(observed.ok).toBe(false); if (observed.ok) throw new Error("Expected cleanup failure"); expect(observed.error.cleanupIncomplete).toBe(true); expect(observed.error.partialObservation).toMatchObject({ initial: snapshot, }); const blocked = await client.execute("observe_native_ui", input); - expect(blocked.ok).toBe(false); if (blocked.ok) throw new Error("Expected retained admission blocker"); expect(runtime.invoke).toHaveBeenCalledTimes(1); const retry = await client.close(); @@ -230,7 +224,6 @@ it("preserves a physical helper failure and all cleanup facts across a late abor const result = await client.execute("observe_native_ui", input, { signal: controller.signal, }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected helper and cleanup failures"); expect(result.error.cleanupIncomplete).toBe(true); expect(result.error.cleanupPrimary?._tag).toBe("ProviderAdapterError"); @@ -265,7 +258,6 @@ it.each([false, true])( factory.mockRestore(); }); const result = await client.execute("observe_native_ui", input); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected owned deadline timeout"); const primary = resolvedAnalysisError( result.error.cleanupPrimary ?? result.error, @@ -311,7 +303,6 @@ it.each(["physical", "cancelled"] as const)( }, }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected typed scenario failure"); expect(result.error._tag).toBe( outcome === "cancelled" diff --git a/tests/boundary/rust/rustBinaryBudget.test.ts b/tests/boundary/rust/rustBinaryBudget.test.ts index 8b498c62ab..6368e01369 100644 --- a/tests/boundary/rust/rustBinaryBudget.test.ts +++ b/tests/boundary/rust/rustBinaryBudget.test.ts @@ -12,7 +12,6 @@ it("refuses extra rustc paths without asking the caller to wait", async () => { const path = join(root, "many-hashes.elf"); await writeFile(path, createRustHashOverflowImage()); const result = await new RustBinaryProvider().inspect({ path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected a hash-capacity refusal"); const projected = projectAnalysisError(result.error); expect(projected).toMatchObject({ @@ -34,7 +33,6 @@ it("refuses an oversized Rust input without evidence-reply advice", async () => await writeFile(path, Buffer.from([0x7f, 0x45, 0x4c, 0x46])); await truncate(path, RUST_BINARY_INPUT_BYTES + 1); const result = await new RustBinaryProvider().inspect({ path }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected an input-size refusal"); const projected = projectAnalysisError(result.error); expect(projected).toMatchObject({ diff --git a/tests/boundary/signals/recordingProvider.test.ts b/tests/boundary/signals/recordingProvider.test.ts index a6376729ad..9884f00423 100644 --- a/tests/boundary/signals/recordingProvider.test.ts +++ b/tests/boundary/signals/recordingProvider.test.ts @@ -1274,7 +1274,6 @@ it.each([ {}, { signal: f.controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected failure"); expect(result.error).toMatchObject({ operation: "inspect_signal_decoders", diff --git a/tests/composition/analysis-sessions/binarySession.test.ts b/tests/composition/analysis-sessions/binarySession.test.ts index cb5a7b3a7a..bf7842494c 100644 --- a/tests/composition/analysis-sessions/binarySession.test.ts +++ b/tests/composition/analysis-sessions/binarySession.test.ts @@ -528,7 +528,6 @@ it("keeps an externally mutated session unbound until cleanup is retried", async ); expect(closeAttempts).toBe(1); - expect(mutation.ok).toBe(false); if (mutation.ok) throw new Error("Expected cleanup failure"); expect(mutation.error).toBeInstanceOf(ProviderCleanupError); expect(mutation.error.cleanupIncomplete).toBe(true); diff --git a/tests/composition/analysis-sessions/managedApplicationGraph.test.ts b/tests/composition/analysis-sessions/managedApplicationGraph.test.ts index 2bb30e5b7f..a6b30a5d07 100644 --- a/tests/composition/analysis-sessions/managedApplicationGraph.test.ts +++ b/tests/composition/analysis-sessions/managedApplicationGraph.test.ts @@ -311,7 +311,6 @@ describe("managed application graph coverage", () => { const rejected = projectManagedApplicationGraphEvidence({ managed_members: mismatched, }); - expect(rejected.ok).toBe(false); if (rejected.ok) throw new Error("mismatched managed Evidence accepted"); expect(JSON.stringify(rejected.error)).toContain( `Managed Evidence inspect_managed_members (${mismatched.evidence_id}) subject SHA-256 ${binary.sha256} does not match normalized artifact SHA-256 ${"b".repeat(64)}`, @@ -530,7 +529,6 @@ describe("managed application graph module identity consistency", () => { managed_members: memberEvidence, managed_native_boundaries: conflictingBoundaries, }); - expect(projected.ok).toBe(false); if (projected.ok) throw new Error("conflicting MVIDs were accepted"); expect(JSON.stringify(projected.error)).toContain( "conflicting known module MVIDs or token scopes", diff --git a/tests/composition/reverseEngineeringCommandPort.test.ts b/tests/composition/reverseEngineeringCommandPort.test.ts index bd2d21dfc3..f1b574a612 100644 --- a/tests/composition/reverseEngineeringCommandPort.test.ts +++ b/tests/composition/reverseEngineeringCommandPort.test.ts @@ -144,7 +144,6 @@ it("projects missing and non-file objdump targets with actionable path reasons", path, operation: "symbols", }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected target validation failure"); const projection = projectAnalysisError(result.error); expect(analysisErrorProjectionSchema.safeParse(projection).success).toBe( @@ -215,7 +214,6 @@ it("keeps target preflight I/O failures out of invalid-input classification", as path, operation: "symbols", }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected target preflight I/O failure"); expect(result.error).toMatchObject({ _tag: "ProviderAdapterError", @@ -282,7 +280,6 @@ it.each([ path, operation: "symbols", }); - expect(result.ok).toBe(false); if (result.ok) throw new Error(`Expected ${code} target path failure`); expect(result.error).toMatchObject({ _tag: "AnalysisInputError", diff --git a/tests/composition/reverseEngineeringUnknownFailures.test.ts b/tests/composition/reverseEngineeringUnknownFailures.test.ts index 8d47a4e774..f6db780be1 100644 --- a/tests/composition/reverseEngineeringUnknownFailures.test.ts +++ b/tests/composition/reverseEngineeringUnknownFailures.test.ts @@ -48,7 +48,6 @@ it.each([ path, operation: "symbols", }); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected injected boundary rejection"); expect(result.error.cause).toBe(cause); const projected = projectAnalysisError(result.error); diff --git a/tests/conformance/providers/managed/managedNativeVerification.test.ts b/tests/conformance/providers/managed/managedNativeVerification.test.ts index e86a3a4318..357ff8fdea 100644 --- a/tests/conformance/providers/managed/managedNativeVerification.test.ts +++ b/tests/conformance/providers/managed/managedNativeVerification.test.ts @@ -13,10 +13,7 @@ import { inspectManagedNativeBoundariesBytes } from "../../../../src/dotnet/Mana import { executeManagedNativeBoundaries } from "../../../../src/application/managed/ManagedNativeVerificationService.js"; import { MANAGED_NATIVE_VERIFICATION_EXAMPLE } from "../../../../src/contracts/managed/managedWorkflowExamples.js"; import { createEvidence } from "../../../../src/domain/evidence.js"; -import { - managedNativeVerificationInputSchema, - managedNativeVerificationResultSchema, -} from "../../../../src/domain/managed/managedNativeVerificationSchemas.js"; +import { managedNativeVerificationResultSchema } from "../../../../src/domain/managed/managedNativeVerificationSchemas.js"; import { managedNativeBoundaryInspectionSchema } from "../../../../src/domain/managed/managedArtifact.js"; import { inspectMachoSchema } from "../../../../src/domain/native/nativeInspection.js"; import { functionDossierSchema } from "../../../../src/domain/native/functionDossier.js"; @@ -33,10 +30,7 @@ const readFixtureSource = (input: unknown) => { return source.value; }; -const exampleInput = () => - managedNativeVerificationInputSchema.parse( - MANAGED_NATIVE_VERIFICATION_EXAMPLE, - ); +const exampleInput = () => structuredClone(MANAGED_NATIVE_VERIFICATION_EXAMPLE); const nativeEvidenceWithExports = ( names: readonly string[], @@ -495,7 +489,6 @@ it("matches ELF module names case-sensitively and leaves unknown platform equiva nativeFunctionEvidence("/examples/libCaseProbe.so", "elf"), ], }); - expect(workflow.ok).toBe(true); if (!workflow.ok) throw workflow.error; expect(workflow.value.evidence.normalized_result).toMatchObject({ summary: { contradicted: 1, verified: 0 }, @@ -687,7 +680,6 @@ it("retains a decorated module match when another decorated candidate has unknow managed_boundaries: managed, native_observations: observations, }); - expect(result.ok).toBe(true); if (!result.ok) throw result.error; const output = managedNativeVerificationResultSchema.parse( result.value.evidence.normalized_result, diff --git a/tests/fixtures/captureDecoderLimits.ts b/tests/fixtures/captureDecoderLimits.ts new file mode 100644 index 0000000000..fe47f96d0f --- /dev/null +++ b/tests/fixtures/captureDecoderLimits.ts @@ -0,0 +1,10 @@ +import { + captureDecoderProcessMemoryLimitBytes, + NODE_CAPTURE_HEAP_LIMITS, +} from "../../src/browser/history/CaptureRelease.js"; + +/** Default Job Object limit used by capture decoder fixtures. */ +export const NODE_CAPTURE_PROCESS_MEMORY_LIMIT_BYTES = + captureDecoderProcessMemoryLimitBytes( + NODE_CAPTURE_HEAP_LIMITS.oldGenerationMiB, + ); diff --git a/tests/process-global/binaryTargetAdmissionCancellation.test.ts b/tests/process-global/binaryTargetAdmissionCancellation.test.ts index 898afbeea2..e7d01def1d 100644 --- a/tests/process-global/binaryTargetAdmissionCancellation.test.ts +++ b/tests/process-global/binaryTargetAdmissionCancellation.test.ts @@ -112,7 +112,6 @@ it.each([ architecture: "x86", entryPoint: "0x1000", }); - expect(resolved.ok).toBe(false); if (resolved.ok) throw new Error("cancelled target was admitted"); expect(projectAnalysisError(resolved.error)).toMatchObject({ code: "cancelled", diff --git a/tests/process-global/shortFileReads.test.ts b/tests/process-global/shortFileReads.test.ts index 957c1bd46c..94f0d6d212 100644 --- a/tests/process-global/shortFileReads.test.ts +++ b/tests/process-global/shortFileReads.test.ts @@ -184,7 +184,6 @@ it("preserves a native plist probe read denial over a simultaneous abort", async { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected native plist read denial"); expect(result.error).not.toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(physical); @@ -215,7 +214,6 @@ it.each([false, true])( { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected plist probe cancellation"); const primary = closeFails ? result.error.cleanupPrimary : result.error; expect(primary).toBeInstanceOf(AnalysisCancelledError); @@ -400,7 +398,6 @@ it("preserves cancellation during continued short reads and releases the descrip { path }, { signal: controller.signal }, ); - expect(result.ok).toBe(false); if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cause).toBe(reason); diff --git a/tests/support/javascriptSemanticGraphFixture.ts b/tests/support/javascriptSemanticGraphFixture.ts index 526d198bb0..d80cb7e261 100644 --- a/tests/support/javascriptSemanticGraphFixture.ts +++ b/tests/support/javascriptSemanticGraphFixture.ts @@ -5,6 +5,7 @@ import { JAVASCRIPT_SEMANTIC_RELATION_FAMILIES, type JavaScriptSemanticGraphInput, type JavaScriptSemanticGraphNode, + type JavaScriptSemanticEvidenceReference, } from "../../src/domain/javascript/javascriptSemanticGraphSchemas.js"; import { createJavaScriptSemanticFingerprint, @@ -250,3 +251,17 @@ export const semanticFixtureGraph = ( withUnknown = false, ): JavaScriptSemanticGraph => createJavaScriptSemanticGraph(semanticFixtureInput(withUnknown)); + +/** Resolve one fact's compact provenance without changing its stored shape. */ +export const resolveJavaScriptSemanticEvidence = ( + graph: Pick, + reference: JavaScriptSemanticEvidenceReference, +): ApplicationGraphEvidence => { + const context = graph.evidence_contexts.find( + ({ context_id }) => context_id === reference.context_id, + ); + if (context === undefined) + throw new TypeError("Semantic evidence reference names an absent context"); + const { context_id: _contextId, ...evidenceContext } = context; + return { ...evidenceContext, location: reference.location }; +};