From eedfe77ac36fae2eda674d25c69e30803fa9771b Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Sat, 28 Nov 2026 12:07:47 -0500 Subject: [PATCH] Decouple NativeOwnerRegistry, delete Thread.wake_context forwarder, fix storage_room test --- src/agent_comms/context_segments/wake.py | 2 +- .../execution/native_input_owner.py | 15 +------------- .../registry/native_owner_registry.py | 20 +++++++++++++++++++ src/agent_comms/registry/registry_document.py | 2 +- src/agent_comms/registry/registry_privacy.py | 3 ++- src/agent_comms/registry/threads.py | 4 ---- tests/test_goals.py | 4 ++-- tests/test_storage_room.py | 2 +- tests/test_thread_identity.py | 4 ++-- tests/test_wake_goal_execution.py | 4 ++-- 10 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 src/agent_comms/registry/native_owner_registry.py diff --git a/src/agent_comms/context_segments/wake.py b/src/agent_comms/context_segments/wake.py index eb654fee93..500f55bf75 100644 --- a/src/agent_comms/context_segments/wake.py +++ b/src/agent_comms/context_segments/wake.py @@ -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, ...]: diff --git a/src/agent_comms/execution/native_input_owner.py b/src/agent_comms/execution/native_input_owner.py index 2bcf6dd732..db75421e9b 100644 --- a/src/agent_comms/execution/native_input_owner.py +++ b/src/agent_comms/execution/native_input_owner.py @@ -7,7 +7,6 @@ from __future__ import annotations import os -from abc import abstractmethod from dataclasses import dataclass from typing import TYPE_CHECKING, ClassVar @@ -27,7 +26,7 @@ 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: @@ -35,18 +34,6 @@ 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 diff --git a/src/agent_comms/registry/native_owner_registry.py b/src/agent_comms/registry/native_owner_registry.py new file mode 100644 index 0000000000..a613615814 --- /dev/null +++ b/src/agent_comms/registry/native_owner_registry.py @@ -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: ... diff --git a/src/agent_comms/registry/registry_document.py b/src/agent_comms/registry/registry_document.py index cb520556b9..6b03138733 100644 --- a/src/agent_comms/registry/registry_document.py +++ b/src/agent_comms/registry/registry_document.py @@ -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, diff --git a/src/agent_comms/registry/registry_privacy.py b/src/agent_comms/registry/registry_privacy.py index b495b84c2a..234afed9ad 100644 --- a/src/agent_comms/registry/registry_privacy.py +++ b/src/agent_comms/registry/registry_privacy.py @@ -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, diff --git a/src/agent_comms/registry/threads.py b/src/agent_comms/registry/threads.py index 66d3e52910..e949bf0f55 100644 --- a/src/agent_comms/registry/threads.py +++ b/src/agent_comms/registry/threads.py @@ -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 @@ -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: diff --git a/tests/test_goals.py b/tests/test_goals.py index 6e67b10394..046b294ace 100644 --- a/tests/test_goals.py +++ b/tests/test_goals.py @@ -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)) @@ -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, ) diff --git a/tests/test_storage_room.py b/tests/test_storage_room.py index 4d9bbde507..0b7da0acf3 100644 --- a/tests/test_storage_room.py +++ b/tests/test_storage_room.py @@ -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 diff --git a/tests/test_thread_identity.py b/tests/test_thread_identity.py index 03ea01792d..d90df5c8a1 100644 --- a/tests/test_thread_identity.py +++ b/tests/test_thread_identity.py @@ -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 diff --git a/tests/test_wake_goal_execution.py b/tests/test_wake_goal_execution.py index 7689ce7363..ee92b8d31d 100644 --- a/tests/test_wake_goal_execution.py +++ b/tests/test_wake_goal_execution.py @@ -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 @@ -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