Report the effective archived state in the settings context
What does this MR do and why?
Govern::PolicyEngine::SettingsContext reported the stored archived
column in the evaluation context. That value is not the state GitLab
presents: it ignores an archived ancestor group, and it still counts a
project that only awaits deletion. A scope rule such as archived == false
then kept matching a project the user already sees as archived through its
group, so the policy kept firing on something the user cannot change.
This reports project.self_or_ancestors_archived? instead, which counts an
archived ancestor and excludes a project awaiting deletion, and preloads the
namespace inherited-settings association so batch evaluation keeps the
loaded-association fast path. The class comment now separates the derived
scope keys (archived, groups) from the project's own stored settings.
The context schema in
!261559 (merged) needs no
change: it describes the key as "Whether the project is archived", and the
effective state matches that description. The whole feature stays behind the
policy_store_experiment_enabled setting, the security_policies_v2 flag,
and the security_orchestration_policies license, so no changelog entry.
Merge plan (nested = depends on parent, siblings = parallel)
References
- Follow-up to !261559 (merged), raised in !261559 (comment 4012898821)
- Resolves https://gitlab.com/gitlab-org/gitlab/-/work_items/633807
Screenshots or screen recordings
Backend-only change, no UI.
| Before | After |
|---|---|
How to set up and validate locally
-
Build the context for a project whose ancestor group is archived:
project = Project.find(id) # inside an archived group Govern::PolicyEngine::SettingsContext .build(project: project, trigger: 'project_settings_change_requested') .dig('project', 'archived') # => true (was false before this change) -
Run the specs:
bin/rspec ee/spec/lib/govern/policy_engine/settings_context_spec.rb
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.