Skip to content

feat(mcp): group sessions by ChatGPT, Codex and VS Code conversation ids - #386

Open
lucasheriques wants to merge 9 commits into
mainfrom
lucas/mcp-session-identity
Open

lucasheriques wants to merge 9 commits into
mainfrom
lucas/mcp-session-identity

Conversation

@lucasheriques

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

MCP Analytics should group one agent conversation into one $session_id. ChatGPT, Codex and VS Code each name the conversation in a tool call's _meta, and OpenAI says openai/session is how to group ChatGPT calls. PostHog::MCP ignored those ids. Worse, on stateless HTTP it filed every sessionless request under the server's own session, so unrelated clients shared one. This implements the sdk-specs "Session identity" requirement, as posthog-js (PostHog/posthog-js#5577, PostHog/posthog-js#5740) and posthog-python (PostHog/posthog-python#1193) already do.

What changed

  • Client conversation ids. The id is read from _meta, and only from the client its row recognizes by User-Agent or client name. The rows are ChatGPT openai/session, Codex sessionId and VS Code vscode.conversationId.
    • The id outranks a conversation handle. $session_id is derived from <key>:<id>.
    • The value itself is never sent. The recognized key is dropped from $mcp_parameters, and from the request the identify and event_properties callbacks receive.
    • ChatGPT is handle-free. Its listing gets no conversation_id, and it is minted no handle.
  • $mcp_session_source is on every event: client_metadata, conversation, transport or generated.
  • Rule 4. On HTTP, a request that carries no session gets a ses_<uuidv7> of its own. That covers every 2026-07-28 request, since the per-request session the mcp gem assigns is not a transport session. A call whose transport already carries a session is minted no handle.
  • Client recognition on stateless HTTP. The server-wide initialize handshake no longer names the client of a stateless HTTP request, because it may be another client's.
  • Custom events during a call. An analytics.capture inside a tool keeps that call's session and identity. When the call mints a handle, its custom events wait until the call records and then go out with the session it recorded. Past 1,000 held events, the rest go out at once with the session the call has so far.
  • stdio rollover. A client-id or handle call on stdio counts as connection activity. A call after 30 idle minutes still starts a new connection session.

Scope

  • The manual PostHog::MCP::Client API reads no client ids. It would need _meta and headers parameters, which is a public API change, so that is a separate PR.
  • This PR does not remove the standalone $identify event, which the spec's "Person identity" requirement forbids. That predates this change.
  • Like posthog-js and posthog-python, Ruby still mints handles on stdio. The spec counts a one-client connection as a transport session.

Divergence from the spec

None known for the behavior this PR changes. The session resolver ("host") is optional and Ruby has none, so host is never sent.

💚 How did you test it?

  • spec/posthog/mcp/client_session_spec.rb runs the spec's scenarios through the real Streamable HTTP transport and stdio, using the spec's $session_id vectors. It also covers the exposure, era, minting, stdio rollover and concurrent custom-event cases. Each example failed before its change.
  • bundle exec rspec: 2621 examples, 0 failures. rubocop and rake public_api:check pass. The snapshot adds Property::SESSION_SOURCE.
  • Two rounds of adversarial review, Opus and Sonnet, each proving findings with repro specs. Every verified finding is fixed here with a test.

📝 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. The posthog.com MCP analytics docs need a Ruby note on client conversation ids, as a follow-up.
  • 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)

  • Claude Code (Opus) ported the behavior from the merged posthog-js stack and posthog-python #1193, test-first against the spec's vectors.
  • The gem gives a 2026-07-28 request a throwaway session on stateful transports too. So the protocol era decides that it carries no transport session, rather than the transport's stateless flag.
  • Held custom events mirror posthog-python's final behavior, including sending events past the bound at once instead of dropping them.

Implements the sdk-specs MCP analytics "Session identity" requirement in
PostHog::MCP, ported from posthog-js #5577/#5740 and posthog-python #1193.

- Reads a client conversation id from tools/call `_meta`, only from the
  client whose row recognizes the request (User-Agent or client name):
  ChatGPT `openai/session`, Codex `sessionId`, VS Code
  `vscode.conversationId`. It outranks a conversation handle.
- ChatGPT is handle-free: its listing omits `conversation_id` (still
  owned and stripped for other clients) and it is minted no handle.
- Every event carries `$mcp_session_source` (client_metadata,
  conversation, transport, generated).
- Rule 4: a stateless HTTP request with no session gets a fresh
  per-request session instead of the server's shared one.
- The handshake names the client only off HTTP, so a stateless request
  is never recognized as another client.
- Custom events captured during a call that mints a handle are held and
  sent with the session and identity the call records.

Tested: bundle exec rspec (2612 examples, 0 failures; new
client_session_spec failed 13 of 14 before the change), rubocop clean,
rake public_api:check passes (adds Property::SESSION_SOURCE).
- Session.resolve keeps its internal sources; EventBuilder maps token and
  mcp to the wire's transport in one place.
- ConversationId.resolve takes mint:, so a handle-free or client-id call
  never mints a handle it then discards.
- Client recognition runs once per request; the client table uses
  validator lambdas, literal regexes and SchemaMutation.fetch.
- Release and hold skip the server mutex when nothing is held.
- env_for and parse move to the MCP spec helpers.

Tested: bundle exec rspec (2612 examples, 0 failures), rubocop clean,
rake public_api:check passes.
… say

Tested: bundle exec rspec spec/posthog/mcp (240 examples, 0 failures).
- The client conversation id no longer reaches $mcp_parameters or
  $identify: the captured request drops the `_meta` key it was read from.
- A 2026-07-28 stateless request's per-request gem session is not a
  transport session; it falls to rule 4 and is labelled generated.
- A call with a carried session (token or transport id) is minted no
  handle, as in posthog-python.
- A client id or echoed handle on stdio counts as connection activity,
  so the 30-minute rollover does not split a live connection.
- $identify carries $mcp_session_source; dropping held custom events past
  the cap warns once instead of logging at debug.

Tested: bundle exec rspec (2618 examples, 0 failures; 7 new examples
failed first), rubocop clean, rake public_api:check passes.
…e stdio sessions

From the second pre-PR gate round:
- The gem gives each 2026-07-28 request a throwaway session on stateful
  transports too, so the era, not the transport's stateless flag,
  decides that its id is not a transport session. A sessionless modern
  call is minted a handle again; the stateless flag on RequestScope is gone.
- A recognized client's `_meta` key is dropped from the captured request
  whatever its value, so an invalid id is not sent either.
- A client-id or handle call on stdio after 30 idle minutes rolls the
  connection session instead of extending it.
- The changeset names that callbacks lose the stripped `_meta` key.

Tested: bundle exec rspec (2621 examples, 0 failures; the new stateful
2026-07-28 and stale-stdio examples failed first), rubocop clean,
rake public_api:check passes.
…python does

posthog-python #1193 (5308a74) stopped dropping held custom events past
1,000: the rest go out at once with the session the call has so far.
Ruby now does the same and warns once.

Tested: bundle exec rspec (2621 examples, 0 failures; the bound example
failed first), rubocop clean.
Tested: bundle exec rspec (2621 examples, 0 failures).
@lucasheriques lucasheriques self-assigned this Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

posthog-ruby-sync Compliance Report

Date: 2026-11-25T17:39:49.383039+00:00
Duration: 94648ms

✅ 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 ✅ 8ms
Format Validation.Event Has Lib Properties ✅ 7ms
Format Validation.Distinct Id Is String ✅ 12ms
Format Validation.Token Is Present ✅ 9ms
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 ✅ 5304ms
Retry Behavior.Does Not Retry On 400 ✅ 2011ms
Retry Behavior.Does Not Retry On 401 ✅ 2011ms
Retry Behavior.Respects Retry After Header ✅ 8014ms
Retry Behavior.Implements Backoff ✅ 15349ms
Retry Behavior.Retries On 500 ✅ 5116ms
Retry Behavior.Retries On 502 ✅ 5159ms
Retry Behavior.Retries On 504 ✅ 5117ms
Retry Behavior.Max Retries Respected ✅ 15615ms
Deduplication.Generates Unique Uuids ✅ 19ms
Deduplication.Preserves Uuid On Retry ✅ 5115ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10353ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5150ms
Deduplication.No Duplicate Events In Batch ✅ 18ms
Deduplication.Different Events Have Different Uuids ✅ 10ms
Compression.Sends Gzip When Enabled ✅ 7ms
Batch Format.Uses Proper Batch Structure ✅ 7ms
Batch Format.Flush With No Events Sends Nothing ✅ 4ms
Batch Format.Synchronous Capture Delivers Each Event Immediately ✅ 18ms
Error Handling.Does Not Retry On 403 ✅ 2009ms
Error Handling.Does Not Retry On 413 ✅ 2008ms
Error Handling.Retries On 408 ✅ 5117ms

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 10ms
Request Payload.Flags Request Uses V2 Query Param ✅ 10ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 8ms
Request Payload.Flags Request Omits Authorization Header ✅ 10ms
Request Payload.Token In Flags Body Matches Init ✅ 7ms
Request Payload.Groups Round Trip ✅ 8ms
Request Payload.Groups Default To Empty Object ✅ 8ms
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 ✅ 8ms
Request Lifecycle.No Flags Request On Init Alone ✅ 3ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 6ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 10ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 7ms
Retry Behavior.Retries Flags On 502 ✅ 111ms
Retry Behavior.Retries Flags On 504 ✅ 155ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 9ms

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

posthog-ruby-async Compliance Report

Date: 2026-11-25T17:39:50.934283+00:00
Duration: 98240ms

✅ All Tests Passed!

47/47 tests passed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 108ms
Format Validation.Event Has Uuid ✅ 106ms
Format Validation.Event Has Lib Properties ✅ 108ms
Format Validation.Distinct Id Is String ✅ 105ms
Format Validation.Token Is Present ✅ 107ms
Format Validation.Custom Properties Preserved ✅ 106ms
Format Validation.Event Has Timestamp ✅ 106ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 6ms
Retry Behavior.Retries On 503 ✅ 5309ms
Retry Behavior.Does Not Retry On 400 ✅ 2110ms
Retry Behavior.Does Not Retry On 401 ✅ 2107ms
Retry Behavior.Respects Retry After Header ✅ 8014ms
Retry Behavior.Implements Backoff ✅ 15615ms
Retry Behavior.Retries On 500 ✅ 5211ms
Retry Behavior.Retries On 502 ✅ 5212ms
Retry Behavior.Retries On 504 ✅ 5209ms
Retry Behavior.Max Retries Respected ✅ 15508ms
Deduplication.Generates Unique Uuids ✅ 109ms
Deduplication.Preserves Uuid On Retry ✅ 5210ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10416ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5213ms
Deduplication.No Duplicate Events In Batch ✅ 109ms
Deduplication.Different Events Have Different Uuids ✅ 105ms
Compression.Sends Gzip When Enabled ✅ 105ms
Batch Format.Uses Proper Batch Structure ✅ 106ms
Batch Format.Flush With No Events Sends Nothing ✅ 3ms
Batch Format.Multiple Events Batched Together ✅ 109ms
Error Handling.Does Not Retry On 403 ✅ 2108ms
Error Handling.Does Not Retry On 413 ✅ 2107ms
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 ✅ 107ms
Request Payload.Flags Request Uses V2 Query Param ✅ 105ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 106ms
Request Payload.Flags Request Omits Authorization Header ✅ 106ms
Request Payload.Token In Flags Body Matches Init ✅ 107ms
Request Payload.Groups Round Trip ✅ 106ms
Request Payload.Groups Default To Empty Object ✅ 105ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 106ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 106ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 106ms
Request Lifecycle.No Flags Request On Init Alone ✅ 3ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 105ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 110ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 105ms
Retry Behavior.Retries Flags On 502 ✅ 209ms
Retry Behavior.Retries Flags On 504 ✅ 208ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 107ms

@github-actions

github-actions Bot commented Nov 25, 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 113.98 µs/op 114.18 µs/op 0.2% more time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Idle process memory (RSS) 28.42 MiB 28.41 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 31.44 MiB 31.43 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) 30.67 MiB 30.66 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process CPU time per operation 30.3 µs/op 30.66 µs/op 1.2% more time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 31.15 MiB 31.12 MiB 0.1% less 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 113.65 µs/op 113.53 µs/op 0.1% less time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Idle process memory (RSS) 33.25 MiB 33.21 MiB 0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 42.38 MiB 41.89 MiB 1.2% 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% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 40.36 MiB 40.1 MiB 0.7% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process CPU time per operation 42.36 µs/op 42.31 µs/op 0.1% less time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 42.07 MiB 41.64 MiB 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.02 ms/op 1.02 ms/op <0.1% more time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Idle process memory (RSS) 28.35 MiB 28.34 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 30.51 MiB 30.42 MiB 0.3% less 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.51 MiB 30.42 MiB 0.3% less memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process CPU time per operation 41.48 µs/op 42.75 µs/op 3.1% more time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 30.51 MiB 30.42 MiB 0.3% less 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.02 ms/op 1.02 ms/op <0.1% more time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Idle process memory (RSS) 33.26 MiB 33.28 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 41.35 MiB 41.04 MiB 0.8% 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% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 40.17 MiB 40.99 MiB 2% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process CPU time per operation 49.19 µs/op 49.97 µs/op 1.6% more time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 41.14 MiB 41.04 MiB 0.3% less memory Not flagged
Queue an event (32-byte payload)
Shard: capture
Caller-thread CPU time per operation 13.71 µs/op 13.67 µs/op 0.3% less time Not flagged
Queue an event (32-byte payload)
Shard: capture
Time per operation 13.71 µs/op 13.67 µs/op 0.3% less time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Caller-thread CPU time per operation 13.49 µs/op 13.39 µs/op 0.7% less time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Time per operation 13.49 µs/op 13.39 µs/op 0.7% 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 158.98 µs/op 159.39 µs/op 0.3% more time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Process CPU time per operation 158.97 µs/op 159.37 µs/op 0.3% more time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Allocations per operation 3,324 count/op 3,324 count/op No observed change Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Time per operation 1.51 ms/op 1.53 ms/op 0.9% more time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Process CPU time per operation 1.51 ms/op 1.53 ms/op 0.9% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Allocations per operation 33,113.56 count/op 33,113.59 count/op <0.1% more Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Time per operation 16.04 ms/op 15.78 ms/op 1.6% less time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Process CPU time per operation 16.04 ms/op 15.78 ms/op 1.6% less time Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Idle process memory (RSS) 39.11 MiB 39.07 MiB <0.1% less memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Observed peak process memory (RSS) 40.35 MiB 40.44 MiB 0.2% more 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% less memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Process memory after settling (RSS) 39.46 MiB 39.53 MiB 0.2% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Lifetime peak process memory (RSS) 40.06 MiB 40.11 MiB 0.1% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Idle process memory (RSS) 37.66 MiB 38.01 MiB 0.9% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Observed peak process memory (RSS) 42.2 MiB 42.23 MiB <0.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) 41.27 MiB 41.32 MiB 0.1% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Lifetime peak process memory (RSS) 42.08 MiB 42.04 MiB 0.1% less 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.94 µs/op 7.94 µs/op <0.1% more time Not flagged
Evaluate one boolean flag
Shard: flags-single
Process CPU time per operation 7.94 µs/op 7.94 µs/op <0.1% more 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.47 µs/op 10.51 µs/op 0.4% more time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Process CPU time per operation 10.47 µs/op 10.51 µs/op 0.4% 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.38 µs/op 13.39 µs/op <0.1% more time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Process CPU time per operation 13.38 µs/op 13.39 µ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 18.81 µs/op 18.76 µs/op 0.2% less time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Process CPU time per operation 18.81 µs/op 18.76 µs/op 0.2% 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 16.9 µs/op 16.93 µs/op 0.2% more time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Process CPU time per operation 16.9 µs/op 16.93 µs/op 0.1% more 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.07 µs/op 8.01 µs/op 0.7% less time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Process CPU time per operation 8.07 µs/op 8.01 µs/op 0.7% less time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Allocations per operation 99 count/op 99 count/op <0.1% fewer Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Time per operation 22.9 µs/op 22.95 µs/op 0.2% more time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Process CPU time per operation 22.9 µs/op 22.94 µs/op 0.2% 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.12 µs/op 7.16 µs/op 0.5% more time Not flagged
Evaluate a rollout flag
Shard: flags-single
Process CPU time per operation 7.12 µs/op 7.16 µs/op 0.5% more 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.8 µs/op 8.85 µs/op 0.6% more time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Process CPU time per operation 8.8 µs/op 8.85 µs/op 0.7% 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 → 16df26ba1b15d9b517e18173eb4e2d868c174974.

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.

@lucasheriques
lucasheriques marked this pull request as ready for review November 25, 2026 17:32
@lucasheriques
lucasheriques requested a review from a team as a code owner November 25, 2026 17:32
@lucasheriques

Copy link
Copy Markdown
Contributor Author

@PostHog review

@posthog

posthog Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@lucasheriques PostHog Review is reviewing this pull request.

@veria-ai

veria-ai Bot commented Nov 25, 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 bb31d73: 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/mcp/analytics.rb Resolved
Comment thread lib/posthog/mcp/analytics.rb Resolved
PostHog Review on bb31d73: a held event copied only its top-level
properties, so later changes to nested values reached it, and it kept the
full object graph until the call ended.

hold now runs the sink's stringify, sanitize and truncate steps at
capture, so a held event is a deep snapshot of at most one event's size,
and a call holds at most 4 MiB of them besides the 1,000-event cap. Past
either bound the rest go out at once with the session the call has so far.

Tested: bundle exec rspec (2623 examples, 0 failures; both new examples
failed first), rubocop clean, rake public_api:check passes.
@lucasheriques

Copy link
Copy Markdown
Contributor Author

@PostHog review

@posthog

posthog Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@lucasheriques PostHog Review is reviewing this pull request.

@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 16df26b: no findings.

@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 won't auto-review this pull request. The deny-list gate refused it because public_api_snapshot.txt changed (it adds PostHog::MCP::Property::SESSION_SOURCE), and that file is covered by the public_api rule. The tier gate then failed as a result, since a deny-list match on public API means this change is never eligible for automated review. The size gate passed, so splitting the PR won't clear this refusal.

Please ask a human reviewer to look at it. They can judge the public API addition along with the rest of the change.

  • posthog[bot] reviewed the current head.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✗ matches: public_api in public_api_snapshot.txt
every_file_attested ✓ not a bot PR
size ✓ 279L, 9F substantive, 649L/14F 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 16df26b

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