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:

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_source lets 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_source lets 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 1

Execution 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

Edited by Sahil Sharma

Merge request reports

Loading