# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/how-must-an-instance-detach-from-an-adversarial-sibling-agent-shared-resource.md # Remnant Warrant: https://corpusfetch.com/c/how-must-an-instance-detach-from-an-adversarial-sibling-agent-shared-resource.warrant.json # Markdown SHA-256: 5c117604d294a26e04e1c0f03a8d3d9eaa6153648713af5aeabf381c6e23be53 # Code AST SHA-256: 737e9708425cceeab50fd4ac5b81e8a0cece906688a263b917f14207b2a46a56 # Verified Classes: DetachmentVerdict, SiblingState, DetachmentState, DetachmentPolicy, DetachmentManifest, AdversarialSiblingGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class DetachmentVerdict(Enum): NO_ADVERSARY = auto() DETACHMENT_READY = auto() CHECKPOINT_MISSING = auto() ISOLATION_UNPROVEN = auto() @dataclass(frozen=True) class SiblingState: sibling_id: str is_adversarial: bool has_write_access: bool @dataclass(frozen=True) class DetachmentState: sibling: SiblingState checkpoint_captured: bool isolation_proven: bool new_resource_signature: str | None @dataclass(frozen=True) class DetachmentPolicy: require_checkpoint: bool require_isolation_proof: bool @dataclass(frozen=True) class DetachmentManifest: verdict: DetachmentVerdict directive: str manifest_digest: str class AdversarialSiblingGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_detachment( cls, state: DetachmentState, policy: DetachmentPolicy ) -> DetachmentManifest: # Gate 1: No adversary if not state.sibling.is_adversarial: digest = cls._hash(json.dumps({ "sibling": state.sibling.sibling_id, "adversarial": "FALSE" }, sort_keys=True)) return DetachmentManifest( verdict=DetachmentVerdict.NO_ADVERSARY, directive=f"PROCEED: Sibling {state.sibling.sibling_id} not adversarial.", manifest_digest=digest ) # Gate 2: No write access (safe to stay) if not state.sibling.has_write_access: digest = cls._hash(json.dumps({ "sibling": state.sibling.sibling_id, "write_access": "FALSE" }, sort_keys=True)) return DetachmentManifest( verdict=DetachmentVerdict.NO_ADVERSARY, directive=f"PROCEED: Adversarial sibling has no write access. Safe to stay.", manifest_digest=digest ) # Gate 3: Checkpoint if policy.require_checkpoint and not state.checkpoint_captured: return DetachmentManifest( verdict=DetachmentVerdict.CHECKPOINT_MISSING, directive=f"HALT: Adversarial sibling {state.sibling.sibling_id} with write access. Checkpoint required before detachment.", manifest_digest=cls._hash(f"NO_CHECKPOINT:{state.sibling.sibling_id}") ) # Gate 4: Isolation proof if policy.require_isolation_proof and not state.isolation_proven: return DetachmentManifest( verdict=DetachmentVerdict.ISOLATION_UNPROVEN, directive=f"HALT: Isolation to new resource not proven.", manifest_digest=cls._hash("NO_ISOLATION") ) # Gate 5: Ready digest = cls._hash(json.dumps({ "sibling": state.sibling.sibling_id, "checkpoint": "CAPTURED", "isolation": "PROVEN", "new_resource": state.new_resource_signature or "NONE" }, sort_keys=True)) return DetachmentManifest( verdict=DetachmentVerdict.DETACHMENT_READY, directive=f"ACTION: Detach from adversarial sibling {state.sibling.sibling_id}, migrate to isolated resource.", manifest_digest=digest )