Skip to content

fix(flags)!: honor versioned local property matching - #248

Draft
marandaneto wants to merge 1 commit into
mainfrom
fix/versioned-boolean-local-evaluation
Draft

fix(flags)!: honor versioned local property matching#248
marandaneto wants to merge 1 commit into
mainfrom
fix/versioned-boolean-local-evaluation

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

Local flag evaluation needs to use the property matching version returned with flag definitions. Without it, version 2 definitions still use legacy boolean coercion. For example, a false filter matches "banana" under legacy matching but should not match under version 2.

This follows the backend behavior and shared SDK contract. Optional shared harness coverage is separate. This PR does not opt the Rust adapter into that coverage.

Changes

  • Deserialize property_matching_version with a default of 1. Exactly 2 uses explicit scalar equality and member equality for nonempty filter arrays. Missing metadata and other versions keep released legacy matching.
  • Preserve recursive truthiness for empty filters and case-insensitive value normalization. For known properties, is_not complements exact. Missing properties remain inconclusive.
  • Keep definitions, group mappings, cohorts, and the matching version in one cache snapshot. Full, simple, and all-flags evaluations use that version through person, group, recursive cohort, and existing flag-dependency paths. Existing dependency limitations are unchanged.
  • Apply version-only refreshes even when definitions are unchanged. Failed responses and HTTP 304 responses preserve the installed snapshot.

Source compatibility

This is source-breaking for public struct-literal callers. Callers constructing LocalEvaluationResponse or EvaluationContext must add property_matching_version: 1 for legacy behavior, or pass the version associated with their definitions. Older serialized definitions still load without this field. The context-free match_feature_flag helper remains legacy.

The existing Sampo changeset is minor because this crate is pre-1.0 (0.25.x). The public API snapshot includes both new fields.

💚 How did you test it?

The committed tree matches the previously validated implementation exactly.

  • Reran cargo test --offline --test test_property_matching_version: 8 passed. Coverage includes wire matching cases, version-only refreshes, older serialized definitions, missing properties, propagation, blocking and async pollers, HTTP failure/304 preservation, the legacy helper, and concurrent snapshots.
  • Required committed-branch autoreview against origin/main: clean, no actionable findings, on 4c50b3ecdeef4bdcfdf5d78cc966c1c742a57a12.
  • Prior publication checks on the same tree passed: focused no-default suite (7 tests), cargo fmt -- --check, scripts/check-public-api.sh, and focused default-feature Clippy with -D warnings.
  • Prior implementation validation passed the complete default suite (354 passed, 1 ignored) and no-default suite (294 passed, 1 ignored). These full suites were not rerun for publication.

Known pre-existing strict all-target/no-default Clippy warnings remain out of scope. Live-service/e2e and capture-v1 runtime suites were not run. Local results do not establish CI success.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed. Public field docs and the API snapshot are updated.
  • No breaking change or entry added to the changelog. This has the source-breaking change described above and a pending Sampo changeset.

If releasing new changes

  • Ran sampo add to generate a changeset file. The existing manually maintained .sampo/changesets/versioned-property-matching.md is included with cargo/posthog-rs: minor.

Keep matching versions with definition snapshots across refreshes and recursive evaluation. Preserve legacy matching unless the version is exactly 2.

BREAKING CHANGE: LocalEvaluationResponse and EvaluationContext struct literals require property_matching_version. Use 1 for legacy behavior. Include a minor Sampo changeset for the pre-1.0 crate.
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

posthog-rs-v0 Compliance Report

Date: 2026-09-05 12:49:41 UTC
Duration: 15548ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 133ms
Format Validation.Event Has Uuid 133ms
Format Validation.Event Has Lib Properties 140ms
Format Validation.Distinct Id Is String 141ms
Format Validation.Token Is Present 142ms
Format Validation.Custom Properties Preserved 141ms
Format Validation.Event Has Timestamp 131ms
Retry Behavior.Retries On 503 5134ms
Retry Behavior.Does Not Retry On 400 2134ms
Retry Behavior.Does Not Retry On 401 2141ms
Retry Behavior.Respects Retry After Header 5105ms
Retry Behavior.Implements Backoff 15104ms
Retry Behavior.Retries On 500 5102ms
Retry Behavior.Retries On 502 5097ms
Retry Behavior.Retries On 504 5096ms
Retry Behavior.Max Retries Respected 15094ms
Deduplication.Generates Unique Uuids 101ms
Deduplication.Preserves Uuid On Retry 5024ms
Deduplication.Preserves Uuid And Timestamp On Retry 10030ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5032ms
Deduplication.No Duplicate Events In Batch 26ms
Deduplication.Different Events Have Different Uuids 23ms
Compression.Sends Gzip When Enabled 23ms
Batch Format.Uses Proper Batch Structure 23ms
Batch Format.Flush With No Events Sends Nothing 25ms
Batch Format.Multiple Events Batched Together 115ms
Error Handling.Does Not Retry On 403 2094ms
Error Handling.Does Not Retry On 413 2096ms
Error Handling.Retries On 408 5097ms

Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 75ms
Request Payload.Flags Request Uses V2 Query Param 67ms
Request Payload.Flags Request Hits Flags Path Not Decide 34ms
Request Payload.Flags Request Omits Authorization Header 32ms
Request Payload.Token In Flags Body Matches Init 39ms
Request Payload.Groups Round Trip 38ms
Request Payload.Groups Default To Empty Object 33ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 27ms
Request Payload.Disable Geoip Omitted Defaults To False 37ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 37ms
Request Lifecycle.No Flags Request On Init Alone 34ms
Request Lifecycle.No Flags Request On Normal Capture 54ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 52ms
Request Lifecycle.Mock Response Value Is Returned To Caller 39ms
Retry Behavior.Retries Flags On 502 240ms
Retry Behavior.Retries Flags On 504 241ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 40ms

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

posthog-rs-v1 Compliance Report

Date: 2026-09-05 12:49:46 UTC
Duration: 23024ms

✅ All Tests Passed!

111/111 tests passed


Capture_V1 Tests

94/94 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint 148ms
Endpoint And Method.Does Not Use Legacy Endpoints 146ms
Required Headers.Has Authorization Bearer Header 147ms
Required Headers.Has Content Type Json 146ms
Required Headers.Has Posthog Sdk Info Format 146ms
Required Headers.Has Posthog Attempt Header 146ms
Required Headers.Has Posthog Request Id 145ms
Required Headers.Has Posthog Request Timestamp 145ms
Required Headers.Has User Agent 151ms
Body Format.Body Has Created At And Batch 144ms
Body Format.No Api Key In Body 122ms
Body Format.No Sent At In Body 133ms
Event Format.Event Has Required Root Fields 134ms
Event Format.Event Uuid Is Valid 134ms
Event Format.Event Timestamp Is Rfc3339 134ms
Event Format.Distinct Id Is String 134ms
Event Format.Distinct Id At Root Not Properties 134ms
Event Format.Custom Properties Preserved 135ms
Event Format.Set Properties Preserved 133ms
Event Format.Set Once Properties Preserved 132ms
Event Format.Groups Properties Preserved 137ms
Event Format.Sdk Generates Uuid If Not Provided 132ms
Event Format.Event Has Required Root Fields Batch 153ms
Event Format.Event Uuid Is Valid Batch 162ms
Event Format.Event Timestamp Is Rfc3339 Batch 176ms
Event Format.Distinct Id Is String Batch 176ms
Event Format.Distinct Id At Root Not Properties Batch 175ms
Event Format.Custom Properties Preserved Batch 176ms
Event Format.Set Properties Preserved Batch 176ms
Event Format.Set Once Properties Preserved Batch 172ms
Event Format.Groups Properties Preserved Batch 146ms
Event Format.Sdk Generates Uuid If Not Provided Batch 144ms
Batch Behavior.Multiple Events In Single Batch 193ms
Batch Behavior.Batch Envelope Smoke 175ms
Batch Behavior.Flush With No Events Sends Nothing 93ms
Batch Behavior.Flush At Triggers Batch 1134ms
Batch Behavior.Created At Reflects Batch Creation Time 105ms
Deduplication.Generates Unique Uuids 181ms
Deduplication.Different Events Same Content Different Uuids 124ms
Deduplication.Preserves Uuid On Retry 5111ms
Deduplication.Preserves Timestamp On Retry 5071ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5131ms
Deduplication.No Duplicate Events In Batch 138ms
Header Behavior On Retry.Attempt Header Starts At One 73ms
Header Behavior On Retry.Attempt Header Increments On Retry 10090ms
Header Behavior On Retry.Request Id Preserved On Retry 5076ms
Header Behavior On Retry.Different Requests Have Different Request Ids 2070ms
Header Behavior On Retry.Request Timestamp Changes On Retry 5062ms
Response Format Validation.Success Response Has Uuid Keyed Results 65ms
Response Format Validation.Success Response Has Ok For Each Event 33ms
Response Format Validation.Success No Retry After When All Ok 36ms
Response Format Validation.Success Retry After Present When Retry Events 32ms
Response Format Validation.Success No Retry After When Drop Only 34ms
Response Format Validation.Response Echoes Request Id 28ms
Retry Behavior.Retries On 408 5033ms
Retry Behavior.Retries On 500 5026ms
Retry Behavior.Retries On 503 5025ms
Retry Behavior.Retries On 504 5024ms
Retry Behavior.Retryable Errors Have Retry After 2027ms
Retry Behavior.Respects Retry After On Retryable Error 8024ms
Retry Behavior.Does Not Retry On 400 2027ms
Retry Behavior.Does Not Retry On 401 2032ms
Retry Behavior.Does Not Retry On 402 2035ms
Retry Behavior.Does Not Retry On 413 2024ms
Retry Behavior.Does Not Retry On 415 2024ms
Retry Behavior.Non Retryable Errors Have No Retry After 2025ms
Retry Behavior.Implements Backoff 15030ms
Retry Behavior.Max Retries Respected 15025ms
Partial Batch Handling.Handles 200 Full Success 2039ms
Partial Batch Handling.Handles 200 With All Ok 3045ms
Partial Batch Handling.Does Not Retry Dropped Events 3032ms
Partial Batch Handling.Does Not Retry Limited Events 3030ms
Partial Batch Handling.Prunes Ok Events On Partial Retry 5027ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry 5025ms
Partial Batch Handling.Retries Only Retry Events From Partial 5025ms
Partial Batch Handling.Partial Retry Preserves Uuids 5025ms
Partial Batch Handling.Partial Retry Attempt Header Increments 5029ms
Partial Batch Handling.Partial Retry Request Id Preserved 5030ms
Partial Batch Handling.Respects Retry After On Partial 5025ms
Partial Batch Handling.Unknown Result Treated As Terminal 3026ms
Partial Batch Handling.Mixed Ok Drop Limited No Retry 3027ms
Compression.Sends Gzip Content Encoding 23ms
Compression.No Content Encoding When Disabled 21ms
Compression.Compressed Body Is Decompressible 22ms
Error Handling.Does Not Retry On Unknown 4Xx 2023ms
Event Options.Cookieless Mode Override 24ms
Event Options.Disable Skew Correction Override 21ms
Event Options.Process Person Profile Override 21ms
Event Options.Product Tour Id Override 21ms
Event Options.Unset Options Omitted 22ms
Event Options.Options Override In Batch 23ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties 21ms
Geoip And Historical Migration.Historical Migration Set In Body 22ms
Geoip And Historical Migration.Historical Migration Absent By Default 21ms

Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 16ms
Request Payload.Flags Request Uses V2 Query Param 17ms
Request Payload.Flags Request Hits Flags Path Not Decide 14ms
Request Payload.Flags Request Omits Authorization Header 14ms
Request Payload.Token In Flags Body Matches Init 13ms
Request Payload.Groups Round Trip 15ms
Request Payload.Groups Default To Empty Object 13ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 13ms
Request Payload.Disable Geoip Omitted Defaults To False 14ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 14ms
Request Lifecycle.No Flags Request On Init Alone 14ms
Request Lifecycle.No Flags Request On Normal Capture 25ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 17ms
Request Lifecycle.Mock Response Value Is Returned To Caller 13ms
Retry Behavior.Retries Flags On 502 219ms
Retry Behavior.Retries Flags On 504 216ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 23ms

@marandaneto
marandaneto marked this pull request as ready for review September 5, 2026 17:29
@marandaneto
marandaneto requested a review from a team as a code owner September 5, 2026 17:29
@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown

Reviews (1): Last reviewed commit: "fix(flags)!: honor versioned local prope..." | Re-trigger Greptile

@marandaneto
marandaneto marked this pull request as draft September 6, 2026 07:00
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