Skip to content

feat: add OSA_DATA_DIR support for container deployments#19

Merged
rorybyrne merged 3 commits into
mainfrom
018-feat-osa-data
Jan 6, 2026
Merged

feat: add OSA_DATA_DIR support for container deployments#19
rorybyrne merged 3 commits into
mainfrom
018-feat-osa-data

Conversation

@rorybyrne

@rorybyrne rorybyrne commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add OSA_DATA_DIR environment variable to control all data paths from a single location
  • Restructure CLI for zero-setup local development
  • Enables simple container deployments with one volume mount at /data
  • Preserves XDG Base Directory defaults for local development

Key Changes

  • OSAPaths refactor: Reads OSA_DATA_DIR directly from environment, supports unified (/data/*) and XDG modes
  • CLI restructure: osa serverosa local, osa initosa config init
  • Self-sufficient start: osa local start auto-creates directories and works without config
  • Config generation: osa config init geo writes to ./osa.yaml (cwd, not XDG)
  • Database URL derivation: model_validator derives URL when not explicitly set
  • Vector persist_dir: DI provider fills from OSAPaths.vectors_dir

New CLI Structure

osa local start|stop|logs|status|restart   # Local dev server management
osa config init <template>                  # Generate config template
osa config path                             # Show config resolution order

User Journeys

Quick start (no setup):

osa local start    # Just works with defaults

Local dev with config:

osa config init geo    # Generate ./osa.yaml
vim osa.yaml           # Customize
osa local start        # Uses the config

Container deployment:

osa config init geo --stdout > config.yaml
docker run -v ./config.yaml:/data/config/config.yaml \
           -v osa-data:/data \
           -e OSA_DATA_DIR=/data osa

Config Resolution Order

  1. ./osa.yaml (current directory)
  2. $OSA_DATA_DIR/config/config.yaml (unified mode)
  3. ~/.config/osa/config.yaml (XDG fallback)

Test Plan

  • 33 unit tests passing
  • Lint and type checks passing
  • Manual test: osa local start with no config
  • Manual test: osa config init geo creates ./osa.yaml
  • Manual test: OSA_DATA_DIR=/tmp/osa-test osa local start

Closes #18

Enable single environment variable to control all data paths for
container deployments while preserving XDG defaults for local dev.

Key changes:
- Add PathsConfig to read OSA_DATA_DIR with Pydantic Settings
- Refactor OSAPaths to support unified (/data/*) and XDG modes
- Derive database URL from paths via model_validator when not set
- Derive vector persist_dir from OSAPaths in DI provider
- Move file I/O from OSAPaths to dedicated utility modules

Design decisions:
- Nested configs (DatabaseConfig, etc.) changed from BaseSettings to
  BaseModel to enable env_nested_delimiter for OSA_DATABASE__URL
- PathsConfig uses default_factory to avoid class-definition-time
  evaluation of environment variables
- Empty string sentinel for database.url to detect "derive from paths"

Closes #18
@github-actions

github-actions Bot commented Jan 4, 2026

Copy link
Copy Markdown

Code Coverage

Package Line Rate Complexity Health
. 68% 0
application 0% 0
application.api 100% 0
application.api.rest 0% 0
application.api.v1 0% 0
application.api.v1.routes 0% 0
application.event 0% 0
cli 40% 0
cli.commands 18% 0
cli.util 53% 0
domain 100% 0
domain.auth 100% 0
domain.auth.adapter 100% 0
domain.auth.command 100% 0
domain.auth.event 100% 0
domain.auth.model 100% 0
domain.auth.port 100% 0
domain.auth.query 100% 0
domain.auth.service 100% 0
domain.curation 100% 0
domain.curation.adapter 100% 0
domain.curation.command 100% 0
domain.curation.event 0% 0
domain.curation.listener 0% 0
domain.curation.model 100% 0
domain.curation.port 100% 0
domain.curation.query 100% 0
domain.curation.service 100% 0
domain.deposition 100% 0
domain.deposition.adapter 100% 0
domain.deposition.command 0% 0
domain.deposition.event 100% 0
domain.deposition.model 0% 0
domain.deposition.port 0% 0
domain.deposition.query 100% 0
domain.deposition.service 0% 0
domain.export 100% 0
domain.export.adapter 100% 0
domain.export.command 100% 0
domain.export.event 100% 0
domain.export.model 100% 0
domain.export.port 100% 0
domain.export.query 100% 0
domain.export.service 100% 0
domain.index 100% 0
domain.index.listener 0% 0
domain.index.model 74% 0
domain.index.service 100% 0
domain.ingest 100% 0
domain.ingest.event 100% 0
domain.ingest.listener 0% 0
domain.ingest.model 76% 0
domain.ingest.schedule 0% 0
domain.ingest.service 100% 0
domain.record 100% 0
domain.record.adapter 100% 0
domain.record.command 100% 0
domain.record.event 100% 0
domain.record.listener 0% 0
domain.record.model 100% 0
domain.record.port 100% 0
domain.record.query 100% 0
domain.record.service 100% 0
domain.schema 100% 0
domain.schema.adapter 100% 0
domain.schema.command 100% 0
domain.schema.event 100% 0
domain.schema.model 100% 0
domain.schema.port 100% 0
domain.schema.query 100% 0
domain.schema.service 100% 0
domain.search 100% 0
domain.search.adapter 100% 0
domain.search.command 100% 0
domain.search.event 100% 0
domain.search.model 100% 0
domain.search.port 100% 0
domain.search.query 100% 0
domain.search.service 100% 0
domain.shared 44% 0
domain.shared.model 90% 0
domain.shared.port 100% 0
domain.validation 0% 0
domain.validation.adapter 100% 0
domain.validation.command 0% 0
domain.validation.event 0% 0
domain.validation.listener 0% 0
domain.validation.model 0% 0
domain.validation.port 0% 0
domain.validation.query 100% 0
domain.validation.service 0% 0
infrastructure 100% 0
infrastructure.event 0% 0
infrastructure.index 0% 0
infrastructure.index.vector 51% 0
infrastructure.ingest 0% 0
infrastructure.messaging 100% 0
infrastructure.oci 0% 0
infrastructure.persistence 0% 0
infrastructure.persistence.adapter 0% 0
sdk 100% 0
sdk.index 100% 0
sdk.ingest 100% 0
util 100% 0
util.di 0% 0
Summary 29% (808 / 2782) 0

  - Rename `osa server` to `osa local` (start/stop/logs/status)
  - Move `osa init` to `osa config init` with template selection
  - Make `osa local start` self-sufficient: auto-creates directories
    and works without config file (uses sensible defaults)
  - Config init writes to ./osa.yaml by default (cwd, not XDG)
  - Simplify OSAPaths to read OSA_DATA_DIR directly from environment

  New user journey:
    osa local start                 # Just works, no setup required
    osa config init geo             # Optional: generate config template
    vim osa.yaml && osa local start # Customize and restart

  Config resolution order:
    1. ./osa.yaml (current directory)
    2. $OSA_DATA_DIR/config/config.yaml
    3. ~/.config/osa/config.yaml (XDG fallback)
Move config init functionality from separate config module to local
commands to simplify CLI structure. Remove standalone config command
and integrate template-based initialization directly into local
workflow. Update admin clean command to reference new location.
@rorybyrne rorybyrne merged commit f96539f into main Jan 6, 2026
3 checks passed
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.

feat: add OSA_DATA_DIR for container deployments

1 participant