feat(codegen): explicit activity-version pinning#172
Conversation
|
More detail, from AI: Prior art / referenceThis mirrors the existing version-capping pattern in the TypeScript SDK repo
Concrete references:
How the Rust approach differsOur Rust approach mirrors the same idea — an explicit |
There was a problem hiding this comment.
Pull request overview
Adds a configurable “activity-version pinning” mechanism to Rust SDK codegen so generated activity submission methods can be capped to explicitly approved ACTIVITY_TYPE_* versions (mirroring the TypeScript SDK’s version map) rather than always following the proto annotation’s latest value.
Changes:
- Introduces
codegen/activity_version_caps.jsonwith apinsmap (base activity family → exact versioned activity literal). - Updates codegen to resolve the proto-provided activity type through the pins map before looking up intent/result types in
proto/activities.json. - Adds helper functions and unit tests for version-suffix stripping and pin resolution/validation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
codegen/src/main.rs |
Loads caps config, resolves/pins activity types during codegen, and adds helper functions + tests. |
codegen/activity_version_caps.json |
Adds the pins configuration file (seeded empty for no-op behavior). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- split initial validate from resolve of activities
Summary
Adds an explicit activity-version pinning mechanism to Rust SDK codegen, mirroring the TypeScript SDK's
VERSIONED_ACTIVITY_TYPESmap.Problem
Today, proto sync can auto-bump generated activity submission methods to whatever
ACTIVITY_TYPE_*literal is present in the proto annotation, even if that activity version has not been released to production yet.Mechanism
codegen/activity_version_caps.jsonwith an explicitpinsmap.ACTIVITY_TYPE_SIGN_TRANSACTION.ACTIVITY_TYPE_*literals codegen should emit, e.g.ACTIVITY_TYPE_SIGN_TRANSACTION_V2._V<number>suffixes to derive the base family, checks for a pin, and overrides the emitted activity type before looking up intent/result types inproto/activities.json.activities.json, and pins that cross base activity families are rejected.No-op default
This PR seeds the config with empty pins, so it is mechanism-only and generated client output remains unchanged. The actual pins should be set in #171.
How to add a pin
Add an entry to
codegen/activity_version_caps.json:{ "pins": { "ACTIVITY_TYPE_SIGN_TRANSACTION": "ACTIVITY_TYPE_SIGN_TRANSACTION_V2" } }The target activity version must already exist in
proto/activities.jsonand must already be released in production.Ordering
This should merge before #171 so that PR can add/bump pins using this mechanism.
Verification
PATH="/workspace/.cargo/bin:$PATH" make generategit diff --stat -- client/src/generatedproduced no outputPATH="/workspace/.cargo/bin:$PATH" make lintPATH="/workspace/.cargo/bin:$PATH" make test