用途:这是 PostHog 摄入管道(ingestion pipeline)框架的快速参考与约定检查工具,适合在需要了解管道结构或确认该用哪个 Doctor 代理时使用。
架构:事件经类型化、可组合的步骤链处理,顺序大致为 Kafka message → messageAware()(解析头与正文)→ sequentially() 预处理 → filterMap() 补充上下文(如 team 查询)→ teamAware() → groupBy(token:distinctId) → concurrently() 按实体处理 → gather() → pipeBatch() 批处理 → handleIngestionWarnings() → handleResults(),之后 handleSideEffects() 和 build()。真实实现见 nodejs/src/ingestion/analytics/joined-ingestion-pipeline.ts。
关键位置:步骤类型在 nodejs/src/ingestion/pipelines/steps.ts,结果类型在 results.ts,文档测试章节在 docs/*.test.ts,Doctor 代理在 .claude/agents/ingestion/,测试辅助在 docs/helpers.ts。
代理选择:步骤结构用 pipeline-step-doctor;结果处理用 pipeline-result-doctor;组合用 pipeline-composition-doctor;测试用 pipeline-testing-doctor。
约定要点:步骤为返回具名内层函数的工厂函数,用泛型 <T extends Input> 扩展类型,不用 any,配置通过闭包传入。结果使用 ok()、dlq()、drop()、redirect() 构造器,副作用作为 Promise 传入 ok(value, [effects]),警告作为第三参数。组合上 messageAware 包裹管道,handleResults 放在 messageAware 内,handleSideEffects 在其后,按实体工作用 groupBy + concurrently,批处理前先 gather。测试中步骤测试直接调用工厂,使用 consumeAll()/collectBatches() 辅助,异步用假定时器,结果断言用类型守卫,不用 any。可让 Claude 对最近改动运行全部四个管道 Doctor 进行综合审查。
限制:资料仅提供架构与约定说明,未给出完整代码示例、安装命令或具体运行依赖要求。