--- title: "ADR 0089: Follow-up state is patched under a fence and its source Repository is authorized" --- * Status: accepted * Code: [`pkg/reconciler/followup.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/reconciler/followup.go) ## Context The follow-ups of a group are stored as state on the PipelineRuns, which several reconciles update, and the event and Repository they were templated from are stored in annotations a user can edit. ## Decision * `consumeFollowUp` reads the run fresh and patches it with `patchFenced`, a merge patch carrying the run's UID and resourceVersion. A conflict or a not found is not an error: another reconcile already moved the run, or the run is gone and stores nothing anymore. * `patchFenced` bypasses `action.PatchPipelineRun` on purpose, because that helper retries on conflict and here a conflict means the work is done. * The stored event is applied over the one rebuilt from annotations, so the definition, its CEL condition and the created run see what the event time saw. * The definition is templated from the Repository recorded on the stored event, because the execution repository of a target namespace may have other custom params and settings. The run is still created in the execution repository. Follow-ups stored by an older version record none and use the execution repository. * `authorizeFollowUpSourceRepo` accepts a source Repository only if it is the execution one or has the same URL, since the reference sits in an editable annotation and its custom param secrets are read. * `verifiedEventSource` rebuilds the git repository annotations from the Repository for the same reason, and for GitHub Apps re-reads the installation ID. * The provider client is initialized from the local repository, which decides whether the git provider secret is inherited from the global one. ## Consequences * A lost fence silently drops that consume; the follow-up is retried on a later reconcile only if it is still pending. * A source Repository for another git repository skips the follow-up.