Skip to content

refactor(protocol): harden simulation wire contract - #42628

Merged
kitlangton merged 3 commits into
v2from
simulation-protocol
Aug 15, 2026
Merged

refactor(protocol): harden simulation wire contract#42628
kitlangton merged 3 commits into
v2from
simulation-protocol

Conversation

@kitlangton

@kitlangton kitlangton commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What

Harden the public @opencode-ai/protocol/simulation contract before standalone Drive deletes its copied schema.

The canonical module now exposes typed backend notifications, models JSON-RPC responses as an exact success/error union, and preserves the existing protocol-v1 request, capability, and RPC declarations explicitly.

This advances #42136. After this lands in an OpenCode next release, Drive can pin that Protocol version and remove its 629-line copy.

How

  • packages/protocol/src/simulation.ts
    • Models JSON-RPC responses with Schema.Union(..., { mode: "oneOf" }) and opposite Schema.Never fields, making success/error exclusivity hold at runtime and in TypeScript.
    • Exposes Backend.Notification and decoders for llm.request, tool.invocation, and tool.cancel.
    • Requires handshake capability responses to contain unique entries.
    • Keeps the explicit request unions and Effect RPC groups rather than introducing a generic operation framework.
  • packages/simulation/test/protocol.test.ts
    • Covers typed notification decoding, finish-reason normalization, and JSON-RPC response exclusivity.
    • Includes compile-time checks for missing and conflicting response outcomes.
  • packages/simulation/test/simulated-provider.test.ts
    • Exercises an omitted finish reason through the real websocket server.

Scope

This PR does not migrate opencode-drive; that follows the Protocol publication gate.

This PR does not change simulation activation. The typed launch profile and unified activation path remain separate follow-up work.

Testing

  • bun typecheck in packages/protocol
  • bun run build in packages/protocol
  • bun typecheck in packages/simulation
  • bun run test in packages/simulation (42 tests)
  • bun run lint packages/protocol/src/simulation.ts packages/simulation/test/protocol.test.ts
  • Repository-wide push typecheck across 33 packages

Flow

flowchart LR
  P[Protocol simulation contract] --> O[OpenCode simulation server]
  P -. published next version .-> D[Standalone Drive]
  D -. deletes copied schema .-> P
Loading

@kitlangton kitlangton changed the title refactor(protocol): derive simulation wire contracts refactor(protocol): harden simulation wire contract Aug 14, 2026
@kitlangton
kitlangton force-pushed the simulation-protocol branch from 6a9c554 to 39171b2 Compare August 14, 2026 19:59
@kitlangton
kitlangton merged commit 7484e32 into v2 Aug 15, 2026
8 checks passed
@kitlangton
kitlangton deleted the simulation-protocol branch August 15, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant