Skip to content

refactor(config): settings resolve in one declared order through pydantic-settings sources - #2518

Merged
dan-petty merged 2 commits into
mainfrom
refactor/2445-settings-sources
Oct 28, 2026
Merged

dan-petty merged 2 commits into
mainfrom
refactor/2445-settings-sources

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Every setting now resolves in one order, which setting_sources in src/devops_cli/config/settings.py declares once as pydantic-settings sources: its variable, then the project config file, then the global config file. A setting that no source holds keeps the default of its field. Before, load_settings merged the two files with _deep_merge, built Settings with model_validate, which reads no source, and then set each variable with dotted_set. _resolve_data_config rebuilt the data section with rules of its own, and telemetry_from_environment applied a partial copy of the variable step.

These results change:

  • Only the value that a setting takes is checked. A config file value that a variable replaces no longer stops the load.
  • A config file that sets only another field of ai.tasks.embedding, such as its timeout, keeps the embedding model. Before, the task's model became None, and the embedding task used the chat model ai.model. The embedding task has its own override class, AIEmbeddingTaskOverride, whose model defaults to the embedding model.
  • A config file that does not hold a mapping of keys to values stops the load with an error that names the file. Before, the load ended in an AttributeError.

docs/CONFIGURATION.md says where the order is declared and states these rules.

Closes #2445

Change: openspec/changes/archive/2026-10-28-2445-settings-sources/

…ntic-settings sources

`setting_sources` declares the order of every setting once: its variable,
the project config file, the global config file, then the default of its
field. `load_settings` builds `Settings` from these sources with the merge
and the validation of pydantic-settings, and `telemetry_from_environment`
uses the same variable source. `Settings(...)` built in code holds its
arguments and the defaults, and reads no variable and no file.

`_apply_env_overrides`, `_resolve_data_config`, `_deep_merge` and the
merged-file cache go. Only the value that a setting takes is checked. The
embedding task keeps its model when a source sets another of its fields,
and a config file that holds no mapping stops the load with an error that
names the file. Credentials keep their own chain in
`security.secrets.build_default_resolver`.
@dan-petty

Copy link
Copy Markdown
Owner Author

Test evidence:

  • uv run devops ci fail-to-pass --base origin/main: 5 failed on base and 1 errored on base, as intended.
    • test_settings_built_in_code_hold_their_arguments_and_the_defaults: Settings() read DEVOPS_CLI_DOMAIN.
    • test_the_embedding_task_keeps_its_model_when_a_layer_sets_another_of_its_fields[config-file]: (None, 45.0).
    • test_a_variable_replaces_a_config_file_value_before_the_value_is_checked: ValidationError.
    • test_a_config_file_that_holds_no_mapping_stops_the_load_and_names_the_file[project-file] and [global-file]: AttributeError.
    • tests/test_embedding_config_retention.py errored on base: AIEmbeddingTaskOverride does not exist there.
    • The tables of the plain setting and the credential passed on base: the order of the values did not change.
  • Full uv run devops ci on the branch: every gate passed, 3 m 28 s in total (tests 3 m 18 s).
  • An earlier full run of the suite on the branch: 11852 passed.

Decisions are in openspec/changes/archive/2026-10-28-2445-settings-sources/design.md.

Filed while building this: #2517 (GET /config returns the field defaults, not the loaded settings).

Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 19:40
@dan-petty
dan-petty merged commit 6a5447a into main Oct 28, 2026
18 checks passed
@dan-petty
dan-petty deleted the refactor/2445-settings-sources branch October 28, 2026 19:41
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.11.0](v0.10.1...v0.11.0)
(2026-10-28)


### Features

* **monitoring:** the roadmap Service's identity refusals, failing and
stalled jobs, restarts, and GitHub and model request volume raise alerts
([#2496](#2496))
([0137f23](0137f23)),
closes [#2472](#2472)
* **service:** roadmap-service runs at one replica, and each model call
in the cluster is sent at most two times
([#2500](#2500))
([2d32dae](2d32dae)),
closes [#2494](#2494)


### Bug Fixes

* **cli:** every command reports a DevOpsCLIError through one exit seam
([#2502](#2502))
([eadd55f](eadd55f)),
closes [#2487](#2487)
* **github:** pr monitor waits until the checks settle and names every
blocker, and pr ready reads the merge-readiness verdict
([#2498](#2498))
([43326ea](43326ea))
* **k8s:** a pod that does not call the Kubernetes API mounts no service
account token
([#2522](#2522))
([305d3ba](305d3ba))
* **k8s:** the cloudflared tunnel replicas prefer different nodes and
keep one up through a drain
([#2499](#2499))
([d4edaf6](d4edaf6)),
closes [#1023](#1023)
* **k8s:** the grafana, prometheus, argo cd and loki clients dial
through the egress-checked factory, and their pre-flight address checks
go ([#2497](#2497))
([e7ca1d5](e7ca1d5))
* **monitoring:** the roadmap Service alerts count a series that starts
in the hour, and a lane of a new pod can stall
([#2514](#2514))
([c7692b2](c7692b2)),
closes [#2505](#2505)
* **review:** a review's scanners leave out the rules that never gave a
valid finding here
([#2508](#2508))
([fe953ac](fe953ac))
* **roadmap:** a refine round leaves an outside account issue to a
person, and refine neutralizes comment openers, www links and
cross-repository references
([#2507](#2507))
([e6230dc](e6230dc)),
closes [#2478](#2478)
* **sandbox:** the metrics scrape and the whitelist NetworkPolicy
resolve each host one time, through the egress check
([#2521](#2521))
([7c01426](7c01426))
* **security:** the subprocess environment guard refuses the zsh and
interpreter keys that make a child run code
([#2510](#2510))
([459621a](459621a))
* **service:** a restart keeps the halt, the budget window and the
failure ledger, and a rate limit or a suspended installation stops every
worker ([#2515](#2515))
([3630de1](3630de1)),
closes [#2474](#2474)


### Code Refactoring

* **config:** settings resolve in one declared order through
pydantic-settings sources
([#2518](#2518))
([6a5447a](6a5447a)),
closes [#2445](#2445)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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.

refactor(config): one source chain declares the resolution order of every setting, through pydantic-settings sources

1 participant