Repository navigation
fix(memory): rank indexed sessions by source activity - #139112
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 5, 2026, 11:02 AM ET / 15:02 UTC. ClawSweeper reviewWhat this changesMemory Core ranks indexed conversations by recorded source activity, preserves lexical fallback confidence, and orders vector fallback results before limiting them. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful fix for behavior still broken on current main. No blocking patch defects found; the earlier migration concern does not apply because the patch reads existing index metadata without changing stored representations. Priority: P2 Review scores
Verification
How this fits togetherMemory Core retrieves notes and indexed conversations for the memory_search tool. It combines keyword and semantic matches, applies ranking, and passes results through session visibility filtering before returning them to the agent. flowchart LR
A[Memory search query] --> B[Keyword and semantic retrieval]
C[Indexed source activity] --> D[Recency and importance ranking]
B --> D
D --> E[Hybrid diversity and result selection]
E --> F[Session visibility filtering]
F --> G[Results returned to agent]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -10, Tests +217, Docs +5. Total +212 across 9 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep one Memory Core ranking flow that consumes authoritative indexed activity while preserving confidence, visibility, and existing storage contracts. Do we have a high-confidence way to reproduce the issue? Yes, source-backed: current main looks for logical session paths under the workspace and slices vector results before final-score sorting. The supplied SQLite reproduction targets both defects; it was not executed during this review. Is this the best way to solve the issue? Yes. Reusing indexed source activity fixes the owning ranking boundary; reconstructing transcript filenames or substituting message timestamps would use the wrong source of recency. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 12a3b102f507. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
871ddef to
1852e6f
Compare
|
Final review of The latest ClawSweeper data-model checklist is addressed: this reads the existing The separate direct review initially proposed feeding private LIKE strength into MMR relevance. We withdrew that finding after checking the shipped unweighted tie-break contract and documented diversity policy: equal confidence and similarity preserve recency order at every MMR round, while different similarity may intentionally favor a diverse result. No ranking-policy change is warranted. The original report and disposition are retained; no accepted P2 findings remain. Proof exercises the real memory tool and SQLite/session/archive owners with fixture embeddings; it does not claim a live external embedding service or full Gateway deployment. Native stamped review validation passed. Proceeding through the repository prepare/merge workflow. |
|
Merged via squash.
|
* origin/main: (46 commits) fix(gateway): keep chat metadata responsive across auth refresh (openclaw#139192) fix(doctor): keep Workshop relocation lint read-only (openclaw#139193) perf(ui): retain unchanged forwarded avatar publications (openclaw#139181) fix(config): guide exec policy migration repairs (openclaw#139143) test(i18n): refresh representative Watch key (openclaw#139197) fix(agents): preserve recovered scheduled-run outcomes (openclaw#139037) refactor(acp): simplify pending operation accounting (openclaw#139189) fix(plugin-sdk): harden account scope for pairing requests and challenges (openclaw#139142) perf(gateway): avoid redundant PR landing ancestry checks (openclaw#139186) perf(ui): release captured audio cache leases directly (openclaw#139174) fix(skills): validate names in library forms (openclaw#139184) fix(sessions): reduce cold catalog listing delays (openclaw#139146) perf(cron): scan preserved action output once (openclaw#139163) fix(agents): keep fresh tool results readable under context pressure (openclaw#139165) fix(compaction): heartbeat sessions ignore the active transcript byte cap (openclaw#136533) perf(agents): reuse snapshotted web search result rows (openclaw#139162) fix(onboarding): keep Tauri setup recoverable and verify model results (openclaw#139140) fix(memory): rank indexed sessions by source activity (openclaw#139112) perf(terminal): avoid rebuilding sanitized link fallbacks (openclaw#139159) perf(agents): bound retained tool result projection data (openclaw#139157) ...
* fix(memory): rank session recall by source recency * fix(memory): weight lexical fallback ordering by recency
Closes #139094
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Fixes an issue where users searching indexed conversations would receive stale or incorrectly ordered recall results. Session recency could be lost, vector fallback could limit results before sorting their final scores, and short CJK substring matches could select an older session despite having its indexed activity timestamp.
This affects Memory Core retrieval through
memory_search, including keyword-only, lexical, hybrid and FTS-unavailable vector paths. The built-in manager already enables recency weighting with a 30-day half-life; there is no new operator toggle.Why This Change Was Made
Ranking now reads existing indexed source activity instead of trying to reconstruct a workspace filename for logical SQLite-backed session paths. The existing ranking pipeline applies that activity before selection, shares lexical finalization, and uses one tie-break comparator across exact and ordinary hybrid results.
Recall-only LIKE matches retain zero public confidence: their private ranking signal receives recency, importance and project weighting without turning substring recall into a scored semantic match. Positive and negative weighted confidence, raw retrieval diagnostics, exact-path precedence and message provenance remain intact.
User Impact
Indexed conversations and retained archives receive the expected recency weighting. Limited result windows select the correct final-ranked match, and unrelated workspace files cannot supply a session timestamp. Extra-memory file mtime behavior, evergreen exemptions and provider availability requirements are preserved.
The change removes 10 production lines overall: 88 added, 98 removed. Tests add 217 net lines; documentation adds five. No schema, migration, index layout, retention, configuration, SDK, public result shape, stored representation or embedding transport changes are introduced.
Evidence
Three failures were reproduced before their respective repairs using actual SQLite/session owners:
maxResults=1select the fresh session. No private availability override or unsupported hybrid-disable setting is used.记忆uses LIKE retrieval for two identical session transcripts. The existing API-shaped embedding fixture returns a valid all-zero vector, so both results retain publicscore=0,vectorScore=0andtextScore=0. Before repair, their private lexical tie-break bypassed decay and selectedsessions/main/a-old.jsonl; afterward the manager and realmemory_searchtool selectsessions/main/z-fresh.jsonl, including a one-result window. This connected gap predates the PR; the confidence contract is intentionally preserved.The expanded affected suite passed 80 tests across six files, covering the six-mode source-recency regression, actual archive lifecycle, workspace decoys, real tool execution, provenance, KNN/scan retrieval, exact-path/MMR ranking, cancellation, visibility and search-generation lifetimes. The existing LIKE helper fixture now covers absent, positive and negative vector confidence, including negative-score exclusion.
The full changed-file check passed, including formatting, production/test typechecking and declaration containment, doctor contracts, plugin boundaries, lint, dependency/coercion/deprecation/dead-export guards, database-first storage checks and zero runtime import cycles. A final mechanical consolidation then shared the identical tie-break comparator; all 35 manager/hybrid tests and targeted type-aware lint passed again on that final source.
git diff --checkpassed. The full gate is attributed to the immediately preceding comparator-equivalent snapshot, rather than claimed as a repeated final run.The source lookup runs under the search-generation lease, constrained to session results and retained candidate paths through one bound JSON set. Current caps allow at most 800 candidate references / 600 distinct paths, with at most one returned row per unique path/source. Memory-only results skip the lookup. No per-hit query or session-history enumeration is added.
For the ClawSweeper data-model proof request: no persistent transition is introduced, so a migration/format-transition test is inapplicable. The unchanged shipped schema already defines
mtime REAL NOT NULLandUNIQUE(path, source); the existing writer and parameterized reader retain those representations. The regressions verify those stored values before search. No compatibility shim or schema workaround is needed.Validation used a task-local frozen dependency install, Node 26.8.1 and pinned pnpm 12.3.4; lockfile supply-chain policies and applicable package lifecycle checks passed. Final staged autoreview is scoped-clean through P2, and the root/peer source challenges found no remaining semantic defect. CI run 33973263252 passed for committed head
685a9be80176f6a21193fcc1de36ead6b14a2e21(79 successful jobs, 16 skipped). The separate direct read-only review initially raised an MMR P2, then withdrew it after source/history/documentation review: LIKE strength is a shipped tie-break rather than MMR confidence, equal confidence and similarity retain recency order at every selection round, and the proposed example changed diversity. The original report is preserved with that disposition; no accepted findings remain through P2, and no code or tests changed for the adjudication. Earlier green CI at1852e6fpredates the added LIKE repair and is not claimed as proof of this final candidate.Proof boundary: deterministic local tests invoke the real tool and SQLite/session/archive owners with fixture embeddings. A booted Gateway/browser, live external embedding endpoint and remote installation were not exercised. Embedding transport and Gateway ingress are unchanged. Exact-head CI passed; native landing validation remains under maintainer ownership.