Skip to content

feat(hostsync): sync login accounts from the main machine to hosts - #159

Merged
deLiseLINO merged 3 commits into
mainfrom
feat/host-account-sync
Nov 27, 2026
Merged

deLiseLINO merged 3 commits into
mainfrom
feat/host-account-sync

Conversation

@deLiseLINO

Copy link
Copy Markdown
Owner

Why

Login providers (codex, antigravity, cline) synced to a host arrived with models but no accounts, so every request on the host failed with account: account not found. Copying credential files does not work: generations are counted per machine, the host daemon only reads accounts at startup, and codex/cline refresh tokens are one-time, so two machines refreshing the same account invalidate each other.

Scope

  • The main machine now pushes account replicas to hosts inside the sync bundle. Hosts apply them with their own generation counter, compare by content, and update the running pool without a restart.
  • antigravity replicas carry the refresh token, since it does not rotate; hosts refresh them locally and keep working while the main machine is off.
  • codex and cline replicas carry the access token only. Hosts never refresh or delete them; an expired or rejected token returns "waiting for fresh credentials from the main machine".
  • The main machine refreshes codex/cline accounts ahead of expiry and wakes the pusher when credentials change.
  • A host that gets a 401 on a replica reports the sha256 of the rejected token in its edits answer; the main machine renews that account and pushes again.
  • Login providers take the main machine's pinned account and model catalogs for replicas, unless the host pinned an account it logged into itself. A local login on a host is never overwritten.
  • Pause, resume, priority and delete on a replica return 409 managed_by_main.
  • sync-base.json stores no replica data.

Blast Radius

Host sync apply path, refresher, account pool and meta, and the pusher. Hosts on an older version ignore the new bundle fields. The desktop and web UI still show account controls for replicas, which now answer 409.

Verification

  • go build ./... passes.
  • go test ./internal/hostsync/... ./internal/auth/... ./internal/account/... ./internal/daemon/... ./internal/management/... ./internal/provider/... ./internal/config/... ./internal/store/... ./internal/routing/... passes.
  • New tests cover: a host serving a request from a pushed replica; a codex replica on 401 that never calls the token endpoint and is not deleted; a reported rejection that makes the main machine refresh once; delete plus re-login on the main machine still winning on the host; pinned account merge; no tokens in sync-base.json; refresh ahead only while a host has sync on.

Model: claude-opus-5-5

… on hosts

- Mark replica accounts with origin main in account meta; a login on the host takes the account over.
- PublishReplica and DeleteReplica write replicas under the account refresh lock with local generations,
  comparing credentials by content so a re-login on the main machine always wins.
- The refresher never renews an access-only replica, never tears a replica down on invalid_grant,
  and reports a refused replica token; such a replica fails with a wait-for-main-machine error.
- Add RefreshAhead and a Published hook for renewing pushed credentials early.
…hosts

- The push bundle carries a replica of every login account on the main machine; codex and cline
  replicas carry no refresh token, antigravity ones carry the whole credential.
- Hosts apply replicas after rename replay and merge, with explicit pool calls so new, changed,
  paused and removed accounts go live without a restart; local logins are never replaced.
- Login providers take the main pin and replica model catalogs unless the host pinned its own account.
- Hosts report refused replica tokens by hash in the edits answer; the main machine renews them
  before the push. The main machine also renews rotating-grant credentials ahead of expiry and
  pushes on credential changes.
- Replica pause, resume, priority and delete on a host answer 409 managed_by_main.
@deLiseLINO
deLiseLINO merged commit d767922 into main Nov 27, 2026
@deLiseLINO
deLiseLINO deleted the feat/host-account-sync branch November 27, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant