End a failed reconciler pass with the dependency error

The merge loop runs inside the TaskGroup that holds the --deep checks,
so a listing or page failure in the middle of a pass left the group as
an ExceptionGroup. The entry point catches Unavailable only: the pass
still exited with code 1, but through an uncaught traceback instead of
the reconcile.failed record. The pass now unwraps the group and raises
the Unavailable with its original cause; the API test fails the listing
on the second page of a deep apply pass and expects Unavailable.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
This commit is contained in:
Artyom
2026-10-30 06:31:46 +03:00
co-authored by Claude Opus 5.5
parent 8cd30488d2
commit 3b3cb5bd7f
3 changed files with 32 additions and 10 deletions
@@ -22,6 +22,7 @@ from messenger.attachments.domain.models import (
AttachmentStatus,
Quarantine,
)
from messenger.shared.application.errors import Unavailable
from messenger.shared.application.ports import Clock, Logger
type UnitOfWorkFactory = Callable[[], AttachmentsUnitOfWork]
@@ -104,18 +105,22 @@ class Pass:
async def run(self) -> None:
objects = aiter(self._objects())
item = await anext(objects, None)
async with asyncio.TaskGroup() as checks:
async for row in self._rows():
while item is not None and item.key < row.object_key:
try:
async with asyncio.TaskGroup() as checks:
async for row in self._rows():
while item is not None and item.key < row.object_key:
await self._orphan(item)
item = await anext(objects, None)
matched = item if item is not None and item.key == row.object_key else None
await self._row(row, matched, checks)
if matched is not None:
item = await anext(objects, None)
while item is not None:
await self._orphan(item)
item = await anext(objects, None)
matched = item if item is not None and item.key == row.object_key else None
await self._row(row, matched, checks)
if matched is not None:
item = await anext(objects, None)
while item is not None:
await self._orphan(item)
item = await anext(objects, None)
except* Unavailable as failed:
error = failed.exceptions[0]
raise error from error.__cause__
async def _timed[ResultT](self, name: str, step: Awaitable[ResultT]) -> ResultT:
started = monotonic()