Skip to content

feat(load): --load-subscribe notification fan-out load - #2927

Merged
cliffhall merged 4 commits into
v2/mainfrom
v2/feat/2913-load-fanout
Nov 5, 2026
Merged

cliffhall merged 4 commits into
v2/mainfrom
v2/feat/2913-load-fanout

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2913

--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.

npm run local:gate is green.

🤖 Generated with Claude Code

@cliffhall cliffhall added the v2 Issues and PRs for v2 label Nov 5, 2026
@cliffhall
cliffhall requested a balanced review from Copilot November 5, 2026 17:54

Copilot AI 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.

🟡 Changes recommended

Retaining every receipt and successful trigger timestamp for the full run causes unbounded memory growth that can exhaust memory during sustained load.

6 open issues
What changed in this PR

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.

Review effort: Balanced

Comment thread core/cli/handlers/load-fanout.ts Resolved
Comment thread core/cli/handlers/load-fanout.ts Resolved
Comment thread core/cli/handlers/load-fanout.ts Resolved
Comment thread core/cli/handlers/load-fanout.ts Resolved
Comment thread core/cli/handlers/load-fanout.ts Resolved
Comment thread core/cli/handlers/load-fanout.ts Resolved
…dates; name the stop

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1, all six findings fixed in 6e1a10f:

  • Bounded memory (incremental FanoutTally).
  • Teardown unsubscribe runs with no ambient abort signal.
  • Receipts that predate their trigger are counted as unexpected.
  • Passive updates are frozen when the window ends.
  • An interrupt during settle is reported (exit 130).
  • The passive stop reason is preserved.

Requesting round 2.

Copilot AI 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.

Comment thread core/cli/handlers/load-fanout.ts Resolved
Comment on lines +295 to +296
if (sample.outcome === "ok") {
tally.addTrigger(clock.now() - sample.latencyMs);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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.

Comment thread core/cli/handlers/load-fanout.ts Resolved
…; refuse open loop

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 2, fixed in 7cb8a55:

  • Trigger starts are now bounded independently of a silent subscriber.
  • An evicted passive update is never timed as 0 ms.
  • --load-open-loop is refused with --load-subscribe.

The microsecond reconstruction offset of the trigger start is declined, with the reason in its thread.

Requesting round 3.

Copilot AI 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.

🔵 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.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

Medium severity 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.

Medium severity 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.

2 resolved since last review

Review effort: Balanced

… an aborted signal

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

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.

Requesting round 4.

Copilot AI 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.

🟢 Approval recommended

No active review issues are identified for the notification fan-out load-testing changes.

1 open issue

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 4 was clean (approval recommended; the one open issue is the thread declined in round 2). The review loop is closed on this clean round.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--load: notification fan-out load (resources/subscribe across many sessions)

2 participants