fix: continue PR #430 - hook dedup + resource singleton + backup timer guard#612
fix: continue PR #430 - hook dedup + resource singleton + backup timer guard#612jlin53882 wants to merge 1 commit intoCortexReach:masterfrom
Conversation
…exReach#603 cherry-pick) - store.ts: Replace unbounded promise chain with tail-reset semaphore - access-tracker.ts: Separate retry count map, cap at _maxRetries=5 - embedder.ts: TTL eviction on set() when near capacity - retrieval-stats.ts: Ring buffer replaces O(n) Array.shift() - noise-prototypes.ts: Lower DEDUP_THRESHOLD 0.95 -> 0.90 Cherry-picked from PR CortexReach#603 (jlin53882/memory-lancedb-pro)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b687062112
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else { | ||
| this._retryCount.set(id, retryCount); | ||
| // Requeue with the original delta only (NOT accumulated) for next flush. | ||
| this.pending.set(id, delta); |
There was a problem hiding this comment.
Preserve concurrent deltas when requeueing failed writes
When a flush is in progress, recordAccess() can add new increments for the same ID into pending; if the write then fails, this assignment overwrites that newer value with the stale batch delta, so accesses recorded during the failed flush are silently lost. This undercounts accessCount and can bias downstream decay/reinforcement behavior for active memories.
Useful? React with 👍 / 👎.
| this.logger.error( | ||
| `access-tracker: dropping ${id.slice(0, 8)} after ${retryCount} failed retries`, | ||
| ); |
There was a problem hiding this comment.
Avoid calling non-required logger.error in retry drop path
AccessTrackerOptions only requires warn (with optional info), but this branch unconditionally calls logger.error; integrations that provide a warn-only logger (which the current type allows) will throw TypeError after max retries are exceeded, aborting flush handling exactly on persistent failures. Use an optional call/fallback to warn to keep retry exhaustion non-fatal.
Useful? React with 👍 / 👎.
替換為 PR #617此 PR(#612)原本指向錯誤的 branch( 正確的 Phase 1 內容已移至 PR #617 → #617 差異說明
Issue #610追蹤:#610 |
PR #612 — Phase 1: Hook Event Deduplication
摘要
繼續 PR #430 的 Phase 1 內容。從 upstream/master (
0988a46) 為基礎,實作鉤子事件去重機制,防止 memory leak。變更內容(Phase 1 Only)
新增模組 (
index.ts)_hookEventDedup: module-levelSet<string>,儲存已處理的事件鍵_dedupHookEvent(handlerName, event): 去重函數,鍵格式handlerName:sessionKey:timestampreturn true(skip)三個 Handler 的 Guard 順序
agent:bootstrapisInternalReflectionSessionKey→:subagent:check →_dedupHookEventappendSelfImprovementNote!Array.isArray(messages)→_dedupHookEventrunMemoryReflection!sessionKey→_dedupHookEvent所有驗證都在
_dedupHookEvent之前,確保 invalid sessions 不會佔用去重鍵。未涵蓋(Phase 2 / 3)
_singletonState)測試覆蓋
24 個單元測試,全部通過 (
test/hook-dedup-phase1.test.mjs)驗證方式
/reset只觸發一次對應的 hook handler_hookEventDedupSet size 保持 bounded(≤200)Codex 對抗式審查
結果:Critical / High 問題 0 個
CriticalCriticalHighHighCommit History
5064e0e— feat: Phase 1 - hook event dedup singleton (index.ts)9b18625— fix: move sessionKey validation before dedup guard (Phase 1 Codex fix)cb458ce— feat: add unit tests + fix pruning logic7f2f476— test(phase1): add selfImprovement mock tests (24/24 pass)0c92567— ci: register hook-dedup-phase1 tests in core-regression group