Add ai_governance_session_id to ClickHouse ai_audit_events

What does this MR do and why?

On GitLab.com, AI audit events are read from ClickHouse. The ClickHouse ai_audit_events table has no session column, so events cannot be looked up by session.

This MR:

  • Adds an ai_governance_session_id column (0 means no session) and a by_ai_governance_session_id projection to the ClickHouse table. The projection is materialized so older data can be read by session too.
  • Sends the session id in the row written to ClickHouse.

References

Screenshots or screen recordings

Not applicable. No UI changes.

How to set up and validate locally

  1. Run bundle exec rake gitlab:clickhouse:migrate.
  2. Check the new column and projection exist:
    SELECT name FROM system.projections WHERE table = 'ai_audit_events';
  3. Run bundle exec rake gitlab:clickhouse:rollback:main STEP=1 and check both are removed.

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.

Merge request reports

Loading
Loading