SY-3833: Strongly Type Schematics on the Core#2283
Open
emilbon99 wants to merge 20 commits intosy-4140-schematic-type-re-organization-and-diagram-optimizationsfrom
Open
SY-3833: Strongly Type Schematics on the Core#2283emilbon99 wants to merge 20 commits intosy-4140-schematic-type-re-organization-and-diagram-optimizationsfrom
emilbon99 wants to merge 20 commits intosy-4140-schematic-type-re-organization-and-diagram-optimizationsfrom
Conversation
…mizations' of https://github.com/synnaxlabs/synnax into sy-3833-strongly-type-schematics-v2
…3-strongly-type-schematics-v2
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## sy-4140-schematic-type-re-organization-and-diagram-optimizations #2283 +/- ##
====================================================================================================
- Coverage 64.20% 64.10% -0.11%
====================================================================================================
Files 2187 2200 +13
Lines 110644 111735 +1091
Branches 8357 8360 +3
====================================================================================================
+ Hits 71042 71628 +586
- Misses 33497 33909 +412
- Partials 6105 6198 +93
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:
|
…mizations' of https://github.com/synnaxlabs/synnax into sy-3833-strongly-type-schematics-v2
…mizations' of https://github.com/synnaxlabs/synnax into sy-3833-strongly-type-schematics-v2
…3-strongly-type-schematics-v2
…mizations' of https://github.com/synnaxlabs/synnax into sy-3833-strongly-type-schematics-v2
…mizations' of https://github.com/synnaxlabs/synnax into sy-3833-strongly-type-schematics-v2
…mizations' of https://github.com/synnaxlabs/synnax into sy-3833-strongly-type-schematics-v2
Regenerated via UPDATE_MIGRATED=1 to absorb json.MarshalIndent's array formatting changes. Drift is pure formatting (short numeric and string arrays now expand onto multiple lines); no migration behavior change.
Switch the assertMigrated golden-file check from string equality on json.MarshalIndent output to gomega.MatchJSON, which unmarshals both sides and compares the structures. Lets prettier own the on-disk format of the testdata files independently of Go's JSON formatter. Reformats the four migrated.json fixtures with prettier.
- ZERO_LEGEND in client/schematic/client.ts: add px units to position so sticky.toCSS doesn't fall back to the percent path and render the legend at 5000%. - useLoadRemote in console/schematic/Schematic.tsx: include remoteCreated: true in the action payload so the sync component doesn't re-create an already-existing schematic on every server push. - Schematic.create call sites in services/ontology.tsx (×2), services/link.ts, workspace/services/ontology.tsx, and range/overview/Snapshots.tsx: pass remoteCreated: true when spreading a server Schematic to avoid the same redundant re-create.
Same fix as the other Schematic.create call sites. The wire-type Schematic has no remoteCreated field, so spreading it leaves the flag at ZERO_STATE.remoteCreated = false, which then triggers a redundant client.schematics.create on the next sync.
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-3833
Description
This is the next split in the SY-3833 schematic strong-typing series. It moves the schematic from an opaque
data: recordblob into a fully typed shape on the server (Legend,Node,Edgewith nestedHandle,EdgeProps, structuredprops/legend/authority), and brings server-side migration support to parity with what the console already has.Highlights:
schemas/schematic.oraclerewritten as the strongly-typed shape; client TS, Go, and protobuf types regenerate from it. Console v6 state types now alias the oracle-generatednodeZ/edgeZ/legendZ/edgePropsZ/handleZ/segmentZso the wire format and console state can never drift.core/pkg/service/schematic/migrations/legacy/v0..v5/. Each version owns its ownLiftstep that decodes the blob if its own version matches, otherwise recurses into the predecessor. The top-levelMigrateSchematicis a normal typed-to-typed step (AutoMigrateSchematicfor gorp-entry fields + a single inline projection fromv5.Datato the typed body).v55_lift_typed_schematicwired into the gorpMigrationsslice (sequenced aftermsgpack_to_orc) so existing clusters lift their stored schematics on first read after the upgrade.oracle/plugin/go/:make(map[string]msgpack.EncodedJSON, n)formap<string, record>fields (was emittinginterface{}).recordviastructpb.NewStruct/AsMap, struct values via per-elementXToPB/XFromPB, with a newMapValueConversion.{Forward,Backward}HasErrortemplate branch for error-returning conversions.int16/uint16cases to the primitive-conversion table soint16?fields round-trip through proto'sint32.msgpack.EncodedJSON{...}literals forrecordso generated codec tests compile.SetData(ctx, key, Schematic)now takes a typed body, preservesKeyandNamefrom the existing entry, and refuses snapshot edits. The TS client (SetDataBody) and console call sites (Schematic.tsx,services/link.ts,services/ontology.tsx,range/overview/Snapshots.tsx,workspace/services/ontology.tsx,export.ts) project console state into the typed shape directly.applyEdgeChangesnow initializesprops[edge.key] = {}on every add so newly-drawn edges always have a parseable EdgeProps entry. Selectors (selectNodeProps,selectElementProps,selectEdgeProps) safe-parse against the loose props record and returnundefinedon absence/mismatch instead of throwing.Node.measureddropped (pluto re-measures at render time; storing it server-side was dead weight).Node.z_indexisint16?(right-sized, optional to match v0 wire format).EdgeProps.variantuses@validate default "pipe",EdgeProps.segmentsdefaults to[], soedgePropsZ.parse({})produces valid defaults — used both at edge-add time and during the v5→v6 lift.Test coverage: 25 schematic specs + 2 v55 gorp e2e specs + 26 symbol specs all pass; per-version legacy migration tests exercise the v0→v5 chain through realistic blob fixtures.
Basic Readiness
Greptile Summary
This PR strongly-types the server-side schematic from an opaque
data: recordblob into a fully structuredLegend,Node,Edge,EdgeProps, andHandleschema, generated fromschematic.oracle. It also adds a full v0→v6 server-side migration chain (MigrateSchematic), wires av55_lift_typed_schematicgorp migration, and updates the TypeScript console/client to project directly against the new typed shape rather than spreading an untypeddatabag. Previously flagged issues (duplicatemigrateLegendColors, missingunitsinZERO_LEGEND, ZIndex cast, nil Colors/Props maps,Snapshotoverwrite,remoteCreatedomissions) all appear resolved in this revision.Confidence Score: 5/5
Safe to merge — all previously flagged P0/P1 issues are resolved in this revision.
All P0/P1 issues from prior review rounds (duplicate migrateLegendColors compile error, missing units in ZERO_LEGEND, ZIndex int16/int32 cast, nil Colors and Props map serialisation, Snapshot overwrite in SetData, remoteCreated omissions across call sites) are addressed. Migration chain is well-tested with per-version fixture data. No new P0/P1 issues found.
No files require special attention. The v6.ts stateMigration legend fallback (spreading undefined when state.legend is absent) is a known pre-existing edge case already noted in prior threads.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Console participant TSClient as TS Client participant API as Go API participant Writer participant GorpTable as Gorp Table participant Migration as v55 Migration Note over GorpTable,Migration: First read after upgrade GorpTable->>Migration: msgpack_to_orc (codec change) Migration->>Migration: v55_lift_typed_schematic Migration->>Migration: legacy.MigrateData (v0→v5 chain) Migration->>Migration: MigrateSchematic (v5→typed Schematic) Migration-->>GorpTable: Schematic{Nodes, Edges, Props, Legend} Note over Console,API: Create / Sync flow Console->>TSClient: schematics.create({nodes, edges, props, legend, ...}) TSClient->>API: POST /schematic/create API->>Writer: Create(ctx, ws, &Schematic) Writer-->>GorpTable: Store typed Schematic Note over Console,API: SetData flow Console->>TSClient: schematics.setData(key, SetDataBody) TSClient->>API: POST /schematic/set-data API->>Writer: SetData(ctx, key, Schematic) Writer->>Writer: preserve Key, Name, Snapshot Writer-->>GorpTable: Updated Schematic Note over Console,API: Retrieve flow GorpTable-->>API: Schematic{Nodes, Edges, Props, Legend} API-->>TSClient: schematicZ-validated response TSClient-->>Console: Schematic (typed) Console->>Console: internalCreate({...ZERO_STATE, ...v, remoteCreated:true})Comments Outside Diff (2)
console/src/schematic/types/v6.ts, line 157-167 (link)migrateLegendColorsdeclaration — compile errormigrateLegendColorsis declared twice as aconstin the same module scope (lines 145 and 157). TypeScript will reject this withCannot redeclare block-scoped variable 'migrateLegendColors', preventing the console from building. The second declaration (returningLegendState["colors"]) is the old version that should have been removed when the type was updated to useLegend["colors"].client/ts/src/schematic/client.ts, line 156-160 (link)ZERO_LEGENDposition renders at5000%when units absentZERO_LEGEND.positionis{ x: 50, y: 50 }with nounits. The sticky-XY renderer atx/ts/src/spatial/sticky/sticky.tsinterprets missing units as decimal fractions:${pos.x * 100}%→5000%. Any schematic created viaZERO_NEW(which embeds this legend) will have its legend rendered far outside the viewport.The v6.ts internal
ZERO_LEGENDcorrectly usesunits: { x: "px", y: "px" }to anchor the legend at 50 px. The same units must be set here so the two defaults remain consistent.Reviews (10): Last reviewed commit: "SY-3833: Set remoteCreated on navigateTo..." | Re-trigger Greptile