Repository navigation
feat(cli): generate self-contained non-JS SDKs for seven languages - #393
Conversation
✅ Deploy Preview for lunorash ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for following the naming conventions! 🙏 |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe change adds OpenRPC-driven SDK generation for Go, Java, Kotlin, Python, Ruby, Rust, and Swift. It adds language-specific renderers, an ChangesSDK generation
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant generateSdk
participant quicktypeCore
participant SDKTarget
participant GeneratedSDK
CLI->>generateSdk: pass OpenRPC document and target
generateSdk->>quicktypeCore: generate language models
quicktypeCore-->>generateSdk: return model source
generateSdk->>SDKTarget: render models and namespaces
SDKTarget-->>CLI: return generated files
CLI->>GeneratedSDK: write SDK files
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
Thank you for confirming the Contributor License Agreement! 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/test.yml:
- Around line 384-386: Extend the Python CI validation around the “Run the
python conformance suite” step in .github/workflows/test.yml (lines 384-386)
with a generated-SDK integration fixture that invokes the CLI generator, imports
or executes the generated Python package, and validates generated methods.
Update .github/file-filters.yml (lines 109-115) to include packages/codegen/**
and packages/cli/** so generator and CLI changes trigger this validation.
In `@packages/cli/src/commands/sdk/handler.ts`:
- Around line 56-60: Update the no-methods branch in the SDK handler so it
retains the warning but does not return early; allow the empty document to
continue through renderPythonModels and emitPythonSdk, ensuring api.py,
models.py, and __init__.py are regenerated as an empty SDK package.
- Around line 72-75: Update the untypedResults calculation in the SDK handler to
use the emitter’s isTypedSchema predicate (or an equivalent shared codegen
predicate) instead of checking result.schema.type. Ensure schemas expressed
through anyOf, oneOf, enum, items, or $ref are counted as typed consistently
with emit-python-sdk.ts.
In `@packages/codegen/src/emit-python-sdk.ts`:
- Around line 95-100: Add pre-render collision detection for normalized
identifiers produced by toSnakeCase across namespace names, method names, and
quicktype model names. Track each generated identifier with its source
functionPath and reject collisions by reporting both conflicting functionPath
values, or apply a stable disambiguating suffix consistently before rendering.
- Line 135: Update isTypedSchema and the result-generation flow used by
renderCallMethod so every typed output shape has an explicit decoder contract,
including object, scalar, array, enum, union, and reference schemas. Generate
and import the decoder for each result rather than assuming quicktype provides a
class with from_dict, and ensure renderCallMethod invokes that decoder
consistently. Add or update fixtures covering all listed output shapes.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b022522e-87b1-4899-bf30-f235e735c4d4
⛔ Files ignored due to path filters (36)
api-snapshots/codegen.api.mdis excluded by none and included by noneexamples/auth-playground/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/auth-playground/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/blog/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/blog/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/chess/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/chess/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/expo/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/expo/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/feedback-board/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/feedback-board/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/kanban-board/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/kanban-board/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/notify-demo/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/notify-demo/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/offline-rejections/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/offline-rejections/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/payment-demo/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/payment-demo/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/realtime-cursors/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/realtime-cursors/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/tanstack-start/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/tanstack-start/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/team-chat/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/team-chat/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by noneexamples/todo-app/lunora/_generated/openapi.jsonis excluded by!**/_generated/**and included by noneexamples/todo-app/lunora/_generated/openapi.tsis excluded by!**/_generated/**and included by nonepackages/codegen/__tests__/emit-python-sdk.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/codegen/__tests__/fixtures/simple/expected/_generated/openapi.jsonis excluded by!**/_generated/**,!**/__tests__/**and included bypackages/**packages/codegen/__tests__/fixtures/simple/expected/_generated/openapi.tsis excluded by!**/_generated/**,!**/__tests__/**and included bypackages/**packages/codegen/__tests__/openapi.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/codegen/__tests__/openrpc.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**pnpm-lock.yamlis excluded by!**/pnpm-lock.yamland included by nonepnpm-workspace.yamlis excluded by none and included by nonesdks/python/lunora/client.pyis excluded by none and included by nonesdks/python/tests/test_client_rpc.pyis excluded by none and included by none
📒 Files selected for processing (10)
.github/file-filters.yml.github/workflows/test.ymlpackages/cli/src/cli.tspackages/cli/src/commands/sdk/handler.tspackages/cli/src/commands/sdk/index.tspackages/codegen/package.jsonpackages/codegen/src/emit-python-sdk.tspackages/codegen/src/index.tspackages/codegen/src/openapi.tspackages/codegen/src/openrpc.ts
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## alpha #393 +/- ##
==========================================
- Coverage 87.09% 87.05% -0.04%
==========================================
Files 1172 1197 +25
Lines 63383 64905 +1522
Branches 15447 16043 +596
==========================================
+ Hits 55202 56505 +1303
- Misses 7654 7860 +206
- Partials 527 540 +13
🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 25.21%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
ddd209e to
7843d11
Compare
There was a problem hiding this comment.
Actionable comments posted: 7
♻️ Duplicate comments (1)
packages/cli/src/commands/sdk/handler.ts (1)
56-60: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winRegenerate an empty SDK.
This return skips
generateSdk()and all output writes. If a prior SDK exists and all methods are removed, staleapi.py,models.py, and package files remain in the output directory. Keep the warning, but continue to generate the empty SDK.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/commands/sdk/handler.ts` around lines 56 - 60, Update the zero-method branch in the SDK handler to retain the warning but remove the early return, allowing generateSdk() and its output writes to run and replace stale SDK files with an empty SDK. Preserve the existing successful return behavior after generation.
🧹 Nitpick comments (1)
packages/codegen/src/sdk/index.ts (1)
19-22: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider typing
SDK_TARGETSso the lookup is provably partial.The CLI handler indexes
SDK_TARGETS[language]with an arbitrary--langstring and then compares the result toundefined(seepackages/cli/src/commands/sdk/handler.tsLines 45-50). With the currentReadonly<Record<string, SdkTarget>>type, that lookup is typed asSdkTargetunlessnoUncheckedIndexedAccessis enabled, so the guard reads as unreachable to the type checker and to lint rules such as@typescript-eslint/no-unnecessary-condition. Runtime behaviour is correct either way.♻️ Optional typing change
-const SDK_TARGETS: Readonly<Record<string, SdkTarget>> = { go: goTarget, python: pythonTarget }; +const SDK_TARGETS: Readonly<Partial<Record<string, SdkTarget>>> = { go: goTarget, python: pythonTarget };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/codegen/src/sdk/index.ts` around lines 19 - 22, Type SDK_TARGETS as a finite readonly mapping of its declared language keys to SdkTarget, rather than Readonly<Record<string, SdkTarget>>, so indexing it with arbitrary CLI input can produce undefined. Preserve SDK_LANGUAGES and the handler’s existing undefined guard for unsupported --lang values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/test.yml:
- Around line 432-441: Extend the generated SDK workflow after the build step to
execute language-specific tests for the generated outputs, while retaining the
existing compilation checks. Use the fixture transport and protocol fixtures to
invoke generated RPC methods in both the Python and Go matrix legs, and assert
the emitted frames match the expected method names and parameter shapes.
In `@packages/cli/src/commands/sdk/handler.ts`:
- Around line 28-31: Update the document parsing flow in the SDK handler around
parsed and the methods-array validation so invalid JSON and a null JSON root are
both caught and converted into LunoraError("BAD_REQUEST", ...) with the spec
path and useful parse/validation context; preserve the existing rejection for
documents without a methods array.
In `@packages/codegen/src/sdk/models.ts`:
- Around line 36-41: Update the schema input setup around JSONSchemaInput and
FetchingJSONSchemaStore to use a non-fetching schema store, ensuring OpenRPC
schemas with remote references fail closed rather than triggering network
access. Preserve the existing serialized source handling and sequential
schemaInput.addSource flow.
In `@packages/codegen/src/sdk/spec.ts`:
- Around line 332-343: Update the shared model-name predicate used by
withDeclaredModels and undeclaredModels to match complete identifiers rather
than raw substrings, using identifier-boundary matching around each predicted
name. Reuse this predicate in both declared and undeclared checks so names such
as MessagesListArgs do not match MessagesListArgsItem.
In `@packages/codegen/src/sdk/targets/go.ts`:
- Around line 53-64: Update assertGeneratable in
packages/codegen/src/sdk/spec.ts to register each query’s derived
Subscribe${memberBase} name in seenMethod and emit the existing rename hint when
it conflicts. No direct changes are required in
packages/codegen/src/sdk/targets/go.ts lines 53-64 or
packages/codegen/src/sdk/targets/python.ts lines 77-96; the shared validator fix
must prevent those duplicate rendered methods.
In `@packages/codegen/src/sdk/targets/python.ts`:
- Line 60: Update the Python import generation near the `returns` handling and
line 127 so `Any` is imported only when at least one method lacks a
`resultType`, using the same conditional gating pattern as the subscription
aliases. Keep `Optional` and other imports unchanged, and ensure generated code
still emits `Any` for untyped results.
- Around line 162-166: Convert python.ts from mixed exports to named exports by
exporting pythonTarget and memberName consistently; update the two import sites,
including the default import in sdk/index.ts, to use named imports. Keep the
public symbols and behavior unchanged, and only apply the same change to go.ts
if required to preserve target symmetry.
---
Duplicate comments:
In `@packages/cli/src/commands/sdk/handler.ts`:
- Around line 56-60: Update the zero-method branch in the SDK handler to retain
the warning but remove the early return, allowing generateSdk() and its output
writes to run and replace stale SDK files with an empty SDK. Preserve the
existing successful return behavior after generation.
---
Nitpick comments:
In `@packages/codegen/src/sdk/index.ts`:
- Around line 19-22: Type SDK_TARGETS as a finite readonly mapping of its
declared language keys to SdkTarget, rather than Readonly<Record<string,
SdkTarget>>, so indexing it with arbitrary CLI input can produce undefined.
Preserve SDK_LANGUAGES and the handler’s existing undefined guard for
unsupported --lang values.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 20b787f2-2534-41ec-8532-dfb16e56bacc
⛔ Files ignored due to path filters (15)
api-snapshots/codegen.api.mdis excluded by none and included by nonepackages/codegen/__tests__/sdk-python.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**packages/codegen/__tests__/sdk-targets.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**pnpm-lock.yamlis excluded by!**/pnpm-lock.yamland included by nonepnpm-workspace.yamlis excluded by none and included by nonesdks/go/go.modis excluded by none and included by nonesdks/go/lunora/client.gois excluded by none and included by nonesdks/go/lunora/conformance_test.gois excluded by none and included by nonesdks/go/lunora/key.gois excluded by none and included by nonesdks/go/lunora/key_test.gois excluded by none and included by nonesdks/go/lunora/nested_test.gois excluded by none and included by nonesdks/go/lunora/wire.gois excluded by none and included by nonesdks/go/lunora/wire_test.gois excluded by none and included by nonesdks/python/lunora/client.pyis excluded by none and included by nonesdks/python/tests/test_client_rpc.pyis excluded by none and included by none
📒 Files selected for processing (11)
.github/file-filters.yml.github/workflows/test.ymlpackages/cli/src/commands/sdk/handler.tspackages/cli/src/commands/sdk/index.tspackages/codegen/src/index.tspackages/codegen/src/sdk/index.tspackages/codegen/src/sdk/models.tspackages/codegen/src/sdk/spec.tspackages/codegen/src/sdk/target.tspackages/codegen/src/sdk/targets/go.tspackages/codegen/src/sdk/targets/python.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/file-filters.yml
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/codegen/src/sdk/targets/ruby.ts`:
- Around line 150-152: Convert rubyTarget in ruby.ts from a default export to a
named export, then update its import in sdk/index.ts accordingly. Apply the same
default-to-named export change to the target exports in go.ts and python.ts,
preserving their existing memberName exports and updating all affected imports.
- Around line 68-77: Update the Ruby SDK generation flow used by renderCall and
the subscription path so generated models provide the serializer helpers
required by typed arguments and results. Disable quicktype’s just-types option
for Ruby model generation, or add equivalent to_dynamic/from_dynamic! helpers at
the generated call sites; ensure both API calls and subscribe use the supported
serialization path without NoMethodError.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 069eb09b-65ab-4498-bea6-bd5569dde18a
⛔ Files ignored due to path filters (7)
api-snapshots/codegen.api.mdis excluded by none and included by nonesdks/ruby/lib/lunora.rbis excluded by none and included by nonesdks/ruby/lib/lunora/client.rbis excluded by none and included by nonesdks/ruby/lib/lunora/key.rbis excluded by none and included by nonesdks/ruby/lib/lunora/wire.rbis excluded by none and included by nonesdks/ruby/test/test_conformance.rbis excluded by none and included by nonesdks/ruby/test/test_key.rbis excluded by none and included by none
📒 Files selected for processing (7)
.github/workflows/test.ymlpackages/cli/src/commands/sdk/handler.tspackages/codegen/src/sdk/index.tspackages/codegen/src/sdk/target.tspackages/codegen/src/sdk/targets/go.tspackages/codegen/src/sdk/targets/python.tspackages/codegen/src/sdk/targets/ruby.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- packages/codegen/src/sdk/target.ts
- packages/cli/src/commands/sdk/handler.ts
- packages/codegen/src/sdk/targets/go.ts
- packages/codegen/src/sdk/targets/python.ts
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)
packages/codegen/src/sdk/index.ts (1)
18-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse named exports for SDK targets.
The Rust and Swift target modules mix default and named exports. Convert both target objects to named exports and update the registry imports.
packages/codegen/src/sdk/index.ts#L18-L19: ImportrustTargetandswiftTargetwith named imports.packages/codegen/src/sdk/targets/rust.ts#L167-L169: Replace the default export with a namedrustTargetexport.packages/codegen/src/sdk/targets/swift.ts#L176-L178: Replace the default export with a namedswiftTargetexport.As per coding guidelines, “Never mix a default export with named exports in the same file.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/codegen/src/sdk/index.ts` around lines 18 - 19, Use named exports consistently for the SDK targets: in packages/codegen/src/sdk/index.ts lines 18-19, change the Rust and Swift imports to named imports; in packages/codegen/src/sdk/targets/rust.ts lines 167-169, export the target as named rustTarget; and in packages/codegen/src/sdk/targets/swift.ts lines 176-178, export it as named swiftTarget.Source: Coding guidelines
.github/workflows/test.yml (1)
441-443: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winPin the Ruby CI dependencies.
gem install dry-struct dry-typesresolves mutable latest versions on every run. A gem release can change the conformance result without a repository change. Use a committedGemfile.lockor pin both versions with Bundler.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/test.yml around lines 441 - 443, Update the Ruby dependency installation step in the workflow to use reproducible dependency versions: either install through a committed Gemfile.lock with Bundler or pin explicit versions for both dry-struct and dry-types. Preserve the Ruby-only condition and ensure CI no longer resolves mutable latest releases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/codegen/src/sdk/targets/rust.ts`:
- Around line 92-96: Update renderCall to honor method.resultType: generate
typed Rust return signatures and decode the RPC response into the declared
result model when present, while preserving Result<WireValue, ClientError> and
raw response handling for untyped methods. Use the existing Models imports and
Rust conversion/decoding conventions rather than introducing a separate type
path.
- Around line 109-111: Update renderNamespaceStruct’s method rendering to handle
methods with verb "query" by generating a Rust subscribe_<function> method in
addition to the existing query call. Ensure the generated subscription API
exposes the returned subscription ID or unsubscribe handle through the SDK,
while preserving renderCall behavior for other methods.
In `@packages/codegen/src/sdk/targets/swift.ts`:
- Around line 20-71: Add borrowing, consuming, nonisolated, open, and
precedencegroup to SWIFT_KEYWORDS so memberName() escapes generated identifiers
matching these Swift declaration keywords with backticks.
- Around line 92-94: Update the generated JSONSerialization call in the Swift
output handling to pass the .fragmentsAllowed option, allowing top-level scalar
results to reach JSONDecoder while preserving the existing result decoding flow.
---
Nitpick comments:
In @.github/workflows/test.yml:
- Around line 441-443: Update the Ruby dependency installation step in the
workflow to use reproducible dependency versions: either install through a
committed Gemfile.lock with Bundler or pin explicit versions for both dry-struct
and dry-types. Preserve the Ruby-only condition and ensure CI no longer resolves
mutable latest releases.
In `@packages/codegen/src/sdk/index.ts`:
- Around line 18-19: Use named exports consistently for the SDK targets: in
packages/codegen/src/sdk/index.ts lines 18-19, change the Rust and Swift imports
to named imports; in packages/codegen/src/sdk/targets/rust.ts lines 167-169,
export the target as named rustTarget; and in
packages/codegen/src/sdk/targets/swift.ts lines 176-178, export it as named
swiftTarget.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d02df251-cd64-40c8-ba39-d069c5059eb4
⛔ Files ignored due to path filters (20)
packages/codegen/__tests__/sdk-targets.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**sdks/rust/.gitignoreis excluded by none and included by nonesdks/rust/Cargo.tomlis excluded by none and included by nonesdks/rust/generated_check/Cargo.tomlis excluded by none and included by nonesdks/rust/generated_check/src/api.rsis excluded by none and included by nonesdks/rust/generated_check/src/lib.rsis excluded by none and included by nonesdks/rust/generated_check/src/models.rsis excluded by none and included by nonesdks/rust/src/client.rsis excluded by none and included by nonesdks/rust/src/key.rsis excluded by none and included by nonesdks/rust/src/lib.rsis excluded by none and included by nonesdks/rust/src/wire.rsis excluded by none and included by nonesdks/rust/tests/conformance.rsis excluded by none and included by nonesdks/swift/.gitignoreis excluded by none and included by nonesdks/swift/Package.swiftis excluded by none and included by nonesdks/swift/Sources/GeneratedCheck/Api.swiftis excluded by none and included by nonesdks/swift/Sources/GeneratedCheck/Models.swiftis excluded by none and included by nonesdks/swift/Sources/Lunora/Client.swiftis excluded by none and included by nonesdks/swift/Sources/Lunora/Key.swiftis excluded by none and included by nonesdks/swift/Sources/Lunora/Wire.swiftis excluded by none and included by nonesdks/swift/Tests/LunoraTests/ConformanceTests.swiftis excluded by none and included by none
📒 Files selected for processing (4)
.github/workflows/test.ymlpackages/codegen/src/sdk/index.tspackages/codegen/src/sdk/targets/rust.tspackages/codegen/src/sdk/targets/swift.ts
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/test.yml (1)
505-510: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winRemove removed generated SDK files before validation.
lunora sdk generateonly writes generated files, while the workflow builds paths such assdks/rust/generated_check/src,sdks/java/generated_check/lunoraapi,sdks/kotlin/generated_check, andsdks/swift/Sources/GeneratedCheckthat include tracked files. If the regenerated fixture no longer emits some tracked output, the build can use stale files. Generate into a fresh check directory or delete generated SDK files before compiling, while preserving smoke fixtures likeGeneratedSmoke.javaor the Swift smoke files.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/test.yml around lines 505 - 510, Update the “Generate an SDK from the committed fixture” workflow step to ensure each SDK validation output directory is fresh before generation, removing stale generated files while preserving smoke fixtures such as GeneratedSmoke.java and the Swift smoke files. Keep the existing generation command and subsequent validation paths unchanged.
🧹 Nitpick comments (2)
packages/codegen/src/sdk/targets/java.ts (1)
187-189: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse named exports for JVM targets.
The Java and Kotlin target files mix a default export with
memberName. Export each target by name and update the registry imports.
packages/codegen/src/sdk/targets/java.ts#L187-L189: ExportjavaTargetas a named export.packages/codegen/src/sdk/targets/kotlin.ts#L138-L140: ExportkotlinTargetas a named export.packages/codegen/src/sdk/index.ts#L16-L17: Import both targets with named imports.As per coding guidelines, “Never mix a default export with named exports in the same file.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/codegen/src/sdk/targets/java.ts` around lines 187 - 189, Replace the default exports with named exports for javaTarget in packages/codegen/src/sdk/targets/java.ts and kotlinTarget in packages/codegen/src/sdk/targets/kotlin.ts, while preserving memberName as a named export. Update the target imports in packages/codegen/src/sdk/index.ts lines 16-17 to use named imports for both targets.Source: Coding guidelines
.github/workflows/test.yml (1)
478-480: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winPin the Ruby validation gems.
Line 480 resolves unpinned gem versions on every run. Pin compatible versions or use a committed
Gemfile.lockto prevent CI drift.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/test.yml around lines 478 - 480, Update the Ruby gem installation step in the matrix SDK workflow to use pinned, compatible versions of dry-struct and dry-types, or install them from a committed Gemfile.lock. Ensure repeated CI runs resolve the same dependency versions while preserving the existing Ruby-only condition.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/test.yml:
- Around line 408-413: Add a Kotlin smoke-test step to the workflow entry
identified by the “kotlin” runner and its buildGenerated command, using the
existing fake poster or fixture transport to exercise generated SDK calls. Run
the compiled smoke test after kotlinc completes, ensuring generated Kotlin
behavior is executed rather than only compiled.
- Around line 465-470: Update the “Install the Kotlin compiler” workflow step to
verify the downloaded /tmp/kotlin.zip using a reviewed SHA-256 checksum or
signature before invoking unzip; abort the step when verification fails, while
preserving the existing download and PATH setup.
In `@packages/codegen/src/sdk/targets/java.ts`:
- Around line 110-152: Escape all interpolated OpenRPC text before emitting
source: in packages/codegen/src/sdk/targets/java.ts lines 110-152, update
renderCall, renderSubscribe, and renderNamespaceClass to use Java-string
escaping for functionPath and Javadoc sanitization for method.summary and
namespace.name; in packages/codegen/src/sdk/targets/kotlin.ts lines 75-105,
apply the equivalent Kotlin-string escaping and KDoc sanitization. Add
regression coverage for comment terminators, quotes, backslashes, and line
terminators in both targets.
---
Outside diff comments:
In @.github/workflows/test.yml:
- Around line 505-510: Update the “Generate an SDK from the committed fixture”
workflow step to ensure each SDK validation output directory is fresh before
generation, removing stale generated files while preserving smoke fixtures such
as GeneratedSmoke.java and the Swift smoke files. Keep the existing generation
command and subsequent validation paths unchanged.
---
Nitpick comments:
In @.github/workflows/test.yml:
- Around line 478-480: Update the Ruby gem installation step in the matrix SDK
workflow to use pinned, compatible versions of dry-struct and dry-types, or
install them from a committed Gemfile.lock. Ensure repeated CI runs resolve the
same dependency versions while preserving the existing Ruby-only condition.
In `@packages/codegen/src/sdk/targets/java.ts`:
- Around line 187-189: Replace the default exports with named exports for
javaTarget in packages/codegen/src/sdk/targets/java.ts and kotlinTarget in
packages/codegen/src/sdk/targets/kotlin.ts, while preserving memberName as a
named export. Update the target imports in packages/codegen/src/sdk/index.ts
lines 16-17 to use named imports for both targets.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2124744a-21fb-49d4-9b97-8b8c4c4846ea
⛔ Files ignored due to path filters (29)
api-snapshots/codegen.api.mdis excluded by none and included by nonepackages/codegen/__tests__/sdk-targets.test.tsis excluded by!**/__tests__/**,!**/*.test.tsand included bypackages/**protocol/README.mdis excluded by none and included by noneprotocol/conformance-cases.jsonis excluded by none and included by nonesdks/README.mdis excluded by none and included by nonesdks/go/lunora/client.gois excluded by none and included by nonesdks/java/.gitignoreis excluded by none and included by nonesdks/java/build.shis excluded by none and included by nonesdks/java/generated_check/GeneratedSmoke.javais excluded by none and included by nonesdks/java/generated_check/lunoraapi/Api.javais excluded by none and included by nonesdks/java/src/dev/lunora/Client.javais excluded by none and included by nonesdks/java/src/dev/lunora/Json.javais excluded by none and included by nonesdks/java/src/dev/lunora/Key.javais excluded by none and included by nonesdks/java/src/dev/lunora/Wire.javais excluded by none and included by nonesdks/java/test/dev/lunora/ConformanceTest.javais excluded by none and included by nonesdks/kotlin/.gitignoreis excluded by none and included by nonesdks/kotlin/build.shis excluded by none and included by nonesdks/kotlin/generated_check/Api.ktis excluded by none and included by nonesdks/kotlin/src/Client.ktis excluded by none and included by nonesdks/kotlin/src/Json.ktis excluded by none and included by nonesdks/kotlin/src/Wire.ktis excluded by none and included by nonesdks/kotlin/test/ConformanceTest.ktis excluded by none and included by nonesdks/python/lunora/client.pyis excluded by none and included by nonesdks/python/lunora/wire.pyis excluded by none and included by nonesdks/python/tests/test_conformance.pyis excluded by none and included by nonesdks/python/tests/test_hardening.pyis excluded by none and included by nonesdks/ruby/lib/lunora/client.rbis excluded by none and included by nonesdks/rust/generated_check/src/api.rsis excluded by none and included by nonesdks/swift/Sources/Lunora/Client.swiftis excluded by none and included by none
📒 Files selected for processing (9)
.github/workflows/test.ymlpackages/cli/src/commands/sdk/handler.tspackages/cli/src/commands/sdk/index.tspackages/codegen/src/sdk/index.tspackages/codegen/src/sdk/models.tspackages/codegen/src/sdk/target.tspackages/codegen/src/sdk/targets/java.tspackages/codegen/src/sdk/targets/kotlin.tspackages/codegen/src/sdk/targets/rust.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- packages/codegen/src/sdk/target.ts
- packages/cli/src/commands/sdk/index.ts
- packages/codegen/src/sdk/models.ts
- packages/cli/src/commands/sdk/handler.ts
- packages/codegen/src/sdk/targets/rust.ts
Seven hand-written codecs, audited against each other and the TS reference.
**A nullable bigint or bytes generated a model that failed every call.**
`hasUnrepresentableWireType` walked `properties`/`items`/`additionalProperties`
but not `allOf`/`anyOf`/`oneOf` — and `.nullable()` renders as
`{anyOf:[inner,{type:"null"}]}`, which is the common spelling. The guard missed
it, emitted `Amount *int64`, and reported nothing. Verified before and after:
the same document now reports `wallet:credit` and emits no model.
**`withDeclaredModels` matched names by substring**, so `FooArgs` counted as
declared whenever `FooArgsResult` appeared. Not theoretical — quicktype renders
an array-of-object result as `<Name>Element`, so Python and Ruby emitted
`MessagesCountResult.from_dict(...)` against a class that never existed. Now
word-bounded, and the test that missed it was matching the same loose way.
**Go's `jsonString` corrupted any string containing the literal text `
`.**
It post-processed `encoding/json`'s output with a ReplaceAll, and a literal
backslash encodes as `\\` — so that six-character input produced `"\\u2028"`,
whose bytes contain the escape being searched for. The replace fired and emitted
invalid JSON. Replaced with a hand-rolled quoter that cannot have the bug, plus
a regression test.
**Kotlin interpolated `$` out of the wire path.** `$` is a legal JavaScript
identifier character, so an export named `$client` generated `"billing:$client"`
— which compiles, runs, and posts the client object's `toString()` as the
function path. Now escaped.
**Go's `ResendSubscriptions` raced the frame handler** (`-race` proves it): it
copied subscription pointers under the lock, then read `cursor`/`epoch` after
releasing it while `advance` wrote them. Now snapshotted inside the lock.
**Go silently encoded any no-exported-field struct to `{}`** — `time.Time` above
all, which is what a Go caller reaches for on a `v.date()` field. That is
precisely what the TS reference refuses; the reflective fallback had reopened it.
Now an error, with a message naming `Date{EpochMs:…}`.
**Java and Kotlin JSON parsers were unbounded.** `Wire.MAX_DEPTH` applies to the
decoded tree and never saw the payload, so a deep frame threw
`StackOverflowError` — an `Error`, which `handleFrame`'s `catch
(RuntimeException)` cannot catch, so it escaped onto the socket thread. Bounded
in the parser; verified a 200k-deep frame is now rejected and `handleFrame`
survives. Truncated `\u` escapes now raise the parser's own error type too.
**An explicitly-null error cause was dropped** by Go, breaking the round-trip
contract for `[…,{},null]`, because nil and "absent" were conflated. `Undefined`
is now the sole absent marker, with `NewError` so a struct literal cannot
accidentally claim a null cause.
Also: the `sdks` CI filter missed `packages/cli/src/commands/sdk/**` — the
command the job actually invokes — plus `shared/base64.ts` and
`shared/wire-key.ts`, both of which are wire changes every port must mirror. And
`.github/workflows/test.yml` was not prettier-formatted, which was failing CI.
`sdks/run-all.sh` runs all seven suites in parallel; they are independent
toolchains over read-only fixtures, so the set costs about the slowest compiler
rather than the sum — 24s wall against seven sequential builds.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
**Every generated Ruby call raised NoMethodError.** The models were rendered
with quicktype's `just-types`, which omits `to_dynamic`/`from_dynamic!` — the two
methods every generated call site uses to reach the wire. `ruby -c` parsed the
file happily, which is exactly how it shipped. Dropped the option, and the CI leg
now RUNS a generated call the way the Java leg does; both languages have now
produced a surface that passed its parse-or-compile gate and threw on first use.
**Ruby also sent `null` for every unset optional.** quicktype's `to_dynamic`
writes an absent field as an explicit null, while `v.optional(x)` parses
`undefined`-or-`x` and rejects null — so any call leaving an optional unset
failed validation server-side. The generated surface now drops nil at every depth
before handing args over, which is what the Python backend already emits.
**Java, Kotlin and Swift clients were not safe to share across threads**, which
is the one topology every consumer has: a socket reader on one thread,
application code subscribing on another. All three now hold a lock over the
subscription registry, the shape views and the id counters, build resend frames
under it (each reads a `cursor` the frame handler writes), and dispatch frames
and user callbacks after releasing it. Each suite gained a case that starts four
subscriber threads against a reader and asserts the resulting subscription count
— a lost `nextId++` silently forgets a live subscription, which is deterministic
where waiting for a hash map to corrupt is not. Verified it fails without the
lock. The Swift leg additionally runs under `--sanitize=thread`, which reports six
races on the unlocked build.
**A summary or function path could escape the syntax it was emitted into.** Both
come from a document that `--spec` lets a user hand-write, and every target
interpolated them raw — so a newline in a summary put the rest of it in
executable position, and a quote in a function path closed its own string
literal. Shared `commentText`/`stringLiteral` escapers now cover all seven, with
a target-level regression case asserting no language emits the injected call.
Kotlin's `$` and Ruby's `#{` escapes layer on top rather than repeating the
backslash rules, which would have emitted a literal decoding to two of them.
**A query's `Subscribe<Base>` member bypassed the collision check.** A namespace
exporting a query `list` alongside a `subscribeList` passed validation and then
emitted the member twice — a compile error in Go, a silent shadow in Python.
Also: codegen no longer builds its schema input on `FetchingJSONSchemaStore`,
which resolves `$ref` over the network — nothing emits a ref, and `--spec`
accepts a hand-written document, so it was a way to point codegen at a URL. A
malformed `--spec` now reports a coded error instead of a bare `SyntaxError`, and
a document with no methods writes an empty SDK rather than leaving the previous
generation's files on disk. Swift gained five missing keywords and
`.fragmentsAllowed`, without which a scalar result fails to decode. Python's
`Any` import is gated on something referencing it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
…ld it
Building was never the check it looked like. Java shipped a surface that compiled
and threw `cannot encode` on the first invocation; Ruby shipped one whose every
method raised NoMethodError. Both had a green compile-or-parse gate throughout.
So all seven legs now generate, build, AND call, each asserting the same frame:
{"args":{"channelId":"chan_1"},"functionPath":"messages:list"}
**Rust sent `"limit": null` for an unset optional**, found by the very first run
of its new smoke — one commit after the same bug was fixed in Ruby. quicktype's
Rust backend renders an optional as `Option<T>` with no `skip_serializing_if`, so
`serde_json::to_value` emits an explicit null, and `v.optional(x)` parses
`undefined`-or-`x` and rejects it: every call leaving an optional unset failed
validation server-side. The runtime gained `from_model_json`, which drops
null-valued fields at every depth, and the generated call sites use it. Go's
backend emits `omitempty` and Python's `to_dict` omits the key, so those two were
already correct — and Swift's synthesised `encode` omits nil optionals, which the
new smoke confirms rather than assumes.
The kotlinc archive is now checked against the SHA-256 JetBrains publishes beside
it (verified by hand against a downloaded copy) before it reaches `unzip`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
Its inner double quotes forced Prettier onto single quotes for the whole value,
which the `quoted-strings` rule rejects — so `Lint (yaml)` has been red since the
ruby leg landed. `Dir.glob(%q{...})` keeps the glob, so a new `test_*.rb` is still
picked up rather than being pinned to a hardcoded list.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
…deps `pnpm --filter '@lunora/cli...' run build` ran @lunora/studio's standalone esbuild step before @lunora/bindings had a dist, so every SDK leg died at "Build the generator" on `Could not resolve "@lunora/bindings/analytics"` — before it ever generated anything. vis orders the closure from `dependsOn: ["^build"]`, which is how the Test legs in this same workflow already build studio. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
…ound Each transport is now held to its own ecosystem's standard tools — ruff, gofmt + go vet, rubocop, cargo fmt + clippy, swift-format, google-java-format + `javac -Xlint:all -Werror`, ktlint — through `sdks/lint-all.sh`. CI runs that same script per leg rather than repeating the commands in YAML, so the local check and the gate cannot drift. Every tool is pinned by version or SHA-256, and a tool missing locally reports SKIP, never PASS. **Every generated Python SDK swallowed KeyboardInterrupt.** quicktype writes a bare `except:` into its `from_union` helper, which catches `BaseException` — so an interrupt raised while a union member was being decoded was discarded and the loop simply tried the next member. Every union-typed field routes through that helper, so it is narrowed in the emitter rather than left to each consumer, with a test pinning it. Four real defects in the Rust transport, all from clippy: - `ClientError::Api` carried an unboxed `ApiError` — 128 bytes, which made every `Result` in the crate that wide, on the success path too. Now boxed. - `keys.sort_by(|a, b| f(a).cmp(&f(b)))` recomputed the key for both sides of every comparison; `sort_by_key` computes it once. - The injected callback types were spelled out at eight sites; they are now `DataHandler` / `ErrorHandler` / `RowsHandler`. Two in Ruby, from rubocop: - `WireMap = Struct.new(:entries)` shadowed `Struct#entries`, so the one method a reader would reach for to enumerate members returned the map's pairs instead. Renamed to `pairs`. - `frame = begin … return nil … end` put a `return` in an assignment's right-hand side, which reads as if it yielded a value. Parsing is now its own method behind a plain guard. Where a rule is switched off, the config records which behaviour of this code the rule was wrong about, rather than just silencing it. Two recur: the wire codec's `case`/`when` tables (rules that would spread one 20-arm table over 60 lines, which is how an arm goes missing) and its shortest-round-trip float comparison (`candidate.to_f == value` is the test itself — an epsilon would accept a shorter, wrong spelling). `generated_check/` is excluded from all of it: those trees are generator output committed as samples, their models come from quicktype, and any correction there is undone by the next regeneration — so the emitter is where generated output is held to account. Also: the line width is 160 across all seven, matching the repo's Prettier `printWidth`, and Java uses `--aosp` for 4-space indentation, so two ports read the same shape side by side. `.prettierignore` now covers the swiftpm and cargo build directories, which Git already ignored but Prettier did not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
…ne in CI `return "$(missing ruff)"` captured the helper's stdout — which was empty, because it writes to stderr — so the skip path ran `return ""`, which bash rejects and turns into status 1. Every missing tool was therefore reported as a lint FAIL naming no offence, and the SKIP state the script advertised never occurred once. With that fixed, SKIP exits 0, which is right locally (not everyone has seven toolchains) and wrong in CI, where the install step for that language just ran: a missing tool there means the install broke, and the gate would go green having checked nothing. So the job sets SDK_LINT_REQUIRE_TOOLS=1, which turns SKIP back into a failure. Verified both modes by running with the tools taken off PATH. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
… ports protocol/conformance-cases.json claimed "each suite asserts it ran every name below", and no line of code read the file. The claim was prose, so the coverage drift it was created to stop could recur in silence — and had: neither the Go nor the Ruby port ever asserted non_2xx_without_error_envelope_fails, one of the 16 required names, with every gate green throughout. Both cases are added here. Every suite now reads the manifest at run time and fails if the run did not cover it. The evidence is produced by the case executing, never by a suite listing names it claims to cover, and the mechanism is the one each runner offers: - python: each case calls covers(); tests/test_zz_manifest.py, which discovery sorts last, compares the recorded set against the manifest. - go: each case calls covers(); TestMain compares after m.Run(). A -run-filtered run is exempt — it cannot cover the manifest by construction. - ruby: each case calls ConformanceManifest.covers; Minitest.after_run aborts on a gap. The recorder and the hook are separate files so a single-file run records without being held to a list it cannot cover. - rust, swift: libtest has no after-all hook and XCTest has none that can record a failure, so there the manifest DRIVES the run — every required name is dispatched to the function that asserts it and a name with no arm fails. Hence plain fns in Rust and caseX methods in Swift: one entry point, so a case cannot be silently detached from its manifest name. - java, kotlin: each case calls covers(); the end of main is the after-all hook. Two adjacent holes found while verifying it, both of which made a check report green without running: - go test served a cached PASS for a manifest that had just changed: every input these suites assert against lives outside the Go module, so the test cache cannot see it change. The go leg now runs with -count=1, here and in CI. - ktlint exits 0 when a glob matches nothing, warning only "No files matched", so a moved file would stop being linted silently. lint-all.sh resolves the paths and holds each input to at least one file; a total count would still pass while one input contributed nothing. Also document that the JVM suites need a real JDK on PATH: the run table said `bash build.sh`, which cannot work on a stock macOS where /usr/bin/java is Apple's stub, and only run-all.sh/lint-all.sh were prepending the Homebrew JDK.
The JVM targets' headers said quicktype's Java and Kotlin backends rename properties and carry no mapping, which is true but stopped short of the options that were never checked. Measured all of them against quicktype-core 26.0.0 and wrote the results down, so the next person does not repeat the investigation. - `acronym-style` does govern exactly the `Id` -> `ID` step, and `original` does yield a field named `channelId`. It is still not sufficient: of 14 realistic wire keys, 5 rename anyway (`2fa` -> `the2Fa`, `ID` -> `id`, `URLs` -> `urLs`, `some-key` -> `someKey`, `user_name` -> `userName`). - Dropping `just-types` emits the exact wire name on both backends (`@JsonProperty`, `@Json(name=)`, `@SerialName`), and every one of the four framework choices needs a third-party library at compile and run time. The transports hand-roll `Json.java`/`Json.kt` precisely to avoid that. - Kotlin has a second blocker no projection can work around: `just-types` erases enum wire values, so the committed fixture's own `kind` argument could not be encoded even with perfect property names. - Java has a third, and it is the one with a known fix: the single-file render is not compilable Java at all, and `quicktypeMultiFile` returns clean per-class files. - `lombok` adds `@lombok.Data` and no mapping; `array-type` and `datetime-provider` are irrelevant here. Verdict unchanged, so the capability matrix stays as it was. The generated JVM surfaces are byte-identical after a regeneration and both generated-call smokes still pass.
Closes the last two gaps in the capability matrix's "Concurrency-safe client" row. The two ports needed opposite things, and the row was wrong about both. Ruby held no lock at all. `@next_id += 1` followed by a second read of `@next_id` is four bytecodes on every Ruby, so two threads can mint the same `sub_N` and the later insert drops a live subscription; the registry, the shape views, the id counters and the sender are now behind one `Mutex`. Resume frames are BUILT under it, because each reads a `cursor` the frame handler writes, and the poke row snapshot likewise. Frames and user callbacks are dispatched with the lock RELEASED — `Mutex` is not reentrant, so a callback that subscribes would otherwise deadlock. Rust needed no lock and now has none: every method touching that state takes `&mut self`, and with no interior mutability, `static` or `unsafe` in the client a data race is not expressible. What it could not do was be shared at all. The injected poster, frame sender and handlers were `Box<dyn Fn>` with no `Send` bound, and because the client stores them, one non-`Send` closure made `Client` itself non-`Send` — so `Arc<Mutex<Client>>` did not compile and the row's advice to "wrap them if you share one" described something impossible. The aliases now carry `+ Send`. Generated code follows by referencing `DataHandler`/ `ErrorHandler` instead of respelling the box, which cannot drift from them. Both ports gain the count-based case the other five have: a socket reader plus four subscriber threads, then assert the surviving subscription count, because a lost `nextId++` silently forgets a subscription where waiting for a hash map to corrupt is not deterministic. The Ruby case gives its injected sender a `Thread.pass`. Without it the case passes with the lock removed and is therefore worthless: MRI's time slice is 100ms, so four CPU-bound threads each run to completion having never interleaved. A real sender writes to a socket and blocks, which releases the GVL, so the yield is the realistic behaviour rather than a nudge — measured, not assumed, by running the case both ways. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
Six of the seven SDK lint legs install their linter at an explicit version, so an upstream release cannot change the rule set under a green PR. The swift leg had no such pin: it called the toolchain's `swift format` subcommand and never reported which version answered, so a runner-image Xcode bump would have changed the rule set silently, and a rollback to Swift 5.x would have failed the leg under SDK_LINT_REQUIRE_TOOLS=1 with nothing named. There is nothing to install. swift-format ships no binary on any of its 48 releases and has no versioned package (Homebrew carries one unversioned formula), and building the pinned tag takes 26m18s for a release build on a 10-core laptop — most of it single-threaded whole-module work on SwiftSyntax, so a 3-core hosted runner is slower — against a 15-minute job timeout. So the pin is an assertion instead — SWIFT_FORMAT_VERSION, compared against the version the tool reports: - the version is printed on the summary line, pass or fail, because this leg has no install step whose log would otherwise record it; - a different minor is a note locally (an unpinned rule set still catches the mistake the run was for) and a failure naming both versions in CI; - SWIFT_FORMAT points the leg at another binary, which `swift format` cannot do on its own — it resolves inside the toolchain and ignores PATH. Its paired SWIFT_FORMAT_VERSION is overridable because the same release reports two versions: `6.3.0` from a toolchain, `603.0.0` from a standalone build. Corrects the leg's comment, which claimed an older toolchain "stays a SKIP" without noting that CI turns that SKIP into a failure. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
The README claimed the Python client was "safe by virtue of the GIL for the operations it performs". Measured against the unsynchronised client, it was not safe, in two distinct ways. The GIL makes each bytecode atomic, not each statement. `self._next_sub_id += 1` followed by a separate read of it is two operations: a switch in between hands two threads the same id, and the second `self._subs[sub_id] = sub` silently forgets a live subscription. One run at the stock 5ms switch interval lost 830 of 16,000 subscriptions. Separately, `connect_and_run` walked `self._subs` to build its reconnect resend while other threads inserted, raising `RuntimeError: dictionary changed size during iteration` on 10 of 10 runs at the stock interval — inside the read loop, so it takes the socket down with it. Every contended method (`subscribe`, `subscribe_shape`, `handle_frame`) is a plain synchronous method, not a coroutine, so the contention is between real OS threads and `threading.Lock` is the right tool; an `asyncio.Lock` only orders tasks on one event loop and cannot be acquired off it. A `threading.Lock` now guards the registries, the id counters, the attached sender and the per-subscription cursor/epoch. Frames and user callbacks dispatch after releasing it, so a callback that subscribes cannot deadlock the read loop. The unlocked walk in `connect_and_run` is replaced by `resend_subscriptions`, which BUILDS each resume frame under the lock because each reads a cursor the frame handler writes — and which fixes that path dropping the resume cursor and shape checkpoint it had already tracked. `tests/test_concurrency.py` runs four subscriber threads against a frame reader and asserts both failures. It fails 6 of 6 runs with the lock removed and passes 12 of 12 with it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
`Test (node-24.11)` failed on `holds a delayed message back until its delay
elapses` while node-22.15 passed the same commit. The case captured
`Date.now()`, sent with `delaySeconds: 60` — which stamps `visible_at` from the
HOST clock, defaulting to the real one — then polled at exactly
`captured + 60_000`. Zero margin: any millisecond between the capture and the
send pushes `visible_at` past the poll and the message stays invisible.
`NodeQueueHostOptions.now` exists for precisely this and documents it verbatim
("a test that captures `Date.now()`, sends, and then polls at `captured + delay`
misses by however many milliseconds elapsed in between"). Three other cases in
this file already inject it; this one did not. Its neighbours survive on the real
clock only because they poll at `now + 5000`, orders of magnitude more slack than
the drift.
Reproduced before fixing: 6 runs of the original, 5 passed and 1 failed. 10 runs
after, all green.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
`SDK conformance (swift)` was cancelled at 15m28s against the job's shared `timeout-minutes: 15`, having already passed swift-format lint and the conformance suite — it died at "Setup node", before generating anything. Nothing swift-related had changed since the same leg finished in 9m53s, so this is the spread of a hosted macOS runner against a ceiling with no margin, not a regression. The leg also does strictly more than its siblings: lint, the suite under ThreadSanitizer, a vis build of the CLI closure, then generate + build + call. The six Linux legs finish in about three minutes, so raising the shared value would hand a genuinely hung Linux leg 30 minutes to burn. Each leg now carries its own value — 15 for Linux, 30 for macOS — and every entry sets it explicitly, because an absent key would silently inherit GitHub's 360-minute default. Measured while diagnosing: ThreadSanitizer is not the cost. From a cold .build, `swift test` is 42s and `--sanitize=thread` 55s; filtering it to the one multithreaded case is 48s, since the build dominates. So there is nothing to win by narrowing the sanitizer's scope. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
The earlier fix injected the clock into the one case that had failed. The rest of the file still mixed two: `send` stamps `visible_at` from the host clock, which defaults to the real one, while each case polls at `captured + offset`. Two were as broken as the one that failed and simply had not been unlucky yet — "retries an explicitly retried message" and "retries every undecided message" both assert `poll(now) === 1` with NO margin, so a single elapsed millisecond between the capture and the send hides the message. Two more were safe only by accident: one polls 5s out, and the dead-letter case captures `now` after its sends, so drift moves the comparison the harmless way. All eight captures now pair with an injected clock. Uniform rather than case-by-case, because "is this one accidentally safe?" is a question no reader of a test should have to answer — and the accident is one edit away from reversing. 12 consecutive runs of the file green after the change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
The repo-layout table still read `sdks/` as "Non-JS client SDKs (`python`)" — six languages out of date, and this is the file agents read first to find out what exists. Also added `sdks/run-all.sh` and `sdks/lint-all.sh` to the block listing gates that `lint`/`test` do not reach. Both have their own CI legs and neither is reachable from any `pnpm run` script, which is exactly what that block is for. Reworded the `test:templates` line: it no longer just builds, it scaffolds, installs, builds and typechecks the copied auth-ui payload. The table is Prettier-realigned because the widened cell moved the column. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
`lunora sdk generate` emitted a typed surface that imported a runtime package and told the user to install it. None of those packages exist: `lunora` 404s on PyPI, RubyGems and crates.io, `dev.lunora:lunora` 404s on Maven Central, and `github.com/anolilab/lunora-go` 404s too — so generated Go could not resolve its own import in a user's project at all, and only compiled in CI because the generated package sat inside our own module. Copy the transport in instead, the way `lunora registry add` copies a registry item: giget from `gh:anolilab/lunora/sdks/<lang>`, reusing the registry's `resolveItemDirectory` so the `--source` gate, staging and `--from` cannot drift between the two. Output is self-contained; five of seven languages now need nothing installed, and the two that do (Rust `serde`, Ruby `dry-struct`) need it for quicktype's models rather than the transport. Each language gets the layout its own toolchain resolves — a `go.mod` and two packages, a Cargo path dependency, SwiftPM targets, package-per-directory on the JVM — with the reasoning in each target file. Two costs are measured rather than assumed: Go keeps two packages because the transport exports `Error`, `Map`, `Set`, `Date` and `Client`, so one flat package would let a user's schema redeclare them; and Swift's `package:` must be the output directory's name, because SwiftPM ignores the manifest's `name:` for a path dependency and a bare product name does not resolve. Pin the fetch to the CLI's own release tag rather than a release branch, so regenerating with a newer CLI is the upgrade path that publishing to seven registries would have given us. Stamp every output with the ref actually used and whether it matched, since a copy has no version to bump. A tag that carries no transport for a language falls back to the branch and says so loudly; `--ref` pins explicitly and never falls back; `--from` is the offline path. Replace the committed generated_check trees with `sdks/generated-check.sh`, which generates into a scratch directory OUTSIDE the repo and runs a call through the consumer project a real user writes. Self-containment cannot be tested in-tree — Python finds `sdks/python/lunora` on sys.path, Go finds a sibling package in the same module, Swift a target in the same package — so a pass there proved nothing. All seven verified end to end. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
The docs site never mentioned the non-JS SDKs, and the pages that touched the subject described the state from before this work. New page `concepts/non-js-sdks`: the command, the per-language install requirements (nothing at all for five of the seven), version pinning and the `lunora-transport.json` stamp, the flags, the per-language wiring, and the two deliberate gaps (no typed models on the JVM, no optimistic updates or offline queue outside JS). Every claim is taken from the generator's own output rather than paraphrased. Corrected alongside it: - `concepts/wire-protocol` was titled "Wire protocol & non-TS SDKs" and said the protocol had one implementation, "a minimal Python client". Its conformance list named two implementations out of eight, and its whole "The Python SDK" section is superseded — the page now covers the protocol and hands off. - `concepts/server-clients` routed non-JS callers to "the Python SDK" and carried a callout promising generated typed bindings as a follow-up. They shipped. - `AGENTS.md` listed the two SDK gate scripts but not `sdks/generated-check.sh`, which became a CI gate when it replaced the matrix's per-leg build step. Verified by building the docs site: the page prerenders and appears in `pages.json`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
cbacb3a to
4566058
Compare
Java and Kotlin were the last two SDK targets taking wire-shaped `Map<String, Object>` / `WireValue` arguments, because quicktype's JVM backends rename properties and, under `just-types`, emit no mapping metadata — so a model they render cannot be projected back onto the wire. `acronym-style: original` fixes `channelId` and still renames 5 of 14 realistic wire keys (`2fa`, `ID`, `URLs`, `some-key`, `user_name`), and Kotlin's `just-types` erases enum wire values outright. The only complete mapping those backends offer needs a Jackson / Klaxon / kotlinx dependency, which is the one thing these JDK-only transports are defined not to have. Emit the models here instead, from the JSON Schema, whose property names ARE the wire names: `toWire()`/`fromWire()` write the schema's own key as a string literal, so there is no renamer to fight and nothing to re-derive. A local field identifier is still derived (`2fa` cannot be a Java field) but is cosmetic and never reaches the wire. - `SdkTarget.renderModels` is the new optional seam, preferred over quicktype when present; it returns FILES because Java takes one per class — its single-file render is not compilable Java at all. The declared-model reconciliation still reads one joined string, so it is the same code for all seven targets. - Enums keep their wire value (`enum class Kind(val wireValue: String)`, `toValue()`/`forValue()` in Java) rather than only a constant name. - An unset optional is OMITTED from the wire map. `v.optional` parses the value or `undefined` and rejects an explicit null, so writing null fails every call that leaves one unset. - A `.nullable()` property is the opposite and does send an explicit null. Optional-and-nullable together cannot express both; null means omit, and the ceiling is recorded where it is decided. - Typing stops below the depth `hasUnrepresentableWireType` inspects, so a `v.bigint()` hidden deeper than that guard looks lands in an untyped leaf instead of a field that would encode it as a plain number. - A name collision between two declarations discards that model rather than emitting one of two same-named classes; it is then reported as undeclared and its call site degrades to an untyped value. Both smoke programs now build a typed model, and each asserts a second frame so the enum and the record are covered at run time and not only at compile time. Three negative controls were run against the emitter: sending an unset optional as null, renaming `channelId` to `channelID`, and encoding an enum's constant name — each fails the check. BREAKING CHANGE: a regenerated Java or Kotlin SDK takes a generated model where it previously took a wire-shaped map, so existing call sites must construct the model. The untyped parameter remains for functions whose schema carries a `v.bigint()`/`v.bytes()`, which no model can represent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
The new JVM assertion was titled "carries the wire key verbatim into toWire and
fromWire" but only checked `models.toContain('"<key>"')` — presence anywhere in the
file. Each field's doc comment already names its wire key, so that assertion is
satisfied by the comment alone.
Proven, not supposed: taking the encode key from the derived identifier instead of
the schema — the exact quicktype rename this design replaced — left all 108 tests
green. The smoke cannot catch it either, because the fixture has no key whose Java
identifier differs from its wire name (`channelId` derives to `channelId`).
Now asserted at the encode AND decode statements: `wire.put("<key>"` /
`wire.get("<key>")` for Java, `add("<key>" to` / `wireField(value, "<key>")` for
Kotlin. The same break now fails 5 tests, one per renamed key.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AyG8dyPFieGYzRd7y1MMme
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
lunora sdk generate --lang <id>emits a typed, self-contained client for sevenlanguages — python, go, ruby, rust, swift, java, kotlin — from a project's own
OpenRPC surface.
The output needs nothing installed in five of the seven languages: python is
standard-library only, go standard-library only, java and kotlin JDK-only, swift
Foundation-only. Rust needs
serde/serde_json(declared in the emittedCargo.toml), ruby needsdry-struct/dry-typesfor the generated models.How it is put together
Three layers, deliberately split:
quicktype-corepackages/codegen/src/sdk/targets/<lang>.tssdks/<lang>/--outThe transport is copied, not installed, and pinned to the git tag matching the
CLI that generated it (
@lunora/cli@<version>). Each output carries alunora-transport.jsonrecording the ref actually used and whether it wasversion-matched, so regenerating with a newer CLI is the upgrade path and a copy is
never silently a different protocol vintage than the surface beside it.
That decision replaced an earlier design that imported a published runtime package.
None of those packages exist —
lunora404s on PyPI, RubyGems and crates.io,dev.lunora:lunora404s on Maven Central, andgithub.com/anolilab/lunora-go404stoo, so the generated Go surface could not resolve its own import in a user's
project. Publishing seven registries is its own project; copy-in works today.
What the SDKs implement
All seven: the full wire codec (every tag), the stable subscription key byte-identical
to the TS client's, RPC query/mutation/action, live subscriptions, the shape/poke
protocol, resume-across-reconnect, and a client that is safe to share across threads.
Two deliberate gaps, both recorded with what was measured:
(
channelId→channelID) and emit no mapping metadata.acronym-style: originalfixes that one case but still renames 5 of 14 realistic keys, and Kotlin's
just-typeserases enum wire values outright — so a model cannot be projected backonto the wire. Both take wire-shaped arguments instead; sending the wrong key
silently is worse than staying untyped.
How it is tested
protocol/fixtures/as the reference TS client.protocol/conformance-cases.jsonis now a real gate — each suite reads it at run time and fails if the run did not
cover it, so adding a name turns all seven languages red. Verified by adding a 17th
case and watching all seven fail.
sdks/generated-check.sh <lang>generatesinto a scratch directory outside the repository, then compiles and runs a call
through it. Building alone was not enough: an earlier revision emitted a Java
surface that compiled perfectly and threw on its first invocation.
sdks/lint-all.sh): ruff, gofmt + go vet,rubocop, cargo fmt + clippy, swift-format, google-java-format +
javac -Xlint:all -Werror, ktlint. Pinned by version or SHA-256 in CI, and a missing tool fails theleg rather than skipping quietly.
Defects found and fixed along the way
Each of these was found by running something, not by reading it:
NoMethodError— the models were rendered withjust-types, which omits theto_dynamic/from_dynamic!the call sites use.ruby -cparsed it happily, which is why the CI leg now runs a call."limit": nullfor unset optionals, whichv.optional()rejects.
virtue of the GIL": the registry walk raised 10/10 runs at the stock switch
interval, and one run silently lost 830 of 16,000 subscriptions. Ruby had the same
class of bug. Java, Kotlin and Swift gained locks; Rust needed
+ Sendboundsbefore
Arc<Mutex<Client>>would even compile.build_subscribe_framewascalled without
since_seq/since_epoch, so the cursor tracked all session wasdropped at the one moment it mattered.
jsonStringcorrupted any string containing a literal, and itssubscription map raced the frame handler (Go answers that with an unrecoverable
fatal error).
except:in generated Python swallowedKeyboardInterruptinsidequicktype's
from_union.go testwas replaying cached passes — the fixtures live outside the Go module,so a fixture edit left the leg green without running. Fixed with
-count=1.summaryorfunctionPathcould escape the syntax it was emitted into, since--specaccepts a hand-written document.until the manifest became a gate.
Also in here
.output()now types RPC results in the OpenRPC/OpenAPI emitters, which previouslydiscarded it while claiming otherwise.
@lunora/*from npm: pnpm auto-installsa missing peer from the registry regardless of
overrides, so every vite-basedtemplate was testing published packages instead of the checkout. Now asserted.
Linux.
concepts/non-js-sdkspage, andconcepts/wire-protocol/concepts/server-clientscorrected — both still described a single Python clientand promised typed bindings as a follow-up.
Out of scope
Publishing the seven transports to their registries, and typed models on the JVM.
Both are recorded with what a real fix would cost.