Skip to content

fix(context): drop archived pages from context packs - #595

Merged
plind-junior merged 2 commits into
vouchdev:testfrom
atoz96:fix/context-pack-excludes-archived-pages
Jul 30, 2026
Merged

fix(context): drop archived pages from context packs#595
plind-junior merged 2 commits into
vouchdev:testfrom
atoz96:fix/context-pack-excludes-archived-pages

Conversation

@atoz96

@atoz96 atoz96 commented Jul 29, 2026

Copy link
Copy Markdown

#581 taught kb.search to drop archived pages. build_context_pack was never given the same filter — it excludes retracted claims and passes pages straight through.

so archiving a page hides it from kb.search while it keeps being injected into every context pack, which is the surface that actually seeds agent context. _append_graph_neighbors carried the identical gap on the expansion path.

reproducing

store.put_page(Page(id="p-live", title="mongodb ops", ..., type=PageType.CONCEPT))
store.put_page(Page(id="p-arch", title="mongodb old", ..., status=PageStatus.ARCHIVED))
health.rebuild_index(store)

pack = context.build_context_pack(store, query="mongodb", limit=10)
{item["id"] for item in pack["items"]}
# -> {'p-arch', 'p-live'}      archived page served

test_search_kb_excludes_retracted_claims already asserts p-arch is absent from kb.search for the same fixture, so the two recall surfaces disagree today.

the change

the page half of the predicate moves into _page_is_live; all three call sites (_filter_live_hits, the context-pack item loop, _append_graph_neighbors) use it.

the claim half stays inlined at each site because those callers need the fetched claim anyway for citations and origin tags — re-fetching it through a boolean predicate would double the reads on the hot path. pages are only ever tested, so one shared helper is enough to stop the two recall surfaces drifting again, which is exactly how this survived #581.

tests

  • test_context_pack_excludes_archived_pages — the regression above; fails on the previous code with assert 'p-arch' not in {'p-arch', 'p-live'}
  • test_page_is_live_rejects_archived_and_missing — pins the predicate's contract over archived and missing pages, which is what the graph path now routes through

verification

pytest tests/ -q --ignore=tests/embeddings   green
mypy src                                     Success: no issues found in 115 source files
ruff check src tests                         All checks passed!

note that tests/test_context.py skips entirely on the base [dev,web] install (its autouse fixture importorskips numpy), so these run in the embeddings job rather than the main matrix. i verified them with numpy present.

unrelated, but worth flagging while i was in there: with numpy installed but not the full [embeddings] extra, five tests fail on a clean test checkout — test_cli.py::test_fsck_clean_kb_prints_clean_and_exits_zero, test_cli.py::test_search_fts5_backend_label, test_delete.py::test_deindex_removes_fts_and_prov, and both test_hot_memory.py::test_covered_methods_attach_sidebar_when_kb_has_recent_claims params. nothing to do with this pr — ci never hits it because the base job has no numpy — but a contributor who installs numpy for one thing lands in a confusing half-configured state. happy to file it separately.

vouchdev#581 taught kb.search to drop archived pages, but build_context_pack was
never given the same filter — it excludes retracted claims and passes
pages straight through. archiving a page therefore hid it from search
while it kept being injected into every context pack, which is the
surface that actually seeds agent context. _append_graph_neighbors had
the identical gap on the expansion path.

the page half of the predicate moves into _page_is_live and all three
call sites use it. the claim half stays inlined because those callers
need the fetched claim anyway for citations and origin tags — pages are
only ever tested, so one shared helper is enough to stop the two recall
surfaces drifting again, which is exactly how this survived vouchdev#581.

covered by a regression asserting an archived page is absent from a
context pack while a live one survives, plus a direct contract test for
the predicate over archived and missing pages.
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 59 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0d5cb806-034a-47ea-9495-51f6be7450ee

📥 Commits

Reviewing files that changed from the base of the PR and between 647c34d and 776c2ae.

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

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 retrieval context, search, synthesis, and evaluation tests tests and fixtures size: S 50-199 changed non-doc lines labels Jul 29, 2026
@plind-junior
plind-junior merged commit 992b291 into vouchdev:test Jul 30, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants