Skip to content

test: enable local feature flag evaluation compliance - #930

Merged
marandaneto merged 8 commits into
mainfrom
test/local-evaluation-harness
Sep 22, 2026
Merged

marandaneto merged 8 commits into
mainfrom
test/local-evaluation-harness

Conversation

@marandaneto

@marandaneto marandaneto commented Sep 8, 2026

Copy link
Copy Markdown
Member

💡 Motivation and Context

Stacked on #922. Merge that PR first, then retarget this PR to main.

The SDK specs and harness now include optional local feature flag evaluation tests. This PR enables them for both Python capture adapters and upgrades the harness workflow and Docker image from 0.10.0 to released version 1.1.1. Both reusable workflow references are pinned to its release commit, 1d6b197ef46758f577f470535bb3d70e37a15fa2.

The adapter now accepts a personal API key, explicitly reloads definitions with a bounded readiness check, and uses the real SDK local-only result API. It distinguishes a conclusive false from an inconclusive result without remote fallback. Forced remote calls use a separate definitions-free Client. Failed loads cannot acknowledge stale definitions, and timed-out loads cannot publish into replacement Clients after reset.

The workflow adds adapter protocol tests and makes compliance failures blocking. No shipped SDK runtime code changes, so no SDK release changeset is included.

Harness routing fix

PostHog/posthog-sdk-test-harness#54 is now included in harness 1.1.1. The released image correctly accepts normal capture-v1 routing for AI-named events, removing the failure seen with 1.1.0. Both complete compliance suites pass with 1.1.1. No SDK routing workaround or additional adapter change was needed for the patch upgrade.

💚 How did you test it?

  • Adapter protocol tests: 23 passed, including versioned matching, false versus inconclusive, forced remote behavior, failed reloads, timeouts, overlapping reloads, empty definitions, and reset isolation.
  • Rebuilt both adapters and ran the full Docker suites against released harness 1.1.1: 56/56 capture-v0 and 121/121 capture-v1 passed.
  • Both modes passed all 17 remote feature-flag tests and all 4 local-evaluation tests, including version-only reloads.
  • Repository-locked Ruff lint and formatting, Mypy with the repository baseline, actionlint, and git diff --check passed.
  • Exact-head autoreview --mode branch --base origin/fix/versioned-boolean-local-evaluation passed at 8939d3fa4de04e984ebb3e870db391809716c5f2 with no actionable findings.

📝 Checklist

  • 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 sampo add to generate a changeset file

Not applicable: this PR changes test infrastructure, not the published SDK.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Implemented with Pi using Git, pytest, Docker, Ruff, Mypy, actionlint, and isolated Pi autoreview. The work was directed by @marandaneto and requires human review.

The adapter delegates matching to the SDK instead of recreating matcher behavior. The separate upstream harness routing fix is now released and consumed here. This draft remains stacked on #922.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-09-22T07:03:05.232005+00:00
Duration: 259276ms

✅ All Tests Passed!

121/121 tests passed


Capture_V1 Tests

95/95 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint 514ms
Endpoint And Method.Does Not Use Legacy Endpoints 509ms
Required Headers.Has Authorization Bearer Header 508ms
Required Headers.Has Content Type Json 509ms
Required Headers.Has Posthog Sdk Info Format 508ms
Required Headers.Has Posthog Attempt Header 508ms
Required Headers.Has Posthog Request Id 508ms
Required Headers.Has Posthog Request Timestamp 508ms
Required Headers.Has User Agent 507ms
Body Format.Body Has Created At And Batch 508ms
Body Format.No Api Key In Body 508ms
Body Format.No Sent At In Body 508ms
Event Format.Event Has Required Root Fields 508ms
Event Format.Event Uuid Is Valid 508ms
Event Format.Event Timestamp Is Rfc3339 507ms
Event Format.Non Utc Event Timestamp Is Converted To Utc 512ms
Event Format.Distinct Id Is String 508ms
Event Format.Distinct Id At Root Not Properties 508ms
Event Format.Custom Properties Preserved 509ms
Event Format.Set Properties Preserved 507ms
Event Format.Set Once Properties Preserved 508ms
Event Format.Groups Properties Preserved 508ms
Event Format.Sdk Generates Uuid If Not Provided 508ms
Event Format.Event Has Required Root Fields Batch 510ms
Event Format.Event Uuid Is Valid Batch 510ms
Event Format.Event Timestamp Is Rfc3339 Batch 510ms
Event Format.Distinct Id Is String Batch 509ms
Event Format.Distinct Id At Root Not Properties Batch 510ms
Event Format.Custom Properties Preserved Batch 510ms
Event Format.Set Properties Preserved Batch 510ms
Event Format.Set Once Properties Preserved Batch 510ms
Event Format.Groups Properties Preserved Batch 510ms
Event Format.Sdk Generates Uuid If Not Provided Batch 510ms
Batch Behavior.Multiple Events In Single Batch 513ms
Batch Behavior.Batch Envelope Smoke 511ms
Batch Behavior.Flush With No Events Sends Nothing 506ms
Batch Behavior.Flush At Triggers Batch 1008ms
Batch Behavior.Created At Reflects Batch Creation Time 508ms
Deduplication.Generates Unique Uuids 513ms
Deduplication.Different Events Same Content Different Uuids 510ms
Deduplication.Preserves Uuid On Retry 6516ms
Deduplication.Preserves Timestamp On Retry 6517ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 6520ms
Deduplication.No Duplicate Events In Batch 513ms
Header Behavior On Retry.Attempt Header Starts At One 507ms
Header Behavior On Retry.Attempt Header Increments On Retry 13524ms
Header Behavior On Retry.Request Id Preserved On Retry 6513ms
Header Behavior On Retry.Different Requests Have Different Request Ids 3018ms
Header Behavior On Retry.Request Timestamp Changes On Retry 6517ms
Response Format Validation.Success Response Has Uuid Keyed Results 508ms
Response Format Validation.Success Response Has Ok For Each Event 511ms
Response Format Validation.Success No Retry After When All Ok 511ms
Response Format Validation.Success Retry After Present When Retry Events 1512ms
Response Format Validation.Success No Retry After When Drop Only 509ms
Response Format Validation.Response Echoes Request Id 508ms
Retry Behavior.Retries On 408 6520ms
Retry Behavior.Retries On 500 6517ms
Retry Behavior.Retries On 503 8519ms
Retry Behavior.Retries On 504 6517ms
Retry Behavior.Retryable Errors Have Retry After 3513ms
Retry Behavior.Respects Retry After On Retryable Error 11514ms
Retry Behavior.Does Not Retry On 400 2511ms
Retry Behavior.Does Not Retry On 401 2511ms
Retry Behavior.Does Not Retry On 402 2511ms
Retry Behavior.Does Not Retry On 413 2512ms
Retry Behavior.Does Not Retry On 415 2511ms
Retry Behavior.Non Retryable Errors Have No Retry After 2511ms
Retry Behavior.Implements Backoff 22532ms
Retry Behavior.Max Retries Respected 22533ms
Partial Batch Handling.Handles 200 Full Success 2511ms
Partial Batch Handling.Handles 200 With All Ok 3514ms
Partial Batch Handling.Does Not Retry Dropped Events 3513ms
Partial Batch Handling.Does Not Retry Limited Events 3510ms
Partial Batch Handling.Prunes Ok Events On Partial Retry 6518ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry 6514ms
Partial Batch Handling.Retries Only Retry Events From Partial 6519ms
Partial Batch Handling.Partial Retry Preserves Uuids 6519ms
Partial Batch Handling.Partial Retry Attempt Header Increments 6513ms
Partial Batch Handling.Partial Retry Request Id Preserved 6519ms
Partial Batch Handling.Respects Retry After On Partial 8518ms
Partial Batch Handling.Unknown Result Treated As Terminal 3513ms
Partial Batch Handling.Mixed Ok Drop Limited No Retry 3516ms
Compression.Sends Gzip Content Encoding 509ms
Compression.No Content Encoding When Disabled 508ms
Compression.Compressed Body Is Decompressible 508ms
Error Handling.Does Not Retry On Unknown 4Xx 2510ms
Event Options.Cookieless Mode Override 509ms
Event Options.Disable Skew Correction Override 512ms
Event Options.Process Person Profile Override 507ms
Event Options.Product Tour Id Override 512ms
Event Options.Unset Options Omitted 510ms
Event Options.Options Override In Batch 510ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties 509ms
Geoip And Historical Migration.Historical Migration Set In Body 508ms
Geoip And Historical Migration.Historical Migration Absent By Default 508ms

Capture_Ai Tests

5/5 tests passed

View Details
Test Status Duration
Routing.Capture Ai Posts To Ai Endpoint 509ms
Routing.Capture Does Not Reroute Ai Named Events 508ms
Identity.Capture Ai Event Has Uuid 508ms
Identity.Capture Ai Keeps Supplied Uuid 508ms
Timestamp Format.Non Utc Event Timestamp Is Converted To Utc 508ms

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 8ms
Request Payload.Flags Request Hits Flags Path Not Decide 7ms
Request Payload.Flags Request Omits Authorization Header 7ms
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 8ms
Request Payload.Disable Geoip Omitted Defaults To False 7ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 7ms
Request Lifecycle.No Flags Request On Init Alone 2ms
Request Lifecycle.No Flags Request On Normal Capture 507ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 11ms
Request Lifecycle.Mock Response Value Is Returned To Caller 7ms
Retry Behavior.Retries Flags On 502 310ms
Retry Behavior.Retries Flags On 504 310ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 510ms

Feature_Flags_Local_Evaluation Tests

4/4 tests passed

View Details
Test Status Duration
Versioned Boolean Matching.Matching Version Missing 46ms
Versioned Boolean Matching.Matching Version 1 45ms
Versioned Boolean Matching.Matching Version 2 46ms
Versioned Boolean Matching.Version Only Reload 1 2 1 2 Missing 27ms

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

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "test: upgrade SDK compliance harness to ..." | Re-trigger Greptile

@marandaneto
marandaneto marked this pull request as draft September 9, 2026 12:20
@github-actions

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@github-actions github-actions Bot added the stale label Sep 17, 2026
Base automatically changed from fix/versioned-boolean-local-evaluation to main September 22, 2026 06:51
@marandaneto
marandaneto marked this pull request as ready for review September 22, 2026 06:55
…-harness

# Conflicts:
#	posthog/client.py
#	posthog/test/test_flag_cache_publication.py
#	posthog/test/test_property_matching_version.py
#	posthog/test/test_redis_flag_cache_snapshot.py
#	posthog/test/test_utils.py
#	posthog/utils.py
@marandaneto
marandaneto merged commit 3e0c4e4 into main Sep 22, 2026
43 checks passed
@marandaneto
marandaneto deleted the test/local-evaluation-harness branch September 22, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants