Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/agent_comms/cli_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
from pydantic_core import CoreSchema
from typing_extensions import TypeForm

from .coordination_errors import CoordinationError, CoordinationReadUnavailable
from .coordination_errors import CommandFailure, CoordinationReadUnavailable
from .declared_family import DeclaredFamily, UnknownFamilyMember
from .external_transcript import RequestedEarlierPage
from .field_codec import FieldCodec, TimestampText
from .maintenance_barrier import MaintenanceHeldError
from .messages import Message
from .recorded_time import UnrecordedTimeError
from .repo import GitCommandError
from .turn_item import NativeTurnId, TurnItem
from .wire_models import DeclaredWireFamily, WireModel

Expand All @@ -43,7 +42,7 @@
from .cli_bridges.shared import BindingThread, CliBridge, DeliveryRow


CLI_FAILURES = (ValueError, OSError, CoordinationError, GitCommandError)
CLI_FAILURES = (ValueError, OSError, CommandFailure)


async def raise_child_exit(child: AttachedChild, reason: str) -> NoReturn:
Expand Down
6 changes: 5 additions & 1 deletion src/agent_comms/coordination_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ class DrainDeferred(Exception): # noqa: N818 - capability, not an outcome
"""A failure an inbox drain records and retries later instead of stopping on."""


class CommandFailure(Exception): # noqa: N818 - capability, not an outcome
"""A failure a command reports to its caller as a failed result instead of crashing."""


class DrainUnavailable(DrainDeferred):
"""A failure meaning the drain's store or coordinator is unavailable right now."""


class CoordinationError(RuntimeError, DrainUnavailable):
class CoordinationError(RuntimeError, DrainUnavailable, CommandFailure):
"""Base class for fail-loud coordinator errors."""

def __reduce__(self):
Expand Down
5 changes: 3 additions & 2 deletions src/agent_comms/registry_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,10 @@ def bind(self, binding: Callable[[Thread], Thread]) -> None:

def __eq__(self, other: object) -> bool:
"""Rows still stored on both sides compare as their JSON; only rows that differ there,
or that either side wrote, are decoded, so a one-row edit never decodes the registry."""
or that either side wrote, are decoded, so a one-row edit never decodes the registry.
Rows equal only rows: a plain mapping is a different value."""
if not isinstance(other, ThreadRows):
return super().__eq__(other)
return NotImplemented
return self.keys() == other.keys() and all(
(name in self._raw and name in other._raw and self._raw[name] == other._raw[name])
or self[name] == other[name]
Expand Down
3 changes: 2 additions & 1 deletion src/agent_comms/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from pydantic import BaseModel, ConfigDict, InstanceOf, PlainSerializer, PlainValidator

from .coordination_errors import CommandFailure
from .declared_family import DeclaredFamily
from .errors import MissingSourceLine
from .field_codec import FieldCodec, WireValue
Expand All @@ -34,7 +35,7 @@ def founding(self, commander: str) -> tuple[Repo, ...]: ...
def without_commander(self) -> None: ...


class GitCommandError(RuntimeError):
class GitCommandError(RuntimeError, CommandFailure):
"""A Git operation failure, not malformed order data to aggregate and continue past."""

def __init__(self, repository: str, run: subprocess.CompletedProcess[bytes]):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_registration_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_edit_owns_turn_and_document_owns_later_changes(tmp_path, *, thread_regi
document.unregister("renamed")
document.begin_delete("renamed")
assert document.remove("renamed") == ()
assert document.threads == {}
assert not document.threads
assert not list(tmp_path.iterdir())


Expand Down
Loading