test: strengthen provider contracts and consolidate duplicate cases

This commit is contained in:
morluto committed 2026-11-10 16:02:45 -05:00
1 parent 6377a1831f
commit 93dc8d044d
10 files changed
+87 -178

No files matched your search

@@ -36,7 +36,7 @@ import {
isSourceEvidenceRetainable,
} from "./AnalysisSnapshotCache.js";
import { EvidenceLedger } from "../investigation/EvidenceLedger.js";
import { enhancedOutputSchemas } from "../../contracts/toolOutputSchemaGroups.js";
import { nativeCallGraphSchema } from "../../domain/native/nativeCallGraph.js";
it.each(["provider", "workflow"] as const)(
"owns nested %s execution data before returning control to callers",
@@ -1270,12 +1270,13 @@ it.each([
evidenceProfile: revisedProfile,
}),
).toBeUndefined();
if (operation === "get_call_graph")
if (operation === "get_call_graph") {
expect(nativeCallGraphSchema.safeParse(oldResult).success).toBe(false);
expect(
enhancedOutputSchemas.get_call_graph.safeParse({
normalized_result: oldResult,
}).success,
).toBe(false);
nativeCallGraphSchema.safeParse({ graph: oldResult, limitations: [] })
.success,
).toBe(true);
}
},
);
@@ -18,6 +18,8 @@ const identity: ProviderIdentity = {
it("retains both child close failures when a resource owner rejects", async () => {
const attempts: string[] = [];
const artifactCause = new Error("artifact close rejected");
const nativeCause = new Error("native close rejected");
const artifact: AnalysisClient = {
execute: async () => ({
ok: true,
@@ -25,7 +27,7 @@ it("retains both child close failures when a resource owner rejects", async () =
}),
close: async () => {
attempts.push("artifact");
throw new Error("artifact close rejected");
throw artifactCause;
},
};
const native: AnalysisClient = {
@@ -35,14 +37,20 @@ it("retains both child close failures when a resource owner rejects", async () =
}),
close: async () => {
attempts.push("native");
throw new Error("native close rejected");
throw nativeCause;
},
};
const closed = await combineBundleResourceClients(artifact, native).close();
expect(attempts.sort()).toEqual(["artifact", "native"]);
expect(closed.ok).toBe(false);
if (!closed.ok) expect(closed.error.cleanupIncomplete).toBe(true);
if (closed.ok) throw new Error("Expected both child close failures");
expect(closed.error.cleanupIncomplete).toBe(true);
expect(closed.error.cause).toBeInstanceOf(AggregateError);
expect((closed.error.cause as AggregateError).errors).toEqual([
expect.objectContaining({ cause: artifactCause }),
expect.objectContaining({ cause: nativeCause }),
]);
});
it("reports the first mixed child failure before awaiting the other owner and retries both", async () => {