Skip to content

Enrich symbol embeddings with parent class/module context #2

@kapillamba4

Description

@kapillamba4

Problem

Symbol embeddings currently use only the symbol's own name and source text. For nested symbols like methods within classes, this loses valuable hierarchical context.

Example: A process() method inside PaymentHandler class is embedded without any reference to its parent class. When a user searches for "payment processing" or "PaymentHandler", this method may not rank well because the parent class context isn't captured in the embedding.

Proposed Solution

Include parent symbol context in embeddings for nested symbols so that:

  • Methods are associated with their containing class
  • Nested classes include outer class context
  • Searches for class names can find methods within them

Benefits

  • Better semantic matching for class methods
  • Aligns with how developers think about code (qualified names)
  • Improves "find methods of X class" queries

Considerations

  • Slightly longer embedding inputs
  • Marginal indexing latency increase
  • Would require re-indexing existing codebases

Acceptance Criteria

  • Nested symbols include parent context in their embeddings
  • Top-level symbols remain unchanged
  • Existing tests pass
  • Improved recall for method/class association searches

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions