Add `author_source` property to CI config internal events
What does this MR do and why?
Adds an author_source additional property to two existing internal events:
commit_change_to_ciconfigfile(fires when CI config is modified on the default branch)create_ci_config_file(fires when CI config is created on any branch)
How author_source is determined
The value comes directly from the Duo-Workflow-Definition git trailer on the commit:
- If the trailer is present, its value is used as-is (e.g.,
ci_expert_agent/v1) - If the trailer is absent or empty, the value is
human
Currently, only the CI Expert Agent sets this trailer (Duo-Workflow-Definition: ci_expert_agent/v1). As more agents adopt the same trailer convention, their values will automatically flow through without any code changes. This also enables version-level granularity in analytics (e.g., distinguishing ci_expert_agent/v1 from ci_expert_agent/v2).
Why this matters
This enables analytics to answer:
| Question | Query |
|---|---|
| How many CI config modifications are from agents vs humans? | commit_change_to_ciconfigfile GROUP BY author_source |
| How many CI configs were created by which agent? | create_ci_config_file WHERE author_source != 'human' GROUP BY author_source |
| Configs created by agent then modified by human? | Join create_ci_config_file with commit_change_to_ciconfigfile(author_source=human) on project |
Technical note: trailer fetching
Commits loaded via commits_between use Gitaly's ListCommitsRequest, which does not populate trailers. To access trailers, ci_config_author_source re-fetches the commit via repository.commit(sha) (uses FindCommitRequest, which supports trailers). This only runs for the commits that touch the CI config file, so the extra Gitaly call is negligible.
Part of a series:
- This MR: Add
author_sourceproperty to CI config events (Snowplow counting) - Add
ci_config_ai_generatedboolean toci_project_metricstable (DB persistence) - Enrich
completed_pipeline_executionevent withai_generatedproperty
Known limitation
If a user changes the project's CI config path setting, the tracking applies to whatever path is current at push time. Historical tracking does not follow path changes. This is acceptable for v1.
Relates to #596636 Part of #594029
How to set up and validate locally
-
Start the internal events monitor for both events:
rails runner scripts/internal_events/monitor.rb commit_change_to_ciconfigfileIn a separate terminal:
rails runner scripts/internal_events/monitor.rb create_ci_config_file -
Test human commit (config change):
- Clone a project that already has a
.gitlab-ci.ymlfile - Make a change to
.gitlab-ci.ymland push to the default branch - Verify
commit_change_to_ciconfigfileappears in the monitor withauthor_source: human
- Clone a project that already has a
-
Test AI agent commit (config change):
- Make a change to
.gitlab-ci.ymlwith a commit message containing the trailer:Update CI config Duo-Workflow-Definition: ci_expert_agent/v1 - Push to the default branch
- Verify
commit_change_to_ciconfigfileappears in the monitor withauthor_source: ci_expert_agent/v1
- Make a change to
-
Test human commit (config creation):
- Clone a project without a
.gitlab-ci.ymlfile - Create a
.gitlab-ci.ymlfile and push to any branch - Verify
create_ci_config_fileappears in the monitor withauthor_source: human
- Clone a project without a
-
Test AI agent commit (config creation):
- Create a
.gitlab-ci.ymlfile with a commit message containing theDuo-Workflow-Definition: ci_expert_agent/v1trailer - Push to any branch
- Verify
create_ci_config_fileappears in the monitor withauthor_source: ci_expert_agent/v1
- Create a
-
Verify
author_sourcereflects the trailer value:- Push a commit with
Duo-Workflow-Definition: some_other_agent/v1modifying.gitlab-ci.yml - Verify the event fires with
author_source: some_other_agent/v1(nothuman)
- Push a commit with
-
Verify
humanis used when:- The commit has no
Duo-Workflow-Definitiontrailer - The commit has a
Duo-Workflow-Definitiontrailer with an empty value
- The commit has no
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.