Phase 5: CloudKit CRUD - 2 plans created - 4 total tasks defined - Ready for execution Plan 05-01: Smart sync with change detection - Change detection with diff reporting - Differential sync (upload only changed records) Plan 05-02: Verification and record management - Sync verification (CloudKit vs local comparison) - Individual record CRUD operations Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5.5 KiB
phase, plan, type, domain
| phase | plan | type | domain |
|---|---|---|---|
| 05-cloudkit-crud | 02 | execute | data-pipeline |
Purpose: Enable verification that CloudKit matches local data, plus ability to manage individual records. Output: Enhanced cloudkit_import.py with --verify, --get, --update-record, and --delete-record flags.
<execution_context> ~/.claude/get-shit-done/workflows/execute-phase.md ~/.claude/get-shit-done/templates/summary.md </execution_context>
@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/05-cloudkit-crud/05-01-PLAN.mdRelevant source files: @Scripts/cloudkit_import.py
Tech stack available: Python 3, requests, cryptography, CloudKit server-to-server API Established patterns: query_all() for full record retrieval, compute_diff() for change detection, sync_diff() for smart sync
Prior plan context:
- Plan 05-01 adds change detection and smart sync
- query_all() returns dict of recordName -> record data
- compute_diff() identifies new/updated/unchanged/deleted
-
Add
--verifyflag to argparse:- Query CloudKit for all record types
- Compare counts with local data
- Report discrepancies
-
Add
verify_sync(ck, data_dir, verbose)function:- For each record type (Stadium, Team, Game, LeagueStructure, TeamAlias, StadiumAlias):
- Query CloudKit count
- Get local count from JSON files
- Compare and report
- Output format per type:
Stadium: CloudKit=32, Local=32 [OK] Game: CloudKit=5758, Local=5760 [MISMATCH: 2 missing in CloudKit]
- For each record type (Stadium, Team, Game, LeagueStructure, TeamAlias, StadiumAlias):
-
Add spot-check verification:
- Random sample 5 records per type (if count matches)
- Verify field values match between CloudKit and local
- Report any field mismatches found
-
Add
--verify-deepflag:- Full field-by-field comparison of ALL records (not just sample)
- Report each mismatch with recordName and field name
- Warning: "Deep verification may take several minutes for large datasets"
-
Menu integration:
- Add option 14: "Verify sync (quick)"
- Add option 15: "Verify sync (deep)"
Avoid: Modifying any data during verification. This is read-only.
cd Scripts && python cloudkit_import.py --verify --verbose
Should output verification report showing CloudKit vs local counts with OK/MISMATCH status. --verify flag reports accurate comparison between CloudKit and local data for all record types
Task 2: Add individual record management commands Scripts/cloudkit_import.py Add commands for managing individual records by ID.-
Add
--get <type> <id>flag:- Query single record by recordName
- Print all field values in formatted output
- Example:
--get Stadium stadium_nba_td_garden
-
Add CloudKit
lookup(record_names)method:- Use records/lookup endpoint for efficient single/batch lookup
- Return list of records
-
Add
--update-record <type> <id> <field>=<value>flag:- Lookup record to get current recordChangeTag
- Update specified field(s)
- Handle CONFLICT error with retry
- Example:
--update-record Stadium stadium_nba_td_garden capacity=19156
-
Add
--delete-record <type> <id>flag:- Lookup record to get recordChangeTag
- Delete single record
- Confirm before delete (unless --force)
- Example:
--delete-record Game game_mlb_2025_ari_phi_0401
-
Add
--list <type>flag:- Query all records of type
- Print recordNames (one per line)
- Support
--list <type> --countfor just the count - Example:
--list Stadiumprints all stadium IDs
-
Error handling:
- Record not found: "Error: No Stadium with id 'xyz' found in CloudKit"
- Invalid type: "Error: Unknown record type 'Foo'. Valid types: Stadium, Team, Game, ..."
Avoid: Deleting records without confirmation. Updating records without checking conflict.
cd Scripts && python cloudkit_import.py --get Stadium stadium_nba_td_garden
Should print all fields for the specified stadium record.
cd Scripts && python cloudkit_import.py --list Game --count
Should print the count of Game records in CloudKit. Individual record management commands work: --get, --list, --update-record, --delete-record
Before declaring plan complete: - [ ] `--verify` reports accurate count comparison for all record types - [ ] `--verify-deep` performs full field comparison with mismatch reporting - [ ] `--get ` retrieves and displays single record - [ ] `--list ` lists all recordNames for type - [ ] `--update-record` updates field with conflict handling - [ ] `--delete-record` deletes with confirmation - [ ] Interactive menu has options 14-15 - [ ] No regressions to existing functionality<success_criteria>
- Verification accurately detects sync discrepancies
- Individual record operations work for all record types
- Conflict handling prevents data corruption
- All CRUD operations now fully supported
- Phase 5 complete </success_criteria>