Repository navigation
feat: create feature-flag configuration for staged rollout and rollback - #501
Merged
robertocarlous merged 4 commits intoOct 19, 2026
Merged
robertocarlous merged 4 commits into
robertocarlous merged 4 commits into
Conversation
- Add central feature-flag mechanism supporting environment-aware rules - Implement deterministic SHA-256 entity hashing for staged rollouts - Implement emergency rollback API, kill switches, and runbook - Log structured evaluation decisions via Winston and export Prometheus metrics - Add operational admin endpoints and middleware guards - Document emergency rollback runbook in docs/FEATURE_FLAGS.md and docs/RUNBOOK.md Closes Neurowealth#494
|
@OAKVISUALZ Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
fix conflicts |
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.
Description
This PR introduces a central, environment-aware feature flag system to enable safer release strategies, monotonic deterministic staged rollouts, and fast emergency rollbacks in production.
Key Changes
src/config/featureFlags.ts):FeatureFlagManagerand global singletonfeatureFlagManager.DEFAULT_FEATURE_FLAGS(agent_autonomous_rebalance,smart_dca_engine,enhanced_stellar_routing,ai_assistant_tool_calling,circuit_breaker_v2,fast_fiat_onramp,emergency_maintenance_mode).hashEntityToPercentage) providing sticky, monotonic distribution for progressive canary rollouts (0% -> 10% -> 25% -> 50% -> 100%).flag,decision,reason,environment,entityId,rolloutPercentage).feature_flag_evaluations_total), rollbacks (feature_flag_rollbacks_total), and rollout percentage gauge (feature_flag_rollout_percentage).src/middleware/featureFlags.ts):requireFeatureFlag: Route guard returning 503FEATURE_DISABLEDwhen feature is off or user is excluded by staged rollout.featureFlagMiddleware: Injectsreq.isFeatureEnabledandreq.evaluateFeatureFlaghelpers onto Express requests.emergencyMaintenanceGuard: Blocks state-mutating requests (POST, PUT, DELETE, PATCH) during emergency maintenance while preserving health probes and admin rollback routes.src/routes/admin.ts):flags:readandflags:write):GET /api/v1/admin/feature-flagsGET /api/v1/admin/feature-flags/historyGET /api/v1/admin/feature-flags/:keyPUT /api/v1/admin/feature-flags/:keyPOST /api/v1/admin/feature-flags/:key/staged-rolloutPOST /api/v1/admin/feature-flags/:key/rollbackPOST /api/v1/admin/feature-flags/:key/resetPOST /api/v1/admin/feature-flags/emergency-disable-alldocs/FEATURE_FLAGS.mddetailing architecture, deterministic hashing, decision logging, and the 4-tier emergency rollback runbook.docs/RUNBOOK.mdand indexed indocs/DOCUMENTATION_INDEX.md.tests/unit/config/featureFlags.test.ts,tests/unit/middleware/featureFlags.test.ts, andtests/unit/routes/admin-feature-flags.test.ts.Related Issues
Closes #494
Type of Change
Checklist
npm run lintwith no errorsnpm run typecheckwith no errorsnpm test)