Skip to content

fix(retrieval): skip map-unit count equality on asset filters - #413

Merged
suguanYang merged 3 commits into
mainfrom
fix/suguan/filtered-map-unit-completeness
Sep 13, 2026
Merged

fix(retrieval): skip map-unit count equality on asset filters#413
suguanYang merged 3 commits into
mainfrom
fix/suguan/filtered-map-unit-completeness

Conversation

@suguanYang

Copy link
Copy Markdown
Contributor

Summary

  • Classic image/table retrieval compared full-revision indexes.unit_count to the filtered has_image / has_table unit subset, so a complete index looked unusable and returned 500.
  • Keep unit-count equality only when loaded rows are the full revision inventory; asset filters, signal paths, and exclude_sections use the same undercount check as unfiltered token projection.
  • Include the failing completeness reason in the RuntimeError, and add mixed-section plus image-filter unusable-index contract coverage.

Test plan

  • Mixed-section classic chunk_types=image|table contract test failed on the old equality check, then passed after the predicate change
  • uv run pytest apps/api/tests/contract/test_retrieval_classic_map_unit_contract.py -q (15 passed, including unusable-index cases)
  • Prod dump knowhere-prod-restore-pg: image/table unit counts unequal to full indexes.unit_count; after the fix map_unit_discovery returned discovery_done for the production image, table, and unfiltered queries

Made with Cursor

Classic image/table queries compared full-revision index.unit_count to the
filtered unit subset, so a complete index looked unusable and returned 500.

Co-authored-by: Cursor <cursoragent@cursor.com>
suguanYang and others added 2 commits September 13, 2026 21:06
…lized local variable'

Initialize the revision-inventory flag before the async storage-mismatch
branch so CodeQL sees it on every path.

Co-authored-by: Cursor <cursoragent@cursor.com>
…lized local variable'

Inline the subset-inventory condition so the extra local is gone. CodeQL
kept flagging the use of that name even after it was assigned earlier.

Co-authored-by: Cursor <cursoragent@cursor.com>
@suguanYang
suguanYang merged commit 3271682 into main Sep 13, 2026
6 checks passed
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.

2 participants