Fix infra topology query-sensitive ranking#999
Conversation
Wire InfraTopologyReader into the existing fact_query scoring path without changing traversal discovery, allow graph read --query on the infra view, and extract shared claim_semantic_similarity for all readers. Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a shared ChangesSemantic similarity propagation
Sequence Diagram(s)sequenceDiagram
participant Reader as InfraTopologyReader
participant Traversal as BFS traversal
participant Store as Claim store
Reader->>Traversal: traverse anchors (query-free)
Traversal->>Store: find_claims (structural filters)
Store-->>Traversal: discovered rows
Reader->>Reader: _stamp_query_similarity(rows, req.query)
Reader->>Store: find_claims(claim_key_in, fact_query=req.query)
Store-->>Reader: similarity-stamped rows
Reader->>Reader: build Candidate.semantic_similarity via claim_semantic_similarity
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@potpie/context-engine/application/readers/infra_topology.py`:
- Around line 233-260: The stamping logic in _stamp_query_similarity currently
assumes limit=len(claim_keys) will return all requested rows, but
ClaimQuery.find_claims applies claim_key_in after vector ranking so some keys
can be dropped. Update _stamp_query_similarity to handle misses by doing a keyed
follow-up for any unstamped claim keys, or switch to a query shape that
prefilters by claim_key before similarity ranking. Make sure the fix preserves
the existing row set while still attaching semantic_similarity to every
discovered row.
🪄 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: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 30262d1b-d85a-4160-94b5-8b52f30a0c6c
📒 Files selected for processing (12)
potpie/context-engine/application/readers/_common.pypotpie/context-engine/application/readers/coding_preferences.pypotpie/context-engine/application/readers/decisions.pypotpie/context-engine/application/readers/docs.pypotpie/context-engine/application/readers/features.pypotpie/context-engine/application/readers/infra_topology.pypotpie/context-engine/application/readers/owners.pypotpie/context-engine/application/readers/prior_bugs.pypotpie/context-engine/application/readers/timeline_reader.pypotpie/context-engine/domain/graph_workbench_ontology.pypotpie/context-engine/tests/conformance/test_graph_surface_lite_e2e.pypotpie/context-engine/tests/unit/test_p9_readers.py
Summary
InfraTopologyReaderinto the existing semantic similarity scoring path so infra claims are ranked by query relevance instead of a flat default score.graph read --queryoninfra_topology.service_neighborhoodand extract sharedclaim_semantic_similarityacross readers.Test plan
pytest tests/unit/test_p9_readers.pypytest tests/conformance/test_graph_surface_lite_e2e.pyMade with Cursor