Refactor the ActiveContext::Query::Result class

What does this MR do and why?

This refactors the Ai::ActiveContext::Queries::Result class based on the suggestions from non-blocking reviews in SemanticCodeSearch: Handle scenario where proje... (!208905 - merged)

  • added helper class methods .success, .error, and .no_embeddings_error
  • added an #error_message method, levering a "template" to build the relevant error message from given target
  • removed the inheritance from SimpleDelegator, and manually delegate certain array methods to hits instead

References

Related issue: Refactor the ActiveContext Query Result class (#577760 - closed)

Screenshots or screen recordings

Project with embeddings

Screenshot_2025-10-27_at_16.22.17

Project without embeddings - ID as project_id

Screenshot_2025-10-27_at_16.23.12 |

Project without embeddings - project path as project_id

Screenshot_2025-10-27_at_16.30.08

How to set up and validate locally

This is a refactor so there is no need for a very involved local validation. But to test this, you can:

  1. Setup MCP server on your GDK

  2. Setup the Code Embeddings Indexing pipeline on your GDK

  3. Enable the code_snippet_search_graphqlapi Feature Flag

  4. With your preferred MCP client (you can use MCP Inspector):

    • test the semantic_code_search tool against a project with code embeddings
    • test the semantic_code_search tool against a project without code embeddings

    Note: see screenshots above for the expected results of either test

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #577760 (closed)

Edited by Pam Artiaga

Merge request reports

Loading