Repository navigation
Description
Problem
FieldValue.list([FieldValue]) (Sources/MistKit/Models/FieldValues/FieldValue.swift:42) can hold mixed element types and arbitrary nesting. CloudKit cannot represent either.
The CloudKit schema grammar is LIST<primitive-type> (.claude/docs/cloudkit-schema-reference.md:48-57): a list is homogeneous, and its element must be a scalar primitive. There is no LIST<LIST<…>>.
So both of these compile, and both are rejected by the server with BAD_REQUEST:
.list([.string("a"), .int64(1)]) // heterogeneous
.list([.list([.string("a")])]) // nestedThe domain type is wider than the API it models, and the gap is only discovered on a live write.
The invariant is already assumed in three places
Each of these works around the missing type guarantee rather than relying on it:
-
FilterBuilder.cloudKitListType(for:)(Sources/MistKit/Models/Queries/FilterBuilder/FilterBuilder.swift:170-203) derives the*_LISTrequest tag fromvalues.firstonly — remaining elements are assumed to match, unchecked. It also returnsnilfor.list, with the comment "Nested lists aren't valid in IN/NOT_IN; omit the type and let CloudKit reject." The invariant is stated in a comment and enforcement is deferred to the server. -
Components.Schemas.FieldValueRequest.init(list:)(Sources/MistKit/OpenAPI/Components/Components.Schemas.FieldValueRequest.swift:130-133) sends lists untagged, so a homogeneous[.date]or[.bytes]list loses the very disambiguation the scalar path is careful to apply (issue FieldValueRequest can't tag scalar TIMESTAMP — Date/Time writes fail with BAD_REQUEST #375). Elements go out shape-only (Components.Schemas.ListValuePayload.swift:45-58). -
Response
LISTtag validation is container-level only —FieldValue+Components.swift:154notes element types "stay lenient," because there is nothing in the type to validate them against.
Proposal
Replace the payload with a homogeneous-by-construction enum:
public enum ListValue: Codable, Equatable, Sendable {
case strings([String])
case int64s([Int])
case doubles([Double])
case bytes([Data])
case dates([Date])
case locations([Location])
case references([Reference])
case assets([Asset])
}
// FieldValue
case list(ListValue)Heterogeneity becomes unrepresentable, and nesting disappears because there is no case lists. The element-type tag becomes total and exact rather than first-element guesswork, which lets FilterBuilder drop its unchecked assumption and lets the request path finally tag TIMESTAMP_LIST / BYTES_LIST correctly.
This matches how the codebase already reasons about the wire: the default-free switches at every conversion boundary exist so the compiler catches unclassified cases. This applies the same instinct one level up.
Why not deprecate the old case
@available(*, deprecated) on an enum case fires on construction but not usefully on pattern matching, so every consumer reading a list keeps compiling silently and keeps getting the old shape. Worse, a deprecated case still counts toward exhaustiveness — we would carry both case list([FieldValue]) and case list(ListValue) under different labels, and every default-free switch (FieldValueRequest.init(from:), ListValuePayload.init(from:), FilterBuilder.cloudKitListType(for:), the response conversions) would have to handle both. That doubles the surface of the mechanism whose exhaustiveness is the load-bearing safety property, to soften a break in a pre-1.0 beta.
It is also the wrong use of the annotation per .claude/memory/feedback_available_semantics.md: deprecated is reserved for symbols that have been replaced. A heterogeneous .list was never a working API — keeping it functional-but-deprecated would tell users "this still works, tidy up later" when a mixed list has never worked against CloudKit and never will.
Break it cleanly. We are pre-1.0; this is the window the beta line exists for. The compiler drives the migration: every construction site and every switch becomes a build error, which is a better experience than an ignorable warning, because the fix is genuinely different code rather than a rename.
Migration plan
- Add
ListValueand changeFieldValue.listto carry it - Update the conversion boundaries:
FieldValue+Components+List.swift,Components.Schemas.ListValuePayload.swift,Components.Schemas.FieldValueRequest.swift - Make
FilterBuilder.cloudKitListType(for:)total onListValue(no morevalues.first, nonilnesting escape hatch) - Tag list requests with the correct
*_LISTtype, closing theTIMESTAMP_LIST/BYTES_LISTgap noted above - Deprecate the accessor, not the case: keep
listValue: [FieldValue]?(FieldValue+Convenience.swift:148) working by flatteningListValueback to[FieldValue], marked@available(*, deprecated)alongside a new typed accessor. This is a genuine replaced-symbol deprecation, and it lets read-only consumers (the MistDemo formatters) compile untouched while write paths migrate. - Add static factory shims for ergonomic continuity where the call site need not change, e.g.
static func list(_ values: [String]) -> FieldValue - Update
Tests/MistKitTests/Models/FieldValues/FieldValueConversionTests+Lists.swift—:44("mixed types") and:83("nested list") currently assert the behavior being removed and must become negative/compile-time cases - Update Examples:
Article+MistKit.swift:119,Feed+MistKit.swift:134(one-liners),RecordInfo+Parsing.swift:160,FieldValueFormatter.swift:57,85 - Update the FieldValue architecture section of
CLAUDE.md -
ReleaseNotes.mdmigration note with before/after for common shapes
Open design questions
- Empty lists.
.strings([])and.int64s([])are distinct values that encode identically on the wire, and the decoder cannot recover an element type from[]. Either add a separatecase empty(cleanEquatable, but every switch grows a case) or accept the asymmetry and document it. AffectsEquatableand round-trip tests. - Naming.
ListValuecollides conceptually with the generatedComponents.Schemas.ListValue/ListValuePayload. ConsiderFieldValue.ListorElementListto keep the domain/wire distinction legible. ASSETID. Response tagASSETIDsharesAssetValuewithASSET(FieldValue+ResponseTypeTag.swift); confirm no separate list case is needed.
Notes
Timing matters: the repo is at v1.0.0-beta.5, so a source-breaking change to a public enum is cheap now and expensive after 1.0.
Activity
research(#481): save empty-list probe harness and blocker notes
leogdion commentedon Sep 9, 2026
Live probe: empty list wire shape (2026-09-09)
Against
iCloud.com.brightdigit.MistDemo/development/ public, S2S.Note.tagsadded asLIST<STRING>in Console.tags: { value: [] }"type":"STRING_LIST","value":[]tags: { value: ["a","b"] }"type":"STRING_LIST","value":["a","b"]Implications for #481:
[]— not absent, not rejected.*_LISTfamily (STRING_LIST), not the flatLISTcurrently modeled onFieldValueResponseinopenapi.yaml. That mismatch is why MistKit currently fails to decode any list response (Cannot initialize _typePayload from invalid String value STRING_LIST).[]still carriesSTRING_LIST, the element type is recoverable on read — socase emptyis not required for honest decode if the response type enum is corrected to the*_LISTfamily. Still useful as a write-side construction for callers who don't care about element type, but not forced by the wire.Harness:
.claude/probes/481-empty-list/.leogdion commentedon Sep 9, 2026
Implementation landed on branch
481-fieldvalue-homogeneous-list(one PR)Domain: each
FieldValuekind carriesArity<T>(.value/.list). Nocase list([FieldValue]). Empty lists are typed (.string(.list([]))).Migration: deprecated scalar factories only (
string(_: String)→.value). No heterogeneous list polyfill.Wire:
FieldValueResponse.typeOpenAPI enum aligned to live*_LISTfamily; list record writes tagged; MistDemoStringListRoundTripPhaseexercisesNote.tagson public + private.Research:
.claude/docs/research/481-homogeneous-list-without-duplicate-enums.mdMake FieldValue lists homogeneous via Arity (#481)
test(#481): cover homogeneous list conversions; gate Win 6.2 tip-over
fix(#481): use Comment literals for Win 6.2 Issue.record stubs
Make FieldValue lists homogeneous via Arity (#481) (#484)
docs: drop duplicate FieldValue list entry from beta.5 notes
v1.0.0 beta.6 (#513)