Skip to content

refactor(config): each setting declares its variable and description on its settings field, and the option, variable and secret registries are derived from it #2444

Closed

Description

@dan-petty

Problem or Motivation

Part 1 of #1000. Six hand-written registries describe the settings, and they already disagree (origin/main 4226904, 2026-10-28):

  • config/options.py: 100 key constants, CONFIG_OPTIONS, SECRET_CONFIG_OPTIONS and KEYRING_KEYS.
  • config/env.py: 84 ENV_* constants, the OPTION_TO_ENV_VAR map and the hand-written get_all_env_var_specs() list (79 specs).
  • security/secrets.py: build_secret_registry repeats the keyring name and the variables of each of the 15 credentials.
  • commands/config.py: config show prints 29 hand-written _row lines.
  • docs/generator.py reads OPTION_TO_ENV_VAR and the spec list.

Measured drift: 7 options have a variable but no spec, so devops config env and docs/ENV_VARS.md do not show them (ai.tasks.<task>.reasoning_effort for 4 tasks, ai.rag.enabled, ai.rag.top_k, ai.rag.score_threshold). CONFIG_OPTIONS has no reader outside options.py.

Proposed Solution & Architectural Design

  • Each environment-bound Settings field declares that it reads a variable, and its description, once on the field. The variable name follows one rule: DEVOPS_CLI_ and the key in upper case with _ for .. The one segment that differs today (ai.tasks is AI_TASK_ in 17 names) is declared once on the tasks field, not 17 times.
  • The credential table in security/secrets.py is the one declaration of each credential: its keyring name, its variables and whether a file may hold it. KEYRING_KEYS and the secret set are derived from it.
  • OPTION_TO_ENV_VAR, the variable spec list, config show, config env, config set, config audit-keys, the workspace route's redaction and the docs generator read the derived view.
  • config/options.py, the ENV_* constants of options, the OPTION_TO_ENV_VAR literal, the spec list and the 29 _row lines are deleted.

Target Subsystem

src/devops_cli/config/, src/devops_cli/security/secrets.py, src/devops_cli/commands/config.py, src/devops_cli/docs/generator.py.

Existing Tool Considered

pydantic field metadata (FieldInfo.description, Annotated metadata) holds the declaration. pydantic-settings' own env binding cannot give today's names for nested fields: it joins nested names with env_nested_delimiter, and the ai.tasks names do not follow the key. Its sources are part 2 of #1000. Nothing new is built: the change deletes four hand-written registries.

Acceptance criteria

  • A snapshot test holds the set of variables and the keyring names and secret keys as they were at the start of the change. The 10 options that code reads and that had no variable get one by the rule, and the change names them. The 3 options that no code reads get none (fix(config): telemetry.logfire, cloudflare.access.enabled and cloudflare.access.idp are settings that no code reads #2457).
  • devops config env and docs/ENV_VARS.md list every variable that sets a setting or a credential, each with a description: the 7 setting variables and the 6 credential variables that the list missed are added.
  • config/options.py and the hand-written spec list do not exist. git grep -n "OPTION_TO_ENV_VAR = {" finds nothing.
  • devops config show prints every declared setting and credential, sorted by key, with --format and --json, and has no _row line for each key.
  • tests/test_config_env_overrides.py, tests/test_config_audit_keys.py and tests/test_config_cmd.py pass.
  • The tests run offline, with no keyring daemon and no Vault.

Related

Parent: #1000. Siblings: one resolution order through pydantic-settings sources, and the import boundary of field-backed defaults.

Source: #1000

Activity

  1. added
    type/refactor
    source/agent
    status/new
    value/medium
    effort/high
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor.
    • Priority: P2-Medium.
    • Value: Medium.
    • Effort: High.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. removed
    status/new
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highpriority/p2-mediumsource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions