Add UnderlyingDB() method for extension database access

Implements database platform layer for extensions like VC to create
their own tables in the same SQLite database.

Changes:
- Add UnderlyingDB() *sql.DB to Storage interface
- Implement in SQLiteStorage to expose underlying connection
- Add comprehensive test suite (5 tests, -race clean)
- Tests cover: basic access, extension tables, concurrency,
  lifecycle safety, and transaction behavior

This allows VC to host its executor_instances and other tables
alongside beads core tables with proper FK enforcement.

Related issues: bd-57, bd-64, bd-65, bd-66

Amp-Thread-ID: https://ampcode.com/threads/T-a6715beb-fe92-4dee-b931-3c9327124875
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-22 17:19:57 -07:00
parent a689c66f77
commit 6829372c39
6 changed files with 312 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ package storage
import (
"context"
"database/sql"
"github.com/steveyegge/beads/internal/types"
)
@@ -72,6 +73,12 @@ type Storage interface {
// Database path (for daemon validation)
Path() string
// UnderlyingDB returns the underlying *sql.DB connection
// This is provided for extensions (like VC) that need to create their own tables
// in the same database. Extensions should use foreign keys to reference core tables.
// WARNING: Direct database access bypasses the storage layer. Use with caution.
UnderlyingDB() *sql.DB
}
// Config holds database configuration