Implement FeatureFlag model, rake task, super admin UI, and helpers #130
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Feature
Lineage
Implementation ticket from spike #129 (feature flag strategy). The architecture doc (
docs/feature-flags.md) defines the approach; this ticket builds it.Repo
ldraney/landscaping-assistantUser Story
As a platform operator
I want to toggle features on/off in production without redeploying
So that I can safely roll out Stripe, client requests, and future integrations with instant rollback
Context
No mechanism exists to toggle features in production without redeploying. Upcoming integrations (Stripe #125) and UI features (client requests #123) need runtime gating. The architecture doc (
docs/feature-flags.md) defines a database-backedFeatureFlagmodel with cached lookups, a deploy-time rake task, and a super admin UI.Current auth state (PR #136):
current_useris a session hash with:username,:email,:roleskeys. Usecurrent_user_has_role?("super_admin")for role checks — there is no ActiveRecord User model.super_adminKeycloak realm role already exists (lucas-super-admintest user has bothadminandsuper_admin).Acceptance Criteria
Model + Migration:
feature_flagstable:name(string, unique, not null),enabled(boolean, default false, not null),description(string),timestampsFeatureFlagmodel with validations,enabled?(name),enable(name),disable(name)class methodsenabled?usesRails.cache.fetchwith 1-minute TTL;enable/disablebust cache immediatelypick(:enabled)for minimal DB overhead on hot pathHelpers:
feature_enabled?(name)helper inApplicationController, exposed to views viahelper_methodRake Task (NOT seeds):
lib/tasks/feature_flags.rakewithfeature_flags:synctaskstripe,client_requests(all disabled by default)find_or_create_by!creates missing flags without overwriting existingenabledstatedb:prepareonly seeds on first DB creation. The rake task runs on every deploy.Super Admin UI:
/platform/feature_flags— table of flags with toggle buttonsPlatform::FeatureFlagsControllerwithindexandupdateactionsrequire_super_adminbefore_action usingcurrent_user_has_role?("super_admin")— returns 404 for non-super-admin users (NOT 403 — the route doesn't exist for them)Tests:
spec/support/feature_flags.rbtest helper withwith_feature_disabled(name)andwith_feature_enabled(name)block helpersbefore(:each)hook enables all flags and clears cache (guard withtable_exists?check)enabled?,enable,disable, cache behaviorTechnical Notes
:file_storein production (SolidCache gem is in Gemfile but not configured —cache_storeis commented out, nosolid_cache.yml).Rails.cache.fetchworks with any cache store, so no additional config is needed for V1. SolidCache can be wired up later (#2).current_useris a hash, NOT an ActiveRecord model. Usecurrent_user_has_role?("super_admin")notcurrent_user&.super_admin?super_adminKeycloak realm role already exists — no Keycloak changes neededturbo_stream_from "application") requires Solid Cable (#2) — not in scope heredocs/feature-flags.mdfor full architecture rationaleOut of Scope
File Targets
Files to create:
db/migrate/YYYYMMDD_create_feature_flags.rbapp/models/feature_flag.rbapp/controllers/platform/feature_flags_controller.rbapp/views/platform/feature_flags/index.html.erblib/tasks/feature_flags.rakespec/support/feature_flags.rbspec/models/feature_flag_spec.rbspec/requests/platform/feature_flags_spec.rbspec/requests/feature_flag_gating_spec.rbFiles to modify:
app/controllers/application_controller.rb— addfeature_enabled?helperconfig/routes.rb— add platform namespaceapp/views/layouts/application.html.erb— Platform link under Person icon for super adminapp/assets/stylesheets/application.css— styles for flags table and platform viewConstraints
~/ror-css-guide(design tokens, component comments, no Tailwind, no inline styles)!important, no#idselectors in CSSEnforcement
After #130 lands, the workflow for adding a new feature flag is:
lib/tasks/feature_flags.rakein thefeature_flags:synctask (name, enabled: false, description with ticket #)feature_enabled?(:flag_name)checks in controllers/viewsWhat gets a flag: new user-visible workflow, external service integration, or role-gated UI surface.
What does NOT: bug fixes, refactors, CSS/layout, test infra, internal model changes, database indexes.
The
template-pr-bodyin pal-e-docs has been updated with this checklist item.Checklist
Related
docs/feature-flags.mdImplement FeatureFlag model, migration, and helpersto Implement FeatureFlag model, rake task, super admin UI, and helpersldraney referenced this issue2026-06-07 01:48:21 +00:00
Scope Review: NEEDS_REFINEMENT
Review note:
review-1354-2026-06-06Well-documented ticket with comprehensive architecture doc backing. All 13 file targets verified -- creates are confirmed absent, modifies are confirmed present with expected content. Dependencies properly tracked, no decomposition needed despite large scope (architecture doc provides complete implementation guide).
Issues found:
Scope review refinements (review-1354-2026-06-06):
cache_storeis commented out inconfig/environments/production.rband nosolid_cache.ymlexists. Updated to note Rails.cache defaults to:file_storeand works fine for V1. SolidCache wiring is tracked in #2.Two systemic gaps flagged (missing
story:authuser story andarch:rails-apparchitecture note) are not #130-specific — will be tracked separately.Scope Review: READY (re-review)
Review note:
review-1354-2026-06-06(rev 2)Re-review after refinements. Both fixable items from previous review are resolved:
openDeferred items (missing story:auth user story entry, missing arch-rails-app note) are systemic gaps tracked separately -- not blocking this ticket.
No new issues found. Ticket is ready to advance.