:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(personhog): seed and show config/changelog (#119808)
Zach Brown72935687e918
diff --git a/rust/common/assignment-coordination/src/store.rs b/rust/common/assignment-coordination/src/store.rsindex 9b1e4a33f77f..569be9056096 100644--- a/rust/common/assignment-coordination/src/store.rs+++ b/rust/common/assignment-coordination/src/store.rs@@ -98,7 +98,7 @@ impl EtcdStore {Ok(Self { client, config })}- #[cfg(test)]+ /// Shares an existing client's channel instead of opening another.pub fn from_client(client: Client, config: StoreConfig) -> Self {Self { client, config }}diff --git a/rust/ingestion-control-plane/README.md b/rust/ingestion-control-plane/README.mdindex 3e1ba3300402..a45997e395d8 100644--- a/rust/ingestion-control-plane/README.md+++ b/rust/ingestion-control-plane/README.md@@ -23,7 +23,7 @@ Lists live ingestion-consumer pods and serves the consumer's routing debug UI pe### Personhog topology-Protocol-aware view of personhog's etcd coordination state (`PERSONHOG_ETCD_PREFIX`, default `/personhog/`): the whole prefix is read in one consistent snapshot and interpreted with the `personhog-coordination` types and the coordinator's own pure predicates, so the derived diagnostics cannot drift from the protocol. Shows the elected coordinator, registered pods and routers (with remaining lease TTLs), per-partition ownership, and in-flight handoffs with their phase age and what each is waiting on — distinguishing a stuck participant ("waiting on freeze acks from router-2") from a stuck coordinator ("quorum met; waiting on the coordinator to advance"). Derived issues cover stuck handoffs past their per-phase deadline, assignments owned by unregistered pods with no replanning handoff, lingering `Complete` records the coordinator hasn't cleaned up, dead new owners awaiting cancellation, unassigned partitions, stale acks from previous handoff attempts, and unparseable records. The deadline knobs (`PERSONHOG_HANDOFF_DEADLINE_SECS`, `PERSONHOG_WARMING_DEADLINE_SECS`) must match the coordinator's to agree with its cancellation decisions. Read-only: the tool never writes coordination state, and a force-reassignment must go through a handoff record, never a raw assignment write.+Protocol-aware view of personhog's etcd coordination state (`PERSONHOG_ETCD_PREFIX`, default `/personhog/`): the whole prefix is read in one consistent snapshot and interpreted with the `personhog-coordination` types and the coordinator's own pure predicates, so the derived diagnostics cannot drift from the protocol. Shows the elected coordinator, registered pods and routers (with remaining lease TTLs), per-partition ownership, and in-flight handoffs with their phase age and what each is waiting on — distinguishing a stuck participant ("waiting on freeze acks from router-2") from a stuck coordinator ("quorum met; waiting on the coordinator to advance"). Derived issues cover stuck handoffs past their per-phase deadline, assignments owned by unregistered pods with no replanning handoff, lingering `Complete` records the coordinator hasn't cleaned up, dead new owners awaiting cancellation, unassigned partitions, stale acks from previous handoff attempts, and unparseable records. The deadline knobs (`PERSONHOG_HANDOFF_DEADLINE_SECS`, `PERSONHOG_WARMING_DEADLINE_SECS`) must match the coordinator's to agree with its cancellation decisions. The tool writes no coordination state except seeding `config/changelog`, and a force-reassignment must go through a handoff record, never a raw assignment write.### Personhog parity@@ -64,6 +64,8 @@ Both etcd tools are disabled (their APIs return 503) unless `ETCD_ENDPOINTS` is| `ETCD_ENDPOINTS` | empty | Comma-separated etcd endpoints; empty disables the etcd explorer and personhog topology tools || `ETCD_ALLOWED_PREFIXES` | `/` | Comma-separated key prefixes the etcd explorer may read and write || `PERSONHOG_ETCD_PREFIX` | `/personhog/` | Prefix the personhog coordination state lives under; must match the personhog services' `ETCD_PREFIX` |+| `PERSONHOG_KAFKA_HOSTS` | `KAFKA_HOSTS` | Cluster the personhog changelog lives on, for the changelog panel |+| `PERSONHOG_KAFKA_TLS` | `KAFKA_TLS` | TLS for `PERSONHOG_KAFKA_HOSTS` || `PERSONHOG_HANDOFF_DEADLINE_SECS` | `120` | Per-phase deadline for flagging stuck handoffs; must match `COORDINATOR_HANDOFF_DEADLINE_SECS` || `PERSONHOG_WARMING_DEADLINE_SECS` | `1800` | Warming-phase deadline; must match `COORDINATOR_WARMING_DEADLINE_SECS` |diff --git a/rust/ingestion-control-plane/src/api.rs b/rust/ingestion-control-plane/src/api.rsindex cff55de0d597..341c4f7553cc 100644--- a/rust/ingestion-control-plane/src/api.rs+++ b/rust/ingestion-control-plane/src/api.rs@@ -6,14 +6,16 @@ use anyhow::Context;use axum::extract::{Path, Query, State};use axum::http::StatusCode;use axum::response::{IntoResponse, Response};-use axum::routing::get;+use axum::routing::{get, post};use axum::{Json, Router};+use personhog_coordination::types::ChangelogConfig;use serde::{Deserialize, Serialize};use serde_json::json;use uuid::Uuid;use k8s_awareness::DiscoveredPod;+use crate::changelog;use crate::etcd;use crate::jobs::{AnalysisRequest, JobView};use crate::kafka::browse::{self, BrowseParams, BrowseStop, MessageFilter, MessageRecord};@@ -431,6 +433,44 @@ async fn personhog_topology(Ok(Json(view))}+async fn personhog_changelog(+ State(state): State<AppState>,+) -> Result<Json<changelog::ChangelogView>, ApiError> {+ let client = etcd_client(&state).await?;+ let view = changelog::view(&state.config, &client, &state.config.personhog_etcd_prefix)+ .await+ .map_err(|e| ApiError::upstream(format!("changelog view failed: {e:#}")))?;+ Ok(Json(view))+}++#[derive(Deserialize)]+struct SeedChangelogRequest {+ topic: String,+ /// The writer's consumer group, as its `KAFKA_CONSUMER_GROUP` names it.+ writer_group: String,+}++async fn personhog_seed_changelog(+ State(state): State<AppState>,+ Json(request): Json<SeedChangelogRequest>,+) -> Result<Json<ChangelogConfig>, ApiError> {+ let prefix = state.config.personhog_etcd_prefix.clone();+ validated_etcd_key(&state, &prefix)?;+ let topic = request.topic.trim();+ if topic.is_empty() {+ return Err(ApiError::bad_request("topic must not be empty"));+ }+ let writer_group = request.writer_group.trim();+ if writer_group.is_empty() {+ return Err(ApiError::bad_request("writer_group must not be empty"));+ }+ let client = etcd_client(&state).await?;+ let seeded = changelog::seed(&state.config, &client, &prefix, topic, writer_group)+ .await+ .map_err(|e| ApiError::bad_request(format!("seed failed: {e:#}")))?;+ Ok(Json(seeded))+}+#[derive(Serialize)]struct PodsResponse {pods: Vec<DiscoveredPod>,@@ -464,6 +504,11 @@ pub fn router(state: AppState) -> Router {).route("/api/personhog/topology", get(personhog_topology)).route("/api/personhog/parity/mismatches", get(parity::mismatches))+ .route("/api/personhog/changelog", get(personhog_changelog))+ .route(+ "/api/personhog/changelog/seed",+ post(personhog_seed_changelog),+ )// The consumer debug UI is served per pod; its relative `debug/...`// fetches resolve to the proxy route below. Pods are addressed by// namespace + name so identical names across lanes cannot collide.diff --git a/rust/ingestion-control-plane/src/changelog.rs b/rust/ingestion-control-plane/src/changelog.rsnew file mode 100644index 000000000000..7ed962059913--- /dev/null+++ b/rust/ingestion-control-plane/src/changelog.rs@@ -0,0 +1,126 @@+use std::time::Duration;++use anyhow::{bail, Context};+use assignment_coordination::store::{EtcdStore, StoreConfig};+use etcd_client::Client;+use personhog_coordination::store::PersonhogStore;+use personhog_coordination::types::ChangelogConfig;+use rdkafka::consumer::Consumer;+use serde::Serialize;++use crate::config::Config;+use crate::kafka::client::metadata_consumer;+use crate::kafka::lag::{scan_group_lag, ConsumerTarget};++fn store(client: &Client, prefix: &str) -> PersonhogStore {+ PersonhogStore::new(EtcdStore::from_client(+ client.clone(),+ StoreConfig {+ endpoints: Vec::new(),+ prefix: prefix.to_string(),+ },+ ))+}++pub async fn topic_partition_count(config: &Config, topic: &str) -> anyhow::Result<u32> {+ let timeout = Duration::from_millis(config.kafka_metadata_timeout_ms);+ let config = config.clone();+ let topic = topic.to_string();+ tokio::task::spawn_blocking(move || {+ let consumer = metadata_consumer(&config).context("create metadata client")?;+ let metadata = consumer+ .fetch_metadata(Some(&topic), timeout)+ .with_context(|| format!("fetch metadata for {topic}"))?;+ let topic_metadata = metadata+ .topics()+ .iter()+ .find(|t| t.name() == topic)+ .with_context(|| format!("topic {topic} is absent from broker metadata"))?;+ if let Some(error) = topic_metadata.error() {+ bail!("topic {topic}: {error:?}");+ }+ let count = topic_metadata.partitions().len();+ if count == 0 {+ bail!("topic {topic} has no partitions");+ }+ Ok(count as u32)+ })+ .await+ .context("metadata task panicked")?+}++pub async fn seed(+ config: &Config,+ client: &Client,+ prefix: &str,+ topic: &str,+ writer_group: &str,+) -> anyhow::Result<ChangelogConfig> {+ let config = &config.personhog_kafka();+ let partitions = topic_partition_count(config, topic).await?;+ let created = store(client, prefix)+ .seed_changelog_config(topic, partitions, writer_group)+ .await?;+ if !created {+ bail!("config/changelog is already seeded");+ }+ Ok(ChangelogConfig {+ writer_group: writer_group.to_string(),+ ..ChangelogConfig::new(topic, partitions)+ })+}++#[derive(Serialize)]+pub struct GroupLag {+ pub group: String,+ pub partitions: usize,+ pub lagging_partitions: usize,+ pub total_lag: i64,+ pub max_partition_lag: i64,+ pub error: Option<String>,+}++#[derive(Serialize)]+pub struct ChangelogView {+ pub config: Option<ChangelogConfig>,+ pub writer: Option<GroupLag>,+}++pub async fn view(config: &Config, client: &Client, prefix: &str) -> anyhow::Result<ChangelogView> {+ let config = &config.personhog_kafka();+ let store = store(client, prefix);+ let changelog = store.get_changelog_config().await?;+ let writer = match &changelog {+ Some(changelog) => Some(group_lag(config, &changelog.writer_group, &changelog.topic).await),+ None => None,+ };+ Ok(ChangelogView {+ config: changelog,+ writer,+ })+}++async fn group_lag(config: &Config, group: &str, topic: &str) -> GroupLag {+ let target = ConsumerTarget {+ group: group.to_string(),+ topic: topic.to_string(),+ };+ match scan_group_lag(config, &target).await {+ Ok(lag) => GroupLag {+ group: group.to_string(),+ partitions: lag.partitions.len(),+ lagging_partitions: lag.partitions.iter().filter(|p| p.lag > 0).count(),+ total_lag: lag.partitions.iter().map(|p| p.lag).sum(),+ max_partition_lag: lag.partitions.iter().map(|p| p.lag).max().unwrap_or(0),+ error: None,+ },+ Err(e) => GroupLag {+ group: group.to_string(),+ partitions: 0,+ lagging_partitions: 0,+ total_lag: 0,+ max_partition_lag: 0,+ error: Some(format!("{e:#}")),+ },+ }+}diff --git a/rust/ingestion-control-plane/src/config.rs b/rust/ingestion-control-plane/src/config.rsindex 74916b38dc87..a1d89ec7527c 100644--- a/rust/ingestion-control-plane/src/config.rs+++ b/rust/ingestion-control-plane/src/config.rs@@ -165,6 +165,14 @@ pub struct Config {#[envconfig(from = "PERSONHOG_ETCD_PREFIX", default = "/personhog/")]pub personhog_etcd_prefix: String,+ /// The personhog changelog's Kafka cluster; unset means `KAFKA_HOSTS`.+ #[envconfig(from = "PERSONHOG_KAFKA_HOSTS")]+ pub personhog_kafka_hosts: Option<String>,++ /// TLS for `PERSONHOG_KAFKA_HOSTS`; unset means `KAFKA_TLS`.+ #[envconfig(from = "PERSONHOG_KAFKA_TLS")]+ pub personhog_kafka_tls: Option<bool>,+/// Per-phase handoff deadline used to flag stuck handoffs; must match/// the coordinator's `COORDINATOR_HANDOFF_DEADLINE_SECS` to agree with/// its cancellation decisions.@@ -181,6 +189,22 @@ impl Config {Self::init_from_env()}+ /// This config pointed at the personhog changelog's Kafka cluster.+ pub fn personhog_kafka(&self) -> Config {+ let mut config = self.clone();+ if let Some(hosts) = self+ .personhog_kafka_hosts+ .as_ref()+ .filter(|h| !h.is_empty())+ {+ config.kafka_hosts = hosts.clone();+ }+ if let Some(tls) = self.personhog_kafka_tls {+ config.kafka_tls = tls;+ }+ config+ }+pub fn etcd_endpoint_list(&self) -> Vec<String> {self.etcd_endpoints.split(',')@@ -245,6 +269,26 @@ pub struct PodTarget {mod tests {use super::*;+ #[test]+ fn the_personhog_cluster_overrides_only_what_is_set() {+ let mut config = Config::init_with_defaults().expect("config defaults are valid");+ config.kafka_hosts = "main:9092".to_string();+ config.kafka_tls = false;+ let unset = config.personhog_kafka();+ assert_eq!(+ (unset.kafka_hosts.as_str(), unset.kafka_tls),+ ("main:9092", false)+ );++ config.personhog_kafka_hosts = Some("personhog:9094".to_string());+ config.personhog_kafka_tls = Some(true);+ let set = config.personhog_kafka();+ assert_eq!(+ (set.kafka_hosts.as_str(), set.kafka_tls),+ ("personhog:9094", true)+ );+ }+#[test]fn pod_targets_support_namespace_prefix_with_default_fallback() {let mut config = Config::init_with_defaults().expect("config defaults are valid");diff --git a/rust/ingestion-control-plane/src/lib.rs b/rust/ingestion-control-plane/src/lib.rsindex 8473acde5312..a1816528f251 100644--- a/rust/ingestion-control-plane/src/lib.rs+++ b/rust/ingestion-control-plane/src/lib.rs@@ -1,5 +1,6 @@pub mod api;pub mod cache;+pub mod changelog;pub mod config;pub mod etcd;pub mod jobs;diff --git a/rust/ingestion-control-plane/src/personhog.rs b/rust/ingestion-control-plane/src/personhog.rsindex 1208ea7ad7d4..9c4a30de0cdb 100644--- a/rust/ingestion-control-plane/src/personhog.rs+++ b/rust/ingestion-control-plane/src/personhog.rs@@ -12,8 +12,8 @@ use personhog_coordination::protocol::{drain_satisfied, freeze_quorum_met, missing_freeze_ackers, past_phase_deadline, warm_satisfied,};use personhog_coordination::types::{- HandoffPhase, HandoffState, LeaderInfo, PartitionAssignment, PodDrainedAck, PodStatus,- PodWarmedAck, RegisteredPod, RegisteredRouter, RouterFreezeAck,+ ChangelogConfig, HandoffPhase, HandoffState, LeaderInfo, PartitionAssignment, PodDrainedAck,+ PodStatus, PodWarmedAck, RegisteredPod, RegisteredRouter, RouterFreezeAck,};use serde::Serialize;@@ -64,6 +64,7 @@ pub struct RawSnapshot {pub warmed_acks: Vec<PodWarmedAck>,pub leader: Option<(LeaderInfo, i64)>,pub total_partitions: Option<u32>,+ pub changelog: Option<ChangelogConfig>,pub parse_errors: Vec<String>,pub unknown_keys: Vec<String>,pub revision: i64,@@ -135,6 +136,10 @@ pub fn parse_snapshot(kvs: &[RawKv], prefix: &str, revision: i64) -> RawSnapshotSome(count) => snapshot.total_partitions = Some(count),None => errors.push(format!("invalid total_partitions at {}", kv.key)),}+ } else if suffix == "config/changelog" {+ if let Some(changelog) = parse::<ChangelogConfig>(kv, errors) {+ snapshot.changelog = Some(changelog);+ }} else {snapshot.unknown_keys.push(kv.key.clone());}@@ -215,6 +220,7 @@ pub struct TopologyView {pub revision: i64,pub prefix: String,pub total_partitions: Option<u32>,+ pub changelog: Option<ChangelogConfig>,pub leader: Option<LeaderView>,pub pods: Vec<PodView>,pub routers: Vec<RouterView>,@@ -536,6 +542,7 @@ pub fn derive_view(revision: raw.revision,prefix: prefix.to_string(),total_partitions: raw.total_partitions,+ changelog: raw.changelog.clone(),leader: raw.leader.as_ref().map(|(leader, _)| LeaderView {holder: leader.holder.clone(),lease_id: leader.lease_id,diff --git a/rust/ingestion-control-plane/src/ui/index.html b/rust/ingestion-control-plane/src/ui/index.htmlindex 4d4e4cb1827c..fa1679fbdde0 100644--- a/rust/ingestion-control-plane/src/ui/index.html+++ b/rust/ingestion-control-plane/src/ui/index.html@@ -1340,6 +1340,7 @@mount(root) {this.ui = {summary: el("div", { class: "row", style: "padding: 0 0 10px" }),+ changelogBody: el("div", {}, el("div", { class: "empty" }, "Loading…")),issuesBody: el("div", {}, el("div", { class: "empty" }, "Loading…")),partitionsBody: el("div", {}, el("div", { class: "empty" }, "Loading…")),podsBody: el("div", {}, el("div", { class: "empty" }, "Loading…")),@@ -1357,6 +1358,7 @@});root.append(this.ui.summary,+ el("div", { class: "panel" }, el("h2", {}, "Changelog"), this.ui.changelogBody),el("div", { class: "panel" }, el("h2", {}, "Issues"), this.ui.issuesBody),el("div", { class: "panel" }, el("h2", {}, "Partitions"), this.ui.partitionsBody),el("div", { class: "panel" }, el("h2", {}, "Pods"), this.ui.podsBody),@@ -1378,6 +1380,67 @@}if (seq !== this.refreshSeq) return;this.render(data);+ // The lag scan talks to Kafka, so it never blocks the topology render.+ fetchJSON("api/personhog/changelog").then(+ (view) => { if (seq === this.refreshSeq) this.renderChangelog(view); },+ (e) => { if (seq === this.refreshSeq) this.ui.changelogBody.replaceChildren(el("div", { class: "error-box" }, String(e))); });+ },++ renderChangelog(view) {+ if (!view.config) {+ const topicInput = el("input", { type: "text", placeholder: "changelog topic, e.g. personhog_updates_64", style: "width: 360px" });+ const groupInput = el("input", { type: "text", placeholder: "writer consumer group, e.g. personhog-writer", style: "width: 280px" });+ const error = el("div");+ const button = el("button", {}, "Seed config/changelog");+ button.onclick = async () => {+ const topic = topicInput.value.trim();+ const writer_group = groupInput.value.trim();+ if (!topic || !writer_group) {+ error.replaceChildren(el("div", { class: "error-box" }, "Enter the topic and the writer's consumer group."));+ return;+ }+ if (!window.confirm(`Seed config/changelog with topic ${topic}, with writer group ${writer_group}?\n\nThe partition count is read from the topic's metadata.`)) return;+ button.disabled = true;+ try {+ await fetchJSON("api/personhog/changelog/seed", {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({ topic, writer_group }),+ });+ this.refresh();+ } catch (e) {+ error.replaceChildren(el("div", { class: "error-box" }, String(e)));+ } finally {+ button.disabled = false;+ }+ };+ this.ui.changelogBody.replaceChildren(+ el("div", { style: "padding: 6px 14px" },+ el("div", { class: "muted", style: "padding-bottom: 8px" },+ "Not seeded."),+ el("div", { class: "row" }, topicInput, groupInput, button),+ error));+ return;+ }+ const c = view.config;+ this.ui.changelogBody.replaceChildren(+ el("div", { class: "row", style: "padding: 6px 14px" },+ el("span", { class: "pill accent mono" }, c.topic),+ el("span", { class: "pill muted" }, `${fmtInt(c.partitions)} partitions`),+ el("span", { class: "pill muted" }, `epoch ${fmtInt(c.epoch)}`)),+ !view.writer+ ? el("div", { class: "empty" }, "No writer group.")+ : el("table", {},+ el("thead", {}, el("tr", {},+ el("th", {}, "writer group"), el("th", {}, "partitions"), el("th", {}, "lagging"), el("th", {}, "total lag"),+ el("th", {}, "worst partition"))),+ el("tbody", {}, [view.writer].map((g) =>+ el("tr", {},+ el("td", { class: "mono" }, g.group),+ el("td", { class: "mono" }, g.error ? el("span", { class: "pill bad", title: g.error }, "scan failed") : fmtInt(g.partitions)),+ el("td", { class: "mono" }, g.error ? "–" : fmtInt(g.lagging_partitions)),+ el("td", { class: "mono" }, g.error ? "–" : el("span", { class: `pill ${g.total_lag === 0 ? "good" : "warn"}` }, fmtInt(g.total_lag))),+ el("td", { class: "mono" }, g.error ? "–" : fmtInt(g.max_partition_lag)))))));},render(data) {diff --git a/rust/personhog-coordination/src/store.rs b/rust/personhog-coordination/src/store.rsindex d4b978f998fa..ba240882b7f9 100644--- a/rust/personhog-coordination/src/store.rs+++ b/rust/personhog-coordination/src/store.rs@@ -7,9 +7,9 @@ use etcd_client::{Compare, CompareOp, DeleteOptions, PutOptions, Txn, TxnOp, Watuse crate::error::{Error, Result};use crate::types::{- AssignmentPrecondition, AssignmentStatus, HandoffReplacement, HandoffState, LeaderInfo,- PartitionAssignment, PodDrainedAck, PodStatus, PodWarmedAck, RegisteredPod, RegisteredRouter,- RouterFreezeAck,+ AssignmentPrecondition, AssignmentStatus, ChangelogConfig, HandoffReplacement, HandoffState,+ LeaderInfo, PartitionAssignment, PodDrainedAck, PodStatus, PodWarmedAck, RegisteredPod,+ RegisteredRouter, RouterFreezeAck,};/// All etcd key patterns used by the PersonHog store.@@ -40,6 +40,7 @@ enum StoreKey<'a> {Leader,Generation,TotalPartitions,+ ChangelogConfig,}impl StoreKey<'_> {@@ -73,6 +74,7 @@ impl StoreKey<'_> {StoreKey::Leader => format!("{prefix}coordinator/leader"),StoreKey::Generation => format!("{prefix}generation"),StoreKey::TotalPartitions => format!("{prefix}config/total_partitions"),+ StoreKey::ChangelogConfig => format!("{prefix}config/changelog"),}}}@@ -1205,6 +1207,36 @@ impl PersonhogStore {Ok(self.inner.put_raw(&key, count.to_string()).await?)}+ pub async fn get_changelog_config(&self) -> Result<Option<ChangelogConfig>> {+ count_call("get_changelog_config");+ let key = self.key(StoreKey::ChangelogConfig);+ Ok(self.inner.get(&key).await?)+ }++ /// Create-if-absent at epoch 1; only a flip may move a live config.+ pub async fn seed_changelog_config(+ &self,+ topic: &str,+ partitions: u32,+ writer_group: &str,+ ) -> Result<bool> {+ count_call("seed_changelog_config");+ let key = self.key(StoreKey::ChangelogConfig);+ let config = ChangelogConfig {+ writer_group: writer_group.to_string(),+ ..ChangelogConfig::new(topic, partitions)+ };+ let txn = Txn::new()+ .when(vec![Compare::create_revision(+ key.clone(),+ CompareOp::Equal,+ 0,+ )])+ .and_then(vec![TxnOp::put(key, serde_json::to_vec(&config)?, None)]);+ let resp = self.inner.txn(txn).await?;+ Ok(resp.succeeded())+ }+pub async fn get_generation(&self) -> Result<String> {let key = self.key(StoreKey::Generation);let bytes = selfdiff --git a/rust/personhog-coordination/src/types.rs b/rust/personhog-coordination/src/types.rsindex 011c43a17e89..c7e9738ccd48 100644--- a/rust/personhog-coordination/src/types.rs+++ b/rust/personhog-coordination/src/types.rs@@ -304,6 +304,39 @@ pub struct LeaderInfo {pub lease_id: i64,}+/// The live changelog target under `{prefix}config/changelog`.+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]+pub struct ChangelogConfig {+ pub topic: String,+ pub partitions: u32,+ /// Monotonic from 1.+ pub epoch: u64,+ /// The writer's consumer group; a generation retires only once it has read it to the end.+ pub writer_group: String,+ /// Generations some consumer may still be reading.+ pub draining: Vec<Generation>,+}++#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]+pub struct Generation {+ pub topic: String,+ pub partitions: u32,+ pub epoch: u64,+}++impl ChangelogConfig {+ /// A freshly seeded config.+ pub fn new(topic: &str, partitions: u32) -> Self {+ Self {+ topic: topic.to_string(),+ partitions,+ epoch: 1,+ writer_group: String::new(),+ draining: Vec::new(),+ }+ }+}+#[cfg(test)]mod tests {use super::*;diff --git a/rust/personhog-coordination/tests/changelog.rs b/rust/personhog-coordination/tests/changelog.rsnew file mode 100644index 000000000000..48290c4f25c9--- /dev/null+++ b/rust/personhog-coordination/tests/changelog.rs@@ -0,0 +1,26 @@+mod common;++use common::test_store;++#[tokio::test]+async fn a_second_seed_is_refused() {+ let store = test_store("changelog-seed").await;+ assert!(store+ .seed_changelog_config("personhog_updates_64", 64, "personhog-writer")+ .await+ .unwrap());+ assert!(!store+ .seed_changelog_config("personhog_updates_128", 128, "other-writer")+ .await+ .unwrap());+ let config = store.get_changelog_config().await.unwrap().unwrap();+ assert_eq!(+ (+ config.topic.as_str(),+ config.partitions,+ config.epoch,+ config.writer_group.as_str()+ ),+ ("personhog_updates_64", 64, 1, "personhog-writer")+ );+}