fix(store,chunkcodec): add relation entity support to cloud sync pipeline#329
fix(store,chunkcodec): add relation entity support to cloud sync pipeline#329parraletz wants to merge 5 commits intoGentleman-Programming:mainfrom
Conversation
…ir pipeline - Add SyncEntityRelation to supported legacy entities in evaluateCloudUpgradeLegacyMutationTx. - Implement full case SyncEntityRelation with decode, field inference from memory_relations, missing-field validation, and repairable/canonicalization logic. - Add unit test for relation legacy mutation repair from authoritative local state. This fixes cloud sync being blocked by upgrade_blocked_legacy_mutation_manual: unsupported legacy mutation "relation"/"upsert" when relation mutations are pending for a project.
…alizer - Add SyncEntityRelation to validateSupportedMutation. - Add mutationRelationPayload struct matching syncRelationPayload wire format. - Add case SyncEntityRelation in normalizeMutationPayload with decode, required-field validation (source_id, target_id, relation, judgment_status, created_at, updated_at), and project canonicalization. - Add unit tests for relation upsert (project rewrite), missing required fields rejection, and relation delete. This fixes the client-side chunk export failing with canonicalize cloud chunk: unsupported mutation "relation"/"upsert".
|
The fix for cloud sync being blocked by relation mutations is ready for review in PR #329. It links the approved issue #313 and includes regression coverage for both the legacy mutation evaluator and the chunk codec canonicalizer. Manual end-to-end verification was also completed successfully. Could you please add the |
There was a problem hiding this comment.
Pull request overview
This PR fixes cloud sync being blocked by legacy relation mutations by adding SyncEntityRelation support to both the legacy-mutation upgrade evaluator (preflight/repair) and the cloud chunk canonicalizer, along with unit tests covering the new paths.
Changes:
- Extend legacy cloud-upgrade mutation evaluation/repair logic to handle
relationupserts/deletes. - Extend chunk canonicalization/validation to accept and normalize
relationmutations (including project rewrite). - Add focused unit tests for relation mutation repair and chunk canonicalization behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/store/store.go | Adds relation to supported legacy entities and implements relation payload decode/repair/validation in the upgrade evaluator. |
| internal/store/store_test.go | Adds a regression test ensuring malformed legacy relation payloads can be repaired from local state. |
| internal/cloud/chunkcodec/chunkcodec.go | Adds relation to supported mutations and normalizes relation payloads (required fields + project canonicalization). |
| internal/cloud/chunkcodec/chunkcodec_test.go | Adds tests for relation upsert (project rewrite), missing required fields rejection, and relation delete. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use mutation.Project as authoritative fallback for body.Project instead of local.Project (memory_relations has no project column). - Remove ifnull(..., "") wrappers from nullable columns (marked_by_actor, marked_by_kind, marked_by_model, session_id) in the memory_relations query so NULL stays nil in *string pointers instead of becoming non-nil empty strings.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Probé contra una DB con el bug real (3 mutations relation/upsert atascadas bloqueando sync). Cliente, OK:
Server, me trabé:
O sea, el fix funciona end-to-end siempre que cliente + server cloud estén ambos en el binario con el PR. Si solo se sube el cliente, los push con relation/upsert vuelven con 400. Sugerencia: dejar nota en release sobre upgrade simultáneo cliente+server. O que el server haga back-compat durante una versión intermedia (acepte y haga skip de relation mutations, en vez de 400). Bonus, el handler de error con sugerencias de recovery está muy útil: |
Linked Issue
Closes #313
PR Type
type:bug— Bug fixSummary
SyncEntityRelationto the legacy mutation evaluator so relation mutations are no longer classified as manual-action-required blockers during cloud sync preflight.SyncEntityRelationto the chunk codec canonicalizer so relation payloads can be exported in push chunks.cloudserverdelegates chunk validation to the samechunkcodecpackage.Changes
internal/store/store.goSyncEntityRelationto supported legacy entities; added fullcase SyncEntityRelation:inevaluateCloudUpgradeLegacyMutationTxwith decode + local-state inference + validation + repairable classification.internal/store/store_test.golegacy relation mutation required fields are detected and repaired from authoritative local statesubtest.internal/cloud/chunkcodec/chunkcodec.goSyncEntityRelationtovalidateSupportedMutation; addedmutationRelationPayloadstruct; addedcase SyncEntityRelationinnormalizeMutationPayloadwith required-field validation and project canonicalization.internal/cloud/chunkcodec/chunkcodec_test.goTest Plan
go test ./...go test ./internal/store -run TestUpgradeRepairDryRunAndApply -vgo test ./internal/cloud/chunkcodec -vengram cloud upgrade doctor --project addi-challenge→status: readyengram cloud upgrade repair --project addi-challenge --apply→applied: trueengram sync --cloud --project addi-challenge→Cloud sync complete(53 mutations exported)Notes for Reviewers
cloudserver.gocallschunkcodec.CanonicalizeForProject, which now accepts relation mutations.syncRelationPayloadalready existed (Phase 2 wire format); this change only bridges it into the cloud sync export/repair paths.