Repository navigation
worker: free plan syncs one device after a free first week (off by default) - #76
Merged
Merged
Conversation
…fault) A free account syncs every device for its first week. After that one device keeps syncing and the others get 403 sync_paused on the data plane and the doorbell, reads included. Paid tiers are never paused. Off unless SYNC_PLAN_GATE=on, so this can deploy before the apps that explain the 403. - accounts.sync_until / sync_device / sync_device_at (migration 0014, the self-host column upgrades, schema.sql) - the kept device is the first to sync after the week; a request with no device id falls back to the most recently seen one - POST /account/sync-device picks it; free accounts switch once a week - GET /account adds sync_until, sync_device, sync_paused - the plan is cached per isolate for a minute to keep D1 off the hot path - OpenAPI 1.4.0 and docs/api.md describe all of it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A free account syncs on every device for its first week. After the week, one device keeps syncing and the others are paused. Paid plans are never paused. The rule ships off (
SYNC_PLAN_GATEunset), so merging and deploying this changes nothing until the apps that explain the pause are out.What it does
403 sync_pausedon the data plane (/relics,/relic/*,/tombstones,/waiting,/keyparams,/ai*,/blob*) and on/sync/socket. Reads are blocked too, because a second device that can still read gets half of sync. Account, device, billing, share and pairing routes stay open.POST /account/sync-devicepicks the kept device. Free accounts can switch once a week, and the first switch after the automatic pick is always allowed. It works with the rule off, too.GET /accountaddssync_until,sync_deviceandsync_paused.accounts.sync_untiloverrides the sign-up week. Launch will use it to give existing two-device users extra time.Schema
Migration
0014_sync_plan.sqladds three nullable columns toaccounts. It's metadata-only, with no backfill. Self-host gets the same columns throughschema-upgrade.ts.Docs
OpenAPI 1.4.0 and
docs/api.md(error model,GET /account, the new route, the tier table).Tests
test/syncplan.test.ts.🤖 Generated with Claude Code