Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

docs(settings): document version-bump reconciliation contract (#4869)

LearningCircuit3d7913782f9e
diff --git a/src/local_deep_research/settings/manager.py b/src/local_deep_research/settings/manager.py
index 406b5c8a22..502805ab90 100644
--- a/src/local_deep_research/settings/manager.py
+++ b/src/local_deep_research/settings/manager.py
@@ -887,7 +887,21 @@ class SettingsManager(ISettingsManager):
f"category={setting.category})"
)
- # Override default with database value
+ # Override the default with the full database row — value AND
+ # schema (options, description, name, constraints).
+ #
+ # This is deliberate, not a bug: the DB row is a self-contained
+ # snapshot. Schema is NOT read live from JSON on every call; it is
+ # reconciled from the JSON defaults only at version bump, via
+ # `import_settings(overwrite=False)` (see `load_from_defaults_file`
+ # and its callers in `database/initialize.py` and post-login in
+ # `web/auth/routes.py`). Every release bumps the package version, so
+ # JSON metadata changes reach a user on their next login after
+ # upgrade. Do NOT change this to overlay defaults schema on every
+ # read — it bypasses that version gate and breaks the snapshot
+ # invariant (clean export/import round-trip, no mid-session drift).
+ # See closed PR #2474 for the rejected schema/value-separation
+ # approach and the reasoning.
result[str(setting.key)] = {
"value": setting.value,
"type": setting_type,
@@ -1219,12 +1233,23 @@ class SettingsManager(ISettingsManager):
raise RuntimeError("Database session is not initialized")
logger.debug(f"Importing {len(settings_data)} settings")
+ # `overwrite=False` is the version-bump reconciliation point: this is
+ # the ONE place where JSON-defined schema (options, description,
+ # constraints) refreshes into the DB rows while the user's chosen value
+ # is preserved. `load_from_defaults_file(overwrite=False)` runs here on
+ # version mismatch. Because each row is fully recreated from
+ # `settings_data` below, all schema fields come from the JSON defaults;
+ # only the existing value is carried over. `get_all_settings()` then
+ # serves that snapshot verbatim — it does not re-read JSON per call.
+ # This is why metadata edits surface at version bump, by design; see
+ # the note at `get_all_settings()` and closed PR #2474.
for key, setting_values in settings_data.items():
setting_values = dict(setting_values)
if not overwrite:
existing_value = self.get_setting(key)
if existing_value is not None:
- # Preserve the value from this setting.
+ # Preserve the user's value; everything else (schema) is
+ # taken fresh from `setting_values` (the JSON defaults).
setting_values["value"] = existing_value
# Delete any existing setting so we can completely overwrite it.