Repository navigation
fix(ci): validate artifact MCP replies against named schemas #6021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gensokyo-dev
merged 2 commits into
main
from
fix/artifact-mcp-output-validation-20261021
Oct 21, 2026
+447
−24
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
fix(ci): validate artifact MCP replies against named schemas
A fresh SDK client has no cached tools/list, so generic tool calls in artifact verification can skip their output schema. Bind actual advertised definitions before lifecycle and analysis calls; compile only the selected schema, reuse one discovery within a negotiated connection and invalidate across reconnects. Keep request options, all existing provider assertions and both cleanup owners. Remove the duplicated provenance definition index and raw artifact call paths. A real stdio boundary fault changes canonical_path from string to number: the unfixed helper accepts it, while the selected SDK schema rejects it. Preserve healthy, space/Unicode, missing-schema, ambiguous-catalog and connection reuse controls. No production provider authority or CLI/MCP contract change. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
- Loading branch information
commit 3e250f39486dbb39e64e59c4fa99b7b49949ed3f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
tests/boundary/process/artifactMcpVerifierOutput.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import { execFile } from "node:child_process"; | ||
| import { mkdir, writeFile } from "node:fs/promises"; | ||
| import { join } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import { promisify } from "node:util"; | ||
| import { expect, it } from "vitest"; | ||
| import { z } from "zod"; | ||
|
|
||
| import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; | ||
|
|
||
| const exec = promisify(execFile); | ||
| const observationSchema = z.strictObject({ | ||
| accepted: z.boolean(), | ||
| catalogRequests: z.number().int().nonnegative(), | ||
| corruptedReplies: z.number().int().nonnegative(), | ||
| toolCalls: z.number().int().nonnegative(), | ||
| error: z | ||
| .strictObject({ | ||
| name: z.string(), | ||
| message: z.string(), | ||
| code: z.union([z.number(), z.string()]).nullable(), | ||
| }) | ||
| .nullable(), | ||
| }); | ||
|
|
||
| async function probe(mode: string, name = "Fixture.app") { | ||
| const root = await createTestTempDirectory("rea-artifact-mcp-schema-"); | ||
| const target = join(root, name); | ||
| await mkdir(join(target, "Contents", "Resources"), { recursive: true }); | ||
| await writeFile( | ||
| join(target, "Contents", "Info.plist"), | ||
| '<?xml version="1.0"?><plist version="1.0"><dict><key>CFBundleIdentifier</key><string>dev.rea.schema-probe</string></dict></plist>', | ||
| ); | ||
| const { stdout } = await exec( | ||
| process.execPath, | ||
| [ | ||
| fileURLToPath( | ||
| new URL("../../fixtures/artifactMcpVerifierProbe.mjs", import.meta.url), | ||
| ), | ||
| mode, | ||
| target, | ||
| ], | ||
| // Retain cleanup time within the existing 30s test budget. | ||
| { timeout: 25_000 }, | ||
| ); | ||
| return observationSchema.parse(JSON.parse(stdout)); | ||
| } | ||
|
|
||
| it("validates the real resource admission reply against its advertised schema", async () => { | ||
| expect(await probe("healthy", "Fixture.app")).toEqual({ | ||
| accepted: true, | ||
| catalogRequests: 1, | ||
| corruptedReplies: 0, | ||
| toolCalls: 1, | ||
| error: null, | ||
| }); | ||
| }); | ||
|
|
||
| it.each(["Fixture.app", "Fixture with spaces 雨.app"])( | ||
| "rejects a corrupted canonical path in a real admission reply: %s", | ||
| async (name) => { | ||
| const result = await probe("corrupt", name); | ||
| expect(result.accepted).toBe(false); | ||
| expect(result.catalogRequests).toBe(1); | ||
| expect(result.corruptedReplies).toBe(1); | ||
| expect(result.error).toMatchObject({ | ||
| name: "ProtocolError", | ||
| code: -32602, | ||
| message: expect.stringMatching(/output schema.*canonical_path/u), | ||
| }); | ||
| }, | ||
| ); | ||
|
|
||
| it.each(["reuse", "concurrent"])( | ||
| "shares one schema discovery within one MCP connection: %s", | ||
| async (mode) => { | ||
| const result = await probe(mode); | ||
| expect(result.accepted).toBe(true); | ||
| expect(result.catalogRequests).toBe(1); | ||
| expect(result.toolCalls).toBe(mode === "reuse" ? 3 : 2); | ||
| }, | ||
| ); | ||
|
|
||
| it("binds the new advertised schema after reconnecting the same client", async () => { | ||
| const result = await probe("reconnect"); | ||
| expect(result.accepted).toBe(false); | ||
| expect(result.catalogRequests).toBe(2); | ||
| expect(result.toolCalls).toBe(2); | ||
| expect(result.error).toMatchObject({ | ||
| code: -32602, | ||
| message: expect.stringContaining("__rea_second_connection"), | ||
| }); | ||
| }); | ||
|
|
||
| it("rejects an omitted output schema before calling the advertised tool", async () => { | ||
| const result = await probe("missing-schema"); | ||
| expect(result.accepted).toBe(false); | ||
| expect(result.toolCalls).toBe(0); | ||
| expect(result.error?.message).toMatch(/omitted its output schema/u); | ||
| }); | ||
|
|
||
| it.each(["duplicate-first", "duplicate-last"])( | ||
| "rejects ambiguous named schemas independently of catalog order: %s", | ||
| async (mode) => { | ||
| const result = await probe(mode); | ||
| expect(result.accepted).toBe(false); | ||
| expect(result.toolCalls).toBe(0); | ||
| expect(result.error?.message).toMatch(/Duplicate MCP tool/u); | ||
| }, | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.