Added __execute_local_criteria() API for local evaluation #22
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.



This pull request adds support for local criteria evaluation in the Switcher client, allowing feature flag checks to be performed using locally loaded snapshots instead of requiring remote API calls. It introduces a new resolver for local logic, improves error handling, and updates the data type definitions for stricter type safety. Comprehensive tests are also added to verify the new local evaluation logic.
Local criteria evaluation and resolver:
Resolverclass inlib/resolver.pyto evaluate feature flags locally using a loaded snapshot, including checks for domain, group, and config activation. Raises a customLocalCriteriaErrorfor missing or invalid data.Switcherinswitcher.pyto route criteria checks through the new local resolver when the context specifies local evaluation, falling back to remote checks otherwise. [1] [2] [3]Error handling improvements:
LocalCriteriaErrorexception for local evaluation errors, ensuring clear error reporting when snapshots are missing or keys are not found.Type safety and data model updates:
Domain,Group,Config,StrategyConfig, andRelaynon-optional and provided default values when parsing JSON, improving type safety and preventing issues with missing data. [1] [2] [3] [4] [5]ResultDetailfor easily creating success and disabled results.