Wire `author_source` into `completed_pipeline_execution` and `first_pipeline_succeeded` events
What does this MR do and why?
Part of #596636 (closed) — identifying agent-generated pipeline configs to filter Config Quality and Time-to-first-pipeline metrics to AI-guided flows.
Previous MRs in this chain established the foundation:
- Add `author_source` property to CI config inter... (!232453 - merged) added
author_sourceto thecommit_change_to_ciconfigfileandcreate_ci_config_fileinternal events by reading theDuo-Workflow-Definitiongit trailer at commit time. - Add ci_config_author_source column to ci_projec... (!232740 - merged) added the
ci_config_generated_bycolumn toci_project_metricsand atrack_ai_generated_config!upsert, which persists the trailer value when an AI agent commits a CI config.
This MR closes the loop by surfacing author_source on the two downstream events that analytics actually uses:
completed_pipeline_execution— fires on every pipeline completion;author_sourcelets us segment Config Quality metrics by whether the pipeline was set up by a human or an AI agent.first_pipeline_succeeded— fires on Time-to-first-pipeline;author_sourcelets us compare TTFP for AI-guided onboarding vs. manual onboarding.
Because these events fire from the pipeline execution context, not from a git push, we cannot read the git trailer there directly. Instead we look up the persisted value from ci_project_metrics at event-fire time. When no AI agent trailer was recorded for the project, the value defaults to 'human'.
Database
Query: Ci::ProjectMetric.ci_config_generated_by_for(project_id)
SELECT ci_config_generated_by FROM ci_project_metrics WHERE project_id = $1 LIMIT 1Execution plan
The ci_project_metrics table is new and has minimal data in production. The execution plan was generated locally:
EXPLAIN (ANALYZE, BUFFERS) SELECT ci_config_generated_by FROM ci_project_metrics WHERE project_id = 1 LIMIT 1
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.15..2.17 rows=1 width=32) (actual time=0.005..0.005 rows=0 loops=1)
Buffers: shared hit=5
-> Index Scan using index_ci_project_metrics_on_project_id on ci_project_metrics (cost=0.15..2.17 rows=1 width=32) (actual time=0.005..0.005 rows=0 loops=1)
Index Cond: (project_id = 1)
Buffers: shared hit=5
Planning:
Buffers: shared hit=86
Planning Time: 0.760 ms
Execution Time: 0.014 ms
(9 rows)References
- Issue: Identify agent-generated pipeline configs using... (#596636 - closed)
- Persistence foundation: Add ci_config_author_source column to ci_projec... (!232740 - merged)
- CI config commit events: Add `author_source` property to CI config inter... (!232453 - merged)