adding-personhog-rpc

Guides adding new gRPC endpoints to personhog-replica and personhog-router services.

713|118|Updated Aug 11, 2020
One-click install
npx skills add https://github.com/PostHog/posthog-foss --skill adding-personhog-rpc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adding-personhog-rpc
Source: https://github.com/PostHog/posthog-foss/tree/main/.agents/skills/adding-personhog-rpc
Command: npx skills add https://github.com/PostHog/posthog-foss --skill adding-personhog-rpc

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Adding a new RPC to PostHog's personhog service spans proto definitions, Python and Node.js client generation, and Rust implementation across replica and router crates, and missing any step breaks the build or routing.

Core Features & Use Cases

  • Eligibility and index validation: Checks whether the target table belongs in personhog and whether the query matches an existing index before any code is written.
  • End-to-end implementation workflow: Walks through proto message and service definitions, client stub generation for Python and Node.js, and Rust storage, service, and router layers.
  • Idempotency enforcement: Requires leader-path RPCs to be safe under at-least-once delivery via convergent operations or explicit operation identity.
  • Use Case: When migrating a Django ORM query on posthog_person to personhog, follow the checklist to define the proto, generate clients, implement the Rust handler, and verify with cargo build and test.

Quick Start

Use the adding-personhog-rpc skill to add a new GetPersonCount RPC to the personhog service end to end.

Frequently Asked Questions about adding-personhog-rpc

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new RPC to the personhog service?

Define proto messages in types/v1, add the RPC to both service.proto and replica.proto with identical signatures, generate Python and Node.js stubs, then implement the Rust storage trait, service handler, and router wiring. Finish by running cargo build and cargo test for all three crates.

Which database tables can a personhog RPC access?

Personhog serves posthog_person, posthog_persondistinctid, posthog_group, posthog_grouptypemapping, posthog_cohortpeople, posthog_featureflaghashkeyoverride, posthog_personoverride, and posthog_personlessdistinctid. Data outside these tables should not go through personhog.

Does every personhog query need to use a database index?

Yes, every query must be an index scan, never a sequential scan. Validate your WHERE clause against the documented indexes before designing the RPC, and request a new migration in rust/persons_migrations if no existing index fits.

Why must leader RPCs be idempotent in personhog?

Leader-path requests can be delivered more than once due to client retries and router replays. Each leader RPC must converge under redelivery, such as read-only lookups or re-appliable merges, or carry explicit operation identity to detect duplicates.

How is read consistency handled for personhog RPCs?

Read requests include a ReadOptions field with a ConsistencyLevel enum. EVENTUAL queries the replica pool while STRONG queries the primary pool, which only applies to PersonData reads since NonPersonData always routes to the replica.