Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## rc #2280 +/- ##
==========================================
+ Coverage 64.26% 64.27% +0.01%
==========================================
Files 2178 2178
Lines 110399 110493 +94
Branches 8289 8300 +11
==========================================
+ Hits 70945 71023 +78
- Misses 33385 33398 +13
- Partials 6069 6072 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
These pb.go and codec_gen_test.go changes were proto-descriptor reordering noise unrelated to the spatial-types work. Reverting to keep the PR diff focused.
These case "numeric" arms in constraintToGo, formatTypeParamsDecl, and the test-fixture concrete-type helpers can't fire: the analyzer requires every numeric-constrained type-param to have a numeric default, and every Go-emitting call site filters through NonDefaultedTypeParams before reaching these functions. The arms were added as completeness hedges; remove them to keep the codebase to live paths only.
…b generator A struct field declared with single "?" in oracle keeps its Go type as a value, but the proto field is nullable on the wire. The generator was calling the inner ToPB unconditionally, which errored on a zero-value struct that contained string-enum fields (e.g. spatial.StickyXY.Root, arc.ir.Function.Body). Route soft-optional struct fields through OptionalFields with a zero-value guard in ToPB and a proto-pointer nil-check in FromPB. The latent same-shape bug in ranger.Range.Color is fixed by the same path. Also fix the pluralize package so trailing acronym runs ending in Y (StickyXY, ClientXY) pluralize as "+s" rather than mangling to "ies". The previous all-uppercase shortcut only caught fully-acronym names.
Schema fields whose names start with a lowercase letter are now used verbatim as the JSON / msgpack tag instead of being routed through SnakeCase. snake_case stays snake_case (data_type) and camelCase stays camelCase (clientX, signedWidth, targetKey), letting Go round-trip directly with the TypeScript zod schemas, which use the schema field name as the property key. Names that begin with an uppercase letter (PascalCase, screaming-case, single-letter caps) keep the existing lowercase-snake convention so WASM -> wasm and OutputMemoryBases -> output_memory_bases are unchanged. Only six fields across the codebase change tags (spatial.ClientXY, spatial.SignedDimensions, ir.Transition.TargetKey, ir.Member.NodeKey); none have shipped data to maintain compatibility with.
…8-prepare-oracle-generated-spatial-primitives-for-strongly
…8-prepare-oracle-generated-spatial-primitives-for-strongly
Reverts commit 3bb7a60. The wire format is canonically snake_case across every language; TypeScript bridges via x/ts caseconv at the boundary, so preserving camelCase schema names verbatim in Go tags broke the convention rather than aligning with it. jsonTagName now routes every field name through SnakeCase regardless of how it is spelled in the schema. This will flip the JSON / msgpack tags on the six fields the previous commit touched (spatial.ClientXY.{clientX,clientY}, spatial.SignedDimensions.{signedWidth,signedHeight}, ir.Transition.targetKey, ir.Member.nodeKey) back to snake_case once oracle sync regenerates the .gen.go files.
…8-prepare-oracle-generated-spatial-primitives-for-strongly
…8-prepare-oracle-generated-spatial-primitives-for-strongly
sy-nico
approved these changes
May 1, 2026
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.
Issue Pull Request
Linear Issue
SY-4138
Description
Adds a
numericbuilt-in constraint to Oracle for primitive-constrained generics (T extends numeric = float64). TypeScript emits a function-form schema (<T extends numeric.Value = number>(t?: z.ZodType<T>) => z.object({...})) plus a value-typed generic interface (Bounds<T extends numeric.Value = number>). Go, C++, Python, and proto substitute the default primitive and emit non-generic concrete types — these languages can't express anumber | bigintconstraint, so they collapse to the default. Analyzer rejectsnumericconstraints without a numeric default.Companion fixes in the TS emitter:
lo.CamelCasereplaced with a smart helper that preserves trailing acronym runs (ClientXY → clientXY,EntityID → entityID), parallel to the existing Go acronym list. Standalone acronyms (XY → xy) and non-acronym names are unchanged.numeric.Valueis auto-imported from@synnaxlabs/x(or@/numericfrom inside thexpackage), mirroring the existingrecord.Unknownpattern. Addsexport * from "@/numeric"tox/ts/src/index.tsso external consumers can resolve the namespace.anypbimport in the generated Go translator is now gated on having non-defaulted type-params, fixing an unused-import error for fully-defaulted generics likeBounds.The new infrastructure is then used to migrate the
spatialprimitive set (Bounds,XY,ClientXY,StickyXY,Viewport,Dimensions, locations, directions, alignment, sticky units, etc.) from hand-written types inx/ts/src/spatial/base.tsto Oracle-generatedtypes.gen.ts,types.gen.go,types.gen.h, andspatial.proto. The hand-rolledboundsZconstant becomes a function (boundsZ()) — call sites inpluto,console, andx/tsare updated accordingly.NumberCoupleandCrudeBoundsstay as TS-only constructs because tuples and unions of struct + tuple aren't expressible in Oracle.Basic Readiness
Greptile Summary
This PR migrates the
spatialprimitive set from hand-written TypeScript to Oracle-generated code (types.gen.ts,types.gen.go,types.gen.h,spatial.proto), adds anumericbuilt-in constraint for primitive-constrained generics, and ships companion fixes to the TS emitter (camelCaseacronym-preserving helper), the Go PB plugin (IsOptionalStructsoft-optional fix, gatedanypbimport), and the pluralizer (StickyXY→StickyXYs). The previous bugs flagged in review comments —StickyXYnil-pointer round-trip, wrong*Xiesplural forms, and zero-value optional struct serialization — are addressed by using pointer types (Root *CornerLocation,Units *StickyUnits) withomitemptytags and conditional translator paths.Confidence Score: 5/5
Safe to merge — all previously flagged bugs are addressed, no new P1/P0 issues found.
The three previously flagged P1 issues (StickyXY nil-pointer round-trip, wrong *Xies plural forms, zero-value optional struct serialization) are all resolved. No remaining P1 or P0 findings. All renamed public APIs are consistently updated across every call site in pluto, console, and x/ts. New code paths are covered by well-structured tests.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["schemas/spatial.oracle"] --> B["Oracle Code Generator"] B --> C["x/ts/src/spatial/types.gen.ts\n(boundsZ as generic fn, clientXYZ, stickyXYZ, ...)"] B --> D["x/go/spatial/types.gen.go\n(StickyXY with *CornerLocation, *StickyUnits)"] B --> E["x/go/spatial/pb/translator.gen.go\n(StickyXYsToPB, ClientXYsToPB, ...)"] B --> F["x/go/spatial/pb/spatial.proto"] B --> G["x/cpp/spatial/types.gen.h"] C --> H["x/ts/src/spatial/base.ts\n(re-exports types.gen + NumberCouple)"] H --> I["bounds / xy / direction / location / sticky modules"] I --> J["pluto / console call sites\n(boundsZ(), xyZ, xZ, cornerZ)"]Comments Outside Diff (2)
x/go/spatial/types.gen.go, line 183-200 (link)ClientXYandSignedDimensionsOracle generates snake_case JSON tags for Go (
client_x,client_y,signed_width,signed_height), while the TypeScript schemas use camelCase (clientX,clientY,signedWidth,signedHeight). Protobuf JSON encoding auto-converts snake_case to camelCase, so proto-mediated round-trips are fine. However, any direct Go JSON/msgpack serialisation of these types (e.g. persisted config files or REST payloads) would produce keys that TypeScript consumers cannot decode without explicit field-name remapping.arc/go/types/pb/translator.gen.go, line 471-520 (link)KindSignedNumericConstantremoved fromKindToPBwhile still active in the type systemKindSignedNumericConstantwas removed from theKindToPB/KindFromPBswitch in this PR, but the kind is still defined inarc/go/types/types.gen.goand actively used inarc/go/types/type.go,arc/go/analyzer/constraints/unify.go, andarc/go/compiler/expression/compiler.go. The functionSignedNumericConstraint()returnsType{Kind: KindSignedNumericConstant}, and it can appear as aConstrainton type-parameter variables.TypeToPBcallsKindToPB(r.Kind)unconditionally before building the proto object (line 104), and recursively calls itself forr.Constraint(line 136). Any code path that callsTypeToPBwith a type whoseKindorConstraint.KindisKindSignedNumericConstantwill hit thedefaultcase and return an error. If function parameter types that carry aSignedNumericConstraint()reach the proto serialization layer, serialization of those params will silently fail at runtime.Reviews (9): Last reviewed commit: "Merge branch 'rc' of https://github.com/..." | Re-trigger Greptile