Skip to content
Closed
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: 2 additions & 2 deletions src/agent_comms/acp_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class NoCursorScope(CursorScope):
class LiveCursorScope(CursorScope, LiveAttachmentScope):
session_id: str
wire_root_id: str
claim_scope: Annotated[ClaimedIdentity, WireName("admission")]
claim_scope: ClaimedIdentity
owner_pid: int

def __post_init__(self):
Expand Down Expand Up @@ -446,7 +446,7 @@ class NoQueueScope(QueueScope):
@dataclass(frozen=True)
class LiveQueueScope(QueueScope, LiveAttachmentScope):
session_id: str
claim_scope: Annotated[ClaimedIdentity, WireName("admission")]
claim_scope: ClaimedIdentity
owner_pid: int

@property
Expand Down
8 changes: 3 additions & 5 deletions src/agent_comms/envelope_claim_transitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ def held_at(self, claimed_generation: int) -> bool:
class RecordedScope(ClaimScope, declared_name=None):
"""Every acquisition published today records the input generation and operation it serves."""

owner_claimed_generation: Annotated[
int, WireName("owner_admission_generation")
]
owner_claimed_generation: int
operation_id: Annotated[str, Id128Text]
turn_id: str

Expand Down Expand Up @@ -274,7 +272,7 @@ class ClaimIdentity:
@dataclass(frozen=True)
class AcquiringClaim(ClaimIdentity):
generation: Annotated[str, Id128Text]
claim_scope: Annotated[ClaimScope, WireName("admission")]
claim_scope: ClaimScope


@dataclass(frozen=True)
Expand Down Expand Up @@ -390,7 +388,7 @@ def project(self, previous: ClaimProjection) -> ClaimProjection:
class WakeClaims(RecordMember, Acquisition, AcquiringClaim):
"""An acquisition published today; its row records the scope it serves."""

claim_scope: Annotated[RecordedScope, WireName("admission")]
claim_scope: RecordedScope


@dataclass(frozen=True)
Expand Down
6 changes: 2 additions & 4 deletions src/agent_comms/goal_failure_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import TYPE_CHECKING, Annotated

from .diagnostics import FailureReason
from .field_codec import Id128Text, WireName
from .field_codec import Id128Text
from .goal_attempt_identity import GoalAttemptIdentity
from .thread_identity import (
ClaimedIdentity,
Expand Down Expand Up @@ -56,9 +56,7 @@ class FailedTurnEvidence(GoalLedgerTable, TypedTable, GoalFailureEvidence):
owner: str
owner_created_at: float
worktree: str
claim_scope: Annotated[
int, WireName("admission"), Column(record_key=True, check="{claim_scope}>0")
]
claim_scope: Annotated[int, Column(record_key=True, check="{claim_scope}>0")]
turn_generation: Annotated[int, Column(check="turn_generation>0")]
goal_revision: Annotated[int, Column(check="goal_revision>=0")]
turn_id: Annotated[str, Column(unique=True, check="length(turn_id)=32")]
Expand Down
2 changes: 1 addition & 1 deletion src/agent_comms/input_attempt.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def require_original_provenance(self, source: InputProvenance):
key: str
sequence: int | None
owner: str
claim_scope: Annotated[int, WireName("admission")]
claim_scope: int
target: str
source_text: str
origin: Annotated[InputOrigin, WireOmitDefault()] = field(
Expand Down
4 changes: 2 additions & 2 deletions src/agent_comms/input_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .bus_publication import HumanOrigin
from .declared_family import DeclaredFamily
from .errors import RelationViolationError
from .field_codec import Id128Text, WireName
from .field_codec import Id128Text
from .goals import GoalCheckpoint
from .message_reference import MessageReference
from .thread_identity import ClaimedIdentity
Expand Down Expand Up @@ -120,7 +120,7 @@ class HumanInputOrigin(InputOrigin):

root_id: Annotated[str, Id128Text]
author: HumanOrigin
claim_scope: Annotated[ClaimedIdentity, WireName("admission")]
claim_scope: ClaimedIdentity
project: str
goal: GoalCheckpoint

Expand Down
4 changes: 1 addition & 3 deletions src/agent_comms/native_runtime_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from agent_comms.private_runtime_schema import PrivateCoordinatorTable

from .coordination_errors import IdentityConflict, PublicationActivationBlocked, StaleFence
from .field_codec import FieldCodec, MalformedRecord, NativeContext, WireName
from .field_codec import FieldCodec, MalformedRecord, NativeContext
from .native_claim_epoch import NativeClaimEpoch, UnrecordedNativeClaim
from .native_input_record import (
NativeColumn,
Expand Down Expand Up @@ -264,7 +264,6 @@ def published_replies(self, db, user, owner_lookup):
owner_token_digest: Annotated[str, FrozenColumn(check="length(owner_token_digest)=64")]
sent_owner_claimed_generation: Annotated[
NativeClaimEpoch,
WireName("sent_owner_admission_generation"),
Column(
record_key=True,
check="{sent_owner_claimed_generation}>0",
Expand Down Expand Up @@ -366,7 +365,6 @@ def context_anchor(self) -> NativeColumn:
owner_generation: Annotated[int, FrozenColumn(primary_key=True, check="owner_generation>0")]
owner_claimed_generation: Annotated[
int,
WireName("owner_admission_generation"),
FrozenColumn(record_key=True, primary_key=True, check="{owner_claimed_generation}>0"),
]

Expand Down
3 changes: 1 addition & 2 deletions src/agent_comms/owner_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typing import TYPE_CHECKING, Annotated
from uuid import uuid4

from agent_comms import field_codec

from .active_route import resolve_comms_route
from agent_comms.attempt_recovery import RecoveryMonitorCapability
Expand Down Expand Up @@ -95,7 +94,7 @@ def record_first_input(self, record) -> None:
class OwnerRestartSelection:
identity: OwnerIdentity
process: ProcessIdentity
claimed_generation: Annotated[int, field_codec.WireName("admission_generation")]
claimed_generation: int
interpreter: str

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions src/agent_comms/queued_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from contextlib import AsyncExitStack, ExitStack, asynccontextmanager
from dataclasses import dataclass, field, replace
from functools import partial
from typing import TYPE_CHECKING, Any, Generic, Self, TypeVar, Annotated
from typing import TYPE_CHECKING, Any, Generic, Self, TypeVar

from acp import RequestError

Expand All @@ -24,7 +24,7 @@
from .coordination_session import ReadNativeCoordinationSession
from .coordinator import Coordination
from .errors import RelationViolationError
from .field_codec import Id128Text, WireName
from .field_codec import Id128Text
from .goals import GoalDeclaration, NoGoal
from .image_inputs import ImageInput
from .input_attempt import InputAttempt, ReservedInput
Expand Down Expand Up @@ -55,7 +55,7 @@ class InputHandoffRefused(RelationViolationError):

@dataclass(frozen=True, slots=True)
class QueuedInputContext:
claim_scope: Annotated[ClaimedIdentity, WireName("admission")]
claim_scope: ClaimedIdentity
goal: GoalDeclaration = field(default_factory=NoGoal)

@classmethod
Expand Down
7 changes: 3 additions & 4 deletions src/agent_comms/registry_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
MalformedRecord,
FieldPlan,
SlicePolicy,
WireName,
WireRequired,
)
from .registration_change import (
Expand Down Expand Up @@ -322,9 +321,9 @@ class RegistryDocument(RegistryPresence[dict[str, ThreadStatus]]):
owners: Annotated[GenerationCounter, SlicePolicy(GenerationOf)] = field(
default_factory=GenerationCounter
)
claims: Annotated[
GenerationCounter, WireName("admissions"), SlicePolicy(GenerationOf)
] = field(default_factory=GenerationCounter)
claims: Annotated[GenerationCounter, SlicePolicy(GenerationOf)] = field(
default_factory=GenerationCounter
)

_human: UserThreadLookup[str] = field(init=False, repr=False, compare=False)

Expand Down
8 changes: 4 additions & 4 deletions src/agent_comms/selected_write_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from contextlib import suppress
from dataclasses import dataclass, fields
from pathlib import Path
from typing import TYPE_CHECKING, Literal, Annotated
from typing import TYPE_CHECKING, Literal

from .coordination_database import CoordinationStore
from .locked_store import DurableFile, PatternFile
Expand All @@ -32,7 +32,7 @@
from .coordination_cohort import sealed_cohort_assignments
from .declared_family import DeclaredFamily
from .envelope_claim_transitions import ExistingFileClaim
from .field_codec import FieldCodec, Id128Text, MalformedRecord, WireName
from .field_codec import FieldCodec, Id128Text, MalformedRecord
from .message_reference import MessageReference
from .private_path import PrivateDirectoryRole, PrivateFileRole, fsync_directory
from .thread_identity import ClaimedIdentity, RecordedThreadIncarnation
Expand All @@ -53,7 +53,7 @@ class SelectedWriteBinding:
root_id: str
source: MessageReference
assignment_id: str
claim_scope: Annotated[ClaimedIdentity, WireName("admission")]
claim_scope: ClaimedIdentity


@dataclass(frozen=True, kw_only=True)
Expand All @@ -68,7 +68,7 @@ class SelectedWriteIntent(DeclaredFamily, affix="WriteIntent"):
claim_id: str
owner: str
incarnation: float
claim_epoch: Annotated[int, WireName("admission_epoch")]
claim_epoch: int
expected_attempt_ordinal: Literal[1]
operation_id: str
resource: str
Expand Down
7 changes: 3 additions & 4 deletions src/agent_comms/thread_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections.abc import Iterable
from dataclasses import dataclass, field, replace
from functools import cached_property
from typing import TYPE_CHECKING, Callable, ClassVar, Self, TypeVar, Annotated
from typing import TYPE_CHECKING, Callable, ClassVar, Self, TypeVar

from metaclass_registry import AutoRegisterMeta, RegistryConfig

Expand All @@ -23,7 +23,6 @@
from .field_codec import (
FieldCodec,
WireValue,
WireName,
)
from .response_policy import CollectivePolicy, InformationalPolicy, ResponsePolicy

Expand Down Expand Up @@ -350,7 +349,7 @@ class ClaimedIdentity:
"""A registry-allocated input generation, never an owner lease."""

incarnation: ThreadIncarnation
claimed_generation: Annotated[int, WireName("admission_generation")]
claimed_generation: int

def includes(self, previous: ClaimedIdentity) -> bool:
"""Compare order only within this registry's input-generation counter."""
Expand Down Expand Up @@ -381,7 +380,7 @@ class TurnFence:

identity: TurnIdentity
turn_id: str
claimed_generation: Annotated[int, WireName("admission_generation")]
claimed_generation: int

def renamed(self, name: str) -> Self:
"""Registry alias resolution changes the name, never incarnation or epochs."""
Expand Down
5 changes: 1 addition & 4 deletions src/agent_comms/turn_lease.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
RecordMember,
SingleFieldValue,
SubclassUnion,
WireName,
WireTransient,
boundary_decoder,
)
Expand Down Expand Up @@ -212,9 +211,7 @@ class ActiveTurn(Executing, RecordMember, TurnDeclaration):
owner_pid: int
started_at: float = field(default_factory=time.time)
routing: TurnRouting | None = None
claimed_generation: Annotated[
TurnGeneration, WireName("admission_generation")
] = UnrecordedGeneration()
claimed_generation: TurnGeneration = UnrecordedGeneration()
turn_generation: TurnGeneration = UnrecordedGeneration()
phase: TurnPhase = field(default_factory=PreparingPhase)
def execution(self, source: GoalExecutionSource) -> GoalExecution:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_envelope_claim_transitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ def test_selected_wake_binding_survives_claim_projection(tmp_path):
message = Message("owner", "owner", "Claim file", ClaimNoticeKind, seq=8, timestamp=1.0)
bound = ClaimMessage.of(message, replace(claimed, message_id=message.message_id))
assert Message.from_wire(bound.to_wire()) == bound
admission_key = FieldCodec.record_key(WakeClaims, "claim_scope")
invalid = {**raw, admission_key: {**raw[admission_key], "version": 99}}
scope_key = FieldCodec.record_key(WakeClaims, "claim_scope")
invalid = {**raw, scope_key: {**raw[scope_key], "version": 99}}
with pytest.raises(ValueError):
FieldCodec.decode(ClaimTransition, invalid)
null_claim = raw.copy()
null_claim[admission_key] = None
null_claim[scope_key] = None
with pytest.raises(ValueError):
FieldCodec.decode(ClaimTransition, null_claim)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_registry_current_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_incomplete_saved_identity_cannot_authorize_an_owner(tmp_path):
registry = Registration(path)
registry.register(registry.new_thread('owner', frozenset(), str(tmp_path), process_identity=ProcessIdentity.capture(os.getpid())))
raw = json.loads(path.read_text())
for field in ("owners", "admissions"):
for field in ("owners", "claims"):
incomplete = dict(raw)
incomplete.pop(field)
path.write_text(json.dumps(incomplete))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unscoped_claim_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ def test_unscoped_history_row_decodes_projects_never_live_and_releases(tmp_path)

# A row published today records its scope; history rows carry none.
with pytest.raises(MalformedRecord):
FieldCodec.decode(ClaimTransition, {**stored, "admission": None})
FieldCodec.decode(ClaimTransition, {**stored, "claim_scope": None})
scoped = FieldCodec.encode(taken[resource])
assert scoped["admission"]["operation_id"] == "c" * 32
assert scoped["claim_scope"]["operation_id"] == "c" * 32