refactor: remove legacy autoflush code paths (bd-xsl9)
Remove dual code paths in the autoflush system. FlushManager is now the only code path for auto-flush operations. Changes: - Remove legacy globals: isDirty, needsFullExport, flushTimer - Remove flushToJSONL() wrapper function (was backward-compat shim) - Simplify markDirtyAndScheduleFlush/FullExport to just call FlushManager - Update tests to use FlushManager or flushToJSONLWithState directly FlushManager handles all flush state internally in its run() goroutine, eliminating the need for global state. Sandbox mode and tests that do not need flushing get a no-op when FlushManager is nil. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -74,17 +74,14 @@ var (
|
||||
rootCancel context.CancelFunc
|
||||
|
||||
// Auto-flush state
|
||||
autoFlushEnabled = true // Can be disabled with --no-auto-flush
|
||||
isDirty = false // Tracks if DB has changes needing export (used by legacy code)
|
||||
needsFullExport = false // Set to true when IDs change (used by legacy code)
|
||||
autoFlushEnabled = true // Can be disabled with --no-auto-flush
|
||||
flushMutex sync.Mutex
|
||||
flushTimer *time.Timer // DEPRECATED: Use flushManager instead
|
||||
storeMutex sync.Mutex // Protects store access from background goroutine
|
||||
storeActive = false // Tracks if store is available
|
||||
flushFailureCount = 0 // Consecutive flush failures
|
||||
lastFlushError error // Last flush error for debugging
|
||||
storeMutex sync.Mutex // Protects store access from background goroutine
|
||||
storeActive = false // Tracks if store is available
|
||||
flushFailureCount = 0 // Consecutive flush failures
|
||||
lastFlushError error // Last flush error for debugging
|
||||
|
||||
// Auto-flush manager (replaces timer-based approach to fix bd-52)
|
||||
// Auto-flush manager (event-driven, fixes bd-52 race condition)
|
||||
flushManager *FlushManager
|
||||
|
||||
// Hook runner for extensibility (bd-kwro.8)
|
||||
|
||||
Reference in New Issue
Block a user