examples/rsc-agent-runtime: adopt the public agent-bundle/mcp-entry stdio lifecycle (RFC #50 Phase 2) - #57
Conversation
…cp-entry lifecycle in the self-built stdio entry (RFC #50 Phase 2) The demo's stdio MCP entry replaces its naive run().catch bootstrap (no console guard, no signals, no stdin-EOF, no bounded shutdown) with the framework's public lifecycle API: redirectConsoleToStderr installs the stdout guard before the server module and v1.30 SDK evaluate (both deferred via dynamic import, mirroring the generated shell), then runStdioServer owns SIGINT->130, SIGTERM->143, stdin-EOF->0, bounded shutdown, and heartbeat attribution over the demo's own SDK transport. The entry stays compiled by the demo's rsbuild at the stable dist/runtime/mcp/stdio.js path pinned by packaging and tests; the structural lifecycle types accept the v1.x SDK without migration and the import bundles into the entry (no lockfile change). The transport suite gains a lifecycle test (handshake-then-act exit codes plus heartbeat), the README ownership-boundary paragraph notes the entry consumes the framework lifecycle while remaining self-built, and the generated topology doc is regenerated (one line stale on main since #52).
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
Summary
Phase-2 executor task for RFC #50 (plan §1.4), scoped to
examples/rsc-agent-runtime— the "framework lifecycle without framework build" witness: the publicagent-bundle/mcp-entryAPI under a consumer-owned bundler and the v1.x MCP SDK.src/mcp/stdio.tsreplaces its naiverun().catchbootstrap (no console guard, no SIGINT/SIGTERM, no stdin-EOF, no bounded shutdown — the RFC §1.2 asymmetry) with the public lifecycle API:redirectConsoleToStderrinstalls the stdout guard before the server module and SDK evaluate (both deferred via dynamic import, mirroring the generated shell's deferral), thenrunStdioServerowns SIGINT→130, SIGTERM→143, stdin-EOF→0, transport-close→0, the 5 s bounded shutdown, and[rsc-agent-runtime]-attributed heartbeats over the demo's own v1.30StdioServerTransport.packages/agent-bundle/package.jsonships the./mcp-entryexport withredirectConsoleToStderr/runStdioServerunder exactly those names, and the option types are structural (LifecycleServer/LifecycleTransport). The v1.30 SDK'sMcpServerandStdioServerTransportsatisfy them with zero casts (roottscproves it). The generated shell was deliberately not used: it hard-imports the v2 SDK this demo doesn't depend on, and the entry must stay compiled by the demo's rsbuild at the stabledist/runtime/mcp/stdio.jspath pinned bypackaging/*/.mcp.jsonargs and the transport/host tests. The import bundles into the entry (rsc environment bundles dependencies);agent-bundlewas already a devDependency — nopnpm-lock.yamlchange.tests/mcp-transports.integration.test.tsgains one lifecycle test: raw JSON-RPC initialize handshake (proves handlers install before we act and that the guard handed stdout back for clean protocol frames), then stdin-EOF→exit 0, SIGINT→130, SIGTERM→143, plus the heartbeat activity line on stderr. All pre-existing assertions untouched.README.mdadds one sentence to the ownership-boundary paragraph noting the stdio entry consumes the framework lifecycle viaagent-bundle/mcp-entrywhile remaining self-built.package.jsonbuildscript byte-identical; nodocs-contract.test.tspins touched.docs/architecture/rsc-runtime-workbench.mdregenerated: one line (tests/public-api-packed.test.ts) was already stale onmainfrom feat(build): agent-bundle owns the package build — bin/lib, entry conventions, stdio entry shell, tools hatch, mcp run (RFC #50 Phase 1) #52; this example's edits contribute nothing else.Everything else in the example (rsbuild config, entry wiring,
package-hosts.mjs,packaging/, http entry, hook CLI) stays by design per the plan; the packaging/hook unification is the recorded Phase-3 candidate (plan Q9).Verification
pnpm --filter @agent-bundle/rsc-agent-runtime-demo check— 15 files, 176 tests: 170 pass, 6 documented platform skips, 0 failures (rsbuild build + package:hosts + full suite + example typecheck)pnpm check:runtime-topology— green after regenerationpnpm eval:spot— greenpnpm typecheck+pnpm lint— greenpackages/workbench/tests/runtime-playground.e2e.test.tsvia the integration config with prebuilt flags — green