Draft: Add the settings policy drift check and reconciliation workers
What does this MR do and why?
Adds the background half of settings enforcement, calling the evaluation service of https://gitlab.com/gitlab-org/gitlab/-/work_items/630148:
Govern::PolicyEngine::ScheduleWorkerruns daily. It collects the candidate projects of every active settings policy through the resolver of !259956 (merged), then evaluates each project once, with every policy scoped to it acting on that one snapshot. Evaluations record the engine-internalproject_settings_drift_checkedtrigger, which authors cannot pick.Govern::PolicyEngine::ProjectReconciliationWorkersubscribes to the project created and project transferred events, so a new or arriving project gets evaluated right away.- A new or changed settings policy enqueues a targeted
ScheduleWorkerrun for itself, so it takes effect without waiting for the next daily tick. The policy model gainsIMPACT_RELEVANT_COLUMNSto decide which saves count.
Both workers only observe and record for now. Writing the demanded value back is the executor of https://gitlab.com/gitlab-org/gitlab/-/work_items/630155.
The code comes from the prototype in !259574, now with specs. No changelog entry, because security_policies_v2 defaults to off.
Merge plan (nested = depends on parent, siblings = parallel)
References
- Issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/630154
- Epic: https://gitlab.com/groups/gitlab-org/-/work_items/23462
Screenshots or screen recordings
Backend-only change, no UI.
| Before | After |
|---|---|
How to set up and validate locally
-
Enable the experiment and point the engine at a running Policy Store, as in the evaluation service MR.
-
Create a settings policy with the
project_createdtrigger, then create a project in its scope.Govern::PolicyEvaluationgains aproject_createdrow for it. -
Run the daily check by hand and inspect the recorded evaluations:
Govern::PolicyEngine::ScheduleWorker.new.perform Govern::PolicyEvaluation.trigger_type_project_settings_drift_checked.last
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.