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
2 changes: 1 addition & 1 deletion src/agent_comms/context_segments/wake.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def capture(cls, sources, owner, goals, *, obligations=(), sent_outcomes=()):
obligations=tuple(obligations),
relevance=relevance,
sent_outcomes=sent_outcomes,
work_context=owner.wake_context(goals),
work_context=goals.wake_context(owner),
)

def input_segments(self, files: tuple[MessageFile, ...]) -> tuple[ContextSegment, ...]:
Expand Down
15 changes: 1 addition & 14 deletions src/agent_comms/execution/native_input_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import annotations

import os
from abc import abstractmethod
from dataclasses import dataclass
from typing import TYPE_CHECKING, ClassVar

Expand All @@ -27,26 +26,14 @@
from agent_comms.execution.turn_lease import TurnLeaseFence
from agent_comms.nominal.field_codec import GoalId, ThreadLookup
from agent_comms.planning.goals import Goal
from agent_comms.registry.claim_generation_read import ClaimGenerationRead
from agent_comms.registry.native_owner_registry import NativeOwnerRegistry
from agent_comms.registry.threads import NativeThread, Thread

if TYPE_CHECKING:
from agent_comms.registry.registration import Registration
from agent_comms.registry.registry_document import RegistrySnapshot


class NativeOwnerRegistry(ClaimGenerationRead):
"""The original locked namespace reads needed to capture local executable authority."""

__slots__ = ()

@abstractmethod
def require_active(self, name: str) -> Thread: ...

@abstractmethod
def require_member[Kind: Thread](self, name: str, kind: type[Kind]) -> Kind: ...


@dataclass(frozen=True, kw_only=True)
class RegistryOwner:
check_type: ClassVar[type[RegistryIdentityCheck]] = GoalRegistryClaimCheck
Expand Down
20 changes: 20 additions & 0 deletions src/agent_comms/registry/native_owner_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Original locked-namespace read contract for capturing local executable authority."""

from __future__ import annotations

from abc import abstractmethod

from agent_comms.registry.claim_generation_read import ClaimGenerationRead
from agent_comms.registry.threads import Thread


class NativeOwnerRegistry(ClaimGenerationRead):
"""The original locked namespace reads needed to capture local executable authority."""

__slots__ = ()

@abstractmethod
def require_active(self, name: str) -> Thread: ...

@abstractmethod
def require_member[Kind: Thread](self, name: str, kind: type[Kind]) -> Kind: ...
2 changes: 1 addition & 1 deletion src/agent_comms/registry/registry_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from agent_comms.errors import OutsideRegistrySlice, RelationViolationError, UnregisteredThreadError
from agent_comms.execution.process_identity import ProcessIdentity
from agent_comms.execution.input_ingress import InputRegistry
from agent_comms.execution.native_input_owner import NativeOwnerRegistry
from agent_comms.registry.native_owner_registry import NativeOwnerRegistry
from agent_comms.execution.restart_refusals import (
OwnerBusyRefusal,
OwnerChangedBeforeFenceRefusal,
Expand Down
3 changes: 2 additions & 1 deletion src/agent_comms/registry/registry_privacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from agent_comms.errors import RelationViolationError
from agent_comms.execution.host_platform import HostPlatform
from agent_comms.execution.input_root_authority import InputRootAuthority
from agent_comms.execution.native_input_owner import NativeOwnerRegistry, RegistryOwner
from agent_comms.execution.native_input_owner import RegistryOwner
from agent_comms.registry.native_owner_registry import NativeOwnerRegistry
from agent_comms.execution.native_runtime_input import NativeRuntimeInput, NativeRuntimeTable
from agent_comms.execution.private_nk_entrypoint import (
PrivateNkLaunch,
Expand Down
4 changes: 0 additions & 4 deletions src/agent_comms/registry/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from typing import Annotated, ClassVar, Protocol

from agent_comms.agent_backend import AgentBackend, NewThreadBackend, RuntimeLocation
from agent_comms.context_segments.wake_values import WakeWorkContext, WakeWorkSource
from agent_comms.errors import RelationViolationError
from agent_comms.execution.process_identity import NoProcess, ProcessIdentity, ProcessState
from agent_comms.execution.cli_inbox_backend import CliInboxBackend
Expand Down Expand Up @@ -918,9 +917,6 @@ def require_turn(self, turn_id: TurnId, claim_scope: int) -> None:
def task_scope(self) -> TaskScope:
return TaskScope.for_goal(self.worktree, self.goal)

def wake_context(self, goals: WakeWorkSource[Thread]) -> WakeWorkContext:
return goals.wake_context(self)

def continuation_goal(self, original: Thread) -> GoalDeclaration:
"""The current active goal still belongs to this captured project/goal."""
if self.worktree != original.worktree:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_goals.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def stored() -> Thread:

def absent(thread: Thread) -> None:
assert thread.goal == NoGoal()
context = thread.wake_context(comms.goals)
context = comms.goals.wake_context(thread)
assert isinstance(context.current_goal, NoWakeGoalContext)
assert FieldCodec.encode(context)["current_goal"] is None
assert thread.task_scope == TurnTaskScope(project=Checkout(tmp_path))
Expand All @@ -108,7 +108,7 @@ def absent(thread: Thread) -> None:
goal = comms.goals.update_goal("worker", SetGoalAction(text="Ship the release"))
thread = stored()
assert thread.goal.require() == thread.goal.require().require_id(goal.id) == goal
context = thread.wake_context(comms.goals)
context = comms.goals.wake_context(thread)
assert context.current_goal == WakeGoalContext(
text="Ship the release", execution=comms.goals.goal_execution(thread.name), progress=goal.progress,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_storage_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def test_a_run_without_room_is_refused_with_the_numbers(tmp_path, monkeypa
one, two = (comms.registry.require(name) for name in ('gate-one', 'gate-two'))
first = await rule.wait_for_room((BuildRoomWork,), one, comms.root)
try:
with pytest.raises(StorageDenied, match=r"no room for unit_start after 0s: .*other runs hold: gate-one \(build\)"):
with pytest.raises(StorageDenied, match=r"no room for Unit Start after 0s: .*other runs hold: gate-one \(Build\)"):
await asyncio.wait_for(rule.wait_for_room((UnitStartRoomWork,), two, comms.root), 2)
with rule.room_ledger.snapshot() as db:
assert RoomClaim.count(db) == 1 # the refused waiter's claim is gone
Expand Down
4 changes: 2 additions & 2 deletions tests/test_thread_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def test_saved_thread_text_round_trips_null_and_supplied_values(tmp_path):
saved = wire(tmp_path).registry.require(name)
assert json.dumps(FieldCodec.encode(saved), sort_keys=True, separators=(",", ":")) == encoded
assert saved.title == title and saved.task == task
assert FieldCodec.encode(saved.wake_context(comms.goals))["title"] == FieldCodec.encode(title)
assert FieldCodec.encode(saved.wake_context(comms.goals))["original_assignment"] == FieldCodec.encode(task)
assert FieldCodec.encode(comms.goals.wake_context(saved))["title"] == FieldCodec.encode(title)
assert FieldCodec.encode(comms.goals.wake_context(saved))["original_assignment"] == FieldCodec.encode(task)
assert saved.launch().task == task


Expand Down
4 changes: 2 additions & 2 deletions tests/test_wake_goal_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def owner(tmp_path: Path) -> Comms:
def assert_owned_status[Execution: GoalExecution](comms: Comms, expected: type[Execution]) -> Execution:
thread = comms.registry.require("worker")
snapshot = comms.goals.goal_snapshot(thread.name)
context = thread.wake_context(comms.goals)
context = comms.goals.wake_context(thread)
encoded = FieldCodec.encode(context)
assert encoded["current_goal"]["status"] == FieldCodec.encode(snapshot.execution)
assert FieldCodec.decode(WakeWorkContext, encoded) == context
Expand Down Expand Up @@ -84,6 +84,6 @@ def test_native_wake_uses_the_effective_execution_family(

def test_absent_goal_keeps_its_declared_null_context(owner: Comms) -> None:
owner.goals.update_goal("worker", ClearGoalAction())
context = owner.registry.require("worker").wake_context(owner.goals)
context = owner.goals.wake_context(owner.registry.require("worker"))
assert isinstance(context.current_goal, NoWakeGoalContext)
assert FieldCodec.encode(context)["current_goal"] is None
Loading