feat(flags): add semver targeting to local evaluation#74
Merged
Conversation
gustavohstrassburger
approved these changes
Mar 4, 2026
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.
Summary
Add semver comparison operators for local feature flag evaluation.
Problem
PostHog supports semver-based feature flag targeting in the UI (e.g., show a feature only to users on app version >=2.0.0), but the Rust SDK could not evaluate these flags locally. This forced all semver-targeted flags to fall back to server-side evaluation, adding latency and network dependency.
Related implementations:
user_blast_radiusposthog#44596Changes
parse_semver()function to parse version strings into(major, minor, patch)tuplessemver_eq,semver_neq,semver_gt,semver_gte,semver_lt,semver_ltesemver_tilde: patch-level range (~1.2.3 means >=1.2.3 <1.3.0)semver_caret: compatible-with range per semver spec (^1.2.3 means >=1.2.3 <2.0.0, with special handling for 0.x versions)semver_wildcard: wildcard patterns (1.2.* means >=1.2.0 <1.3.0)semvercrate to minimize dependency footprint for SDK consumersHow did you test this code?
Added 38 new tests covering:
Parsing tests:
Operator tests:
Error handling tests:
InconclusiveMatchErrorInconclusiveMatchError