Skip to content

fix(knowledge): hold the research quarantine on relation expansion and the category graph path (#16665) - #21956

Merged
mrveiss merged 10 commits into
mainfrom
issue-16665-quarantine
Nov 21, 2026
Merged

mrveiss merged 10 commits into
mainfrom
issue-16665-quarantine

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Refs #16665

Single-issue rationale: the four gaps are the remaining AC3 items of #16665 and share one helper; no other issue touches these files.

Thinking Path

AC3: the research quarantine holds on every route that has it. Four gaps remained. Two read facts straight from Redis hashes (metadata is a JSON string), so they never pass the KB.search gate and need the canonical predicate applied by hand; one is a trace; one is a missing behavioural test.

What Changed

Gap Change
1. /multi-source/search related facts _related_fact_is_accessible (api/knowledge_search_aggregator.py) now also withholds a quarantined target/source fact. It is the one gate for _expand_fact_relations and the /context citation path.
2. /multi-source/graph category path get_facts_in_category (knowledge/categories.py) drops quarantined facts at the single choke point. Its callers are the graph route and the categories route; neither needs quarantined facts, so no include_quarantined opt-out is added.
3. rag_legs kb_adapter.search Trace: services/rag_legs.py self.kb_adapter.search -> services/knowledge_base_adapter.py self.kb.search(...) (both the V1 and V2 branches) -> KnowledgeBase.search in knowledge/search.py, which ends in gate_response. It reaches the gate, so no code change. The existing matrix test used a fake that gated itself, so a new test runs the real SearchMixin.search through the adapter.
4. /query (kb_librarian) Behavioural route-level test added.

Shared helper: is_quarantined_hash / drop_quarantined_hashes in knowledge/quarantine.py wrap the existing is_quarantined for raw hashes, parsing metadata with the existing _decode_redis_hash codec. No second predicate.

Tests: api/knowledge_quarantine_gaps_16665_test.py (gaps 1 and 2, with a sensitivity control), api/knowledge_rag_matrix_16665_test.py (gap 3), api/kb_read_routes_visibility_16665_test.py (gap 4). tools/lint/check_no_kb_aioredis_access.py allowlists the new test fake, which needs the Redis-present guard.

Line counts, this branch vs origin/main: api/knowledge_search_aggregator.py 899 vs 899; knowledge/categories.py 963 vs 965.

Known limit: get_facts_in_category filters the page after pagination, so total_count and has_more still count quarantined ids and a page may be short. The graph route already tolerates short batches. Tracked in #21957 (exact count needs a quarantine-aware index).

Verification

Tests not run locally (owner rule: CI gates). ruff check clean on changed files apart from two E402 findings already on main in the aggregator; black --check --line-length=120 clean. CI result to follow.

Model Used

Claude Sonnet 5.5

Summary by CodeRabbit

  • Bug Fixes
    • Quarantined facts are excluded from category listings, graph-based results and related-fact search results.
    • Search and context responses continue to include accessible, non-quarantined facts, including shared facts.
    • Quarantine filtering is consistent across knowledge browsing and search, so quarantined information is not shown in results for standard or administrative accounts.

@mrveiss mrveiss added the phase:M2.1 Company and company boundaries label Nov 21, 2026
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 387cb68 and e318da2.

Files selected for processing: 7

  • autobot-backend/api/kb_read_routes_visibility_16665_test.py
  • autobot-backend/api/knowledge_quarantine_gaps_16665_test.py
  • autobot-backend/api/knowledge_rag_matrix_16665_test.py
  • autobot-backend/api/knowledge_search_aggregator.py
  • autobot-backend/knowledge/categories.py
  • autobot-backend/knowledge/quarantine.py
  • tools/lint/check_no_kb_aioredis_access.py

No actionable comments were generated in the recent review.

Walkthrough

The change adds quarantine checks for category facts and related facts reached through graph expansion. Tests cover category paths, multi-source search, librarian, advanced search and context routes.

Changes: Knowledge quarantine filtering

Layer / File(s) Summary
Filter category facts
autobot-backend/knowledge/quarantine.py, autobot-backend/knowledge/categories.py, autobot-backend/api/knowledge_quarantine_gaps_16665_test.py
New helpers detect quarantined Redis hashes and remove them from collections. Category retrieval applies this filter. Tests cover category listings and graph paths, including a control case without quarantine metadata.
Filter related facts
autobot-backend/api/knowledge_search_aggregator.py, autobot-backend/api/knowledge_quarantine_gaps_16665_test.py
Related facts are rejected when quarantined, in addition to being rejected when missing. Tests cover quarantined related facts and an open target reached from a quarantined source.
Verify read-route filtering
autobot-backend/api/knowledge_rag_matrix_16665_test.py, autobot-backend/api/kb_read_routes_visibility_16665_test.py, tools/lint/check_no_kb_aioredis_access.py
Tests cover the librarian, advanced search and context routes. They verify that quarantined facts are absent when the gate is active and present in a gate-bypass sensitivity case. The lint allowlist includes the new quarantine test file.
Merge Risk: Minimal · previous review 387cb

This change withholds quarantined research facts from related-fact results and from category listings and graph paths. No outstanding merge-blocking defects were found. Category counts may be slightly off until the follow-up issue lands.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: holding the research quarantine on relation expansion and the category graph path. The raw summary confirms related-fact filtering in knowledge_search_aggregator.py, q…
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.
Full details: Title check

Explanation

The title names the main change: holding the research quarantine on relation expansion and the category graph path. The raw summary confirms related-fact filtering in knowledge_search_aggregator.py, quarantine filtering in categories.py via drop_quarantined_hashes, and new helpers in quarantine.py. The title is specific and matches the changeset. The title's length (103 characters) is at the upper end of concise, but it is still readable and within the expected scope.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 248049d and 387cb68.

Files selected for processing: 7

  • autobot-backend/api/kb_read_routes_visibility_16665_test.py
  • autobot-backend/api/knowledge_quarantine_gaps_16665_test.py
  • autobot-backend/api/knowledge_rag_matrix_16665_test.py
  • autobot-backend/api/knowledge_search_aggregator.py
  • autobot-backend/knowledge/categories.py
  • autobot-backend/knowledge/quarantine.py
  • tools/lint/check_no_kb_aioredis_access.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Notice: 28 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@mrveiss mrveiss added the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 21, 2026

@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: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9e603ba and 248049d.

Files selected for processing: 7

  • autobot-backend/api/kb_read_routes_visibility_16665_test.py
  • autobot-backend/api/knowledge_quarantine_gaps_16665_test.py
  • autobot-backend/api/knowledge_rag_matrix_16665_test.py
  • autobot-backend/api/knowledge_search_aggregator.py
  • autobot-backend/knowledge/categories.py
  • autobot-backend/knowledge/quarantine.py
  • tools/lint/check_no_kb_aioredis_access.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 21, 2026
@mrveiss mrveiss added the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 21, 2026
@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 21, 2026
@mrveiss
mrveiss merged commit 710a836 into main Nov 21, 2026
64 checks passed
@mrveiss
mrveiss deleted the issue-16665-quarantine branch November 21, 2026 16:11
@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M2.1 Company and company boundaries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant