Collaborative Grids Architecture
The Collaborative Grids feature is built on top of CloudKit and Apple's CloudKit Sharing UI. This ensures secure, authenticated, and reliable synchronization across devices.
Network Architecture
Unlike local peer-to-peer solutions, Control It uses a cloud-first approach:
- Storage: Grids are stored in a custom `CollaborativeGridsZone` within your private CloudKit database.
- Sharing: When shared, a `CKShare` record is created, granting access to invited participants.
- Transport: All data transfer occurs over HTTPS to iCloud servers. No direct device-to-device connection is required.
Sync Synchronization
Changes are propagated using CloudKit Subscriptions:
- Push: When you make a change, the app uploads the modified `CKRecord`.
- Notification: CloudKit sends a silent push notification to all other participants.
- Pull: Devices receive the notification and fetch the latest changes in the background.
Conflict Resolution
The system employs a Last Writer Wins (LWW) strategy for conflict resolution.
Scenario
User A and User B edit the same button simultaneously. User A saves first. User B saves milliseconds later.
Outcome
User B's save operation will trigger a "Server Record Changed" error. The app automatically fetches the latest server version (User A's change), re-applies User B's changes on top, and attempts to save again. If the fields overlap, User B's value will persist.
Permissions & Roles
Permissions are managed via the standard CloudKit Share options:
| Permission Level | Capabilities |
|---|---|
| Owner | Full access. Can add/remove users, stop sharing, and delete the grid. |
| Can Make Changes | Can edit, add, or remove actions. Can invite others if allowed by Owner. |
| View Only | Can use the grid (trigger actions) but cannot modify the layout or settings. |