feat(reflection): Option B BM25 neighbor expansion for fresh sessions (Issue #513) #523
feat(reflection): Option B BM25 neighbor expansion for fresh sessions (Issue #513) #523jlin53882 wants to merge 3 commits intoCortexReach:masterfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…each#513) CRITICAL fixes: 1. Neighbor timestamp: now -> candidate.timestamp (fix aggregation text override bug) 2. Guard order: enabled check before scopeFilter (fix config.enabled=false bypass) 3. Add await to loadAgentReflectionSlicesFromEntries calls in index.ts 4. Add await + async to memory-reflection.test.mjs (8 tests fixed) 5. Add bm25NeighborExpansion to parsePluginConfig (config from openclaw.json now works) Other fixes: - Remove unused 'now' variable (timestamp now comes from candidate) - Update outdated comment about fresh session BM25 expansion behavior
Critical Bugs Fixed (v2)經過深度對抗 review,發現並修復了以下 Critical bugs: 🔴 Fixed: Neighbor timestamp 覆蓋 derived 文字
🔴 Fixed: Guard 順序enabled === false 檢查移到 scopeFilter === undefined 之前
🔴 Fixed: loadAgentReflectionSlicesFromEntries async callerindex.ts 兩處呼叫都已加 �wait
🔴 Fixed: parsePluginConfig 缺少 bm25NeighborExpansion�m25NeighborExpansion 現在會正確從 openclaw.json 讀取 🔴 Fixed: memory-reflection.test.mjs 缺 async/await8 個測試從 24 通過 → 32 通過(+8) 測試結果\ 待確認等待 maintainer review 確認修復完整性。 |
Summary實作 Option B Phase 1: BM25 Neighbor Expansion for Reflection Slices,解決 Issue #513 中 reviewer 提出的核心問題。 MotivationIssue #513#513 [Proposal B Phase 1] Seeking guidance: redesign approach for BM25 neighbor expansion AliceLJY 的建議:
PR #503(已關閉,Architectural Reference)#503 feat(B-1): Scope-aware BM25 neighbor expansion for reflection slices (v3) — CLOSED PR #503 實作 post-hoc expansion(在
PR #523 根據 AliceLJY 的 Option B 建議重新設計,在 ImplementationArchitectureCore Logic
Configbm25NeighborExpansion?: {
enabled?: boolean; // default: true
maxCandidates?: number; // default: 5
maxNeighborsPerCandidate?: number; // default: 3
}Example in {
"plugins": {
"memory-lancedb-pro": {
"bm25NeighborExpansion": {
"enabled": true,
"maxCandidates": 5,
"maxNeighborsPerCandidate": 3
}
}
}
}Defense Mechanisms(D1~D6)
Changes
Critical Bugs Fixed(v1 → v2)
Test Results待 Maintainer 確認請審閱以下幾點:
感謝審閱!🙏 |
PR #523 變更內容詳細說明作者您好,以下是本 PR 的變更分類說明: 實際變更範圍(排除 encoding 差異)
建議拆分方案(可接受)如果需要拆分,建議分為 2 個 PR: PR A:相容性修復(必要的底層修改)理由: 變更:
PR B:Option B Feature(核心功能)理由:Issue #513 的 Option B 實作是新功能,獨立於相容性修復。 變更:
如果不拆分本 PR 包含所有變更,可一次審查。缺點是範圍較大,優點是所有變更都有明確關聯(都是為了實作 Option B)。 請告知您偏好的處理方式,謝謝! |
PR #523 修復說明(Encoding Fixed)抱歉,上一個 comment 因 encoding 問題顯示為亂碼。以下是完整的修復說明: 5 個 Critical Bugs 已修復
測試結果
關於 Issue #445本 PR 的實作方向與 Issue #445(Proposal A & B Implementation Analysis)相關。Issue #513 的 Option B 建議是根據 Issue #445 的分析架構來的。 關於 PR 拆分如果範圍太大需要拆分,建議分為:
請告知您偏好的處理方式,謝謝! |
|
Hi @jlin53882, the |
rwmjhb
left a comment
There was a problem hiding this comment.
Review: feat(reflection): Option B BM25 neighbor expansion for fresh sessions
这个 PR 有几个阻塞问题,建议重新提交一个干净的版本。
Must Fix
-
candidateTimestamp 丢失: Promise chain 中
candidateTimestamp被 drop 了,运行时所有 neighbor timestamp 都是undefined,核心功能不可用。 -
Fresh-session early return: D1 阶段在 derived 为空时直接 return,但这个 PR 的目标恰恰是解决 fresh session 没有 derived 的问题——early return 把核心 use case 打断了。
-
编码问题:
index.ts和test/memory-reflection.test.mjs因为 PowerShell UTF encoding artifact 导致 diff 膨胀到 ~8300 行,实际有效改动只有 ~10 行。行级 review 几乎不可能。建议用git config core.autocrlf或.gitattributes修复后重新提交。 -
Full test suite 180s 超时: 新增的 5 次 BM25 search per
loadAgentReflectionSlicesFromEntries调用可能是原因。
Questions
- 有做过 latency profiling 吗?5 次 BM25 search 在典型负载下的开销?
- CI cli-smoke 失败是 pre-existing 还是这个 PR 引入的?
建议清理编码问题后重新提交。
|
Closing — implementation has fundamental issues (timestamp dropped, fresh-session early return defeats purpose, encoding artifacts make review impractical). Please resubmit a clean version addressing the review findings. |
Summary
Proposal B Phase 1: Scope-aware BM25 neighbor expansion for reflection slices.
處理的內容
核心功能
在
loadAgentReflectionSlicesFromEntries的rankReflectionLines()之前加入 BM25 expansion:Issue #513 的解決方案
防禦機制(從 PR #503 保留並強化)
seen = new Set()空初始化(避免重複)scopeFilter !== undefinedguard新增測試
17 個單元測試,使用 jiti import + standalone mock,jiti v2 ESM transpilation 正常
技術細節
async/await以避免 jiti v2 TypeScript transpiler 的 parse errorbm25NeighborExpansionconfig 開關(default enabled)測試結果