Replace JSON file-based session storage with SQLite backend while maintaining full backward compatibility through LegacyAdapter. New files: - pkg/session/types.go: Turn, SessionInfo, CreateOpts, ListFilter types - pkg/session/store.go: SessionStore interface (15 methods) - pkg/session/sqlite.go: SQLite implementation (WAL mode, modernc.org/sqlite) - pkg/session/legacy_adapter.go: wraps SessionStore with SessionManager API - pkg/session/migrate.go: JSON → SQLite migration at startup Changes: - pkg/agent/instance.go: Sessions type changed to *LegacyAdapter - loop.go / loop_test.go: zero changes (method signatures identical) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
1 KiB
Go
31 lines
1 KiB
Go
package session
|
|
|
|
import "time"
|
|
|
|
// SessionStore is the storage interface for sessions and turns.
|
|
// Phase 0 provides a SQLite implementation; LegacyAdapter wraps it to
|
|
// expose the same API as SessionManager.
|
|
type SessionStore interface { //nolint:interfacebloat // storage facade — methods are logically grouped
|
|
// Session CRUD
|
|
Create(key string, opts *CreateOpts) error
|
|
Get(key string) (*SessionInfo, error)
|
|
List(filter *ListFilter) ([]*SessionInfo, error)
|
|
SetStatus(key, status string) error
|
|
SetSummary(key, summary string) error
|
|
Delete(key string) error
|
|
Children(key string) ([]*SessionInfo, error)
|
|
|
|
// Turn operations
|
|
Append(sessionKey string, turn *Turn) error
|
|
Turns(sessionKey string, sinceSeq int) ([]*Turn, error)
|
|
LastTurn(sessionKey string) (*Turn, error)
|
|
TurnCount(sessionKey string) (int, error)
|
|
Compact(sessionKey string, upToSeq int, summary string) error
|
|
|
|
// DAG operations
|
|
Fork(parentKey, childKey string, opts *CreateOpts) error
|
|
|
|
// Maintenance
|
|
Prune(olderThan time.Duration) (int, error)
|
|
Close() error
|
|
}
|