Skip to content

feat(flags): add semver targeting to local evaluation#107

Open
dmarticus wants to merge 1 commit intomainfrom
feat/semver-targeting
Open

feat(flags): add semver targeting to local evaluation#107
dmarticus wants to merge 1 commit intomainfrom
feat/semver-targeting

Conversation

@dmarticus
Copy link
Contributor

@dmarticus dmarticus commented Mar 2, 2026

Summary

  • Add 9 semver operators for local flag evaluation: semver_eq, semver_neq, semver_gt, semver_gte, semver_lt, semver_lte, semver_tilde, semver_caret, semver_wildcard
  • Implement parse_semver function that handles v-prefix, whitespace, pre-release suffixes, partial versions (e.g., "1.2" → "1.2.0"), and 4-part versions
  • Add bounds calculation for range operators following npm/semver conventions:
    • Tilde (~1.2.3): >=1.2.3 <1.3.0
    • Caret (^1.2.3): >=1.2.3 <2.0.0 (with special handling for 0.x versions)
    • Wildcard (1.2.*): >=1.2.0 <1.3.0

This enables targeting users by app/SDK version without network calls, matching the behavior in:

Test plan

  • Added 19 comprehensive test cases covering:
    • All 6 basic comparison operators (eq, neq, gt, gte, lt, lte)
    • All 3 range operators (tilde, caret, wildcard) with boundary conditions
    • Edge cases: v-prefix, pre-release suffixes, whitespace, leading zeros
    • Partial versions (1.2 → 1.2.0, 1 → 1.0.0)
    • 4-part versions (1.2.3.4 → 1.2.3)
    • Invalid input handling (raises InconclusiveMatchError)
    • Missing/null property values
  • Run bundle exec rspec spec/posthog/feature_flag_spec.rb — all 70 tests pass

@dmarticus dmarticus force-pushed the feat/semver-targeting branch from 28b0389 to 1192999 Compare March 3, 2026 01:29
@dmarticus dmarticus force-pushed the feat/semver-targeting branch from 1192999 to da36285 Compare March 3, 2026 18:50
@dmarticus dmarticus mentioned this pull request Mar 3, 2026
9 tasks
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