Skip to content

fix(flags): don't fall back to the server for flag leaves in cohorts - #396

Open
marandaneto wants to merge 2 commits into
mainfrom
fix/cohort-flag-leaves
Open

marandaneto wants to merge 2 commits into
mainfrom
fix/cohort-flag-leaves

Conversation

@marandaneto

@marandaneto marandaneto commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

💡 Motivation and Context

A cohort definition can contain a flag dependency leaf: {"type": "flag", "operator": "flag_evaluates_to", ...}. Local evaluation sent it to the ordinary property matcher, which raised Unknown operator. So the flag fell back to /flags, only_evaluate_locally returned nil, and the load-time check reported the flag as an unsupported definition.

The flags service (rust/feature-flags in PostHog/posthog) doesn't resolve flag dependencies inside a cohort. It parses the leaf as an ordinary property filter, and its property matcher rejects flag_evaluates_to, so the leaf is a definitive non-match. I checked this by running the server's evaluate_dynamic_cohorts directly. It returns false for the leaf whatever the referenced flag returns, and true when the leaf is negated. Any other operator on a flag leaf compares the leaf's key with person properties. Ruby already did that, so it doesn't change.

This change treats a flag_evaluates_to leaf inside a cohort as a non-match before negation is applied, and stops the load-time check from reporting it as unsupported. A leaf whose key isn't a string or number is the one exception. The flags service can't parse it and fails the whole cohort, so the SDK now falls back to the server for it, and the load-time check reports it. Flag dependencies in release conditions are unchanged.

Spec divergence: the local evaluator spec currently says every flag filter, including one inside a cohort, evaluates the dependency. That doesn't match the flags service, so this PR follows the service. PostHog/sdk-specs#267 changes the spec to match.

The cohort API only accepts behavioral, cohort, person and person_metadata leaves, so this shape should be rare. It mainly matters for older stored cohorts.

Follows #394, which kept this case out of scope. Some SDKs, for example posthog-go and posthog-python, evaluate this leaf as a real dependency, which can disagree with the server.

💚 How did you test it?

  • New spec/posthog/feature_flags_cohort_flag_leaf_spec.rb (10 examples). They cover non-match whatever the referenced flag and caller properties are, negation, a leaf without value or dependency_chain, exact leaves against person properties, leaves with a missing, nil, array or hash key (fall back to the server) and a numeric key (stays local), and the load-time check. Each was checked against the flags service's evaluate_dynamic_cohorts. They fail without the fix.
  • bundle exec rspec: 2635 examples, 0 failures (49 pending need the optional otel bundle).
  • bundle exec rubocop and rake public_api:check pass.

📝 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)

  • Pi (Claude) followed up the out-of-scope note in fix(flags): treat unsupported property-filter types as inconclusive #394, ran probes against the flags service to confirm its result for each leaf shape, and wrote failing specs before the fix. Manoel directed the work.
  • Autoreview (GPT) found no issues. PostHog Review flagged a keyless leaf, which is now fixed, and the spec difference, which is resolved by changing the spec.

The flags service doesn't resolve a flag dependency inside a cohort. Its
property matcher rejects flag_evaluates_to, so the leaf is a definitive
non-match and a negated leaf matches. Local evaluation treated the leaf as
an unknown operator, so the flag fell back to /flags, and the load-time
check reported it as an unsupported definition.
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

posthog-ruby-sync Compliance Report

Date: 2026-11-30T09:28:37.381934+00:00
Duration: 94087ms

✅ All Tests Passed!

47/47 tests passed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 8ms
Format Validation.Event Has Uuid ✅ 6ms
Format Validation.Event Has Lib Properties ✅ 5ms
Format Validation.Distinct Id Is String ✅ 7ms
Format Validation.Token Is Present ✅ 6ms
Format Validation.Custom Properties Preserved ✅ 6ms
Format Validation.Event Has Timestamp ✅ 6ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 5ms
Retry Behavior.Retries On 503 ✅ 5235ms
Retry Behavior.Does Not Retry On 400 ✅ 2009ms
Retry Behavior.Does Not Retry On 401 ✅ 2012ms
Retry Behavior.Respects Retry After Header ✅ 8016ms
Retry Behavior.Implements Backoff ✅ 15271ms
Retry Behavior.Retries On 500 ✅ 5161ms
Retry Behavior.Retries On 502 ✅ 5149ms
Retry Behavior.Retries On 504 ✅ 5117ms
Retry Behavior.Max Retries Respected ✅ 15493ms
Deduplication.Generates Unique Uuids ✅ 16ms
Deduplication.Preserves Uuid On Retry ✅ 5149ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10326ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5121ms
Deduplication.No Duplicate Events In Batch ✅ 16ms
Deduplication.Different Events Have Different Uuids ✅ 7ms
Compression.Sends Gzip When Enabled ✅ 5ms
Batch Format.Uses Proper Batch Structure ✅ 4ms
Batch Format.Flush With No Events Sends Nothing ✅ 3ms
Batch Format.Synchronous Capture Delivers Each Event Immediately ✅ 13ms
Error Handling.Does Not Retry On 403 ✅ 2006ms
Error Handling.Does Not Retry On 413 ✅ 2009ms
Error Handling.Retries On 408 ✅ 5147ms

Feature_Flags Tests

✅ 17/17 tests passed

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

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

posthog-ruby-async Compliance Report

Date: 2026-11-30T09:28:46.917146+00:00
Duration: 98843ms

✅ All Tests Passed!

47/47 tests passed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 109ms
Format Validation.Event Has Uuid ✅ 106ms
Format Validation.Event Has Lib Properties ✅ 109ms
Format Validation.Distinct Id Is String ✅ 107ms
Format Validation.Token Is Present ✅ 107ms
Format Validation.Custom Properties Preserved ✅ 108ms
Format Validation.Event Has Timestamp ✅ 107ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 108ms
Retry Behavior.Retries On 503 ✅ 5412ms
Retry Behavior.Does Not Retry On 400 ✅ 2110ms
Retry Behavior.Does Not Retry On 401 ✅ 2109ms
Retry Behavior.Respects Retry After Header ✅ 8113ms
Retry Behavior.Implements Backoff ✅ 15722ms
Retry Behavior.Retries On 500 ✅ 5211ms
Retry Behavior.Retries On 502 ✅ 5214ms
Retry Behavior.Retries On 504 ✅ 5209ms
Retry Behavior.Max Retries Respected ✅ 15513ms
Deduplication.Generates Unique Uuids ✅ 112ms
Deduplication.Preserves Uuid On Retry ✅ 5211ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10317ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5214ms
Deduplication.No Duplicate Events In Batch ✅ 111ms
Deduplication.Different Events Have Different Uuids ✅ 107ms
Compression.Sends Gzip When Enabled ✅ 106ms
Batch Format.Uses Proper Batch Structure ✅ 107ms
Batch Format.Flush With No Events Sends Nothing ✅ 5ms
Batch Format.Multiple Events Batched Together ✅ 111ms
Error Handling.Does Not Retry On 403 ✅ 2109ms
Error Handling.Does Not Retry On 413 ✅ 2110ms
Error Handling.Retries On 408 ✅ 5214ms

Feature_Flags Tests

✅ 17/17 tests passed

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

@github-actions

github-actions Bot commented Nov 26, 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.83 µs/op 108.75 µs/op <0.1% less time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Idle process memory (RSS) 28.37 MiB 28.35 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 31.15 MiB 31.13 MiB <0.1% less 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.15 MiB 31.13 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process CPU time per operation 19.59 µs/op 19.59 µs/op <0.1% more time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 31.28 MiB 31.29 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.67 µs/op 108.75 µs/op <0.1% more time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Idle process memory (RSS) 33.18 MiB 33.22 MiB 0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 42.27 MiB 42.08 MiB 0.4% less 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.88 MiB 39.73 MiB 0.4% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process CPU time per operation 26.98 µs/op 27.11 µs/op 0.5% more time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 42.04 MiB 41.98 MiB 0.1% less memory Not flagged
Capture and deliver events (32-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 (32-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 (32-byte payload, steady)
Shard: capture
Idle process memory (RSS) 28.3 MiB 28.37 MiB 0.2% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 30.38 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.38 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.72 µs/op 32.07 µs/op 1.1% more time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 30.38 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.24 MiB 33.25 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 40.78 MiB 40.82 MiB 0.1% more 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.51 MiB 40.44 MiB 0.2% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process CPU time per operation 34.86 µs/op 36.68 µs/op 5.2% more time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 40.93 MiB 40.96 MiB <0.1% more memory Not flagged
Queue an event (32-byte payload)
Shard: capture
Caller-thread CPU time per operation 8.57 µs/op 8.55 µs/op 0.2% less time Not flagged
Queue an event (32-byte payload)
Shard: capture
Time per operation 8.57 µs/op 8.55 µs/op 0.2% less time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Caller-thread CPU time per operation 8.54 µs/op 8.52 µs/op 0.2% less time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Time per operation 8.53 µs/op 8.52 µs/op 0.2% less time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Allocations per operation 343.02 count/op 343.02 count/op No observed change Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Time per operation 94.53 µs/op 94.99 µs/op 0.5% more time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Process CPU time per operation 94.53 µs/op 94.98 µs/op 0.5% more time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Allocations per operation 3,324 count/op 3,323.97 count/op <0.1% fewer Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Time per operation 909.39 µs/op 916.86 µs/op 0.8% more time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Process CPU time per operation 909.4 µs/op 916.77 µs/op 0.8% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Allocations per operation 33,113.62 count/op 33,113.62 count/op No observed change Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Time per operation 9.25 ms/op 9.28 ms/op 0.3% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Process CPU time per operation 9.25 ms/op 9.27 ms/op 0.3% more time Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Idle process memory (RSS) 39.08 MiB 39.09 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Observed peak process memory (RSS) 40.47 MiB 40.41 MiB 0.1% less memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Managed heap after settling 7.99 MiB 7.99 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Process memory after settling (RSS) 39.54 MiB 39.5 MiB <0.1% less memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Lifetime peak process memory (RSS) 40.17 MiB 40.11 MiB 0.2% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Idle process memory (RSS) 37.66 MiB 37.97 MiB 0.8% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Observed peak process memory (RSS) 41.15 MiB 41.58 MiB 1% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Managed heap after settling 9.5 MiB 9.5 MiB <0.1% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Process memory after settling (RSS) 40.77 MiB 41.16 MiB 0.9% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Lifetime peak process memory (RSS) 41.08 MiB 41.45 MiB 0.9% more memory Not flagged
Evaluate one boolean flag
Shard: flags-single
Allocations per operation 38 count/op 38 count/op No observed change Not flagged
Evaluate one boolean flag
Shard: flags-single
Time per operation 7.85 µs/op 7.85 µs/op <0.1% less time Not flagged
Evaluate one boolean flag
Shard: flags-single
Process CPU time per operation 7.86 µs/op 7.85 µs/op <0.1% less time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Allocations per operation 38 count/op 38 count/op No observed change Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Time per operation 10.79 µs/op 11.02 µs/op 2.1% more time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Process CPU time per operation 10.79 µs/op 11.02 µs/op 2.1% more time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Allocations per operation 55 count/op 55 count/op No observed change Not flagged
Evaluate a flag (early match)
Shard: flags-single
Time per operation 13.95 µs/op 13.96 µs/op 0.1% more time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Process CPU time per operation 13.95 µs/op 13.97 µs/op 0.1% more time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Allocations per operation 76 count/op 76 count/op No observed change Not flagged
Evaluate a flag (late match)
Shard: flags-single
Time per operation 19.7 µs/op 19.64 µs/op 0.3% less time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Process CPU time per operation 19.7 µs/op 19.64 µs/op 0.3% less time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Allocations per operation 67 count/op 67 count/op No observed change Not flagged
Evaluate a flag (no match)
Shard: flags-single
Time per operation 17.78 µs/op 17.74 µs/op 0.2% less time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Process CPU time per operation 17.78 µs/op 17.74 µs/op 0.2% less time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Allocations per operation 34 count/op 34 count/op No observed change Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Time per operation 8.11 µs/op 8.13 µs/op 0.3% more time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Process CPU time per operation 8.11 µs/op 8.13 µs/op 0.3% more time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Allocations per operation 99 count/op 99 count/op <0.1% more Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Time per operation 23.17 µs/op 23.2 µs/op 0.1% more time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Process CPU time per operation 23.17 µs/op 23.2 µs/op 0.1% more time Not flagged
Evaluate a rollout flag
Shard: flags-single
Allocations per operation 31 count/op 31 count/op No observed change Not flagged
Evaluate a rollout flag
Shard: flags-single
Time per operation 7.08 µs/op 7.06 µs/op 0.3% less time Not flagged
Evaluate a rollout flag
Shard: flags-single
Process CPU time per operation 7.08 µs/op 7.06 µs/op 0.3% less time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Allocations per operation 37 count/op 37 count/op No observed change Not flagged
Evaluate a multivariate flag
Shard: flags-single
Time per operation 8.78 µs/op 8.8 µs/op 0.2% more time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Process CPU time per operation 8.78 µs/op 8.8 µs/op 0.2% 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 0586335a5e0a1b7e805e4166779a0e9ab400db3a → b7be7934f83dd15b5f1ced28952427b7d64addcc.

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 26, 2026 13:27
@marandaneto
marandaneto requested a review from a team as a code owner November 26, 2026 13:27
@veria-ai

veria-ai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@posthog posthog Bot 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.

PostHog Review · Standard · reviewed ee0240c: 2 Should fix.

New pushes to this pull request won't start an automatic review. Comment @posthog review to review new changes.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

Comment thread lib/posthog/feature_flags.rb Resolved
Comment on lines +1133 to +1134
matches = if cohort_flag_dependency?(prop)
false

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.

P2 · Reconcile cohort flag handling with the published SDK contract

For a cohort flag_evaluates_to leaf referencing a matching flag, this shortcut returns false instead of evaluating the dependency. The published local-feature-flag-evaluator spec explicitly applies flag dependency handling to dynamic-cohort leaves, so this changes behavior away from the canonical contract. Reconcile the spec with the intended server behavior and document the divergence.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I checked this against the flags service, and the spec is what's wrong here, so I kept the code. In rust/feature-flags, evaluate_cohort_filter only special-cases cohort leaves. A type: "flag" leaf goes to the ordinary property matcher, which rejects flag_evaluates_to, and evaluate_property_with_negation turns that into false before applying negation. Running evaluate_dynamic_cohorts on posthog d72ad144b3c gives false for the leaf whatever the referenced flag returns, and true when it's negated. Resolving the dependency, as the spec says now, could return true where /flags returns false. PostHog/sdk-specs#267 changes the spec to match the service, and the PR description now notes the difference. I'll leave this thread open for you to confirm.

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not approved — this change needs a human reviewer.

Add the stamphog label to request another review once you have addressed this.

Both substantive inline concerns remain unaddressed, so the current-head comment-only review does not provide independent assurance. Address @PostHog's findings and request review from a teammate or agent reviewer, with Gustavo H. Strassburger or Phil Haack as suggested reviewers, before re-requesting.

  • Author wrote 0% of the modified lines and has 51 merged PRs in these paths (familiarity MODERATE).
  • PostHog Review (Standard) reviewed the current head: 2 findings, posted on the PR.
  • posthog[bot] reviewed the current head.
  • @PostHog, lib/posthog/feature_flags.rb: The shortcut checks only leaf type and operator, without validating the required key. A keyless negated leaf therefore produces a positive match and is also classified as supported at load time. Address the missing-key validation concern before re-requesting.
  • @PostHog, lib/posthog/feature_flags.rb: The concern about compatibility with the published cross-SDK dependency contract remains unresolved: current code unconditionally rejects these dependencies before negation, and no non-author acceptance or contract reconciliation is provided. The external specification and server behavior cannot be independently verified from this checkout. Reconcile the intended contract and document any divergence; if the finding is incorrect, explain why in the review thread and resolve it.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
every_file_attested ✓ not a bot PR
size ✓ 20L, 1F substantive, 85L/3F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1d-complex (85L, 3F, cross-cutting, fix)
stamphog 2.9.1 .stamphog/policy.yml @ ee0240c · reviewed head ee0240c

@stamphog stamphog Bot removed the stamphog label Nov 26, 2026
The flags service can't parse a flag leaf whose key isn't a string or
number, and fails the whole cohort. Such a leaf now raises
RequiresServerEvaluation, so the flag falls back to /flags, and the
load-time check reports it as an unsupported definition. Before, a
negated keyless leaf matched and enabled the flag locally.

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not approved — this change needs a human reviewer.

Add the stamphog label to request another review once you have addressed this.

The missing-key concern is addressed by validation and regression tests, but @PostHog's contract-reconciliation concern remains unresolved and there is no current-head review covering the behavioral contract change. Request review from Gustavo H. Strassburger, Phil Haack, or another teammate to confirm the intended contract and resolve that concern before re-requesting.

  • Author wrote 0% of the modified lines and has 51 merged PRs in these paths (familiarity MODERATE).
  • @PostHog on lib/posthog/feature_flags.rb: The contract-reconciliation concern remains open. The current implementation deliberately skips dependency evaluation for these cohort leaves; the checkout contains no referenced evaluator specification or reconciliation establishing that this departure is accepted. Obtain independent confirmation of the intended contract and address the thread before re-requesting; if the finding is incorrect, explain why in the bot's thread and resolve it.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
every_file_attested ✓ not a bot PR
size ✓ 32L, 1F substantive, 117L/3F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1d-complex (117L, 3F, cross-cutting, fix)
stamphog 2.9.1 .stamphog/policy.yml @ b7be793 · reviewed head b7be793

@stamphog stamphog Bot removed the stamphog label Nov 30, 2026

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.

1 participant