Add confirmed zone metadata (syncToken, atomic) to zone schemas - #427
Add confirmed zone metadata (syncToken, atomic) to zone schemas#427leogdion wants to merge 5 commits into
Conversation
Adds two project memory files plus their MEMORY.md index entries: - project_beta4_worktree_layout: the branch/worktree split for the remaining v1.0.0-beta.4 issues, the grouping rule (shared openapi.yaml path family => shared branch, to avoid Sources/MistKitOpenAPI/ regeneration collisions), and why #407 was excluded. - project_419_fixed_in_beta3: #419 is already fixed by 5a58120 and verified building on macOS Swift 6.3.2; do not re-implement. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
All four zone responses (`zones/list`, `zones/lookup`, `zones/modify`,
`zones/changes`) modeled a zone as just `{ zoneID }`. Introduce a shared
`Zone` schema in `openapi.yaml` carrying the metadata Apple's archived
"Zone Dictionary" documents, and surface it on the domain `ZoneInfo`.
Only fields confirmed against a primary source are encoded:
- `syncToken` — "The current point in the zone's change history."
- `atomic` — "A Boolean value indicating whether this zone supports
atomic operations."
Both verified against Apple's archived CloudKit Web Services Reference
"Zone Dictionary" (Types.html), which documents exactly three keys:
`zoneID`, `syncToken`, `atomic`.
Deliberately NOT implemented, because no primary source confirms them:
- `isEager` — appears in neither the archived reference nor the local
CloudKit JS docs.
- `atomic` on the `zones/modify` request — Apple documents the request
body as `operations` only.
- zone create options on `ZoneOperation` — Apple documents the
operation's `zone` as having "a single `zoneID` key".
`ZoneInfo.atomic` is `Bool?` rather than defaulting to `false` so an
absent key stays distinguishable from an explicit `false`. Both new
properties are added with defaulted initializer parameters, keeping the
existing public initializer source-compatible.
Refs #386
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Captures the primary-source verification done for #386: the Zone Dictionary has exactly three keys, and isEager / modify-request `atomic` / zone create options do not exist in any Apple source. Also records the unresolved metaSyncToken discrepancy on zones/changes so it isn't re-investigated from scratch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Review: #427 — Add confirmed zone metadata (syncToken, atomic) to zone schemas Overall this is a clean, well-scoped change. The PR description's source-verification work (Zone Dictionary vs. Code quality / correctness
Test coverage — one gap worth flagging However, none of the existing Also pre-existing (not introduced by this PR, but adjacent): Scope note Security / performance Nothing here blocks merging; the missing end-to-end assertions are the only actionable item. |
Review: Add confirmed zone metadata (syncToken, atomic) to zone schemasSolid, well-scoped PR. The verification-against-primary-sources approach (confirming Code quality
Test coverageGood breadth — all four response shapes, zone-level vs. response-level Minor nit
Process concern (not a code issue in this PR itself)
Security / performanceNo concerns — this is a response-schema addition with no new network surface, no untrusted-input parsing beyond what already existed, and no hot-path changes. Nice work overall — the "verify against primary source, omit what isn't confirmed" discipline here is a good pattern to keep using on the remaining beta.4 issues. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.0.0-beta.4 #427 +/- ##
================================================
Coverage ? 76.45%
================================================
Files ? 158
Lines ? 3771
Branches ? 0
================================================
Hits ? 2883
Misses ? 888
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| /// Convert a CloudKit `Zone` payload into a `ZoneInfo`, carrying the | ||
| /// zone-level metadata (`syncToken`, `atomic`) alongside the identity. | ||
| internal init(from zone: Components.Schemas.Zone) throws(ConversionError) { |
There was a problem hiding this comment.
instead of (from zone:) make this (zone: )
| /// boundary instead. | ||
| internal init(fromZoneID zoneID: Components.Schemas.ZoneID?) throws(ConversionError) { | ||
| internal init( | ||
| fromZoneID zoneID: Components.Schemas.ZoneID?, |
There was a problem hiding this comment.
remove fromZoneID and just do zoneID
Print the new ZoneInfo metadata fields from list/lookup/create CLI and verbose zone integration phases so zone schema changes are testable. Co-authored-by: Cursor <cursoragent@cursor.com>
ReviewReviewed the diff for PR #427 ( Code quality / best practices
Potential bugs / issues
PerformanceNo concerns — this only adds two optional scalar fields to an existing decode path; no new network calls, loops, or allocation patterns. SecurityNo concerns — no new external input handling beyond what already existed (decoding additional optional fields from an already-trusted CloudKit response). Test coverageStrong. New tests cover:
One gap: no test exercises the actual Minor / non-blocking
Nothing here blocks merging — the scope discipline (explicitly declining |
Summary
Every zone response modeled a zone as just
{ zoneID }. This adds a sharedZoneschema inopenapi.yaml— reused byZonesListResponse,ZonesLookupResponse,ZonesModifyResponse, andZoneChangesResponse— carrying the zone metadata that Apple actually documents, and surfaces it on the domainZoneInfo.The issue flagged these field names as unverified, and verification changed the scope. Only two of the three proposed response fields exist in a primary source, and neither of the two proposed request changes does. I implemented the confirmed subset and left the rest out rather than guessing.
Verification against primary sources
Verified against Apple's archived CloudKit Web Services Reference (
.claude/docs/webservices.mdis abbreviated on zone payloads and confirms none of these, per.claude/memory/reference_cloudkit_archived_endpoints.md).✅ CONFIRMED — implemented
zoneIDsyncTokenatomicThe Zone Dictionary documents exactly these three keys — no more. All four zone endpoints route their success payload through it: zones/list, zones/lookup, zones/modify, zones/changes — each says "If successful, the result dictionary contains the keys described in Zone Dictionary."
❌ NOT CONFIRMED — deliberately omitted
isEageron zone responsesgrep -i isEagerover.claude/docs/webservices.md+.claude/docs/cloudkitjs.mdreturns nothing. No basis to encode a name or type.atomicon thezones/modifyrequestoperationsonly ("This key is required"), with noatomickey. Contrastrecords/modify, which does documentatomic— the asymmetry looks deliberate.ZoneOperationzoneas "A dictionary representing the zone to modify. It has a singlezoneIDkey." No room for create options.A regression test (
ZoneOperation encodes only operationType and zoneID) pins the request shape so create options can't be added back accidentally without a doc update.Incidental findings (not acted on — filed as an issue comment)
zones/changesis documented as deprecated in favor ofchanges/database.metaSyncToken, in both request and response — MistKit currently sends/readssyncToken. Left alone: out of scope, and Apple's own page is internally inconsistent (themoreComingdescription refers back to "the includedsyncTokenkey"), so this needs a live-response check rather than a doc-driven change.Changes
openapi.yaml— new sharedZoneschema; all four zone responses now$refit.Sources/MistKitOpenAPI/Types.swiftvia./Scripts/generate-openapi.sh(not hand-edited). The four inline anonymous zone structs collapse into oneComponents.Schemas.Zone, which is why that file shows net deletions.ZoneInfo— addssyncToken: String?andatomic: Bool?, plus aninit(from: Components.Schemas.Zone)conversion.CloudKitService+ZoneOperations.swift,CloudKitService+ModifyZones.swift,ZoneChangesResult.swift— converted through the new initializer so metadata reaches callers.AGENTS.md(symlinked asCLAUDE.md) — Result Types entry forZoneInfoplus a zone-metadata section recording what is confirmed and what must not be added speculatively.Design note
atomicisBool?, not defaulted tofalse— an absent key stays distinguishable from an explicitfalse. Same forsyncToken. Note the per-zonesyncTokenis distinct from the response-levelsyncTokenonZoneChangesResult; a test pins both.Source compatibility
No breaks. Both
ZoneInfoproperties are added with defaulted initializer parameters, so the existinginit(zoneName:ownerRecordName:capabilities:)still compiles.modifyZonesgained no parameters — the proposedatomic:flag was unconfirmed, so the signature is untouched.ZoneInfois astructwith a memberwise-style public init, so adding stored properties is additive here.Out of scope: RecordResult pattern
Per
.claude/memory/feedback_record_result_pattern_throughout.md, per-item modify failures should surface via theRecordResultpattern for zones too.modifyZonesdoes not do this today — it returns[ZoneInfo]and silently drops errored entries, exactly the gap that memory describes. Apple documents a "Zone Fetch Error Dictionary" (zoneID,reason,serverErrorCode,retryAfter,redirectURL) returned inline for failed zones inzones/list,zones/lookup, andzones/modify.Fixing it means a
ZoneOperationFailureschema, aoneOfresponse, and changingmodifyZones' return type — a real source break and a distinct piece of work from this schema enrichment. Filed separately rather than folded in here.Verification
All run locally in the worktree:
swift build— ✅ cleanswift test— ✅ 560 tests in 176 suites passed (10 new)mise exec -- swift-format -i -r Sources/ Tests/— ✅ applied./Scripts/lint.sh— ✅ 0 violations in 393 files, periphery reports no unused code. (One pre-existing swift-format warning inCloudKitService+BatchChunking.swift, a file this PR does not touch.)Examples/MistDemoswift build— ✅ clean (API shape changed, so verified)New tests cover:
Zonepayload decoding,ZoneInfometadata carry-through, absent-stays-nil,atomic: falsepreservation, the existing missing-zoneNamethrow path, decoding across all four response types, zone-level vs response-levelsyncToken, and theZoneOperationrequest shape.Closes #386
🤖 Generated with Claude Code