Repository navigation
fix(sdk-generator): rename channel message methods that collide with leave() - #114
Merged
Merged
Conversation
…leave() The Artifact channel declares a client-to-server 'leave' event. The TypeScript emitter turned it into 'async leave(payload)' next to the lifecycle 'async leave()', so tsc failed with TS2393. The Python emitter emitted a second 'async def leave', which silently replaced the lifecycle method. Message methods whose names equal a member the channel class defines now get a Message suffix (leaveMessage / leave_message). Contract-test and sample emitters share the same naming helpers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.
Review on ArchCode
Task: tsk_034jsXbpOVaZqQO9kGlka2 (blocks tsk_00P3MwVmlsfLC0KnJpssNu, thread-computer SDK release)
Problem
scripts/regenerate_sdk.shin archastro-js emits a TS SDK that failsnpm run buildwith TS2393 insrc/channels/api_artifact_channel.ts.x-channels) has a client-to-server message event namedleave.async leave(): Promise<void>.leaveevent asasync leave(payload)(tsChannelMessageMethodName= camelCase(event)).tscfails; CI builds before tests, so no SDK can release.async def leavesilently replaces the lifecycleleave(), sochannel.leave()would push aleaveevent instead of leaving.What changed
Message/_messagewhen the name equals a member the class defines itself.leave,channel,joinResponse,constructor. Result:leaveMessage(payload).leave,join,topic,join_response. Result:leave_message(payload).contract-tests/channel-emitter.ts,channel-emitter-python.ts) now call the same helpers instead of duplicating the naming.this.channel.push("leave", payload).leave()stays the public leave API; every other message/push name is identical.Scope
Generator only (
packages/sdk-generator). No generated output hand-edited, no spec change.Risk
Low. Only event names that collide with a class member change; in the current spec that is just Artifact
leave. Compatibility: no SDK ever shipped a workingleave(payload)(TS did not compile; Python's was shadowed), so nothing can depend on the old name.Testing
__tests__/backends/typescript.test.ts("does not emit a message method that collides with leave()") andpython.test.ts("does not let a leave event replace the lifecycle leave()").vitest run: 12 files / 428 tests pass.npm run lint,npm run build: clean.specs/platform-openapi.json):@archastro/sdk-generator@latestviascripts/regenerate_sdk.sh --local <this repo>, thentsc --noEmitinpackages/sdk: TS2393 atapi_artifact_channel.tslines 31 and 51 (reproduced).dist/index.js(--lang typescriptand--lang contract-tests-ts):tsc --noEmitexits clean; emittedasync leave()plusasync leaveMessage(payload).ci.ymlon PR vianpm test --workspaces. The generate-then-tsccheck has no automatic path in this repo (it needs the archastro-js checkout); archastro-js CI builds the regenerated SDK after release. Not proven here: Python end-to-end generation (unit test only); Swift/Go/Rust.Follow-ups
@archastro/sdk-generatorversion (release.yml), then regenerate archastro-js / archastro-python with it. Not done here.leave()and usesuniqueSwiftMemberNamesfor message names; likely the same collision. Go/Rust not checked.🤖 Generated with Claude Code