feat: extract DailyMemoryStorage interface with pluggable storage filter#1051
Merged
feat: extract DailyMemoryStorage interface with pluggable storage filter#1051
Conversation
Extract a DailyMemoryStorage interface from DailyMemory (flat files) so the entire daily memory storage backend can be swapped via a single filter: datamachine_daily_memory_storage. DailyMemoryAbilities now resolves storage through resolveStorage() which fires the filter with the default filesystem implementation. Plugins like Intelligence can return their own DailyMemoryStorage implementation (WordPress pages, external services, etc.) and own the entire storage layer — read, write, append, list, search, delete — with one hook. Also removes the duplicative datamachine_daily_memory_archived action from DailyMemoryTask. The pre_archive filter handles the write override, and the storage interface handles everything else.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One filter to swap the entire daily memory storage backend:
Supersedes #1050 (closed) which used 5 per-operation filters — that was a code smell pointing at missing abstraction.
What changed
New
DailyMemoryStorageinterface (inc/Core/FilesRepository/DailyMemoryStorage.php)read,write,append,delete,list_all,searchDailyMemoryclass already hasDailyMemoryimplementsDailyMemoryStorageimplements DailyMemoryStorageto the class declarationDailyMemoryAbilitiesresolves storage via filterresolveStorage($user_id, $agent_id)methoddatamachine_daily_memory_storagefilter with the defaultDailyMemoryinstancenew DailyMemory()DailyMemoryStorage, falls back to defaultRemoved
datamachine_daily_memory_archivedaction fromDailyMemoryTaskpre_archivefilter handles write override, the storage interface handles read-backdatamachine_daily_memory_storagein thepre_archivedocblockHow Intelligence uses this
Intelligence hooks one filter and returns its own
DailyMemoryStorageimplementation that stores/reads daily memory as WordPress pages. One hook, total replacement. Data Machine doesn't know or care what's behind the interface.Files
inc/Core/FilesRepository/DailyMemoryStorage.phpinc/Core/FilesRepository/DailyMemory.phpimplements DailyMemoryStorageinc/Abilities/DailyMemoryAbilities.phpresolveStorage()+ filter, all methods use itinc/Engine/AI/System/Tasks/DailyMemoryTask.phpdatamachine_daily_memory_archivedaction