Skip to content

feat(aio): support offline experiment scorers - #1313

Merged
Radu-Raicea merged 1 commit into
mainfrom
feat/aio-experiment-score-sdk
Nov 26, 2026
Merged

Radu-Raicea merged 1 commit into
mainfrom
feat/aio-experiment-score-sdk

Conversation

@Radu-Raicea

Copy link
Copy Markdown
Member

Motivation and context

Python callers can now pin an experiment scorer version when creating a run and manage experiment formulas and suite assignments through the sync and async scorer clients. Experiment formulas retain the statistic, version policy, and category when callers fetch and reuse them. Older item scorer responses remain readable.

The public API snapshot, offline evaluations example, and release changeset are updated. The server contract and shared acceptance scenarios are in PostHog/sdk-specs#256. The backend shipped in PostHog/posthog#142387.

How did you test it?

  • 720 offline evaluation tests passed, including sync and async regression coverage for version selection, formula round-tripping, and suite assignments.
  • Ruff lint and formatting, mypy for the evaluations package, and the public API snapshot check passed.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Codex implemented and tested the SDK changes. Radu signed and pushed the verified commit.

@Radu-Raicea
Radu-Raicea requested a review from a team as a code owner November 26, 2026 16:22
@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

@github-actions

Copy link
Copy Markdown
Contributor

SDK performance: posthog-python

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
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Capture and deliver events (32-byte payload, steady)
Shard: capture
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Queue an event (32-byte payload)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​; head:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​
Queue an event (32-byte payload)
Shard: capture
Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​; head:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​
Queue an event (4,096-byte payload)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​; head:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​
Queue an event (4,096-byte payload)
Shard: capture
Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​; head:​ Background preparation has no public completion boundary before flush; see capture.​drain for full-pipeline allocations.​
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Refresh 1,000 flag definitions
Shard: flags-memory
Managed heap after settling — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​; head:​ CPython has no uninstrumented total managed-heap byte counter; tracing would distort this RSS pass.​
Capture and deliver events (32-byte payload, burst)
Shard: capture
Allocated memory per operation 133.67 KiB/op 133.67 KiB/op No observed change Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Allocations per operation 1,345.51 count/op 1,345.51 count/op No observed change Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Time per operation 77.44 µs/op 77.6 µs/op 0.2% more time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Idle process memory (RSS) 37.67 MiB 37.66 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 40.12 MiB 40.11 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 40.12 MiB 40.11 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process CPU time per operation 81.08 µs/op 80.96 µs/op 0.1% less time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 40.62 MiB 40.62 MiB No observed change Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Allocated memory per operation 185.75 KiB/op 185.75 KiB/op No observed change Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Allocations per operation 1,337.51 count/op 1,337.51 count/op No observed change Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Time per operation 101.37 µs/op 101.21 µs/op 0.2% less time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Idle process memory (RSS) 41.22 MiB 41.27 MiB 0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 47.01 MiB 47.06 MiB 0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 47.01 MiB 47.06 MiB 0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process CPU time per operation 98.78 µs/op 98.16 µs/op 0.6% less time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 51.47 MiB 51.47 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Allocated memory per operation 138.73 KiB/op 138.73 KiB/op <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Allocations per operation 1,390.3 count/op 1,390.3 count/op <0.1% fewer Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Time per operation 88.48 µs/op 88.57 µs/op 0.1% more time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Idle process memory (RSS) 37.6 MiB 37.57 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 37.78 MiB 37.72 MiB 0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 37.78 MiB 37.72 MiB 0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process CPU time per operation 90.42 µs/op 88.44 µs/op 2.2% less time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 40.62 MiB 40.62 MiB No observed change Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Allocated memory per operation 190.9 KiB/op 190.9 KiB/op <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Allocations per operation 1,382.19 count/op 1,382.19 count/op <0.1% fewer Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Time per operation 106.62 µs/op 106.51 µs/op 0.1% less time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Idle process memory (RSS) 41.1 MiB 41.08 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 41.56 MiB 41.52 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 41.16 MiB 41.13 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process CPU time per operation 103.63 µs/op 103.2 µs/op 0.4% less time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 41.49 MiB 41.44 MiB 0.1% less memory Not flagged
Queue an event (32-byte payload)
Shard: capture
Caller-thread CPU time per operation 57.05 µs/op 57.18 µs/op 0.2% more time Not flagged
Queue an event (32-byte payload)
Shard: capture
Time per operation 57.04 µs/op 57.18 µs/op 0.2% more time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Caller-thread CPU time per operation 56.61 µs/op 56.8 µs/op 0.3% more time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Time per operation 56.62 µs/op 56.8 µs/op 0.3% more time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Allocated memory per operation 233.85 KiB/op 233.85 KiB/op No observed change Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Allocations per operation 2,352.93 count/op 2,352.93 count/op No observed change Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Time per operation 85.52 µs/op 85.22 µs/op 0.4% less time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Process CPU time per operation 85.53 µs/op 85.23 µs/op 0.3% less time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Allocated memory per operation 2.25 MiB/op 2.25 MiB/op No observed change Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Allocations per operation 23,148.75 count/op 23,148.75 count/op No observed change Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Time per operation 805.15 µs/op 800.31 µs/op 0.6% less time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Process CPU time per operation 805.22 µs/op 800.39 µs/op 0.6% less time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Allocated memory per operation 22.45 MiB/op 22.45 MiB/op No observed change Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Allocations per operation 231,005.5 count/op 231,005.5 count/op No observed change Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Time per operation 7.94 ms/op 7.97 ms/op 0.4% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Process CPU time per operation 7.94 ms/op 7.97 ms/op 0.4% more time Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Idle process memory (RSS) 43.8 MiB 43.82 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Observed peak process memory (RSS) 44.1 MiB 44.13 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Process memory after settling (RSS) 44.1 MiB 44.13 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Lifetime peak process memory (RSS) 43.89 MiB 43.86 MiB <0.1% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Idle process memory (RSS) 42.98 MiB 42.96 MiB <0.1% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Observed peak process memory (RSS) 42.99 MiB 42.97 MiB <0.1% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Process memory after settling (RSS) 42.99 MiB 42.97 MiB <0.1% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Lifetime peak process memory (RSS) 43.18 MiB 42.8 MiB 0.9% less memory Not flagged
Evaluate one boolean flag
Shard: flags-single
Allocated memory per operation 15.74 KiB/op 15.74 KiB/op No observed change Not flagged
Evaluate one boolean flag
Shard: flags-single
Allocations per operation 162.77 count/op 162.77 count/op No observed change Not flagged
Evaluate one boolean flag
Shard: flags-single
Time per operation 8.21 µs/op 8.19 µs/op 0.2% less time Not flagged
Evaluate one boolean flag
Shard: flags-single
Process CPU time per operation 8.21 µs/op 8.19 µs/op 0.2% less time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Allocated memory per operation 25.28 KiB/op 25.28 KiB/op No observed change Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Allocations per operation 245.28 count/op 245.28 count/op No observed change Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Time per operation 11.7 µs/op 11.62 µs/op 0.7% less time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Process CPU time per operation 11.7 µs/op 11.62 µs/op 0.7% less time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Allocated memory per operation 41.36 KiB/op 41.36 KiB/op No observed change Not flagged
Evaluate a flag (early match)
Shard: flags-single
Allocations per operation 401.77 count/op 401.77 count/op No observed change Not flagged
Evaluate a flag (early match)
Shard: flags-single
Time per operation 16.9 µs/op 17 µs/op 0.6% more time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Process CPU time per operation 16.9 µs/op 17 µs/op 0.6% more time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Allocated memory per operation 63.34 KiB/op 63.34 KiB/op No observed change Not flagged
Evaluate a flag (late match)
Shard: flags-single
Allocations per operation 608.27 count/op 608.27 count/op No observed change Not flagged
Evaluate a flag (late match)
Shard: flags-single
Time per operation 24.07 µs/op 24.26 µs/op 0.8% more time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Process CPU time per operation 24.07 µs/op 24.26 µs/op 0.8% more time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Allocated memory per operation 61.97 KiB/op 61.97 KiB/op No observed change Not flagged
Evaluate a flag (no match)
Shard: flags-single
Allocations per operation 591.77 count/op 591.77 count/op No observed change Not flagged
Evaluate a flag (no match)
Shard: flags-single
Time per operation 22.65 µs/op 22.81 µs/op 0.7% more time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Process CPU time per operation 22.65 µs/op 22.81 µs/op 0.7% more time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Allocated memory per operation 19.38 KiB/op 19.38 KiB/op No observed change Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Allocations per operation 195.27 count/op 195.27 count/op No observed change Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Time per operation 9.38 µs/op 9.36 µs/op 0.2% less time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Process CPU time per operation 9.38 µs/op 9.36 µs/op 0.2% less time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Allocated memory per operation 21.01 KiB/op 21.01 KiB/op No observed change Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Allocations per operation 200.77 count/op 200.77 count/op No observed change Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Time per operation 9.96 µs/op 9.87 µs/op 0.9% less time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Process CPU time per operation 9.96 µs/op 9.87 µs/op 0.9% less time Not flagged
Evaluate a rollout flag
Shard: flags-single
Allocated memory per operation 14.89 KiB/op 14.89 KiB/op No observed change Not flagged
Evaluate a rollout flag
Shard: flags-single
Allocations per operation 152.77 count/op 152.77 count/op No observed change Not flagged
Evaluate a rollout flag
Shard: flags-single
Time per operation 7.84 µs/op 7.68 µs/op 2.1% less time Not flagged
Evaluate a rollout flag
Shard: flags-single
Process CPU time per operation 7.84 µs/op 7.68 µs/op 2.1% less time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Allocated memory per operation 15.9 KiB/op 15.9 KiB/op No observed change Not flagged
Evaluate a multivariate flag
Shard: flags-single
Allocations per operation 166.77 count/op 166.77 count/op No observed change Not flagged
Evaluate a multivariate flag
Shard: flags-single
Time per operation 8.53 µs/op 8.6 µs/op 0.8% more time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Process CPU time per operation 8.53 µs/op 8.6 µs/op 0.8% 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 42d95918e1e552fb29218ddeeebcef94e48968b6 → cd4c09f3c33d74ace05a90592ba444666a768452.

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.

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

Adding the stamphog label gives the same result unless the changed files change.

stamphog can't approve this pull request automatically. The deny-list gate refused it because the change touches references/public_api_snapshot.txt, which matches the public_api category. The tier gate then placed it in T2-never as a result. Size was not a factor: the substantive change is 297 lines across 5 files, within the ceiling.

The next step is to ask a human reviewer to look at it, since changes to the public API surface need a person's sign-off. Splitting the PR won't help, because any piece that updates the API snapshot would be refused the same way.

Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✗ matches: public_api in references/public_api_snapshot.txt
every_file_attested ✓ not a bot PR
size ✓ 297L, 5F substantive, 515L/10F incl. docs/generated/snapshots — within ceiling
tier ✗ T2-never because the deny-list matched public_api
stamphog 2.9.1 .stamphog/policy.yml @ unknown · reviewed head cd4c09f

@stamphog stamphog Bot removed the stamphog Request stamphog review label Nov 26, 2026
@Radu-Raicea
Radu-Raicea merged commit 32c0ab3 into main Nov 26, 2026
58 checks passed
@Radu-Raicea
Radu-Raicea deleted the feat/aio-experiment-score-sdk branch November 26, 2026 16:59
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