Skip to content

fix(events): send --metadata on events/stream and every request a subscription makes - #3063

Merged
cliffhall merged 2 commits into
v2/mainfrom
v2/fix/3062-events-stream-metadata
Nov 27, 2026
Merged

cliffhall merged 2 commits into
v2/mainfrom
v2/fix/3062-events-stream-metadata

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #3062

events/stream dropped --metadata from the stream request and from every reconnect. Copilot found it while reviewing the 2.17.0 milestone merge (#3061). The fix goes on v2/main and reaches the merge by re-merging, per the release skill, 2c.

Cause

run-method passed args.metadata only to resolveEventType, the events/list lookup. eventsStreamOutcome took only arguments and cursor. EventSubscriptionsState had no metadata in EventSubscribeOptions, so its runners called client.streamEvents (and pollEvents, subscribeEvents, unsubscribeEvents) without any, even though every one of those client methods accepts it.

Change

  • EventSubscribeOptions.metadata. The engine keeps it on the registry entry, off the snapshot the UI reads (the same treatment as the webhook secret). It sends it on every request the subscription makes: the first poll or stream, every reconnect, webhook subscribe and refresh, and the webhook unsubscribe. A resume that omits it keeps the previous run's metadata, and new metadata replaces it.
  • eventsStreamOutcome takes metadata, and run-method passes --metadata to it.
  • When there's no metadata, nothing changes on the wire: options carry no metadata key.

Verified

  • New tests. 4 in the engine (push stream plus reconnect, every poll, none when none is given, resume keeps or replaces) and 1 in webhook (subscribe, refresh, unsubscribe). 1 CLI test through runMethod against the Events fixture, with a spy on streamEvents. All 5 fail without the core/ change and pass with it.

  • End to end, with mcpdo @evp events/stream incident.created --metadata com.example/trace=abc through a proxy that logs params._meta, forcing a reconnect with inject_event_failure preset:=stall_stream:

    Build events/list events/stream, first and reconnect
    before (8f79314d, the 2.17.0 merge) "com.example/trace":"abc" missing on both
    this branch "com.example/trace":"abc" "com.example/trace":"abc" on both
  • npm run local:gate: green (4m56s). Web 10,987 tests, cli 1,230, with coverage unchanged.

🤖 Generated with Claude Code

…scription makes (#3062)

events/stream used --metadata only for the events/list lookup:
eventsStreamOutcome took no metadata, and EventSubscriptionsState had
nowhere to keep it, so the stream request and every reconnect went
without it. EventSubscribeOptions now takes metadata; the engine keeps
it on the entry (off the snapshot, like the webhook secret), carries it
across a resume that omits it, and passes it on every poll, stream,
reconnect, webhook subscribe/refresh and unsubscribe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Nov 27, 2026
@cliffhall
cliffhall requested a balanced review from Copilot November 27, 2026 08:43

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

Automatic re-listing omits retained subscription metadata, which can select the wrong event types or fail and incorrectly disable resubscription; metadata forwarding and termination-path test coverage are still needed.

1 open issue
What changed in this PR

This PR addresses #3062 by forwarding CLI --metadata into the shared event subscription engine, preserving it across reconnects and subscription lifecycle requests.

Changes:

  • Adds subscription metadata storage, retaining it on resume unless replaced.
  • Forwards metadata to stream, poll, webhook subscribe, refresh, and unsubscribe requests.
  • Adds engine and CLI regression tests for metadata propagation.
File Description
core/​mcp/​state/​eventSubscriptionsState.ts Stores metadata and forwards it to subscription requests.
core/​cli/​handlers/​run-method.ts Passes CLI metadata to the stream handler.
core/​cli/​handlers/​events.ts Carries stream metadata into subscription options.
clients/​web/​src/​test/​core/​mcp/​state/​eventSubscriptionsState.webhook.test.ts Tests metadata across the webhook lifecycle.
clients/​web/​src/​test/​core/​mcp/​state/​eventSubscriptionsState.test.ts Tests metadata on streams, reconnects, polls, and resumes.
clients/​cli/​__tests__/​events.test.ts Tests metadata forwarding through runMethod.

Review effort: Balanced

…tion (#3062)

Addresses review on #3063. After a contract-changing termination the
engine re-lists the event types to decide whether to offer a
resubscribe, and that listAllEvents call went without the subscription's
metadata. The default re-list now sends it, and an injected relist
receives it as its argument; the web and TUI hosts, which refresh a
shared list, keep ignoring it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall

Copy link
Copy Markdown
Member Author

Round 1 addressed in bc6490c:

  • Re-list after termination drops metadata (r4717304045): fixed. The default re-list sends the subscription's metadata, an injected relist receives it, and two new tests cover the termination path. The headline's "termination-path test coverage" is the same finding, and those two tests answer it.

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 remain for the subscription metadata propagation change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review loop closed after round 2: the round was clean (0 inline comments, nothing suppressed, approval recommended, round 1's finding marked resolved), so no further round was requested.

@cliffhall
cliffhall merged commit 2182535 into v2/main Nov 27, 2026
12 checks passed
@cliffhall
cliffhall deleted the v2/fix/3062-events-stream-metadata branch November 27, 2026 09:12
cliffhall added a commit that referenced this pull request Nov 27, 2026
Brings in #3063 (events/stream forwards --metadata, #3062).

Signed-off-by: cliffhall <cliff@futurescale.com>
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.

events/stream drops --metadata from the stream request and its reconnects

2 participants