Skip to content

find_related is not restricted to the seed chunk's language (upstream parity) #113

Closed

Description

@amondnet

Summary

Upstream SembleIndex.find_related only returns chunks in the same language as the seed:

selector = self._get_selector_vector(filter_languages=[target.language]) if target.language else None
results = _search_semantic(target.content, ..., top_k + 1, selector)

csp's CspIndex::find_related (crates/csp/src/indexing/index.rs:259-272) queries the semantic index with selector = None. Related-code results can therefore mix languages, for example a Markdown or YAML chunk returned for a Rust seed. .please/docs/references/semble.md §4.9 describes csp's find_related as "same-language", so the reference doc is also wrong about the code.

This predates the 6bbbd32..0e5e028 review window. It was found incidentally while comparing the indexing code.

Proposal

  • When seed.language is Some, build a selector from the language→indices map that build_selector already uses and pass it to semantic_index.query. Fall back to None when the seed has no language.
  • Keep the top_k + 1 / exclude-seed behavior.

Acceptance

  • A test with a mixed-language index shows that a seed in language A returns only language-A chunks.
  • A seed with no language still searches the whole index.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:proposalProposal for discussiontype:bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions