You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--load-subscribe <uri> adds notification fan-out load to --load in the one-shot CLI and in mcpdo tools/call --load. It opens --load-subscribers sessions, subscribes each to the resource, and measures how notifications/resources/updated reaches them: per-notification delivery latency, missed notifications per session, and the subscribe cost.
Design
Triggered mode (a tool name or --load-scenario): the ordinary engine run is the trigger, and each successful call is expected to update the resource once. Triggers run one at a time (--load-concurrency defaults to, and must be, 1), so a session's k-th notification is attributed to the k-th successful call, and its latency runs from that call's start. The trigger start times come from the engine's existing per-call samples (completion time minus latency), so the engine needed no new hooks.
Passive mode (no tool): nothing is called. The run listens for --load-duration, and latency runs from the first subscriber's receipt of each update.
After the run, subscribers get --load-subscribe-wait (default 2 s) to catch up. The summary gains fanout: { uri, mode, requested, subscribed, failed, connectMs, subscribeMs, errorMessages, updates, delivered, missed, sessionsMissed, unexpected, deliveryMs }, and the text summary gains a fan-out block.
Session failures: opening extra sessions (stored credentials only, HTTP/SSE only when there is more than one) and subscribing happen before the clock starts. A session that fails either step is counted and the run continues. If no session can subscribe, the run fails. A connection that is already subscribed (an mcpdo resources/subscribe stream) is listened on and left subscribed. Otherwise the primary is unsubscribed and the extras are closed when the run ends.
Refusals:--load-subscribe cannot be combined with --load-connections, --load-churn, --load-steps/--load-ramp or --load-warmup. --load-concurrency above 1 is refused. --load-subscribers/--load-subscribe-wait require --load-subscribe. A passive run with --load-requests is refused.
Code layout: the code lives in a new core/cli/handlers/load-fanout.ts, which depends on load-test.ts and not the reverse. Both front ends now enter through runLoadOrFanout. The fan-out shape (uri, subscribers, mode) is part of a --load-baseline comparison.
Test server:ServerConfig.onResourceSubscribe hands a test each subscribing session's context. Every HTTP session is its own server, so a fan-out test needs it to notify all of them.
The CLI and mcpdo READMEs and the mcpdo agent skill document the flags.
Tests
clients/cli/__tests__/load-fanout.test.ts covers option resolution and refusals, the matching and tally (tallyFanout), and runFanout over fake subscribers on the fake clock. That includes trigger attribution with a failed trigger, the settle wait, open and subscribe failures, no subscriber, an already-subscribed session, other resources' notifications, passive mode, and interrupts. It also covers the text summary, the baseline shape, and CLI HTTP end-to-end runs (triggered with 3 subscribers, and passive against a server emitting its own updates).
mcpdo: flag resolution (passive with no tool name), the daemon opener and stdio refusal, and a daemon HTTP end-to-end fan-out.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Retaining every receipt and successful trigger timestamp for the full run causes unbounded memory growth that can exhaust memory during sustained load.
Adds notification fan-out load testing to the one-shot CLI and mcpdo, extending shared load-testing support to measure resource-update delivery across subscribed sessions.
Changes:
Adds triggered and passive fan-out modes with delivery latency, missed-notification counts, setup costs, and subscription cleanup.
Wires flags into both clients and includes fan-out configuration in baseline compatibility checks.
Adds unit and HTTP end-to-end coverage, a test-server subscription hook, and usage documentation.
File
Description
test-servers/src/composable-test-server.ts
Exposes subscribing sessions to fan-out fixtures.
skills/mcpdo/SKILL.md
Documents fan-out commands and metrics.
core/cli/handlers/load-test.ts
Adds fan-out options, conflict checks, and shared helpers.
core/cli/handlers/load-format.ts
Adds the human-readable fan-out summary.
core/cli/handlers/load-fanout.ts
Implements subscription setup, measurement, tallying, and cleanup.
core/cli/handlers/load-baseline.ts
Checks fan-out configuration compatibility.
clients/mcpdo/src/daemon/server.ts
Routes fan-out runs and opens extra subscriber sessions.
clients/mcpdo/src/connection/mcp.ts
Registers fan-out command-line flags.
clients/mcpdo/src/connection/load-flags.ts
Resolves fan-out flags and permits passive runs.
clients/mcpdo/README.md
Documents flags and existing-subscription behavior.
clients/mcpdo/__tests__/load.test.ts
Covers flag resolution and HTTP fan-out.
clients/mcpdo/__tests__/daemon-load.test.ts
Covers session opening and stdio refusal.
clients/cli/src/cli.ts
Wires CLI flags, transport checks, and execution.
clients/cli/README.md
Explains modes, metrics, restrictions, and examples.
clients/cli/__tests__/load-fanout.test.ts
Tests tallying, lifecycle, formatting, baselines, and CLI integration.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Trigger history remains unbounded when a subscriber is silent, while timestamp handling can fabricate zero-latency measurements and misclassify valid notifications as missed.
The reason will be displayed to describe this comment to others. Learn more.
Partly fixed in 7cb8a55, partly declined. The open-loop case is real: a sample's latency then runs from the scheduled start, which would put the worker wait into every delivery latency. --load-subscribe now refuses --load-open-loop, which also fits its one-trigger-at-a-time model. The bookkeeping shift is declined. The reconstructed start is the engine's own done - latency plus the time between the engine's clock.now() and the sample callback, a few synchronous statements later, so microseconds at most. A notification can't cross the network inside that window, so it can't turn a valid receipt into an early one. Threading a separate dispatch timestamp through the engine would buy nothing measurable.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Active issues discard authentication failure causes needed for recovery and classification, and make already-aborted sessions wait the full load duration before returning.
Preserve authentication causes in aggregated subscription failures
core/cli/handlers/load-fanout.ts:285
When every subscription fails with a typed or structured 401, failure() keeps only the messages and this terminal error loses the original cause chains. The CLI's auth recovery and error classifier can no longer recognize those failures, so a rejected token produces a generic error instead of OAuth recovery or auth_required under --stored-auth-only. Preserve an original authentication failure as the terminal error's cause while keeping the summarized messages.
Skip the passive wait when the abort signal is already set
core/cli/handlers/load-fanout.ts:358
If the signal aborts during session setup, it is already aborted when the passive window starts. sleepUnlessAborted only listens for future abort events, so this call still waits the entire --load-duration before returning the interrupted summary. Skip the sleep when the signal is already aborted, and extend the existing pre-aborted passive test to assert that no duration wait occurs.
Copilot round 3. No inline comments; the two previously missed findings (no threads) are fixed in 85447c9:
Auth cause preserved: the primary always tries to subscribe, so when no session subscribed, its failure is the one to report. It is now rethrown as it was, so a 401 or an AuthRecoveryRequiredError still reaches the CLI's auth recovery and exit-code classifier. Test added that asserts identity.
Pre-aborted signal:sleepUnlessAborted in the engine now returns at once for a signal that is already aborted. An abort listener only hears future aborts, so a passive run interrupted during setup no longer waits out --load-duration. The pre-aborted test now asserts elapsedMs: 0.
The "1 open issue" in the headline is the thread I declined in round 2 (the reconstruction offset of the trigger start); my reply is there.
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
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.
Closes #2913
--load-subscribe <uri>adds notification fan-out load to--loadin the one-shot CLI and inmcpdo tools/call --load. It opens--load-subscriberssessions, subscribes each to the resource, and measures hownotifications/resources/updatedreaches them: per-notification delivery latency, missed notifications per session, and the subscribe cost.Design
--load-scenario): the ordinary engine run is the trigger, and each successful call is expected to update the resource once. Triggers run one at a time (--load-concurrencydefaults to, and must be,1), so a session's k-th notification is attributed to the k-th successful call, and its latency runs from that call's start. The trigger start times come from the engine's existing per-call samples (completion time minus latency), so the engine needed no new hooks.--load-duration, and latency runs from the first subscriber's receipt of each update.--load-subscribe-wait(default 2 s) to catch up. The summary gainsfanout: { uri, mode, requested, subscribed, failed, connectMs, subscribeMs, errorMessages, updates, delivered, missed, sessionsMissed, unexpected, deliveryMs }, and the text summary gains a fan-out block.resources/subscribestream) is listened on and left subscribed. Otherwise the primary is unsubscribed and the extras are closed when the run ends.--load-subscribecannot be combined with--load-connections,--load-churn,--load-steps/--load-rampor--load-warmup.--load-concurrencyabove 1 is refused.--load-subscribers/--load-subscribe-waitrequire--load-subscribe. A passive run with--load-requestsis refused.core/cli/handlers/load-fanout.ts, which depends onload-test.tsand not the reverse. Both front ends now enter throughrunLoadOrFanout. The fan-out shape (uri, subscribers, mode) is part of a--load-baselinecomparison.ServerConfig.onResourceSubscribehands a test each subscribing session's context. Every HTTP session is its own server, so a fan-out test needs it to notify all of them.The CLI and mcpdo READMEs and the mcpdo agent skill document the flags.
Tests
clients/cli/__tests__/load-fanout.test.tscovers option resolution and refusals, the matching and tally (tallyFanout), andrunFanoutover fake subscribers on the fake clock. That includes trigger attribution with a failed trigger, the settle wait, open and subscribe failures, no subscriber, an already-subscribed session, other resources' notifications, passive mode, and interrupts. It also covers the text summary, the baseline shape, and CLI HTTP end-to-end runs (triggered with 3 subscribers, and passive against a server emitting its own updates).npm run local:gateis green.🤖 Generated with Claude Code