Draft: feat: Add Knowledge Graph enable and disable commands

Summary

Introduce a ChatOps command to enable or disable the Knowledge Graph for a root namespace. This is an administrative command that will be used for internal tests of the product.

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

Merge request reports

Loading