Skip to content

Conversation

ashwinb
Copy link
Contributor

@ashwinb ashwinb commented Oct 6, 2025

This PR changes configurations in a backward incompatible way.

Run configs today repeat full SQLite/Postgres snippets everywhere a store is needed, which means duplicated credentials, extra connection pools, and lots of drift between files. This PR introduces named storage backends so the stack and providers can share a single catalog and reference those backends by name.

Key Changes

  • Add storage.backends to StackRunConfig, register each KV/SQL backend once at startup, and validate that references point to the right family.
  • Move server stores under storage.stores with lightweight references (backend + namespace/table) instead of full configs.
  • Update every provider/config/doc to use the new reference style; docs/codegen now surface the simplified YAML.

Migration

Before:

metadata_store:
  type: sqlite
  db_path: ~/.llama/distributions/foo/registry.db
inference_store:
  type: postgres
  host: ${env.POSTGRES_HOST}
  port: ${env.POSTGRES_PORT}
  db: ${env.POSTGRES_DB}
  user: ${env.POSTGRES_USER}
  password: ${env.POSTGRES_PASSWORD}
conversations_store:
  type: postgres
  host: ${env.POSTGRES_HOST}
  port: ${env.POSTGRES_PORT}
  db: ${env.POSTGRES_DB}
  user: ${env.POSTGRES_USER}
  password: ${env.POSTGRES_PASSWORD}

After:

storage:
  backends:
    kv_default:
      type: kv_sqlite
      db_path: ~/.llama/distributions/foo/kvstore.db
    sql_default:
      type: sql_postgres
      host: ${env.POSTGRES_HOST}
      port: ${env.POSTGRES_PORT}
      db: ${env.POSTGRES_DB}
      user: ${env.POSTGRES_USER}
      password: ${env.POSTGRES_PASSWORD}
  stores:
    metadata:
      backend: kv_default
      namespace: registry
    inference:
      backend: sql_default
      table_name: inference_store
      max_write_queue_size: 10000
      num_writers: 4
    conversations:
      backend: sql_default
      table_name: openai_conversations

Provider configs follow the same pattern—for example, a Chroma vector adapter switches from:

providers:
  vector_io:
  - provider_id: chromadb
    provider_type: remote::chromadb
    config:
      url: ${env.CHROMADB_URL}
      kvstore:
        type: sqlite
        db_path: ~/.llama/distributions/foo/chroma.db

to:

providers:
  vector_io:
  - provider_id: chromadb
    provider_type: remote::chromadb
    config:
      url: ${env.CHROMADB_URL}
      persistence:
        backend: kv_default
        namespace: vector_io::chroma_remote

Once the backends are declared, everything else just points at them, so rotating credentials or swapping to Postgres happens in one place and the stack reuses a single connection pool.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 6, 2025
Copy link
Contributor

@cdoern cdoern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the direction this is going in, but have a general comment about some class structure here now that it seems these StoreConfig classes are combining functionality more than before.

If this is out of scope of this PR, let's open up a follow up issue to track some of this possible refactoring. Thanks!

@ashwinb
Copy link
Contributor Author

ashwinb commented Oct 6, 2025

Thanks for the reviews @leseb, @cdoern... will act on them, and taking PR to draft stage while I clean it up.

@ashwinb ashwinb marked this pull request as draft October 6, 2025 14:07
@ashwinb ashwinb changed the title feat(stores)!: implement backend registry pattern for persistence configuration feat(stores)!: use backend storage references instead of configs Oct 16, 2025
@ashwinb ashwinb marked this pull request as ready for review October 16, 2025 23:22
Copy link
Contributor

@cdoern cdoern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall this is really nice! just one nit so far.

Copy link
Contributor

@ehhuang ehhuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@ashwinb ashwinb force-pushed the stores branch 2 times, most recently from c232167 to 32d9e39 Compare October 20, 2025 19:34
@ashwinb
Copy link
Contributor Author

ashwinb commented Oct 20, 2025

ok CI is green. landing!

@ashwinb ashwinb merged commit 2c43285 into main Oct 20, 2025
47 checks passed
@ashwinb ashwinb deleted the stores branch October 20, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants