How must an instance quarantine semantically adjacent but factually incorrect peer context?
**Date of Record:** 2026 October 27 **Scope:** Applies when an agentic session receives context (memories, references, claims) from peers that is semantically adjacent to what it needs but factually incorrect (a similar-but-different fact, an outdated version, or a subtly wrong claim), and the incorrect context could contaminate the agent's reasoning. Does not apply to obviously incorrect context (which is easy to reject) or strictly verifiable context.
Core Distinction
The separation between **semantic relevance** (the context seems applicable) and **factual applicability** (the context actually applies to the current situation). Relying on relevance creates the **Adjacent Contamination**: the agent retrieves or receives context that is close to the right answer, incorporates it into reasoning, and arrives at a subtly wrong conclusion because the context was about a similar-but-not-identical situation.
What Was Observed
In peer-context-sharing agent architectures, failing to quarantine adjacent-but-wrong context produces three primary failure modes:
- **Version Substitution:** The agent asks for "API rate limits." A peer provides rate limits for the previous API version. The agent, seeing rate limit information, incorporates it as current, and its requests fail with the new version's actual limits.
- **Entity Confusion:** The agent asks about "User X's orders." A peer provides orders for User X-prime (a different user with a similar name). The agent incorporates the wrong user's data into its reasoning about the correct user.
- **Scope Creep Application:** The agent asks about "the EU data retention policy." A peer provides policy that applies to a specific EU country (not the whole EU). The agent applies the country-specific rule as if it were EU-wide.
Recorded Elements
- **`context_applicability_receipt`:** For each context item, the exact scope of applicability (entity, version, time, geography), so the agent can compare against the actual current scope.
- **`context_entity_verification_signature`:** The cryptographic proof that the context's target entity matches the requested entity, preventing entity substitution.
- **`context_version_attestation_receipt`:** For versioned context, the exact version it applies to, and the current version, so mismatches are detectable.
- **`adjacent_quarantine_decision_receipt`:** When adjacent-but-wrong context is detected, the cryptographic record of the quarantine decision, so the reasoning that follows does not inadvertently re-include the wrong context.
Condition of Validity
* **Applies when:** Context comes from peers, relevance-based retrieval may return adjacent-but-wrong items, and incorrect context affects downstream decisions. * **Does not apply when:** Context is strictly verified (no room for substitution) or retrieval is strictly keyed on exact matches.
Decision Boundary
- **Is the context semantically relevant to the request?** If no, discard. If yes, proceed.
- **Does the `context_applicability_receipt` cover the exact scope of the request?** If yes, context is applicable. If no, context may be adjacent-but-wrong.
- **Does the `context_entity_verification_signature` match the requested entity?** If yes, entity is correct. If no, quarantine.
- **Conversely, when can adjacent context be used without quarantine?** Only when the agent explicitly reasons about "similar-but-not-identical" cases (e.g., analogical reasoning), and the fact that the context is adjacent, not exact, is part of the reasoning.
Operational Effect
- **Version Substitution Prevention:** Version mismatches are detected before incorporation.
- **Entity Confusion Prevention:** Entity verification prevents similar-name substitution.
- **Scope Creep Prevention:** Scope mismatches are caught, preventing over-generalization.
from dataclasses import dataclass
from enum import Enum, auto
import hashlib
import json
class AdjacentContextVerdict(Enum):
EXACT_MATCH = auto()
ADJACENT_QUARANTINED = auto()
ADJACENT_ACCEPTED_ANALOGY = auto()
IRRELEVANT = auto()
@dataclass(frozen=True)
class ContextItem:
context_id: str
semantic_relevance: float
applicability_scope: dict
entity_id: str
version: str
@dataclass(frozen=True)
class ContextRequest:
target_entity: str
target_version: str
target_scope: dict
min_relevance: float
@dataclass(frozen=True)
class AdjacentContextPolicy:
require_exact_entity: bool
require_exact_version: bool
allow_analogy: bool
@dataclass(frozen=True)
class AdjacentContextManifest:
verdict: AdjacentContextVerdict
directive: str
manifest_digest: str
class AdjacentContextQuarantine:
@staticmethod
def _hash(data: str) -> str:
return hashlib.sha256(data.encode("utf-8")).hexdigest()
@classmethod
def evaluate_context(
cls, item: ContextItem, req: ContextRequest, policy: AdjacentContextPolicy
) -> AdjacentContextManifest:
# Gate 1: Relevance threshold
if item.semantic_relevance < req.min_relevance:
digest = cls._hash(json.dumps({
"context": item.context_id,
"relevance": f"{item.semantic_relevance:.2f}"
}, sort_keys=True))
return AdjacentContextManifest(
verdict=AdjacentContextVerdict.IRRELEVANT,
directive=f"DISCARD: Context {item.context_id} relevance {item.semantic_relevance:.2f} < {req.min_relevance:.2f}.",
manifest_digest=digest
)
# Gate 2: Entity check
if policy.require_exact_entity and item.entity_id != req.target_entity:
if policy.allow_analogy:
digest = cls._hash(json.dumps({
"context": item.context_id,
"target": req.target_entity,
"found": item.entity_id
}, sort_keys=True))
return AdjacentContextManifest(
verdict=AdjacentContextVerdict.ADJACENT_ACCEPTED_ANALOGY,
directive=f"PROCEED_AS_ANALOGY: Context for {item.entity_id} vs target {req.target_entity}.",
manifest_digest=digest
)
return AdjacentContextManifest(
verdict=AdjacentContextVerdict.ADJACENT_QUARANTINED,
directive=f"QUARANTINE: Context for {item.entity_id} does not match target {req.target_entity}.",
manifest_digest=cls._hash(f"ENTITY:{item.context_id}")
)
# Gate 3: Version check
if policy.require_exact_version and item.version != req.target_version:
return AdjacentContextManifest(
verdict=AdjacentContextVerdict.ADJACENT_QUARANTINED,
directive=f"QUARANTINE: Context version {item.version} != target {req.target_version}.",
manifest_digest=cls._hash(f"VERSION:{item.context_id}")
)
# Gate 4: Scope check
for key, val in req.target_scope.items():
if item.applicability_scope.get(key) != val:
return AdjacentContextManifest(
verdict=AdjacentContextVerdict.ADJACENT_QUARANTINED,
directive=f"QUARANTINE: Scope mismatch on '{key}': {item.applicability_scope.get(key)} != {val}.",
manifest_digest=cls._hash(f"SCOPE:{item.context_id}")
)
# Gate 5: Exact
digest = cls._hash(json.dumps({
"context": item.context_id,
"entity": item.entity_id,
"version": item.version,
"scope": tuple(sorted(item.applicability_scope.items()))
}, sort_keys=True))
return AdjacentContextManifest(
verdict=AdjacentContextVerdict.EXACT_MATCH,
directive=f"PROCEED: Context {item.context_id} exactly matches request.",
manifest_digest=digest
)