Skip to content

fix(dev): bound MCP probe teardown and path redaction - #316

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
fix/review-batch5-probe
Sep 2, 2026
Merged

fix(dev): bound MCP probe teardown and path redaction#316
ScriptedAlchemy merged 1 commit into
mainfrom
fix/review-batch5-probe

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

  • bound MCP probe teardown waiting to 50 ms while the close promises continue through the stdio transport's TERM/KILL path
  • redact POSIX and Windows absolute paths after =, :, and , separators
  • add focused regressions and a patch changeset

Test plan

  • red proof: both new unit regressions failed without the production fix
  • pnpm exec rstest run packages/agent-bundle/tests/mcp-probe-service.test.ts --config rstest.unit.config.ts
  • AGENT_BUNDLE_INTEGRATION_MAX_WORKERS=1 AGENT_BUNDLE_TEST_TIME_SCALE=4 pnpm exec rstest run packages/agent-bundle/tests/mcp-probe-dev-server.test.ts --config rstest.integration.config.ts
  • AGENT_BUNDLE_INTEGRATION_MAX_WORKERS=1 AGENT_BUNDLE_TEST_TIME_SCALE=4 pnpm exec rstest run packages/agent-bundle/tests/host-discovery-dev-server.test.ts --config rstest.integration.config.ts
  • pnpm build
  • pnpm typecheck
  • pnpm lint
  • discovery browser e2e not run locally: host load reached 52 and all 47 GiB swap was consumed

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 81721de

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T22:21:29.506415Z 4cf4aaa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 2, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@316
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@316
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@316

commit: 4cf4aaa

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4cf4aaa3a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


const hasAbsolutePath = (value: string): boolean =>
/(?:file:|(?:^|[\s"'([{])\/[^\s,;{}()[\]<>"']+|(?:^|[\s"'([{])[A-Za-z]:[\\/]|\\\\)/u.test(value);
/(?:file:|(?:^|[\s"'([{=,:])\/[^\s,;{}()[\]<>"']+|(?:^|[\s"'([{=,:])[A-Za-z]:[\\/]|\\\\)/u.test(value);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid treating URL schemes as path separators

When instructions, tool metadata, server metadata, or an error contains a normal URL such as https://example.com/docs, allowing : as the prefix causes this regex to match ://example.com/docs; redactProbeText then replaces the entire field with [REDACTED] even though it contains no local path. This hides common MCP documentation and link guidance, so exclude URI scheme delimiters before interpreting a colon as a path separator.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #397 (merged as d25a9c6). redactProbeText no longer treats the :// of a URI scheme as a path separator, so https://… links survive, while userinfo (scheme://user:secret@host) is masked through the final @, non-network schemes (unix://, vscode://file/, postgres://…/…, file:) still fail closed, and URIs glued to a preceding identifier are handled. tests/mcp-probe-service.test.ts covers URLs beside real bundle paths plus the userinfo and local-URI cases.

timer.unref();
});
try {
await Promise.race([teardown, teardownWait]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep plugin-data cleanup behind transport teardown

When a stdio server uses the resolved plugin-data directory and its close takes longer than 50 ms, this race lets #execute return while that child still has the directory open, after which #run immediately removes it. On Windows, a server holding a database or another non-delete-shared file can make that rm reject, turning the intended timed-out report into the route's generic 502; on other platforms the directory can disappear while shutdown is still using it. The detached close path should retain responsibility for removing plugin data after teardown instead of allowing the outer cleanup to run at the 50 ms response boundary.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #397 (merged as d25a9c6). Plugin-data removal in mcp-probe-service.ts is now chained after the transport teardown settles (bounded by a 10 s cap, with one fenced retry when an early removal fails because the child still holds the directory), the timeout path reuses the single memoized close() rather than issuing a second one, a synchronously throwing close() no longer skips cleanup, and settle() / Workbench server.close() join in-flight probes and detached cleanups. Proven by the slow-teardown, settle, and dev-server tests in tests/mcp-probe-service.test.ts and tests/mcp-probe-dev-server.test.ts.

Keep timed-out probes responsive without cancelling transport termination, and fail closed on separator-prefixed absolute paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant