Repository navigation
feat(memory): semantic recall relevance floors (ADR-0074) + dogfood evidence - #668
Conversation
…dence 8-round reviewed plan, 4-round reviewed operator harness (IDs-only privacy schema), and the 2026-07-02/03 live run evidence that surfaced defects D0-D8 including the D7/D8 recall-quality pair fixed by ADR-0074. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Live o6n dogfood evidence showed semantic recall injects top-K cross-topic results for any query (similarity 0.095-0.143 on unrelated queries) and defer_when_semantic_memory_hits then suppresses KB retrieval permanently (zero KB references in all probed run snapshots). Add default-off per-source floors applied before plan assembly: - [memory.semantic].recall_min_score for semantic-sourced hits (topic summaries and accepted-memory hits; score-less session-store records exempt), l2_distance_to_similarity_v1 scale - [memory.semantic].recall_min_overlap for deterministic token-overlap hits The KB-deferral marker counts the filtered plan, so sub-floor-only queries now let KB run (D8 fixed structurally). Direct TopicRecallPlanner consumers are unaffected. Helm renders memory.semantic.recallMinScore/recallMinOverlap mirroring kb.maxDistance. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 34 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds default-off per-source semantic recall relevance floors ( ChangesSemantic recall relevance floor feature
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant App as core/app.py
participant Plugin as SemanticMemoryPlugin
participant Planner as SemanticRecallPlanner
App->>Plugin: recall_min_score, recall_min_overlap
Plugin->>Plugin: validate_recall_floor()
Plugin->>Planner: recall_min_score, recall_min_overlap
Planner->>Planner: _filter_deterministic_results(topic_results)
Planner->>Planner: _semantic_hit_satisfies_floor(hit)
Planner-->>Plugin: filtered plan (topic_hits, memory_hits)
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
coding-agent/src/coding_agent/topics/semantic_recall.py (1)
100-111: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueHoist the repeated floor check out of the branch.
_semantic_hit_satisfies_floor(hit)is called identically in both theTOPIC_SUMMARYandACCEPTED_REVIEWED_MEMORYbranches. Checking it once before theif/elifremoves the duplication:♻️ Proposed refactor
for hit in semantic_hits: document_id = SemanticDocId.parse(hit.memory_id) + if not self._semantic_hit_satisfies_floor(hit): + continue if document_id.kind is SemanticDocKind.TOPIC_SUMMARY: - if not self._semantic_hit_satisfies_floor(hit): - continue topic_hits.append(hit) elif document_id.kind is SemanticDocKind.ACCEPTED_REVIEWED_MEMORY: - if not self._semantic_hit_satisfies_floor(hit): - continue memory_hits.append(hit)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@coding-agent/src/coding_agent/topics/semantic_recall.py` around lines 100 - 111, Hoist the repeated floor check out of the branching in semantic_recall.py: the _semantic_hit_satisfies_floor(hit) guard is duplicated in both the TOPIC_SUMMARY and ACCEPTED_REVIEWED_MEMORY paths inside the loop over semantic_hits. Update the logic around SemanticDocId.parse and the document_id.kind checks so the floor predicate is evaluated once per hit before entering the kind-specific branches, then keep the existing topic_hits and memory_hits append behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@coding-agent/docs/dogfood/semantic_memory_dogfood.py`:
- Around line 522-528: The ensure_topic_store_available gate currently raises
HarnessError without recording the failure, so add a fail-record write to
semantic_memory_dogfood_evidence.jsonl before the exception is raised. Use the
existing evidence-writing path used by record_status_snapshot (or the same
underlying helper) inside ensure_topic_store_available so the false
topic_store_available condition is captured with the current phase and status
context, then raise HarnessError as before.
In `@coding-agent/docs/dogfood/SEMANTIC_MEMORY_RUN_EVIDENCE.md`:
- Around line 3-12: The Markdown evidence report is out of sync with the
underlying `semantic_memory_dogfood_evidence.jsonl` data, so regenerate it from
the source JSONL rather than editing the summary by hand. Re-run the
`docs/dogfood/semantic_memory_dogfood.py report` flow that produces
`SEMANTIC_MEMORY_RUN_EVIDENCE.md`, then recommit the updated report so the
`Summary` counts and rendered records match the full committed evidence set.
---
Nitpick comments:
In `@coding-agent/src/coding_agent/topics/semantic_recall.py`:
- Around line 100-111: Hoist the repeated floor check out of the branching in
semantic_recall.py: the _semantic_hit_satisfies_floor(hit) guard is duplicated
in both the TOPIC_SUMMARY and ACCEPTED_REVIEWED_MEMORY paths inside the loop
over semantic_hits. Update the logic around SemanticDocId.parse and the
document_id.kind checks so the floor predicate is evaluated once per hit before
entering the kind-specific branches, then keep the existing topic_hits and
memory_hits append behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b3eb0b79-44df-40a9-977a-a4b6d4398fbc
📒 Files selected for processing (16)
coding-agent/docs/adr/0074-semantic-recall-relevance-threshold.mdcoding-agent/docs/dogfood/SEMANTIC_MEMORY_DOGFOOD_PLAN.mdcoding-agent/docs/dogfood/SEMANTIC_MEMORY_RUN_EVIDENCE.mdcoding-agent/docs/dogfood/semantic_memory_dogfood.pycoding-agent/docs/dogfood/semantic_memory_dogfood_evidence.jsonlcoding-agent/helm/templates/configmap-agent-config.yamlcoding-agent/helm/values.yamlcoding-agent/src/coding_agent/core/app.pycoding-agent/src/coding_agent/plugins/semantic_memory.pycoding-agent/src/coding_agent/topics/recall_floor.pycoding-agent/src/coding_agent/topics/semantic_recall.pycoding-agent/tests/coding_agent/plugins/test_kb_plugin.pycoding-agent/tests/coding_agent/plugins/test_semantic_memory.pycoding-agent/tests/coding_agent/test_memory_switch.pycoding-agent/tests/coding_agent/test_semantic_recall.pycoding-agent/tests/deploy/test_helm_chart.py
CodeRabbit review on #668: ensure_topic_store_available now appends a topic_store_available=false evidence record before raising (evidence-before- gate consistency), and the rendered report is regenerated to include the Phase 0 baseline records (17 -> 20). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Fixes the D7/D8 recall-quality defect pair surfaced by the 2026-07-02/03 live o6n semantic-memory dogfood (evidence in this PR).
Defects (snapshot-evidenced on the live instance):
1/(1+L2)or deterministic token-overlap). Live snapshots show scores 0.095–0.143 injected for entirely unrelated queries.defer_when_semantic_memory_hitssuppresses KB on any nonzero hit count, so with D7 the KB never runs: all probed run snapshots contain a Cross-topic recall section and zero KB references sections, while the sre KB corpus verifiably contains the queried facts.Fix (ADR-0074, default-off):
[memory.semantic].recall_min_score— floors all semantic-sourced hits (topic summaries AND accepted-memory hits; score-less session-store records exempt).[memory.semantic].recall_min_overlap— floors deterministic token-overlap results.TopicRecallPlannerconsumers (ADR-0046 API, Bee, recall evaluation) unaffected; Helm knobsmemory.semantic.recallMinScore/recallMinOverlapmirrorkb.maxDistance.Also lands: the reviewed dogfood plan, IDs-only operator harness, and run evidence (
docs/dogfood/). The defect ledger there (D0–D8, F2–F5) seeds follow-up work; production floor values will be calibrated on o6n per the ADR before opting in via the private values repo.Review provenance: plan 8-round codex-reviewed to 0 P1/P2; harness 4-round reviewed; this implementation codex-authored and 2-round subagent-reviewed to 0 P1/P2, with all P3s (accepted-memory floor, exemption regression guard, DRY validator hoist) applied.
Test plan
uv run pytest tests/coding_agent/test_semantic_recall.py tests/coding_agent/plugins/test_semantic_memory.py tests/coding_agent/plugins/test_kb_plugin.py tests/coding_agent/test_memory_switch.py tests/deploy/test_helm_chart.py -q→ 159 passed🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation