-
Notifications
You must be signed in to change notification settings - Fork 88
Runtime rules engine #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime rules engine #148
Conversation
This is the "official" repo, but has been virtually abandoned. the 2017 alpha release is what we need though
…time-rules-engine-clean
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #148 +/- ##
==========================================
+ Coverage 93.81% 94.28% +0.46%
==========================================
Files 9 9
Lines 1375 1557 +182
Branches 91 101 +10
==========================================
+ Hits 1290 1468 +178
- Misses 52 54 +2
- Partials 33 35 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for a runtime rules engine in local feature flag evaluation, enabling complex rule evaluation without network calls. The implementation uses the json-logic library to evaluate JSON-based rules against user properties.
- Adds
json-logicdependency for evaluating complex runtime rules - Introduces
runtime_evaluation_rulefield to support JSON-based rule definitions - Maintains backward compatibility with legacy
runtime_evaluation_definition
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pyproject.toml | Adds json-logic>=0.7.0a0 dependency for rule evaluation |
| mixpanel/flags/types.py | Adds runtime_evaluation_rule field to Rollout model to support JSON-based rules |
| mixpanel/flags/local_feature_flags.py | Implements _is_runtime_rules_engine_satisfied() method to evaluate JSON logic rules, with fallback to legacy evaluation |
| mixpanel/flags/test_local_feature_flags.py | Adds comprehensive test coverage for JSON logic rules including equality, contains, multi-value, AND operations, comparisons, and legacy compatibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
d359620 to
6fb5c01
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
msiebert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jaredmixpanel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM

Support complex runtime rules in local-evaluation - no network calls required!

GitHub Copilot Summary
This pull request introduces a new runtime rules engine for feature flag evaluation using JSON Logic, and updates the test suite to cover a wide range of rule scenarios. The main benefit is that feature flag rollouts can now be controlled by expressive, declarative rules, improving flexibility and maintainability. Legacy runtime evaluation logic is preserved for backward compatibility, but is ignored when new-style rules are present.
Feature flag evaluation logic:
json_logicand implemented_is_runtime_rules_engine_satisfied, which evaluates rollout rules using JSON Logic whenruntime_evaluation_ruleis present, falling back to legacy logic otherwise. [1] [2]runtime_evaluation_ruleover legacyruntime_evaluation_definition, ensuring backward compatibility but prioritizing new rules.Test suite enhancements:
TEST_FLAG_KEY,USER_CONTEXT), and added helper for user context with custom properties. [1] [2]General test improvements: