Repository navigation
feat(feature-flags): admin pages, writes and audit (3/7) - #536
Merged
Merged
Conversation
added 3 commits
October 21, 2026 17:40
…s panel (3/7) Super admins change flags from /admin/feature_flags only. Every write goes through FeatureFlags::Admin, which records one Audit in the write's transaction and bumps the version token after commit, so other processes reload only a change that exists. Signed-off-by: aixle-developer-agent <[email protected]>
Signed-off-by: aixle-developer-agent <[email protected]>
Signed-off-by: aixle-developer-agent <[email protected]>
artempartos
added a commit
that referenced
this pull request
Oct 22, 2026
…rs-without-channels-audit * origin/develop: feat(feature-flags): admin pages, writes and audit (3/7) (#536) # Conflicts: # CHANGELOG.md
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Feature flags 3/7 (board task #168, design
docs/research/technical-feature-flags-system-design-research-2026-10-21.md§3.1, §3.3, §6.1, §7.1, §7.2). Super admins can now change flags from/admin; company admins still never see them.FeatureFlags::Admin(app/services/feature_flags/admin.rb):set_global,clear_global,set_override,remove_override,turn_off_everywhere, plusprunefor orphaned rows (feature_flag.pruned, §7.2). Each one takesactor:and a requiredreason:. It writes the rows and exactly oneAuditin one transaction:auditableis the flag row,associatedis the company for overrides,useristrue_user, andcommentis the reason;audited_changesis{ "enabled" => [old, new] }, and turn-off-everywhere also stores the removed overrides.FeatureFlags.version_token.bump, throughActiveRecord.after_all_transactions_commit. So a caller's surrounding transaction delays the bump until it commits, and a rollback drops it.FeatureFlagsnamespace,WriteRefusedandEnvLocked < WriteRefused. Nothing is written when there is no reason, the flag is ENV-locked, the key is undeclared, a global flag is given an override, or the override to remove does not exist.Admin::FeatureFlagsControllerandAdmin::FeatureFlagOverridesControllerare custom pages, not Administrate dashboards.GET /admin/feature_flagshas one row per declared flag with key, description, owner, kind, scope, default, ENV ("locked byFEATURE_X"), global value, override counts (on/off), the value for companies without an override, and badges (past remove-by, same everywhere 30+ days). Orphaned rows are listed with a delete action that needs a reason.GET /admin/feature_flags/:keyhas the source matrix with the winner highlighted, the global control (on / off / use default) with a reason, Turn off everywhere, the overrides table (ENV-shadowed overrides marked), a company search showingexplainfor each match, Add override, and the audit history newest first. ENV-locked flags render every control inside<fieldset disabled>and name the variable./admin/companies/:id.FeatureFlags::Overviewis the read model behind both pages.Decision to review: the pages resolve against the committed rows
The admin pages use the same
FeatureFlags::ResolverthatFeature.explainuses, but overFeatureFlag.load_snapshotinstead of the process's cachedFeatureFlags.storesnapshot. The cached snapshot can lag a write by the store's refresh interval (5 s), or by max staleness (60 s) while Redis is down. Showing it would let an admin save a change and then see the old value on the page the save redirects to.FeatureFlags::Storeis unchanged. The pages do not touch the pinnedCurrent.feature_snapshot(decision #45822), and they add no re-read anywhere a request or job checks a flag.Smaller choices
updated_atandupdated_by, override writes included. "Same everywhere 30+ days" counts from that timestamp. For a flag with no row it counts fromintroduced:, and with neither it shows no badge.created_by(who set the current value).FakeFeatureFlagVersionTokengained abumpscount and anon_bumphook, used to show that the bump happens after commit.Type of change
How was this tested?
test/services/feature_flags/admin_test.rbuses real rows and the version-token fake. It covers each write and its audit shape, the bump happening after commit (open transaction count at bump time), the bump being deferred inside a caller's transaction and dropped on rollback, the reason being required for every write, the ENV lock refusing every write, a failure inside the transaction leaving no rows, no audit and no bump, and pruning.test/services/feature_flags/overview_test.rbcovers an empty registry, flags with no rows, ENV locks and counts from the rows, both badges, and orphans.test/integration/admin/feature_flags_test.rbcovers company admins and employees getting the/adminrejection on every route with nothing written, an empty registry, flags without rows, ENV-locked controls being disabled and the write endpoints refusing, turn off everywhere, search, check, add and remove override, a global flag refusing an override, orphan listing and deletion, and the company panel.aixle-prod-69c1fb03) in thedocker-compose.ci.ymlweb image, afterbin/vite build:bin/rails testonf61f3a31: 8708 runs, 0 failures, 0 errors, 3 skips (the Redis-only version-token cases);brakemanonf61f3a31: 0 warnings;dd4baa86(which only fixes lambda spacing in a test):rubocopon the 11 changed Ruby files reports no offenses, andtest/services/feature_flags+test/integration/admin/feature_flags_test.rbgive 113 runs, 0 failures.How to test manually: declare a flag in
config/feature_flags.yml(copy one fromtest/fixtures/files/feature_flags_registry.yml), sign in as a super admin and open/admin/feature_flags. Open the flag, set the global value with a reason, search a company, add an override, then use Turn off everywhere. The History table records each step. Restart withFEATURE_<KEY>=off: the page shows the lock and every control is disabled.Related issues
Board task #168 (Feature flags 3/7). Parent research #164. It builds on #166 / #530 (tasks 1 and 2), and task 6 (pilot ops flag) waits for this one.
Checklist
git commit -s).[Unreleased]in CHANGELOG.md.make check_all: not run as one command. The backend parts (full rails suite, rubocop on the changed files, brakeman) ran separately on Coder, see above. No frontend changes.