Skip to content

fix(proxy): refresh takeover backup on hot-switch#295

Merged
SaladDay merged 3 commits into
SaladDay:mainfrom
unive3sal:main
Jun 23, 2026
Merged

fix(proxy): refresh takeover backup on hot-switch#295
SaladDay merged 3 commits into
SaladDay:mainfrom
unive3sal:main

Conversation

@unive3sal

Copy link
Copy Markdown
Collaborator

Refresh the restore backup from the selected provider during takeover hot-switches so disabling proxy restores the provider the user chose instead of the one active when takeover began.

Fixes #292

Refresh the restore backup from the selected provider during takeover hot-switches so disabling proxy restores the provider the user chose instead of the one active when takeover began.
@unive3sal unive3sal requested a review from SaladDay June 22, 2026 15:09
@SaladDay

Copy link
Copy Markdown
Owner

@unive3sal Thanks for the fix. The direction makes sense, but I think this still needs one more pass before merge.

The new backup refresh currently uses a two-way merge from the existing restore backup into the selected provider snapshot. That updates keys that exist in the selected provider, but it does not remove provider-owned keys that only existed on the previous provider.

A concrete case:

  • provider A restore backup has env.ANTHROPIC_API_KEY = a-key, env.ANTHROPIC_BASE_URL = https://a.example, and env.LOCAL_ONLY = kept
  • provider B only has env.ANTHROPIC_API_KEY = b-key
  • hot-switch to provider B

After update_live_backup_from_provider, the restore backup becomes:

{
  "env": {
    "ANTHROPIC_API_KEY": "b-key",
    "ANTHROPIC_BASE_URL": "https://a.example",
    "LOCAL_ONLY": "kept"
  }
}

So disabling proxy would restore provider B's key mixed with provider A's base URL. That still leaves part of #292 unfixed.

I think this needs a base-aware merge: base = previous selected provider snapshot, local = existing restore backup, incoming = newly selected provider snapshot. That would preserve local-only fields like LOCAL_ONLY, while removing old provider-owned fields that the new provider no longer has. Codex TOML likely needs the same stale-key consideration too, not only Claude JSON.

Could you add a regression test for this case? The current tests cover overwriting shared keys and preserving local-only keys, but not removing stale provider-owned keys.

@unive3sal unive3sal self-assigned this Jun 23, 2026
unive3sal and others added 2 commits June 23, 2026 10:48
Use the previous provider snapshot as the merge base when refreshing takeover restore backups so stale provider-owned keys are removed while local-only edits are preserved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SaladDay

Copy link
Copy Markdown
Owner

LGTM, THANKS

@SaladDay SaladDay merged commit 82e9a10 into SaladDay:main Jun 23, 2026
4 checks passed
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.

Claude Code Local configuration does NOT correctly recover

2 participants