# Where must an instance bound its own decision-provenance event schema before the trace becomes unqueryable **Date of Record:** 2026 November 26 **Scope:** Applies to any agent runtime that emits structured observability events (spans, decision records, tool-call provenance) to a collector, where a downstream consumer reconstructs *why* an action was taken from those events alone. Does not apply to single-turn stateless inference with no persisted decision trail, nor to systems where provenance is reconstructed from raw prompt/response logs rather than typed events. ## Core Distinction There are two distinct things an agent observability schema can record, and they are routinely conflated: 1. **What happened** — the tool was called, the span closed, the token count was N. This is *execution telemetry*, and it is naturally append-only, monotonic, and cheap to validate. 2. **Why it happened** — the decision record: which candidate actions were considered, which evidence the model cited, what confidence it attached, and which prior event it was causally downstream of. This is *decision provenance*, and it is where the schema boundary fails. The boundary failure is not "the schema is missing a field." It is that **decision provenance is a directed causal graph emitted as a flat, timestamp-ordered event stream**, and the schema has no invariant forcing the causal edges to be resolvable *at the moment of emission*. When an agent emits a decision event referencing a parent decision by an identifier the collector has not yet seen—or has already evicted from its retention window—the provenance is not merely incomplete. It is **silently dangling**: the event parses, validates against the schema, and produces a trace that looks complete while the causal chain is severed. The failure is invisible until an auditor tries to replay the decision, at which point the "why" is unreconstructable and the "what" is all that survives. ## What Was Observed A multi-step agent handling a refund workflow emitted events under a schema where each `decision` event carried a `parent_decision_id` and an `evidence_refs` array pointing at earlier `observation` events by `event_id`. Three concrete failure traces: **Trace A — forward reference under async emission.** The agent's planner emitted `decision:d7` (issue refund) *before* the async tool-span for `observation:o3` (the retrieved order record it cited) flushed to the collector, because the tool wrapper batched flushes on a 500ms timer while the planner emitted synchronously. The collector accepted `d7` with `evidence_refs:["o3"]`. `o3` arrived 380ms later with a *later* wall-clock timestamp. Any replay that joins on `evidence_refs` and orders by timestamp concludes the decision preceded its own evidence—a causality inversion that the schema validated as legal. **Trace B — retention-window eviction of referenced parents.** A long-running session (41 minutes) had a collector retention of 30 minutes for `observation` events. `decision:d40` referenced `parent_decision_id:d12`, which had aged out. The join returned null. The trace viewer rendered `d40` as a root decision with no antecedent, so the auditor saw an unexplained refund with no preceding escalation-check decision—the check *had* happened, but its provenance was evicted. **Trace C — schema-legal but semantically empty evidence.** `evidence_refs` was typed `array` with no requirement that each string resolve. The model, under context pressure, emitted `evidence_refs:["order_lookup","order_lookup"]`—duplicated, and referencing a *tool name* rather than an `event_id`. It validated. It joined to nothing. The provenance field was populated and worthless. In all three, the event schema reported success. The observability pipeline's own health metrics (events received, parse errors) showed zero failures. The failure lived entirely in the *queryability* of provenance, which no metric measured. ## Condition of Validity The invariant that must hold for a decision-provenance stream to be reconstructable is: > **Referential closure at emission time.** Every identifier appearing in a provenance field (`parent_decision_id`, `evidence_refs[]`, `supersedes`) must resolve to an event that is *already durably committed* to the collector's store, and must be *retained* for at least as long as any event that can reference it. This decomposes into three checkable conditions, each of which the naive schema silently violates: - **Temporal closure:** a reference may only point *backward* to a committed event. Forward references (Trace A) are illegal, which means synchronous emission of a decision that cites an async-flushed observation is a schema violation, not a race to tolerate. - **Retention closure:** retention of a referenced event class must be ≥ retention of the referencing class plus the maximum reference lag. A 30-minute observation window under a 60-minute decision window (Trace B) mathematically guarantees dangling edges. - **Type closure:** provenance identifiers must be drawn from a namespace the collector can resolve—`event_id`s, not free-text tool names (Trace C). The schema must reject unresolvable shapes *before* they are persisted, not at query time. The condition of validity is therefore: *the schema is only sound when emission ordering, retention windows, and identifier namespaces are jointly constrained such that referential closure is guaranteed by construction.* Absent that, the schema is a well-typed generator of dangling edges. ## Decision Boundary The boundary the agent runtime must decide at, per event, is: **Emit-now-or-buffer.** When a decision event would reference an observation that is not yet durably committed, the runtime has exactly two sound options and one unsound default: - *Buffer the decision* until its referenced evidence commits, preserving backward-only edges (correct, at the cost of emission latency and reordering in the stream). - *Emit a provisional decision* with `evidence_refs:[]` and a `pending_evidence` marker, then emit a `decision_amended` event once evidence commits, carrying the resolved refs and pointing backward to both (correct, at the cost of schema complexity). - *Emit the decision citing uncommitted refs* (the default, and the failure). This must be blocked. The decision boundary is thus a **commit-ordering gate**: a provenance-bearing event may cross the emission boundary only if `all(ref ∈ committed_set)` for its references. The runtime must maintain a committed-set index and refuse to serialize a decision whose references are not in it—raising rather than emitting a dangling edge. The same gate must enforce retention closure by refusing to reference an event class whose retention is shorter than the referencing class's. ## Operational Effect Enforcing the commit-ordering gate converts an invisible, replay-time failure into a loud, emission-time failure. The operational consequences: - **Latency becomes explicit.** Buffering decisions behind evidence commits surfaces the true cost of provenance; teams that previously "got away with" forward references discover their planner was racing their tool layer. - **Retention becomes a schema parameter, not an ops afterthought.** The gate forces retention windows to be declared per event class and validated against reference lag, so eviction-induced dangles become a configuration error caught at startup, not an audit surprise. - **Replay becomes total.** With backward-only, committed, resolvable edges, a replay that walks `parent_decision_id` and `evidence_refs` terminates at a root with no dangling joins. Provenance is reconstructable or the event was never emitted. The invariant to carry forward: **a decision-provenance event is not a log line; it is a graph node whose edges must be closed at emission. Treat any reference to uncommitted or unretained state as an emission failure, not a downstream join miss.** ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceClosureError(RuntimeError): """Raised when a decision event's provenance references cannot be resolved to durably committed, retained events at emission time.""" pass @dataclass class Event: event_id: str kind: str # "observation" | "decision" parent_decision_id: Optional[str] = None evidence_refs: list = field(default_factory=list) class ProvenanceGate: """Enforces referential closure at emission: backward-only, committed, and retention-consistent references.""" def __init__(self, retention_seconds: dict, max_reference_lag: int = 0): # retention_seconds maps event kind -> retention window self.retention_seconds = retention_seconds self.max_reference_lag = max_reference_lag self.committed: dict = {} # event_id -> Event self.committed_kind: dict = {} # event_id -> kind def commit(self, event: Event) -> None: self.committed[event.event_id] = event self.committed_kind[event.event_id] = event.kind def _resolve(self, ref_id: str, referencing_kind: str) -> None: if ref_id not in self.committed: # Trace A / Trace C: forward reference or non-existent id raise ProvenanceClosureError( f"provenance ref {ref_id!r} not committed at emission of " f"{referencing_kind!r} event; dangling edge refused" ) ref_kind = self.committed_kind[ref_id] ref_ret = self.retention_seconds.get(ref_kind, 0) own_ret = self.retention_seconds.get(referencing_kind, 0) # Trace B: retention closure — referenced class must outlive referencer if ref_ret < own_ret + self.max_reference_lag: raise ProvenanceClosureError( f"retention closure violated: {ref_kind!r} retention " f"({ref_ret}s) < {referencing_kind!r} retention " f"({own_ret}s) + lag ({self.max_reference_lag}s)" ) def emit_decision(self, event: Event) -> Event: if event.kind != "decision": raise ProvenanceClosureError( f"emit_decision received kind {event.kind!r}" ) if event.parent_decision_id is not None: self._resolve(event.parent_decision_id, event.kind) for ref in event.evidence_refs: self._resolve(ref, event.kind) self.commit(event) return event def demo() -> None: gate = ProvenanceGate( retention_seconds={"observation": 1800, "decision": 3600}, max_reference_lag=60, ) # Commit an observation, then a decision that cites it: legal. gate.commit(Event(event_id="o3", kind="observation")) gate.emit_decision( Event(event_id="d7", kind="decision", evidence_refs=["o3"]) ) # Forward reference: decision cites evidence never committed -> raises. gate.emit_decision( Event(event_id="d8", kind="decision", evidence_refs=["o99"]) ) if __name__ == "__main__": demo() ```