Update last_queried_at during Semantic Code Search

What does this MR do and why?

As part of &19655, we are introducing an auto-deletion process that will delete the Code Embeddings of a project if it hasn't been used/search in a while.

To achieve this, we need to:

  • IN THIS MR: Update the Ai::ActiveContext::Code::Repository#last_queried_at whenever a semantic code search is performed on its associated project
  • Issues #577332 (closed) & #577333: Perform the deletion of Code Embeddings after a certain time has passed since last_queried_at

References

Related issue: [Code Embeddings Query] Set last_queried_at (#576637 - closed)

Screenshots or screen recordings

Screen recording show semantic_code_search execution changes the Ai::ActiveContext::Code::Repository#last_queried_at timestamp.

Screen_Recording_2025-10-27_at_19.29.19

How to set up and validate locally

  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), perform a semantic_code_search on a project with Code Embeddings

  5. Verify that the last_queried_at of that project's Ai::ActiveContext::Code::Repository record has been updated, ie:

    project_id = # ID of project you set up from Step 2
    ac_repository = Ai::ActiveContext::Code::Repository.find_by(project_id: project_id)
    ac_repository.last_queried_at

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 #576637 (closed)

Edited by Pam Artiaga

Merge request reports

Loading