Expand description
Prompt storage backends.
Provides domain-scoped storage for prompt templates with pluggable backends:
- Project scope:
SQLite(faceted by repo/branch) - User scope:
SQLite, PostgreSQL, Redis, or Filesystem - Org scope:
SQLiteor Filesystem (org-isolated)
§URN Scheme
subcog://{domain}/_prompts/{prompt-name}
Examples:
subcog://project/_prompts/code-reviewsubcog://user/_prompts/api-designsubcog://org/_prompts/team-review
§Backend Selection Logic
The backend is selected based on configuration and domain:
1. Check explicit backend type in config/env
├─► PostgreSQL if SUBCOG_POSTGRES_URL set + domain supports it
├─► Redis if SUBCOG_REDIS_URL set + domain supports it
└─► Continue to step 2
2. Check domain scope
├─► Project → `SQLite` (faceted by repo/branch)
├─► User → `SQLite` (local, performant, no server required)
└─► Org → `SQLite` with org-prefixed path
3. Fallback
└─► Filesystem (always available, human-readable YAML files)§Selection Priority by Domain
| Domain | Priority Order | Rationale |
|---|---|---|
| Project | SQLite → Filesystem | Faceted by repo/branch |
| User | PostgreSQL → Redis → SQLite → Filesystem | Configured external, then local |
| Org | PostgreSQL → Redis → SQLite → Filesystem | Shared org database preferred |
§Backend Capabilities
| Backend | ACID | Shared | Versioned | Query | Setup |
|---|---|---|---|---|---|
SQLite | Yes | No | No | Full SQL | None |
| PostgreSQL | Yes | Yes | No | Full SQL | Server |
| Redis | No | Yes | No | Pattern | Server |
| Filesystem | No | Via sync | No | Glob only | None |
§Domain Routing
Each domain scope maps to an appropriate storage backend:
| Domain | Backend | Location |
|---|---|---|
| Project | SQLite | ~/.config/subcog/memories.db (with repo/branch facets) |
| User | SQLite | ~/.config/subcog/memories.db |
| User | PostgreSQL | Configured connection |
| User | Redis | Configured connection |
| User | Filesystem | ~/.config/subcog/prompts/ |
| Org | SQLite | ~/.config/subcog/orgs/{org}/memories.db |
| Org | Filesystem | ~/.config/subcog/orgs/{org}/prompts/ |
§Org Identifier Resolution
The org identifier is resolved from:
SUBCOG_ORGenvironment variable (highest priority)- Git remote URL (extracts org from
github.com/org/repo) - Returns error if no identifier can be resolved
Modules§
- filesystem 🔒
- Filesystem-based prompt storage fallback.
- postgresql 🔒
- PostgreSQL-based prompt storage.
- redis 🔒
- Redis-based prompt storage using
RediSearch. - sqlite 🔒
- SQLite-based prompt storage for user scope.
- traits 🔒
- Prompt storage trait definition.
Structs§
- Filesystem
Prompt Storage - Filesystem-based prompt storage.
- Postgres
Prompt Storage - PostgreSQL-based prompt storage with auto-migration support.
- Prompt
Storage Factory - Factory for creating domain-scoped prompt storage.
- Redis
Prompt Storage - Redis-based prompt storage using
RediSearch. - Sqlite
Prompt Storage SQLite-based prompt storage.
Enums§
- Prompt
Backend Type - Backend type for prompt storage.
Traits§
- Prompt
Storage - Trait for prompt storage backends.