fix: Phase 1 review fixes for PR #518 (issue #417)#534
fix: Phase 1 review fixes for PR #518 (issue #417)#534jlin53882 wants to merge 4 commits intoCortexReach:masterfrom
Conversation
…CortexReach#417) - Fix #1: buildAutoCaptureConversationKeyFromIngress — DM fallback to channelId (fixes pendingIngressTexts never being written for Discord DM) - Fix #2: cumulative counting — autoCaptureSeenTextCount accumulates, not overwrites (fixes eligibleTexts.length always 1 for DM, extractMinMessages never satisfied) - Fix #3: REPLACE vs APPEND — use pendingIngressTexts as-is when present (avoids deduplication issues from text appearing in both sources) - Fix #5: isExplicitRememberCommand guard with lastPending fallback (preserves explicit remember command behavior in DM context) - Fix #6: Math.min cap on extractMinMessages (max 100) — prevents misconfiguration - Fix #7: MAX_MESSAGE_LENGTH=5000 guard in message_received hook - Smart extraction threshold now uses currentCumulativeCount (turn count) instead of cleanTexts.length (per-event message count) - Debug logs updated to show cumulative count context All 29 test suites pass. Based on official latest (5669b08).
…turn counting test + changelog - Fix #1: buildAutoCaptureConversationKeyFromIngress DM fallback - Fix #2: currentCumulativeCount (cumulative per-event counting) - Fix #3: REPLACE vs APPEND + cum count threshold for smart extraction - Fix #4: remove pendingIngressTexts.delete() - Fix #5: isExplicitRememberCommand lastPending guard - Fix #6: Math.min extractMinMessages cap (max 100) - Fix #7: MAX_MESSAGE_LENGTH=5000 guard - Add test: 2 sequential agent_end events with extractMinMessages=2 - Add changelog: Unreleased section with issue details
…move dead isExplicitRememberCommand guard (PR CortexReach#518 review fixes)
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
I'll analyze this and get back to you. |
Review SummaryVerdict: REQUEST-CHANGES | Value: 54% | Size: MEDIUM What This PR DoesFixes single-turn DM conversations falling through to regex fallback instead of smart-extracted memories, by making Must Fix
Scope Drift
|
|
This PR has been superseded by PR #549, which resolves all blocking concerns from the PR #534 review (Must Fix #1, #2, #3, and Minor item #4) and additionally corrects a placement bug in Fix #1 identified during adversarial review. Summary of fixes in #549:
|
…rsedes #518, #534) (#549) * fix: auto-capture cumulative turn counting for smart extraction (issue #417) - Fix #1: buildAutoCaptureConversationKeyFromIngress — DM fallback to channelId (fixes pendingIngressTexts never being written for Discord DM) - Fix #2: cumulative counting — autoCaptureSeenTextCount accumulates, not overwrites (fixes eligibleTexts.length always 1 for DM, extractMinMessages never satisfied) - Fix #3: REPLACE vs APPEND — use pendingIngressTexts as-is when present (avoids deduplication issues from text appearing in both sources) - Fix #5: isExplicitRememberCommand guard with lastPending fallback (preserves explicit remember command behavior in DM context) - Fix #6: Math.min cap on extractMinMessages (max 100) — prevents misconfiguration - Fix #7: MAX_MESSAGE_LENGTH=5000 guard in message_received hook - Smart extraction threshold now uses currentCumulativeCount (turn count) instead of cleanTexts.length (per-event message count) - Debug logs updated to show cumulative count context All 29 test suites pass. Based on official latest (5669b08). * fix: re-apply all 7 fixes for issue #417 + add cumulative turn counting test + changelog - Fix #1: buildAutoCaptureConversationKeyFromIngress DM fallback - Fix #2: currentCumulativeCount (cumulative per-event counting) - Fix #3: REPLACE vs APPEND + cum count threshold for smart extraction - Fix #4: remove pendingIngressTexts.delete() - Fix #5: isExplicitRememberCommand lastPending guard - Fix #6: Math.min extractMinMessages cap (max 100) - Fix #7: MAX_MESSAGE_LENGTH=5000 guard - Add test: 2 sequential agent_end events with extractMinMessages=2 - Add changelog: Unreleased section with issue details * docs: update changelog - add test file reference and improve breaking change label * fix: Phase 1 - createMockApi accepts pluginConfigOverrides param + remove dead isExplicitRememberCommand guard (PR #518 review fixes) * fix: resolve all Must Fix items from PR #534 review (issue #417) * fix: move currentCumulativeCount reset inside success block (Fix #9) * fix: add try-catch around extractAndPersist to prevent hook crash on extraction failure (Fix #10) * fix: clear pendingIngressTexts in catch block on extraction failure (Fix #10 extended) * fix: add conversationKey guard to Fix #8 + restore test comment * fix: Must Fix 1/2/5 from PR #549 review - counter reset always, newTexts counting, Fix#8 assertion * fix: Must Fix 1 revised - reset counter to previousSeenCount on all-dedup (reviewer suggestion) * fix: revert Must Fix #2 (eligibleTexts.length counting restored) - preserves extractMinMessages semantics * fix: correct test expectation - collected 1 not 2 text(s) after counter formula revert (e5b5e5b) * fix: replace throw in hook with safe return (Fix-Must5) * fix: remove unreachable conversationKey guard (Claude Code review) * fix(issue-417): skip regex fallback when all candidates skipped with no boundary texts (Fix-Must1b) * test(issue-417): add Fix-Must1b DM fallback regression test * fix(issue-417): F1 success block counter reset + rate limiter inside success path (rwmjhb review) * fix(issue-417): document intentional non-reset of counter after regex fallback * fix(issue-417): MR1 counter虛增 + MR2 cap不合理(Codex對抗式review實作) - MR1: currentCumulativeCount 改用 newTexts.length 而非 eligibleTexts.length,防止重複full-history payload導致counter虛增 - MR2: 抽出 AUTO_CAPTURE_PENDING_WINDOW=6 常數, 讓 queue.slice(-6)、slice(-6)、Math.min(...,100) 三處 共用同一常數,消除magic number並與threshold cap對齊 * test(issue-417): F5 counter reset success-path regression test 新增 runCounterResetSuccessScenario() 測試 Fix #9(counter 在成功提取後 reset)。 - Turn 1: cumulative=1 < 2, skip - Turn 2: cumulative=2 >= 2, trigger extraction, LLM returns SUCCESS -> Fix #9: counter resets to 0 - Turn 3: cumulative restarts from 0 -> +1 = 1 < 2, skip 關鍵 assertion: 1. LLM 只被 call 一次(turn 2 成功後 turn 3 不再 trigger) 2. Turn 2 成功 log 出現 3. Turn 3 觀察到 cumulative=1 < minMessages=2,正確 skip * fix(issue-417): 修復維護者review問題 - test mock schema + 移除runtime cap * fix(issue-417): below-threshold return + CHANGELOG sync (rwmjhb review fix) * fix(issue-417): remove stale [Fix #6] comment + fix CHANGELOG PR number * fix(issue-417): Issue2 export fn + Issue3 Fix#5 explicit remember guard + Issue2 unit test * test(issue-417): add R2 Stage 2 LLM dedup + R3 DM key fallback integration tests * fix(issue-417): correct misleading comment — counter uses newTexts.length not eligibleTexts.length Fixes rwmjhb Nice-to-have: comment at line ~2830 stated the counter uses eligibleTexts.length, but the actual code (since MR1 commit 2ac682d) uses newTexts.length. Updated comment to accurately describe the newTexts.length approach and explain why it is correct vs eligibleTexts.length. * fix(issue-417): MF1 explicit-remember prepend, MF3 counter based on texts.length * fix(issue-417): MF1 v2 - avoid lastPending duplicate in REPLACE mode * fix(issue-417): MF3 move let texts before counter; fix MF1 typo * fix(issue-417): MF1 v3 - includes() check; revert MF3 to newTexts.length * fix(issue-417-mustfixes): MF2 - move R2 dedup scenario to module scope * fix(pr549/issue-417): export buildAutoCaptureConversationKeyFromIngress, DM fallback, MAX_MESSAGE_LENGTH guard, cumulative counting, counter reset, try-catch handlers * fix(test): remove non-existent log assertion in multi-round scenario (Must-Fix 3) Root cause: line 501 asserted a log message that never existed in production code. The 'created [preferences]...' format does not exist in smart-extractor.ts or index.ts. Preserved the actual log assertions: 'merged [preferences]' and 'skipped [preferences]'. Also preserved entry content validation (entries[0].text). --------- Co-authored-by: James <james53882@users.noreply.github.com> Co-authored-by: OpenClaw Agent <agent@openclaw.ai> Co-authored-by: jlin53882 <jlin53882@users.noreply.github.com> Co-authored-by: OpenClaw Agent <agent@openclaw.dev>

Summary
Phase 1 fixes for PR #518 review feedback. These are pure cleanup fixes with no semantic changes:
createMockApinow accepts an optional 5thpluginConfigOverridesparameterisExplicitRememberCommandguard)See original PR #518 for the main feature.
Phase 1 Changes
Fix 1:
createMockApiaccepts pluginConfigOverrides (test/smart-extractor-branches.mjs)The test was calling
createMockApi(..., { extractMinMessages: 2, smartExtraction: true })as a 5th parameter, but the function only accepted 4 parameters. The 5th argument was silently ignored.pluginConfigOverridesis spread intopluginConfig, allowing tests to override defaults.Fix 2: Removed dead
isExplicitRememberCommandguard (index.ts)The guard:
This is unreachable under the REPLACE strategy (Fix #3 of PR #518):
texts = newTexts = pendingIngressTexts(REPLACE mode)pendingIngressTextsis a rolling window of up to 6 messagestexts.length === 1can only be true whenpendingIngressTexts.length === 1pendingIngressTexts.lengthgrows from 1→2→...→6Testing
smart-extractor-branches.mjs: passes ✅npm test: all pre-existing tests pass ✅Known Issues (Out of Scope for Phase 1)
PR #518 has 2 pre-existing test failures in
strip-envelope-metadata.test.mjs(tests #12 and #13) caused by other changes in the PR, unrelated to these Phase 1 fixes.Phase 2 Discussion Points (pending maintainer input)
The following design questions need maintainer input before Phase 2 can proceed:
pendingIngressTextsfrom being consumed twice ifagent_endfires without a precedingmessage_received?extractMinMessagessemantic change: This PR changes semantics from "per-event message count" to "cumulative turns". Is this acceptable?isExplicitRememberCommandguard removal: What was the original intent of this guard? Is removing it correct?