Automattic / Automattic/cortext
Sync collection schemas (collection + field entities)
- Dominant language
- JavaScript
- Stars
- 51
- Forks
- 2
- Avg merge
- 3h 12m
- Merged PRs (30d)
- 8
Description
## Depends on
* #164 (spike)
## Goal
Adding, removing, reordering, or renaming fields preserves co-editors' concurrent changes.
Cortext's schema splits across two entities. The collection holds the ordered list of field IDs in `fields` post meta (`Collection.php:64`); each field's attributes live on its own `crtxt_field` post (`Field.php:55`). Concurrent edits to different fields touch different posts, so they don't conflict. The only piece that might need custom handling is the `fields` ordering on the collection, and we verify before we write that code.
## Scope (locks in after the spike)
* Register `_crdt_document` meta on `crtxt_collection` and `crtxt_field`.
* For `crtxt_field`: rely on the auto-applied post-type config or a flat-meta config (decided by spike).
* For `crtxt_collection`: first verify whether core's default meta merge preserves concurrent reorder, add, and remove on the `fields` multi-value meta. If yes, no custom code. Only if core's default loses or reorders inserts under concurrent edits, write a small custom `SyncConfig` (about 30-50 lines) that handles `fields` as `Y.Array`. Other meta stays flat. Don't embed field attributes; they live on `crtxt_field`.
## Acceptance
* Two editors each adding a new field both keep their fields, with the order preserved.
* Renaming a field by one editor while another changes its type produces the merged result.
* Reordering fields on one client appears on the other after the polling interval.
* Playwright test covers the concurrent-add and reorder paths.
---
*This issue is the result of a guided back and forth between Opus 4.7 and GPT 5.5.*
Contributor guide
Research direction
Read spike #164 first, then inspect Collection.php:64 and Field.php:55 to understand the collection fields meta and field entities. Verify how the existing sync configuration handles the collection's multi-value fields meta before deciding whether custom handling is needed. Add the Playwright coverage for concurrent adds and reordering, and use the stated acceptance cases as the definition of done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php, playwright
- Domain
- backend, distributed-systems, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100