refactor: align memory injection with Claude Code architecture#1329
Merged
Conversation
Move memory injection from system prompt to messages array (prepend + tail), persist conditional rules and task reminders to transcript as isMeta messages, and replace per-turn filesInContext rescan with event-driven triggers. - Unconditional rules: transient, prepended as <system-reminder> each turn - Conditional rules: event-driven via triggerFileRead() → processTriggeredRules(), persisted as isMeta user messages, dedup via loadedRuleIds Set - Task reminder: persisted to messageManager with <!-- task-reminder --> marker so turn counter correctly throttles to every 10 turns (fixes repeated firing bug) - Remove '## Memory Context' section from system prompt - Delete filesInContext, replaced with pendingFileReadTriggers + loadedRuleIds - Rename touchFile → triggerFileRead, hasFileInContext → hasFileBeenRead - Update specs 017-memory-management and 043-task-management-tools - All 3139 tests pass (1 skipped), type-check clean
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
Move memory injection from system prompt to messages array (prepend + tail), persist conditional rules and task reminders to transcript as
isMetamessages, and replace per-turnfilesInContextrescan with event-driven triggers — aligning Wave with Claude Code's architecture.Changes
Memory Injection Architecture (matches Claude Code)
paths): Transient, prepended as<system-reminder>each turnpaths): Event-driven viatriggerFileRead()→processTriggeredRules(), persisted asisMeta: trueuser messages, dedup vialoadedRuleIdsSet<!-- task-reminder -->marker so turn counter correctly throttles to every 10 turns (fixes repeated firing bug where reminder fired every turn once threshold crossed)API Changes
## Memory Contextsection from system promptfilesInContextSet, replaced withpendingFileReadTriggers+loadedRuleIdstouchFile()→triggerFileRead()hasFileInContext()→hasFileBeenRead()getMemoryForInjection()return type simplified:{ prependContent }(removedconditionalRules)processTriggeredRules()returns matched conditional rulesgetActiveRulesSplit()on MemoryRuleManagerSpec Updates
specs/017-memory-management.md: FR-016 (event-driven + persistence), FR-025 (loadedRuleIds), FR-026 (compaction), FR-027 deletedspecs/043-task-management-tools.md: FR-030 (persist to transcript asisMeta: true)Verification