Add the setting writer behind the set_setting action
What does this MR do and why?
Adds the write layer for the set_setting policy action, part of https://gitlab.com/gitlab-org/gitlab/-/work_items/630155. Govern::PolicyEngine::ProjectSettingWriter writes one catalog setting through Projects::UpdateService, so the write runs the same validations, permission checks, and audit events as a regular settings change. Govern::PolicyEngine::ProjectSettingParams translates a catalog setting name and value into the service params. A value the translation does not know writes nothing, and only a real boolean reaches a boolean or approval column.
The writer marks its own write with a reserved skip_govern_settings_gate param. Projects::UpdateService consumes the param during validation and skips the SettingsChangeGate, because the policy engine already decided the write. The param never reaches attribute assignment, and no REST, GraphQL, or controller path can inject it.
Projects::UpdateService leaves authorization and the archived check to its callers. The engine dispatches every write as the organization's admin bot, so the writer asserts that actor identity and refuses archived projects before every write; the security-settings path authorizes through the granular update_security_setting permission instead.
secret_push_protection_enabled has no Projects::UpdateService param, so the writer updates the project's security settings row directly, with the same checks and audit event as the REST endpoint (ee/lib/api/project_security_settings.rb).
No production code calls these classes yet. The executor that dispatches the writer sits in !261837 (merged), which builds on this branch.
No changelog entry, because security_policies_v2 defaults to off.
Merge plan (nested = depends on parent, siblings = parallel)
- Setting writer (this MR)
- !261837 (merged)
set_settingwrite-back executor- !264545 cross-trigger E2E spec (also needs the drift workers)
- !261837 (merged)
- !261561 (closed) drift workers
- !262405 (merged) effective archived state
Database review
This MR adds no new queries.
References
- Issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/630155
- Epic: https://gitlab.com/groups/gitlab-org/-/work_items/23462
Screenshots or screen recordings
Backend-only change, no UI.
How to set up and validate locally
-
In the Rails console, write one governed setting through the writer:
project = Project.find_by_full_path('group/project') actor = Users::Internal.in_organization(project.organization_id).admin_bot writer = Govern::PolicyEngine::ProjectSettingWriter.new(project: project, actor: actor) writer.write('request_access_enabled', false) -
The call returns
{ status: :success }andproject.reload.request_access_enabledisfalse.
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.