feat: Add Knowledge Graph enable and disable commands
Summary
Introduce a ChatOps command to enable or disable the Knowledge Graph for a root namespace to seed the service during the initial stages of the launch.
Later, we will have a background worker that will be fully automatic, but we probably can't do that right away. I'd expect that we'd first enable it for some namespaces at first, and possibly some customers who really want to participate, and switch to the worker when we're ready.
Tests
Test Data
| id | name | parent_id |
|---|---|---|
| 35 | Acme Corp | |
| 95 | Acme Sub | 35 |
Test Script
GITLAB_TOKEN='xxxx' bundle exec ruby -I lib -e "
require 'chatops'
client = Chatops::Gitlab::Client.new(
token: ENV['GITLAB_TOKEN'],
host: 'localhost:3000'
)
puts '=== Enable root namespace (Acme Corp, id=35) ==='
begin
result = client.knowledge_graph_enable_namespace(35)
puts 'SUCCESS: ' + result.inspect
rescue => e
puts 'FAILED: ' + e.class.name + ': ' + e.message
end
puts
puts '=== Enable subgroup (Acme Sub, id=95) - should fail ==='
begin
result = client.knowledge_graph_enable_namespace(95)
puts 'SUCCESS: ' + result.inspect
rescue => e
puts 'FAILED: ' + e.class.name + ': ' + e.message
end
puts
puts '=== Disable root namespace (Acme Corp, id=35) ==='
begin
client.knowledge_graph_disable_namespace(35)
puts 'SUCCESS: Disabled'
rescue => e
puts 'FAILED: ' + e.class.name + ': ' + e.message
end
"
Test Output
=== Enable root namespace (Acme Corp, id=35) ===
SUCCESS: #<Gitlab::ObjectifiedHash:5560 {hash: {"id"=>4, "root_namespace_id"=>35, "created_at"=>"2025-12-11T16:29:22.280Z"}}
=== Enable subgroup (Acme Sub, id=95) - should fail ===
FAILED: Gitlab::Error::BadRequest: Server responded with code 400, message: Namespace must be a root namespace. Request URI: http://localhost:3000/api/v4/admin/knowledge_graph/namespaces/95
=== Disable root namespace (Acme Corp, id=35) ===
SUCCESS: Disabled
Issue
Resolves gitlab-org/gitlab#582318
Edited by Jean-Gabriel Doyon