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
4 changes: 0 additions & 4 deletions src/agent_comms/cli_bridges/antigravity_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ class AntigravityCatchUp(CatchUpReadingPhase, AntigravityReaderPhase):
pending: tuple[StatusUpdate, ...] = ()
latest_info: tuple[RuntimeInfoObserved, ...] = ()

def status(self, update: StatusUpdate) -> tuple[RuntimeUpdate, ...]:
self.pending = (update,)
return ()

def window_ended(self, session: AntigravitySession) -> tuple[RuntimeUpdate, ...]:
session.phase = AntigravityLive()
return (*self.latest_info, *self.pending)
Expand Down
4 changes: 0 additions & 4 deletions src/agent_comms/cli_bridges/claude_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,6 @@ def offered(self, update: OfferedToolsObserved) -> tuple[RuntimeUpdate, ...]:
self.latest_tools = (update,)
return ()

def status(self, update: StatusUpdate) -> tuple[RuntimeUpdate, ...]:
self.pending = (update,)
return ()

def window_ended(self, session: ClaudeSession) -> tuple[RuntimeUpdate, ...]:
session.phase = Live()
return (*self.latest_tools, *self.latest_info, *self.pending)
Expand Down
23 changes: 17 additions & 6 deletions src/agent_comms/cli_bridges/hook_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,31 @@ async def handle(self, service: MonitorService, peer: MonitorPeer) -> SessionRep
return reply


@dataclass(frozen=True)
class ReadGateRequest(ReadGateProgram, HookRequest[GatedCall], declared_name=ReadGateProgram.wire_name()):
class GatedHookRequest(HookRequest, declared_name=None):
"""A hook request decoded into a gated call via its declared event_type."""

def decode_event(self, comms: Comms, binding: Binding, output: ResidentHookOutput) -> GatedCall:
return self.event_type().of(self.payload, output=output, comms=comms, binding=binding)


@dataclass(frozen=True)
class ReadGateRequest(
GatedHookRequest,
ReadGateProgram,
HookRequest[GatedCall],
declared_name=ReadGateProgram.wire_name(),
):
def run_hook(self, event: GatedCall, comms: Comms, binding: Binding) -> None:
event.judge()


@dataclass(frozen=True)
class ReminderRequest(ReminderProgram, HookRequest[ReminderCall], declared_name=ReminderProgram.wire_name()):
def decode_event(self, comms: Comms, binding: Binding, output: ResidentHookOutput) -> ReminderCall:
return self.event_type().of(self.payload, output=output, comms=comms, binding=binding)

class ReminderRequest(
GatedHookRequest,
ReminderProgram,
HookRequest[ReminderCall],
declared_name=ReminderProgram.wire_name(),
):
def run_hook(self, event: ReminderCall, comms: Comms, binding: Binding) -> None:
event.warn(*event.take(comms, binding, event.completed()))

Expand Down
4 changes: 4 additions & 0 deletions src/agent_comms/cli_bridges/runtime_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ def runtime_info(self, update: RuntimeInfoObserved) -> tuple[RuntimeUpdate, ...]
class CatchUpReadingPhase(ReadingPhase):
"""A transcript reading phase that buffers catch-up updates before going live."""

def status(self, update: StatusUpdate) -> tuple[RuntimeUpdate, ...]:
self.pending = (update,)
return ()

def runtime_info(self, update: RuntimeInfoObserved) -> tuple[RuntimeUpdate, ...]:
self.latest_info = (update,)
return ()
Expand Down
9 changes: 3 additions & 6 deletions src/agent_comms/messaging/read_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ def in_targets(self, targets: Collection[str], snapshot: RegistryProvenance) ->
class NamedConversation(Conversation, declared_name=None):
"""A conversation whose identity does not depend on per-incarnation DM resolution."""

def recorded_keys(self, snapshot: RegistryProvenance) -> Iterable[Conversation]:
return (self,)

def resolved(self, snapshot: RegistryProvenance) -> Self:
return self

Expand All @@ -619,9 +622,6 @@ def scope(self, snapshot: RegistryProvenance) -> AllChannelDisplayScope:
def sql_keys(self, snapshot: RegistryProvenance):
return (('', ''),)

def recorded_keys(self, snapshot: RegistryProvenance):
return (self,)

def in_targets(self, targets: Collection[str], snapshot: RegistryProvenance) -> bool:
return True

Expand All @@ -636,9 +636,6 @@ def scope(self, snapshot: RegistryProvenance) -> ChannelDisplayScope:
def sql_keys(self, snapshot: RegistryProvenance) -> Iterable[tuple[str, str]]:
return ((self.target, ""),)

def recorded_keys(self, snapshot: RegistryProvenance) -> Iterable[Conversation]:
return (self,)

def in_targets(self, targets: Collection[str], snapshot: RegistryProvenance) -> bool:
return self.target in targets

Expand Down
2 changes: 1 addition & 1 deletion src/agent_comms/registry/thread_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self) -> None:
super().__init__("Registry creation identities collide.")


class CreationTime(float, WireValue, ABC):
class CreationTime(float, WireValue):
@abstractmethod
def distinct_from(self, used: Set[float]) -> CreationTime: ...

Expand Down
21 changes: 13 additions & 8 deletions src/agent_comms/registry/thread_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,18 @@ def in_view(self, visibility: RosterVisibility) -> bool:
return False


class ServiceThreadStatus(PublishingPresence, HiddenThreadStatus):
class UnrestorableThreadStatus(ThreadStatus, declared_name=None):
"""A thread status that remains unchanged when restoration is requested."""

def restored(self) -> ThreadStatus:
return self


class ServiceThreadStatus(
UnrestorableThreadStatus,
PublishingPresence,
HiddenThreadStatus,
):
"""A service can publish, but has no executable roster row or owner controls."""

def external_registered(self, thread: PresenceThread, now: float) -> ThreadStatus:
Expand All @@ -527,11 +538,8 @@ def external_registered(self, thread: PresenceThread, now: float) -> ThreadStatu
def after_heartbeat(self, name: str) -> ThreadStatus:
return self

def restored(self) -> ThreadStatus:
return self


class ArchivedThreadStatus(OrphansHolds, VacantThreadStatus):
class ArchivedThreadStatus(UnrestorableThreadStatus, OrphansHolds, VacantThreadStatus):

def require_checkout_adoption(self) -> None:
"""Only retired declarations can surrender their checkout grants."""
Expand All @@ -542,9 +550,6 @@ def is_archived(self) -> bool:
def in_view(self, visibility: RosterVisibility) -> bool:
return visibility.archived

def restored(self) -> ThreadStatus:
return self

def active_checkout_matches(self, thread):
return ()

Expand Down
3 changes: 1 addition & 2 deletions src/agent_comms/storage/maintenance_barrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from pathlib import Path
from typing import Annotated, ClassVar, Literal, Self

from agent_comms.coordination.errors import DrainUnavailable
from agent_comms.errors import RelationViolationError
from agent_comms.execution.process_identity import ProcessIdentity
from agent_comms.execution.launch_runtime import LaunchRuntime
Expand Down Expand Up @@ -47,7 +46,7 @@
from agent_comms_hooks import ToolRefusedError


class MaintenanceHeldError(RelationViolationError, ToolRefusedError, DrainUnavailable):
class MaintenanceHeldError(RelationViolationError, ToolRefusedError):
"""The bus is in maintenance: its readers close and wait for READY. A drain that meets
the hold is unavailable until maintenance ends, never stopped: an install must not fail
every unit whose inbox drains during its window."""
Expand Down
16 changes: 4 additions & 12 deletions src/agent_comms/storage/private_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ def accepts_links(cls, nlink: int) -> bool:
class DirectoryFilesystemRole(FilesystemRole, declared_name=None):
"""A filesystem role that requires and opens a directory."""

@classmethod
def kind_flags(cls) -> int:
return os.O_DIRECTORY

@classmethod
def accepts_kind(cls, mode: int) -> bool:
return stat.S_ISDIR(mode)
Expand Down Expand Up @@ -244,10 +248,6 @@ def require_private_tree(
cls.require(
directory.lstat(), refusal("Native Pi session directory must be owner-only"))

@classmethod
def kind_flags(cls) -> int:
return os.O_DIRECTORY


class PrivateSocketRole(NonBlockingFilesystemRole):
@classmethod
Expand All @@ -274,20 +274,12 @@ def address(cls, path: Path) -> Iterator[Path]:


class OwnedDirectoryRole(DirectoryFilesystemRole):
@classmethod
def kind_flags(cls) -> int:
return os.O_DIRECTORY

@classmethod
def accepts_permissions(cls, observed: os.stat_result) -> bool:
return True


class TrustedAncestorRole(DirectoryFilesystemRole):
@classmethod
def kind_flags(cls) -> int:
return os.O_DIRECTORY

@classmethod
def require_path(cls, directory: Path, refusal: Exception) -> None:
for ancestor in (directory, *directory.parents):
Expand Down
5 changes: 0 additions & 5 deletions src/agent_comms/storage/storage_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ def _open_reader(
connection.close()
raise

@classmethod
def schema_change(cls, path: Path) -> WriterOwnedFile:
"""The host-wide ledger is carried under its writer lock, outside any one bus."""
return WriterOwnedFile()

def dead_claims(self):
# Dead/replaced processes cannot hold room, but are never replayed.
with self.snapshot() as db:
Expand Down
7 changes: 1 addition & 6 deletions src/agent_comms/storage/typed_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3678,9 +3678,8 @@ def path(self) -> Path:
return self.path_in(self.root)

@classmethod
@abstractmethod
def schema_change(cls, path: Path) -> SchemaChange:
"""Whether this file's schema belongs to installation or its runtime."""
return WriterOwnedFile()

@classmethod
def declares_schema(cls) -> bool:
Expand Down Expand Up @@ -3730,10 +3729,6 @@ class DerivedStore(TypedStore, DerivedTables, RuntimeWriter):
file instead of rebuilding this one under the writer's lock.
"""

@classmethod
def schema_change(cls, path: Path) -> SchemaChange:
return WriterOwnedFile()

def __init_subclass__(cls, **kwargs: object) -> None:
super().__init_subclass__(**kwargs)
schema = json.dumps(cls.declared_schema(), sort_keys=True).encode()
Expand Down
2 changes: 1 addition & 1 deletion src/agent_comms/transport/tool_denial.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ class SelectedToolDenied(ToolRefusedError): # noqa: N818 - nominal fail-closed
"""A rejected request, including duplicate or uncertain prior consumption."""


class StorageDenied(SelectedToolDenied, ToolRefusedError): # noqa: N818 - existing nominal refusal
class StorageDenied(SelectedToolDenied): # noqa: N818 - existing nominal refusal
"""The storage preflight refused an operation before it executed, or found no room for it."""
Loading