Skip to content

db: Add encrypted Turso adapter with shared migration flow#50

Draft
stefanskoricdev wants to merge 4 commits into
mainfrom
auth/credentials-storage
Draft

db: Add encrypted Turso adapter with shared migration flow#50
stefanskoricdev wants to merge 4 commits into
mainfrom
auth/credentials-storage

Conversation

@stefanskoricdev
Copy link
Copy Markdown
Contributor

No description provided.

stefanskoricdev and others added 4 commits May 25, 2026 13:27
- Add EncryptedTursoDb<M: DbSpec> alongside TursoDb<M> in the shared DB module
- Require SCE_DB_ENCRYPTION_KEY, reject empty keys, and configure Turso encryption via EncryptionOpts with strict aegis256
- Reuse extracted shared helpers for parent directory setup, runtime creation, and migration execution to keep encrypted/non-encrypted paths consistent
- Expose sync execute()/query() on encrypted adapter and keep __sce_migrations metadata behavior aligned
- Update context memory files to reflect the current shared Turso DB architecture and glossary terms

Co-authored-by: SCE <sce@crocoder.dev>
Add encrypted auth DB foundation: `AuthDb = EncryptedTursoDb<AuthDbSpec>`
wrapper, ordered auth token migrations (table + email index), and
`AuthDbLifecycle` provider registered in the shared lifecycle catalog.
Wire the canonical `<state_root>/sce/auth.db` path resolver, module
export, and lifecycle ordering (config → local_db → auth_db →
agent_trace_db → hooks). Sync context files to reflect the new
current-state DB surface.

Plan: encrypted-auth-db
Tasks: T01 (auth DB path + migrations), T02 (auth_db mod.rs), T03
(lifecycle integration)

Co-authored-by: SCE <sce@crocoder.dev>
Replace baseline auth schema/table naming from auth_tokens to auth_credentials and store identity via user_id instead of email.

Update embedded migration constants and migration IDs to match the new schema naming and index contract.

Add focused auth DB tests covering baseline migration objects/constraints, applied migration ordering, and lifecycle provider inclusion/order.

Sync context docs to reflect the implemented auth DB schema and lifecycle wiring state.

Co-authored-by: SCE <sce@crocoder.dev>
Remove the UNIQUE constraint on user_id and its dedicated index
migration. Add an updated_at column and an auto-update trigger to
track credential modification timestamps.

This prepares for supporting multiple credentials per user while
retaining modification timestamps for cache-invalidation use cases.

Drop 002_create_auth_tokens_email_index.sql, add
002_create_auth_credentials_updated_at_trigger.sql, and update the
Rust module and test assertions accordingly.

Co-authored-by: SCE <sce@crocoder.dev>
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.

2 participants