feat: cross-machine usage aggregation with device-level dedup - #252
feat: cross-machine usage aggregation with device-level dedup#252Yeachan-Heo wants to merge 1 commit into
Conversation
Port device-level tracking from PR junhoyeo#55 into the client-based structure. Each client now tracks per-device contributions (keyed by API token ID) to prevent double-counting when the same user submits from multiple machines. On resubmit, only the device's data is replaced while other devices' data is preserved. Legacy data without device tracking is gracefully migrated to a __legacy__ device key. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@Yeachan-Heo is attempting to deploy a commit to the Inevitable Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/src/lib/db/helpers.ts">
<violation number="1" location="packages/frontend/src/lib/db/helpers.ts:222">
P2: Legacy incoming payloads that only provide modelId (no models) will drop model-level attribution after recalculation because device contributions only copy incomingClient.models. recalculateClientAggregate rebuilds client.models exclusively from device.models, so legacy modelId data is lost.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Hi @Yeachan-Heo — closing this together with #55, with thanks. Detailed context: Main now implements device-level dedup, but with two deliberate design differences from this approach:
The scenarios your 8 tests covered (multi-device aggregation, same-device replace, legacy migration) are all covered by main's submit tests against the relational model, including the savepoint-protected legacy adoption race in #609/#611. Your two PRs were the first to clearly frame the overwrite bug, and that framing shaped the fix — genuinely appreciated. 🙇 |
Summary
feat/cross-machine-aggregation-sync) into the currentclient-based codebase structuredevicesfield keyed by API token ID__legacy__device key on first mergeChanges
helpers.ts: AddedDeviceClientDatainterface,devices?field onClientBreakdownData,recalculateClientAggregatehelper, and updatedmergeClientBreakdownsto acceptdeviceIdand perform device-level merge with legacy migrationroute.ts: INSERT path now initializesdevices[tokenId]from the start; UPDATE path passestokenRecord.tokenIdto the merge functionschema.ts: Addeddevices?to thesourceBreakdownJSONB type definitionsubmit.test.ts: Added 8 new tests covering device-level dedup scenarios (resubmit, multi-device aggregation, legacy migration, device removal, cross-device model aggregation, multi-client multi-device)Test plan
__legacy__🤖 Generated with Claude Code
Summary by cubic
Add per-device usage tracking and dedup to client aggregation to support cross‑machine submissions. Resubmits now replace only that device’s data, preventing double counting and keeping totals accurate.
Written for commit 556afd9. Summary will update on new commits.