fix(pyodide): align bootstrap dispatcher with protocol envelope#197
fix(pyodide): align bootstrap dispatcher with protocol envelope#197
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe pull request replaces an old Python dispatch protocol with a new structured protocol-driven system using the 'tywrap/1' identifier. Messages now follow a standardized format with numeric id, protocol, method, and params fields. Support is added for four dispatch methods (call, instantiate, call_method, dispose_instance), and error handling is standardized with proper validation on both Python and TypeScript sides. Changes
Sequence DiagramsequenceDiagram
participant Client as TypeScript Client
participant Dispatcher as Python Dispatcher
participant Module as Python Module/Class
participant Store as Instance Store
Client->>Dispatcher: {id: 1, protocol: 'tywrap/1', method: 'call', params: {...}}
activate Dispatcher
Dispatcher->>Dispatcher: Validate message format
Dispatcher->>Dispatcher: Route by method
alt method = 'call'
Dispatcher->>Module: Dynamic import & call function
Module-->>Dispatcher: result
else method = 'instantiate'
Dispatcher->>Module: Dynamic import & instantiate class
Module-->>Dispatcher: instance
Dispatcher->>Store: Store instance by handle
else method = 'call_method'
Dispatcher->>Store: Fetch instance by handle
Store-->>Dispatcher: instance
Dispatcher->>Module: Invoke bound method
Module-->>Dispatcher: result
else method = 'dispose_instance'
Dispatcher->>Store: Remove instance by handle
Store-->>Dispatcher: disposal result
end
Dispatcher-->>Client: {id: 1, protocol: 'tywrap/1', result: {...}} | {id: 1, protocol: 'tywrap/1', error: {...}}
deactivate Dispatcher
Client->>Client: Validate response.id & protocol
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary\n- rewrite Pyodide bootstrap dispatcher to consume
protocol+method+params\n- return protocol-aligned envelopes with numeric ids and protocol echo\n- update runtime protocol examples/comments still using obsoletetypeshape\n- add transport-level regressions for legacy shape rejection and unknown-method errors\n\n## Validation\n- npx vitest --run test/transport.test.ts test/runtime_pyodide.test.ts