From e8ca68f6371e36677ed950488dd5c8274ae115d5 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 4 Dec 2026 09:33:38 +0800 Subject: [PATCH] test(mcp): share source publication router fixtures (#16526) --- .../mcp/sourcePublicationComposed.test.ts | 57 ++++++------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/tests/boundary/mcp/sourcePublicationComposed.test.ts b/tests/boundary/mcp/sourcePublicationComposed.test.ts index 21581b0a91c..2704dea90b0 100644 --- a/tests/boundary/mcp/sourcePublicationComposed.test.ts +++ b/tests/boundary/mcp/sourcePublicationComposed.test.ts @@ -17,11 +17,14 @@ import { compareApplicationVersionsEvidence } from "../../../src/application/jav import { createToolResultDelivery } from "../../../src/server/toolResult.js"; import { recoveryOmissionRemediation } from "../../../src/domain/analysisErrorProjection.js"; +const sourceOnlyRouter = () => + createTestProviderRouter(() => { + throw new Error("no provider needed"); + }); + it("preserves the source when an inline result with unknown retention exceeds delivery", async () => { const session = new BinarySession( - createTestProviderRouter(() => { - throw new Error("no provider needed"); - }), + sourceOnlyRouter(), new InvestigationRecords({ maximumRepresentationBytes: 0 }), ); const input = JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE; @@ -62,9 +65,7 @@ it("preserves the source when an inline result with unknown retention exceeds de await full.close(); const boundedSession = new BinarySession( - createTestProviderRouter(() => { - throw new Error("no provider needed"); - }), + sourceOnlyRouter(), new InvestigationRecords({ maximumRepresentationBytes: 0 }), ); const { client } = await createApplicationMcpHarness({ @@ -105,9 +106,7 @@ it("preserves both identities and distinct retention when neither payload fits t ); if (!completed.ok) throw completed.error; const session = new BinarySession( - createTestProviderRouter(() => { - throw new Error("no provider needed"); - }), + sourceOnlyRouter(), new InvestigationRecords({ maximumRepresentationBytes: 0 }), ); const { client } = await createApplicationMcpHarness({ @@ -162,12 +161,7 @@ it("does not infer ledger membership from an independently registered reader", a maximumRepresentationBytes: sizing.statistics().retainedRepresentationBytes, }); expect(records.recordEvidence(computed.value.evidence).ok).toBe(true); - const session = new BinarySession( - createTestProviderRouter(() => { - throw new Error("no provider needed"); - }), - records, - ); + const session = new BinarySession(sourceOnlyRouter(), records); const { client } = await createApplicationMcpHarness({ session }); const response = await client.callTool({ name: "compare_application_versions", @@ -200,9 +194,7 @@ it.each([ "returns completed $name with honest retention when source recording fails", async ({ name, input, kind }) => { const session = new BinarySession( - createTestProviderRouter(() => { - throw new Error("no provider needed"); - }), + sourceOnlyRouter(), new InvestigationRecords({ maximumRepresentationBytes: 0 }), ); const { client } = await createApplicationMcpHarness({ session }); @@ -233,12 +225,7 @@ it.each(["zero", "normal"] as const)( const records = new InvestigationRecords( mode === "zero" ? { maximumRepresentationBytes: 0 } : {}, ); - const session = new BinarySession( - createTestProviderRouter(() => { - throw new Error("no provider needed"); - }), - records, - ); + const session = new BinarySession(sourceOnlyRouter(), records); const { client } = await createApplicationMcpHarness({ session }); const input = { ...FUNCTION_COMPARISON_EXAMPLE }; const expected = compareFunctionEvidence(input); @@ -296,12 +283,7 @@ it("reports a preexisting primary when source admission fails", async () => { maximumRepresentationBytes: sizing.statistics().retainedRepresentationBytes, }); expect(records.recordEvidence(expected.value.evidence).ok).toBe(true); - const session = new BinarySession( - createTestProviderRouter(() => { - throw new Error("no provider needed"); - }), - records, - ); + const session = new BinarySession(sourceOnlyRouter(), records); const { client } = await createApplicationMcpHarness({ session }); const response = await client.callTool({ name: "compare_functions", @@ -341,9 +323,7 @@ it.each([ "returns the selected $name view when source publication is refused", async ({ name, input }) => { const session = new BinarySession( - createTestProviderRouter(() => { - throw new Error("no provider needed"); - }), + sourceOnlyRouter(), new InvestigationRecords({ maximumRepresentationBytes: 0 }), ); const { client } = await createApplicationMcpHarness({ session }); @@ -380,11 +360,10 @@ it.each([ ] as const)( "preserves the completed $name parent when a selected view cannot be retained", async ({ name, input }) => { - const router = () => - createTestProviderRouter(() => { - throw new Error("no provider needed"); - }); - const normal = new BinarySession(router(), new InvestigationRecords()); + const normal = new BinarySession( + sourceOnlyRouter(), + new InvestigationRecords(), + ); const normalHarness = await createApplicationMcpHarness({ session: normal, }); @@ -402,7 +381,7 @@ it.each([ expect(sizing.recordEvidence(source).ok).toBe(true); } const session = new BinarySession( - router(), + sourceOnlyRouter(), new InvestigationRecords({ maximumRepresentationBytes: sizing.statistics().retainedRepresentationBytes,