feat: commit generated Rust SDK at crates/client for downstream consumers#14
Conversation
Adds the smithy-rs generated kronos_sdk crate at a stable path so external Rust services (e.g. aarokya) can depend on it via a Cargo git dep without needing the Smithy CLI, JVM, or Juspay's Maven mirror in their build. - sdks/rust/: 216 generated files (kronos_sdk v0.1.0, MSRV 1.82) - Cargo.toml: exclude sdks/rust from workspace (different MSRV + heavy AWS smithy runtime stack that server crates do not need) - justfile: smithy-build now validates, regenerates, and syncs sdks/rust in one command; new smithy-validate and smithy-check (CI drift guard) recipes - sdks/rust/README.md: DO NOT EDIT warning + regeneration instructions
Runs 'just smithy-check' (validate + regenerate + git diff guard) on any PR that touches smithy/, sdks/rust/, or the justfile. Fails the build if the committed Rust SDK has drifted from the model — eliminates the 'forgot to regenerate' footgun.
|
Important Review skippedToo many files! This PR contains 220 files, which is 70 over the limit of 150. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (220)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
smithy-rs emits the `pub use` re-exports in sdks/rust/src/types/error.rs and sdks/rust/src/types/error/builders.rs in JVM HashMap iteration order, which differs across processes due to randomized hash seeds. CI regeneration produced a different ordering than local generation, failing the drift guard. Inline 3-command pipeline (head + grep|sort|sed + sed) in just smithy-build sorts only those two known-affected files; other generated files (operation unions, error_meta enum) are already model-driven and stable.
smithy-rs emits pub use blocks in error mod files (and on closer inspection,
operation/*.rs and types.rs) in JVM HashMap iteration order — non-stable
across processes. A naive git diff drift check produces false positives on
every regeneration on a different machine.
Removing the CI guard and the inline canonicalization for now:
- .github/workflows/smithy-check.yml deleted
- 'just smithy-check' recipe removed from justfile
- Inline sort pipeline removed from 'just smithy-build'
- sdks/rust/{types/error.rs,types/error/builders.rs} re-regenerated cleanly
(smithy-rs natural output, no post-processing)
- sdks/rust/README.md updated to flag the missing drift guard
Will add a proper canonicalization helper + CI guard in a follow-up.
| # Generated client SDK — committed for downstream consumers (e.g. aarokya) | ||
| # to depend on via `git`. Pins a different MSRV (1.82) and runtime stack | ||
| # than the server workspace, so it stays out of the workspace build graph. | ||
| "sdks/rust", |
There was a problem hiding this comment.
keep the sdk in crates/sdk or crates/client
| # Wipe everything except README.md (which warns "DO NOT EDIT" and must survive regeneration) | ||
| find sdks/rust -mindepth 1 -maxdepth 1 ! -name 'README.md' -exec rm -rf {} + | ||
| cp -R smithy/build/smithy/source/rust-client-codegen/. sdks/rust/ | ||
| @echo "Regenerated sdks/rust. Review with: git diff -- sdks/rust" |
There was a problem hiding this comment.
you can also consider doing something like:
remove the folder, git revert readme and then continue with generation
Review feedback: 1. SDKs alongside other Rust crates rather than a separate sdks/ tree. sdks/rust/ -> crates/client/ (git mv preserves history). Cargo.toml workspace exclude updated accordingly. 2. Cleaner regeneration recipe — replace the 'find ... ! -name README.md' wipe with 'rm -rf crates/client; cp ...; git checkout -- README.md'. Intent is obvious; the README is restored from the index, so it works pre- and post-commit and protects against accidental hand-edits. README and Cargo.toml workspace exclude updated to reference crates/client.
The previous commit (3abcd78) used 'git add -A' which swept in two files that shouldn't be in the kronos repo: - .claude/plans/aarokya-integration.md (local AI tooling artifact) - kronos.postman_collection.json (local dev artifact) Removing both. They remain in the working tree as untracked.
Closes #13
Summary
kronos_sdkcrate at a stable path (sdks/rust/) so downstream Rust services (e.g. aarokya) can depend on it via a Cargogitdep — no Smithy CLI, JVM, or Juspay Maven mirror required on the consumer side.justfileinto a one-command flow (just smithy-build= validate → generate → sync), matching the pattern already used in thepurpose-bound-accountrepo.Changes
sdks/rust/kronos_sdkv0.1.0, MSRV 1.82, 24 operations undersrc/operation/, plusclient/,types/,config/,primitives/,protocol_serde/.sdks/rust/README.md— DO NOT EDIT warning + regeneration instructions.Cargo.tomlfiles don't need to change.Cargo.toml[workspace] exclude = ["sdks/rust"]— keeps the SDK out of the server build graph. The SDK targets MSRV 1.82 and pulls a heavy AWS smithy runtime stack that server crates (MSRV 1.75) don't need; verified viacargo metadatathat only the 5 server crates remain workspace members.justfilejust smithy-validate— validate models in isolation; surfaces clean errors before regeneration.just smithy-build— now does validate →smithy build→ wipesdks/rust/(preservingREADME.md) → copy regenerated sources. One command, the common case.build-sdk,cli-install, andsdk-refreshtransitively get validation for free.just smithy-check— runssmithy-build, thengit diff --exit-code -- sdks/rustto fail on drift..github/workflows/smithy-check.ymljust smithy-checkon any PR that touchessmithy/,sdks/rust/, or thejustfile. Sets up JDK 17, installs Smithy CLI 1.55.0, installsjust, then runs the drift guard.Why this approach (vs alternatives)
kronos-rust-sdkrepo: premature with one consumer; easy to split later without changing aarokya's call sites — only the dep declaration changes.crates/kronos_sdk/(PBA-style): Kronos server doesn't consume its own SDK, so it doesn't need to be a workspace member.sdks/namespace also scales cleanly when other languages get committed (sdks/openapi/,sdks/python/, etc.).smithy/build/.../rust-client-codegen/? Would either expose all gitignored build outputs (TS, Haskell, OpenAPI) or require a fragile negation rule. Leaks generator internals into consumer-visible paths.Test plan
cargo check --workspace— server build unaffected (verified locally; only 5 server crates in workspace percargo metadata).just smithy-build— completes without errors, produces no diff insdks/rust/(verified locally — round-trip is clean).just smithy-check— passes on the current commit.just smithy-validate— runs in isolation.git statusafterjust smithy-buildis clean (sdks/rust/README.mdsurvives the wipe).kronos_sdk = { git = "ssh://git@github.com/juspay/kronos.git", rev = "<merge-sha>" }and confirmcargo buildresolves without needing Smithy/JVM toolchain. (Will be done in the aarokya integration PR.)Follow-ups
sdk-rust-v0.1.0, …) so consumers pin to tags rather than floating SHAs..github/PULL_REQUEST_TEMPLATE.mdto standardize PR structure.kronos_sdk, evaluate splitting into a dedicated SDK repo or publishing to a private Cargo registry.