Fixes critical bug where brain.clear() did not fully clear storage:
Root causes:
1. _cow/ directory contents deleted but directory not removed
2. In-memory counters (totalNounCount, totalVerbCount) not reset
3. COW could auto-reinitialize on next operation
Fixes applied:
- FileSystemStorage: Delete entire _cow/ directory with fs.rm()
- OPFSStorage: Delete _cow/ with removeEntry({recursive: true})
- S3CompatibleStorage: Reset counters after clear
- BaseStorage: Guard initializeCOW() against reinit when cowEnabled=false
- All adapters: Reset totalNounCount and totalVerbCount to 0
Impact: Resolves Workshop bug report - storage now properly clears from
103MB to 0 bytes, entity counts correctly return to 0.
GCSStorage, R2Storage, AzureBlobStorage already had correct implementations.
|
||
|---|---|---|
| .. | ||
| adapters | ||
| cow | ||
| backwardCompatibility.ts | ||
| baseStorage.ts | ||
| cacheManager.ts | ||
| enhancedCacheManager.ts | ||
| enhancedClearOperations.ts | ||
| readOnlyOptimizations.ts | ||
| sharding.ts | ||
| storageFactory.ts | ||