Skip to content

feat(memory): semantic recall relevance floors (ADR-0074) + dogfood evidence - #668

Merged
delete-cloud merged 3 commits into
mainfrom
feat/semantic-recall-floors-adr-0074
Jul 3, 2026
Merged

delete-cloud merged 3 commits into
mainfrom
feat/semantic-recall-floors-adr-0074

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jul 3, 2026 •

Copy link
Copy Markdown
Owner

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):

  • D7 — semantic recall injects top-K cross-topic results for ANY query, with no relevance floor on either score kind (semantic similarity 1/(1+L2) or deterministic token-overlap). Live snapshots show scores 0.095–0.143 injected for entirely unrelated queries.
  • D8 — defer_when_semantic_memory_hits suppresses 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.
  • Filtering happens before plan assembly, so the KB-deferral marker counts only surviving hits — sub-floor-only queries now fall through to KB (structural D8 fix).
  • Direct TopicRecallPlanner consumers (ADR-0046 API, Bee, recall evaluation) unaffected; Helm knobs memory.semantic.recallMinScore/recallMinOverlap mirror kb.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

  • ADR gating: 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
  • Full suite: 4045 passed / 8 skipped / 20 xfailed (pre-change baseline 4025)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added optional semantic recall thresholds to improve result quality and make recall behavior configurable.
    • Added Helm configuration support for these new semantic memory settings.
  • Bug Fixes

    • Low-quality semantic recall matches can now be filtered out before planning, helping fallback retrieval run when no strong match is found.
    • Existing behavior remains unchanged when the new settings are left unset.
  • Tests

    • Added coverage for configuration parsing, rendering, and recall-threshold behavior.
  • Documentation

    • Added planning and evidence documents for semantic memory dogfooding and rollout verification.

delete-cloud and others added 2 commits July 3, 2026 11:15
…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>
@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@delete-cloud, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1a5f287f-6921-4daa-a8bf-64e5b7fd81ad

📥 Commits

Reviewing files that changed from the base of the PR and between b1f4c46 and 97b3338.

📒 Files selected for processing (2)
  • coding-agent/docs/dogfood/SEMANTIC_MEMORY_RUN_EVIDENCE.md
  • coding-agent/docs/dogfood/semantic_memory_dogfood.py
📝 Walkthrough

Walkthrough

This PR adds default-off per-source semantic recall relevance floors (recall_min_score, recall_min_overlap) with shared validation, config parsing, Helm rendering, and planner-level filtering in SemanticRecallPlanner/SemanticMemoryPlugin. It also adds ADR-0074, dogfood plan/evidence docs, a dogfood CLI harness, and extensive tests.

Changes

Semantic recall relevance floor feature

Layer / File(s) Summary
ADR and design rationale
coding-agent/docs/adr/0074-semantic-recall-relevance-threshold.md
Documents the two new config knobs, filtering location, rejected alternatives, and acceptance criteria for relevance floors.
Shared validation helper
coding-agent/src/coding_agent/topics/recall_floor.py
Adds validate_recall_floor to normalize/validate optional floor values within [0, 1].
Config parsing and Helm wiring
coding-agent/src/coding_agent/core/app.py, coding-agent/helm/templates/configmap-agent-config.yaml, coding-agent/helm/values.yaml
Adds recall_min_score/recall_min_overlap fields to SemanticMemoryConfig, parses/validates them from TOML, conditionally emits them in to_config_dict() and Helm templates, and adds Helm values defaulting to null.
Planner and plugin filtering logic
coding-agent/src/coding_agent/plugins/semantic_memory.py, coding-agent/src/coding_agent/topics/semantic_recall.py
SemanticMemoryPlugin validates and forwards floor values to SemanticRecallPlanner, which filters deterministic topic results by overlap and semantic hits by score before plan assembly.
Tests
coding-agent/tests/coding_agent/plugins/test_kb_plugin.py, coding-agent/tests/coding_agent/plugins/test_semantic_memory.py, coding-agent/tests/coding_agent/test_memory_switch.py, coding-agent/tests/coding_agent/test_semantic_recall.py, coding-agent/tests/deploy/test_helm_chart.py
Adds tests for config parsing/validation errors, planner floor filtering (including default-off regression), plugin filtering, KB deferral zero-grounding behavior, and Helm rendering/omission.
Dogfood plan, harness, and evidence
coding-agent/docs/dogfood/*
Adds a dogfood execution plan, a CLI harness script for running/recording phases against a live instance, and rendered/raw evidence artifacts.

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)
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: semantic recall relevance floors, with the dogfood evidence add-on also reflected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/semantic-recall-floors-adr-0074

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
coding-agent/src/coding_agent/topics/semantic_recall.py (1)

100-111: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Hoist the repeated floor check out of the branch.

_semantic_hit_satisfies_floor(hit) is called identically in both the TOPIC_SUMMARY and ACCEPTED_REVIEWED_MEMORY branches. Checking it once before the if/elif removes 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

📥 Commits

Reviewing files that changed from the base of the PR and between 011d0e6 and b1f4c46.

📒 Files selected for processing (16)
  • coding-agent/docs/adr/0074-semantic-recall-relevance-threshold.md
  • coding-agent/docs/dogfood/SEMANTIC_MEMORY_DOGFOOD_PLAN.md
  • coding-agent/docs/dogfood/SEMANTIC_MEMORY_RUN_EVIDENCE.md
  • coding-agent/docs/dogfood/semantic_memory_dogfood.py
  • coding-agent/docs/dogfood/semantic_memory_dogfood_evidence.jsonl
  • coding-agent/helm/templates/configmap-agent-config.yaml
  • coding-agent/helm/values.yaml
  • coding-agent/src/coding_agent/core/app.py
  • coding-agent/src/coding_agent/plugins/semantic_memory.py
  • coding-agent/src/coding_agent/topics/recall_floor.py
  • coding-agent/src/coding_agent/topics/semantic_recall.py
  • coding-agent/tests/coding_agent/plugins/test_kb_plugin.py
  • coding-agent/tests/coding_agent/plugins/test_semantic_memory.py
  • coding-agent/tests/coding_agent/test_memory_switch.py
  • coding-agent/tests/coding_agent/test_semantic_recall.py
  • coding-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>
@delete-cloud
delete-cloud merged commit a4b2eee into main Jul 3, 2026
2 checks passed
@delete-cloud
delete-cloud deleted the feat/semantic-recall-floors-adr-0074 branch July 3, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant