Repository navigation
fix(verifiers): retain the Go fixture root until MCP ownership completes #8650
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
Open
kaoru0822-kitauji
wants to merge
5
commits into
main
Choose a base branch
from
fix/8555-go-verifier-mcp-ownership
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+935
−37
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c2f42f0
fix(verifiers): retain the Go fixture root until MCP ownership completes
kaoru0822-kitauji cdb8752
test(verifiers): select Go cleanup scenarios and paths through their …
kaoru0822-kitauji 678305e
fix(verifiers): keep the Go root while process lineage is unknown
kaoru0822-kitauji 5d9567f
Merge remote-tracking branch 'origin/main' into fix/8555-go-verifier-…
kaoru0822-kitauji 61aea43
Merge origin/main into fix/8555-go-verifier-mcp-ownership
kaoru0822-kitauji 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { ChildProcess } from "node:child_process"; | ||
|
|
||
| import { StdioClientTransport } from "@modelcontextprotocol/client/stdio"; | ||
|
|
||
| import { ProviderProcessSupervisor } from "../../dist/process/ProviderProcess.js"; | ||
| import { closeVerifierResources } from "./verifier-cleanup.mjs"; | ||
|
|
||
| const noChildHandle = () => | ||
| new Error( | ||
| "The MCP SDK stdio transport exposes no child handle, so its completion cannot be proven", | ||
| ); | ||
|
|
||
| /** | ||
| * SDK stdio transport that can prove its child finished. | ||
| * | ||
| * The SDK's `close()` can return right after sending its final SIGKILL, before | ||
| * the child is reaped, and its `pid` is cleared by then. `close()` itself keeps | ||
| * that contract and must not reject: the SDK calls it without awaiting after a | ||
| * failed handshake. Callers that release resources the child can use await | ||
| * `closeAndVerifyChild()` instead. | ||
| */ | ||
| export class VerifierStdioClientTransport extends StdioClientTransport { | ||
| #supervisor; | ||
| #handleMissing = false; | ||
| #outputClosed = false; | ||
|
|
||
| async start() { | ||
| const started = super.start(); | ||
| // The SDK assigns its child synchronously and exposes only that PID. | ||
| const child = Reflect.get(this, "_process"); | ||
| // A failed spawn rejects here, having acquired nothing to prove finished. | ||
| await started; | ||
| if (!(child instanceof ChildProcess)) { | ||
| this.#handleMissing = true; | ||
| throw noChildHandle(); | ||
| } | ||
| // An unread stderr would hold the child's pipe open past its exit. | ||
| this.stderr?.resume(); | ||
| child.once("close", () => { | ||
| this.#outputClosed = true; | ||
| }); | ||
| this.#supervisor = new ProviderProcessSupervisor( | ||
| { process: child, ownsProcessLifetime: true }, | ||
| { | ||
| captureStdout: false, | ||
| maxDiagnosticBytes: { stdout: 0, stderr: 0 }, | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Close through the SDK, then stop any surviving child and prove it finished. | ||
| * A rejection keeps the child owned; calling this again retries from its state. | ||
| */ | ||
| closeAndVerifyChild() { | ||
| return closeVerifierResources([ | ||
| () => this.close(), | ||
| () => this.#verifyChildFinished(), | ||
| ]); | ||
| } | ||
|
|
||
| async #verifyChildFinished() { | ||
| if (this.#handleMissing) throw noChildHandle(); | ||
| const supervisor = this.#supervisor; | ||
| if (supervisor === undefined) return; | ||
| const stopped = await supervisor.stop(); | ||
| const child = `MCP stdio child ${String(supervisor.launch.process.pid)}`; | ||
| if (stopped.status === "incomplete") | ||
| throw new Error( | ||
| `${child} completion could not be proven: ${stopped.reason}`, | ||
| ); | ||
| // Exit proves only this process. Its pipes stay open while anything that | ||
| // inherited them runs, including a reparented process no lineage walk finds. | ||
| if (!this.#outputClosed) | ||
| throw new Error( | ||
| `${child} exited, but its stdio pipes are still open, so a process that inherited them may still be running`, | ||
| ); | ||
| } | ||
| } |
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
Oops, something went wrong.
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.