Add dynamic defaults for model_registry/experiments access levels based on project visibility
Goal
Add after_initialize callbacks on ProjectFeature so newly created projects get the right default for model_registry_access_level and model_experiments_access_level:
- Public projects →
ENABLED - Internal or private projects →
PRIVATE
Mirrors the existing set_pages_access_level pattern in app/models/project_feature.rb.
Why
Today, ProjectPolicy has a carve-out:
rule { ~public_project & guest & model_registry_enabled }.enable :read_model_registrythat forces member-only access for model registry / experiments on non-public projects, bypassing the Featurable access-level system. This task is step 1 of 3 to remove that carve-out without changing observable behavior — by making the access-level default at creation time match today's policy, new projects continue to behave the same way after the carve-out is removed.
Implementation sketch
after_initialize :set_model_registry_access_level, if: :new_record?
after_initialize :set_model_experiments_access_level, if: :new_record?
private
def set_model_registry_access_level
self.model_registry_access_level ||= self.project&.public? ? ENABLED : PRIVATE
end
def set_model_experiments_access_level
self.model_experiments_access_level ||= self.project&.public? ? ENABLED : PRIVATE
end(Could DRY into one method taking the column name; either reads fine.)
References
- Parent: #599574
- Discussion: !235259 (closed)