test: harden protocol provider contracts - #44
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the protocol-provider boundary by making the normalized server-event contract explicit (a fixed vocabulary), validating provider declarations up-front, and running golden corpora/fixtures through the provider interface to ensure exact wire ↔ normalized-event behavior stays stable.
Changes:
- Introduces an exhaustive, immutable
OMP_SERVER_EVENT_KINDSvocabulary (andOmpServerFrameexcluding the client-onlypair.start) and threads it through protocol/client types. - Adds provider validation (immutability/duplicates/unknown kinds) and a runtime “fail closed” check when a provider returns an undeclared server event.
- Adds golden corpus + canonical fixture-driven tests to lock down outbound frames, normalized inbound events (object + JSON text), and invalid inputs.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/protocol/test/server-event.test.ts | Adds assertions that the shared server-event vocabulary is complete, unique, and frozen. |
| packages/protocol/src/server-event.ts | Defines OmpServerFrame and exports frozen OMP_SERVER_EVENT_KINDS derived from an exhaustive type-checked map. |
| packages/protocol/src/index.ts | Narrows decodeServerFrame’s return type to OmpServerFrame and re-exports server-event utilities. |
| packages/protocol/src/desktop-ipc.ts | Updates renderer frame types to use OmpServerFrame. |
| packages/client/test/protocol-provider.test.ts | Adds a regression test that the client becomes fatal if a provider emits an undeclared event. |
| packages/client/test/protocol-provider-registry.test.ts | Adds corpus-driven provider tests and registry validation tests for event-kind declarations. |
| packages/client/test/protocol-provider-corpus.ts | New helper to load/validate/run a versioned “golden corpus” against a provider. |
| packages/client/test/protocol-provider-corpus.test.ts | New tests for corpus schema validation and coverage enforcement. |
| packages/client/test/protocol-provider-conformance.ts | Extends conformance suite to require declared immutable server-event vocabulary and enforce membership. |
| packages/client/test/protocol-provider-canonical-fixtures.test.ts | New test that decodes upstream app-wire canonical fixtures and asserts vocabulary coverage. |
| packages/client/test/fixtures/protocol/README.md | Documents the purpose and maintenance rules for protocol corpora fixtures. |
| packages/client/test/fixtures/protocol/omp-app-v1-corpus.json | New pinned golden corpus for omp-app/1 outbound/inbound/invalid examples. |
| packages/client/src/projection.ts | Updates projection frame typing to use OmpServerFrame. |
| packages/client/src/omp-protocol-provider.ts | Extends provider contract with serverEventKinds. |
| packages/client/src/omp-protocol-provider-registry.ts | Adds provider validation (kinds non-empty, frozen, unique, known) before registry use. |
| packages/client/src/omp-client-runtime.ts | Routes inbound raw messages through provider-declaration validation (decodeProviderServerEvent). |
| packages/client/src/omp-client-frames.ts | Adds decodeProviderServerEvent guard and uses it before dispatch. |
| packages/client/src/omp-app-v1-protocol-provider.ts | Declares serverEventKinds for the pinned omp-app/1 provider. |
| docs/adr/009-protocol-provider-boundary.md | Updates ADR consequences to include golden corpora and runtime event-kind declaration/validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this changes
This strengthens the protocol middle layer without changing the upstream OMP wire format or adding automatic protocol negotiation.
How you verified it
Checklist