Core Rings (Clean Architecture Sub-project 1) Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Build the entities ring (domain/) and boundary ports (ports/) with opaque positions and five segregated store ports, port the memory/sqlite/postgresql backends as adapters, and keep the entire existing suite green through a legacy compatibility layer.

Architecture: Clean Architecture rings per docs/adrs/0019-clean-architecture-store-ports.md and spec docs/superpowers/specs/2026-07-29-core-rings-design.md. Ports are structural Protocols; adapters satisfy them without inheritance; conformance suites (including hypothesis property suites) are the compliance check. Old stores/ surface survives via a LegacyStoreAdapter wrapper until sub-project 2.

Tech Stack: Python 3.11+, pydantic v2, sqlalchemy async (aiosqlite/asyncpg), pytest + pytest-asyncio, hypothesis, mutmut + cosmic-ray.

Global Constraints


Task 1: StreamId value object (`domain/`)

Files:

Interfaces:


# tests/unit/domain/test_stream_id.py
import re
from uuid import uuid4

import pytest
from hypothesis import given
from hypothesis import strategies as st

from eventsource.domain import StreamId

CATEGORY_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-"


class TestStreamId:
    def test_render_matches_legacy_wire_format(self) -> None:
        aid = uuid4()
        assert StreamId(aggregate_id=aid, category="Order").render() == f"{aid}:Order"

    def test_parse_round_trip(self) -> None:
        sid = StreamId(aggregate_id=uuid4(), category="Order.v2")
        assert StreamId.parse(sid.render()) == sid

    def test_category_with_colon_rejected(self) -> None:
        with pytest.raises(ValueError):
            StreamId(aggregate_id=uuid4(), category="Order:evil")

    def test_empty_category_rejected(self) -> None:
        with pytest.raises(ValueError):
            StreamId(aggregate_id=uuid4(), category="")

    def test_frozen(self) -> None:
        sid = StreamId(aggregate_id=uuid4(), category="Order")
        with pytest.raises(Exception):
            sid.category = "Other"  # type: ignore[misc]

    @given(category=st.text(alphabet=CATEGORY_ALPHABET, min_size=1, max_size=64))
    def test_valid_categories_round_trip(self, category: str) -> None:
        sid = StreamId(aggregate_id=uuid4(), category=category)
        assert StreamId.parse(sid.render()) == sid

    @given(category=st.text(min_size=1, max_size=64))
    def test_fuzzed_categories_never_corrupt_wire_format(self, category: str) -> None:
        try:
            sid = StreamId(aggregate_id=uuid4(), category=category)
        except ValueError:
            return  # rejected is fine; corrupted is not
        assert StreamId.parse(sid.render()) == sid

Run: uv run pytest tests/unit/domain/test_stream_id.py -v Expected: FAIL / collection error β€” eventsource.domain does not exist.


# src/eventsource/domain/stream_id.py
"""Stream identity value object."""

import re
from dataclasses import dataclass
from uuid import UUID

CATEGORY_PATTERN = re.compile(r"^[A-Za-z0-9_.-]+$")


@dataclass(frozen=True, slots=True)
class StreamId:
    """Identity of an event stream: aggregate id + category.

    ``category`` is today's aggregate type. The rendered wire format is
    ``"{aggregate_id}:{category}"`` β€” the delimiter is why ``:`` is banned
    from categories.
    """

    aggregate_id: UUID
    category: str

    def __post_init__(self) -> None:
        if not CATEGORY_PATTERN.match(self.category):
            raise ValueError(
                f"invalid stream category {self.category!r}: "
                "must match [A-Za-z0-9_.-]+"
            )

    def render(self) -> str:
        return f"{self.aggregate_id}:{self.category}"

    @classmethod
    def parse(cls, raw: str) -> "StreamId":
        aggregate_id, sep, category = raw.partition(":")
        if not sep:
            raise ValueError(f"not a stream id: {raw!r}")
        return cls(aggregate_id=UUID(aggregate_id), category=category)

# src/eventsource/domain/__init__.py
"""Entities ring. Pure: stdlib + pydantic only.

TRANSITION: DomainEvent/EventRegistry still live in eventsource.events and
count as this ring until sub-project 3 moves them.
"""

from eventsource.domain.stream_id import CATEGORY_PATTERN, StreamId

__all__ = ["CATEGORY_PATTERN", "StreamId"]

Run: uv run pytest tests/unit/domain/test_stream_id.py -v Expected: PASS (all).


git add src/eventsource/domain tests/unit/domain
git commit -m "feat: add streamid value object in domain ring"

Task 2: Position value object and exceptions (`ports/positions.py`)

Files:

Interfaces:


# tests/unit/ports/test_position.py
import pytest
from hypothesis import given
from hypothesis import strategies as st

from eventsource.exceptions import PositionDecodeError, PositionForeignError
from eventsource.ports import Position

keys = st.lists(
    st.one_of(st.integers(min_value=0, max_value=2**62), st.text(max_size=32)),
    min_size=1,
    max_size=3,
).map(tuple)


class TestPositionOrdering:
    def test_same_store_orders_by_key(self) -> None:
        assert Position("pg:a", (1,)) < Position("pg:a", (2,))

    def test_foreign_store_ordering_raises(self) -> None:
        with pytest.raises(PositionForeignError):
            _ = Position("pg:a", (1,)) < Position("pg:b", (1,))

    def test_foreign_store_equality_is_false_not_error(self) -> None:
        assert Position("pg:a", (1,)) != Position("pg:b", (1,))

    def test_equality_with_none_and_other_types(self) -> None:
        assert Position("pg:a", (1,)) != None  # noqa: E711
        assert Position("pg:a", (1,)) != 1
        assert Position("pg:a", (1,)) in {Position("pg:a", (1,))}

    @given(a=keys, b=keys, c=keys)
    def test_ordering_laws_within_store(self, a, b, c) -> None:
        pa, pb, pc = (Position("s", k) for k in (a, b, c))
        assert (pa < pb) == (not (pb < pa or pa == pb))  # trichotomy-ish
        if pa < pb and pb < pc:
            assert pa < pc  # transitivity


class TestPositionSerialization:
    @given(store_id=st.text(min_size=1, max_size=32), key=keys)
    def test_round_trip(self, store_id: str, key) -> None:
        p = Position(store_id, key)
        assert Position.from_str(p.to_str()) == p

    @given(garbage=st.text(max_size=64))
    def test_from_str_garbage_raises_decode_error(self, garbage: str) -> None:
        try:
            p = Position.from_str(garbage)
        except PositionDecodeError:
            return
        # If it decoded, it must round-trip (accidentally-valid JSON is ok)
        assert Position.from_str(p.to_str()) == p

    def test_bare_int_is_not_valid_here(self) -> None:
        # Legacy bare-int checkpoints are decoded by the SQL codec (Task 6),
        # never by Position.from_str itself (no store_id to attach).
        with pytest.raises(PositionDecodeError):
            Position.from_str("12345")

Run: uv run pytest tests/unit/ports/test_position.py -v Expected: FAIL β€” eventsource.ports does not exist.

First append to src/eventsource/exceptions.py (match the module's existing base-class and docstring style β€” read it first):


class DuplicateEventError(EventSourceError):
    """An event with this event_id already exists in the store."""


class PositionDecodeError(EventSourceError):
    """A persisted position string could not be decoded."""


class PositionForeignError(EventSourceError):
    """Positions from different stores were compared for order."""

# src/eventsource/ports/positions.py
"""Position and ExpectedVersion value objects for the store ports."""

import json
from dataclasses import dataclass
from typing import Any

from eventsource.exceptions import PositionDecodeError, PositionForeignError


@dataclass(frozen=True, slots=True)
class Position:
    """Opaque, ordered, serializable global-feed position token.

    Totally ordered within one store; ordering across stores raises
    PositionForeignError; equality across stores is False. Consumers
    compare and persist β€” never arithmetic.
    """

    store_id: str
    key: tuple[int | str, ...]

    def _check_comparable(self, other: "Position") -> None:
        if self.store_id != other.store_id:
            raise PositionForeignError(
                f"cannot order positions from {self.store_id!r} "
                f"and {other.store_id!r}"
            )

    def __lt__(self, other: object) -> bool:
        if not isinstance(other, Position):
            return NotImplemented
        self._check_comparable(other)
        return self.key < other.key

    def __le__(self, other: object) -> bool:
        if not isinstance(other, Position):
            return NotImplemented
        self._check_comparable(other)
        return self.key <= other.key

    def __gt__(self, other: object) -> bool:
        if not isinstance(other, Position):
            return NotImplemented
        self._check_comparable(other)
        return self.key > other.key

    def __ge__(self, other: object) -> bool:
        if not isinstance(other, Position):
            return NotImplemented
        self._check_comparable(other)
        return self.key >= other.key

    def to_str(self) -> str:
        return json.dumps(
            {"s": self.store_id, "k": list(self.key)}, separators=(",", ":")
        )

    @classmethod
    def from_str(cls, raw: str) -> "Position":
        try:
            data: Any = json.loads(raw)
            store_id = data["s"]
            key = data["k"]
            if not isinstance(store_id, str) or not isinstance(key, list):
                raise TypeError
            if not all(isinstance(e, (int, str)) and not isinstance(e, bool) for e in key):
                raise TypeError
        except (json.JSONDecodeError, TypeError, KeyError) as exc:
            raise PositionDecodeError(f"not a position: {raw!r}") from exc
        return cls(store_id=store_id, key=tuple(key))

Note: @dataclass(frozen=True) generates __eq__ comparing (store_id, key) β€” foreign stores compare unequal without raising, which is exactly the contract. Do not pass order=True (it would generate raising-free ordering); the explicit dunders above are the point.


# src/eventsource/ports/__init__.py
"""Boundary ports (Clean Architecture output ports). Depends on domain only."""

from eventsource.ports.positions import Position

__all__ = ["Position"]

Run: uv run pytest tests/unit/ports/test_position.py -v Expected: PASS.


git add src/eventsource/ports src/eventsource/exceptions.py tests/unit/ports
git commit -m "feat: add opaque position value object and port exceptions"

Task 3: ExpectedVersion value object

Files:

Interfaces:


# tests/unit/ports/test_expected_version.py
import pytest

from eventsource.ports import ExpectedVersion


class TestExpectedVersion:
    def test_four_modes(self) -> None:
        assert ExpectedVersion.any_().kind == "any"
        assert ExpectedVersion.no_stream().kind == "no_stream"
        assert ExpectedVersion.stream_exists().kind == "stream_exists"
        ev = ExpectedVersion.exact(3)
        assert (ev.kind, ev.version) == ("exact", 3)

    def test_exact_negative_rejected(self) -> None:
        with pytest.raises(ValueError):
            ExpectedVersion.exact(-1)

    def test_equality(self) -> None:
        assert ExpectedVersion.exact(2) == ExpectedVersion.exact(2)
        assert ExpectedVersion.any_() != ExpectedVersion.no_stream()

    def test_frozen(self) -> None:
        with pytest.raises(Exception):
            ExpectedVersion.any_().kind = "exact"  # type: ignore[misc]

@dataclass(frozen=True, slots=True)
class ExpectedVersion:
    """Optimistic-concurrency expectation for append.

    Versions are 1-based event counts; an absent stream has version 0.
    ``exact(n)`` means "the stream currently has exactly n events".
    """

    kind: str
    version: int | None = None

    @classmethod
    def any_(cls) -> "ExpectedVersion":
        return cls(kind="any")

    @classmethod
    def no_stream(cls) -> "ExpectedVersion":
        return cls(kind="no_stream")

    @classmethod
    def stream_exists(cls) -> "ExpectedVersion":
        return cls(kind="stream_exists")

    @classmethod
    def exact(cls, version: int) -> "ExpectedVersion":
        if version < 0:
            raise ValueError(f"exact version must be >= 0, got {version}")
        return cls(kind="exact", version=version)

Task 4: Envelope and read-option value objects (`ports/envelopes.py`)

Files:

Interfaces:


# tests/unit/ports/test_envelopes.py
from datetime import UTC, datetime
from uuid import uuid4

import pytest

from eventsource.domain import StreamId
from eventsource.events import DomainEvent
from eventsource.ports import (
    AppendResult,
    EventEnvelope,
    FeedReadOptions,
    Position,
    ReadDirection,
    StreamReadOptions,
)


class ThingHappened(DomainEvent):
    pass


def make_envelope(position: Position | None) -> EventEnvelope:
    return EventEnvelope(
        event=ThingHappened(aggregate_id=uuid4()),
        stream_id=StreamId(aggregate_id=uuid4(), category="Thing"),
        stream_version=1,
        position=position,
        stored_at=datetime.now(UTC),
    )


class TestEnvelopes:
    def test_position_may_be_none_for_feedless_stores(self) -> None:
        assert make_envelope(None).position is None

    def test_envelope_frozen(self) -> None:
        env = make_envelope(None)
        with pytest.raises(Exception):
            env.stream_version = 2  # type: ignore[misc]

    def test_append_result_has_no_conflict_flags(self) -> None:
        result = AppendResult(
            stream=StreamId(aggregate_id=uuid4(), category="Thing"),
            new_version=1,
            position=None,
        )
        assert not hasattr(result, "success")
        assert not hasattr(result, "conflict")

    def test_option_defaults(self) -> None:
        assert StreamReadOptions().direction is ReadDirection.FORWARD
        assert FeedReadOptions().tenant_id is None

Task 5: The five store port protocols (`ports/store.py`) + snapshot/bus port re-homes

Files:

Interfaces:


class EventAppender(Protocol):
    max_append_batch: int | None
    async def append(self, stream: StreamId, events: Sequence[DomainEvent],
                     expected: ExpectedVersion) -> AppendResult: ...

class StreamReader(Protocol):
    def read_stream(self, stream: StreamId,
                    options: StreamReadOptions | None = None) -> AsyncIterator[EventEnvelope]: ...
    async def get_stream_version(self, stream: StreamId) -> int: ...

class EventLookup(Protocol):
    async def event_exists(self, event_id: UUID) -> bool: ...

class GlobalEventFeed(Protocol):
    def read_all(self, from_position: Position | None = None,
                 options: FeedReadOptions | None = None) -> AsyncIterator[EventEnvelope]: ...
    async def current_position(self) -> Position | None: ...

class CategoryQuery(Protocol):
    def read_category(self, category: str,
                      options: CategoryReadOptions | None = None) -> AsyncIterator[EventEnvelope]: ...

class FullEventStore(EventAppender, StreamReader, EventLookup,
                     GlobalEventFeed, CategoryQuery, Protocol): ...

# tests/unit/ports/test_store_ports.py
import pytest

from eventsource.ports import collect
from eventsource.ports.store import (
    CategoryQuery,
    EventAppender,
    EventLookup,
    FullEventStore,
    GlobalEventFeed,
    StreamReader,
)


async def _agen(items):
    for item in items:
        yield item


@pytest.mark.asyncio
async def test_collect_drains_iterator() -> None:
    assert await collect(_agen([1, 2, 3])) == [1, 2, 3]


def test_ports_are_importable_and_distinct() -> None:
    ports = {EventAppender, StreamReader, EventLookup, GlobalEventFeed, CategoryQuery}
    assert len(ports) == 5
    assert issubclass(FullEventStore, EventAppender)

(Match the project's asyncio test style β€” check whether existing tests use @pytest.mark.asyncio or asyncio_mode=auto in pyproject, and follow it.)


Task 6: SQL position codec + `_sql` helper package (`adapters/_sql/`)

Files:

Interfaces:


# tests/unit/adapters/test_sql_position_codec.py
import pytest

from eventsource.adapters._sql.positions import IntPositionCodec
from eventsource.exceptions import PositionDecodeError, PositionForeignError
from eventsource.ports import Position


class TestIntPositionCodec:
    def test_encode_decode_round_trip(self) -> None:
        codec = IntPositionCodec(store_id="pg:main")
        pos = codec.encode(42)
        assert codec.decode(pos.to_str()) == pos
        assert codec.value_of(pos) == 42

    def test_legacy_bare_int_checkpoint_decodes(self) -> None:
        codec = IntPositionCodec(store_id="pg:main")
        assert codec.decode("12345") == Position("pg:main", (12345,))

    def test_foreign_store_decode_raises(self) -> None:
        codec = IntPositionCodec(store_id="pg:main")
        foreign = Position("sqlite:other", (1,)).to_str()
        with pytest.raises(PositionForeignError):
            codec.decode(foreign)

    def test_garbage_raises_decode_error(self) -> None:
        with pytest.raises(PositionDecodeError):
            IntPositionCodec(store_id="pg:main").decode("not-a-position")

    def test_dialect_reexport_intact(self) -> None:
        from eventsource.repositories._dialect import Dialect  # old path
        from eventsource.adapters._sql.dialect import Dialect as NewDialect
        assert Dialect is NewDialect

# src/eventsource/adapters/_sql/positions.py
"""Int-backed position codec shared by the SQL-family adapters."""

from dataclasses import dataclass

from eventsource.exceptions import PositionDecodeError, PositionForeignError
from eventsource.ports import Position


@dataclass(frozen=True, slots=True)
class IntPositionCodec:
    store_id: str

    def encode(self, value: int) -> Position:
        return Position(store_id=self.store_id, key=(value,))

    def decode(self, raw: str) -> Position:
        if raw.isdigit():  # legacy bare-int checkpoint value
            return self.encode(int(raw))
        position = Position.from_str(raw)
        if position.store_id != self.store_id:
            raise PositionForeignError(
                f"position belongs to {position.store_id!r}, "
                f"this store is {self.store_id!r}"
            )
        return position

    def value_of(self, position: Position) -> int:
        if position.store_id != self.store_id:
            raise PositionForeignError(
                f"position belongs to {position.store_id!r}, "
                f"this store is {self.store_id!r}"
            )
        if len(position.key) != 1 or not isinstance(position.key[0], int):
            raise PositionDecodeError(f"not an int-backed position: {position!r}")
        return position.key[0]

Move _dialect.py content verbatim (git mv preferred, then create the re-export at the old path).


Task 7: Memory adapter (`adapters/memory/store.py`)

Files:

Interfaces:


# tests/unit/adapters/test_memory_store.py
from uuid import uuid4

import pytest

from eventsource.adapters.memory import MemoryEventStore
from eventsource.domain import StreamId
from eventsource.events import DomainEvent
from eventsource.exceptions import DuplicateEventError, OptimisticLockError
from eventsource.ports import ExpectedVersion, collect


class ThingHappened(DomainEvent):
    pass


def sid() -> StreamId:
    return StreamId(aggregate_id=uuid4(), category="Thing")


@pytest.fixture
def store() -> MemoryEventStore:
    return MemoryEventStore()


class TestAppend:
    async def test_append_returns_one_based_version(self, store) -> None:
        stream = sid()
        result = await store.append(
            stream, [ThingHappened(aggregate_id=stream.aggregate_id)],
            ExpectedVersion.no_stream(),
        )
        assert result.new_version == 1
        assert await store.get_stream_version(stream) == 1

    async def test_absent_stream_version_zero(self, store) -> None:
        assert await store.get_stream_version(sid()) == 0

    async def test_exact_conflict_raises(self, store) -> None:
        stream = sid()
        await store.append(stream, [ThingHappened(aggregate_id=stream.aggregate_id)],
                           ExpectedVersion.no_stream())
        with pytest.raises(OptimisticLockError):
            await store.append(stream, [ThingHappened(aggregate_id=stream.aggregate_id)],
                               ExpectedVersion.exact(0))

    async def test_duplicate_event_id_rejected_atomically(self, store) -> None:
        stream = sid()
        event = ThingHappened(aggregate_id=stream.aggregate_id)
        await store.append(stream, [event], ExpectedVersion.no_stream())
        fresh = ThingHappened(aggregate_id=stream.aggregate_id)
        with pytest.raises(DuplicateEventError):
            await store.append(stream, [fresh, event], ExpectedVersion.exact(1))
        assert await store.get_stream_version(stream) == 1  # atomic: fresh not written

    async def test_empty_batch_rejected(self, store) -> None:
        with pytest.raises(ValueError):
            await store.append(sid(), [], ExpectedVersion.any_())


class TestFeed:
    async def test_exclusive_resumption(self, store) -> None:
        stream = sid()
        await store.append(stream,
                           [ThingHappened(aggregate_id=stream.aggregate_id) for _ in range(3)],
                           ExpectedVersion.no_stream())
        first_two = [env async for env in store.read_all()][:2]
        resumed = [env async for env in store.read_all(from_position=first_two[-1].position)]
        assert len(resumed) == 1

    async def test_current_position_none_when_empty(self, store) -> None:
        assert await store.current_position() is None

def _check_expected(self, current: int, expected: ExpectedVersion, stream: StreamId) -> None:
    if expected.kind == "any":
        return
    if expected.kind == "no_stream" and current != 0:
        raise OptimisticLockError(...)   # mirror the fields the existing exception carries
    if expected.kind == "stream_exists" and current == 0:
        raise OptimisticLockError(...)
    if expected.kind == "exact" and current != expected.version:
        raise OptimisticLockError(...)

(Open src/eventsource/exceptions.py for OptimisticLockError's actual constructor β€” it carries aggregate/expected/actual fields today; populate them faithfully, aggregate_id=stream.aggregate_id.)


Task 8: Conformance package β€” Appender, StreamReader, EventLookup suites

Files:

Interfaces:


from collections.abc import AsyncIterator

import pytest

from eventsource.adapters.memory import MemoryEventStore
from eventsource.testing.conformance_ports import (
    AppenderConformance,
    EventLookupConformance,
    StreamReaderConformance,
)


class TestMemoryAppender(AppenderConformance):
    @pytest.fixture
    async def store(self) -> AsyncIterator[MemoryEventStore]:
        yield MemoryEventStore()


class TestMemoryStreamReader(StreamReaderConformance):
    @pytest.fixture
    async def store(self) -> AsyncIterator[MemoryEventStore]:
        yield MemoryEventStore()


class TestMemoryEventLookup(EventLookupConformance):
    @pytest.fixture
    async def store(self) -> AsyncIterator[MemoryEventStore]:
        yield MemoryEventStore()

Task 9: Conformance β€” GlobalFeed + CategoryQuery suites, feed-less partitioned store

Files:

Interfaces:


Task 10: Hypothesis stateful machine + sync faΓ§ade

Files:

Interfaces:


# tests/unit/adapters/test_memory_stateful.py
from hypothesis import settings

from eventsource.adapters.memory import MemoryEventStore
from eventsource.testing.conformance_ports.stateful import StoreStateMachine
from eventsource.testing.sync_facade import SyncStoreFacade


class MemoryStateMachine(StoreStateMachine):
    def make_store(self) -> SyncStoreFacade:
        return SyncStoreFacade(MemoryEventStore())


TestMemoryStateful = MemoryStateMachine.TestCase
TestMemoryStateful.settings = settings(max_examples=25, deadline=None)

Additionally (same task, spec Testing §property 4): tests/unit/serialization/test_event_round_trip_property.py — a hypothesis test generating events with arbitrary payload field values (st.dictionaries of json-safe scalars applied to a test DomainEvent subclass with a payload: dict[str, Any] field), asserting registry-mediated serialize→deserialize round-trip equality via the existing EventSourceJSONEncoder path (read src/eventsource/serialization/ for the canonical encode/decode entry points and use those, not raw json).


Task 11: SQLite adapter

Files:

Interfaces:


Task 12: PostgreSQL adapter with safe-horizon feed

Files:

Interfaces:


SELECT ... FROM events
WHERE global_position > :from_position
  AND xmin::text::bigint < pg_snapshot_xmin(pg_current_snapshot())::text::bigint
ORDER BY global_position ASC
LIMIT :limit

Rationale comment to include verbatim: rows whose inserting transaction is not yet definitely-committed (xmin β‰₯ snapshot xmin) are deferred to a later poll β€” the sequence commits out of order, and reading past a still-uncommitted lower position would skip it forever once the reader resumes from higher up. Uses the xmin system column: no DDL, schema untouched. Caveat: epoch comparison is not wraparound-proof in the ancient-xid regime; acceptable for now, revisit if a xid8 column is ever added.

No-skip integration test (the mutation-killer for the horizon predicate):


# tests/integration/adapters/test_postgresql_no_skip.py  (marker: postgres)
# Two concurrent writers: writer A begins a transaction, inserts (acquiring
# global_position N), and parks pre-commit on an asyncio.Event; writer B then
# inserts and commits (position N+1). Reader reads the feed: must NOT see N+1
# while N is uncommitted (horizon holds it back). Release A, commit; reader
# resumes from its checkpoint: sees N then N+1. Assert no event lost, order
# by position. Drive writer A with a raw asyncpg/sqlalchemy connection held
# open across an explicit begin(); park with anyio/asyncio primitives, and
# put a hard timeout (asyncio.wait_for, 10s) around the whole test.

Write this as a real test β€” the comment above is the specification of its choreography; every step in it becomes code.


Task 13: Legacy compatibility wrapper (`stores/legacy.py`)

Files:

Interfaces:


Task 14: Snapshot adapters, top-level exports, gate wiring

Files:


Final Gate (orchestrator, not a task)