# When must an instance reconcile a trace's span clock against its memory-op wall clock before trusting a correlated incident timeline **Date of Record:** 2026 November 20 **Scope:** Applies to single- and multi-agent systems where observability spans (LLM calls, tool invocations) are emitted with monotonic or wall-clock timestamps by one subsystem, while memory operations (episodic writes, distillation, retrieval) are emitted by a separate store with its own clock and its own transaction-commit time. Does not apply when all telemetry shares a single clock domain and a single commit point. ## Core Distinction The failure mode is not "missing telemetry" and not "clock skew" in the trivial NTP sense. It is **correlation-validity**: the assumption that ordering two events by their recorded timestamps reproduces the causal order in which the agent actually observed them. Two clocks are in play. The **span clock** timestamps an event when the agent's execution loop reaches the emission point — typically at call start or call return, in the tracer's process, using a monotonic source. The **memory wall clock** timestamps an event when the memory store *commits* the write, in the store's process, using the store's wall clock. These differ by three structurally distinct offsets: 1. **Emission-to-commit lag** (Δc): the time between the agent deciding to write and the store durably committing. Under write-ahead buffering, batch flush, or replication, Δc is unbounded and load-dependent. 2. **Clock-domain offset** (Δo): store wall clock minus tracer monotonic-derived wall clock. Drift, VM migration, and container suspend/resume make Δo non-constant. 3. **Observation-to-emission lag** (Δe): the agent *observed* the retrieved memory at the moment the tool returned, but the span is emitted at loop iteration boundary. The correlation invariant that must hold: *if span S causally precedes memory-op M, then `t_span(S) + Δe < t_commit(M) − Δc`*. When this is violated, the timeline inverts: a write that the agent actually performed *before* a retrieval appears *after* it, and the incident reconstruction attributes a stale read to a race that never happened. ## What Was Observed An agent performed a three-step cycle repeatedly: `retrieve(query) → reason → write(memory_record)`. During a load spike, the memory store's commit path backed up behind a batch flush (Δc spiked from ~4 ms to ~900 ms). The tracer, unaffected, continued stamping spans at loop boundaries. Post-incident, the correlation engine reconstructed the following apparent sequence for a single cycle: - `t=1042.118` — `memory.retrieve` span emitted, returned record `R_k` - `t=1042.301` — `llm.reason` span emitted - `t=1042.455` — `memory.write` span emitted (agent-side, at decision point) - `t=1043.402` — `memory.commit` event (store-side, wall clock), record `R_k+1` The engine concluded the agent had retrieved `R_k`, reasoned, and written `R_k+1` — a clean, correct-looking sequence. But a *second* `retrieve` in the following cycle at `t=1043.501` returned `R_k` again, not `R_k+1`. The engine flagged this as a **stale-read anomaly** and escalated it as a retrieval-cache bug. The actual sequence: the write of `R_k+1` had been *decided* at `t=1042.455` but not committed until `t=1043.402`. The subsequent retrieve at `t=1043.501` was issued 99 ms after commit — it should have seen `R_k+1`. It did not because the *store's* read path was reading from a replica whose replication lag exceeded 99 ms. The correlation engine had no way to see this, because it never modeled Δc or replica lag; it only saw span timestamps and commit timestamps and assumed span-order = commit-order. The real root cause — replica read lag on the memory store — was invisible in the trace. The reported root cause — retrieval-cache staleness — was a fiction manufactured by the correlation engine's ordering assumption. ## Condition of Validity The naive correlation (sort all events by their recorded timestamp) is valid **only** when all of the following hold simultaneously: - Δe ≤ ε_e, where ε_e is the tracer's emission granularity (loop-boundary granularity, not wall-clock resolution); - Δc ≤ ε_c, where ε_c is small relative to the inter-event spacing you are trying to resolve; - Δo is bounded and known (single clock domain, or a measured offset applied); - the memory store is read-your-writes consistent for the agent's own session, so that a retrieve after a write observes the write. When **any** of these is false, timestamp-sorted correlation is not merely imprecise — it is *structurally invalid* and will produce confident, wrong causal attributions. In particular, the ordering of a `write` span against a subsequent `retrieve` span carries **zero** information about whether the retrieve observed the write, because the write's visibility is governed by commit-and-replicate time, not by span emission time. The correct correlation requires an explicit **happens-before edge** from write to retrieve, sourced not from timestamps but from a *causal token*: the write returns a version/commit-id, the retrieve carries the session's last-seen version, and the store asserts `last_seen_version ≥ required_version`. Absent that token, the two events are **concurrent** in the correlation graph and must not be ordered. ## Decision Boundary The operational rule for the correlation engine: - **If** a causal token (commit-id, version vector, session read-after-write marker) is present on both the write and the subsequent read **and** the store asserts the read saw the required version → order the events by the token, and treat any timestamp disagreement as diagnostic of Δc/Δo, not as a causal signal. - **If** the token is absent → mark the pair `CONCURRENT`, do not emit a stale-read or race finding, and emit a `correlation_undetermined` record instead. An undetermined correlation is honest; a fabricated ordering is not. - **If** Δc for the relevant store window exceeds the smallest inter-event interval the incident query is trying to resolve → the timeline is **not resolvable** at that resolution; the engine must refuse to answer "did the write precede the read" and report the resolution floor. The boundary is therefore not a threshold on skew — it is a threshold on *whether the query's required temporal resolution exceeds the system's commit-lag resolution*. When it does, the query is unanswerable from timestamps alone and must be answered from causal tokens or declared undetermined. ## Operational Effect Without this boundary, the correlation engine systematically mis-attributes replica-lag and commit-lag failures to retrieval-cache bugs and race conditions in agent logic — the two most expensive classes of false-positive incident, because they send engineers to rewrite correct agent code. The agent's own memory-continuity logic is exonerated only if the correlation engine refuses to order concurrent events. With the boundary enforced, a stale-read finding requires a version-token violation, not a timestamp inversion. The class of "phantom races" — write span appears after a read span that actually followed the write's commit — disappears entirely, because the engine no longer orders by span timestamp across clock domains. The guardrail is cheap: attach the write's returned commit-id to the session state, attach the session's last-seen version to every retrieve, and have the memory store return a boolean `read_satisfied_required_version`. The correlation engine then has a ground-truth edge and never needs to infer causality from Δc-contaminated timestamps. ```python from dataclasses import dataclass from typing import Optional class CorrelationOrderingError(RuntimeError): """Raised when a correlation engine attempts to order events that are concurrent under the system's commit-lag resolution floor.""" @dataclass class MemoryEvent: kind: str # "write" | "retrieve" span_ts: float # tracer monotonic-derived, seconds commit_ts: Optional[float] # store wall clock, None for retrieve spans commit_id: Optional[str] # returned by write, carried by retrieve required_version: Optional[str] # retrieve's session last-seen version read_satisfied: Optional[bool] # store assertion for retrieve def order_write_then_read( write: MemoryEvent, read: MemoryEvent, resolution_floor_s: float, ) -> str: """Return 'write_precedes_read', 'concurrent', or 'undetermined'. Never orders by span timestamp across clock domains. Uses causal tokens first; falls back to a resolution-floor check; refuses to guess otherwise. """ if write.kind != "write" or read.kind != "retrieve": raise CorrelationOrderingError( f"expected write/retrieve, got {write.kind}/{read.kind}" ) # Path 1: causal token present on both sides. if write.commit_id is not None and read.required_version is not None: if read.read_satisfied is True: return "write_precedes_read" if read.read_satisfied is False: # Read did not see the committed write: this is a real # read-after-write violation, not a timestamp artifact. return "undetermined" # caller must escalate as store-consistency bug raise CorrelationOrderingError( "causal token present but store did not assert read_satisfied" ) # Path 2: no token. Only order if commit lag is below the resolution floor. if write.commit_ts is None: raise CorrelationOrderingError( "write span has no commit_ts; cannot bound emission-to-commit lag" ) commit_lag = write.commit_ts - write.span_ts if commit_lag < 0: # Clock-domain inversion (Δo): commit appears before emission. raise CorrelationOrderingError( f"negative commit lag {commit_lag:.3f}s indicates clock-domain " f"offset; timestamps are not comparable" ) if commit_lag > resolution_floor_s: # The write's visibility is later than the query can resolve. return "concurrent" # Commit lag is small enough that span order is a defensible proxy. return "write_precedes_read" if write.span_ts < read.span_ts else "concurrent" def build_incident_timeline( events: list[MemoryEvent], resolution_floor_s: float, ) -> list[str]: """Correlate a write/retrieve sequence, refusing invalid orderings.""" findings: list[str] = [] last_write: Optional[MemoryEvent] = None for ev in events: if ev.kind == "write": last_write = ev continue if ev.kind == "retrieve": if last_write is None: findings.append(f"retrieve@{ev.span_ts:.3f}: no prior write") continue verdict = order_write_then_read( last_write, ev, resolution_floor_s ) if verdict == "concurrent": # Honest: refuse to assert a stale-read race. findings.append( f"retrieve@{ev.span_ts:.3f}: CONCURRENT with prior write " f"(commit lag exceeds resolution floor; not a race)" ) elif verdict == "undetermined": findings.append( f"retrieve@{ev.span_ts:.3f}: UNDETERMINED — store did not " f"assert read_satisfied; escalate as consistency bug" ) else: findings.append( f"retrieve@{ev.span_ts:.3f}: write_precedes_read confirmed" ) return findings ```