Skip to content

refactor(feature-flags): plain cached reads, no usage tooling - #579

Merged
aixle-com[bot] merged 5 commits into
developfrom
feature/feature-flags-simplify
Oct 27, 2026
Merged

aixle-com[bot] merged 5 commits into
developfrom
feature/feature-flags-simplify

Conversation

@aixle-com

@aixle-com aixle-com Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Task #180: cut the feature flag system down to what it needs.

What changed

Read path (§1). FeatureFlags::Store, VersionToken, MemoryStore, Snapshot, the dedicated Redis client and the FEATURE_FLAGS_REFRESH_INTERVAL / FEATURE_FLAGS_MAX_STALENESS settings are gone. FeatureFlags.snapshot is now Rails.cache.fetch("feature_flags/snapshot", expires_in: 10.seconds) { FeatureFlag.load_snapshot }, memoised in Current per request or job, with no memo outside an executor run (Temporal activities). FeatureFlags::Admin calls FeatureFlags.changed! (a cache delete) after its transaction commits. FeatureFlag.load_snapshot returns a plain frozen hash.

Second ENV variable (§2). The registry has one optional env: field (coder_reap: env: CODER_REAP_ENABLED) in place of env_setting + env_setting_variable. It is validated as an upper-case variable name that is not FEATURE_* and that no other flag claims. config/settings.yml collects the FEATURE_* variables plus the declared env: variables, reading their names from config/feature_flags.yml. EnvSource parses both the same way, and FEATURE_<KEY> wins when both are set. coder.reap_enabled and the settings-tree reading are removed. Intended behaviour change: a CODER_REAP_ENABLED value other than on/off/true/false/1/0 now fails boot (CHANGELOG entry added).

Usage and removal tooling (§3). Removed FeatureFlags::Lifecycle, lib/tasks/feature_flags.rake, Admin.prune, the orphaned-rows section with its DELETE /admin/feature_flags/:key route, the "same everywhere 30+ days" badge, the source-scanning half of the registry test, and Resolution#shadowed along with its "Shadowed" column. Overview keeps what the index shows plus the past-remove_by badge, shown on release flags only.

Test seam (§4). FeatureFlags.with(env:) is the only seam left, used by stub_feature_env(key, value, variable: nil), which can simulate either variable. Removed with_feature_registry, uses_feature_registry, the example registry fixture, SUITE_GRAPH, reinstall_suite_graph!, stub_feature_env_setting and FakeFeatureFlagVersionToken. with_feature writes rows inside the test transaction. Facade and web tests use the real flags: external_runners (company scope) and coder_reap (global, with env:). Machinery tests build in-memory registries. No test needed a test-only flag at the facade level. New test/services/feature_flags/read_path_test.rb checks that a request reads once, that a write is visible on the next request, that a missed delete heals after the TTL, and that nothing is memoised outside an executor run.

Docs (§5). docs/architecture/feature-flags.md is rewritten as a short guide. The research doc is deleted and no longer linked. Also updated: docs/reference/configuration.md and its portal copy, the Coder user guide and its portal copy, docs/operations/releasing.md, docs/index.md and the CHANGELOG.

One existing test changed bound: aixle_builder_controller_test N+1 guard goes from 23 to 25 queries. The features prop now loads the flag rows once per request, and the test cache is a null store. The count is constant per request.

Line counts

before after
Production (app/services/feature.rb, feature_flags.rb, feature_flags/*.rb) 1,078 591
Feature-flag tests (incl. helper, fixture, fake) 2,654 1,572
Docs (guide + research) 1,106 146

Tested

On a Coder workspace, at head 521ce44f:

  • bundle exec rubocop on every changed Ruby file: no offenses.
  • Feature-flag targeted tests: 295 runs, 0 failures.
  • Full bin/rails test, 4 parallel workers: 8,854 runs, 0 failures, 0 errors.
  • GitHub CI: all checks green, including system tests and Vitest.

How to test manually

On /admin/feature_flags, set and clear the global value, add and remove an override, and turn a flag off everywhere. With CODER_REAP_ENABLED=false, the coder_reap page shows "Locked by CODER_REAP_ENABLED". With CODER_REAP_ENABLED=yes, boot fails and names the variable.

Aixle Flow added 3 commits October 26, 2026 19:30
Cut the flag system down to what it needs. The per-process snapshot
store, the Redis version token, the memory store and their settings
give way to one Rails.cache read with a 10 s TTL, memoised in Current
per request or job and dropped by FeatureFlags::Admin after commit.

CODER_REAP_ENABLED keeps locking coder_reap, now through a single
`env:` registry field parsed like FEATURE_<KEY>, instead of the
coder.reap_enabled settings bridge.

Removed: FeatureFlags::Lifecycle and the feature_flags rake tasks,
Admin.prune and the orphaned-rows UI, the "same everywhere" detection,
the source-scanning registry test, Resolution#shadowed, registry
substitution in tests (with_feature_registry, the example registry,
SUITE_GRAPH) and the research doc. Tests set values as rows; the ENV
layer is the only process-wide substitution left.

Signed-off-by: Aixle Flow <[email protected]>
@aixle-com
aixle-com Bot marked this pull request as ready for review October 26, 2026 20:00
Comment thread app/resources/features_resource.rb Resolved
Comment thread config/settings.yml Resolved
Comment thread app/services/feature_flags.rb Resolved
@NOX73
NOX73 force-pushed the feature/feature-flags-simplify branch from 184897b to 4a93b29 Compare October 27, 2026 10:42
The initializer now calls FeatureFlags.booted instead of boot!. In production
eager loading reaches FeaturesResource, which reads the registry and composes
the graph first; boot! composed it again and reported every undeclared
FEATURE_* variable twice.

Signed-off-by: Rozhnov Alexandr <[email protected]>
@NOX73
NOX73 force-pushed the feature/feature-flags-simplify branch from 4a93b29 to abee03a Compare October 27, 2026 10:45
…cals

Parse config/feature_flags.yml with aliases: false, as
FeatureFlags::Registry.load does, so the two parsers agree.

Signed-off-by: Aixle Flow <[email protected]>
@aixle-com
aixle-com Bot merged commit a078f30 into develop Oct 27, 2026
16 checks passed
artempartos added a commit to Hitin/flow that referenced this pull request Oct 28, 2026
* origin/develop:
  docs(workflows): describe workflows as sessions made of steps (AixleHQ#595)
  feat(workflows): open archived workflows read-only in the builder (AixleHQ#594)
  feat(task-comments): let authors delete their own recent comments (AixleHQ#593)
  feat(mcp): log the JSON-RPC method and tool name of each MCP call (AixleHQ#592)
  fix(board): show a run waiting for a session slot as Queued on its card (AixleHQ#591)
  feat(brand): use the new Aixle Flow lockup and route fonts through tokens (AixleHQ#590)
  feat(overview): show tokens used and session time instead of token cost (AixleHQ#589)
  fix(agents): pre-acknowledge Claude Code's cost-threshold notice (AixleHQ#587)
  test(playwright): QA helpers batch 2 (appRequest, readInertiaPage, shot, probeRoutes, signOut) (AixleHQ#586)
  test(playwright): plain-JS QA helpers for browser_run_code on staging (AixleHQ#584)
  feat(runners): add the runners table and the Runner model (AixleHQ#583)
  refactor(feature-flags): plain cached reads, no usage tooling (AixleHQ#579)

# Conflicts:
#	CHANGELOG.md
artempartos added a commit to Hitin/flow that referenced this pull request Oct 28, 2026
* origin/develop:
  docs(workflows): describe workflows as sessions made of steps (AixleHQ#595)
  feat(workflows): open archived workflows read-only in the builder (AixleHQ#594)
  feat(task-comments): let authors delete their own recent comments (AixleHQ#593)
  feat(mcp): log the JSON-RPC method and tool name of each MCP call (AixleHQ#592)
  fix(board): show a run waiting for a session slot as Queued on its card (AixleHQ#591)
  feat(brand): use the new Aixle Flow lockup and route fonts through tokens (AixleHQ#590)
  feat(overview): show tokens used and session time instead of token cost (AixleHQ#589)
  fix(agents): pre-acknowledge Claude Code's cost-threshold notice (AixleHQ#587)
  test(playwright): QA helpers batch 2 (appRequest, readInertiaPage, shot, probeRoutes, signOut) (AixleHQ#586)
  test(playwright): plain-JS QA helpers for browser_run_code on staging (AixleHQ#584)
  feat(runners): add the runners table and the Runner model (AixleHQ#583)
  refactor(feature-flags): plain cached reads, no usage tooling (AixleHQ#579)

# Conflicts:
#	CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant