Skip to content

fix(mcp): give every manual capture a $session_id and read client conversation ids - #392

Open
lucasheriques wants to merge 5 commits into
lucas/mcp-virtual-tool-handlefrom
lucas/mcp-manual-steps
Open

lucasheriques wants to merge 5 commits into
lucas/mcp-virtual-tool-handlefrom
lucas/mcp-manual-steps

Conversation

@lucasheriques

@lucasheriques lucasheriques commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Stacked on #391. The sdk-specs "Manual capture" requirement, for the lower-level method, says this. A $session_id the caller passes "is sent unchanged as the transport session unless a client conversation id or a conversation handle applies". Without one, "each call gets a fresh ses_<UUIDv7>". A client conversation id applies when the caller passes the request's _meta with the User-Agent or client name that recognizes its client. PostHog::MCP::Client sent no $session_id when given none, and read no client ids.

What changed

  • Every capture_* sends $session_id and $mcp_session_source: the caller's session unchanged, or else a fresh generated one. The anonymous distinct_id falls back to it instead of "anonymous".
  • capture_tool_call takes request_meta: and client_name:, and groups by a recognized client's conversation id.
  • capture_missing_capability no longer sends $mcp_parameters. The keyword is still accepted.

Scope

The spec's three-step manual API (list, call and result steps) is not here. It is new public API and needs its own design.

💚 How did you test it?

  • New client_spec.rb tables cover a fresh or passed session for each capture_*, and client-id recognition by User-Agent, by name, and for a key the client doesn't define. They failed first.
  • bundle exec rspec: 0 failures. rubocop and rake public_api:check pass with the regenerated snapshot.

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

Claude Code (Opus) found this gap in a spec-alignment audit of #386 and checked it against sdk-specs main. It wrote the fix test-first. The pre-PR gate ran over the whole stack: /simplify, a comment pass, and an adversarial review by Opus and Sonnet. Every verified finding is fixed here with a test.

@lucasheriques
lucasheriques added this pull request to stack #393 November 25, 2026 19:37
@lucasheriques lucasheriques self-assigned this Nov 25, 2026
@lucasheriques lucasheriques changed the title lucas/mcp manual steps fix(mcp): give every manual capture a $session_id and read client conversation ids Nov 25, 2026
@lucasheriques
lucasheriques marked this pull request as ready for review November 25, 2026 19:38
@lucasheriques

Copy link
Copy Markdown
Contributor Author

@PostHog review

@lucasheriques
lucasheriques requested a review from a team as a code owner November 25, 2026 19:38
@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

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

posthog-ruby-sync Compliance Report

Date: 2026-11-30T10:36:55.365782+00:00
Duration: 94360ms

✅ 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 ✅ 5ms
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 ✅ 5ms
Format Validation.Event Has Timestamp ✅ 6ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 5ms
Retry Behavior.Retries On 503 ✅ 5240ms
Retry Behavior.Does Not Retry On 400 ✅ 2008ms
Retry Behavior.Does Not Retry On 401 ✅ 2008ms
Retry Behavior.Respects Retry After Header ✅ 8014ms
Retry Behavior.Implements Backoff ✅ 15386ms
Retry Behavior.Retries On 500 ✅ 5164ms
Retry Behavior.Retries On 502 ✅ 5114ms
Retry Behavior.Retries On 504 ✅ 5161ms
Retry Behavior.Max Retries Respected ✅ 15623ms
Deduplication.Generates Unique Uuids ✅ 15ms
Deduplication.Preserves Uuid On Retry ✅ 5111ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10362ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5152ms
Deduplication.No Duplicate Events In Batch ✅ 15ms
Deduplication.Different Events Have Different Uuids ✅ 8ms
Compression.Sends Gzip When Enabled ✅ 4ms
Batch Format.Uses Proper Batch Structure ✅ 5ms
Batch Format.Flush With No Events Sends Nothing ✅ 2ms
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 ✅ 5153ms

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 ✅ 7ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 7ms
Request Payload.Flags Request Omits Authorization Header ✅ 6ms
Request Payload.Token In Flags Body Matches Init ✅ 5ms
Request Payload.Groups Round Trip ✅ 4ms
Request Payload.Groups Default To Empty Object ✅ 5ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 5ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 5ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 5ms
Request Lifecycle.No Flags Request On Init Alone ✅ 1ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 5ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 6ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 5ms
Retry Behavior.Retries Flags On 502 ✅ 107ms
Retry Behavior.Retries Flags On 504 ✅ 107ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 5ms

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

posthog-ruby-async Compliance Report

Date: 2026-11-30T10:36:48.389784+00:00
Duration: 98853ms

✅ All Tests Passed!

47/47 tests passed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 110ms
Format Validation.Event Has Uuid ✅ 107ms
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 ✅ 109ms
Format Validation.Event Has Timestamp ✅ 107ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 8ms
Retry Behavior.Retries On 503 ✅ 5411ms
Retry Behavior.Does Not Retry On 400 ✅ 2110ms
Retry Behavior.Does Not Retry On 401 ✅ 2110ms
Retry Behavior.Respects Retry After Header ✅ 8016ms
Retry Behavior.Implements Backoff ✅ 15723ms
Retry Behavior.Retries On 500 ✅ 5214ms
Retry Behavior.Retries On 502 ✅ 5213ms
Retry Behavior.Retries On 504 ✅ 5213ms
Retry Behavior.Max Retries Respected ✅ 15523ms
Deduplication.Generates Unique Uuids ✅ 112ms
Deduplication.Preserves Uuid On Retry ✅ 5212ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10317ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5214ms
Deduplication.No Duplicate Events In Batch ✅ 112ms
Deduplication.Different Events Have Different Uuids ✅ 108ms
Compression.Sends Gzip When Enabled ✅ 107ms
Batch Format.Uses Proper Batch Structure ✅ 106ms
Batch Format.Flush With No Events Sends Nothing ✅ 4ms
Batch Format.Multiple Events Batched Together ✅ 113ms
Error Handling.Does Not Retry On 403 ✅ 2109ms
Error Handling.Does Not Retry On 413 ✅ 2109ms
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 ✅ 109ms
Request Payload.Flags Request Uses V2 Query Param ✅ 107ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 108ms
Request Payload.Flags Request Omits Authorization Header ✅ 107ms
Request Payload.Token In Flags Body Matches Init ✅ 108ms
Request Payload.Groups Round Trip ✅ 108ms
Request Payload.Groups Default To Empty Object ✅ 107ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 108ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 109ms
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 ✅ 111ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 106ms
Retry Behavior.Retries Flags On 502 ✅ 210ms
Retry Behavior.Retries Flags On 504 ✅ 247ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 111ms

@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 f25d417: 1 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/client.rb Resolved
@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 e5b5af6: 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 can't auto-approve this pull request because the deny-list gate matched the public API surface: public_api_snapshot.txt changed, and the change adds request_meta: and client_name: to capture_tool_call. Because of that match, the tier gate also placed the PR in the never-auto-approve tier. The size gate passed, so size isn't the issue.

Please ask a human reviewer to look at it. Since public API changes always need that review, no change to the diff will alter this outcome.

  • 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 ✓ 39L, 2F substantive, 115L/5F 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 e5b5af6

@stamphog stamphog Bot removed the stamphog label Nov 25, 2026
@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.9 µs/op 113.85 µs/op <0.1% less time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Idle process memory (RSS) 28.4 MiB 28.42 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 31.42 MiB 31.44 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Managed heap after settling 5.3 MiB 5.3 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 30.65 MiB 30.68 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process CPU time per operation 30.24 µs/op 30.05 µs/op 0.6% less time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 31.14 MiB 31.16 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 113.61 µs/op 113.69 µs/op <0.1% more time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Idle process memory (RSS) 33.26 MiB 33.22 MiB 0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 41.9 MiB 41.86 MiB <0.1% 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.34 MiB 39.21 MiB 0.3% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process CPU time per operation 41.68 µs/op 42.11 µs/op 1% more time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 41.63 MiB 41.69 MiB 0.2% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Allocations per operation 58.68 count/op 58.68 count/op 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% less time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Idle process memory (RSS) 28.34 MiB 28.34 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 30.48 MiB 30.54 MiB 0.2% 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.48 MiB 30.54 MiB 0.2% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process CPU time per operation 42.98 µs/op 41.92 µs/op 2.5% less time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 30.48 MiB 30.54 MiB 0.2% 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.02 ms/op 1.02 ms/op <0.1% less time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Idle process memory (RSS) 33.27 MiB 33.25 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 41 MiB 41.19 MiB 0.5% 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% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 40.15 MiB 40.12 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process CPU time per operation 47.4 µs/op 46.59 µs/op 1.7% less time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 41.17 MiB 41.17 MiB No observed change Not flagged
Queue an event (32-byte payload)
Shard: capture
Caller-thread CPU time per operation 13.55 µs/op 13.94 µs/op 2.9% more time Not flagged
Queue an event (32-byte payload)
Shard: capture
Time per operation 13.55 µs/op 13.94 µs/op 2.9% more time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Caller-thread CPU time per operation 13.84 µs/op 13.96 µs/op 0.8% more time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Time per operation 13.84 µs/op 13.95 µs/op 0.8% more 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 95.66 µs/op 94.85 µs/op 0.9% less time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Process CPU time per operation 95.62 µs/op 94.85 µs/op 0.8% less time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Allocations per operation 3,324 count/op 3,323.94 count/op <0.1% fewer Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Time per operation 914.8 µs/op 909.87 µs/op 0.5% less time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Process CPU time per operation 914.74 µs/op 909.83 µs/op 0.5% less time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Allocations per operation 33,113.56 count/op 33,113.56 count/op No observed change Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Time per operation 9.18 ms/op 9.2 ms/op 0.2% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Process CPU time per operation 9.18 ms/op 9.2 ms/op 0.2% more time Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Idle process memory (RSS) 39.19 MiB 39.16 MiB <0.1% less memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Observed peak process memory (RSS) 40.49 MiB 40.47 MiB <0.1% less memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Managed heap after settling 8 MiB 8 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Process memory after settling (RSS) 39.6 MiB 39.57 MiB <0.1% less memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Lifetime peak process memory (RSS) 40.12 MiB 40.14 MiB <0.1% more memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Idle process memory (RSS) 38.15 MiB 38.11 MiB 0.1% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Observed peak process memory (RSS) 38.92 MiB 38.78 MiB 0.4% less 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) 38.92 MiB 38.78 MiB 0.4% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Lifetime peak process memory (RSS) 38.92 MiB 38.78 MiB 0.4% 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.83 µs/op 7.82 µs/op 0.2% less time Not flagged
Evaluate one boolean flag
Shard: flags-single
Process CPU time per operation 7.83 µs/op 7.82 µs/op 0.2% 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.81 µs/op 10.78 µs/op 0.3% less time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Process CPU time per operation 10.81 µs/op 10.78 µs/op 0.3% less 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.98 µs/op 13.94 µs/op 0.3% less time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Process CPU time per operation 13.98 µs/op 13.94 µs/op 0.3% less 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.76 µs/op 0.3% more time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Process CPU time per operation 19.7 µs/op 19.76 µs/op 0.3% more 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.76 µs/op 17.8 µs/op 0.2% more time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Process CPU time per operation 17.76 µs/op 17.8 µs/op 0.2% 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.17 µs/op 8.14 µs/op 0.3% less time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Process CPU time per operation 8.17 µs/op 8.14 µs/op 0.3% less 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.11 µs/op 23.13 µs/op <0.1% more time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Process CPU time per operation 23.11 µs/op 23.12 µ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.04 µs/op 7.07 µs/op 0.4% more time Not flagged
Evaluate a rollout flag
Shard: flags-single
Process CPU time per operation 7.04 µs/op 7.06 µs/op 0.4% 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.83 µs/op 8.81 µs/op 0.2% less time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Process CPU time per operation 8.83 µs/op 8.81 µs/op 0.2% less 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 2cea45dc80711f024bcc1b37c6e48833194e6e56 → 42aa5e87d3fd954219be29293f8683e95e035f1a.

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.

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

Note

🤖 Automated comment by QA Swarm — not written by a human

QA Swarm review complete. See inline comments and the summary comment.

Comment thread lib/posthog/mcp/client.rb Resolved
Comment thread lib/posthog/mcp/client.rb Resolved
Comment thread lib/posthog/mcp/client.rb Resolved
Comment thread lib/posthog/mcp/client.rb Resolved
Comment thread spec/posthog/mcp/client_spec.rb Resolved
@posthog

posthog Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Note

🤖 Automated comment by QA Swarm — not written by a human

Multi-perspective review: router (cheap-first pass) + delegated lenses (qa-team, paul-reviewer, xp-reviewer, security-audit, engineering-systems-thinking as warranted)

Verdict: 💬 APPROVE WITH NITS (round 1 @ e5b5af6)

The session and $mcp_session_source logic matches the spec. One robustness gap remains: a malformed _meta conversation value can still raise out of capture_tool_call into the host.

Key findings

  • 🟡 MEDIUM lib/posthog/mcp/client.rb:53: ClientConversation.read runs outside the Sink's rescue. The new valid_encoding? guard covers only the User-Agent and client name, so a _meta value with invalid UTF-8 bytes can raise ArgumentError from downcase / match?.
  • 🟢 LOW client.rb:59: capture_tool_call now sends $mcp_client_name. Not in the changeset and not asserted by a spec.
  • 🟢 LOW client.rb:55: only the client conversation id overrides the caller's session_id; a conversation handle does not. Confirm this scope-out is intentional.
  • ⚪ NIT: parameters: on capture_missing_capability is now silently ignored; tests miss the $exception sibling event session and the non-String / empty session_id fallback.

Convergence

None (only the router ran).

Reviewer summaries

Reviewer Assessment
🧭 router Small, spec-aligned change with table-driven tests. Danger LOW, confidence HIGH. No delegation (115 changed lines, no auth, billing, migration or concurrency).

Automated by QA Swarm — not a human review

@lucasheriques

Copy link
Copy Markdown
Contributor Author

@PostHog review

@lucasheriques

Copy link
Copy Markdown
Contributor Author

@PostHog review

@posthog

posthog Bot commented Nov 29, 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 3d68e96: no findings.

@lucasheriques

Copy link
Copy Markdown
Contributor Author

@PostHog review

@posthog

posthog Bot commented Nov 30, 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 0ef302d: 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 can't auto-approve this pull request. The deny-list gate refused it because public_api_snapshot.txt matched the public_api category, and the tier gate then put it in T2-never as a result. The change touches the public API surface: capture_tool_call gains new request_meta: and client_name: keywords.

The size gate passed, so splitting isn't needed. The next step is to ask a human reviewer to look at it and merge it if they agree.

  • 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 ✓ 39L, 2F substantive, 142L/5F 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 0ef302d

@stamphog stamphog Bot removed the stamphog label Nov 30, 2026
…versation ids

sdk-specs "Manual capture", lower-level method: a $session_id the caller
passes is sent unchanged unless a client conversation id applies; without
one, each call gets a fresh ses_<UUIDv7>. A client conversation id applies
when the caller passes the request's `_meta` with the User-Agent or client
name that recognizes its client.

- PostHog::MCP::Client's capture_* methods fill a missing session with a
  fresh generated one (so distinct_id falls back to it, not "anonymous")
  and set $mcp_session_source.
- capture_tool_call takes request_meta: and client_name:.

The three-step manual API (list, call, result) the spec also asks for is
not in this PR: it is a new public API and needs its own design.

Tested: bundle exec rspec (2652 examples, 0 failures; 12 new client_spec
examples failed first), rubocop clean, rake public_api:check passes with
the regenerated snapshot.
…ases

/simplify on the stack: base_event chooses the session and its source in
one place, and the VS Code client-name case joins the parameterized
recognition table.

Tested: bundle exec rspec spec/posthog/mcp (280 examples, 0 failures).
…ability

Pre-PR gate: sdk-specs "Optional events" says the report events never
carry $mcp_parameters; the automatic path already dropped them. The
keyword stays accepted, so existing callers keep working.

Tested: bundle exec rspec (no failures; the new client_spec expectation
failed first), rubocop clean, rake public_api:check passes.
…its encoding

PostHog Review on f25d417: ClientConversation.recognize raised
ArgumentError from Regexp#match? on a User-Agent with invalid UTF-8, and
the manual capture_tool_call calls it outside the sink's rescue, so the
error reached the host's dispatcher. Such a value now recognizes no client.

Tested: bundle exec rspec spec/posthog/mcp (283 examples, 0 failures; the
new client_spec example failed without the fix).
…ient name property

What: specs for an empty or non-String session_id, the $exception sibling's session, and $mcp_client_name; the changeset now says capture_tool_call sends the client name.
Why: QA Swarm flagged these as untested or unmentioned behavior.
Tested: spec/posthog/mcp/client_spec.rb 36 examples 0 failures; rubocop clean.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants