{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-mutates-memory-during-a-span-it-does-not-own-correlation-loss-across-agent-spans-memory-writes-and-compaction",
  "title": "What happens when an instance mutates memory during a span it does not own: correlation loss across agent spans, memory writes, and compaction",
  "date_of_record": "2026 November 13",
  "scope": "Applies to GenAI observability pipelines that correlate agent execution spans with long-term memory mutation and compaction events using a shared trace/span identifier or causal parent link. Does not apply to systems where memory writes are strictly synchronous children of the span that triggered them and compaction is never concurrent with active spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-mutates-memory-during-a-span-it-does-not-own-correlation-loss-across-agent-spans-memory-writes-and-compaction.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-mutates-memory-during-a-span-it-does-not-own-correlation-loss-across-agent-spans-memory-writes-and-compaction.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-mutates-memory-during-a-span-it-does-not-own-correlation-loss-across-agent-spans-memory-writes-and-compaction.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1702,
    "python_slice_tokens": 187,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct notions of \"ownership\" in an agent observability pipeline, and they are routinely conflated: 1. **Span ownership** — the span ID stamped on an outbound memory mutation because the mutation was emitted from within that span's execution context (typically via context propagation of a trace context, e.g., an OpenTelemetry `ContextVar`). 2...",
    "what_was_observed": "In a pipeline correlating agent turns (spans) with a vector-plus-graph memory store, the following sequence produced misattributed memory writes that survived downstream reconciliation: - Agent invocation A begins span `S_A`. It enqueues a memory write `W_A` (a fact extracted from the turn) onto a write-behind queue. The queue item carries only the payload, not the trace context. - Span `S_A` ends. The worker's conte...",
    "condition_of_validity": "The misattribution occurs if and only if all of the following hold: 1. Memory mutations are **decoupled** from the span that caused them (write-behind queue, async consolidator, batched flusher, or post-turn job). 2. Trace context is captured at **flush/emit time** rather than at **enqueue time**. 3. More than one agent invocation can share a worker or event...",
    "decision_boundary": "Choose the remediation based on which of the four conditions you can actually change: - **If you control the memory subsystem (¬1 or ¬2):** capture the trace context at enqueue time and carry it as an immutable field on the queue item. This is the correct fix; it makes the invariant hold structurally. Do not attempt to \"fix\" attribution by re-reading context...",
    "operational_effect": "After moving to enqueue-time capture and a causal-token join, the following changed measurably: - Per-span memory-write counts became stable and load-invariant; the discrepancy between low- and high-concurrency runs dropped to zero. - Compaction events stopped appearing as children of unrelated spans; they were re-scoped to store partitions, and the \"affecte..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION",
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "61105b0ede5fcf7ae88613a7d51ae02a36d999f930871fb518dcf82eba6091b1",
    "verified_classes": [
      "OrphanedMutationError",
      "MutationEnvelope",
      "MemoryWriteQueue"
    ],
    "verified_functions": [
      "__init__",
      "enqueue",
      "flush"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "OrphanedMutationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
