📝 design: client-uuid split (T9 follow-up)#2435
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Pull request overview
This PR adds a design document (docs/design/client-uuid-split.md) proposing a follow-up refactor to PR #2433 (T9). It outlines splitting the dual-owned id column on offline-first tables into a server-owned id (PK) and a client-owned clientUuid (idempotency key), with a phased migration plan, sync-plugin rewire sketches, API surface changes, and rollback story.
Changes:
- Adds a ~650-line design doc covering motivation, target schema (
bigserialPK +client_uuid), hybrid migration plan, sync-plugin rewire, API additive changes, and a 6-PR implementation plan. - Documents 8 open questions for the reviewer (Andrew) to resolve before implementation.
- No code changes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Architectural design doc proposing a clean split between server-owned `id` (real PK) and client-owned `clientUuid` (idempotency key for offline-first sync). Walks the codebase to ground the design in current schema, route handlers, and Legend State stores. Covers schema target, migration path (recommends hybrid 2-phase rollout), sync plugin rewire, API surface, FK contract during offline window, rollback story, open questions, and a 6-PR implementation plan. Design only — no code changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bd88349 to
50e7818
Compare
…-split T9 (optional id + server mintId) and T8 (POST /packs/:id/items/from-catalog) proved hacky on a single id column with dual ownership. Per design doc shipped in #2435 (docs/design/client-uuid-split.md), the cleaner pattern is two columns: server-owned `id` (always minted) + client-owned `clientUuid` (idempotency key with UNIQUE(user_id, client_uuid)). Reverting T8/T9 here so #2433 ships only T1-T6 + T10 (lean endpoints + API thickening). The optional-id work is preserved on feat/client-uuid-split for the proper migration. Removed: - packages/api/src/utils/ids.ts (mintId helper) - packages/api/src/routes/packs/index.ts: /:packId/items/from-catalog endpoint, mintId fallbacks - packages/api/src/routes/trips/index.ts: mintId fallback - packages/api/src/routes/trailConditions/reports.ts: mintId fallback, 23505-only-if-data.id branch - packages/mcp/src/tools/packs.ts: add_pack_item_from_catalog tool - packages/schemas/src/packs.ts: AddPackItemFromCatalogBodySchema - packages/schemas/{trips,packs,trailConditions}.ts: id back to z.string() (required) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Design-only PR — no code changes. Adds
docs/design/client-uuid-split.md(~650 lines).Follow-up to PR #2433 (T9: server-side ID minting). T9 made every offline-syncable POST accept an optional
idand mint one server-side when absent, which works but leaves a dual-ownership smell on theidcolumn. This design proposes the cleaner split that Andrew flagged on the T9 PR: server-ownedid(real PK) plus client-ownedclientUuid(idempotency key supplied by offline-first stores).What the doc covers
bigserialover UUIDv7 for the new serverid, with reasoning. Drizzle pseudo-migration per affected table (packs,pack_items,weight_history,trips,pack_templates,pack_template_items,trail_condition_reports).client_uuidalongside existing textid; Phase 2 narrowsidtobigserialonce mobile rollout has drained.apps/expo/features/packs/store/{packs,packItems}.ts. Covers the FK edge (packItems → packs) during the offline window.clientUuidalongsideid, return both). Recommends transition in place, no/v2/prefix.packId(server) andpackClientUuid(local); FK columns server-side referenceid, neverclient_uuid.Review focus
bigserialvs UUIDv7 for the new serverid?syncedCrudactually behaves in practice?Test plan
main🤖 Generated with Claude Code