feat(phase2): Singleton State Management (PR #598, 4 commits)#637
Open
jlin53882 wants to merge 5 commits intoCortexReach:masterfrom
Open
feat(phase2): Singleton State Management (PR #598, 4 commits)#637jlin53882 wants to merge 5 commits intoCortexReach:masterfrom
jlin53882 wants to merge 5 commits intoCortexReach:masterfrom
Conversation
…variable (PR CortexReach#598) - Add PluginSingletonState interface: defines all 18 properties returned by the singleton factory (8 heavy resources + 8 session Maps with their types) - Add module-level _singletonState: null until first register() call - Add _initPluginState(api) factory skeleton: returns PluginSingletonState This commit only adds the interface and skeleton. The factory body is empty (returns null!) and will be filled in subsequent commits.
…ll (PR CortexReach#598) - Replace the old init block (config, store, embedder, tierManager, retriever, scopeManager, migrator, smartExtractor, extractionRateLimiter) with: - if (!_singletonState) guard that calls _initPluginState() - destructuring of all 18 properties from _singletonState - The factory _initPluginState() body is still empty (returns null!) — filled in the next commit - Helpers section is unchanged but will reference undefined values until the factory body is added in the next commit (expected state)
…ers (PR CortexReach#598) The helpers section had 8 Map declarations that are now created once in _singletonState and accessed via destructuring. Remove them to prevent duplicate declarations that would cause TypeScript errors. Maps removed from helpers: - reflectionErrorStateBySession - reflectionDerivedBySession - reflectionByAgentCache - recallHistory - turnCounter - autoCaptureSeenTextCount - autoCapturePendingIngressTexts - autoCaptureRecentTexts
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
migrator was returned by _initPluginState() but missing from the singleton destructuring, causing ReferenceError at createMemoryCLI() call site (index.ts:2286). This was the root cause of CI failures in PR CortexReach#598.
Contributor
Author
CI 狀態說明
|
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.
Phase 2: Singleton State Management
Split into 4 clean commits for reviewer convenience.
Commits
0a74a95PluginSingletonStateinterface +_singletonStatevariable + empty_initPluginState()skeletondc027992bbab76_initPluginState()body with all resources (store, embedder, tierManager, retriever, 8 Maps, etc.)9c466abMotivation
The old
register()function ran a ~140-line init block on every call. In multi-agent processes with 9 scope registrations per lifecycle, this created duplicate heavy resources (stores, embedders, tier managers) and accumulated session Maps across re-registrations.Solution
_initPluginState(api)factory functionif (!_singletonState)— first call initializes, subsequent calls reuseTesting
openclaw memory-pro stats_hookEventDedup/_dedupHookEventremain intact_initPluginStatereturnFiles Changed
index.ts: single file refactor, no new tests required for infrastructure changeNotes
return null!— breaks TypeScript compilation until C3 fills it. This is expected for the commit-split strategy.