ActiveContext: Allow disabling ref fields
What does this MR do and why?
#536212 (closed) is split over a few MRs:
-
Allow disabling ref fields
⬅️ this MR - !190313 (merged): Reference, collection, queue, migration classes for Code collection
- !190224 (merged): Standardised error handling for preprocessors
References
- Draft: Code embedding files using ActiveContext (!189310 - closed)
- [Embedding indexing pipeline] Reference class (#536212 - closed)
How to set up and validate locally
- Check out
536212-3-code-embeddings-fileswhich depends on this branch but contains Code files - Update the initializer
config/initializers/active_context.rbby changingfalsetotrue - Create a connection
- Run the migration worker:
Ai::ActiveContext::MigrationWorker.new.perform - Verify that the partitions were created with the right schema (particularly without
ref_idandref_version)
# on ES
GET gitlab_active_context_code
# on psql
\d gitlab_active_context_code
- Verify that the collection record exists and has the right values, particularly
include_ref_fieldsis false
ActiveContext.adapter.connection.collections
=> [#<Ai::ActiveContext::Collection:0x0000000168a50c80
id: 48,
name: "gitlab_active_context_code",
metadata: {"collection_class"=>"Ai::Context::Collections::Code", "include_ref_fields"=>false, "indexing_embedding_versions"=>[1]},
number_of_partitions: 1,
created_at: Tue, 06 May 2025 12:49:23.504247000 UTC +00:00,
updated_at: Tue, 06 May 2025 12:50:37.082487000 UTC +00:00,
connection_id: 10,
include_ref_fields: false,
indexing_embedding_versions: [1],
search_embedding_version: nil,
collection_class: "Ai::Context::Collections::Code">]
[Optional]
- Delete the partitions
- Set the migrations as not completed:
ActiveContext.adapter.connection.migrations.update_all(status: 'pending') - Change the migration to create the collection by removing the
options(thereby makinginclude_ref_fieldstrue) - Repeat steps 4-6 and this time see that
ref_idandref_versionare present.
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 #536212 (closed)
Edited by Madelein van Niekerk