Summary
The project's stated purpose (README: "Real-time payment analytics for Stellar... measuring and improving cross-border payment reliability") requires computing reliability and latency-percentile metrics (P50/P95/P99-class statistics) over a stream of ledger-close events that can arrive out of order and on a different clock than wall time — but no such computation exists anywhere in the codebase. There is substantial infrastructure for ingesting, indexing, reconciling, and serving contract/event data (event_indexer, reconciliation, realtime, contract_ops), but the actual core analytics computation the whole system exists to support is missing.
Location
None yet — this is a request to build a new component. Closest related existing code: backend/src/event_indexer/ (ingestion), backend/src/reconciliation/compare.rs (which already depends on the concept of a "period" being reconcilable — i.e. finalized — which is exactly the watermarking problem below), backend/src/observability/metrics.rs (currently a 5-line stub).
Current gap / Motivation
grep -rln "reliability\|percentile\|watermark" backend/src returns nothing. There is no module computing the payment-reliability or latency statistics the product is named for. This isn't a missing test or a missing edge case in an existing function — it's a missing core subsystem, and it happens to be one of the genuinely hard problems in streaming systems engineering.
The hard part
- Streaming, mergeable percentile estimation at scale. Exact percentiles require sorting the full dataset, which doesn't scale to a continuously-arriving, unbounded stream. A correct implementation needs a mergeable summary structure (e.g. t-digest, HDR histogram, or a KLL sketch) with a proven, bounded error on P50/P95/P99 estimates — and the error bound needs to be understood and documented, not just "close enough in testing." The structure also needs to be mergeable across time windows and across parallel ingestion shards without re-processing raw data, since re-scanning the full event history on every query is not viable at any real scale.
- Out-of-order event handling with a real watermarking strategy. Stellar ledger-close events can arrive at the indexer out of ledger-close order (RPC/Horizon replication lag, retries, multi-source ingestion). A percentile computation keyed by time window must decide, for each window, when it is safe to consider "final" (a watermark) versus when late-arriving events must still be admitted and the window's stats retroactively corrected — and it must do this without either (a) waiting so long that "real-time" stops being true, or (b) finalizing prematurely and silently under/over-counting reliability incidents that arrived a few seconds late.
- Two clocks, one truth. Stellar ledger close time and wall-clock ingestion time diverge under network conditions, indexer backpressure, and ledger production irregularities. "Latency" for a cross-border payment has to be defined precisely — latency of what, measured against which clock, and how do the two get reconciled when they disagree — before any percentile of it means anything. This needs an explicit, documented decision, because getting it wrong doesn't fail loudly; it just produces plausible-looking, wrong numbers.
- Consistency with the reconciliation subsystem's notion of "finalized."
reconciliation/compare.rs already operates on the concept of "reconcilable periods" — implying some existing notion of when a period's data is considered complete enough to reconcile. Whatever watermarking strategy this new component adopts needs to either reuse that notion or have an explicit, justified reason for a different one; two different, disagreeing definitions of "this time window is final" in the same system is a correctness bug waiting to happen.
- Backpressure-safe under ingestion bursts. A ledger backlog replay (e.g. after indexer downtime) can produce a burst of events far exceeding steady-state rate. The percentile/reliability computation must not fall over, produce garbage intermediate results, or block the real-time path when this happens — it needs a defined degraded-mode behavior that's still correct, even if delayed.
Implementation
This is intentionally not prescriptive beyond the constraints above — the right sketch structure, windowing strategy, and clock-reconciliation policy are real design decisions with tradeoffs that should be argued for, not assumed. At minimum, a complete solution needs to:
- Choose and justify a mergeable percentile sketch with documented, bounded error characteristics.
- Define the watermarking policy precisely (how long a window stays open, how late data is handled once it closes) and reconcile it with
reconciliation's existing period-finality concept.
- Define latency's clock basis precisely and document the tradeoff.
- Demonstrate correctness under out-of-order arrival, including a worst-case reordering/lateness scenario, with a test proving the computed percentiles converge to within the sketch's documented error bound of the true values.
- Demonstrate the system doesn't degrade correctness (only, at worst, timeliness) under a simulated ingestion burst.
Acceptance criteria
Out of scope
The frontend visualization of these metrics; this issue is specifically about the correctness of the underlying computation.
Summary
The project's stated purpose (README: "Real-time payment analytics for Stellar... measuring and improving cross-border payment reliability") requires computing reliability and latency-percentile metrics (P50/P95/P99-class statistics) over a stream of ledger-close events that can arrive out of order and on a different clock than wall time — but no such computation exists anywhere in the codebase. There is substantial infrastructure for ingesting, indexing, reconciling, and serving contract/event data (
event_indexer,reconciliation,realtime,contract_ops), but the actual core analytics computation the whole system exists to support is missing.Location
None yet — this is a request to build a new component. Closest related existing code:
backend/src/event_indexer/(ingestion),backend/src/reconciliation/compare.rs(which already depends on the concept of a "period" being reconcilable — i.e. finalized — which is exactly the watermarking problem below),backend/src/observability/metrics.rs(currently a 5-line stub).Current gap / Motivation
grep -rln "reliability\|percentile\|watermark" backend/srcreturns nothing. There is no module computing the payment-reliability or latency statistics the product is named for. This isn't a missing test or a missing edge case in an existing function — it's a missing core subsystem, and it happens to be one of the genuinely hard problems in streaming systems engineering.The hard part
reconciliation/compare.rsalready operates on the concept of "reconcilable periods" — implying some existing notion of when a period's data is considered complete enough to reconcile. Whatever watermarking strategy this new component adopts needs to either reuse that notion or have an explicit, justified reason for a different one; two different, disagreeing definitions of "this time window is final" in the same system is a correctness bug waiting to happen.Implementation
This is intentionally not prescriptive beyond the constraints above — the right sketch structure, windowing strategy, and clock-reconciliation policy are real design decisions with tradeoffs that should be argued for, not assumed. At minimum, a complete solution needs to:
reconciliation's existing period-finality concept.Acceptance criteria
reconciliation's period-finality concept are shown to agree, or the deliberate difference is documented with rationale.cargo testsuite stays green.Out of scope
The frontend visualization of these metrics; this issue is specifically about the correctness of the underlying computation.