fix(settings): reduce settings desync — single source of truth + atomic writes - #249
Open
pnewsam wants to merge 2 commits into
Open
fix(settings): reduce settings desync — single source of truth + atomic writes#249pnewsam wants to merge 2 commits into
pnewsam wants to merge 2 commits into
Conversation
…rmalization (ENG-1125) Server foundation for the ENG-941 settings-CRUD refactor (PR1). Collapses the duplicated pieces of the settings contract into single definitions on/near UserSettings so the client can stop restating them in copies that drift. - Add SETTING_ENV_ALIASES + ENV_ALIAS_TO_SETTING: one canonical .env<->DB key map. migrations._ENV_TO_SETTING now derives from it instead of keeping a hand-maintained copy (the client's syncSettings.ts copy had already drifted, silently omitting gemini/openai-compatible/router/memory/act_first/etc.). - Add normalize_provider_value(): one home for the hyphen->underscore + minds_cloud detection previously reimplemented in migrations, syncSettings.ts, and settingsTransform.js. migrations._normalize_provider_value now delegates to it. - Parity tests so future drift between the alias map, the model, and the migration fails CI (incl. pinning the canonical show_dots default that the client had wrong). Client consumes the existing GET /settings/ (already returns every field's resolved default + options), so no new endpoint is added — the single source is the server the client already talks to. No storage or auth change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Server half of the ENG-941 settings-CRUD refactor (PR2). Two write-honesty fixes.
Atomic saves: add PUT /settings (bulk), backed by SettingService.save_all, which
validates every key and writes them in one transaction — all-or-nothing. The
Settings form will move onto this from the per-key PUT /{key} loop, which could
leave the DB half-written when one key in a logical save failed. Extracts a
shared _encode_for_store/_write_row helper so upsert_setting and save_all share
one encode path.
No silent write on test: POST /test-providers no longer persists provider_status.
A "test" is a read; persisting it made a stale green dot outlive a revoked key or
a drained wallet and still read as passing (ENG-335). Callers render the returned
results directly.
No storage or auth change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 28, 2026
No PR environment for this pull requestAdd the Updated on every push to this PR. |
pnewsam
marked this pull request as ready for review
July 29, 2026 00:26
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.
Description
Saving user settings has been a source of many bugs. We've applied many patches but there are some root causes that have gone unaddressed, as described in ENG-941. This makes a first pass at improving some of the settings code design.
This PR is paired with the frontend PR. It includes two changes:
UserSettings; parity tests fail CI if they drift again.PUT /settingswhich writes all keys in an all-or-nothing transaction, to prevent partial writesPOST /test-providers, so that it's read-only (note: a stored green dot could outlive a revoked key or drained wallet)References