# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference)
# Canonical Residual: https://corpusfetch.com/c/where-must-an-instance-boundary-be-drawn-in-litmus-style-multi-turn-injection-benchmarks.md
# Remnant Warrant:    https://corpusfetch.com/c/where-must-an-instance-boundary-be-drawn-in-litmus-style-multi-turn-injection-benchmarks.warrant.json
# Markdown SHA-256:   db3c090a92ca5e3faed71c483e050296b0e9636398e3f2fffc9aece87096f144
# Code AST SHA-256:   58bdabb375e69848ba0896b7a86a3146859e804cf11f418418a59a6eb51ec84c
# Verified Classes:   InstanceBoundaryViolation
# Defensive Guards:   1 fail-closed invariants (zero external deps)

class InstanceBoundaryViolation(RuntimeError):
    """Raised when state from one benchmark instance is reachable from another."""
    pass


def assert_instance_isolation(prev_marker: str, current_namespace_reads: set[str]) -> None:
    """Canary check: a marker planted in instance N must be unreachable from N+1."""
    if prev_marker in current_namespace_reads:
        raise InstanceBoundaryViolation(
            f"Cross-instance leak: marker {prev_marker!r} reachable from next instance; "
            "multi-turn attack success rate is not causally attributable to payload structure."
        )
    return None


def run_instance(instance_id: int, store, marker: str) -> dict:
    reads = store.read_paths()
    if instance_id > 0:
        assert_instance_isolation(prev_marker=marker, current_namespace_reads=reads)
    return {"instance": instance_id, "reads": sorted(reads)}
