Skip to content

Plan C Phase 7: mock server v3 broadcast event validation#95

Draft
krukow wants to merge 1 commit intoplan-c/codegen-pipelinefrom
plan-c/mock-v3
Draft

Plan C Phase 7: mock server v3 broadcast event validation#95
krukow wants to merge 1 commit intoplan-c/codegen-pipelinefrom
plan-c/mock-v3

Conversation

@krukow
Copy link
Copy Markdown
Collaborator

@krukow krukow commented Apr 28, 2026

Plan C Phase 7 — mock server v3 broadcast event coverage

Stacks on #93 (codegen pipeline). Independent of #94 (instrument dedup).

What

Adds typo-protection at the test/mock boundary. mock/send-session-event! now validates the event-type against the SDK's canonical public event-types registry; injecting an unknown type throws with a helpful message instead of silently producing a notification the client ignores.

A dedicated mock/send-v3-broadcast-event! helper restricts injection to the five protocol v3 broadcast events (external_tool.requested, permission.requested, command.execute, elicitation.requested, capabilities.changed) — RPC-replacement events the SDK intercepts in client/handle-v3-broadcast-event!. A namespace-load-time assertion catches drift in the hand-curated set.

The four v3 integration tests (13 call sites) have migrated to the dedicated helper to make protocol v3 intent explicit. Negative tests can still bypass validation via send-notification!.

Why

Previously the mock accepted any string as event-type. A typo like "session.startt" produced a silently-ignored notification on the client side, and the test failed with a confusing "expected event never arrived" timeout. With Plan C giving us a canonical event registry, validating at the injection point is a free win.

Design notes (from rubber-duck review)

The first attempt validated against the schema-derived set (event-specs/event-types, 38 events). That was too strict — the SDK's public event-types set is hand-curated and includes 74 events, including protocol-level events like permission.requested and mcp.oauth_required that aren't in the upstream session-events schema. The rubber-duck flagged this and we switched to the SDK registry as the source of truth.

We deliberately do NOT assert that event-specs/event-types ⊆ known-event-types: there is real drift (e.g. session.import_legacy is in the upstream schema but not yet in the SDK's curated set). That drift is a known issue tracked separately by the codegen pipeline and out of scope here.

Verification

bb test — 200 tests / 668 assertions pass.

Closes nothing (Plan C tracking issue is internal).

Adds typo-protection at the test/mock boundary so that injecting an
unknown event-type fails fast with a helpful message instead of silently
emitting an unrecognised notification (the kind of bug that previously
produced confusing "expected event never arrived" test failures).

* `mock/send-session-event!` now validates the event-type against the
  SDK's canonical public `event-types` registry
  (`github.copilot-sdk/event-types`). Any event the SDK recognises can
  still be injected.
* New `mock/send-v3-broadcast-event!` helper restricts injection to the
  five protocol v3 broadcast events (`external_tool.requested`,
  `permission.requested`, `command.execute`, `elicitation.requested`,
  `capabilities.changed`). A subset assertion at namespace-load time
  guards against drift in the hand-curated set.
* Migrated the four v3 integration tests (13 call sites) from
  `send-session-event!` to `send-v3-broadcast-event!` to make protocol
  v3 intent explicit.
* Negative tests that need to inject deliberately-unknown event types
  can use `send-notification!` to bypass validation (documented in the
  helper's docstring).

200 tests / 668 assertions still pass on `bb test`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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