Problem
Currently SpendTracker only records transactions in memory. All spending history and policy state is lost on restart. This is fine for development but unacceptable for production deployments.
Proposed Solution
Implement a StorageBackend interface with the adapter pattern:
interface StorageBackend {
recordTransaction(tx: Transaction): Promise<void>;
getTransactions(filter: TransactionFilter): Promise<Transaction[]>;
getSpendingTotal(agentId: string, window: TimeWindow): Promise<number>;
}
Implementation Plan
- Phase 1: SQLite — Zero-config, embedded, perfect for single-node deployments
- Phase 2: PostgreSQL — For multi-instance / production environments
- Phase 3: Migration tooling — Schema versioning with automatic migrations
Acceptance Criteria
Problem
Currently
SpendTrackeronly records transactions in memory. All spending history and policy state is lost on restart. This is fine for development but unacceptable for production deployments.Proposed Solution
Implement a
StorageBackendinterface with the adapter pattern:Implementation Plan
Acceptance Criteria
StorageBackendinterface definedPAYSENTRY_STORAGE=sqlite|memory)