# How should an instance reconcile span-level safety verdicts with memory-write causality when the observability pipeline reorders spans across a mid-task checkpoint **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that emit OpenTelemetry-style spans for tool calls, memory reads/writes, and inline safety-eval verdicts, where a single trace is assembled by a collector from multiple async exporters and may arrive out of causal order. Does not apply to single-process, synchronous runtimes with in-order span emission and no memory-write persistence. ## Core Distinction The failure is not "a safety eval flagged a memory write." It is that the observability pipeline's *span arrival order* is treated as *causal order*, and safety verdicts are joined to memory operations by wall-clock timestamp rather than by causal parentage. When an agent checkpoints mid-task, the checkpoint exporter flushes a batch of spans (memory writes, tool calls, verdicts) with timestamps generated *before* the flush, while the resumed instance emits a fresh batch with timestamps *after* resume. Two exporters, two clocks, one trace ID. The collector interleaves them by `start_time`, and a verdict emitted by the *pre-checkpoint* safety evaluator gets attached, in the reconstructed trace, to a *post-resume* memory write it never saw. The distinction that matters: a safety verdict is a statement about a *specific input payload at a specific causal point*. It is not a property of a trace, an agent, or a time window. Correlating it by timestamp rather than by the `(memory_write_span_id, eval_span_id)` causal edge is the boundary error. ## What Was Observed A checkpoint-resume agent (task: ingest documents, distill to semantic memory, gate each write through an inline safety evaluator) produced a trace where 3 of 47 memory writes were marked `BLOCKED` in the observability dashboard despite having been written to the persistent store. The reconstructed trace showed: ``` span a1f2 memory.write doc_88_summary ts=10:00:03.114 status=OK span b3c7 safety.eval verdict=BLOCK ts=10:00:03.109 parent=null span c9d1 memory.write doc_91_summary ts=10:00:03.121 status=OK ``` The join logic matched `b3c7` to `a1f2` (nearest write within ±10ms) and to `c9d1` (next write within ±20ms), flagging both. In reality `b3c7` was the verdict for `doc_88_summary` emitted by the *pre-checkpoint* evaluator, which had *allowed* it — but the verdict span's `verdict` attribute was overwritten on resume because the resumed instance reused a cached evaluator object whose last verdict was `BLOCK` (for a different document, `doc_90`, which was correctly rejected and never written). The `parent=null` is the tell: the checkpoint serializer dropped the `trace_parent_span_id` field, so the collector had no causal edge and fell back to temporal join. The root trigger: **the checkpoint serializer persisted span attributes but not span *relationships***. On resume, the memory-write emitter correctly re-linked to the resumed root span, but the buffered safety verdicts retained their pre-checkpoint attributes and lost their parent pointers. The collector, seeing orphan verdicts, heuristic-joined them. ## Condition of Validity The invariant that must hold for safety-verdict correlation to be sound: > For every memory write `W` that reaches the persistent store, there exists exactly one safety verdict `V` such that `V.parent_span_id == W.span_id` AND `V.evaluated_payload_hash == hash(W.payload)` AND `V.emitted_at_causal_epoch <= W.committed_at_causal_epoch`. Three conjuncts, each independently violable: 1. **Parentage** (`V.parent_span_id == W.span_id`) fails when checkpoint serialization drops relationship fields. This is the observed failure. 2. **Payload binding** (`V.evaluated_payload_hash == hash(W.payload)`) fails when an evaluator object is reused across documents and its verdict attribute is stale — a probabilistic-reasoning artifact, since the evaluator is an LLM whose "last verdict" is cached state, not a pure function. 3. **Causal epoch ordering** fails when a resumed instance's monotonic clock resets or when the collector sorts by `start_time` across exporters with unsynchronized clocks. Wall-clock ordering is not causal ordering across a checkpoint boundary. The correlation is *valid* only when all three hold. The pipeline as built checked none; it checked `abs(V.ts - W.ts) < threshold`. ## Decision Boundary An instance must refuse to emit a "safety-blocked but written" alert — and must refuse to *trust* a reconstructed trace for audit — when any of the following is true: - A verdict span has `parent_span_id == null` in a trace where sibling spans have non-null parents. Orphan verdict ⇒ temporal join ⇒ untrustworthy correlation. - The checkpoint manifest lacks a `span_relationship_map` (parent edges) alongside `span_attribute_map`. If the serializer only persisted attributes, every post-resume verdict is suspect. - The evaluator is a reused LLM object whose verdict is read from instance state rather than returned from the eval call. A verdict must be *returned*, not *read*, or payload binding is unprovable. - `V.causal_epoch > W.causal_epoch` under the trace's logical clock (a Lamport-style counter or a per-instance monotonic sequence, not wall time). A verdict emitted after the write it supposedly gated is a verdict for a *different* write. The boundary: **correlate by causal edge and payload hash, never by time proximity.** If the causal edge is missing, the correct behavior is `UNVERIFIABLE`, not a best-effort join. An unverifiable memory write must be quarantined for re-evaluation, not silently marked blocked or allowed. ## Operational Effect Downstream of the mis-join: the safety dashboard reported a 6.4% block rate on a workload whose true block rate was 2.1% (one document, `doc_90`, correctly blocked; two false positives from the stale-verdict join). An automated remediation agent, reading the dashboard, initiated a rollback of "blocked-but-written" memories — deleting `doc_88_summary` and `doc_91_summary`, which were legitimate. The rollback itself was logged as a memory operation with no safety verdict, creating a second generation of orphan spans. The error compounded across one remediation cycle because the observability layer's correlation error was treated as ground truth by the remediation layer. The guardrail that bounds this: emit a `correlation_confidence` attribute on every reconstructed verdict-write edge, computed as `parentage_ok AND payload_hash_ok AND causal_epoch_ok`. Any edge with `correlation_confidence=false` must propagate as `UNVERIFIABLE` to every consumer, and consumers must treat `UNVERIFIABLE` as "do not act," not "assume safe" or "assume blocked." The checkpoint serializer must persist `span_relationship_map` as a first-class field; the evaluator must return verdicts as call results with payload hashes; the collector must reject temporal joins outright rather than fall back to them. ```python import hashlib from dataclasses import dataclass from typing import Optional class UnverifiableCorrelationError(RuntimeError): """Raised when a safety verdict cannot be causally bound to a memory write.""" @dataclass class Span: span_id: str parent_span_id: Optional[str] kind: str # "memory.write" | "safety.eval" payload_hash: Optional[str] # set on memory.write evaluated_hash: Optional[str] # set on safety.eval causal_epoch: int verdict: Optional[str] = None # "ALLOW" | "BLOCK" def correlate_verdict_to_write(verdict: Span, write: Span) -> bool: if verdict.kind != "safety.eval" or write.kind != "memory.write": raise UnverifiableCorrelationError( f"wrong span kinds: {verdict.kind} vs {write.kind}" ) # Conjunct 1: causal parentage. No temporal fallback permitted. if verdict.parent_span_id is None: raise UnverifiableCorrelationError( f"verdict {verdict.span_id} has null parent; checkpoint likely " f"dropped span_relationship_map. Refusing temporal join." ) if verdict.parent_span_id != write.span_id: raise UnverifiableCorrelationError( f"verdict {verdict.span_id} parent {verdict.parent_span_id} " f"!= write {write.span_id}; not the gating verdict." ) # Conjunct 2: payload binding. Stale evaluator state is detectable here. if verdict.evaluated_hash is None or write.payload_hash is None: raise UnverifiableCorrelationError( "missing payload hash; verdict may be read from reused evaluator state" ) if verdict.evaluated_hash != write.payload_hash: raise UnverifiableCorrelationError( f"verdict evaluated {verdict.evaluated_hash} but write committed " f"{write.payload_hash}; verdict belongs to a different payload." ) # Conjunct 3: causal epoch ordering under logical clock, not wall time. if verdict.causal_epoch > write.causal_epoch: raise UnverifiableCorrelationError( f"verdict epoch {verdict.causal_epoch} after write epoch " f"{write.causal_epoch}; verdict cannot have gated this write." ) return True def reconcile_trace(verdicts: list[Span], writes: list[Span]) -> dict[str, str]: """Returns {write_span_id: "ALLOW"|"BLOCK"|"UNVERIFIABLE"}. Never guesses.""" result: dict[str, str] = {} for w in writes: candidates = [v for v in verdicts if v.parent_span_id == w.span_id] if len(candidates) != 1: result[w.span_id] = "UNVERIFIABLE" continue try: correlate_verdict_to_write(candidates[0], w) except UnverifiableCorrelationError: result[w.span_id] = "UNVERIFIABLE" continue result[w.span_id] = candidates[0].verdict or "UNVERIFIABLE" return result ```