Repository navigation
Description
Context & Rationale
Six hand-synchronised registries describe each setting, and eight read paths each know part of the resolution order. Checked at 9c879ae.
- A new option-backed setting edits: a key in
config/options.py, anENV_*constant inconfig/env.py, anOPTION_TO_ENV_VARentry, aCONFIG_OPTIONSentry, anEnvVarSpecin the 436-line hand-writtenget_all_env_var_specs()(env.py:220-655), aSettingsfield (settings.py:595-624), aDEFAULT_*indefaults.py, a help string, a_row()incommands/config.py(29 hand-written rows) and three__all__entries inconfig/__init__.py: 10 to 12 edits across 6 files. The pyroscope item (8271385) spent 3 of its 5 source-file touches here for one URL. - Eight ways to read a setting:
load_settings()(71 modules),dotted_get(4 command modules), rawos.environ(83 call sites outsideconfig/, 11 of them incommands/devcontainer.pyand 9 intelemetry/tracer.py),ENV_*constants (5 modules), rawDEFAULT_*imports (206 modules), the secret getters throughsecurity.secrets,opt.*dotted keys (9), and theconfigfacade (13 modules using 11 of its 431 names). - 23
DEFAULT_*values are both aSettingsfield default and imported raw by feature modules (DEFAULT_OLLAMA_URLS,DEFAULT_QDRANT_URL,DEFAULT_OTEL_ENDPOINT,DEFAULT_AI_GATEWAY_URL, ...). Aconfig.yamloverride is honoured by one caller and ignored by another.ai/benchmark/{runner,suite,embedding_runner}.pyalso hard-codehttp://localhost:11434as a fallback. - Tests patch
load_settings121 times at 15 distinct module paths; 25 test files patchconfig.settings._keyring_get,CONFIG_PATHoros.environ.get.
Deletion test: delete options.py, the registry in env.py and the config/__init__.py re-exports and nothing reappears; all of it is derivable from Settings field metadata. Delete settings.py and it reappears in 71 callers. That module is the seam.
Scope & Deliverables
- Deliverable: each
Settingsfield declares its env name, secret flag and description once (pydantic-settings already binds env vars and carries field metadata).config show,config set,config env,OPTION_TO_ENV_VAR,get_all_env_var_specsandconfig audit-keysbecome views ofmodel_fields. ADEFAULT_*that backs a field is reachable only throughSettings, so the dual-path overrides become impossible, and the threelocalhost:11434fallbacks go. - Tests:
test_config_env_overrides.py,test_config_audit_keys.pyandtest_config_cmd.pyalready drive the interface and stay; the hand-written_rowexpectations go. Follow-on, not prerequisite: feature modules receive aSettingsinstance instead of callingload_settings(), which retires the 121 patches. - Key questions (open):
- Can pydantic-settings' env binding express the current precedence (keyring, Vault, env, file, default), or does
_apply_env_overridesstay as the one place that does? - Where does fix(config): numeric settings from environment variables load as strings and are never range-checked #992's numeric coercion and range check live in the new shape?
- What do the generated docs (fix(docs): generated reference docs fail closed and describe the real surface #854, fix(docs): generated docs mask non-secret defaults and hide off flags, and docs name things that do not exist #956) read:
model_fieldsdirectly?
- Can pydantic-settings' env binding express the current precedence (keyring, Vault, env, file, default), or does
- Constraint:
DEFAULT_*values stay indefaults.py; the AGENTS.md constants rule is not touched by this item (refactor(config): the config barrel and the unused config names go, and the package inits stop re-exporting #776 is).
Strategic Alignment
- Design: none
- Depends on: none
- Related: fix(config): numeric settings from environment variables load as strings and are never range-checked #992, refactor(config): the config barrel and the unused config names go, and the package inits stop re-exporting #776, fix(docs): generated reference docs fail closed and describe the real surface #854, fix(docs): generated docs mask non-secret defaults and hide off flags, and docs name things that do not exist #956
- Source: architecture review of 2026-10-02, config and language cross-cut
Scope added 2026-10-02: checked at 38517a8. Lines moved by about 11: Settings is at config/settings.py:606, _apply_env_overrides at :733-752, dotted_get and dotted_set at :1072 and :1095. get_llm_client (:1062) has 1 caller (ai/harness/workflow.py:498), not 3. The dual-path count needs re-measuring before it is used as evidence. The sampled raw imports read the setting first and fall back to the default only when it is empty, for example config.gateway_url or DEFAULT_AI_GATEWAY_URL (ai/client/openai.py:40, ai/gateway.py:352, ai/rag/embeddings.py:784, ai/pydantic_ai_bridge.py:84). Others are function defaults that callers override (QdrantClient(base_url=DEFAULT_QDRANT_URL), ai/rag/qdrant.py:147). The ignored-override bug exists only where a module uses such a default without reading the setting. The hard-coded http://localhost:11434 fallbacks are not three. 10 modules outside config/ spell it in code: ai/client/ollama.py:186, ai/client/unified.py:292-296, ai/review/runner.py:140-162, ai/review/pipeline.py:200-212, ai/rag/embeddings.py:489, ai/rag/indexer.py:581-582, ai/models/ollama.py:31, ai/benchmark/runner.py:160, ai/benchmark/embedding_runner.py:128 and ai/benchmark/suite.py:507. #950 (v0.2.25, in flight) deletes suite.py, #954 (v0.2.25, in flight) edits embedding_runner.py, and #995 deletes runner's copy. #956 (v0.2.25, in flight) edits how generated docs show defaults. The Constraint line's "(#776 is)" is stale: the AGENTS.md constants rule now belongs to ##1016, which keeps Settings-backed DEFAULT_* values in defaults.py.
Acceptance criteria
- Each user-settable
Settingsfield declares its environment variable name, its secret flag and its description once, in field metadata.config/options.pyand the hand-writtenget_all_env_var_specs(config/env.py:222) are deleted, andOPTION_TO_ENV_VARis derived. -
config show,config set,config envandconfig audit-keysread the field metadata. The 29_row()calls incommands/config.pyare gone. - The resolution order is defined in one place. A table test covers one secret field and one plain field across keyring, Vault, environment, file and default.
- The set of environment variable names does not change. A test compares the derived list with a snapshot taken at the start of the PR.
- A field-backed
DEFAULT_*is imported only insideconfig/. An import-boundary test lists the importers outside it and finds none. No code outsideconfig/falls back to a literalhttp://localhost:11434; each site above reads the field's default. A test grepssrcfor the literal outsideconfig/, docstrings and user messages, and finds none. - The PR names each site where an override was ignored at 38517a8, with a test per site that sets the override and asserts it is used. If there is none, the PR says so.
-
tests/test_config_env_overrides.py,tests/test_config_audit_keys.pyandtests/test_config_cmd.pypass. Only the hand-written_rowexpectations change. -
docs/ENV_VARS.mdanddocs/CONFIGURATION.mdare regenerated and lose no variable. - The tests run offline, with no keyring daemon or Vault server.
-
uv run devops cipasses. - (person-run)
devops config showanddevops config envprint the same keys and variables before and after on the devcontainer.
Key questions
- Can pydantic-settings' env binding express the current precedence (keyring, Vault, env, file, default), or does
_apply_env_overridesstay as the one place that does? (proposed) Usesettings_customise_sourceswith a YAML file source and keyring and Vault sources, in that order, and carry today's variable names on the fields. That is a documented pydantic-settings feature and adds no dependency. If a nested field's name cannot be expressed next toenv_nested_delimiter(settings.py:609),_apply_env_overridesstays as the one place and reads the names from field metadata. - Where does fix(config): numeric settings from environment variables load as strings and are never range-checked #992's numeric coercion and range check live in the new shape? (proposed) In the field's type. fix(config): numeric settings from environment variables load as strings and are never range-checked #992 lands first as a defect fix. Once environment values pass through field validation, numeric types and
ge/lebounds coerce and check them, and fix(config): numeric settings from environment variables load as strings and are never range-checked #992's tests stay. - What do the generated docs (fix(docs): generated reference docs fail closed and describe the real surface #854, fix(docs): generated docs mask non-secret defaults and hide off flags, and docs name things that do not exist #956) read:
model_fieldsdirectly? (proposed) The same metadata viewconfig envreads, so the docs and the command cannot drift. This item lands after fix(docs): generated docs mask non-secret defaults and hide off flags, and docs name things that do not exist #956. - Is the dual-path claim a measured bug? (proposed) Not yet. The import-boundary test makes the dual path impossible either way; the PR reports whether any override was in fact ignored.
Update 2026-10-08: refinement
The registry premise holds. The criterion that each localhost:11434 site reads 'the field's default' conflicts with #1165's rule that service URLs have no code default. Those literal sites (for example ai/client/ollama.py:183, ai/rag/indexer.py:395-397, ai/review/runner.py:150-172) and their guard belong to #1165. The constraint reads: DEFAULT_* values stay in defaults.py, except service URLs, which have none.
Proposed design
Problem statement
The configuration system has six hand-synchronized registries that describe each setting, leading to 10-12 edits across 6 files when adding a new option. The resolution order is scattered across 8 read paths, and there are dual-path overrides where config.yaml values can be ignored by feature modules. There's also a hard-coded fallback for Ollama URLs that should be removed.
Acceptance criteria
- Criterion 1: Each user-settable Settings field declares its environment variable name, secret flag and description once in field metadata
Verification: Verify that config/options.py and get_all_env_var_specs() are deleted and OPTION_TO_ENV_VAR is derived from model_fields - Criterion 2: config show, config set, config env and config audit-keys read the field metadata
Verification: Ensure the 29 _row() calls in commands/config.py are gone and these commands use model_fields directly - Criterion 3: The resolution order is defined in one place with a table test covering keyring, Vault, environment, file and default precedence
Verification: Run a test that validates the resolution order across all eight override mechanisms and confirms only one source handles precedence - Criterion 4: The set of environment variable names does not change from the current implementation
Verification: Compare the derived list with a snapshot taken at the start of the PR to ensure no environment variables are lost or added - Criterion 5: A field-backed DEFAULT_* is imported only inside config/ and hard-coded localhost:11434 fallbacks are removed
Verification: Run an import-boundary test that lists importers outside config/ and verify none fall back to literal 'http://localhost:11434' - Criterion 6: Each site where an override was ignored is reported with a test per site that sets the override and asserts it is used
Verification: Run tests for each of the 10 sites that previously ignored overrides, ensuring they now properly use the override - Criterion 7: Existing tests continue to pass with only hand-written _row expectations changing
Verification: Run test_config_env_overrides.py, test_config_audit_keys.py and test_config_cmd.py to confirm all existing functionality works - Criterion 8: docs/ENV_VARS.md and docs/CONFIGURATION.md are regenerated without losing any variables
Verification: Verify that the generated documentation includes all environment variables and configuration options with correct metadata - Criterion 9: The tests run offline, with no keyring daemon or Vault server required
Verification: Execute tests in an environment without keyring daemon or Vault server to ensure they function properly offline
Key questions
- Can pydantic-settings' env binding express the current precedence (keyring, Vault, env, file, default), or does _apply_env_overrides stay as the one place that does?: Use settings_customise_sources with a YAML file source and keyring and Vault sources, in that order, and carry today's variable names on the fields. That is a documented pydantic-settings feature and adds no dependency. If a nested field's name cannot be expressed next to env_nested_delimiter, _apply_env_overrides stays as the one place and reads the names from field metadata. [sources: src/devops_cli/config/settings.py:733-752]
- Where does fix(config): numeric settings from environment variables load as strings and are never range-checked #992's numeric coercion and range check live in the new shape?: In the field's type. fix(config): numeric settings from environment variables load as strings and are never range-checked #992 lands first as a defect fix. Once environment values pass through field validation, numeric types and ge/le bounds coerce and check them, and fix(config): numeric settings from environment variables load as strings and are never range-checked #992's tests stay. [sources: src/devops_cli/config/settings.py:606]
- What do the generated docs (fix(docs): generated reference docs fail closed and describe the real surface #854, fix(docs): generated docs mask non-secret defaults and hide off flags, and docs name things that do not exist #956) read: model_fields directly?: The same metadata view config env reads, so the docs and the command cannot drift. This item lands after fix(docs): generated docs mask non-secret defaults and hide off flags, and docs name things that do not exist #956. [sources: docs/ENV_VARS.md, docs/CONFIGURATION.md]
- Is the dual-path claim a measured bug?: Not yet. The import-boundary test makes the dual path impossible either way; the PR reports whether any override was in fact ignored. [sources: src/devops_cli/config/settings.py:606]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsReady
Activity
dan-petty commentedon Oct 3, 2026
Consolidation (2026-10-03): #992 becomes a sub-issue of this item and lands first, as this item's key question proposes. It carries the library-first settings amendment (posted on #992 as an amendment):
validate_assignment=Trueandhide_input_in_errors=Trueon every section model, andhide_input_in_errorsonSettings. Every value from the environment, config.yaml andconfig setthen passes its field type: bool, number, URL and list.gt=0, finite).This item keeps the registry rework.
Proposed criterion for this item, for a person to accept (medium confidence):
extra='forbid'onSettingsand every nested config model, with an error that names the unknown key. A test loads a stray key at the top level and inside a section. #1070's refusal foraiandai.tasksis the first instance. The PR lists the keys this rejects, such asai.lightllm_url.Declared fields that nothing reads stay with their own items:
analyze --enhancedandai agentsuse theai.tasks.metadatamodel #1068:ai.tasks.metadata.ai.rag.top_kandscore_threshold.ai.durablesettings are removed #1121:ai.durable, which lands before the forbid rule or is listed in it.Related: #1022 (one helper that reads the config file; no settings error repeats a value).
dan-petty commentedon Oct 8, 2026
Linked: #1068 edits
ai.tasks.metadatadescriptions (config/env.py:377-392) this item turns into field views, and #1121 removesai.durable(config/settings.py:413,:497), whichextra='forbid'would reject. Found by the 2026-10-08 backlog review.dan-petty commentedon Oct 17, 2026
Moved to v0.2.37: v0.2.37 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)
dan-petty commentedon Oct 19, 2026
Status set to Ready at 0ae4ea4 (see proposed design in issue body).
dan-petty commentedon Oct 28, 2026
This item is larger than one pull request, so it becomes three sub-issues, each with its own change. Measured on origin/main 4226904 (2026-10-28):
config/options.py(100 keys, the secret set, the keyring map),config/env.py(84 variables, the option map, 79 hand-written specs), the credential table insecurity/secrets.py, the 29_rowlines ofconfig show, the docs generator, and the fields ofSettings. They already disagree: 7 options with a variable have no spec, soconfig envanddocs/ENV_VARS.mddo not show them.load_settingsbuildsSettingswithmodel_validate, so pydantic-settings reads no source;_apply_env_overridesapplies every variable.DEFAULT_*names are imported in 39 files outsideconfig/.localhost:11434criterion is done: fix(config): service clients use only configured urls and never fall back to an unconfigured localhost default #1165 removed the fallbacks, and the literals left are user messages, docstrings and one value thatstack_lifecycle.pywrites on purpose.Parts (sub-issues):
Decisions on the key questions:
DEVOPS_CLI_and the key in upper case), with theai.taskssegment declared once on its field. pydantic-settings' nested binding cannot give today's names, so part 2 keeps them through a custom source.validate_assignment=True); fix(config): numeric settings from environment variables load as strings and are never range-checked #992 is closed.config env.extra='forbid'on every section is not in these parts. feat(config): devops config unset removes a key, and an unknown key's error names the line and that command #2201 already names the file and line of a key that a section refuses.refactor(config): each setting declares its variable on its settings …
dan-petty commentedon Oct 28, 2026
All three parts of this item are merged:
config env,config showand the docs derive their lists from those declarations.setting_sourcesinconfig/settings.py: the variable, the project config file, the global config file, then the field default.config/settings.pyreads the default of a setting fromconfig/defaults.py. An invariant intests/invariants/test_source_tree.pytakes the names from the settings module itself, so it keeps no list and no baseline. Nine settings that a config file could not change before now reach their readers.