fix: idempotent register guard + governance detail logging#365
Open
jlin53882 wants to merge 1 commit intoCortexReach:masterfrom
Open
fix: idempotent register guard + governance detail logging#365jlin53882 wants to merge 1 commit intoCortexReach:masterfrom
jlin53882 wants to merge 1 commit intoCortexReach:masterfrom
Conversation
- Add _initialized singleton flag to prevent re-initialization when register() is called multiple times during gateway boot - Add per-entry debug logging for governance filter decisions (id, reason, score, text snippet) for observability - Export _resetInitialized() for test harness reset - Fixes initialization block repeated N times on startup - Fixes governance filter decisions not observable in logs
This was referenced Mar 27, 2026
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
Two fixes for
memory-lancedb-proplugin:1. Idempotent
register()guardProblem: During gateway boot, OpenClaw calls
register()multiple times (once per agent session). Without a guard, the expensive initialization (MemoryStore, embedder, hooks) runs every time, causing redundant initialization blocks in logs.Fix: Add
let _initialized = falsemodule-level flag. On repeatedregister()calls, log a debug message and return early.Export
_resetInitialized()for test harness reset.2. Governance filter observability
Problem: Governance filter decisions were only logged as aggregate counts (
stateFiltered=N), making it impossible to trace which entries were filtered and why without replaying.Fix: Add per-entry debug log with id, reason, score, and text snippet:
Testing
All regression tests passed!)initialized successfullyonly onceFiles changed
index.ts: +14 lines (guard + logging + export)