Skip to content

feat(flags): support known-absent property keys in local evaluation - #369

Open
marandaneto wants to merge 16 commits into
mainfrom
feat/flags-known-absent-property-keys
Open

marandaneto wants to merge 16 commits into
mainfrom
feat/flags-known-absent-property-keys

Conversation

@marandaneto

@marandaneto marandaneto commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

💡 Motivation and Context

Local flag evaluation can't tell "the caller didn't pass plan" from "this person has no plan". A key left out of person_properties is inconclusive. So a condition like plan is_not_set can't resolve locally, and the SDK falls back to /flags. Callers who know a person has no plan had no way to say so. Local results and the /flags fallback could then disagree.

This adds an optional way to list property keys that are known to be absent. It follows the cross-SDK spec in PostHog/sdk-specs#233 and the backend support in PostHog/posthog#138239.

Issue: PostHog/posthog#88947

New input

Every flag evaluation method now accepts two optional keyword arguments:

  • person_property_keys_known_absent: takes an Array of String or Symbol keys.
  • group_property_keys_known_absent: takes a Hash from group type name to an Array of keys.

These methods accept them: evaluate_flags, get_feature_flag, get_feature_flag_result, is_feature_enabled, get_feature_flag_payload, get_all_flags and get_all_flags_and_payloads. SendFeatureFlagsOptions also accepts them, and so does the hash form of capture(send_feature_flags:). Both default to nil, so existing calls behave the same.

flags = posthog.evaluate_flags(
  'user-1',
  groups: { organization: 'acme' },
  person_properties: { email: 'a@example.com' },
  person_property_keys_known_absent: ['plan'],
  group_property_keys_known_absent: { organization: ['tier'] }
)
flags.enabled?('onboarding-incomplete')

Local evaluation behavior

  • A listed key resolves locally with no remote call. is_not_set, is_not, not_icontains, not_starts_with, not_ends_with and not_regex match. Every other operator does not match. That includes is_set, exact, the contains/starts_with/ends_with/regex checks, number comparisons, all semver_* operators including semver_neq, and the date operators.
  • A listed key counts as absent even when the caller also passed a value for it. This also applies to values the SDK adds itself, such as distinct_id in person properties and $group_key in group properties.
  • Operators the SDK does not support are still checked first. They stay unresolved and fall back to /flags as before, even for a listed key. Like the flags service, a listed key resolves without parsing the condition value, so a malformed regex, number, date or semver value on a listed key still resolves from the table.
  • Operator support is checked before the known-absent table, in flag conditions and in dynamic-cohort leaves, as required by the latest spec revision (docs(flags): specify known-absent property keys sdk-specs#233). The test dynamic cohorts check operator support before the known-absent table covers a cohort leaf plan not_between [1, 2] with and without negation.
  • An omitted or JSON null condition value on a listed key stays inconclusive with unsupported_definition and falls back to /flags, per docs(flags): resolve known-absent keys without reading the condition value sdk-specs#239. is_set and is_not_set still resolve from the table whatever the value is.
  • A key that is left out and not listed stays inconclusive, as today.
  • Person keys starting with __posthog_person_metadata__ are ignored for local matching. They are still sent to /flags as given.
  • Known-absent keys apply only to the matching filter type: person keys only to type: "person" filters, group keys only to type: "group" filters of their own group type, and a person_metadata filter such as created_at never resolves from a listing, per docs(flags): specify known-absent property keys sdk-specs#233 and chore(deps-dev): bump rake from 13.2.1 to 13.4.2 #239. This includes group conditions inside flags that mix person and group conditions and person checks inside dynamic cohorts. A String and a Symbol that name the same group type are merged.
  • In dynamic cohorts, a property check uses the listed-key result before the check's negation is applied. Static cohorts and holdouts are unchanged.
  • A flag dependency is evaluated like a standalone flag, as the flags service does: with its own aggregation, bucketing ID, property map and known-absent keys, and as false when its group isn't passed. A person-aggregated dependency of a group flag reads person properties and person keys, and a group-aggregated one reads that group type's properties and keys. This also fixes a gap on main, where a dependency was evaluated with the calling condition's properties and bucketing ID (separate patch changeset).
  • A type: "group" filter without group_type_index reads the group type of the condition it is in, as in the flags service (PropertyFilter::group_filter_index), so that group type's known-absent keys apply to it.
  • A group key that is empty, nil, a boolean, an Array or a Hash counts as no group key, as in the flags service (is_usable_group_key, docs(flags): evaluate flag dependencies in their own context sdk-specs#250): a condition aggregated on that group type is skipped, and a flag whose conditions are all skipped resolves false locally with no /flags call (separate patch changeset).

/flags request body

When a call falls back to /flags, or skips local evaluation, the request includes person_property_keys_known_absent: [...] and group_property_keys_known_absent: { group_type => [...] }. A field is left out when the caller did not provide it or when it is empty.

Limits

Each list holds at most 1000 keys, counting duplicates. For groups the limit applies per group type. A longer list raises ArgumentError before any evaluation or request. The list is never truncated. Lists that are not an Array or Set, keys that are not a String or Symbol, and group types that are not a String or Symbol also raise ArgumentError. capture(send_feature_flags:) is the exception: capture is fire-and-forget per the capture spec, so it logs a warning and sends the event without flags.

Not included

Links

💚 How did you test it?

New tests in spec/posthog/feature_flags_known_absent_spec.rb and spec/posthog/send_feature_flags_options_spec.rb cover:

  • the result of every operator for a listed key, and local resolution with no remote call
  • a listed key overriding a supplied value, distinct_id and $group_key
  • an unlisted key staying inconclusive
  • the person metadata prefix being ignored
  • group-type scoping, mixed-targeting group conditions, and String/Symbol group names being merged
  • filter-type scoping (filter types block): a person_metadata created_at filter with is_not_set, is_date_before and is_date_after on a listed key, as a flag filter and as a cohort leaf, plus supplied-value and /flags fallback cases; a person listing against group filters; a group listing against another group type, a person filter and a person cohort leaf; and cross-aggregation dependencies in both directions, including a group dependency with a conflicting person value. 15 of these failed before the fix and all pass now. A same-aggregation group dependency already passed and stays as a regression test.
  • condition values a listed key does not read: malformed regex, number, date and semver values resolve from the table in local-only and default modes
  • unsupported operators and malformed filters on a listed key still falling back to /flags
  • an unsupported not_between leaf in a dynamic cohort, with and without negation, staying unresolved with unsupported_definition and falling back to /flags for a listed key. The new test passed without production changes, and it fails if the support check is removed.
  • cohort negation and a flag dependency
  • dependencies evaluated with their own context: a group-aggregated dependency whose group is missing, a group dependency whose person and group values for the same key differ, and the reverse person-parent case. All three failed before the fix and pass now.
  • a legacy group filter without group_type_index (exact and is_not_set), plus a guard that an explicit index for another group type still ignores the listing
  • an omitted or null condition value on a listed key: stays unsupported for is_not omitted / is_not null / exact null / gt null condition value on a listed key, stays unsupported for a JSON null condition value with a String-keyed filter, still resolves is_not_set / is_set with a null condition value on a listed key, leave an omitted / null is_not condition value unresolved in local-only mode and fall back to /flags for an omitted / null is_not condition value. The omitted and null is_not and exact cases failed before the fix and pass after it. gt null and the is_set/is_not_set cases already passed.
  • the /flags body including the fields on fallback for evaluate_flags, the older getters, all flags and payloads, and capture(send_feature_flags:), and leaving them out when they are missing or empty
  • the 1000-key limit for person keys, per group type and for an empty flag_keys scope, plus wrong input types
  • unusable group keys in spec/posthog/feature_flags_unusable_group_key_spec.rb, parameterized over '', nil, true, false, [], {}, a non-empty Array and a non-empty Hash: group flags, mixed flags, group dependencies, the single-flag getter, all flags and capture(send_feature_flags:). 56 failed before the fix and pass now; string, integer and float keys and a usable key without group properties stay as regression tests.

Commands run on the final commit:

  • bundle exec rspec: 2784 examples, 0 failures, 49 pending
  • bundle exec rubocop: no offenses
  • bundle exec rake public_api:check: passed

The otel gemfile suite was not run locally. No manual testing against a live PostHog project was done.

📝 Checklist

  • All commits are signed (see Commit signing)
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Implemented and reviewed with the pi coding agent, using Claude. Autoreview with GPT ran four rounds against origin/main. Accepted findings were fixed in separate signed commits. Those fixes merge String and Symbol group names, reject non-String group types, and check the key limit before evaluate_flags returns early for an empty flag_keys. Every round also flagged that dependencies did not use their own context. Review on this PR showed it combined with known-absent keys to return wrong local values, so it is now fixed here. A later round on the filter-type scoping found that a cross-aggregation dependency dropped its own listing. That is fixed in a separate commit, with a regression test.

@marandaneto marandaneto self-assigned this Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

posthog-ruby-sync Compliance Report

Date: 2026-11-25T13:03:07.146450+00:00
Duration: 94649ms

✅ All Tests Passed!

47/47 tests passed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 11ms
Format Validation.Event Has Uuid ✅ 7ms
Format Validation.Event Has Lib Properties ✅ 8ms
Format Validation.Distinct Id Is String ✅ 9ms
Format Validation.Token Is Present ✅ 8ms
Format Validation.Custom Properties Preserved ✅ 8ms
Format Validation.Event Has Timestamp ✅ 9ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 7ms
Retry Behavior.Retries On 503 ✅ 5329ms
Retry Behavior.Does Not Retry On 400 ✅ 2008ms
Retry Behavior.Does Not Retry On 401 ✅ 2011ms
Retry Behavior.Respects Retry After Header ✅ 8014ms
Retry Behavior.Implements Backoff ✅ 15329ms
Retry Behavior.Retries On 500 ✅ 5114ms
Retry Behavior.Retries On 502 ✅ 5145ms
Retry Behavior.Retries On 504 ✅ 5146ms
Retry Behavior.Max Retries Respected ✅ 15515ms
Deduplication.Generates Unique Uuids ✅ 18ms
Deduplication.Preserves Uuid On Retry ✅ 5138ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10294ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5121ms
Deduplication.No Duplicate Events In Batch ✅ 18ms
Deduplication.Different Events Have Different Uuids ✅ 10ms
Compression.Sends Gzip When Enabled ✅ 6ms
Batch Format.Uses Proper Batch Structure ✅ 6ms
Batch Format.Flush With No Events Sends Nothing ✅ 4ms
Batch Format.Synchronous Capture Delivers Each Event Immediately ✅ 16ms
Error Handling.Does Not Retry On 403 ✅ 2009ms
Error Handling.Does Not Retry On 413 ✅ 2009ms
Error Handling.Retries On 408 ✅ 5116ms

Feature_Flags Tests

✅ 17/17 tests passed

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

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

posthog-ruby-async Compliance Report

Date: 2026-11-25T13:03:12.422347+00:00
Duration: 98296ms

✅ All Tests Passed!

47/47 tests passed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 7ms
Format Validation.Event Has Uuid ✅ 103ms
Format Validation.Event Has Lib Properties ✅ 106ms
Format Validation.Distinct Id Is String ✅ 103ms
Format Validation.Token Is Present ✅ 104ms
Format Validation.Custom Properties Preserved ✅ 105ms
Format Validation.Event Has Timestamp ✅ 104ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 104ms
Retry Behavior.Retries On 503 ✅ 5309ms
Retry Behavior.Does Not Retry On 400 ✅ 2107ms
Retry Behavior.Does Not Retry On 401 ✅ 2106ms
Retry Behavior.Respects Retry After Header ✅ 8113ms
Retry Behavior.Implements Backoff ✅ 15617ms
Retry Behavior.Retries On 500 ✅ 5206ms
Retry Behavior.Retries On 502 ✅ 5218ms
Retry Behavior.Retries On 504 ✅ 5210ms
Retry Behavior.Max Retries Respected ✅ 15516ms
Deduplication.Generates Unique Uuids ✅ 108ms
Deduplication.Preserves Uuid On Retry ✅ 5208ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10414ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5211ms
Deduplication.No Duplicate Events In Batch ✅ 108ms
Deduplication.Different Events Have Different Uuids ✅ 105ms
Compression.Sends Gzip When Enabled ✅ 103ms
Batch Format.Uses Proper Batch Structure ✅ 105ms
Batch Format.Flush With No Events Sends Nothing ✅ 4ms
Batch Format.Multiple Events Batched Together ✅ 107ms
Error Handling.Does Not Retry On 403 ✅ 2106ms
Error Handling.Does Not Retry On 413 ✅ 2106ms
Error Handling.Retries On 408 ✅ 5211ms

Feature_Flags Tests

✅ 17/17 tests passed

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

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

SDK performance: posthog-ruby

Benchmarks completed. No changes flagged for review.

Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate.

View all results
Test Measurement Before PR With PR Change Assessment
Capture and deliver events (32-byte payload, burst)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Capture and deliver events (32-byte payload, steady)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Queue an event (32-byte payload)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​; head:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​
Queue an event (32-byte payload)
Shard: capture
Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​; head:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​
Queue an event (4,096-byte payload)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​; head:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​
Queue an event (4,096-byte payload)
Shard: capture
Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​; head:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​
Evaluate all 10 flags
Shard: flags-scaling
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate all 100 flags
Shard: flags-scaling
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate all 1,000 flags
Shard: flags-scaling
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate one boolean flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a cohort-filtered flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a flag (early match)
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a flag (late match)
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a flag (no match)
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a property-filtered flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a regex-filtered flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a rollout flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a multivariate flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Capture and deliver events (32-byte payload, burst)
Shard: capture
Allocations per operation 56.27 count/op 56.27 count/op No observed change Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Time per operation 108.85 µs/op 108.83 µs/op <0.1% less time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Idle process memory (RSS) 28.34 MiB 28.38 MiB 0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 31.12 MiB 31.15 MiB 0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Managed heap after settling 5.3 MiB 5.3 MiB 0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 31.12 MiB 31.15 MiB 0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process CPU time per operation 19.72 µs/op 19.79 µs/op 0.3% more time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 31.25 MiB 31.27 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Allocations per operation 58.65 count/op 58.65 count/op No observed change Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Time per operation 108.8 µs/op 108.83 µs/op <0.1% more time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Idle process memory (RSS) 33.17 MiB 33.38 MiB 0.6% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 42.27 MiB 42.41 MiB 0.3% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Managed heap after settling 9.17 MiB 9.17 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 39.42 MiB 39.78 MiB 0.9% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process CPU time per operation 27.54 µs/op 27.32 µs/op 0.8% less time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 42.06 MiB 42.32 MiB 0.6% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Allocations per operation 58.68 count/op 58.68 count/op <0.1% fewer Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Time per operation 1.01 ms/op 1.01 ms/op 0.2% less time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Idle process memory (RSS) 28.27 MiB 28.39 MiB 0.5% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 30.39 MiB 30.4 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Managed heap after settling 5.3 MiB 5.3 MiB 0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 30.39 MiB 30.4 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process CPU time per operation 31.88 µs/op 32.24 µs/op 1.1% more time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 30.39 MiB 30.4 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Allocations per operation 58.68 count/op 58.68 count/op No observed change Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Time per operation 1.01 ms/op 1.01 ms/op <0.1% more time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Idle process memory (RSS) 33.21 MiB 33.24 MiB 0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 41.5 MiB 40.9 MiB 1.4% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Managed heap after settling 9.17 MiB 9.17 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 40.45 MiB 39.23 MiB 3% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process CPU time per operation 37.73 µs/op 37.27 µs/op 1.2% less time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 41.32 MiB 41.26 MiB 0.2% less memory Not flagged
Queue an event (32-byte payload)
Shard: capture
Caller-thread CPU time per operation 8.64 µs/op 8.68 µs/op 0.5% more time Not flagged
Queue an event (32-byte payload)
Shard: capture
Time per operation 8.64 µs/op 8.68 µs/op 0.5% more time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Caller-thread CPU time per operation 8.46 µs/op 8.53 µs/op 0.8% more time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Time per operation 8.46 µs/op 8.53 µs/op 0.8% more time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Allocations per operation 343.02 count/op 352.02 count/op 2.6% more Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Time per operation 91.98 µs/op 95.11 µs/op 3.4% more time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Process CPU time per operation 91.98 µs/op 95.08 µs/op 3.4% more time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Allocations per operation 3,324 count/op 3,414 count/op 2.7% more Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Time per operation 886.93 µs/op 912.12 µs/op 2.8% more time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Process CPU time per operation 886.89 µs/op 912.07 µs/op 2.8% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Allocations per operation 33,113.62 count/op 34,013.5 count/op 2.7% more Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Time per operation 8.99 ms/op 9.19 ms/op 2.3% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Process CPU time per operation 8.99 ms/op 9.19 ms/op 2.3% more time Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Idle process memory (RSS) 39.06 MiB 39.29 MiB 0.6% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Observed peak process memory (RSS) 40.38 MiB 40.7 MiB 0.8% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Managed heap after settling 7.99 MiB 8 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Process memory after settling (RSS) 39.49 MiB 39.73 MiB 0.6% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Lifetime peak process memory (RSS) 40.05 MiB 40.3 MiB 0.6% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Idle process memory (RSS) 38.01 MiB 38.05 MiB <0.1% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Observed peak process memory (RSS) 42.13 MiB 42.54 MiB 1% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Managed heap after settling 9.5 MiB 9.51 MiB <0.1% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Process memory after settling (RSS) 41.21 MiB 42.54 MiB 3.2% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Lifetime peak process memory (RSS) 41.95 MiB 42.54 MiB 1.4% more memory Not flagged
Evaluate one boolean flag
Shard: flags-single
Allocations per operation 38 count/op 39 count/op 2.6% more Not flagged
Evaluate one boolean flag
Shard: flags-single
Time per operation 7.07 µs/op 7.25 µs/op 2.5% more time Not flagged
Evaluate one boolean flag
Shard: flags-single
Process CPU time per operation 7.07 µs/op 7.24 µs/op 2.5% more time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Allocations per operation 38 count/op 39 count/op 2.6% more Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Time per operation 8.97 µs/op 9.26 µs/op 3.3% more time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Process CPU time per operation 8.97 µs/op 9.26 µs/op 3.3% more time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Allocations per operation 55 count/op 56 count/op 1.8% more Not flagged
Evaluate a flag (early match)
Shard: flags-single
Time per operation 11.99 µs/op 12.58 µs/op 4.9% more time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Process CPU time per operation 11.99 µs/op 12.58 µs/op 4.9% more time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Allocations per operation 76 count/op 77 count/op 1.3% more Not flagged
Evaluate a flag (late match)
Shard: flags-single
Time per operation 17.19 µs/op 17.45 µs/op 1.5% more time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Process CPU time per operation 17.19 µs/op 17.45 µs/op 1.5% more time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Allocations per operation 67 count/op 68 count/op 1.5% more Not flagged
Evaluate a flag (no match)
Shard: flags-single
Time per operation 15.67 µs/op 16.44 µs/op 4.9% more time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Process CPU time per operation 15.66 µs/op 16.44 µs/op 4.9% more time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Allocations per operation 34 count/op 35 count/op 2.9% more Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Time per operation 7.08 µs/op 7.37 µs/op 4.1% more time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Process CPU time per operation 7.08 µs/op 7.37 µs/op 4.1% more time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Allocations per operation 99 count/op 100 count/op 1% more Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Time per operation 19.34 µs/op 20 µs/op 3.4% more time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Process CPU time per operation 19.34 µs/op 20 µs/op 3.4% more time Not flagged
Evaluate a rollout flag
Shard: flags-single
Allocations per operation 31 count/op 32 count/op 3.2% more Not flagged
Evaluate a rollout flag
Shard: flags-single
Time per operation 6.3 µs/op 6.55 µs/op 3.9% more time Not flagged
Evaluate a rollout flag
Shard: flags-single
Process CPU time per operation 6.3 µs/op 6.55 µs/op 3.9% more time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Allocations per operation 37 count/op 38 count/op 2.7% more Not flagged
Evaluate a multivariate flag
Shard: flags-single
Time per operation 7.75 µs/op 8.16 µs/op 5.3% more time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Process CPU time per operation 7.75 µs/op 8.16 µs/op 5.3% more time Not flagged

Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals.

Each shard uses its own runner; compare Before PR against With PR within a row, not across shards.

Compared 27fbf08b5a4cce9cda88f04db5b219391a7e04ff → d067af4ff27240f57ce792c1c7eac9ddfe47f78b.

Full report and diagnostics

102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in comparison.json, including per-runner environments, resource limits, measurement methods, samples and checkpoints.

@marandaneto
marandaneto marked this pull request as ready for review November 20, 2026 10:28
@marandaneto
marandaneto requested a review from a team as a code owner November 20, 2026 10:28
@veria-ai

veria-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@dustinbyrne dustinbyrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the KnownAbsentPropertyKeys abstraction, operator matching table, 1000-key limit validation, /flags wire serialization, public_api_snapshot.txt update, and changeset look clean.

Three behavioral concerns came up during review and local base/head RSpec checks (see inline comments):

  1. FeatureFlagsPoller.match_property applies known_absent_keys to type: 'person_metadata' filters (e.g. created_at), diverging from PostHog/posthog (flag_matching.rs:2656).
  2. evaluate_flag_dependency forwards outer known_absent_keys across person/group aggregation boundaries, turning a safe remote fallback on main into a silent wrong-true local result.
  3. Client#capture with send_feature_flags: skips add_local_person_and_group_properties, causing local evaluation with group_property_keys_known_absent to fail on mixed-targeting group conditions and hit NoMethodError via on_error on multi-filter pure group flags.

Follow-up (non-blocking, outside this PR — PostHog/team-client-libraries):

  • Update PostHog/posthog.com once released (contents/docs/feature-flags/local-evaluation/index.mdx still states is_not_set cannot be evaluated locally, and contents/docs/libraries/ruby/index.mdx omits the new options).
  • Coordinate merging open PostHog/sdk-specs#233 (and consider aligning it and the sibling Python/Node PRs on type: 'person_metadata' alongside the __posthog_person_metadata__ prefix rule).
  • Wire person_property_keys_known_absent / group_property_keys_known_absent into sdk_compliance_adapter/adapter.rb once the adapter declares feature_flags_local_evaluation_v1 and feature_flags_known_absent_v1 so harness 1.34.0's known-absent suite runs in CI.

AI-assisted review.

Comment thread lib/posthog/feature_flags.rb Resolved
Comment thread lib/posthog/feature_flags.rb Resolved
Comment thread lib/posthog/client.rb Resolved
Comment thread lib/posthog/client.rb Resolved
Comment thread lib/posthog/client.rb Resolved
@dustinbyrne
dustinbyrne requested a review from a team November 24, 2026 03:43

@dustinbyrne dustinbyrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the earlier threads — person_metadata filtering, capture(send_feature_flags:) group enrichment and fire-and-forget handling on invalid listings, Set YARD/specs, get_feature_flag_payload specs, and the sdk-specs#239 updates all look solid (648 flag/client RSpec examples, RuboCop, rake public_api:check, and all five earlier reproductions pass locally on 2b8680f0).

Two issues remain from the follow-up commits (see inline comments):

  1. Breaking (8e398d56): dependency_known_absent_scope switches known_absent_scope to a cross-aggregation dependency's aggregation while evaluate_flag_dependency still omits _compute_flag_locally's groups.key? check and passes the caller's distinct_id and properties, returning wrong local booleans with 0 /flags requests.
  2. Concern (bffa4f7a): KnownAbsentPropertyKeys::Scope#covers? excludes legacy type: 'group' filters omitting group_type_index, breaking backend parity (PropertyFilter::group_filter_index) and letting supplied group_properties override group_property_keys_known_absent.

(The PostHog/posthog.com docs follow-up from the earlier review remains non-blocking.)

AI-assisted review.

Comment thread lib/posthog/feature_flags.rb Resolved
@dustinbyrne
dustinbyrne requested review from a team and dustinbyrne November 24, 2026 19:08
@marandaneto

Copy link
Copy Markdown
Member Author

@dustinbyrne thanks for the review. Both issues from your summary are fixed in 9b38999, which landed after your review:

  1. Flag dependency context (8e398d56): evaluate_flag_dependency now evaluates each dependency through _compute_flag_locally with the top-level inputs, like a standalone flag. It uses its own aggregation, bucketing identifier, properties and known-absent listing, and it keeps the groups.key? check, so a group-aggregated dependency without its group resolves false. dependency_known_absent_scope is removed. Covered in spec/posthog/feature_flags_known_absent_spec.rb:
    • evaluate a group-aggregated dependency as false when its group is not passed
    • evaluate a group-aggregated dependency with its group properties, not person properties
    • evaluate a person-aggregated dependency with person properties, not group properties
    • do not leak person keys into a group-aggregated flag dependency / do not leak group keys into a person-aggregated flag dependency (updated to expect false)
  2. Legacy group filters (bffa4f7a): KnownAbsentPropertyKeys::Scope#covers? now treats a type: 'group' filter without group_type_index as belonging to the scope it is evaluated in, matching PropertyFilter::group_filter_index. Covered by apply group keys to a legacy group filter without group_type_index. do not apply group keys to a group filter for another group type still covers the explicit index case.

Full suite green after merging main (2723 examples, 0 failures), plus RuboCop and rake public_api:check.

This branch has not been deployed

No deployments
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.

2 participants