--- title: "ADR 0099: Follow-ups are stored on a dependency run and runs are created in phases" --- * Status: accepted * Code: [`pkg/pipelineascode/followups.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/pipelineascode/followups.go) ## Context A follow-up (`on-pipelinerun`) is not started at event time; the watcher creates it once its dependencies are done (see [ADR 0058]({{< relref "0058-followup-dependency-graph.md" >}})). Something has to carry the intent from the event to the watcher, and the watcher can only find a follow-up through the run that carries it. ## Decision * `planFollowUps` removes follow-up matches from the list of runs to start. Each becomes a `prgroup.FollowUp` (deterministic name from the definition and a group ID, its dependencies, state pending). The group ID is minted once per event, only when at least one definition has dependencies. * The follow-up is stored on its lexicographically smallest dependency (`onRunDefinitionFor`). `stampFollowUps` adds it to that run before the run is created, so it reaches the cluster in the creation request with no extra patch. * `creationPhases` creates the runs without follow-ups first, all at once, then the runs carrying follow-ups one at a time by descending definition name. * If the carrying run did not match, `stampFollowUps` skips it and `reportFollowUps` reports the follow-up as skipped. ## Consequences * Because the carrier is the smallest dependency and carriers are created in descending order, every other dependency of a follow-up is created, or failed to start, before the carrier exists. The watcher can then treat a missing dependency run as absent for good, not as still being created. The code states this reasoning; nothing enforces it other than the ordering. * Carriers are created sequentially, so an event with many follow-up chains creates those runs more slowly than plain runs. * The watcher side of the contract lives outside this package; this record covers only what the event side stamps.