Skip to content

refactor(config): use pydantic-settings and platformdirs #628

Closed as not planned

Description

@Sinity

Problem

Polylogue declares pydantic-settings as a runtime dependency but still hand-rolls runtime settings and XDG path resolution.

Evidence:

  • pyproject.toml declares pydantic-settings, but rg pydantic_settings polylogue devtools tests finds no imports.
  • polylogue/config.py:29-151 uses dataclasses plus manual env reads such as VOYAGE_API_KEY.
  • polylogue/paths/_roots.py:9-33 manually implements XDG config/data/cache/state fallback logic with os.environ.get.
  • polylogue/paths/_roots.py:66-73 handles POLYLOGUE_ARCHIVE_ROOT and render-root derivation outside a typed settings model.

This is both a compactness issue and a drift issue: config/environment behavior is spread across path helpers, config dataclasses, Drive auth helpers, pipeline commands, and terminal formatting helpers.

Suggested shape

  • Add a RuntimeSettings / adapter layer using pydantic_settings.BaseSettings with a POLYLOGUE_ prefix.
  • Add platformdirs as a direct dependency for user config/data/cache/state roots, or explicitly reject it and remove pydantic-settings if the project wants custom path code.
  • Keep existing Config, Source, and DriveConfig as public/internal contracts at first; make get_config() consume the settings adapter.
  • Migrate manual env reads in follow-up slices.

Acceptance criteria

  • get_config() is backed by typed settings validation rather than scattered os.environ.get calls.
  • XDG/default path resolution goes through one platform-aware path/settings layer.
  • Existing env vars keep their intended behavior, with tests for POLYLOGUE_ARCHIVE_ROOT, XDG roots, Drive credential/token paths, schema validation mode, and VOYAGE_API_KEY.
  • pydantic-settings is either used directly or removed from runtime dependencies.
  • Documentation lists the supported env vars from the same settings source of truth.

Ref #578
Ref #614

Activity

  1. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Superseded by #614. I consolidated this finding into the composite issue so the work can be handled as one coherent slice instead of as a tiny standalone ticket. The original evidence remains available in this issue history.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions