Skip to content

fix(search): exclude retracted claims and archived pages - #584

Open
kurosawareiji7007-hub wants to merge 1 commit into
vouchdev:testfrom
kurosawareiji7007-hub:fix/search-exclude-retracted
Open

fix(search): exclude retracted claims and archived pages#584
kurosawareiji7007-hub wants to merge 1 commit into
vouchdev:testfrom
kurosawareiji7007-hub:fix/search-exclude-retracted

Conversation

@kurosawareiji7007-hub

@kurosawareiji7007-hub kurosawareiji7007-hub commented Jul 29, 2026

Copy link
Copy Markdown

what changed

search_kb (the shared kb.search path) now drops retracted claims and archived pages after scope filtering, matching kb.context.

why

#78 taught context to honour archive/supersede/redact. search never got the same filter, so agents calling kb.search after recall could still retrieve retracted knowledge.

validation

python -m pytest tests/test_context.py::test_search_kb_excludes_retracted_claims -q
python -m ruff check src/vouch/context.py tests/test_context.py
python -m mypy src/vouch/context.py

Fixes #581

Summary by CodeRabbit

  • Bug Fixes
    • Search results now exclude retracted claims and archived pages.
    • Archived, superseded, and redacted knowledge no longer appears in detail-search results.
    • Live results are prioritized so excluded items do not reduce the requested result count.

kb.context already drops ARCHIVED/SUPERSEDED/REDACTED claims; kb.search
did not, so lifecycle controls leaked on the detail-search surface.

Fixes vouchdev#581

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

search_kb now filters retracted claims and archived pages before applying result limits. A regression test covers lifecycle changes, and the changelog documents the behavior.

Changes

Search lifecycle filtering

Layer / File(s) Summary
Filter search results for live artifacts
src/vouch/context.py
search_kb scopes results without a limit, removes retracted claims and archived pages, ignores missing artifacts, and then applies the final limit.
Validate lifecycle filtering
tests/test_context.py, CHANGELOG.md
Regression coverage verifies lifecycle filtering, and the unreleased changelog documents the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • vouchdev/vouch#79: Adds related lifecycle filtering behavior to the context-pack retrieval path.

Suggested reviewers: plind-junior, dripsmvcp, galuis116

🚥 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 Title clearly states the main fix: excluding retracted claims and archived pages from search.
Linked Issues check ✅ Passed search_kb now filters ARCHIVED/SUPERSEDED/REDACTED claims and ARCHIVED pages after scope filtering, with regression coverage.
Out of Scope Changes check ✅ Passed Changes are limited to the search fix, test, and changelog note; no unrelated behavior appears introduced.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added docs documentation, specs, examples, and repo guidance retrieval context, search, synthesis, and evaluation tests tests and fixtures size: S 50-199 changed non-doc lines labels Jul 29, 2026
@kurosawareiji7007-hub

Copy link
Copy Markdown
Author

ready for review — regression in tests/test_context.py::test_search_kb_excludes_retracted_claims. please consider label bug if accurate.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/test_context.py (1)

175-207: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

exercise SUPERSEDED and REDACTED too.

This test only transitions a claim to archived. Parameterize or add cases for the other retracted statuses so a regression affecting only those statuses cannot pass while violating the stated lifecycle contract.

🤖 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 `@tests/test_context.py` around lines 175 - 207, The
test_search_kb_excludes_retracted_claims coverage only verifies ARCHIVED claims.
Extend it to exercise SUPERSEDED and REDACTED claim transitions as well, using
parameterized cases or separate cases while preserving the existing assertions
that live claims/pages remain searchable and retracted claims do not.
src/vouch/context.py (1)

522-523: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

keep code comments lowercase.

Start the added comment with lowercase prose.

As per path instructions, “use lowercase prose in comments and review notes.”

🤖 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 `@src/vouch/context.py` around lines 522 - 523, Update the added comment near
the status-filtering search logic so its prose starts with lowercase text, while
preserving the existing wording and behavior.

Source: Path instructions

🤖 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 `@src/vouch/context.py`:
- Around line 522-525: Update the retrieval flow around filter_hits and
_filter_live_hits so candidate collection continues beyond the backend’s
fetch_limit before lifecycle filtering, allowing retracted or archived hits to
be replaced by later live candidates. Reuse the shared
storage/proposals/lifecycle path rather than duplicating filtering logic, and
preserve the requested limit in the final live results.

---

Nitpick comments:
In `@src/vouch/context.py`:
- Around line 522-523: Update the added comment near the status-filtering search
logic so its prose starts with lowercase text, while preserving the existing
wording and behavior.

In `@tests/test_context.py`:
- Around line 175-207: The test_search_kb_excludes_retracted_claims coverage
only verifies ARCHIVED claims. Extend it to exercise SUPERSEDED and REDACTED
claim transitions as well, using parameterized cases or separate cases while
preserving the existing assertions that live claims/pages remain searchable and
retracted claims do not.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c0e0470-8afe-4a5f-910f-3bcda06062ae

📥 Commits

Reviewing files that changed from the base of the PR and between 1fe8fb5 and d0cd394.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/vouch/context.py
  • tests/test_context.py

Comment thread src/vouch/context.py
Comment on lines +522 to +525
# Scope first without a limit so status filtering can refill the window —
# otherwise a page of retracted hits would leave search under-filled.
scoped = filter_hits(store, hits, viewer, limit=None)
live = _filter_live_hits(store, scoped, limit=limit)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

retrieve candidates beyond the pre-lifecycle window.

hits is already capped at fetch_limit by every backend before this filtering runs. Removing the filter_hits limit cannot replace retracted or archived candidates that never entered hits; if those consume the fetched window, later live results are still omitted. paginate candidates or enforce lifecycle state before backend limiting.

As per path instructions, “use the shared underlying storage/proposals/lifecycle code path rather than duplicating filtering logic.”

🤖 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 `@src/vouch/context.py` around lines 522 - 525, Update the retrieval flow
around filter_hits and _filter_live_hits so candidate collection continues
beyond the backend’s fetch_limit before lifecycle filtering, allowing retracted
or archived hits to be replaced by later live candidates. Reuse the shared
storage/proposals/lifecycle path rather than duplicating filtering logic, and
preserve the requested limit in the final live results.

Source: Path instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs documentation, specs, examples, and repo guidance retrieval context, search, synthesis, and evaluation size: S 50-199 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant