Skip to content

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

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

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

Conversation

@dmarticus
Copy link
Contributor

@dmarticus dmarticus commented Mar 2, 2026

Summary

  • Add 9 semver comparison operators to local feature flag evaluation
  • Implement inline semver parsing (no external dependencies)
  • Add 45 comprehensive tests

What

This PR adds semver (semantic versioning) targeting support to local feature flag evaluation, matching the behavior already implemented in the Python SDK and PostHog server.

New operators

Operator Description Example
semver_eq Exact match 1.2.3 == 1.2.3
semver_neq Not equal 1.2.3 != 1.2.4
semver_gt Greater than 1.2.4 > 1.2.3
semver_gte Greater than or equal 1.2.3 >= 1.2.3
semver_lt Less than 1.2.2 < 1.2.3
semver_lte Less than or equal 1.2.3 <= 1.2.3
semver_tilde Patch-level range ~1.2.3 means >=1.2.3 <1.3.0
semver_caret Compatible-with range ^1.2.3 means >=1.2.3 <2.0.0
semver_wildcard Wildcard range 1.2.* means >=1.2.0 <1.3.0

Semver parsing

The parseSemver function handles:

  • v/V prefix stripping (v1.2.31.2.3)
  • Whitespace trimming
  • Pre-release suffix stripping (1.2.3-alpha1.2.3)
  • Build metadata stripping (1.2.3+build1.2.3)
  • Partial versions (1.21.2.0, 11.0.0)
  • Extra parts ignored (1.2.3.41.2.3)
  • Leading zeros (01.02.031.2.3)

Invalid inputs throw InconclusiveMatchException following the existing error handling pattern.

Test plan

  • All 45 new semver tests pass
  • Existing property matching tests still pass
  • PHP syntax validation passes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant