spike: codegen experiments (SDK-1107)#273
Draft
Tr00d wants to merge 5 commits into
Draft
Conversation
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.
Status: 🚧 DRAFT — spike, not for merge
This is an evaluation spike. All generated code lives in isolated, standalone projects that are in the solution for visibility but are not referenced by
Supabase.csproj(analyzers disabled, separate assemblies) — nothing here affects the product build, analyzers, or quality metrics.Summary
Evaluates whether the HTTP layer of the C# SDK (Storage / Functions / PostgREST; Auth is blocked by model coverage) can be generated from the shared Smithy models in
supabase/sdk#51, producing idiomatic C# that a maintainer would own long-term. Input is the committed Smithy→OpenAPI artifacts; Smithy is never run in the C# toolchain. All evaluated generators are deterministic, template-based tools — output is a function of the input document and configuration only, with no generative-AI component.Two toolchains were run end-to-end (NSwag and Kiota), the rest of the brief's list assessed with rationale, and both generated clients were exercised against a live local Supabase platform. The model gaps found by the live runs were fixed upstream in supabase/sdk#55 and verified by rerunning the spike against the corrected artifacts.
What's included
Supabase.sln)nswag-spike/(spike-nswag)kiota-spike/(spike-kiota)nswag-testrun/(spike-nswag.TestRun)kiota-testrun/(spike-kiota.TestRun)codegen-comparison.md(root)Key findings
MakeRequesttransport; Kiota's replaces it with 4,338 generated LOC plus an 8-package runtime, without the current ergonomics (progress reporting, caching,FailureHintmapping). Generated models do add value — as drift protection against the shared contract and as the type source for new endpoints.IParsable, require its runtime, and placeMicrosoft.Kiota.Abstractionson the SDK's public API — there is no models-only adoption path for Kiota.nullableon optional fields (NSwag serialized defaults the server rejects; Kiota omits unset fields). Both generators translated their input faithfully and deterministically — which means the fixes, made once in the model, propagated to both toolchains on regeneration. Validation must target the model; the test-run harnesses are the mechanism.byte→binary, the{wildcardPath+}path label, and build reproducibility. Rerun results: both clients compile with 0 errors from the committed artifacts verbatim (previously 24 compile errors without local patching); Kiota live harness 4/4 —ListBucketsreturns real counts (the false-zero failure is gone); NSwag deserializes lists and creates buckets withoutfile_size_limit(no more 413-trap). NSwag's one remaining live failure (ListObjects400) is generator-side null-serialization, addressed by client config (WhenWritingNull), not a model defect.Recommendation — adapt, with NSwag in models-only mode, in two stages
WhenWritingNullserialization config, source-generatedJsonSerializerContextfor AOT, PascalCase naming — optional-field typing now comes from the spec); use generated models as the type source for newly implemented endpoints; stand up a drift monitor — generated models diffed against the existing public types, with a committed baseline, reported and triaged (divergence on implemented surface = defect/contract change; unimplemented surface = parity-backlog input), not a build gate; adoptHttpCompletionOption.ResponseHeadersReadinCore.Scope of validity: these conclusions are specific to an SDK with owned transport, a published public API, and a parity backlog. For an SDK built from scratch, the same evaluation favours whole-client generation (Kiota is the strongest candidate assessed). Invariant in both settings: generated code is only as correct as the contract it is generated from, and a live contract-test harness is a required pipeline stage. Full rationale, cost analysis, and reversal criteria in
codegen-comparison.md.Upstream model gaps — status
supabase/sdk#55, verified live.nullable— fixed insupabase/sdk#55, verified live.byte→binary;{wildcardPath+}label; build reproducibility — fixed insupabase/sdk#55.200only — the API can return204; currently handled in hand-written code.How to run the harnesses
🤖 Generated with Claude Code