From 26383dc21a07f02f9bad76a6f77fe0e0b8b3fbe4 Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Sat, 28 Nov 2026 08:26:14 -0500 Subject: [PATCH] Split execution/process_identity.py and async_retirement.py out of child_process.py --- src/agent_comms/acp_extension.py | 2 +- src/agent_comms/agent_backend.py | 2 +- src/agent_comms/cli_bridges/codex.py | 2 +- src/agent_comms/cli_bridges/hook_session.py | 2 +- src/agent_comms/cli_bridges/inbox_watch.py | 2 +- .../cli_bridges/model_agent_client.py | 2 +- src/agent_comms/cli_bridges/monitor.py | 2 +- src/agent_comms/cli_bridges/opencode.py | 2 +- src/agent_comms/cli_bridges/shared.py | 8 +- src/agent_comms/cli_verbs/attach_session.py | 2 +- src/agent_comms/cli_verbs/cli_commands.py | 2 +- src/agent_comms/cli_verbs/register.py | 2 +- .../coordination/attempt_recovery.py | 2 +- src/agent_comms/coordination/coordinator.py | 2 +- .../optional_awareness_projection.py | 2 +- src/agent_comms/coordination/work.py | 2 +- src/agent_comms/execution/acp.py | 2 +- src/agent_comms/execution/antigravity_acp.py | 4 +- .../execution/antigravity_backend.py | 2 +- src/agent_comms/execution/async_retirement.py | 63 ++ src/agent_comms/execution/child_process.py | 915 +---------------- src/agent_comms/execution/diagnostics.py | 4 +- src/agent_comms/execution/goal_scheduler.py | 3 +- src/agent_comms/execution/host_platform.py | 14 +- src/agent_comms/execution/input_drain.py | 2 +- src/agent_comms/execution/native_child.py | 10 +- .../execution/native_input_owner.py | 2 +- .../execution/native_session_files.py | 8 +- src/agent_comms/execution/native_startup.py | 2 +- src/agent_comms/execution/nk_foreground.py | 2 +- src/agent_comms/execution/owner_lifecycle.py | 4 +- .../execution/persistent_pi_session.py | 2 +- src/agent_comms/execution/process_identity.py | 949 ++++++++++++++++++ src/agent_comms/execution/queued_input.py | 2 +- .../execution/registry_identity_rules.py | 2 +- .../execution/remote_core_process.py | 3 +- .../execution/request_diagnostics.py | 2 +- src/agent_comms/execution/request_progress.py | 2 +- src/agent_comms/execution/restart_queue.py | 8 +- src/agent_comms/execution/root_host_store.py | 10 +- .../execution/root_runtime_read.py | 18 +- .../execution/runtime_processes.py | 6 +- .../execution/session_config_options.py | 2 +- .../execution/session_lifecycle.py | 3 +- src/agent_comms/execution/session_tasks.py | 2 +- src/agent_comms/execution/test_lease.py | 2 +- src/agent_comms/execution/turn_lease.py | 2 +- src/agent_comms/execution/turn_phase.py | 2 +- src/agent_comms/execution/turn_runner.py | 2 +- src/agent_comms/execution/watch_passes.py | 2 +- src/agent_comms/execution/worker/__main__.py | 9 +- src/agent_comms/host_services/__init__.py | 3 +- src/agent_comms/installer/building_runtime.py | 2 +- .../installer/interpreter_operation.py | 4 +- src/agent_comms/planning/goal_actions.py | 2 +- src/agent_comms/projects/integration.py | 3 +- src/agent_comms/projects/storage_rules.py | 2 +- src/agent_comms/registry/owner_release.py | 2 +- src/agent_comms/registry/presence_reads.py | 2 +- src/agent_comms/registry/registration.py | 2 +- .../registry/registration_change.py | 2 +- src/agent_comms/registry/registry_document.py | 2 +- src/agent_comms/registry/registry_store.py | 4 +- .../registry/thread_configuration.py | 2 +- src/agent_comms/registry/thread_identity.py | 2 +- src/agent_comms/registry/thread_management.py | 2 +- .../registry/thread_presentation.py | 2 +- src/agent_comms/registry/thread_status.py | 2 +- src/agent_comms/registry/threads.py | 2 +- .../resources/directory_queries.py | 6 +- .../storage/maintenance_barrier.py | 2 +- src/agent_comms/storage/storage_room.py | 2 +- src/agent_comms/team/standing_rules.py | 2 +- src/agent_comms/thread_views.py | 2 +- src/agent_comms/transport/attachment_scope.py | 2 +- src/agent_comms/transport/background_runs.py | 8 +- src/agent_comms/transport/connector.py | 4 +- .../transport/native_tool_transport.py | 2 +- src/agent_comms/transport/owner_connection.py | 2 +- src/agent_comms/transport/owner_requests.py | 4 +- .../transport/serving/owner_launch.py | 2 +- src/agent_comms/transport/tool_request.py | 3 +- src/agent_comms/transport/tools/commands.py | 2 +- src/agent_comms/transport/tools/sidebar.py | 2 +- src/agent_comms/ui_model/observation.py | 2 +- .../ui_model/observation_service.py | 3 +- stack/test-native-global-extensions.py | 2 +- tests/bus_record_fixture.py | 2 +- tests/native_backend_fixture.py | 6 +- tests/owner_socket_fixture.py | 6 +- tests/process_pool_child.py | 7 +- tests/process_tree_fixture.py | 2 +- tests/registration_lifecycle_child.py | 2 +- tests/restart_fixture.py | 2 +- tests/test_acp.py | 2 +- tests/test_acp_extension.py | 2 +- tests/test_acp_private_nk_delivery.py | 2 +- tests/test_acp_queue_contract.py | 2 +- tests/test_acp_selected_write_plan.py | 2 +- tests/test_active_turn.py | 2 +- tests/test_activity_text.py | 2 +- tests/test_agent_backend.py | 2 +- tests/test_agent_settings.py | 2 +- tests/test_antigravity_acp_backend.py | 20 +- tests/test_atomic_turn_source_owner.py | 2 +- tests/test_backend_native_child.py | 5 +- tests/test_background_runs.py | 8 +- tests/test_board_freshness.py | 5 +- tests/test_bridge_reader_lifetime.py | 2 +- tests/test_building_runtime.py | 2 +- tests/test_bus_async_retirement.py | 3 +- tests/test_bus_resource_claims.py | 2 +- tests/test_carry.py | 2 +- tests/test_channel_coding_tools.py | 2 +- tests/test_channels.py | 5 +- tests/test_check_root.py | 2 +- tests/test_child_process.py | 12 +- tests/test_claim_admission_verifier.py | 2 +- tests/test_claim_bus_read.py | 2 +- tests/test_cli.py | 2 +- tests/test_cli_inbox_switch.py | 2 +- tests/test_coordinated_runtime.py | 2 +- tests/test_coordination_response.py | 2 +- tests/test_declarations.py | 5 +- tests/test_deferral_guard.py | 2 +- tests/test_dm_scoped_ack.py | 2 +- tests/test_dm_scoped_ack_successor.py | 2 +- tests/test_envelope_bus_integration.py | 2 +- tests/test_envelope_claim_transitions.py | 2 +- tests/test_external_compaction_activity.py | 2 +- tests/test_external_goal_owner.py | 2 +- tests/test_goal_answers.py | 2 +- tests/test_goal_attempts.py | 2 +- tests/test_goal_block_reason.py | 2 +- tests/test_goal_execution.py | 3 +- tests/test_goal_failure_observation.py | 2 +- tests/test_goal_input_review.py | 2 +- tests/test_goal_publication_sources.py | 2 +- tests/test_goal_reply_lock_scope.py | 2 +- tests/test_goal_resume.py | 2 +- tests/test_goal_selection_owner.py | 2 +- tests/test_goal_standby.py | 2 +- tests/test_goal_standby_liveness.py | 2 +- tests/test_goal_wait_certified_reply.py | 2 +- tests/test_historical_goal_generation.py | 2 +- tests/test_historical_notifications.py | 2 +- tests/test_historical_views.py | 2 +- tests/test_holder_standing_rules.py | 2 +- tests/test_importing.py | 2 +- tests/test_input_delivery_history.py | 5 +- tests/test_input_disposition.py | 2 +- tests/test_input_documents.py | 2 +- tests/test_install.py | 5 +- tests/test_install_session_bridge.py | 3 +- tests/test_irc.py | 2 +- tests/test_l0_goal_input_closure.py | 2 +- tests/test_maintenance_barrier.py | 2 +- tests/test_message_notifications.py | 2 +- tests/test_monitor_delivery.py | 2 +- tests/test_native_send_admission.py | 6 +- tests/test_native_settlement_scope.py | 2 +- tests/test_native_unknown_recovery.py | 6 +- tests/test_operations.py | 2 +- tests/test_optional_awareness_projection.py | 2 +- tests/test_order_claims.py | 2 +- tests/test_order_progress.py | 2 +- tests/test_ordinary_nk_delivery.py | 2 +- tests/test_owned_turn_goal_replacement.py | 2 +- tests/test_owner_process.py | 6 +- tests/test_owner_release_restart.py | 2 +- tests/test_owner_restart_handoff.py | 5 +- tests/test_owner_without_socket.py | 2 +- tests/test_peer_relevance.py | 2 +- tests/test_private_idle_drain.py | 2 +- tests/test_process_names.py | 7 +- tests/test_process_state.py | 6 +- tests/test_project_resume.py | 2 +- tests/test_read_ledger.py | 2 +- tests/test_reader_liveness_is_socket.py | 2 +- tests/test_registration_authority.py | 2 +- tests/test_registration_components.py | 2 +- tests/test_registration_inheritance.py | 2 +- tests/test_registration_process_identity.py | 3 +- tests/test_registration_transitions.py | 2 +- tests/test_registry_copy_retires_processes.py | 2 +- tests/test_registry_current_format.py | 2 +- tests/test_reopen_orders.py | 2 +- tests/test_root_host_retirement.py | 2 +- tests/test_roster_restoration.py | 5 +- tests/test_runtime.py | 2 +- tests/test_runtime_owned_session_admission.py | 2 +- tests/test_runtime_processes.py | 11 +- tests/test_runtime_retention.py | 6 +- tests/test_runtime_subscription_handshake.py | 2 +- tests/test_selected_answer_forms.py | 2 +- tests/test_selected_source_batch.py | 2 +- tests/test_session_bridge_owner.py | 5 +- tests/test_session_close.py | 2 +- tests/test_session_load_plan.py | 2 +- tests/test_stopped_claim_expiry.py | 5 +- tests/test_storage_room.py | 2 +- tests/test_task_decisions.py | 2 +- tests/test_team_deaf_monitor.py | 5 +- tests/test_team_notifications.py | 2 +- tests/test_thread_identity.py | 5 +- tests/test_thread_names.py | 2 +- tests/test_thread_status.py | 2 +- tests/test_todos.py | 2 +- tests/test_tool_output.py | 2 +- tests/test_turn_declaration.py | 5 +- tests/test_turn_digests.py | 2 +- tests/test_turn_lease_release.py | 2 +- tests/test_turn_record.py | 2 +- tests/test_unit_state.py | 2 +- tests/test_unowned_checkout_work.py | 2 +- tests/test_wake_goal_execution.py | 2 +- tests/test_wake_lifetime.py | 2 +- tests/test_watch_git_preparation.py | 6 +- tests/worker_hosts.py | 7 +- tools/agent_comms_project.py | 7 +- 220 files changed, 1341 insertions(+), 1262 deletions(-) create mode 100644 src/agent_comms/execution/async_retirement.py create mode 100644 src/agent_comms/execution/process_identity.py diff --git a/src/agent_comms/acp_extension.py b/src/agent_comms/acp_extension.py index 84cb6c73b6..0373000556 100644 --- a/src/agent_comms/acp_extension.py +++ b/src/agent_comms/acp_extension.py @@ -19,7 +19,7 @@ ) from agent_comms.execution.session_updates import AgentCommsUpdate, UpdateBatch from agent_comms.text_route_update import TextRouteUpdate -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.context_reading import ContextReading from agent_comms.execution.input_origin import InputOrigin, UnattributedInputOrigin from agent_comms.execution.native_output import NativeOutputScope diff --git a/src/agent_comms/agent_backend.py b/src/agent_comms/agent_backend.py index 40a1edad7f..a4a84112fc 100644 --- a/src/agent_comms/agent_backend.py +++ b/src/agent_comms/agent_backend.py @@ -37,7 +37,7 @@ ContextCommitProof, TurnInputContent, ) -from agent_comms.execution.child_process import NoProcess, ProcessState +from agent_comms.execution.process_identity import NoProcess, ProcessState from agent_comms.execution.history_view import OwnHistory from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.native_arguments import ModelProvider diff --git a/src/agent_comms/cli_bridges/codex.py b/src/agent_comms/cli_bridges/codex.py index f25bfce63a..324f7fc859 100755 --- a/src/agent_comms/cli_bridges/codex.py +++ b/src/agent_comms/cli_bridges/codex.py @@ -49,7 +49,7 @@ Watch, run_bridge, ) -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.host_services.codex_inbox import CodexInboxService from agent_comms.messaging.messages import Message diff --git a/src/agent_comms/cli_bridges/hook_session.py b/src/agent_comms/cli_bridges/hook_session.py index d73a8247aa..fb058e941a 100644 --- a/src/agent_comms/cli_bridges/hook_session.py +++ b/src/agent_comms/cli_bridges/hook_session.py @@ -9,7 +9,7 @@ from agent_comms.cli_bridges.session_watch import WatchClaim from agent_comms.cli_bridges.shared import Serve -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms_hooks import ClaudeTranscriptHook from agent_comms_hooks.watch import SessionEndpoint, SkillText diff --git a/src/agent_comms/cli_bridges/inbox_watch.py b/src/agent_comms/cli_bridges/inbox_watch.py index 654ec33360..76ef1b601b 100644 --- a/src/agent_comms/cli_bridges/inbox_watch.py +++ b/src/agent_comms/cli_bridges/inbox_watch.py @@ -50,7 +50,7 @@ from agent_comms.coordination.database import CoordinationStore from agent_comms.coordination.tables.harness_deliveries import HarnessDelivery from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.agent_inbox import NoWait, TakenInputPosition, TakenInputStart from agent_comms.messaging.bus import Bus from agent_comms.messaging.bus_route_counts import BusRouteCounts diff --git a/src/agent_comms/cli_bridges/model_agent_client.py b/src/agent_comms/cli_bridges/model_agent_client.py index ba1d6fc443..7c1ab72c01 100644 --- a/src/agent_comms/cli_bridges/model_agent_client.py +++ b/src/agent_comms/cli_bridges/model_agent_client.py @@ -29,7 +29,7 @@ from agent_comms.comms import Comms from agent_comms.conversational_slop import ResponseContext, SlopVerdict, verify_all from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity, ProcessName +from agent_comms.execution.process_identity import ProcessIdentity, ProcessName from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.provider_records import ParsedThinking from agent_comms.installer.active_route import resolve_comms_route diff --git a/src/agent_comms/cli_bridges/monitor.py b/src/agent_comms/cli_bridges/monitor.py index a8063f876f..746777ef8e 100644 --- a/src/agent_comms/cli_bridges/monitor.py +++ b/src/agent_comms/cli_bridges/monitor.py @@ -36,7 +36,7 @@ WatchRecord, ) from agent_comms.coordination.errors import CoordinationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.installer.runtime_wire import CrossesRuntimes from agent_comms.nominal.declared_family import DeclaredFamily diff --git a/src/agent_comms/cli_bridges/opencode.py b/src/agent_comms/cli_bridges/opencode.py index 1481ba8e35..275b210873 100755 --- a/src/agent_comms/cli_bridges/opencode.py +++ b/src/agent_comms/cli_bridges/opencode.py @@ -44,7 +44,7 @@ run_bridge, ) from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.messages import Message from agent_comms.messaging.send_result import SendResult from agent_comms.projects.checkouts import Checkout diff --git a/src/agent_comms/cli_bridges/shared.py b/src/agent_comms/cli_bridges/shared.py index 728543ba1c..23f779b561 100644 --- a/src/agent_comms/cli_bridges/shared.py +++ b/src/agent_comms/cli_bridges/shared.py @@ -100,12 +100,8 @@ ) from agent_comms.coordination.tables.harness_deliveries import HarnessDelivery, HarnessObservedPart from agent_comms.errors import RelationViolationError, UnregisteredThreadError -from agent_comms.execution.child_process import ( - OutlivesLauncherLifetime, - Platform, - ProcessIdentity, - SpawnedProcess, -) +from agent_comms.execution.child_process import OutlivesLauncherLifetime, Platform, SpawnedProcess +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.delivers_input import DeliversInput from agent_comms.execution.launch_runtime import LaunchRuntime, RunningSource from agent_comms.execution.turn_item import NoSourceTurn, SourceTurn diff --git a/src/agent_comms/cli_verbs/attach_session.py b/src/agent_comms/cli_verbs/attach_session.py index 5db96948d2..38ad0ad4b0 100644 --- a/src/agent_comms/cli_verbs/attach_session.py +++ b/src/agent_comms/cli_verbs/attach_session.py @@ -7,7 +7,7 @@ from agent_comms.cli_verbs.cli_verb import CliBus, CliCommand from agent_comms.cli_verbs.cli_commands import NameArgument from agent_comms.cli_verbs.cli_result import CliResult -from agent_comms.execution.child_process import NoProcess, ProcessIdentity, ProcessState +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity, ProcessState from agent_comms.execution.session_file import SessionFile from agent_comms.nominal.field_codec import Argument, WireOmitDefault diff --git a/src/agent_comms/cli_verbs/cli_commands.py b/src/agent_comms/cli_verbs/cli_commands.py index 06aa9584f4..be6ab69709 100644 --- a/src/agent_comms/cli_verbs/cli_commands.py +++ b/src/agent_comms/cli_verbs/cli_commands.py @@ -9,7 +9,7 @@ from typing import Annotated from agent_comms.cli_verbs.cli_result import CliResult, TargetEditResult -from agent_comms.execution.child_process import ProcessState +from agent_comms.execution.process_identity import ProcessState from agent_comms.execution.pi_vocabulary import ServiceTier, ThinkingLevelField from agent_comms.messaging.message_reference import MessageReference from agent_comms.nominal.field_codec import ( diff --git a/src/agent_comms/cli_verbs/register.py b/src/agent_comms/cli_verbs/register.py index 986c0e1783..8d1d87f061 100644 --- a/src/agent_comms/cli_verbs/register.py +++ b/src/agent_comms/cli_verbs/register.py @@ -7,7 +7,7 @@ from agent_comms.cli_verbs.cli_verb import CliBus, CliCommand from agent_comms.cli_verbs.cli_commands import NameArgument, _tags from agent_comms.cli_verbs.cli_result import CliResult, RegisteredResult -from agent_comms.execution.child_process import NoProcess, ProcessIdentity, ProcessState +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity, ProcessState from agent_comms.nominal.field_codec import Argument, Normalize from agent_comms.projects.checkouts import Checkout from agent_comms.registry.thread_text import NoParent, NoThreadText, ThreadParent, ThreadText diff --git a/src/agent_comms/coordination/attempt_recovery.py b/src/agent_comms/coordination/attempt_recovery.py index cc2aa7f228..5d596a8997 100644 --- a/src/agent_comms/coordination/attempt_recovery.py +++ b/src/agent_comms/coordination/attempt_recovery.py @@ -33,7 +33,7 @@ from agent_comms.coordination.tables.executions import CurrentExecutions from agent_comms.coordination.tables.recovery import RecoveryAudit from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_entries import NativeEntry from agent_comms.execution.native_failures import NativePiUnavailable from agent_comms.execution.native_input_record import FullNativeExecution, TriageNativeExecution diff --git a/src/agent_comms/coordination/coordinator.py b/src/agent_comms/coordination/coordinator.py index 840a6f1e04..48b592ecaf 100644 --- a/src/agent_comms/coordination/coordinator.py +++ b/src/agent_comms/coordination/coordinator.py @@ -27,7 +27,7 @@ ) from agent_comms.coordination.work import CoordinationWork from agent_comms.coordination.working_memory_annotations import WorkingMemoryAnnotations -from agent_comms.execution.child_process import join_retirement +from agent_comms.execution.async_retirement import join_retirement from agent_comms.execution.publication_measurements import ( CoordinatorRun, CoordinatorWait, diff --git a/src/agent_comms/coordination/optional_awareness_projection.py b/src/agent_comms/coordination/optional_awareness_projection.py index bf9bcd016b..a7dc893fd1 100644 --- a/src/agent_comms/coordination/optional_awareness_projection.py +++ b/src/agent_comms/coordination/optional_awareness_projection.py @@ -46,7 +46,7 @@ from agent_comms.coordination.tables.participants import OwnerGenerations from agent_comms.coordination.tables.responses import ResponseObligation from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_input_owner import RegistryOwner from agent_comms.execution.context_provenance import ResourceProvenance, WireProvenance from agent_comms.execution.turn_context import ContextSegment, InstructionFile diff --git a/src/agent_comms/coordination/work.py b/src/agent_comms/coordination/work.py index f03f3dd085..4f53aca9f9 100644 --- a/src/agent_comms/coordination/work.py +++ b/src/agent_comms/coordination/work.py @@ -5,7 +5,7 @@ from functools import partial from typing import ClassVar -from agent_comms.execution.child_process import AsyncWork +from agent_comms.execution.async_retirement import AsyncWork from agent_comms.execution.publication_measurements import WorkCpu from agent_comms.installer.native_build_inputs import GitLaunch from agent_comms.storage.maintenance_barrier import MaintenanceHolder diff --git a/src/agent_comms/execution/acp.py b/src/agent_comms/execution/acp.py index a5fb242b61..91ca6affa4 100644 --- a/src/agent_comms/execution/acp.py +++ b/src/agent_comms/execution/acp.py @@ -68,7 +68,7 @@ from agent_comms.execution import manual_compaction_bridge from agent_comms.execution.acp_failure import NativeTurnError from agent_comms.execution.acp_request_consumer import AcpRequestConsumer -from agent_comms.execution.child_process import ProcessName +from agent_comms.execution.process_identity import ProcessName from agent_comms.execution.controller import ( ACP_PERMISSION_TIMEOUT_SECONDS, CancelledOutcome, diff --git a/src/agent_comms/execution/antigravity_acp.py b/src/agent_comms/execution/antigravity_acp.py index bb48c89836..39d85a5f30 100644 --- a/src/agent_comms/execution/antigravity_acp.py +++ b/src/agent_comms/execution/antigravity_acp.py @@ -43,7 +43,7 @@ AcpWireModel, AntigravityAcpUpdate, ) -from agent_comms.execution.child_process import NoProcess, Platform, ProcessIdentity, ProcessState +from agent_comms.execution.process_identity import NoProcess, ProcessPlatform, ProcessIdentity, ProcessState from agent_comms.execution.native_session_files import SessionFiles from agent_comms.nominal.declared_family import DeclaredFamily from agent_comms.nominal.field_codec import AcpSessionId, NominalSpelling, NominalText @@ -361,7 +361,7 @@ def delete(self) -> int: if entry.is_file() or entry.is_symlink(): freed += entry.lstat().st_size shutil.rmtree(brain) - Platform.current().sync_directory(brain.parent) + ProcessPlatform.current().sync_directory(brain.parent) return freed diff --git a/src/agent_comms/execution/antigravity_backend.py b/src/agent_comms/execution/antigravity_backend.py index e13b3fddba..6109aa0c77 100644 --- a/src/agent_comms/execution/antigravity_backend.py +++ b/src/agent_comms/execution/antigravity_backend.py @@ -49,7 +49,7 @@ AntigravitySessionDeclaration, ) from agent_comms.execution.backend_query import TurnInputContent -from agent_comms.execution.child_process import ProcessState +from agent_comms.execution.process_identity import ProcessState from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.runtime_observations import ( AgentInfo, diff --git a/src/agent_comms/execution/async_retirement.py b/src/agent_comms/execution/async_retirement.py new file mode 100644 index 0000000000..150feccab6 --- /dev/null +++ b/src/agent_comms/execution/async_retirement.py @@ -0,0 +1,63 @@ +"""Cancellation-safe retirement joins and accepted async work.""" + +from __future__ import annotations + +import asyncio +import inspect +from collections.abc import Callable + + +class ChildRetirementError(BaseException): + """The child owner's cleanup acknowledgement failed independently of cancellation.""" + + +class ChildRetirementFailed(RuntimeError, ChildRetirementError): + """An ordinary retirement failure; never a cancellation.""" + + +class ChildRetirementCancelled(asyncio.CancelledError, ChildRetirementError): + """Preserve cancellation and an independently failed retirement acknowledgement.""" + + +async def join_retirement[Result](task: asyncio.Future[Result]) -> Result: + """Join owned cleanup through repeated cancellation, then propagate it.""" + interrupted = None + try: + while not task.done(): + try: + # wait does not cancel the original future or replace its own + # typed cancellation with shield's synthetic CancelledError. + await asyncio.wait((task,)) + except asyncio.CancelledError as error: + interrupted = error + result = task.result() + if interrupted is not None and inspect.isawaitable(result): + returned = asyncio.ensure_future(result) + returned.cancel() + try: + await join_retirement(returned) + except asyncio.CancelledError: + pass + except ChildRetirementError: + raise # Cancellation cannot turn an unattested physical stop into success. + except BaseException as error: + # A failed joined operation has still finished. Its error must + # not consume the caller's cancellation and restart an observer loop. + if interrupted is not None: + raise interrupted from error + raise + if interrupted is not None: + raise interrupted + return result + + +class AsyncWork: + """Accepted work finishes before its caller releases the operation's resources.""" + + @classmethod + async def run_async[Result](cls, operation: Callable[[], Result]) -> Result: + return await join_retirement(asyncio.create_task(asyncio.to_thread(operation))) + + @classmethod + def cancel_on_shutdown[Result](cls, pending: asyncio.Future[Result]) -> None: + """A mutation must finish, even if its worker has not started yet.""" diff --git a/src/agent_comms/execution/child_process.py b/src/agent_comms/execution/child_process.py index 5f606b0ca4..c9d4301d1b 100644 --- a/src/agent_comms/execution/child_process.py +++ b/src/agent_comms/execution/child_process.py @@ -72,10 +72,27 @@ from agent_comms.errors import RelationViolationError from agent_comms.execution.host_platform import ( AndroidHostFilesystem, + CurrentPlatform, HostFilesystem, LinuxHostFilesystem, RelayEnding as RelayEnding, ) +from agent_comms.execution.async_retirement import ( + AsyncWork, + ChildRetirementCancelled, + ChildRetirementError, + ChildRetirementFailed, + join_retirement, +) +from agent_comms.execution.process_identity import ( + STOP_GRACE_SECONDS, + AndroidProcessOperations, + DarwinProcessOperations, + LinuxProcessOperations, + ProcessIdentity, + ProcessName, + ProcessOperations, +) from agent_comms.execution.helper_workers import ( ForkedTemplate, ForkedWorkers, @@ -113,745 +130,24 @@ from agent_comms.registry.thread_identity import ThreadIncarnation, ThreadRole -STOP_GRACE_SECONDS = 2.0 -PR_SET_NAME = 15 - - -@dataclass(frozen=True) -class ProcfsColumn(FieldDirective): - key: str - scale: int = 1024 - - def value(self, tokens: list[str]) -> int: - return int(tokens[0]) * self.scale - - -class ProcfsRecord: - """Procfs owns the text; field declarations own selection, units and requiredness.""" - - filename: ClassVar[str] - - @classmethod - def read(cls, directory: Path) -> Self: - fields = {key: value.split() - for line in (directory / cls.filename).read_text().splitlines() - for key, _, value in (line.partition(":"),)} - return FieldCodec.decode(cls, { - plan.key: column.value(fields[column.key]) - for plan in FieldCodec.field_plans(cls) - for column in ProcfsColumn.single(plan.annotation) - if column.key in fields - }) - - -@dataclass(frozen=True) -class ProportionalMemory(ProcfsRecord): - filename = "smaps_rollup" - bytes: Annotated[int, ProcfsColumn("Pss"), WireRequired()] - - -@dataclass(frozen=True) -class ResidentMemory(ProcfsRecord): - """One procfs status sample, in bytes; kernel threads have no resident pages.""" - - filename = "status" - parent: Annotated[int, ProcfsColumn("PPid", 1), WireRequired()] - resident: Annotated[int, ProcfsColumn("VmRSS")] = 0 - peak: Annotated[int, ProcfsColumn("VmHWM")] = 0 - - @classmethod - def tree(cls, process: ProcessIdentity, proc: Path) -> dict[int, ResidentMemory]: - """A sampled descendant set, guarded by the root's exact process birth. The kernel lists - each task's children, so only the subtree's status files are read.""" - if not process.alive(): - return {} - rows: dict[int, ResidentMemory] = {} - pending = [process.pid] - while pending: - pid = pending.pop() - directory = proc / str(pid) - try: - rows[pid] = cls.read(directory) - except (FileNotFoundError, ProcessLookupError): - continue - pending.extend(child for child in cls.children(directory) if child not in rows) - return rows if process.alive() else {} - - @staticmethod - def children(directory: Path) -> Iterator[int]: - """Every task's children: a child forked by a non-leader thread is listed only there.""" - for listing in directory.glob("task/*/children"): - try: - yield from map(int, listing.read_text().split()) - except (FileNotFoundError, ProcessLookupError): - continue - - -class IdentityMismatchError(ProcessLookupError): - """A recorded process incarnation is absent or has been replaced.""" - - -class ChildRetirementError(BaseException): - """The child owner's cleanup acknowledgement failed independently of cancellation.""" - - -class ChildRetirementFailed(RuntimeError, ChildRetirementError): - """An ordinary retirement failure; never a cancellation.""" - - -class ChildRetirementCancelled(asyncio.CancelledError, ChildRetirementError): - """Preserve cancellation and an independently failed retirement acknowledgement.""" - - -class ProcessSighting[Status](ABC): - """A thread's live presence, answering for the process state its owner has.""" - - __slots__ = () - - @abstractmethod - def heartbeat_seen(self, last_seen: float) -> Status: - """The presence when no process is recorded: the heartbeat is the evidence.""" - - @abstractmethod - def process_seen(self, process: ProcessState) -> Status: - """The presence when a process is recorded for it.""" - - -class ProcessFence[Status](ABC): - """A stored stop, answering for whether a process still binds it.""" - - __slots__ = () - - @abstractmethod - def unbound(self) -> Status: - """The stop when no process binds it.""" - - @abstractmethod - def fenced(self) -> Status: - """The stop while its process still binds it.""" - - -class NativeBinding[Presentation](ABC): - """A registry lease that presents its thread natively once a process holds it.""" - - __slots__ = () - - @abstractmethod - def native_presentation(self, ordinary: Presentation) -> Presentation: ... - - -class ProcessRestart[Change](ABC): - """A registration change over a prior incarnation, kept or restarted by its processes.""" - - __slots__ = () - - @property - @abstractmethod - def previous_incarnation(self) -> ThreadIncarnation: ... - - @abstractmethod - def kept(self) -> Change: - """The change as requested: no process restarts it.""" - - @abstractmethod - def restarted(self) -> Change: - """The change once a process replaces the prior incarnation's.""" - - -class ProcessState(SubclassUnion, affix=""): - """An exact recorded process or a worker which has never started.""" - - @abstractmethod - def allows_owner_start(self) -> bool: ... - - def require_owner_startable(self) -> None: - """Refuse if the process state does not allow starting an owner.""" - raise RelationViolationError('Retired session acquired another process') - @abstractmethod - def allows_inactive_stop(self) -> bool: ... - - @abstractmethod - def require_held_by(self, role: type[ThreadRole]) -> None: ... - @abstractmethod - def conflicts_with(self, previous: ProcessState) -> bool: ... - - @abstractmethod - def registration_change[Change]( - self, previous: ProcessState, change: ProcessRestart[Change], incarnation: ThreadIncarnation, - ) -> Change: ... - - @abstractmethod - def restarted_registration[Change]( - self, change: ProcessRestart[Change], incarnation: ThreadIncarnation, - ) -> Change: ... - - @abstractmethod - def native_presentation[Presentation]( - self, ordinary: Presentation, binding: NativeBinding[Presentation], - ) -> Presentation: ... - - @abstractmethod - def applied(self, previous: ProcessState) -> ProcessState: ... - - @abstractmethod - def offline(self) -> bool: ... - - @abstractmethod - def require(self, message: str = "No worker process has started") -> ProcessIdentity: ... - - @abstractmethod - def alive(self) -> bool: ... - - @abstractmethod - def thread_status[Status](self, presence: ProcessSighting[Status], last_seen: float) -> Status: ... - - @abstractmethod - def stopped_seen[Status](self, stopped: ProcessFence[Status]) -> Status: - """A stored stop with no process is stopped; one still bound is a fence.""" - - @abstractmethod - def runs_here(self) -> bool: ... - - @abstractmethod - def signal(self, signum: int) -> None: ... - - @abstractmethod - def require_release_by(self, process: ProcessIdentity) -> None: ... - - @abstractmethod - def held_external_stop(self, release: Callable[[], None], name: str) -> str | None: - """Stop a CLI endpoint this process holds: the name still for the ordinary stop, if any.""" - - -@dataclass(frozen=True) -class NoProcess(NullMember, ProcessState): - def allows_owner_start(self) -> bool: - return True - - def allows_inactive_stop(self) -> bool: - return True - - def require_held_by(self, role: type[ThreadRole]) -> None: - """No process is held, so any role may declare it.""" - - def conflicts_with(self, previous: ProcessState) -> bool: - return False - - def registration_change[Change]( - self, previous: ProcessState, change: ProcessRestart[Change], incarnation: ThreadIncarnation, - ) -> Change: - return change.kept() - - def restarted_registration[Change]( - self, change: ProcessRestart[Change], incarnation: ThreadIncarnation, - ) -> Change: - return change.kept() - - def native_presentation[Presentation]( - self, ordinary: Presentation, binding: NativeBinding[Presentation], - ) -> Presentation: - return ordinary - - def applied(self, previous: ProcessState) -> ProcessState: - return previous - - def offline(self) -> bool: - return False - - def require(self, message: str = "No worker process has started") -> ProcessIdentity: - raise RelationViolationError(message) - - def alive(self) -> bool: - return False - - def thread_status[Status](self, presence: ProcessSighting[Status], last_seen: float) -> Status: - return presence.heartbeat_seen(last_seen) - - def stopped_seen[Status](self, stopped: ProcessFence[Status]) -> Status: - return stopped.unbound() - - def runs_here(self) -> bool: - return False - - def signal(self, signum: int) -> None: - pass - - def require_release_by(self, process: ProcessIdentity) -> None: - # Stopping before the first start still produces a valid release. - pass - - def held_external_stop(self, release: Callable[[], None], name: str) -> str | None: - """Nothing holds the endpoint, so the ordinary stop finishes it on the bus.""" - return name - - def require_owner_startable(self) -> None: - pass - - -@dataclass(frozen=True) -class ProcessName: - """One short kernel-visible name published by the process that owns the role.""" - - value: str - - def __post_init__(self) -> None: - encoded = self.value.encode("utf-8") - if not encoded or len(encoded) > 15 or not self.value.isprintable(): - raise ValueError("A process name needs 1-15 safe UTF-8 bytes") - - @property - def encoded(self) -> bytes: - return self.value.encode("utf-8") - - def publish(self) -> None: - Platform.current().publish_process_name(self) - - -@dataclass(frozen=True) -class ProcessIdentity(RecordMember, ProcessState): - pid: int - start_time: int - - def __post_init__(self) -> None: - if self.pid <= 0 or self.start_time <= 0: - raise ValueError("A positive PID and platform start time are required") - - def memory(self, proc: Path = Path("/proc")) -> ResidentMemory: - platform = Platform.current() - platform.require(self) - result = ResidentMemory.read(proc / str(self.pid)) - platform.require(self) - return result - - @classmethod - def pid_argument(cls, value: str) -> dict[str, object]: - return FieldCodec.encode_record(cls.capture(int(value))) - - @classmethod - def capture(cls, pid: int) -> ProcessIdentity: - return cls.current() if pid == os.getpid() else Platform.current().identity(pid) - - @classmethod - def current(cls) -> ProcessIdentity: - """The caller's immutable birth; a fork selects its own PID, not its parent's.""" - return cls._current(os.getpid()) - - @staticmethod - @cache - def _current(pid: int) -> ProcessIdentity: - return Platform.current().identity(pid) - - def allows_owner_start(self) -> bool: - return False - - def allows_inactive_stop(self) -> bool: - return self.runs_here() - - def require_held_by(self, role: type[ThreadRole]) -> None: - role.require_executable( - RelationViolationError("A human thread cannot hold an owner process") - ) - - def conflicts_with(self, previous: ProcessState) -> bool: - return self != previous - - def offline(self) -> bool: - return not self.alive() - - def native_presentation[Presentation]( - self, ordinary: Presentation, binding: NativeBinding[Presentation], - ) -> Presentation: - return binding.native_presentation(ordinary) - - def applied(self, previous: ProcessState) -> ProcessState: - return self - - def require(self, message: str = "No worker process has started") -> ProcessIdentity: - return self - - @staticmethod - def in_group(pid: int, start_time: int, pgid: int) -> ProcessIdentity: - return GroupLeader(pid, start_time) if pgid == pid else GroupMember(pid, start_time) - - def __eq__(self, other: object) -> bool: - if not isinstance(other, ProcessIdentity): - return NotImplemented - return (self.pid, self.start_time) == (other.pid, other.start_time) - - def alive(self) -> bool: - return Platform.current().matches(self) - - def arguments(self) -> tuple[str, ...]: - return Platform.current().arguments(self) - - def environment(self) -> dict[str, str]: - return Platform.current().environment(self) - - def require_alive(self) -> ProcessIdentity: - """Validate this recorded PID and start time against the live process.""" - return Platform.current().require(self) - - def runs_here(self) -> bool: - return os.getpid() == self.pid - - def signal(self, signum: int) -> None: - Platform.current().send(self, signum) - - def lineage(self) -> Iterator[ProcessIdentity]: - """This incarnation and its exact ancestors, ending at PID 1.""" - platform = Platform.current() - current = self - while True: - yield current - if current.pid == 1: - return - current = platform.parent_identity(current.pid) - - def require_ancestor_of(self, pid: int) -> None: - """A supplied process is authority only for its actual descendant.""" - platform = Platform.current() - platform.require(self) - if self in platform.identity(pid).lineage(): - return - raise IdentityMismatchError('The declared process is not an ancestor of this hook') - - async def wait_exited(self) -> None: - await Platform.current().wait_exited(self) - - def require_release_by(self, process: ProcessIdentity) -> None: - if self != process: - raise RelationViolationError("Only the registered owner may release itself.") - - def held_external_stop(self, release: Callable[[], None], name: str) -> str | None: - """A live holder (a CLI bridge or the connector's inbox watch) serves no owner runtime to - retire, so its binding is released for it. A dead holder left a binding the ordinary stop - finishes.""" - if not self.alive(): - return name - release() - return None - - def thread_status[Status](self, presence: ProcessSighting[Status], last_seen: float) -> Status: - return presence.process_seen(self) - - def stopped_seen[Status](self, stopped: ProcessFence[Status]) -> Status: - return stopped.fenced() - - def registration_change[Change]( - self, previous: ProcessState, change: ProcessRestart[Change], incarnation: ThreadIncarnation, - ) -> Change: - return previous.restarted_registration(change, incarnation) - - def restarted_registration[Change]( - self, change: ProcessRestart[Change], incarnation: ThreadIncarnation, - ) -> Change: - return change.restarted() if incarnation != change.previous_incarnation else change.kept() - - def members(self, platform: Platform) -> tuple[ProcessIdentity, ...]: - return () # A stored, exited identity cannot grant group ownership. - - -NO_PROCESS = NoProcess() - - -class GroupLeader(ProcessIdentity, declared_name=None): - def members(self, platform: Platform) -> tuple[ProcessIdentity, ...]: - return tuple(member for member in platform.members_of_group(self.pid) - if member.start_time >= self.start_time) - - -class GroupMember(ProcessIdentity, declared_name=None): - def members(self, platform: Platform) -> tuple[ProcessIdentity, ...]: - return (self,) if platform.matches(self) else () - - -class PidfdHandles: - @staticmethod - def open_pidfd(pid: int) -> int: - """Use libc when a portable Python build omitted Linux wrappers.""" - if hasattr(os, "pidfd_open"): - return os.pidfd_open(pid) - libc = ctypes.CDLL(None, use_errno=True) - function = getattr(libc, "pidfd_open", None) - if function is None: - raise NotImplementedError("Linux libc pidfd_open unavailable") - function.argtypes = (ctypes.c_int, ctypes.c_uint) - function.restype = ctypes.c_int - descriptor = function(pid, 0) - if descriptor < 0: - code = ctypes.get_errno() - raise OSError(code, os.strerror(code)) - return int(descriptor) - - @staticmethod - def signal_pidfd(pidfd: int, sig: int) -> None: - if hasattr(signal, "pidfd_send_signal"): - signal.pidfd_send_signal(pidfd, sig) - return - libc = ctypes.CDLL(None, use_errno=True) - function = getattr(libc, "pidfd_send_signal", None) - if function is None: - raise NotImplementedError("Linux libc pidfd_send_signal unavailable") - function.argtypes = (ctypes.c_int, ctypes.c_int, ctypes.c_void_p, ctypes.c_uint) - function.restype = ctypes.c_int - if function(pidfd, sig, None, 0) < 0: - code = ctypes.get_errno() - raise OSError(code, os.strerror(code)) - - -class Platform(HostFilesystem, DeclaredFamily, affix="Platform"): - @classmethod - def current(cls) -> Platform: - return cls.member_named(sys.platform)() - - @abstractmethod - def require_watched_procfs(self, refusal: Exception) -> None: ... +class Platform(CurrentPlatform, ProcessOperations, DeclaredFamily, affix="Platform"): def launch( self, command: tuple[str, ...], pass_fds: tuple[int, ...], runtime: LaunchRuntime, lifetime: type[ChildLifetime], ) -> ChildLaunch: return ChildLaunch(self, command, pass_fds, runtime, lifetime) - def terminate_group(self, identity: ProcessIdentity) -> None: - self.signal_group(identity, signal.SIGTERM) - - def force_group(self, identity: ProcessIdentity) -> None: - self.signal_group(identity, signal.SIGKILL) - - @abstractmethod - def identity(self, pid: int) -> ProcessIdentity: ... - - def started_at(self, identity: ProcessIdentity) -> float: - """This recorded process's birth on the monotonic clock.""" - raise NotImplementedError("This platform does not expose process elapsed time") - - @abstractmethod - def arguments(self, process: ProcessIdentity) -> tuple[str, ...]: ... - - @abstractmethod - def environment(self, process: ProcessIdentity) -> dict[str, str]: ... - - @abstractmethod - def process_name(self, pid: int) -> str: ... - - def publish_process_name(self, name: ProcessName) -> None: - """Keep the inherited executable name on platforms without a naming operation.""" - return None - def worker_start(self) -> WorkerStart: """The platform's way to get worker processes: fresh interpreters.""" return SpawnedHelper() - def parent_identity(self, pid: int) -> ProcessIdentity: - raise NotImplementedError('This platform does not expose exact parent identities') - async def wait_exited(self, identity: ProcessIdentity) -> None: - """Wait for one incarnation's exit; members with a loop-readable handle override this.""" - await asyncio.to_thread(self.wait_any_exited, (identity,), math.inf) - - @abstractmethod - def wait_any_exited( - self, identities: tuple[ProcessIdentity, ...], timeout: float, - ) -> None: - """Wait for a member's exit or the caller's remaining deadline.""" - - def matches(self, identity: ProcessIdentity) -> bool: - if identity.runs_here(): - return identity == ProcessIdentity.current() - try: - return self.identity(identity.pid) == identity - except ProcessLookupError: - return False - - def require(self, identity: ProcessIdentity) -> ProcessIdentity: - with suppress(ProcessLookupError): - current = self.identity(identity.pid) - if current == identity: - return current - raise IdentityMismatchError(f"Process incarnation changed: {identity.pid}") - - def send(self, identity: ProcessIdentity, signum: int) -> None: - self.require(identity) - os.kill(identity.pid, signum) - - def group_members(self, leader: ProcessIdentity) -> tuple[ProcessIdentity, ...]: - try: - current = self.identity(leader.pid) - except ProcessLookupError: - return leader.members(self) - if current != leader: - raise IdentityMismatchError(f"Process incarnation changed: {leader.pid}") - return current.members(self) - - def signal_group(self, leader: ProcessIdentity, signum: int) -> None: - # Snapshot identities, then signal each exact member. Never signal a - # numeric group after its leader may have been reaped and reused. - signalled = 0 - for member in self.group_members(leader): - try: - self.send(member, signum) - except ProcessLookupError: - continue - signalled += 1 - if not signalled and self.matches(leader): - raise RuntimeError(f"Live process {leader.pid} was not signalled") - - def parent_death_binding(self) -> int: - """Darwin has no parent-death signal: its exec gate binds no launcher.""" - return 0 - - @abstractmethod - def members_of_group(self, pgid: int) -> tuple[ProcessIdentity, ...]: ... - - -@dataclass(frozen=True) -class LinuxProcessRecord: - identity: ProcessIdentity - group: int - parent: int - flags: int = 0 - - -class LinuxPlatform(PidfdHandles, LinuxHostFilesystem, Platform): - def require_watched_procfs(self, refusal: Exception) -> None: - return None - - def parent_death_binding(self) -> int: - """The exec gate arms PR_SET_PDEATHSIG and binds to this launcher's PID.""" - return os.getpid() - - @staticmethod - def _stat(pid: int) -> LinuxProcessRecord: - """One process as the kernel has it now. A process changes group at exec and its PID - is reused after it dies, so no earlier read answers for a later one.""" - try: - # comm can contain whitespace and ')'; fields after its final ')' - # start at field 3. Kernel starttime is field 22, pgrp is field 5, - # flags field 9 (0-indexed within the post-comm split: 6). - fields = Path(f"/proc/{pid}/stat").read_text().rsplit(") ", 1)[1].split() - except FileNotFoundError: - raise ProcessLookupError(pid) from None - if fields[0] in {"Z", "X"}: - raise ProcessLookupError(pid) - group = int(fields[2]) - return LinuxProcessRecord( - ProcessIdentity.in_group(pid, int(fields[19]), group), group, int(fields[1]), - flags=int(fields[6])) - - def identity(self, pid: int) -> ProcessIdentity: - return self._stat(pid).identity - - def started_at(self, identity: ProcessIdentity) -> float: - started = identity.start_time / os.sysconf("SC_CLK_TCK") - age = time.clock_gettime(time.CLOCK_BOOTTIME) - started - return time.monotonic() - age - - def arguments(self, process: ProcessIdentity) -> tuple[str, ...]: - return self._proc_cmdline(process.pid) - - def environment(self, process: ProcessIdentity) -> dict[str, str]: - try: - raw = Path(f"/proc/{process.pid}/environ").read_bytes() - except FileNotFoundError: - raise ProcessLookupError(process.pid) from None - values = (item.split(b"=", 1) for item in raw.split(b"\0") if b"=" in item) - return {os.fsdecode(key): os.fsdecode(value) for key, value in values} - - def process_name(self, pid: int) -> str: - try: - return Path(f"/proc/{pid}/comm").read_text().strip() - except FileNotFoundError: - raise ProcessLookupError(pid) from None - - def publish_process_name(self, name: ProcessName) -> None: - operation = ctypes.CDLL(None, use_errno=True).prctl - operation.argtypes = ( - ctypes.c_int, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, - ) - operation.restype = ctypes.c_int - if operation(PR_SET_NAME, name.encoded, 0, 0, 0): - code = ctypes.get_errno() - raise OSError(code, os.strerror(code)) - - def _lock_holder_command(self, pid: int) -> tuple[str, ...]: - return self.arguments(self.identity(pid)) - - def parent_identity(self, pid: int) -> ProcessIdentity: - return self.identity(self._stat(pid).parent) - - async def wait_exited(self, identity: ProcessIdentity) -> None: - try: - descriptor = self.open_pidfd(identity.pid) - except ProcessLookupError: - return - try: - self.require(identity) - loop = asyncio.get_running_loop() - exited = loop.create_future() - def observe() -> None: - if not exited.done(): - exited.set_result(None) - loop.add_reader(descriptor, observe) - try: - await exited - finally: - loop.remove_reader(descriptor) - except ProcessLookupError: - return - finally: - os.close(descriptor) - - def wait_any_exited( - self, identities: tuple[ProcessIdentity, ...], timeout: float, - ) -> None: - descriptors: list[int] = [] - try: - pending = select.poll() - for identity in identities: - try: - descriptor = self.open_pidfd(identity.pid) - descriptors.append(descriptor) - current = self.identity(identity.pid) - except ProcessLookupError: - return - if current != identity: - return # Another incarnation holds the pid: this member exited. - pending.register(descriptor, select.POLLIN) - pending.poll(None if math.isinf(timeout) else max(0, math.ceil(timeout * 1000))) - finally: - for descriptor in descriptors: - os.close(descriptor) - - def members_of_group(self, pgid: int) -> tuple[ProcessIdentity, ...]: - """The kernel answers an empty group in one call; only a live one walks /proc.""" - try: - os.killpg(pgid, 0) - except ProcessLookupError: - return () - except PermissionError: - pass - members = [] - for entry in Path("/proc").iterdir(): - if entry.name.isdecimal(): - with suppress(ProcessLookupError): - record = self._stat(int(entry.name)) - if record.group == pgid: - members.append(record.identity) - return tuple(members) - - def send(self, identity: ProcessIdentity, signum: int) -> None: - # Bind first; recheck start time against the pidfd-bound incarnation - # before signaling. A concurrent exit can never target a reused PID. - descriptor = self.open_pidfd(identity.pid) - try: - self.require(identity) - self.signal_pidfd(descriptor, signum) - finally: - os.close(descriptor) +class LinuxPlatform(LinuxProcessOperations, Platform): + """Linux child launching and process inspection platform.""" -class AndroidPlatform(AndroidHostFilesystem, LinuxPlatform): +class AndroidPlatform(AndroidProcessOperations, LinuxPlatform): """Termux's Python names Android; its process and file operations use the Linux kernel.""" def worker_start(self) -> WorkerStart: @@ -860,136 +156,9 @@ def worker_start(self) -> WorkerStart: return ForkedStart() -class DarwinPlatform(Platform): +class DarwinPlatform(DarwinProcessOperations, Platform): """libproc exposes microsecond birth times, unlike formatted ps output.""" - def require_watched_procfs(self, refusal: Exception) -> None: - raise refusal - - class ProcessInfo(ctypes.Structure): - # External Darwin proc_bsdinfo ABI, from xnu/bsd/sys/proc_info.h. - _fields_ = [ - (name, ctypes.c_uint32) - for name in ( - "flags", - "status", - "xstatus", - "pid", - "ppid", - "uid", - "gid", - "ruid", - "rgid", - "svuid", - "svgid", - "reserved", - ) - ] + [ - ("comm", ctypes.c_char * 16), - ("name", ctypes.c_char * 32), - ("nfiles", ctypes.c_uint32), - ("pgid", ctypes.c_uint32), - ("pjobc", ctypes.c_uint32), - ("tdev", ctypes.c_uint32), - ("tpgid", ctypes.c_uint32), - ("nice", ctypes.c_int32), - ("start_seconds", ctypes.c_uint64), - ("start_microseconds", ctypes.c_uint64), - ] - - def __init__(self): - self.libproc = ctypes.CDLL("/usr/lib/libproc.dylib", use_errno=True) - self.libproc.proc_pidinfo.argtypes = ( - ctypes.c_int, - ctypes.c_int, - ctypes.c_uint64, - ctypes.c_void_p, - ctypes.c_int, - ) - self.libproc.proc_pidinfo.restype = ctypes.c_int - self.libproc.proc_listpids.argtypes = ( - ctypes.c_uint32, - ctypes.c_uint32, - ctypes.c_void_p, - ctypes.c_int, - ) - self.libproc.proc_listpids.restype = ctypes.c_int - - def identity(self, pid: int) -> ProcessIdentity: - info = self.ProcessInfo() - size = self.libproc.proc_pidinfo(pid, 3, 0, ctypes.byref(info), ctypes.sizeof(info)) - if size != ctypes.sizeof(info): - code = ctypes.get_errno() - if code == 3: # ESRCH, the actual OS absence result. - raise ProcessLookupError(pid) - raise OSError(code, os.strerror(code)) - if info.status == 5: # SZOMB: exited, awaiting reap. - raise ProcessLookupError(pid) - return ProcessIdentity.in_group( - pid, info.start_seconds * 1_000_000 + info.start_microseconds, info.pgid, - ) - - def started_at(self, identity: ProcessIdentity) -> float: - return time.monotonic() - (time.time() - identity.start_time / 1_000_000) - - def arguments(self, process: ProcessIdentity) -> tuple[str, ...]: - raise NotImplementedError(f"{type(self).__name__} does not read process arguments") - - def environment(self, process: ProcessIdentity) -> dict[str, str]: - raise NotImplementedError(f"{type(self).__name__} does not read process environment") - - def process_name(self, pid: int) -> str: - raise NotImplementedError(f"{type(self).__name__} does not read process names") - - def members_of_group(self, pgid: int) -> tuple[ProcessIdentity, ...]: - # proc_listpids returns bytes. Grow until one query fits; never mistake - # a full buffer for a complete process-group observation. - capacity = 16 - while True: - buffer = (ctypes.c_int * capacity)() - size = self.libproc.proc_listpids(2, pgid, buffer, ctypes.sizeof(buffer)) - if size < 0: - code = ctypes.get_errno() - raise OSError(code, os.strerror(code)) - if size < ctypes.sizeof(buffer): - break - capacity *= 2 - members = [] - for pid in buffer[: size // ctypes.sizeof(ctypes.c_int)]: - if pid > 0: - with suppress(ProcessLookupError): - members.append(self.identity(pid)) - return tuple(members) - - def wait_any_exited( - self, identities: tuple[ProcessIdentity, ...], timeout: float, - ) -> None: - with select.kqueue() as pending: - events = [ - select.kevent( - identity.pid, filter=select.KQ_FILTER_PROC, - flags=select.KQ_EV_ADD | select.KQ_EV_ONESHOT, - fflags=select.KQ_NOTE_EXIT, - ) - for identity in identities - ] - for identity in identities: - try: - current = self.identity(identity.pid) - except ProcessLookupError: - return - if current != identity: - return # Another incarnation holds the pid: this member exited. - try: - returned = pending.control( - events, 1, None if math.isinf(timeout) else max(0, timeout), - ) - for event in returned: - if event.flags & select.KQ_EV_ERROR: - raise OSError(event.data, os.strerror(event.data)) - except ProcessLookupError: - return - class UnitActivity(DeclaredFamily, affix="Unit"): """systemd's ActiveState of a unit, an external contract decoded once by its spelling.""" @@ -1776,16 +945,6 @@ async def answer(self) -> Result: return await asyncio.wrap_future(self) -class AsyncWork: - """Accepted work finishes before its caller releases the operation's resources.""" - - @classmethod - async def run_async[Result](cls, operation: Callable[[], Result]) -> Result: - return await join_retirement(asyncio.create_task(asyncio.to_thread(operation))) - - @classmethod - def cancel_on_shutdown[Result](cls, pending: asyncio.Future[Result]) -> None: - """A mutation must finish, even if its worker has not started yet.""" class ReadWork(AsyncWork): @@ -1882,36 +1041,6 @@ def workers(self, max_workers: int, initializer: Callable[..., object] | None = return ForkedWorkers(max_workers, initializer, initargs) -async def join_retirement[Result](task: asyncio.Future[Result]) -> Result: - """Join owned cleanup through repeated cancellation, then propagate it.""" - interrupted = None - try: - while not task.done(): - try: - # wait does not cancel the original future or replace its own - # typed cancellation with shield's synthetic CancelledError. - await asyncio.wait((task,)) - except asyncio.CancelledError as error: - interrupted = error - result = task.result() - if interrupted is not None and inspect.isawaitable(result): - returned = asyncio.ensure_future(result) - returned.cancel() - try: - await join_retirement(returned) - except asyncio.CancelledError: - pass - except ChildRetirementError: - raise # Cancellation cannot turn an unattested physical stop into success. - except BaseException as error: - # A failed joined operation has still finished. Its error must - # not consume the caller's cancellation and restart an observer loop. - if interrupted is not None: - raise interrupted from error - raise - if interrupted is not None: - raise interrupted - return result class ChildProcess(Sealed, ABC): diff --git a/src/agent_comms/execution/diagnostics.py b/src/agent_comms/execution/diagnostics.py index 3e312ed0e9..70ecc30922 100644 --- a/src/agent_comms/execution/diagnostics.py +++ b/src/agent_comms/execution/diagnostics.py @@ -14,7 +14,7 @@ from metaclass_registry.mro_dispatch import MroDispatch, handles -from agent_comms.execution.child_process import Platform +from agent_comms.execution.process_identity import ProcessPlatform from agent_comms.execution.native_failures import NativeRequestFailure from agent_comms.execution.turn_failure import TurnFailure from agent_comms.nominal.field_codec import ( @@ -158,6 +158,6 @@ def ordinary_evidence(error: BaseException) -> dict: def write(cls, root: Path, name: str, document: dict) -> Path: path = cls.path_in(root, name=name) path.parent.mkdir(mode=0o700, exist_ok=True) - Platform.current().sync_directory(root) + ProcessPlatform.current().sync_directory(root) AtomicFile(path).write_text(json.dumps(document, indent=2) + "\n") return path.resolve() diff --git a/src/agent_comms/execution/goal_scheduler.py b/src/agent_comms/execution/goal_scheduler.py index 02f20aa1a9..099b5fc66f 100644 --- a/src/agent_comms/execution/goal_scheduler.py +++ b/src/agent_comms/execution/goal_scheduler.py @@ -11,7 +11,8 @@ from agent_comms.comms import Comms from agent_comms.coordination.work import CoordinationWork from agent_comms.errors import GoalAttemptError, GoalRefused, RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity, join_retirement +from agent_comms.execution.async_retirement import join_retirement +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_drain import InputDrain, OwnerSession, WakeScheduleCheck from agent_comms.execution.reservation_rules import ReservationViolationError from agent_comms.execution.session_lifecycle import SessionLifecycle diff --git a/src/agent_comms/execution/host_platform.py b/src/agent_comms/execution/host_platform.py index 4b9c3d9abc..900d4f4890 100644 --- a/src/agent_comms/execution/host_platform.py +++ b/src/agent_comms/execution/host_platform.py @@ -15,7 +15,7 @@ from io import BufferedReader from pathlib import Path from tempfile import TemporaryDirectory -from typing import ClassVar +from typing import ClassVar, Self from agent_comms.nominal.declared_family import DeclaredFamily @@ -316,12 +316,16 @@ def share_file(self, source: Path, destination: Path) -> bool: return False # A byte copy would not deliver the inode sharing this operation promises. -class HostPlatform(HostFilesystem, DeclaredFamily, affix="HostPlatform"): - """Lightweight OS declaration for callers needing only filesystem or socket operations.""" +class CurrentPlatform: + """Resolve the current OS member of a platform DeclaredFamily.""" @classmethod - def current(cls) -> HostPlatform: - return cls.member_named(sys.platform)() + def current(cls) -> Self: + return cls.member_named(sys.platform)() # type: ignore[attr-defined] + + +class HostPlatform(CurrentPlatform, HostFilesystem, DeclaredFamily, affix="HostPlatform"): + """Lightweight OS declaration for callers needing only filesystem or socket operations.""" class LinuxHostPlatform(LinuxHostFilesystem, HostPlatform): diff --git a/src/agent_comms/execution/input_drain.py b/src/agent_comms/execution/input_drain.py index 95964787ad..0e2fca6c54 100644 --- a/src/agent_comms/execution/input_drain.py +++ b/src/agent_comms/execution/input_drain.py @@ -30,7 +30,7 @@ from agent_comms.coordination.participant_store import ParticipantSnapshot from agent_comms.coordination.tables.assignments import WakeAssignment from agent_comms.errors import RelationViolationError, UnregisteredThreadError -from agent_comms.execution.child_process import join_retirement +from agent_comms.execution.async_retirement import join_retirement from agent_comms.execution.controller import SessionUpdateSink from agent_comms.execution.cursor_owner import CursorOwner, CursorState from agent_comms.execution.drain_failures import ( diff --git a/src/agent_comms/execution/native_child.py b/src/agent_comms/execution/native_child.py index e4b1343ebe..8f75507de6 100644 --- a/src/agent_comms/execution/native_child.py +++ b/src/agent_comms/execution/native_child.py @@ -10,13 +10,9 @@ from pathlib import Path from typing import TYPE_CHECKING, NoReturn, Self -from agent_comms.execution.child_process import ( - AttachedChild, - ChildOutcome, - NoProcess, - ProcessState, - join_retirement, -) +from agent_comms.execution.async_retirement import join_retirement +from agent_comms.execution.child_process import AttachedChild, ChildOutcome +from agent_comms.execution.process_identity import NoProcess, ProcessState from agent_comms.execution.launch_runtime import INHERITED_ENVIRONMENT from agent_comms.execution.native_attestation import NativeAttestation, PendingAttestation from agent_comms.execution.native_failures import NativePiUnavailable, NativeRequestFailure diff --git a/src/agent_comms/execution/native_input_owner.py b/src/agent_comms/execution/native_input_owner.py index c4bb9e7101..2bcf6dd732 100644 --- a/src/agent_comms/execution/native_input_owner.py +++ b/src/agent_comms/execution/native_input_owner.py @@ -15,7 +15,7 @@ from agent_comms.coordination.participant_store import ParticipantStoreOwner from agent_comms.coordination.tables.participants import OwnerGenerations from agent_comms.errors import RelationViolationError, UnregisteredThreadError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.registry_identity_rules import ( GoalRegistryClaimCheck, GoalRegistryIdentityCheck, diff --git a/src/agent_comms/execution/native_session_files.py b/src/agent_comms/execution/native_session_files.py index 693e897d53..2928ca7967 100644 --- a/src/agent_comms/execution/native_session_files.py +++ b/src/agent_comms/execution/native_session_files.py @@ -16,7 +16,7 @@ from typing import Annotated, ClassVar, Self from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import Platform, ProcessIdentity +from agent_comms.execution.process_identity import ProcessPlatform, ProcessIdentity from agent_comms.execution.native_arguments import SelectedModel from agent_comms.execution.native_failures import NativePiUnavailable from agent_comms.execution.native_input_proof import NativeInputProof @@ -118,7 +118,7 @@ def delete(self) -> int: freed += path.lstat().st_size path.unlink() if self.session.parent.is_dir(): - Platform.current().sync_directory(self.session.parent) + ProcessPlatform.current().sync_directory(self.session.parent) return freed @@ -217,11 +217,11 @@ def prepare_private_directory(cls, directory: Path) -> None: for path in reversed(missing): path.mkdir(mode=0o700, exist_ok=True) cls.require_private_directory(path) - Platform.current().sync_directory(path.parent) + ProcessPlatform.current().sync_directory(path.parent) cls.require_private_directory(directory) parent = directory.parent while True: - Platform.current().sync_directory(parent) + ProcessPlatform.current().sync_directory(parent) if parent == parent.parent: break try: diff --git a/src/agent_comms/execution/native_startup.py b/src/agent_comms/execution/native_startup.py index 3901830380..731e2b52ad 100644 --- a/src/agent_comms/execution/native_startup.py +++ b/src/agent_comms/execution/native_startup.py @@ -6,7 +6,7 @@ from dataclasses import dataclass, field from pathlib import Path -from agent_comms.execution.child_process import NoProcess, ProcessState +from agent_comms.execution.process_identity import NoProcess, ProcessState from agent_comms.execution.native_pi import NativePiRpcLaunch from agent_comms.execution.publication_measurements import PublicationMeasurements from agent_comms.nominal.field_codec import boundary_decoder diff --git a/src/agent_comms/execution/nk_foreground.py b/src/agent_comms/execution/nk_foreground.py index 22b0f808da..99109a63be 100644 --- a/src/agent_comms/execution/nk_foreground.py +++ b/src/agent_comms/execution/nk_foreground.py @@ -27,7 +27,7 @@ from agent_comms.coordinated_runtime import ExecutionRoot, SelectedExecution from agent_comms.coordination.errors import PublicationActivationBlocked from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.cursor_publication import CursorDelivery from agent_comms.execution.native_execution import RunsNativePackage from agent_comms.execution.native_session_files import NativeSessionFiles diff --git a/src/agent_comms/execution/owner_lifecycle.py b/src/agent_comms/execution/owner_lifecycle.py index 88e67984ad..701b81ac9a 100644 --- a/src/agent_comms/execution/owner_lifecycle.py +++ b/src/agent_comms/execution/owner_lifecycle.py @@ -24,7 +24,7 @@ from agent_comms.cli_verbs.cli_result import TargetEditResult from agent_comms.coordination.attempt_recovery import RecoveryMonitorCapability from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import Platform, ProcessIdentity +from agent_comms.execution.process_identity import ProcessPlatform, ProcessIdentity from agent_comms.execution.diagnostics import OwnerProcessOutput from agent_comms.execution.input_key import AcpInputKey, InputKey from agent_comms.execution.launch_root import LaunchRoot @@ -115,7 +115,7 @@ class OwnerRestartSelection: def capture(cls, snapshot: RegistrySnapshot, name: str): owner = snapshot.require_active(name) process = owner.require_process() - platform = Platform.current() + platform = ProcessPlatform.current() platform.require(process) interpreter = process.arguments()[0] if not interpreter: diff --git a/src/agent_comms/execution/persistent_pi_session.py b/src/agent_comms/execution/persistent_pi_session.py index 27ef06608d..be4733118b 100644 --- a/src/agent_comms/execution/persistent_pi_session.py +++ b/src/agent_comms/execution/persistent_pi_session.py @@ -2,7 +2,7 @@ import asyncio -from agent_comms.execution.child_process import ProcessState +from agent_comms.execution.process_identity import ProcessState from agent_comms.execution.native_child import ( BorrowedNative, EmptyNative, diff --git a/src/agent_comms/execution/process_identity.py b/src/agent_comms/execution/process_identity.py new file mode 100644 index 0000000000..8b1892e8d9 --- /dev/null +++ b/src/agent_comms/execution/process_identity.py @@ -0,0 +1,949 @@ +"""Identity-bound process records, procfs memory samples and OS process inspection. + +Split from ``agent_comms.execution.child_process`` so callers that only record, decode or +inspect process incarnations never pull in child-spawning, multiprocessing, helper workers, +systemd units or repository launch machinery. +""" + +from __future__ import annotations + +import asyncio +import ctypes +import math +import os +import select +import signal +import sys +import time +from abc import ABC, abstractmethod +from collections.abc import Callable, Iterator +from contextlib import suppress +from dataclasses import dataclass +from functools import cache +from pathlib import Path +from typing import Annotated, ClassVar, Self + +from agent_comms.errors import RelationViolationError +from agent_comms.execution.host_platform import ( + AndroidHostFilesystem, + CurrentPlatform, + HostFilesystem, + LinuxHostFilesystem, +) +from agent_comms.nominal.declared_family import DeclaredFamily +from agent_comms.nominal.field_codec import ( + FieldCodec, + FieldDirective, + NullMember, + RecordMember, + SubclassUnion, + WireRequired, +) +from agent_comms.registry.thread_identity import ThreadIncarnation, ThreadRole + +STOP_GRACE_SECONDS = 2.0 +PR_SET_NAME = 15 + + +@dataclass(frozen=True) +class ProcfsColumn(FieldDirective): + key: str + scale: int = 1024 + + def value(self, tokens: list[str]) -> int: + return int(tokens[0]) * self.scale + + +class ProcfsRecord: + """Procfs owns the text; field declarations own selection, units and requiredness.""" + + filename: ClassVar[str] + + @classmethod + def read(cls, directory: Path) -> Self: + fields = { + key: value.split() + for line in (directory / cls.filename).read_text().splitlines() + for key, _, value in (line.partition(":"),) + } + return FieldCodec.decode( + cls, + { + plan.key: column.value(fields[column.key]) + for plan in FieldCodec.field_plans(cls) + for column in ProcfsColumn.single(plan.annotation) + if column.key in fields + }, + ) + + +@dataclass(frozen=True) +class ProportionalMemory(ProcfsRecord): + filename = "smaps_rollup" + bytes: Annotated[int, ProcfsColumn("Pss"), WireRequired()] + + +@dataclass(frozen=True) +class ResidentMemory(ProcfsRecord): + """One procfs status sample, in bytes; kernel threads have no resident pages.""" + + filename = "status" + parent: Annotated[int, ProcfsColumn("PPid", 1), WireRequired()] + resident: Annotated[int, ProcfsColumn("VmRSS")] = 0 + peak: Annotated[int, ProcfsColumn("VmHWM")] = 0 + + @classmethod + def tree(cls, process: ProcessIdentity, proc: Path) -> dict[int, ResidentMemory]: + """A sampled descendant set, guarded by the root's exact process birth. The kernel lists + each task's children, so only the subtree's status files are read.""" + if not process.alive(): + return {} + rows: dict[int, ResidentMemory] = {} + pending = [process.pid] + while pending: + pid = pending.pop() + directory = proc / str(pid) + try: + rows[pid] = cls.read(directory) + except (FileNotFoundError, ProcessLookupError): + continue + pending.extend(child for child in cls.children(directory) if child not in rows) + return rows if process.alive() else {} + + @staticmethod + def children(directory: Path) -> Iterator[int]: + """Every task's children: a child forked by a non-leader thread is listed only there.""" + for listing in directory.glob("task/*/children"): + try: + yield from map(int, listing.read_text().split()) + except (FileNotFoundError, ProcessLookupError): + continue + + +class IdentityMismatchError(ProcessLookupError): + """A recorded process incarnation is absent or has been replaced.""" + + +class ProcessSighting[Status](ABC): + """A thread's live presence, answering for the process state its owner has.""" + + __slots__ = () + + @abstractmethod + def heartbeat_seen(self, last_seen: float) -> Status: + """The presence when no process is recorded: the heartbeat is the evidence.""" + + @abstractmethod + def process_seen(self, process: ProcessState) -> Status: + """The presence when a process is recorded for it.""" + + +class ProcessFence[Status](ABC): + """A stored stop, answering for whether a process still binds it.""" + + __slots__ = () + + @abstractmethod + def unbound(self) -> Status: + """The stop when no process binds it.""" + + @abstractmethod + def fenced(self) -> Status: + """The stop while its process still binds it.""" + + +class NativeBinding[Presentation](ABC): + """A registry lease that presents its thread natively once a process holds it.""" + + __slots__ = () + + @abstractmethod + def native_presentation(self, ordinary: Presentation) -> Presentation: ... + + +class ProcessRestart[Change](ABC): + """A registration change over a prior incarnation, kept or restarted by its processes.""" + + __slots__ = () + + @property + @abstractmethod + def previous_incarnation(self) -> ThreadIncarnation: ... + + @abstractmethod + def kept(self) -> Change: + """The change as requested: no process restarts it.""" + + @abstractmethod + def restarted(self) -> Change: + """The change once a process replaces the prior incarnation's.""" + + +class ProcessState(SubclassUnion, affix=""): + """An exact recorded process or a worker which has never started.""" + + @abstractmethod + def allows_owner_start(self) -> bool: ... + + def require_owner_startable(self) -> None: + """Refuse if the process state does not allow starting an owner.""" + raise RelationViolationError("Retired session acquired another process") + + @abstractmethod + def allows_inactive_stop(self) -> bool: ... + + @abstractmethod + def require_held_by(self, role: type[ThreadRole]) -> None: ... + + @abstractmethod + def conflicts_with(self, previous: ProcessState) -> bool: ... + + @abstractmethod + def registration_change[Change]( + self, + previous: ProcessState, + change: ProcessRestart[Change], + incarnation: ThreadIncarnation, + ) -> Change: ... + + @abstractmethod + def restarted_registration[Change]( + self, + change: ProcessRestart[Change], + incarnation: ThreadIncarnation, + ) -> Change: ... + + @abstractmethod + def native_presentation[Presentation]( + self, + ordinary: Presentation, + binding: NativeBinding[Presentation], + ) -> Presentation: ... + + @abstractmethod + def applied(self, previous: ProcessState) -> ProcessState: ... + + @abstractmethod + def offline(self) -> bool: ... + + @abstractmethod + def require(self, message: str = "No worker process has started") -> ProcessIdentity: ... + + @abstractmethod + def alive(self) -> bool: ... + + @abstractmethod + def thread_status[Status](self, presence: ProcessSighting[Status], last_seen: float) -> Status: ... + + @abstractmethod + def stopped_seen[Status](self, stopped: ProcessFence[Status]) -> Status: + """A stored stop with no process is stopped; one still bound is a fence.""" + + @abstractmethod + def runs_here(self) -> bool: ... + + @abstractmethod + def signal(self, signum: int) -> None: ... + + @abstractmethod + def require_release_by(self, process: ProcessIdentity) -> None: ... + + @abstractmethod + def held_external_stop(self, release: Callable[[], None], name: str) -> str | None: + """Stop a CLI endpoint this process holds: the name still for the ordinary stop, if any.""" + + +@dataclass(frozen=True) +class NoProcess(NullMember, ProcessState): + def allows_owner_start(self) -> bool: + return True + + def allows_inactive_stop(self) -> bool: + return True + + def require_held_by(self, role: type[ThreadRole]) -> None: + """No process is held, so any role may declare it.""" + + def conflicts_with(self, previous: ProcessState) -> bool: + return False + + def registration_change[Change]( + self, + previous: ProcessState, + change: ProcessRestart[Change], + incarnation: ThreadIncarnation, + ) -> Change: + return change.kept() + + def restarted_registration[Change]( + self, + change: ProcessRestart[Change], + incarnation: ThreadIncarnation, + ) -> Change: + return change.kept() + + def native_presentation[Presentation]( + self, + ordinary: Presentation, + binding: NativeBinding[Presentation], + ) -> Presentation: + return ordinary + + def applied(self, previous: ProcessState) -> ProcessState: + return previous + + def offline(self) -> bool: + return False + + def require(self, message: str = "No worker process has started") -> ProcessIdentity: + raise RelationViolationError(message) + + def alive(self) -> bool: + return False + + def thread_status[Status](self, presence: ProcessSighting[Status], last_seen: float) -> Status: + return presence.heartbeat_seen(last_seen) + + def stopped_seen[Status](self, stopped: ProcessFence[Status]) -> Status: + return stopped.unbound() + + def runs_here(self) -> bool: + return False + + def signal(self, signum: int) -> None: + pass + + def require_release_by(self, process: ProcessIdentity) -> None: + # Stopping before the first start still produces a valid release. + pass + + def held_external_stop(self, release: Callable[[], None], name: str) -> str | None: + """Nothing holds the endpoint, so the ordinary stop finishes it on the bus.""" + return name + + def require_owner_startable(self) -> None: + pass + + +@dataclass(frozen=True) +class ProcessName: + """One short kernel-visible name published by the process that owns the role.""" + + value: str + + def __post_init__(self) -> None: + encoded = self.value.encode("utf-8") + if not encoded or len(encoded) > 15 or not self.value.isprintable(): + raise ValueError("A process name needs 1-15 safe UTF-8 bytes") + + @property + def encoded(self) -> bytes: + return self.value.encode("utf-8") + + def publish(self) -> None: + ProcessPlatform.current().publish_process_name(self) + + +@dataclass(frozen=True) +class ProcessIdentity(RecordMember, ProcessState): + pid: int + start_time: int + + def __post_init__(self) -> None: + if self.pid <= 0 or self.start_time <= 0: + raise ValueError("A positive PID and platform start time are required") + + def memory(self, proc: Path = Path("/proc")) -> ResidentMemory: + platform = ProcessPlatform.current() + platform.require(self) + result = ResidentMemory.read(proc / str(self.pid)) + platform.require(self) + return result + + @classmethod + def pid_argument(cls, value: str) -> dict[str, object]: + return FieldCodec.encode_record(cls.capture(int(value))) + + @classmethod + def capture(cls, pid: int) -> ProcessIdentity: + return cls.current() if pid == os.getpid() else ProcessPlatform.current().identity(pid) + + @classmethod + def current(cls) -> ProcessIdentity: + """The caller's immutable birth; a fork selects its own PID, not its parent's.""" + return cls._current(os.getpid()) + + @staticmethod + @cache + def _current(pid: int) -> ProcessIdentity: + return ProcessPlatform.current().identity(pid) + + def allows_owner_start(self) -> bool: + return False + + def allows_inactive_stop(self) -> bool: + return self.runs_here() + + def require_held_by(self, role: type[ThreadRole]) -> None: + role.require_executable( + RelationViolationError("A human thread cannot hold an owner process") + ) + + def conflicts_with(self, previous: ProcessState) -> bool: + return self != previous + + def offline(self) -> bool: + return not self.alive() + + def native_presentation[Presentation]( + self, + ordinary: Presentation, + binding: NativeBinding[Presentation], + ) -> Presentation: + return binding.native_presentation(ordinary) + + def applied(self, previous: ProcessState) -> ProcessState: + return self + + def require(self, message: str = "No worker process has started") -> ProcessIdentity: + return self + + @staticmethod + def in_group(pid: int, start_time: int, pgid: int) -> ProcessIdentity: + return GroupLeader(pid, start_time) if pgid == pid else GroupMember(pid, start_time) + + def __eq__(self, other: object) -> bool: + if not isinstance(other, ProcessIdentity): + return NotImplemented + return (self.pid, self.start_time) == (other.pid, other.start_time) + + def alive(self) -> bool: + return ProcessPlatform.current().matches(self) + + def arguments(self) -> tuple[str, ...]: + return ProcessPlatform.current().arguments(self) + + def environment(self) -> dict[str, str]: + return ProcessPlatform.current().environment(self) + + def require_alive(self) -> ProcessIdentity: + """Validate this recorded PID and start time against the live process.""" + return ProcessPlatform.current().require(self) + + def runs_here(self) -> bool: + return os.getpid() == self.pid + + def signal(self, signum: int) -> None: + ProcessPlatform.current().send(self, signum) + + def lineage(self) -> Iterator[ProcessIdentity]: + """This incarnation and its exact ancestors, ending at PID 1.""" + platform = ProcessPlatform.current() + current = self + while True: + yield current + if current.pid == 1: + return + current = platform.parent_identity(current.pid) + + def require_ancestor_of(self, pid: int) -> None: + """A supplied process is authority only for its actual descendant.""" + platform = ProcessPlatform.current() + platform.require(self) + if self in platform.identity(pid).lineage(): + return + raise IdentityMismatchError("The declared process is not an ancestor of this hook") + + async def wait_exited(self) -> None: + await ProcessPlatform.current().wait_exited(self) + + def require_release_by(self, process: ProcessIdentity) -> None: + if self != process: + raise RelationViolationError("Only the registered owner may release itself.") + + def held_external_stop(self, release: Callable[[], None], name: str) -> str | None: + """A live holder (a CLI bridge or the connector's inbox watch) serves no owner runtime to + retire, so its binding is released for it. A dead holder left a binding the ordinary stop + finishes.""" + if not self.alive(): + return name + release() + return None + + def thread_status[Status](self, presence: ProcessSighting[Status], last_seen: float) -> Status: + return presence.process_seen(self) + + def stopped_seen[Status](self, stopped: ProcessFence[Status]) -> Status: + return stopped.fenced() + + def registration_change[Change]( + self, + previous: ProcessState, + change: ProcessRestart[Change], + incarnation: ThreadIncarnation, + ) -> Change: + return previous.restarted_registration(change, incarnation) + + def restarted_registration[Change]( + self, + change: ProcessRestart[Change], + incarnation: ThreadIncarnation, + ) -> Change: + return change.restarted() if incarnation != change.previous_incarnation else change.kept() + + def members(self, platform: ProcessOperations) -> tuple[ProcessIdentity, ...]: + return () # A stored, exited identity cannot grant group ownership. + + +NO_PROCESS = NoProcess() + + +class GroupLeader(ProcessIdentity, declared_name=None): + def members(self, platform: ProcessOperations) -> tuple[ProcessIdentity, ...]: + return tuple( + member + for member in platform.members_of_group(self.pid) + if member.start_time >= self.start_time + ) + + +class GroupMember(ProcessIdentity, declared_name=None): + def members(self, platform: ProcessOperations) -> tuple[ProcessIdentity, ...]: + return (self,) if platform.matches(self) else () + + +class PidfdHandles: + @staticmethod + def open_pidfd(pid: int) -> int: + """Use libc when a portable Python build omitted Linux wrappers.""" + if hasattr(os, "pidfd_open"): + return os.pidfd_open(pid) + libc = ctypes.CDLL(None, use_errno=True) + function = getattr(libc, "pidfd_open", None) + if function is None: + raise NotImplementedError("Linux libc pidfd_open unavailable") + function.argtypes = (ctypes.c_int, ctypes.c_uint) + function.restype = ctypes.c_int + descriptor = function(pid, 0) + if descriptor < 0: + code = ctypes.get_errno() + raise OSError(code, os.strerror(code)) + return int(descriptor) + + @staticmethod + def signal_pidfd(pidfd: int, sig: int) -> None: + if hasattr(signal, "pidfd_send_signal"): + signal.pidfd_send_signal(pidfd, sig) + return + libc = ctypes.CDLL(None, use_errno=True) + function = getattr(libc, "pidfd_send_signal", None) + if function is None: + raise NotImplementedError("Linux libc pidfd_send_signal unavailable") + function.argtypes = (ctypes.c_int, ctypes.c_int, ctypes.c_void_p, ctypes.c_uint) + function.restype = ctypes.c_int + if function(pidfd, sig, None, 0) < 0: + code = ctypes.get_errno() + raise OSError(code, os.strerror(code)) + + +class ProcessOperations(HostFilesystem, ABC): + """OS process inspection, liveness, naming and signalling without child spawning.""" + + @abstractmethod + def require_watched_procfs(self, refusal: Exception) -> None: ... + + def terminate_group(self, identity: ProcessIdentity) -> None: + self.signal_group(identity, signal.SIGTERM) + + def force_group(self, identity: ProcessIdentity) -> None: + self.signal_group(identity, signal.SIGKILL) + + @abstractmethod + def identity(self, pid: int) -> ProcessIdentity: ... + + def started_at(self, identity: ProcessIdentity) -> float: + """This recorded process's birth on the monotonic clock.""" + raise NotImplementedError("This platform does not expose process elapsed time") + + @abstractmethod + def arguments(self, process: ProcessIdentity) -> tuple[str, ...]: ... + + @abstractmethod + def environment(self, process: ProcessIdentity) -> dict[str, str]: ... + + @abstractmethod + def process_name(self, pid: int) -> str: ... + + def publish_process_name(self, name: ProcessName) -> None: + """Keep the inherited executable name on platforms without a naming operation.""" + return None + + def parent_identity(self, pid: int) -> ProcessIdentity: + raise NotImplementedError("This platform does not expose exact parent identities") + + async def wait_exited(self, identity: ProcessIdentity) -> None: + """Wait for one incarnation's exit; members with a loop-readable handle override this.""" + await asyncio.to_thread(self.wait_any_exited, (identity,), math.inf) + + @abstractmethod + def wait_any_exited( + self, identities: tuple[ProcessIdentity, ...], timeout: float, + ) -> None: + """Wait for a member's exit or the caller's remaining deadline.""" + + def matches(self, identity: ProcessIdentity) -> bool: + if identity.runs_here(): + return identity == ProcessIdentity.current() + try: + return self.identity(identity.pid) == identity + except ProcessLookupError: + return False + + def require(self, identity: ProcessIdentity) -> ProcessIdentity: + with suppress(ProcessLookupError): + current = self.identity(identity.pid) + if current == identity: + return current + raise IdentityMismatchError(f"Process incarnation changed: {identity.pid}") + + def send(self, identity: ProcessIdentity, signum: int) -> None: + self.require(identity) + os.kill(identity.pid, signum) + + def group_members(self, leader: ProcessIdentity) -> tuple[ProcessIdentity, ...]: + try: + current = self.identity(leader.pid) + except ProcessLookupError: + return leader.members(self) + if current != leader: + raise IdentityMismatchError(f"Process incarnation changed: {leader.pid}") + return current.members(self) + + def signal_group(self, leader: ProcessIdentity, signum: int) -> None: + # Snapshot identities, then signal each exact member. Never signal a + # numeric group after its leader may have been reaped and reused. + signalled = 0 + for member in self.group_members(leader): + try: + self.send(member, signum) + except ProcessLookupError: + continue + signalled += 1 + if not signalled and self.matches(leader): + raise RuntimeError(f"Live process {leader.pid} was not signalled") + + def parent_death_binding(self) -> int: + """Darwin has no parent-death signal: its exec gate binds no launcher.""" + return 0 + + @abstractmethod + def members_of_group(self, pgid: int) -> tuple[ProcessIdentity, ...]: ... + + +@dataclass(frozen=True) +class LinuxProcessRecord: + identity: ProcessIdentity + group: int + parent: int + flags: int = 0 + + +class LinuxProcessOperations(PidfdHandles, LinuxHostFilesystem, ProcessOperations): + def require_watched_procfs(self, refusal: Exception) -> None: + return None + + def parent_death_binding(self) -> int: + """The exec gate arms PR_SET_PDEATHSIG and binds to this launcher's PID.""" + return os.getpid() + + @staticmethod + def _stat(pid: int) -> LinuxProcessRecord: + """One process as the kernel has it now. A process changes group at exec and its PID + is reused after it dies, so no earlier read answers for a later one.""" + try: + # comm can contain whitespace and ')'; fields after its final ')' + # start at field 3. Kernel starttime is field 22, pgrp is field 5, + # flags field 9 (0-indexed within the post-comm split: 6). + fields = Path(f"/proc/{pid}/stat").read_text().rsplit(") ", 1)[1].split() + except FileNotFoundError: + raise ProcessLookupError(pid) from None + if fields[0] in {"Z", "X"}: + raise ProcessLookupError(pid) + group = int(fields[2]) + return LinuxProcessRecord( + ProcessIdentity.in_group(pid, int(fields[19]), group), + group, + int(fields[1]), + flags=int(fields[6]), + ) + + def identity(self, pid: int) -> ProcessIdentity: + return self._stat(pid).identity + + def started_at(self, identity: ProcessIdentity) -> float: + started = identity.start_time / os.sysconf("SC_CLK_TCK") + age = time.clock_gettime(time.CLOCK_BOOTTIME) - started + return time.monotonic() - age + + def arguments(self, process: ProcessIdentity) -> tuple[str, ...]: + return self._proc_cmdline(process.pid) + + def environment(self, process: ProcessIdentity) -> dict[str, str]: + try: + raw = Path(f"/proc/{process.pid}/environ").read_bytes() + except FileNotFoundError: + raise ProcessLookupError(process.pid) from None + values = (item.split(b"=", 1) for item in raw.split(b"\0") if b"=" in item) + return {os.fsdecode(key): os.fsdecode(value) for key, value in values} + + def process_name(self, pid: int) -> str: + try: + return Path(f"/proc/{pid}/comm").read_text().strip() + except FileNotFoundError: + raise ProcessLookupError(pid) from None + + def publish_process_name(self, name: ProcessName) -> None: + operation = ctypes.CDLL(None, use_errno=True).prctl + operation.argtypes = ( + ctypes.c_int, + ctypes.c_char_p, + ctypes.c_ulong, + ctypes.c_ulong, + ctypes.c_ulong, + ) + operation.restype = ctypes.c_int + if operation(PR_SET_NAME, name.encoded, 0, 0, 0): + code = ctypes.get_errno() + raise OSError(code, os.strerror(code)) + + def _lock_holder_command(self, pid: int) -> tuple[str, ...]: + return self.arguments(self.identity(pid)) + + def parent_identity(self, pid: int) -> ProcessIdentity: + return self.identity(self._stat(pid).parent) + + async def wait_exited(self, identity: ProcessIdentity) -> None: + try: + descriptor = self.open_pidfd(identity.pid) + except ProcessLookupError: + return + try: + self.require(identity) + loop = asyncio.get_running_loop() + exited = loop.create_future() + + def observe() -> None: + if not exited.done(): + exited.set_result(None) + + loop.add_reader(descriptor, observe) + try: + await exited + finally: + loop.remove_reader(descriptor) + except ProcessLookupError: + return + finally: + os.close(descriptor) + + def wait_any_exited( + self, identities: tuple[ProcessIdentity, ...], timeout: float, + ) -> None: + descriptors: list[int] = [] + try: + pending = select.poll() + for identity in identities: + try: + descriptor = self.open_pidfd(identity.pid) + descriptors.append(descriptor) + current = self.identity(identity.pid) + except ProcessLookupError: + return + if current != identity: + return # Another incarnation holds the pid: this member exited. + pending.register(descriptor, select.POLLIN) + pending.poll(None if math.isinf(timeout) else max(0, math.ceil(timeout * 1000))) + finally: + for descriptor in descriptors: + os.close(descriptor) + + def members_of_group(self, pgid: int) -> tuple[ProcessIdentity, ...]: + """The kernel answers an empty group in one call; only a live one walks /proc.""" + try: + os.killpg(pgid, 0) + except ProcessLookupError: + return () + except PermissionError: + pass + members = [] + for entry in Path("/proc").iterdir(): + if entry.name.isdecimal(): + with suppress(ProcessLookupError): + record = self._stat(int(entry.name)) + if record.group == pgid: + members.append(record.identity) + return tuple(members) + + def send(self, identity: ProcessIdentity, signum: int) -> None: + # Bind first; recheck start time against the pidfd-bound incarnation + # before signaling. A concurrent exit can never target a reused PID. + descriptor = self.open_pidfd(identity.pid) + try: + self.require(identity) + self.signal_pidfd(descriptor, signum) + finally: + os.close(descriptor) + + +class AndroidProcessOperations(AndroidHostFilesystem, LinuxProcessOperations): + """Termux's Python names Android; its process and file operations use the Linux kernel.""" + + +class DarwinProcessOperations(ProcessOperations): + """libproc exposes microsecond birth times, unlike formatted ps output.""" + + def require_watched_procfs(self, refusal: Exception) -> None: + raise refusal + + class ProcessInfo(ctypes.Structure): + # External Darwin proc_bsdinfo ABI, from xnu/bsd/sys/proc_info.h. + _fields_ = [ + (name, ctypes.c_uint32) + for name in ( + "flags", + "status", + "xstatus", + "pid", + "ppid", + "uid", + "gid", + "ruid", + "rgid", + "svuid", + "svgid", + "reserved", + ) + ] + [ + ("comm", ctypes.c_char * 16), + ("name", ctypes.c_char * 32), + ("nfiles", ctypes.c_uint32), + ("pgid", ctypes.c_uint32), + ("pjobc", ctypes.c_uint32), + ("tdev", ctypes.c_uint32), + ("tpgid", ctypes.c_uint32), + ("nice", ctypes.c_int32), + ("start_seconds", ctypes.c_uint64), + ("start_microseconds", ctypes.c_uint64), + ] + + def __init__(self) -> None: + self.libproc = ctypes.CDLL("/usr/lib/libproc.dylib", use_errno=True) + self.libproc.proc_pidinfo.argtypes = ( + ctypes.c_int, + ctypes.c_int, + ctypes.c_uint64, + ctypes.c_void_p, + ctypes.c_int, + ) + self.libproc.proc_pidinfo.restype = ctypes.c_int + self.libproc.proc_listpids.argtypes = ( + ctypes.c_uint32, + ctypes.c_uint32, + ctypes.c_void_p, + ctypes.c_int, + ) + self.libproc.proc_listpids.restype = ctypes.c_int + + def identity(self, pid: int) -> ProcessIdentity: + info = self.ProcessInfo() + size = self.libproc.proc_pidinfo(pid, 3, 0, ctypes.byref(info), ctypes.sizeof(info)) + if size != ctypes.sizeof(info): + code = ctypes.get_errno() + if code == 3: # ESRCH, the actual OS absence result. + raise ProcessLookupError(pid) + raise OSError(code, os.strerror(code)) + if info.status == 5: # SZOMB: exited, awaiting reap. + raise ProcessLookupError(pid) + return ProcessIdentity.in_group( + pid, + info.start_seconds * 1_000_000 + info.start_microseconds, + info.pgid, + ) + + def started_at(self, identity: ProcessIdentity) -> float: + return time.monotonic() - (time.time() - identity.start_time / 1_000_000) + + def arguments(self, process: ProcessIdentity) -> tuple[str, ...]: + raise NotImplementedError(f"{type(self).__name__} does not read process arguments") + + def environment(self, process: ProcessIdentity) -> dict[str, str]: + raise NotImplementedError(f"{type(self).__name__} does not read process environment") + + def process_name(self, pid: int) -> str: + raise NotImplementedError(f"{type(self).__name__} does not read process names") + + def members_of_group(self, pgid: int) -> tuple[ProcessIdentity, ...]: + # proc_listpids returns bytes. Grow until one query fits; never mistake + # a full buffer for a complete process-group observation. + capacity = 16 + while True: + buffer = (ctypes.c_int * capacity)() + size = self.libproc.proc_listpids(2, pgid, buffer, ctypes.sizeof(buffer)) + if size < 0: + code = ctypes.get_errno() + raise OSError(code, os.strerror(code)) + if size < ctypes.sizeof(buffer): + break + capacity *= 2 + members = [] + for pid in buffer[: size // ctypes.sizeof(ctypes.c_int)]: + if pid > 0: + with suppress(ProcessLookupError): + members.append(self.identity(pid)) + return tuple(members) + + def wait_any_exited( + self, identities: tuple[ProcessIdentity, ...], timeout: float, + ) -> None: + with select.kqueue() as pending: + events = [ + select.kevent( + identity.pid, + filter=select.KQ_FILTER_PROC, + flags=select.KQ_EV_ADD | select.KQ_EV_ONESHOT, + fflags=select.KQ_NOTE_EXIT, + ) + for identity in identities + ] + for identity in identities: + try: + current = self.identity(identity.pid) + except ProcessLookupError: + return + if current != identity: + return # Another incarnation holds the pid: this member exited. + try: + returned = pending.control( + events, 1, None if math.isinf(timeout) else max(0, timeout), + ) + for event in returned: + if event.flags & select.KQ_EV_ERROR: + raise OSError(event.data, os.strerror(event.data)) + except ProcessLookupError: + return + + +class ProcessPlatform(CurrentPlatform, ProcessOperations, DeclaredFamily, affix="ProcessPlatform"): + """Lightweight OS declaration for callers needing process identity or inspection.""" + + +class LinuxProcessPlatform(LinuxProcessOperations, ProcessPlatform): + """Linux process inspection and filesystem platform.""" + + +class AndroidProcessPlatform(AndroidProcessOperations, LinuxProcessPlatform): + """Android process inspection and filesystem platform.""" + + +class DarwinProcessPlatform(DarwinProcessOperations, ProcessPlatform): + """Darwin process inspection and filesystem platform.""" diff --git a/src/agent_comms/execution/queued_input.py b/src/agent_comms/execution/queued_input.py index d7e479c90a..4c0334cdd0 100644 --- a/src/agent_comms/execution/queued_input.py +++ b/src/agent_comms/execution/queued_input.py @@ -24,7 +24,7 @@ from agent_comms.coordination.session import ReadNativeCoordinationSession from agent_comms.coordination.tables.assignments import WakeAssignment from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.controller import NO_CONTROLLER, Controller from agent_comms.execution.image_input import ImageInput from agent_comms.execution.input_key import AcpInputKey, InputKey diff --git a/src/agent_comms/execution/registry_identity_rules.py b/src/agent_comms/execution/registry_identity_rules.py index e33a3e53e6..ba3981e9bb 100644 --- a/src/agent_comms/execution/registry_identity_rules.py +++ b/src/agent_comms/execution/registry_identity_rules.py @@ -4,7 +4,7 @@ from dataclasses import dataclass -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.reservation_rules import ReservationRule, RuleCheck from agent_comms.execution.turn_goal_permission import GoalPermission from agent_comms.registry.threads import Thread diff --git a/src/agent_comms/execution/remote_core_process.py b/src/agent_comms/execution/remote_core_process.py index fc2bd2420a..5748087901 100644 --- a/src/agent_comms/execution/remote_core_process.py +++ b/src/agent_comms/execution/remote_core_process.py @@ -11,7 +11,8 @@ from metaclass_registry.mro_dispatch import MroDispatch, handles -from agent_comms.execution.child_process import Platform, ProcessName, WorkerStart +from agent_comms.execution.child_process import Platform, WorkerStart +from agent_comms.execution.process_identity import ProcessName from agent_comms.execution.thread_launch import ThreadLaunch from agent_comms.transport.remote_core import RemoteCoreAccess from agent_comms.transport.request import ReadRequest, ToolRequest diff --git a/src/agent_comms/execution/request_diagnostics.py b/src/agent_comms/execution/request_diagnostics.py index b23ac5039a..6a1599c9b6 100644 --- a/src/agent_comms/execution/request_diagnostics.py +++ b/src/agent_comms/execution/request_diagnostics.py @@ -9,7 +9,7 @@ from pathlib import Path from typing import Annotated -from agent_comms.execution.child_process import ProcessState +from agent_comms.execution.process_identity import ProcessState from agent_comms.execution.publication_measurements import ( CoordinatorRun, CoordinatorWait, diff --git a/src/agent_comms/execution/request_progress.py b/src/agent_comms/execution/request_progress.py index 9d3e741f62..3dc646c033 100644 --- a/src/agent_comms/execution/request_progress.py +++ b/src/agent_comms/execution/request_progress.py @@ -5,7 +5,7 @@ from dataclasses import dataclass from typing import Annotated, Literal -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.pi_wire import PiPayload from agent_comms.execution.turn_item import NativeTurnIdText from agent_comms.nominal import field_codec diff --git a/src/agent_comms/execution/restart_queue.py b/src/agent_comms/execution/restart_queue.py index 88b58f79e9..892ea2d240 100644 --- a/src/agent_comms/execution/restart_queue.py +++ b/src/agent_comms/execution/restart_queue.py @@ -22,12 +22,8 @@ from agent_comms.coordination.work import CoordinationWork from agent_comms.coordination.errors import CoordinationError from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( - OutlivesLauncherLifetime, - Platform, - ProcessIdentity, - SpawnedProcess, -) +from agent_comms.execution.child_process import OutlivesLauncherLifetime, Platform, SpawnedProcess +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime, RecordedRuntime, RestartEnvironment from agent_comms.execution.native_arguments import GivenBinary, NativeArguments from agent_comms.execution.owner_cutover import PreserveOwnerRuntime diff --git a/src/agent_comms/execution/root_host_store.py b/src/agent_comms/execution/root_host_store.py index 0b21b3bc39..66eab1fe51 100644 --- a/src/agent_comms/execution/root_host_store.py +++ b/src/agent_comms/execution/root_host_store.py @@ -7,10 +7,11 @@ from typing import TextIO from agent_comms.execution.child_process import ( + ObservedProcess, OutlivesLauncherLifetime, - ProcessIdentity, SpawnedProcess, ) +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.root_runtime import ( HostRetirement, @@ -34,6 +35,9 @@ def retire_host(self) -> RootHost: """Retire this root's physical host only after its logical owners detached.""" return self.read().host.retired_through(self) + def stop_host(self, process: ProcessIdentity) -> None: + ObservedProcess(process).stop_sync() + def host_retired_once_ownerless(self) -> RootHost: """Keep the registry cut current through the host write: no new owner may attach between the ownership decision and the physical retirement. @@ -41,7 +45,9 @@ def host_retired_once_ownerless(self) -> RootHost: with RegistryStore.at(self.path.parent).current_snapshot() as cut: def retire(data: RootRuntime) -> DocumentChange[RootRuntime, RootHost]: if data.host.retire( - self.path.parent, lambda process: not cut.snapshot.process_owners(process), + self.path.parent, + lambda process: not cut.snapshot.process_owners(process), + self, ): data = replace(data, host=NoRootHost()) return DocumentChange(data, data.host) diff --git a/src/agent_comms/execution/root_runtime_read.py b/src/agent_comms/execution/root_runtime_read.py index 4aaa31f7e4..cb9d6ca8f0 100644 --- a/src/agent_comms/execution/root_runtime_read.py +++ b/src/agent_comms/execution/root_runtime_read.py @@ -9,13 +9,12 @@ from typing import Annotated from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( +from agent_comms.execution.launch_runtime import LaunchRuntime +from agent_comms.execution.process_identity import ( NoProcess, - ObservedProcess, ProcessIdentity, ProcessState, ) -from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.messaging.recorded_bus import RecordedBus, RecordedBusIdentity from agent_comms.nominal.declared_family import DeclaredFamily from agent_comms.nominal.field_codec import PathText, WireOmitDefault @@ -95,12 +94,17 @@ class HostRetirement(FileStore, ABC): @abstractmethod def host_retired_once_ownerless(self) -> RootHost: ... + @abstractmethod + def stop_host(self, process: ProcessIdentity) -> None: ... + class RootHost(DeclaredFamily, affix="RootHost"): def observed(self, root: Path) -> ProcessState: return NoProcess() - def retire(self, root: Path, ready: Callable[[ProcessIdentity], bool]) -> bool: + def retire( + self, root: Path, ready: Callable[[ProcessIdentity], bool], retirement: HostRetirement, + ) -> bool: return True def retired_through(self, store: HostRetirement) -> RootHost: @@ -123,13 +127,15 @@ class RecordedRootHost(RootHost): process: ProcessIdentity bus: RecordedBus - def retire(self, root: Path, ready: Callable[[ProcessIdentity], bool]) -> bool: + def retire( + self, root: Path, ready: Callable[[ProcessIdentity], bool], retirement: HostRetirement, + ) -> bool: observed = self.observed(root) if observed.alive(): process = observed.require() if not ready(process): return False - ObservedProcess(process).stop_sync() + retirement.stop_host(process) return True def retired_through(self, store: HostRetirement) -> RootHost: diff --git a/src/agent_comms/execution/runtime_processes.py b/src/agent_comms/execution/runtime_processes.py index 98a5df6f6e..5761266940 100644 --- a/src/agent_comms/execution/runtime_processes.py +++ b/src/agent_comms/execution/runtime_processes.py @@ -7,7 +7,7 @@ from dataclasses import dataclass, field from pathlib import Path -from agent_comms.execution.child_process import IdentityMismatchError, Platform, ProcessIdentity +from agent_comms.execution.process_identity import IdentityMismatchError, ProcessPlatform, ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.nominal.declared_family import DeclaredFamily @@ -318,7 +318,7 @@ def unread(self) -> tuple[str, ...]: return tuple(line for outcome in self.outcomes for line in outcome.unread()) @classmethod - def imports(cls, platform: Platform, identity: ProcessIdentity, directory: Path, + def imports(cls, platform: ProcessPlatform, identity: ProcessIdentity, directory: Path, command: RuntimeReference) -> tuple[RuntimeProcessOutcome, ...]: """What this process can import from inside the installation. @@ -350,7 +350,7 @@ def under(cls, directory: Path, *, scope: RuntimeProcessScope = RuntimeProcessSc proc: Path = Path("/proc")) -> RuntimeProcesses: """Read references below this exact directory; grants no stop authority.""" outcomes: list[RuntimeProcessOutcome] = [] - platform = Platform.current() + platform = ProcessPlatform.current() observer = ProcessIdentity.capture(os.getpid()) for entry in proc.iterdir(): if not entry.name.isdecimal(): diff --git a/src/agent_comms/execution/session_config_options.py b/src/agent_comms/execution/session_config_options.py index e012e3cac4..2e9d36def9 100644 --- a/src/agent_comms/execution/session_config_options.py +++ b/src/agent_comms/execution/session_config_options.py @@ -24,7 +24,7 @@ from agent_comms.config_options import ConfigOptions, ConfigurationChanges from agent_comms.coordination.work import CoordinationWork from agent_comms.coordination.errors import IdentityConflict, Refused -from agent_comms.execution.child_process import join_retirement +from agent_comms.execution.async_retirement import join_retirement from agent_comms.execution.controller import SessionUpdateSink from agent_comms.execution.native_arguments import NativeArguments from agent_comms.execution.native_failures import NativePiUnavailable diff --git a/src/agent_comms/execution/session_lifecycle.py b/src/agent_comms/execution/session_lifecycle.py index 49e9bd9c06..8ee25f9656 100644 --- a/src/agent_comms/execution/session_lifecycle.py +++ b/src/agent_comms/execution/session_lifecycle.py @@ -34,7 +34,8 @@ from agent_comms.coordination.work import CoordinationWork from agent_comms.coordination.errors import Refused from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity, join_retirement +from agent_comms.execution.async_retirement import join_retirement +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.controller import NO_CONTROLLER, NoController from agent_comms.execution.input_key import InputKey, InputKeyText from agent_comms.execution.thread_launch import ThreadLaunch diff --git a/src/agent_comms/execution/session_tasks.py b/src/agent_comms/execution/session_tasks.py index 33f6b166b3..63e06186af 100644 --- a/src/agent_comms/execution/session_tasks.py +++ b/src/agent_comms/execution/session_tasks.py @@ -10,7 +10,7 @@ from dataclasses import dataclass from agent_comms.agent_backend import AgentBackend -from agent_comms.execution.child_process import join_retirement +from agent_comms.execution.async_retirement import join_retirement from agent_comms.messaging.watched import ChangeSignal diff --git a/src/agent_comms/execution/test_lease.py b/src/agent_comms/execution/test_lease.py index 393f71c7fb..f9f430f3a5 100644 --- a/src/agent_comms/execution/test_lease.py +++ b/src/agent_comms/execution/test_lease.py @@ -13,7 +13,7 @@ from pathlib import Path from typing import ClassVar, TextIO -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.storage.store_files import SourceTier from agent_comms_hooks.process_claim import ClaimHeldError, ProcessSingleton diff --git a/src/agent_comms/execution/turn_lease.py b/src/agent_comms/execution/turn_lease.py index 1939050029..b7609f2a6a 100644 --- a/src/agent_comms/execution/turn_lease.py +++ b/src/agent_comms/execution/turn_lease.py @@ -11,7 +11,7 @@ from pydantic import JsonValue from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity, ProcessState +from agent_comms.execution.process_identity import ProcessIdentity, ProcessState from agent_comms.execution.reported_turn import NoReportedTurn, ReportedTurn, ReportedTurnState from agent_comms.execution.turn_phase import IdlePhase, PreparingPhase, TurnPhase from agent_comms.execution.turn_registry import TurnRegistry diff --git a/src/agent_comms/execution/turn_phase.py b/src/agent_comms/execution/turn_phase.py index ea4043c2c4..d2ad88eef9 100644 --- a/src/agent_comms/execution/turn_phase.py +++ b/src/agent_comms/execution/turn_phase.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, ClassVar, Self from agent_comms.execution.agent_event import AgentEvent -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.provider_records import ProviderDiagnosticError from agent_comms.nominal.declared_family import DeclaredFamily from agent_comms.nominal.field_codec import ToolCallId diff --git a/src/agent_comms/execution/turn_runner.py b/src/agent_comms/execution/turn_runner.py index fa328db585..d181261daf 100644 --- a/src/agent_comms/execution/turn_runner.py +++ b/src/agent_comms/execution/turn_runner.py @@ -20,7 +20,7 @@ from agent_comms.errors import RelationViolationError from agent_comms.execution import pi_events as pi from agent_comms.execution.context_reading import ContextUsage -from agent_comms.execution.child_process import NoProcess, ProcessState +from agent_comms.execution.process_identity import NoProcess, ProcessState from agent_comms.execution.controller import Controller from agent_comms.execution.goal_scheduler import GoalScheduler from agent_comms.execution.image_input import ImageInput diff --git a/src/agent_comms/execution/watch_passes.py b/src/agent_comms/execution/watch_passes.py index 85a487d85c..3b509eabd1 100644 --- a/src/agent_comms/execution/watch_passes.py +++ b/src/agent_comms/execution/watch_passes.py @@ -6,7 +6,7 @@ from functools import partial from agent_comms.comms import Comms -from agent_comms.execution.child_process import AsyncWork +from agent_comms.execution.async_retirement import AsyncWork from agent_comms.nominal.declared_family import DeclaredFamily from agent_comms.storage.watch_phase import WatchPhase diff --git a/src/agent_comms/execution/worker/__main__.py b/src/agent_comms/execution/worker/__main__.py index 448c0ebb59..d57d178dcb 100644 --- a/src/agent_comms/execution/worker/__main__.py +++ b/src/agent_comms/execution/worker/__main__.py @@ -14,12 +14,9 @@ from agent_comms.coordination.service_passes import ServicePassStore from agent_comms.execution.acp import CommsAgent from agent_comms.execution.context_state import LlamaSlotHost -from agent_comms.execution.child_process import ( - GitChildren, - OwnedGitOpening, - ProcessName, - join_retirement, -) +from agent_comms.execution.async_retirement import join_retirement +from agent_comms.execution.child_process import GitChildren, OwnedGitOpening +from agent_comms.execution.process_identity import ProcessName from agent_comms.execution.launch_root import LaunchRoot, started from agent_comms.execution.native_arguments import TurnHost from agent_comms.execution.root_runtime import RootRuntimeStore diff --git a/src/agent_comms/host_services/__init__.py b/src/agent_comms/host_services/__init__.py index 9d03cac720..e5460db1b2 100644 --- a/src/agent_comms/host_services/__init__.py +++ b/src/agent_comms/host_services/__init__.py @@ -14,7 +14,8 @@ from pathlib import Path from typing import Annotated, ClassVar, Self -from agent_comms.execution.child_process import ProcessIdentity, ResidentManager +from agent_comms.execution.child_process import ResidentManager +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.systemd_unit import SystemdUnit from agent_comms.nominal.declared_family import DeclaredFamily diff --git a/src/agent_comms/installer/building_runtime.py b/src/agent_comms/installer/building_runtime.py index f03ef921ac..c67db0ff99 100644 --- a/src/agent_comms/installer/building_runtime.py +++ b/src/agent_comms/installer/building_runtime.py @@ -37,7 +37,7 @@ from pathlib import Path from typing import ClassVar -from agent_comms.execution.child_process import IdentityMismatchError, ProcessIdentity +from agent_comms.execution.process_identity import IdentityMismatchError, ProcessIdentity from agent_comms.nominal.field_codec import FieldCodec, MalformedRecord diff --git a/src/agent_comms/installer/interpreter_operation.py b/src/agent_comms/installer/interpreter_operation.py index 397c851ca4..384489c856 100644 --- a/src/agent_comms/installer/interpreter_operation.py +++ b/src/agent_comms/installer/interpreter_operation.py @@ -22,7 +22,7 @@ from typing_extensions import TypeForm -from agent_comms.execution.child_process import Platform +from agent_comms.execution.process_identity import ProcessPlatform from agent_comms.execution.launch_root import started from agent_comms.installer.native_build_inputs import GitLaunch from agent_comms.installer.runtime_wire import CrossesRuntimes @@ -92,7 +92,7 @@ def launched(self) -> LaunchedPhase: return LaunchedPhase(LauncherPhase) def started_at(self, now: float) -> float: - platform = Platform.current() + platform = ProcessPlatform.current() return platform.started_at(platform.identity(os.getpid())) diff --git a/src/agent_comms/planning/goal_actions.py b/src/agent_comms/planning/goal_actions.py index b9aa5f1740..973242077e 100644 --- a/src/agent_comms/planning/goal_actions.py +++ b/src/agent_comms/planning/goal_actions.py @@ -6,7 +6,7 @@ from typing import Annotated from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import InputKey, InputKeyText from agent_comms.execution.reported_turn import ReportedTurnState from agent_comms.nominal import field_codec diff --git a/src/agent_comms/projects/integration.py b/src/agent_comms/projects/integration.py index 8b1dc36a2e..48a1cb2cc2 100644 --- a/src/agent_comms/projects/integration.py +++ b/src/agent_comms/projects/integration.py @@ -15,7 +15,8 @@ import agent_comms from agent_comms.cli_verbs.declared_verb import DeclaredOptions -from agent_comms.execution.child_process import STOP_GRACE_SECONDS, ResidentManager, SpawnedProcess +from agent_comms.execution.child_process import ResidentManager, SpawnedProcess +from agent_comms.execution.process_identity import STOP_GRACE_SECONDS from agent_comms.execution.launch_runtime import CheckoutSource, RestoredRuntime from agent_comms.execution.systemd_unit import AgentsSlice from agent_comms.execution.test_lease import LeaseStart, TestLease diff --git a/src/agent_comms/projects/storage_rules.py b/src/agent_comms/projects/storage_rules.py index 687c9e6b4b..c261f120ab 100644 --- a/src/agent_comms/projects/storage_rules.py +++ b/src/agent_comms/projects/storage_rules.py @@ -25,7 +25,7 @@ ) from agent_comms.errors import TodoError -from agent_comms.execution.child_process import ResidentMemory +from agent_comms.execution.process_identity import ResidentMemory from agent_comms.nominal.declared_family import DeclaredFamily from agent_comms.nominal.field_codec import FieldCodec, GoalId, MalformedRecord, ValueDirective from agent_comms.planning.problem_number import ProblemNumber diff --git a/src/agent_comms/registry/owner_release.py b/src/agent_comms/registry/owner_release.py index 9d6e313719..20d2a9ffce 100644 --- a/src/agent_comms/registry/owner_release.py +++ b/src/agent_comms/registry/owner_release.py @@ -10,7 +10,7 @@ from typing import Annotated from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessState +from agent_comms.execution.process_identity import ProcessState from agent_comms.nominal.declared_family import DeclaredFamily from agent_comms.registry.registry_document import RegistrySnapshot from agent_comms.registry.thread_identity import ( diff --git a/src/agent_comms/registry/presence_reads.py b/src/agent_comms/registry/presence_reads.py index a757f2390b..4c38191c81 100644 --- a/src/agent_comms/registry/presence_reads.py +++ b/src/agent_comms/registry/presence_reads.py @@ -2,7 +2,7 @@ from __future__ import annotations from abc import ABC, abstractmethod -from agent_comms.execution.child_process import ProcessIdentity, ProcessState +from agent_comms.execution.process_identity import ProcessIdentity, ProcessState from agent_comms.registry.thread_identity import OwnerIdentity, ThreadIncarnation, ThreadRole diff --git a/src/agent_comms/registry/registration.py b/src/agent_comms/registry/registration.py index c4b9d1526f..4e6a031342 100644 --- a/src/agent_comms/registry/registration.py +++ b/src/agent_comms/registry/registration.py @@ -10,7 +10,7 @@ from typing import Concatenate from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import NoProcess, ProcessIdentity +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.input_ingress import InputRegistration from agent_comms.execution.native_input_owner import RegistryOwner from agent_comms.execution.selected.owner_source import RegistryOwnerSource diff --git a/src/agent_comms/registry/registration_change.py b/src/agent_comms/registry/registration_change.py index 351687c89d..74071bb47d 100644 --- a/src/agent_comms/registry/registration_change.py +++ b/src/agent_comms/registry/registration_change.py @@ -15,7 +15,7 @@ from agent_comms.coordination.participant_store import ParticipantStore from agent_comms.coordination.session import CoordinationSession from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessRestart +from agent_comms.execution.process_identity import ProcessRestart from agent_comms.planning.goals import GoalDeclaration, NoGoal from agent_comms.registry.thread_identity import ThreadIncarnation from agent_comms.registry.thread_status import ThreadStatus diff --git a/src/agent_comms/registry/registry_document.py b/src/agent_comms/registry/registry_document.py index 834163f9bb..b9ab013992 100644 --- a/src/agent_comms/registry/registry_document.py +++ b/src/agent_comms/registry/registry_document.py @@ -30,7 +30,7 @@ from pydantic import JsonValue from agent_comms.errors import OutsideRegistrySlice, RelationViolationError, UnregisteredThreadError -from agent_comms.execution.child_process import ProcessIdentity +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.execution.restart_refusals import ( diff --git a/src/agent_comms/registry/registry_store.py b/src/agent_comms/registry/registry_store.py index f09ad28069..3b0da57ed6 100644 --- a/src/agent_comms/registry/registry_store.py +++ b/src/agent_comms/registry/registry_store.py @@ -19,7 +19,7 @@ from agent_comms.coordination.errors import StaleFence from agent_comms.coordination.private_runtime_schema import PrivateCoordinatorTable from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import NoProcess, Platform +from agent_comms.execution.process_identity import NoProcess, ProcessPlatform from agent_comms.execution.input_ingress import InputAuthorityCut, InputRegistryStore from agent_comms.execution.native_input_owner import RegistryOwner from agent_comms.execution.session_file import RegistrySessionLocation @@ -466,7 +466,7 @@ def retain(self, destination: Path) -> RegistryRevision: destination.mkdir(mode=0o700, parents=True, exist_ok=True) with self.guarded_read(): self.copy_file(self.path, copied.path) - Platform.current().sync_file(copied.path) + ProcessPlatform.current().sync_file(copied.path) copied.rows.withdraw_namespace() copied.mark_historical() return copied.read_revision() diff --git a/src/agent_comms/registry/thread_configuration.py b/src/agent_comms/registry/thread_configuration.py index f8fb5ef684..e7f8c55e23 100644 --- a/src/agent_comms/registry/thread_configuration.py +++ b/src/agent_comms/registry/thread_configuration.py @@ -4,7 +4,7 @@ from pathlib import Path from agent_comms.acp_extension import CoordinationChangedUpdate -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.registry.agent_activity import AgentActivity from agent_comms.registry.registration import Registration from agent_comms.registry.thread_management import ThreadManagement diff --git a/src/agent_comms/registry/thread_identity.py b/src/agent_comms/registry/thread_identity.py index 5cbef46806..026360ae90 100644 --- a/src/agent_comms/registry/thread_identity.py +++ b/src/agent_comms/registry/thread_identity.py @@ -37,7 +37,7 @@ from agent_comms.registry.cli_options import JsonFlagRecord if TYPE_CHECKING: - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.messages import Message from agent_comms.messaging.read_ledger import ReadDocument, ReadLedger from agent_comms.registry.registry_provenance import RegistryProvenance diff --git a/src/agent_comms/registry/thread_management.py b/src/agent_comms/registry/thread_management.py index bf2cf43aaa..d295f3ba51 100644 --- a/src/agent_comms/registry/thread_management.py +++ b/src/agent_comms/registry/thread_management.py @@ -16,7 +16,7 @@ from agent_comms.cli_verbs.cli_commands import ThreadDeleted from agent_comms.coordination.errors import CoordinationError from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( +from agent_comms.execution.process_identity import ( NO_PROCESS, ProcessIdentity, ProcessState, diff --git a/src/agent_comms/registry/thread_presentation.py b/src/agent_comms/registry/thread_presentation.py index 6929b5c89d..c75b46b657 100644 --- a/src/agent_comms/registry/thread_presentation.py +++ b/src/agent_comms/registry/thread_presentation.py @@ -21,7 +21,7 @@ import agent_comms.registry.thread_presentation as thread_presentation from agent_comms.coordination.work import CoordinationWork from agent_comms.errors import RelationViolationError, RouteChangedError, UnregisteredThreadError -from agent_comms.execution.child_process import NativeBinding, ProcessIdentity +from agent_comms.execution.process_identity import NativeBinding, ProcessIdentity from agent_comms.execution.native_arguments import GivenArguments from agent_comms.messaging.message_reference import MessageReference from agent_comms.nominal.declared_family import DeclaredFamily diff --git a/src/agent_comms/registry/thread_status.py b/src/agent_comms/registry/thread_status.py index 61370eaf46..a9458d57bd 100644 --- a/src/agent_comms/registry/thread_status.py +++ b/src/agent_comms/registry/thread_status.py @@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, ClassVar, Self from agent_comms.errors import RelationViolationError, ThreadNotStoppedError, ThreadNotVisibleError -from agent_comms.execution.child_process import ( +from agent_comms.execution.process_identity import ( ProcessFence, ProcessIdentity, ProcessSighting, diff --git a/src/agent_comms/registry/threads.py b/src/agent_comms/registry/threads.py index 6cd4ee51fe..6a66360523 100644 --- a/src/agent_comms/registry/threads.py +++ b/src/agent_comms/registry/threads.py @@ -14,7 +14,7 @@ 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.child_process import NoProcess, ProcessIdentity, ProcessState +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity, ProcessState from agent_comms.execution.cli_inbox_backend import CliInboxBackend from agent_comms.execution.thread_launch import ThreadLaunch, ThreadLaunchSource from agent_comms.execution.native_arguments import SelectedModel diff --git a/src/agent_comms/resources/directory_queries.py b/src/agent_comms/resources/directory_queries.py index 188c524e57..56d42f2123 100644 --- a/src/agent_comms/resources/directory_queries.py +++ b/src/agent_comms/resources/directory_queries.py @@ -6,7 +6,7 @@ antipattern. Here the modes are declared members of a :class:`DirectoryQuery` family; the CLI dispatches by iterating that family. -Process-stat parsing is delegated to :class:`LinuxPlatform` in +Process-stat parsing is delegated to :class:`LinuxProcessPlatform` in ``child_process``: one owner for ``/proc/*/stat`` reading, and the kernel-thread filter uses the new ``flags`` field added to :class:`LinuxProcessRecord`. @@ -23,7 +23,7 @@ from pathlib import Path from typing import TextIO -from agent_comms.execution.child_process import LinuxPlatform +from agent_comms.execution.process_identity import LinuxProcessPlatform from agent_comms.nominal.declared_family import DeclaredFamily @@ -131,7 +131,7 @@ def __post_init__(self) -> None: os.fsencode(command.name), } self.ancestors: set[tuple[int, int]] = set() - self.platform = LinuxPlatform() + self.platform = LinuxProcessPlatform() pid = os.getpid() while pid: try: diff --git a/src/agent_comms/storage/maintenance_barrier.py b/src/agent_comms/storage/maintenance_barrier.py index dc1d551c15..c963805b1f 100644 --- a/src/agent_comms/storage/maintenance_barrier.py +++ b/src/agent_comms/storage/maintenance_barrier.py @@ -20,7 +20,7 @@ from agent_comms.coordination.errors import DrainUnavailable from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.send_outcome import GrantedSend, HeldSend from agent_comms.nominal.declared_family import DeclaredFamily diff --git a/src/agent_comms/storage/storage_room.py b/src/agent_comms/storage/storage_room.py index 9a6a4339dd..5e435101ad 100644 --- a/src/agent_comms/storage/storage_room.py +++ b/src/agent_comms/storage/storage_room.py @@ -17,7 +17,7 @@ from sqlite3 import Connection from typing import Annotated, ClassVar -from agent_comms.execution.child_process import ProcessIdentity, ResidentMemory +from agent_comms.execution.process_identity import ProcessIdentity, ResidentMemory from agent_comms.messaging.watched import ChangeSignal, FileSource from agent_comms.nominal.declared_family import DeclaredFamily from agent_comms.nominal.field_codec import RoomTicket diff --git a/src/agent_comms/team/standing_rules.py b/src/agent_comms/team/standing_rules.py index 7496924ad1..ca3e8b7322 100644 --- a/src/agent_comms/team/standing_rules.py +++ b/src/agent_comms/team/standing_rules.py @@ -21,7 +21,7 @@ ServicePassStore, ) from agent_comms.errors import RejectedEnforcementError, RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity, ResidentMemory +from agent_comms.execution.process_identity import ProcessIdentity, ResidentMemory from agent_comms.execution.root_runtime import RootRuntimeStore from agent_comms.execution.turn_bound import LastTurns from agent_comms.execution.turn_digests import ( diff --git a/src/agent_comms/thread_views.py b/src/agent_comms/thread_views.py index 80fdfc1b4c..34f6e75288 100644 --- a/src/agent_comms/thread_views.py +++ b/src/agent_comms/thread_views.py @@ -9,7 +9,7 @@ from typing import Annotated from agent_comms.cli_verbs.cli_result import CliResult -from agent_comms.execution.child_process import NoProcess, ProcessState +from agent_comms.execution.process_identity import NoProcess, ProcessState from agent_comms.execution.runtime_info import RuntimeInfo from agent_comms.messaging.pending_count_source import PendingCountSource from agent_comms.nominal.declared_family import DeclaredFamily diff --git a/src/agent_comms/transport/attachment_scope.py b/src/agent_comms/transport/attachment_scope.py index b046821138..bfadb16ee8 100644 --- a/src/agent_comms/transport/attachment_scope.py +++ b/src/agent_comms/transport/attachment_scope.py @@ -3,7 +3,7 @@ from abc import abstractmethod from dataclasses import dataclass, replace -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import ( AcceptsNull, AcpSessionId, diff --git a/src/agent_comms/transport/background_runs.py b/src/agent_comms/transport/background_runs.py index dcd2a6b6ab..f2aadedbab 100644 --- a/src/agent_comms/transport/background_runs.py +++ b/src/agent_comms/transport/background_runs.py @@ -24,12 +24,8 @@ from typing import ClassVar from agent_comms.bus_context import BusContext -from agent_comms.execution.child_process import ( - OutlivesLauncherLifetime, - Platform, - ProcessIdentity, - SpawnedProcess, -) +from agent_comms.execution.child_process import OutlivesLauncherLifetime, Platform, SpawnedProcess +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.installer.native_build_inputs import DetachedChildStdio from agent_comms.messaging.channel_targets import ThreadTarget from agent_comms.nominal.declared_family import DeclaredFamily diff --git a/src/agent_comms/transport/connector.py b/src/agent_comms/transport/connector.py index 46284980dc..d126bacf15 100644 --- a/src/agent_comms/transport/connector.py +++ b/src/agent_comms/transport/connector.py @@ -54,16 +54,16 @@ from agent_comms.coordination.coordinator import Coordination from agent_comms.coordination.service_passes import ServicePassStore from agent_comms.errors import UnexposedToolError +from agent_comms.execution.async_retirement import join_retirement from agent_comms.execution.child_process import ( GitChildren, HelperStart, OutlivesLauncherLifetime, OwnedGitOpening, Platform, - ProcessIdentity, SpawnedProcess, - join_retirement, ) +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.forkserver_helper import ForkserverHelper from agent_comms.installer.native_build_inputs import DetachedChildStdio from agent_comms_hooks import ToolRefusedError diff --git a/src/agent_comms/transport/native_tool_transport.py b/src/agent_comms/transport/native_tool_transport.py index 9c8343ba4f..fb497ea233 100644 --- a/src/agent_comms/transport/native_tool_transport.py +++ b/src/agent_comms/transport/native_tool_transport.py @@ -18,7 +18,7 @@ from agent_comms.coordination.database import CoordinationStore from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import join_retirement +from agent_comms.execution.async_retirement import join_retirement from agent_comms.messaging.message_files import MAX_SEND_REQUEST_BYTES from agent_comms.nominal.field_codec import FieldCodec, InputId, MalformedRecord, Token256Text from agent_comms.nominal.lifecycle_capability import Complete diff --git a/src/agent_comms/transport/owner_connection.py b/src/agent_comms/transport/owner_connection.py index 4ba82ca82b..fab6c9420e 100644 --- a/src/agent_comms/transport/owner_connection.py +++ b/src/agent_comms/transport/owner_connection.py @@ -17,7 +17,7 @@ from agent_comms.coordination.work import CoordinationWork from agent_comms.errors import RelationViolationError, UnregisteredThreadError from agent_comms.messaging.message_files import MAX_SEND_REQUEST_BYTES -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.owner_protocol import OwnerLine from agent_comms.nominal.field_codec import FieldCodec, NullMember, SingleFieldValue, SubclassUnion from agent_comms.registry.registration import RegistryBus diff --git a/src/agent_comms/transport/owner_requests.py b/src/agent_comms/transport/owner_requests.py index 7b17cb9cf2..ab8913867e 100644 --- a/src/agent_comms/transport/owner_requests.py +++ b/src/agent_comms/transport/owner_requests.py @@ -11,7 +11,7 @@ from agent_comms.errors import RelationViolationError from agent_comms.execution import launch_runtime from agent_comms.execution.thread_launch import ThreadLaunch -from agent_comms.execution.child_process import NoProcess, Platform, ProcessIdentity, ProcessState +from agent_comms.execution.process_identity import NoProcess, ProcessPlatform, ProcessIdentity, ProcessState from agent_comms.execution.native_arguments import ( ConfiguredBinary, InheritedArguments, @@ -62,7 +62,7 @@ def capture( ) -> RetainedOwnerLaunch: thread = selection.require_current(snapshot) process = selection.process - platform = Platform.current() + platform = ProcessPlatform.current() platform.require(process) result = FieldCodec.decode(cls, OwnerConnection.exchange( root, process, ReadOwnerLaunchRuntimeRequest(thread=thread.name, owner=selection.identity), diff --git a/src/agent_comms/transport/serving/owner_launch.py b/src/agent_comms/transport/serving/owner_launch.py index befdfef70d..0a4a61728c 100644 --- a/src/agent_comms/transport/serving/owner_launch.py +++ b/src/agent_comms/transport/serving/owner_launch.py @@ -11,7 +11,7 @@ from agent_comms.coordination.work import CoordinationWork from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity, ProportionalMemory, ResidentMemory +from agent_comms.execution.process_identity import ProcessIdentity, ProportionalMemory, ResidentMemory from agent_comms.nominal.field_codec import AcpSessionId, FieldCodec from agent_comms.registry.registry_document import RegistryEntry from agent_comms.registry.registry_store import RegistryReadCounts diff --git a/src/agent_comms/transport/tool_request.py b/src/agent_comms/transport/tool_request.py index 2bd4b4d60f..c201ae7434 100644 --- a/src/agent_comms/transport/tool_request.py +++ b/src/agent_comms/transport/tool_request.py @@ -13,7 +13,8 @@ from pydantic import JsonValue from agent_comms.bus_context import BusContext -from agent_comms.execution.child_process import AsyncWork, ReadWork +from agent_comms.execution.async_retirement import AsyncWork +from agent_comms.execution.child_process import ReadWork from agent_comms.nominal.declared_family import DeclaredFamily from agent_comms.nominal.field_codec import FieldCodec, MalformedRecord, ToolCallId from agent_comms.nominal.served_declaration import ServesDeclaration diff --git a/src/agent_comms/transport/tools/commands.py b/src/agent_comms/transport/tools/commands.py index c3d38c123b..0703b50800 100644 --- a/src/agent_comms/transport/tools/commands.py +++ b/src/agent_comms/transport/tools/commands.py @@ -12,7 +12,7 @@ from typing import Annotated, ClassVar from agent_comms.coordination.tables.refusals import SendRefusal -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.pi_vocabulary import ServiceTier, ThinkingLevelField from agent_comms.messaging.channels import Channel, SavedView, ViewMatch from agent_comms.messaging.history_result import HistoryPageResult diff --git a/src/agent_comms/transport/tools/sidebar.py b/src/agent_comms/transport/tools/sidebar.py index 643c3f49a0..e8e9ad46ce 100644 --- a/src/agent_comms/transport/tools/sidebar.py +++ b/src/agent_comms/transport/tools/sidebar.py @@ -25,7 +25,7 @@ ContextManifestReference, ) from agent_comms.display_order import ChannelSort, ThreadSort -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_origin import HumanInputOrigin from agent_comms.execution.session_revision import SessionObservation from agent_comms.execution.transcript_sources import TranscriptCursor diff --git a/src/agent_comms/ui_model/observation.py b/src/agent_comms/ui_model/observation.py index 68ef88f6c1..14e5c1142f 100644 --- a/src/agent_comms/ui_model/observation.py +++ b/src/agent_comms/ui_model/observation.py @@ -38,7 +38,7 @@ ) from agent_comms.coordination.work import CoordinationWork from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import join_retirement +from agent_comms.execution.async_retirement import join_retirement from agent_comms.execution.publication_measurements import WorkCpu from agent_comms.input_disposition import DeliveryOverview from agent_comms.messaging.bus_read import CapturesTranscriptPage, OwnerScopedRead, UiRead diff --git a/src/agent_comms/ui_model/observation_service.py b/src/agent_comms/ui_model/observation_service.py index 7d2dc1767a..9f505f7cd9 100644 --- a/src/agent_comms/ui_model/observation_service.py +++ b/src/agent_comms/ui_model/observation_service.py @@ -24,7 +24,8 @@ from metaclass_registry.mro_dispatch import MroDispatch, handles from agent_comms.comms import Comms -from agent_comms.execution.child_process import HelperStart, ProcessName, SpawnedHelper +from agent_comms.execution.child_process import HelperStart, SpawnedHelper +from agent_comms.execution.process_identity import ProcessName from agent_comms.execution.launch_root import started from agent_comms.history_views import SidebarCut from agent_comms.installer.active_route import CommsRoute diff --git a/stack/test-native-global-extensions.py b/stack/test-native-global-extensions.py index 2dda89492b..e45ba09ab2 100755 --- a/stack/test-native-global-extensions.py +++ b/stack/test-native-global-extensions.py @@ -68,7 +68,7 @@ def main(fixture: Path): "PI_OFFLINE": "1", "NODE_DISABLE_COMPILE_CACHE": "1", } environment.update(RestartEnvironment(native_config=agent, agent_directory=agent).encode_native()) - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.registry.threads import Thread comms = wire(root / "wire") diff --git a/tests/bus_record_fixture.py b/tests/bus_record_fixture.py index e9b12cd411..138314e71d 100644 --- a/tests/bus_record_fixture.py +++ b/tests/bus_record_fixture.py @@ -13,7 +13,7 @@ canonical_publication_key, public_envelope_digest, ) -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import RestoredRuntime from agent_comms.execution.native_arguments import NativeArguments from agent_comms.messaging.audience_manifest import freeze_audience diff --git a/tests/native_backend_fixture.py b/tests/native_backend_fixture.py index 631be92ae3..76bfc31de1 100644 --- a/tests/native_backend_fixture.py +++ b/tests/native_backend_fixture.py @@ -14,10 +14,8 @@ from agent_comms.agent_backend import NoInputStartListener from agent_comms.comms import wire from agent_comms.coordination.coordinator import Coordination -from agent_comms.execution.child_process import ( - BoundedRun, - join_retirement, -) +from agent_comms.execution.async_retirement import join_retirement +from agent_comms.execution.child_process import BoundedRun from agent_comms.execution.controller import NO_CONTROLLER, NoController from agent_comms.execution.cursor_publication import CursorDelivery from agent_comms.execution.fresh_private_session import create_fresh_private_session diff --git a/tests/owner_socket_fixture.py b/tests/owner_socket_fixture.py index ad16091865..236212cab1 100644 --- a/tests/owner_socket_fixture.py +++ b/tests/owner_socket_fixture.py @@ -16,10 +16,8 @@ import pytest from agent_comms.comms import Comms -from agent_comms.execution.child_process import ( - ProcessIdentity, - SpawnedProcess, -) +from agent_comms.execution.child_process import SpawnedProcess +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.projects.checkouts import Checkout from agent_comms.registry.threads import NativeThread, Thread from agent_comms.storage.private_path import PrivateSocketRole diff --git a/tests/process_pool_child.py b/tests/process_pool_child.py index 4c22d52fe2..d3ce3f427d 100644 --- a/tests/process_pool_child.py +++ b/tests/process_pool_child.py @@ -3,11 +3,8 @@ import sys from pathlib import Path -from agent_comms.execution.child_process import ( - ForkedProcessPool, - ProcessName, - SpawnedProcess, -) +from agent_comms.execution.child_process import ForkedProcessPool, SpawnedProcess +from agent_comms.execution.process_identity import ProcessName from process_tree_fixture import TREE if __name__ == "__main__": diff --git a/tests/process_tree_fixture.py b/tests/process_tree_fixture.py index 4582038721..c9f30e6e19 100644 --- a/tests/process_tree_fixture.py +++ b/tests/process_tree_fixture.py @@ -6,7 +6,7 @@ from collections.abc import Callable from pathlib import Path -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import FieldCodec TREE = """import subprocess,sys,os,time,json diff --git a/tests/registration_lifecycle_child.py b/tests/registration_lifecycle_child.py index 897fabc103..4dc8235d39 100644 --- a/tests/registration_lifecycle_child.py +++ b/tests/registration_lifecycle_child.py @@ -6,7 +6,7 @@ from dataclasses import replace from pathlib import Path -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import FieldCodec, TurnId from agent_comms.projects.checkouts import Checkout from agent_comms.registry.registration import Registration diff --git a/tests/restart_fixture.py b/tests/restart_fixture.py index bdfcd90f41..4f70389085 100644 --- a/tests/restart_fixture.py +++ b/tests/restart_fixture.py @@ -6,7 +6,7 @@ import pytest import agent_comms.execution.restart_queue as queue -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import RestartEnvironment from agent_comms.execution.owner_lifecycle import OwnerRestartSelection from agent_comms.nominal.field_codec import RestartId diff --git a/tests/test_acp.py b/tests/test_acp.py index 34d3b52353..2acf82a6a4 100644 --- a/tests/test_acp.py +++ b/tests/test_acp.py @@ -27,7 +27,7 @@ from agent_comms.comms import wire from agent_comms.coordination.errors import Refused from agent_comms.errors import UnregisteredThreadError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.context_reading import ContextUsage, UnmeasuredContext from agent_comms.execution.native_arguments import GivenArguments from agent_comms.execution.pi_vocabulary import ServiceTier diff --git a/tests/test_acp_extension.py b/tests/test_acp_extension.py index 5da64aea2b..03cfcd06fe 100644 --- a/tests/test_acp_extension.py +++ b/tests/test_acp_extension.py @@ -47,7 +47,7 @@ InputFailedUpdate, RequestFailedUpdate, ) -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.context_reading import UnmeasuredContext from agent_comms.execution.native_output import AssistantOutput, NativeRecordLocation from agent_comms.execution.native_record_file import PresentSessionCut diff --git a/tests/test_acp_private_nk_delivery.py b/tests/test_acp_private_nk_delivery.py index 9342fcfc14..764ef57eff 100644 --- a/tests/test_acp_private_nk_delivery.py +++ b/tests/test_acp_private_nk_delivery.py @@ -15,7 +15,7 @@ from agent_comms.comms import wire from agent_comms.coordination.coordinator import Coordination from agent_comms.coordination.errors import PublicationActivationBlocked -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import AcpSessionId from agent_comms.projects.checkouts import Checkout from agent_comms.registry.thread_model import DeclaredModel diff --git a/tests/test_acp_queue_contract.py b/tests/test_acp_queue_contract.py index 6afd33e5b6..4a9c61362c 100644 --- a/tests/test_acp_queue_contract.py +++ b/tests/test_acp_queue_contract.py @@ -28,7 +28,7 @@ ) from agent_comms.comms import Comms, wire from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import AcpInputKey, BusInputKey from agent_comms.execution.queued_input import AcceptedTurn, QueuedInput, QueuedInputContext from agent_comms.execution.runtime import present_session diff --git a/tests/test_acp_selected_write_plan.py b/tests/test_acp_selected_write_plan.py index 1b2eaa217c..38d98e3b8a 100644 --- a/tests/test_acp_selected_write_plan.py +++ b/tests/test_acp_selected_write_plan.py @@ -24,7 +24,7 @@ from agent_comms.coordination.cohort import sealed_cohort_assignments from agent_comms.coordination.cohort_foreground import AcceptsDeliveries from agent_comms.coordination.coordinator import Coordination -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.native_runtime_input import NativeRuntimeInput from agent_comms.messaging.envelope_claim_transitions import UnclaimedResource diff --git a/tests/test_active_turn.py b/tests/test_active_turn.py index f238ea5c16..f233b53e55 100644 --- a/tests/test_active_turn.py +++ b/tests/test_active_turn.py @@ -2,7 +2,7 @@ import time from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.turn_phase import ( CompactionPhase, IdlePhase, diff --git a/tests/test_activity_text.py b/tests/test_activity_text.py index 528b14c449..0c5dd03472 100644 --- a/tests/test_activity_text.py +++ b/tests/test_activity_text.py @@ -7,7 +7,7 @@ from agent_comms.cli_bridges.runtime_updates import ThreadOutput from agent_comms.display_order import LastActivityThreadSort -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.pi_events import ToolExecutionStart from agent_comms.execution.provider_records import ( CodelessProviderDiagnosticError, diff --git a/tests/test_agent_backend.py b/tests/test_agent_backend.py index 3420422c8b..eb56fd0bf4 100644 --- a/tests/test_agent_backend.py +++ b/tests/test_agent_backend.py @@ -14,7 +14,7 @@ import agent_comms.agent_backend as ab from agent_comms.errors import RelationViolationError from agent_comms.execution.acp import CommsAgent -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.cli_inbox_backend import CliInboxBackend, CliInboxRuntime from agent_comms.execution.native_arguments import GivenArguments, GivenBinary, NativeArguments from agent_comms.execution.persistent_pi_session import PersistentPiSession diff --git a/tests/test_agent_settings.py b/tests/test_agent_settings.py index b2b165d63e..43aebaec3e 100644 --- a/tests/test_agent_settings.py +++ b/tests/test_agent_settings.py @@ -15,7 +15,7 @@ from python_introspect.jsonable import RegisteredClassChoices, registered_class_from_key from agent_comms.cli_verbs.new import NewThreadCliCommand -from agent_comms.execution.child_process import NO_PROCESS, ProcessIdentity +from agent_comms.execution.process_identity import NO_PROCESS, ProcessIdentity from agent_comms.execution.pi_vocabulary import ( HighThinkingLevel, LowThinkingLevel, diff --git a/tests/test_antigravity_acp_backend.py b/tests/test_antigravity_acp_backend.py index 9e164d7706..a36d34d4b7 100644 --- a/tests/test_antigravity_acp_backend.py +++ b/tests/test_antigravity_acp_backend.py @@ -31,7 +31,7 @@ AntigravityAcpUpdate, ) from agent_comms.execution.antigravity_backend import AntigravityAcpBackend, AntigravitySession -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_arguments import AntigravityProvider, NativeArguments, SelectedModel from agent_comms.execution.pi_vocabulary import HighThinkingLevel from agent_comms.execution.runtime_observations import AgentInfo, ContextInfo @@ -325,7 +325,7 @@ async def collect(backend: AntigravityAcpBackend, thread: NativeThread, text: st def test_switch_to_native_and_attach_session_for_antigravity_thread(tmp_path: Path, comms) -> None: - from agent_comms.execution.child_process import NoProcess + from agent_comms.execution.process_identity import NoProcess from agent_comms.registry.thread_status import NoBridgeThreadStatus from agent_comms.registry.threads import ExternalThread @@ -401,7 +401,7 @@ async def test_comms_agent_drains_and_runs_two_turns_on_antigravity_acp( from bus_record_fixture import prepare_native_comms from agent_comms.comms import wire from agent_comms.execution.acp import CommsAgent, RetainedOwnerLaunch - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_arguments import NativeArguments from agent_comms.nominal.field_codec import ToolCallId from agent_comms.registry.threads import NextTurnConfiguration @@ -515,7 +515,7 @@ async def test_five_concurrent_antigravity_threads_wake_without_lock_starvation( from bus_record_fixture import prepare_native_comms from agent_comms.comms import wire from agent_comms.execution.acp import CommsAgent, RetainedOwnerLaunch - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_arguments import NativeArguments from agent_comms.messaging.channel_targets import ChannelTarget from agent_comms.messaging.message_notification import MessageNotification @@ -642,7 +642,7 @@ async def test_antigravity_acp_turn_publishes_external_transcript_items_and_draf from bus_record_fixture import prepare_native_comms from agent_comms.comms import wire from agent_comms.execution.acp import CommsAgent, RetainedOwnerLaunch - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_arguments import NativeArguments from agent_comms.nominal.field_codec import ToolCallId from agent_comms.registry.threads import NextTurnConfiguration @@ -778,7 +778,7 @@ async def test_antigravity_acp_steers_dm_during_active_persistent_goal( from bus_record_fixture import prepare_native_comms from agent_comms.comms import wire from agent_comms.execution.acp import CommsAgent, RetainedOwnerLaunch - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_arguments import NativeArguments from agent_comms.messaging.message_notification import MessageNotification from agent_comms.messaging.notification_evidence import AllOutcomes @@ -855,7 +855,7 @@ async def test_antigravity_acp_ignores_unmentioned_channel_post_and_settles_rece from bus_record_fixture import prepare_native_comms from agent_comms.comms import wire from agent_comms.execution.acp import CommsAgent, RetainedOwnerLaunch - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_arguments import NativeArguments from agent_comms.messaging.notification_evidence import AllOutcomes from agent_comms.messaging.notification_progress import IgnoredProgress @@ -929,7 +929,7 @@ async def test_antigravity_acp_suppresses_ignore_channel_reply_without_posting( from bus_record_fixture import prepare_native_comms from agent_comms.comms import wire from agent_comms.execution.acp import CommsAgent, RetainedOwnerLaunch - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_arguments import NativeArguments from agent_comms.messaging.channel_targets import ChannelTarget from agent_comms.messaging.message_notification import MessageNotification @@ -1169,7 +1169,7 @@ async def test_antigravity_acp_waking_dm_survives_restart_before_turn_starts( from bus_record_fixture import prepare_native_comms from agent_comms.comms import wire from agent_comms.execution.acp import CommsAgent, RetainedOwnerLaunch - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_arguments import NativeArguments from agent_comms.messaging.message_notification import MessageNotification from agent_comms.messaging.notification_evidence import AllOutcomes @@ -1306,7 +1306,7 @@ async def test_collective_channel_post_steers_running_goal_turn_without_hijackin from bus_record_fixture import prepare_native_comms from agent_comms.comms import wire from agent_comms.execution.acp import CommsAgent, RetainedOwnerLaunch - from agent_comms.execution.child_process import ProcessIdentity + from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_arguments import NativeArguments from agent_comms.messaging.channel_targets import ChannelTarget from agent_comms.messaging.message_notification import MessageNotification diff --git a/tests/test_atomic_turn_source_owner.py b/tests/test_atomic_turn_source_owner.py index c0a269c959..62eea20bc0 100644 --- a/tests/test_atomic_turn_source_owner.py +++ b/tests/test_atomic_turn_source_owner.py @@ -8,7 +8,7 @@ from agent_comms.execution.acp import CommsAgent from agent_comms.comms import wire from agent_comms.coordination.errors import StaleFence -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_input_owner import RegistryOwner from agent_comms.execution.owned_turn import OwnedTurn from agent_comms.execution.runtime_observations import AgentInfo, NativeSessionPathObservation diff --git a/tests/test_backend_native_child.py b/tests/test_backend_native_child.py index 7e20daebfe..fa23c13038 100644 --- a/tests/test_backend_native_child.py +++ b/tests/test_backend_native_child.py @@ -4,10 +4,7 @@ import pytest -from agent_comms.execution.child_process import ( - ChildRetirementCancelled, - ChildRetirementError, -) +from agent_comms.execution.async_retirement import ChildRetirementCancelled, ChildRetirementError from agent_comms.execution.native_child import RetiringNative from native_backend_fixture import native_backend_fixture diff --git a/tests/test_background_runs.py b/tests/test_background_runs.py index 030e0df55d..4053eb6907 100644 --- a/tests/test_background_runs.py +++ b/tests/test_background_runs.py @@ -15,12 +15,8 @@ import pytest from agent_comms.comms import Comms -from agent_comms.execution.child_process import ( - NoResidentManager, - Platform, - ProcessIdentity, - ResidentManager, -) +from agent_comms.execution.child_process import NoResidentManager, Platform, ResidentManager +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.registry.thread_identity import ThreadIncarnation, ThreadIncarnationRecord from agent_comms.registry.threads import Thread from agent_comms.storage.file_observation import FileRevision diff --git a/tests/test_board_freshness.py b/tests/test_board_freshness.py index 6795f5aaf5..d1f6c57638 100644 --- a/tests/test_board_freshness.py +++ b/tests/test_board_freshness.py @@ -12,10 +12,7 @@ from agent_comms.cli_bridges.codex_connection import CodexConnection from agent_comms.coordination.service_passes import ServicePassStore -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.turn_digests import OrderEditCountReadings from agent_comms.messaging.messages import InfoKind, Message from agent_comms.messaging.revision_views import TeamBoardView diff --git a/tests/test_bridge_reader_lifetime.py b/tests/test_bridge_reader_lifetime.py index 841c720a3b..217a9425a3 100644 --- a/tests/test_bridge_reader_lifetime.py +++ b/tests/test_bridge_reader_lifetime.py @@ -6,7 +6,7 @@ import sys from pathlib import Path -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.projects.checkouts import Checkout from agent_comms.registry.activity import ActivityState from agent_comms.registry.thread_status import NoBridgeThreadStatus diff --git a/tests/test_building_runtime.py b/tests/test_building_runtime.py index 03e91f87e9..0bceb332b0 100644 --- a/tests/test_building_runtime.py +++ b/tests/test_building_runtime.py @@ -14,7 +14,7 @@ import pytest -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.runtime_processes import RuntimeProcesses from agent_comms.installer.building_runtime import BuildingRuntime diff --git a/tests/test_bus_async_retirement.py b/tests/test_bus_async_retirement.py index f6e540dac7..474e558d09 100644 --- a/tests/test_bus_async_retirement.py +++ b/tests/test_bus_async_retirement.py @@ -7,7 +7,8 @@ import pytest -from agent_comms.execution.child_process import ChildRetirementFailed, ReadWork +from agent_comms.execution.async_retirement import ChildRetirementFailed +from agent_comms.execution.child_process import ReadWork class HeldFactory: diff --git a/tests/test_bus_resource_claims.py b/tests/test_bus_resource_claims.py index 8e581b4896..13450e5d01 100644 --- a/tests/test_bus_resource_claims.py +++ b/tests/test_bus_resource_claims.py @@ -12,7 +12,7 @@ from agent_comms.messaging.message_reads import RecordBuilder from agent_comms.coordination.errors import IdentityConflict from agent_comms.errors import CommittedMessageError -from agent_comms.execution.child_process import NoProcess, ProcessIdentity +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.messaging.bus import Bus, ClaimRecord, KeyedPrivateRecord, PublicRecord from agent_comms.messaging.bus_tables import MessageIdentitySource from agent_comms.messaging.envelope_claim_transitions import ( diff --git a/tests/test_carry.py b/tests/test_carry.py index 62c736fc03..5f5f0fc12e 100644 --- a/tests/test_carry.py +++ b/tests/test_carry.py @@ -19,7 +19,7 @@ from agent_comms.cli_verbs.stop import StopCliCommand from agent_comms.comms import wire from agent_comms.coordination.coordinator import Coordination -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.launch_runtime import LaunchRuntime, RestoredRuntime from agent_comms.execution.native_arguments import GivenArguments, GivenBinary diff --git a/tests/test_channel_coding_tools.py b/tests/test_channel_coding_tools.py index 5cc4b9c5f7..23ba8266cf 100644 --- a/tests/test_channel_coding_tools.py +++ b/tests/test_channel_coding_tools.py @@ -16,7 +16,7 @@ from agent_comms.comms import wire from agent_comms.coordination.session import NativeCapture from agent_comms.execution.channel_coding_tools import CodingToolSocket -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.pi_events import ToolExecutionEnd, ToolExecutionStart from agent_comms.execution.provider_records import ( ReportedText, diff --git a/tests/test_channels.py b/tests/test_channels.py index 6450aa7449..4894e5af6b 100644 --- a/tests/test_channels.py +++ b/tests/test_channels.py @@ -16,10 +16,7 @@ ThreadSort, ) from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.pi_vocabulary import HighThinkingLevel from agent_comms.execution.session_file import RegistrySessionLocation diff --git a/tests/test_check_root.py b/tests/test_check_root.py index 483edfcfee..c8db9becc0 100644 --- a/tests/test_check_root.py +++ b/tests/test_check_root.py @@ -11,7 +11,7 @@ from agent_comms.comms import Comms, wire from agent_comms.errors import UnreceivedAnswerError from agent_comms.execution.check_root import CheckRoot -from agent_comms.execution.child_process import NoProcess +from agent_comms.execution.process_identity import NoProcess from agent_comms.execution.native_entries import NativeEntry from agent_comms.execution.transcript_sources import ExternalTranscript from agent_comms.execution.turn_item import ( diff --git a/tests/test_child_process.py b/tests/test_child_process.py index e27ab8271d..4c6b177ef8 100644 --- a/tests/test_child_process.py +++ b/tests/test_child_process.py @@ -16,28 +16,30 @@ import pytest import agent_comms +from agent_comms.execution.async_retirement import ChildRetirementFailed from agent_comms.execution.child_process import ( - STOP_GRACE_SECONDS, AttachedChild, BoundedRun, ChildOutcome, - ChildRetirementFailed, DetachedExitOutcome, DiesWithLauncherLifetime, ExitedOutcome, FailedToStartOutcome, ForcedStopOutcome, - GroupMember, - IdentityMismatchError, ObservedProcess, ParentLifeline, Platform, - ProcessIdentity, ResidentManager, SpawnedProcess, SynchronousProcess, TimedOutOutcome, ) +from agent_comms.execution.process_identity import ( + STOP_GRACE_SECONDS, + GroupMember, + IdentityMismatchError, + ProcessIdentity, +) from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.installer.native_build_inputs import ConfiguredChildStdio, DetachedChildStdio from agent_comms.nominal.field_codec import FieldCodec diff --git a/tests/test_claim_admission_verifier.py b/tests/test_claim_admission_verifier.py index dc4bbf4927..9ee73d7d15 100644 --- a/tests/test_claim_admission_verifier.py +++ b/tests/test_claim_admission_verifier.py @@ -24,7 +24,7 @@ from agent_comms.coordination.errors import IdentityConflict from agent_comms.coordination.owner_fence import prepare_fence_token from agent_comms.coordination.tables.executions import WireOrigin -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.selected.claim import ( publish_selected_resource_claim, verify_selected_wake, diff --git a/tests/test_claim_bus_read.py b/tests/test_claim_bus_read.py index eb2083052c..bdfdc16de8 100644 --- a/tests/test_claim_bus_read.py +++ b/tests/test_claim_bus_read.py @@ -23,7 +23,7 @@ from agent_comms.coordination.reason_codes import NoReasonCode from agent_comms.coordination.session import NativeCapture from agent_comms.coordination.tables.executions import WireOrigin -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.context_prior import UNREAD_CONTEXT from agent_comms.execution.selected.claim import ( publish_selected_resource_claim, diff --git a/tests/test_cli.py b/tests/test_cli.py index d673ae2741..c2c4d2b49c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -33,7 +33,7 @@ from agent_comms.cli_verbs.stop import StopCliCommand from agent_comms.comms import wire from agent_comms.errors import UnregisteredThreadError -from agent_comms.execution.child_process import NoProcess, ProcessIdentity +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.native_arguments import GivenArguments, GivenBinary from agent_comms.execution.owner_lifecycle import OwnerStartResult from agent_comms.execution.pi_vocabulary import ServiceTier diff --git a/tests/test_cli_inbox_switch.py b/tests/test_cli_inbox_switch.py index 67d8de9019..daa3dd6bec 100644 --- a/tests/test_cli_inbox_switch.py +++ b/tests/test_cli_inbox_switch.py @@ -18,7 +18,7 @@ ModelConfigOption, ) from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import NoProcess, ProcessIdentity +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.cli_inbox_backend import CliInboxBackend, CliInboxRuntime from agent_comms.execution.pi_durable_backend import PiDurableBackend from agent_comms.execution.session_file import RegistrySessionLocation diff --git a/tests/test_coordinated_runtime.py b/tests/test_coordinated_runtime.py index 002d2205c1..b9299bf9af 100644 --- a/tests/test_coordinated_runtime.py +++ b/tests/test_coordinated_runtime.py @@ -16,7 +16,7 @@ from agent_comms.coordination.coordinator import Coordination from agent_comms.coordination.database import CoordinationStore from agent_comms.coordination.errors import IdentityConflict, PublicationActivationBlocked -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_failures import NativePiUnavailable from agent_comms.execution.native_runtime_input import NativeRuntimeInput, NativeRuntimeTable from agent_comms.execution.pi_vocabulary import HighThinkingLevel diff --git a/tests/test_coordination_response.py b/tests/test_coordination_response.py index 928406a080..a950f906be 100644 --- a/tests/test_coordination_response.py +++ b/tests/test_coordination_response.py @@ -45,7 +45,7 @@ ) from agent_comms.coordination.tables.publications import PublicationEvidence, PublicationIntents from agent_comms.coordination.tables.responses import ResponseObligation -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_origin import WireInputOrigin from agent_comms.execution.selected.source_batch import SelectedSource from agent_comms.input_disposition import InputDispositions diff --git a/tests/test_declarations.py b/tests/test_declarations.py index 17f5b370d1..b2b7e105dd 100644 --- a/tests/test_declarations.py +++ b/tests/test_declarations.py @@ -10,10 +10,7 @@ from agent_comms.comms import wire from agent_comms.errors import RelationViolationError, UnregisteredThreadError -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.context_reading import ContextUsage, UnmeasuredContext from agent_comms.execution.launch_runtime import CallingThreadUnavailable from agent_comms.execution.native_input_owner import RegistryOwner diff --git a/tests/test_deferral_guard.py b/tests/test_deferral_guard.py index 9619849d83..37d95a33ad 100644 --- a/tests/test_deferral_guard.py +++ b/tests/test_deferral_guard.py @@ -17,7 +17,7 @@ from agent_comms.cli_bridges.hook_requests import HookReply, StopRequest from agent_comms.cli_bridges.session_watch import WatchClaim from agent_comms.comms import Comms -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.turn_item import ( NativeItemId, NativeTurnId, diff --git a/tests/test_dm_scoped_ack.py b/tests/test_dm_scoped_ack.py index 1105c10d61..74e5f3ff8b 100644 --- a/tests/test_dm_scoped_ack.py +++ b/tests/test_dm_scoped_ack.py @@ -10,7 +10,7 @@ from agent_comms.messaging.channel_targets import CommandTarget, ThreadTarget from agent_comms.coordination.errors import DMPaintedBoundChanged, DMScopeChanged, TranscriptChanged -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.message_page import PageBounds from agent_comms.projects.checkouts import Checkout from agent_comms.messaging.read_basis import DMSelection, EmptyTail diff --git a/tests/test_dm_scoped_ack_successor.py b/tests/test_dm_scoped_ack_successor.py index 996454b403..0e457cce54 100644 --- a/tests/test_dm_scoped_ack_successor.py +++ b/tests/test_dm_scoped_ack_successor.py @@ -11,7 +11,7 @@ from agent_comms.messaging.channel_targets import CommandTarget, ThreadTarget from agent_comms.comms import wire from agent_comms.coordination.errors import DMScopeChanged -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.message_page import PageBounds from agent_comms.projects.checkouts import Checkout from agent_comms.messaging.read_basis import DMSelection diff --git a/tests/test_envelope_bus_integration.py b/tests/test_envelope_bus_integration.py index 1fd61d21c0..28c0c74f02 100644 --- a/tests/test_envelope_bus_integration.py +++ b/tests/test_envelope_bus_integration.py @@ -22,7 +22,7 @@ from agent_comms.comms import Comms, wire from agent_comms.coordination.session import NativeCapture from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.envelope_claim_transitions import ( ClaimConflict, ExistingFileClaim, diff --git a/tests/test_envelope_claim_transitions.py b/tests/test_envelope_claim_transitions.py index ee8e9a29ce..0e13f875c6 100644 --- a/tests/test_envelope_claim_transitions.py +++ b/tests/test_envelope_claim_transitions.py @@ -6,7 +6,7 @@ import pytest -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.bus import ClaimRecord from agent_comms.messaging.envelope_claim_transitions import ( ClaimConflict, diff --git a/tests/test_external_compaction_activity.py b/tests/test_external_compaction_activity.py index 7bcdf41a43..c70cba27df 100644 --- a/tests/test_external_compaction_activity.py +++ b/tests/test_external_compaction_activity.py @@ -5,7 +5,7 @@ from agent_comms.cli_bridges.codex_protocol import ItemStream, RpcNotification from agent_comms.cli_bridges.runtime_updates import ThreadOutput from agent_comms.comms import client_wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.projects.checkouts import Checkout from agent_comms.registry import activity from agent_comms.registry.activity import ActivityState diff --git a/tests/test_external_goal_owner.py b/tests/test_external_goal_owner.py index fc0ceea464..209540bd6b 100644 --- a/tests/test_external_goal_owner.py +++ b/tests/test_external_goal_owner.py @@ -19,7 +19,7 @@ ) from agent_comms.comms import Comms from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import FieldCodec from agent_comms.planning.goal_actions import ( ActiveGoalAction, diff --git a/tests/test_goal_answers.py b/tests/test_goal_answers.py index 277493b9a7..a1736f7ee9 100644 --- a/tests/test_goal_answers.py +++ b/tests/test_goal_answers.py @@ -12,7 +12,7 @@ from agent_comms import agent_events as events from agent_comms.coordination.errors import Refused from agent_comms.errors import UnresolvedAttemptError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.goal_turn_permit import NoLaunchPermit from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.owned_turn import TurnGoalAccount diff --git a/tests/test_goal_attempts.py b/tests/test_goal_attempts.py index 53c3d6d2bf..e20ec2bc8f 100644 --- a/tests/test_goal_attempts.py +++ b/tests/test_goal_attempts.py @@ -19,7 +19,7 @@ from agent_comms.coordination.database import CoordinationStore from agent_comms.coordination.errors import RecoveryBlocked from agent_comms.errors import GoalRefused, StaleAttemptError, UnresolvedAttemptError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_runtime_input import NativeRuntimeInput from agent_comms.execution.pi_wire import PiUsage from agent_comms.execution.turn_failure import BackendFailed, FailedTurnResolution diff --git a/tests/test_goal_block_reason.py b/tests/test_goal_block_reason.py index 77ce4c3ce2..306c4bc0a7 100644 --- a/tests/test_goal_block_reason.py +++ b/tests/test_goal_block_reason.py @@ -6,7 +6,7 @@ import pytest from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.turn_failure import BackendFailed, FailedTurnResolution from agent_comms.planning.goal_actions import ( ActiveGoalAction, diff --git a/tests/test_goal_execution.py b/tests/test_goal_execution.py index e5f19ff12c..79f2039d85 100644 --- a/tests/test_goal_execution.py +++ b/tests/test_goal_execution.py @@ -14,7 +14,8 @@ from agent_comms import agent_events as events from agent_comms.comms import Comms, wire from agent_comms.execution.acp_failure import NativeTurnError -from agent_comms.execution.child_process import ChildOutcome, ProcessIdentity +from agent_comms.execution.child_process import ChildOutcome +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.owned_turn import OwnedTurn from agent_comms.execution.turn_failure import NativeChildSignaled from agent_comms.nominal.field_codec import FieldCodec, GoalId diff --git a/tests/test_goal_failure_observation.py b/tests/test_goal_failure_observation.py index 64edce09bb..8b1ee59f9f 100644 --- a/tests/test_goal_failure_observation.py +++ b/tests/test_goal_failure_observation.py @@ -8,7 +8,7 @@ import pytest from agent_comms.errors import StaleAttemptError, UnresolvedAttemptError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.turn_failure import BackendFailed, FailedTurnResolution, FinalStopMissing from agent_comms.execution.turn_lease import FinishedTurn, StoredTurnRecord, TurnLeaseFence from agent_comms.nominal.field_codec import GoalId, TurnId diff --git a/tests/test_goal_input_review.py b/tests/test_goal_input_review.py index 2f6792f277..25daaedc31 100644 --- a/tests/test_goal_input_review.py +++ b/tests/test_goal_input_review.py @@ -5,7 +5,7 @@ import pytest from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import AcpInputKey, BusInputKey, InputKeyText from agent_comms.input_disposition import InputDispositions from agent_comms.messaging.channel_targets import CommandTarget diff --git a/tests/test_goal_publication_sources.py b/tests/test_goal_publication_sources.py index 8e843a0b2d..c652af4d5a 100644 --- a/tests/test_goal_publication_sources.py +++ b/tests/test_goal_publication_sources.py @@ -18,7 +18,7 @@ from agent_comms.acp_extension import GoalChangedUpdate, decode_updates from agent_comms.cli_bridges.runtime_updates import ThreadOutput from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_drain import UnreadRegistry from agent_comms.execution.transcript_sources import ExternalTranscript from agent_comms.execution.turn_phase import IdlePhase, ToolRunningPhase diff --git a/tests/test_goal_reply_lock_scope.py b/tests/test_goal_reply_lock_scope.py index d5e23d489a..5eddc7133e 100644 --- a/tests/test_goal_reply_lock_scope.py +++ b/tests/test_goal_reply_lock_scope.py @@ -9,7 +9,7 @@ import pytest from agent_comms.coordination.errors import StaleFence -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import BusInputKey from agent_comms.execution.reported_turn import NoReportedTurn from agent_comms.input_disposition import InputDispositions diff --git a/tests/test_goal_resume.py b/tests/test_goal_resume.py index c7a60da55b..d95aee9b42 100644 --- a/tests/test_goal_resume.py +++ b/tests/test_goal_resume.py @@ -7,7 +7,7 @@ import pytest from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.reported_turn import ReportedTurn from agent_comms.execution.turn_failure import BackendFailed, FailedTurnResolution from agent_comms.nominal.field_codec import FieldCodec, GoalId, TurnId diff --git a/tests/test_goal_selection_owner.py b/tests/test_goal_selection_owner.py index ba52135aa5..8336ec3791 100644 --- a/tests/test_goal_selection_owner.py +++ b/tests/test_goal_selection_owner.py @@ -4,7 +4,7 @@ import pytest -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.planning.goal_actions import ( ActiveGoalAction, GoalPrecondition, diff --git a/tests/test_goal_standby.py b/tests/test_goal_standby.py index bee3b2b48f..fa63df4db4 100644 --- a/tests/test_goal_standby.py +++ b/tests/test_goal_standby.py @@ -5,7 +5,7 @@ import pytest -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import GoalWaitId, TurnId from agent_comms.planning.goal_actions import ( ClearGoalAction, diff --git a/tests/test_goal_standby_liveness.py b/tests/test_goal_standby_liveness.py index 22a50323e7..aff5497d5a 100644 --- a/tests/test_goal_standby_liveness.py +++ b/tests/test_goal_standby_liveness.py @@ -7,7 +7,7 @@ import pytest from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.turn_lease import NoFinishedTurn from agent_comms.messaging.messages import ConversationRole, NoticeRole from agent_comms.nominal.field_codec import TurnId diff --git a/tests/test_goal_wait_certified_reply.py b/tests/test_goal_wait_certified_reply.py index af9c087b92..234a046fcc 100644 --- a/tests/test_goal_wait_certified_reply.py +++ b/tests/test_goal_wait_certified_reply.py @@ -3,7 +3,7 @@ import os from dataclasses import replace -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import BusInputKey from agent_comms.input_disposition import InputDispositions from agent_comms.messaging.messages import NoticeRole diff --git a/tests/test_historical_goal_generation.py b/tests/test_historical_goal_generation.py index 3a37e5f6d3..02fa15ac34 100644 --- a/tests/test_historical_goal_generation.py +++ b/tests/test_historical_goal_generation.py @@ -8,7 +8,7 @@ import pytest from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import AcpInputKey from agent_comms.input_disposition import InputDispositions from agent_comms.nominal.field_codec import GoalId, InputId diff --git a/tests/test_historical_notifications.py b/tests/test_historical_notifications.py index ff20f83557..aa22d71fe0 100644 --- a/tests/test_historical_notifications.py +++ b/tests/test_historical_notifications.py @@ -26,7 +26,7 @@ SchemaVersionError, ) from agent_comms.coordination.tables.harness_deliveries import HarnessDelivery -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_origin import WireInputOrigin from agent_comms.input_disposition import InputDispositions from agent_comms.messaging.bus import Bus diff --git a/tests/test_historical_views.py b/tests/test_historical_views.py index 28150bf181..6e4dff46ec 100644 --- a/tests/test_historical_views.py +++ b/tests/test_historical_views.py @@ -13,7 +13,7 @@ import agent_comms from agent_comms.comms import wire from agent_comms.coordination.errors import HistoricalSourceChanged, ReloadRequired -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.execution.transcript_routes import DisplayText from agent_comms.execution.turn_item import FreshNativeId diff --git a/tests/test_holder_standing_rules.py b/tests/test_holder_standing_rules.py index 96ad24e633..3a4b7ebc46 100644 --- a/tests/test_holder_standing_rules.py +++ b/tests/test_holder_standing_rules.py @@ -23,7 +23,7 @@ ThreadNotVisibleError, TodoError, ) -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import AcpInputKey from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.native_arguments import GivenBinary diff --git a/tests/test_importing.py b/tests/test_importing.py index 4b8b748114..4837a7aa92 100644 --- a/tests/test_importing.py +++ b/tests/test_importing.py @@ -44,7 +44,7 @@ from agent_comms.cli_bridges.runtime_updates import FinishedItem, TurnEnded from agent_comms.comms import Comms from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import NO_PROCESS +from agent_comms.execution.process_identity import NO_PROCESS from agent_comms.execution.imported_messages import ( ImportedMessage, ImportedReply, diff --git a/tests/test_input_delivery_history.py b/tests/test_input_delivery_history.py index b3a2248916..684dfe00ea 100644 --- a/tests/test_input_delivery_history.py +++ b/tests/test_input_delivery_history.py @@ -17,10 +17,7 @@ from agent_comms.comms import Comms, wire from agent_comms.coordination.errors import ReloadRequired, StaleFence from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.input_key import AcpInputKey, BusInputKey from agent_comms.execution.reported_turn import ReportedTurn from agent_comms.input_attempt import ( diff --git a/tests/test_input_disposition.py b/tests/test_input_disposition.py index e4eceebcfb..298c23e2d9 100644 --- a/tests/test_input_disposition.py +++ b/tests/test_input_disposition.py @@ -8,7 +8,7 @@ from agent_comms.comms import wire from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import AcpInputKey, BusInputKey from agent_comms.execution.input_origin import DeliveredInput, UndeliveredInput, WireInputOrigin from agent_comms.input_attempt import ( diff --git a/tests/test_input_documents.py b/tests/test_input_documents.py index 0ce7f4fc6c..f4cc113b4c 100644 --- a/tests/test_input_documents.py +++ b/tests/test_input_documents.py @@ -9,7 +9,7 @@ from agent_comms.comms import wire from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import ( AcpInputKey, BusInputKey, diff --git a/tests/test_install.py b/tests/test_install.py index 8c166fcd83..4e6f36eddd 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -11,10 +11,7 @@ from agent_comms.cli_runtime import CliInvocation from agent_comms.cli_verbs.install import InstallCliCommand from agent_comms.comms import wire -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.installer.active_route import ActiveRoute, read_active_route from agent_comms.installer.route_publication import route_new_bus from agent_comms.installer.backup import bus_files diff --git a/tests/test_install_session_bridge.py b/tests/test_install_session_bridge.py index 1168badf8d..7522b0ead2 100644 --- a/tests/test_install_session_bridge.py +++ b/tests/test_install_session_bridge.py @@ -41,7 +41,8 @@ UnobservedBridge, ) from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity, SpawnedProcess +from agent_comms.execution.child_process import SpawnedProcess +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.root_runtime import RootRuntime from agent_comms.execution.turn_bound import LastTurns diff --git a/tests/test_irc.py b/tests/test_irc.py index 68c5e1bd32..4ba8253e52 100644 --- a/tests/test_irc.py +++ b/tests/test_irc.py @@ -5,7 +5,7 @@ from agent_comms.comms import wire from agent_comms.errors import UnknownChannelError, UnregisteredThreadError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.thread_launch import ThreadLaunch from agent_comms.messaging.channel_targets import CommandTarget, DeclaredTag from agent_comms.messaging.channels import AllChannel, BuiltinChannelView diff --git a/tests/test_l0_goal_input_closure.py b/tests/test_l0_goal_input_closure.py index bf2b38f840..45bd9082b5 100644 --- a/tests/test_l0_goal_input_closure.py +++ b/tests/test_l0_goal_input_closure.py @@ -7,7 +7,7 @@ import pytest from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import BusInputKey from agent_comms.execution.turn_failure import BackendFailed, FailedTurnResolution from agent_comms.input_disposition import InputDispositions diff --git a/tests/test_maintenance_barrier.py b/tests/test_maintenance_barrier.py index c7dfb91a11..d11a7dd5bd 100644 --- a/tests/test_maintenance_barrier.py +++ b/tests/test_maintenance_barrier.py @@ -33,7 +33,7 @@ from agent_comms.comms import wire from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.send_outcome import GrantedSend, HeldSend from agent_comms.execution.turn_item import ( NativeItemId, diff --git a/tests/test_message_notifications.py b/tests/test_message_notifications.py index 17351371da..3783ece6d7 100644 --- a/tests/test_message_notifications.py +++ b/tests/test_message_notifications.py @@ -8,7 +8,7 @@ from agent_comms.coordination.coordinator import Coordination from agent_comms.coordination.database import CoordinationStore from agent_comms.coordination.tables.harness_deliveries import HarnessDelivery -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.channel_targets import CommandTarget from agent_comms.messaging.human_read_cut import HumanReadCut from agent_comms.messaging.message_notification import MessageNotification diff --git a/tests/test_monitor_delivery.py b/tests/test_monitor_delivery.py index 399ea72d10..54d337e954 100644 --- a/tests/test_monitor_delivery.py +++ b/tests/test_monitor_delivery.py @@ -71,7 +71,7 @@ from agent_comms.coordination.tables.assignments import WakeAssignment from agent_comms.coordination.tables.harness_deliveries import HarnessDelivery, HarnessObservedPart from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.diagnostics import record_terminal_failure from agent_comms.execution.launch_runtime import ( InstalledSource, diff --git a/tests/test_native_send_admission.py b/tests/test_native_send_admission.py index 903664548b..ba04c5e5b6 100644 --- a/tests/test_native_send_admission.py +++ b/tests/test_native_send_admission.py @@ -27,10 +27,8 @@ from agent_comms.coordination.coordinator import Coordination from agent_comms.coordination.database import CoordinationStore from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( - AttachedChild, - ProcessIdentity, -) +from agent_comms.execution.child_process import AttachedChild +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_prompt_send import ( PromptSendNotWritten, PromptSendUnknown, diff --git a/tests/test_native_settlement_scope.py b/tests/test_native_settlement_scope.py index 08b9ff5378..e2517f7a89 100644 --- a/tests/test_native_settlement_scope.py +++ b/tests/test_native_settlement_scope.py @@ -7,7 +7,7 @@ from agent_comms.coordination.attempt_states import SucceededAttempt from agent_comms.coordination.coordinator import StandaloneCoordination -from agent_comms.execution.child_process import NoProcess +from agent_comms.execution.process_identity import NoProcess from agent_comms.execution.selected.claim import publish_selected_resource_claim from agent_comms.messaging.bus import Bus from agent_comms.messaging.envelope_claim_transitions import ExistingFileClaim diff --git a/tests/test_native_unknown_recovery.py b/tests/test_native_unknown_recovery.py index 4fa8357e31..561915a9ee 100644 --- a/tests/test_native_unknown_recovery.py +++ b/tests/test_native_unknown_recovery.py @@ -23,10 +23,8 @@ from agent_comms.coordination.reason_codes import GivenReasonCode from agent_comms.coordination.tables.attempts import ReplayFact from agent_comms.coordination.tables.executions import CurrentExecutions, WireOrigin -from agent_comms.execution.child_process import ( - ProcessIdentity, - SpawnedProcess, -) +from agent_comms.execution.child_process import SpawnedProcess +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.cursor_publication import CursorDelivery from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.thread_launch import ThreadLaunch diff --git a/tests/test_operations.py b/tests/test_operations.py index 4b4e36f739..b5b6a70cac 100644 --- a/tests/test_operations.py +++ b/tests/test_operations.py @@ -11,7 +11,7 @@ from agent_comms.comms import Comms, wire from agent_comms.errors import RelationViolationError, UnregisteredThreadError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.context_reading import ContextUsage from agent_comms.execution.launch_runtime import CallingThreadUnavailable from agent_comms.execution.thread_launch import ThreadLaunch diff --git a/tests/test_optional_awareness_projection.py b/tests/test_optional_awareness_projection.py index 6d85238fe2..66ca394c97 100644 --- a/tests/test_optional_awareness_projection.py +++ b/tests/test_optional_awareness_projection.py @@ -25,7 +25,7 @@ from agent_comms.coordination.tables.assignments import WakeAssignment from agent_comms.coordination.tables.executions import WireOrigin from agent_comms.coordination.tables.responses import ResponseObligation -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.selected.source_batch import SelectedSource from agent_comms.messaging.bus_publication import Delivered from agent_comms.messaging.messages import NoticeRole diff --git a/tests/test_order_claims.py b/tests/test_order_claims.py index 6c9f728ac0..cb6d7325ef 100644 --- a/tests/test_order_claims.py +++ b/tests/test_order_claims.py @@ -18,7 +18,7 @@ HumanSendRefusedError, TodoError, ) -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.bus_tables import AuthoredAnswers from agent_comms.messaging.messages import HandoffKind, Message, QuestionKind from agent_comms.nominal.field_codec import ( diff --git a/tests/test_order_progress.py b/tests/test_order_progress.py index a60f6686c1..1880b08ccd 100644 --- a/tests/test_order_progress.py +++ b/tests/test_order_progress.py @@ -14,7 +14,7 @@ import fixture_git from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRoot from agent_comms.planning.order_goal_actions import CreateProblemGoalAction from agent_comms.planning.orders import ( diff --git a/tests/test_ordinary_nk_delivery.py b/tests/test_ordinary_nk_delivery.py index 8258747d17..0414210a18 100644 --- a/tests/test_ordinary_nk_delivery.py +++ b/tests/test_ordinary_nk_delivery.py @@ -6,7 +6,7 @@ import os from agent_comms.messaging.channel_targets import ThreadTarget -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.messages import NoticeRole from agent_comms.projects.checkouts import Checkout from agent_comms.registry.threads import NativeThread diff --git a/tests/test_owned_turn_goal_replacement.py b/tests/test_owned_turn_goal_replacement.py index 1d87af09e0..f5b3cf479c 100644 --- a/tests/test_owned_turn_goal_replacement.py +++ b/tests/test_owned_turn_goal_replacement.py @@ -10,7 +10,7 @@ from agent_comms.execution.acp import CommsAgent from agent_comms.execution.backend import TurnSession from agent_comms.execution.channel_coding_tools import OrdinaryGoalRule -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.controller import NO_CONTROLLER from agent_comms.execution.owned_send import OwnedSend from agent_comms.execution.owned_turn import OwnedTurn diff --git a/tests/test_owner_process.py b/tests/test_owner_process.py index 7ba0780a1f..819a9f81fa 100644 --- a/tests/test_owner_process.py +++ b/tests/test_owner_process.py @@ -24,10 +24,8 @@ from agent_comms.coordination.coordinator import Coordination from agent_comms.errors import RelationViolationError from agent_comms.execution.acp import CommsClient -from agent_comms.execution.child_process import ( - NoProcess, - SpawnedProcess, -) +from agent_comms.execution.child_process import SpawnedProcess +from agent_comms.execution.process_identity import NoProcess from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.launch_runtime import LaunchRuntime, RestartEnvironment from agent_comms.execution.native_arguments import GivenArguments, GivenBinary diff --git a/tests/test_owner_release_restart.py b/tests/test_owner_release_restart.py index cbb51d5ad5..0645f8b3b8 100644 --- a/tests/test_owner_release_restart.py +++ b/tests/test_owner_release_restart.py @@ -11,7 +11,7 @@ from agent_comms.comms import wire from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import NoProcess, ProcessIdentity +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.launch_runtime import RestoredRuntime from agent_comms.execution.owner_cutover import PreserveOwnerRuntime from agent_comms.execution.owner_lifecycle import OwnerLifecycle, OwnerRestartSelection diff --git a/tests/test_owner_restart_handoff.py b/tests/test_owner_restart_handoff.py index 26154c8656..1a00d68ae6 100644 --- a/tests/test_owner_restart_handoff.py +++ b/tests/test_owner_restart_handoff.py @@ -10,10 +10,7 @@ import pytest from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.launch_runtime import ( LaunchRuntime, RestartEnvironment, diff --git a/tests/test_owner_without_socket.py b/tests/test_owner_without_socket.py index b1d1b61fc5..2de01b29e4 100644 --- a/tests/test_owner_without_socket.py +++ b/tests/test_owner_without_socket.py @@ -7,7 +7,7 @@ import pytest -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.projects.storage_rules import StorageRule from agent_comms.transport.owner_connection import OwnerConnection diff --git a/tests/test_peer_relevance.py b/tests/test_peer_relevance.py index 34cb527bf1..d42c39cbe8 100644 --- a/tests/test_peer_relevance.py +++ b/tests/test_peer_relevance.py @@ -8,7 +8,7 @@ from agent_comms.context_segments.awareness import AwarenessSegment from agent_comms.context_segments.partner_activity import PartnerActivitySegment from agent_comms.context_segments.relationships import RelationshipsSegment -from agent_comms.execution.child_process import NoProcess +from agent_comms.execution.process_identity import NoProcess from agent_comms.execution.turn_context import ( CoordinationSegment, NextContextTurn, diff --git a/tests/test_private_idle_drain.py b/tests/test_private_idle_drain.py index 7dba840ea7..8e408b7824 100644 --- a/tests/test_private_idle_drain.py +++ b/tests/test_private_idle_drain.py @@ -13,7 +13,7 @@ from agent_comms.coordination.coordinator import Coordination from agent_comms.coordination.database import ReadableStore from agent_comms.coordination.errors import StaleFence -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.owned_turn import OwnedTurn from agent_comms.execution.queued_input import DeliveredInput from agent_comms.execution.turn_input_source import NoTurnAcceptance diff --git a/tests/test_process_names.py b/tests/test_process_names.py index a98817d92b..c3e6fb3d3d 100644 --- a/tests/test_process_names.py +++ b/tests/test_process_names.py @@ -8,11 +8,8 @@ import pytest -from agent_comms.execution.child_process import ( - ForkedProcessPool, - ProcessName, - SpawnedHelper, -) +from agent_comms.execution.child_process import ForkedProcessPool, SpawnedHelper +from agent_comms.execution.process_identity import ProcessName from agent_comms.execution.remote_core_process import RemoteReadProcess from agent_comms.transport.remote_core import RemoteCoreAccess diff --git a/tests/test_process_state.py b/tests/test_process_state.py index fc8f098112..19e70255fa 100644 --- a/tests/test_process_state.py +++ b/tests/test_process_state.py @@ -8,11 +8,7 @@ from agent_comms.cli_verbs.cli_commands import ThreadCreatedResult from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, - ProcessState, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity, ProcessState from agent_comms.nominal.field_codec import FieldCodec from agent_comms.registry.owner_release import OwnerReleaseEvidence diff --git a/tests/test_project_resume.py b/tests/test_project_resume.py index 40eab99623..c00b23de48 100644 --- a/tests/test_project_resume.py +++ b/tests/test_project_resume.py @@ -10,7 +10,7 @@ from agent_comms.comms import wire from agent_comms.coordination.coordinator import Coordination from agent_comms.coordination.tables.executions import NoPointedExecution -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.turn_phase import CancellingPhase, ShutdownPhase from agent_comms.execution.turn_terminal import InstallStopped, OperatorStopped, OwnerStop from agent_comms.messaging.messages import InfoKind, Message diff --git a/tests/test_read_ledger.py b/tests/test_read_ledger.py index 58ea5b3f64..0d09137ac7 100644 --- a/tests/test_read_ledger.py +++ b/tests/test_read_ledger.py @@ -8,7 +8,7 @@ from agent_comms.comms import wire from agent_comms.coordination.errors import DMPaintedBoundChanged, DMScopeChanged, ReadAgain -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.channel_targets import CommandTarget, ThreadTarget from agent_comms.messaging.message_page import ( MessagePageRequest, diff --git a/tests/test_reader_liveness_is_socket.py b/tests/test_reader_liveness_is_socket.py index d50e67be34..627338251b 100644 --- a/tests/test_reader_liveness_is_socket.py +++ b/tests/test_reader_liveness_is_socket.py @@ -16,7 +16,7 @@ import pytest from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.registry.activity import ReadyDrainReadiness from agent_comms.team.standing import UnitDeaf from test_cli import cli # noqa: F401 (the installed-root command line fixture) diff --git a/tests/test_registration_authority.py b/tests/test_registration_authority.py index 4dbe306ac6..38c9a609ae 100644 --- a/tests/test_registration_authority.py +++ b/tests/test_registration_authority.py @@ -10,7 +10,7 @@ from agent_comms.comms import wire from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.turn_lease import RecordedGeneration from agent_comms.execution.turn_phase import PreparingPhase from agent_comms.nominal.field_codec import GoalId, TurnId diff --git a/tests/test_registration_components.py b/tests/test_registration_components.py index ca80269255..3cf3d46fe6 100644 --- a/tests/test_registration_components.py +++ b/tests/test_registration_components.py @@ -10,7 +10,7 @@ import pytest from agent_comms.errors import RelationViolationError, UnregisteredThreadError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.messaging.routing import NoTurnRouting from agent_comms.messaging.snapshot_slices import ThreadSlice from agent_comms.nominal.field_codec import FieldCodec, TurnId diff --git a/tests/test_registration_inheritance.py b/tests/test_registration_inheritance.py index 4ea4eac873..10642012b2 100644 --- a/tests/test_registration_inheritance.py +++ b/tests/test_registration_inheritance.py @@ -9,7 +9,7 @@ from agent_comms.comms import wire from agent_comms.coordination.errors import StaleFence from agent_comms.coordination.response import LiveResponseOwner -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.pi_vocabulary import HighThinkingLevel from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.execution.turn_lease import NoTurnLease diff --git a/tests/test_registration_process_identity.py b/tests/test_registration_process_identity.py index b05b15dfe9..e5a791d46a 100644 --- a/tests/test_registration_process_identity.py +++ b/tests/test_registration_process_identity.py @@ -15,7 +15,8 @@ from agent_comms.comms import wire from agent_comms.config_options import ConfigOptions from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import NoProcess, ProcessIdentity, SpawnedProcess +from agent_comms.execution.child_process import SpawnedProcess +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.thread_launch import ThreadLaunch from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.installer.native_build_inputs import DetachedChildStdio diff --git a/tests/test_registration_transitions.py b/tests/test_registration_transitions.py index c433ca3358..590a10caa9 100644 --- a/tests/test_registration_transitions.py +++ b/tests/test_registration_transitions.py @@ -6,7 +6,7 @@ import pytest from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.execution.turn_lease import ( ActiveTurn, diff --git a/tests/test_registry_copy_retires_processes.py b/tests/test_registry_copy_retires_processes.py index 307422ac7b..9d9fb00e8d 100644 --- a/tests/test_registry_copy_retires_processes.py +++ b/tests/test_registry_copy_retires_processes.py @@ -2,7 +2,7 @@ import os -from agent_comms.execution.child_process import NoProcess, ProcessIdentity +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.projects.checkouts import Checkout from agent_comms.registry.registration import Registration from agent_comms.registry.threads import NativeThread diff --git a/tests/test_registry_current_format.py b/tests/test_registry_current_format.py index f96c27d1f5..71b1403b08 100644 --- a/tests/test_registry_current_format.py +++ b/tests/test_registry_current_format.py @@ -8,7 +8,7 @@ import pytest from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import FieldCodec, GoalId from agent_comms.planning.goal_states import ( BlockedGoal, diff --git a/tests/test_reopen_orders.py b/tests/test_reopen_orders.py index f6ac8a8e11..f716ef81f5 100644 --- a/tests/test_reopen_orders.py +++ b/tests/test_reopen_orders.py @@ -6,7 +6,7 @@ from agent_comms_hooks import ToolRefusedError from agent_comms.errors import TodoError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.installer.runtime_record import ToadPackage from agent_comms.nominal.field_codec import FieldCodec from agent_comms.planning import orders diff --git a/tests/test_root_host_retirement.py b/tests/test_root_host_retirement.py index ca444f0c2c..9d92003e72 100644 --- a/tests/test_root_host_retirement.py +++ b/tests/test_root_host_retirement.py @@ -7,7 +7,7 @@ import pytest -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.root_host_store import RootHostStore from agent_comms.execution.root_runtime import ( NoRootHost, diff --git a/tests/test_roster_restoration.py b/tests/test_roster_restoration.py index b3fb3afd0b..0942877b94 100644 --- a/tests/test_roster_restoration.py +++ b/tests/test_roster_restoration.py @@ -14,10 +14,7 @@ from agent_comms.coordination.tables.executions import NoPointedExecution from agent_comms.display_order import LastActivityThreadSort from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.execution.turn_lease import NoTurnRecord from agent_comms.messaging.channel_targets import CommandTarget diff --git a/tests/test_runtime.py b/tests/test_runtime.py index 2aaae8965d..84a658fa5b 100644 --- a/tests/test_runtime.py +++ b/tests/test_runtime.py @@ -23,7 +23,7 @@ ) from agent_comms.comms import wire from agent_comms.coordination.coordinator import Coordination -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import BusInputKey from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.native_arguments import GivenBinary diff --git a/tests/test_runtime_owned_session_admission.py b/tests/test_runtime_owned_session_admission.py index 094cc69bc2..ee744c4435 100644 --- a/tests/test_runtime_owned_session_admission.py +++ b/tests/test_runtime_owned_session_admission.py @@ -15,7 +15,7 @@ from agent_comms.comms import wire from agent_comms.coordination.errors import Refused from agent_comms.errors import RelationViolationError, UnregisteredThreadError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.owner_protocol import OwnerFailure, OwnerLine from agent_comms.nominal.field_codec import AcpSessionId, FieldCodec from agent_comms.projects.checkouts import Checkout diff --git a/tests/test_runtime_processes.py b/tests/test_runtime_processes.py index 649e093f7e..58a829ec2b 100644 --- a/tests/test_runtime_processes.py +++ b/tests/test_runtime_processes.py @@ -6,12 +6,9 @@ from contextlib import ExitStack from pathlib import Path -from agent_comms.execution.child_process import ( - Platform, - ProcessIdentity, - SpawnedProcess, -) +from agent_comms.execution.child_process import SpawnedProcess from agent_comms.execution.launch_runtime import LaunchRuntime +from agent_comms.execution.process_identity import ProcessIdentity, ProcessPlatform from agent_comms.execution.runtime_processes import ( RuntimeProcesses, RuntimeProcessOutcome, @@ -63,7 +60,7 @@ def test_runtime_process_family(tmp_path, monkeypatch): assert outcome.process == ProcessIdentity.capture(children[0].pid) assert outcome.process.prefix == old.prefix assert outcome.process.application.process == ProcessIdentity.capture(os.getpid()) - assert outcome.process.application.name == Platform.current().process_name(os.getpid()) + assert outcome.process.application.name == ProcessPlatform.current().process_name(os.getpid()) # Resolving the interpreter would collapse both runtimes onto the shared Python. assert old.interpreter.resolve() == target.interpreter.resolve() assert str(children[0].pid) in outcome.line() @@ -87,7 +84,7 @@ def denied_arguments(platform, process): raise PermissionError("process command line denied") with monkeypatch.context() as denied: - denied.setattr(type(Platform.current()), "arguments", denied_arguments) + denied.setattr(type(ProcessPlatform.current()), "arguments", denied_arguments) (unknown,) = RuntimeProcesses.observe(target, proc).outcomes assert isinstance(unknown, UnreadableRuntimeProcess) assert unknown.pid == os.getpid() diff --git a/tests/test_runtime_retention.py b/tests/test_runtime_retention.py index ff6089ef90..9e20c12b4a 100644 --- a/tests/test_runtime_retention.py +++ b/tests/test_runtime_retention.py @@ -7,10 +7,8 @@ from contextlib import contextmanager from pathlib import Path -from agent_comms.execution.child_process import ( - ProcessIdentity, - SpawnedProcess, -) +from agent_comms.execution.child_process import SpawnedProcess +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.runtime_processes import ( ImportingRuntimeProcess, diff --git a/tests/test_runtime_subscription_handshake.py b/tests/test_runtime_subscription_handshake.py index 125a99f5d2..caf6562697 100644 --- a/tests/test_runtime_subscription_handshake.py +++ b/tests/test_runtime_subscription_handshake.py @@ -12,7 +12,7 @@ from agent_comms.comms import wire from agent_comms.coordination.database import CoordinationStore from agent_comms.coordination.errors import CoordinationReadUnavailable -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.owner_protocol import OwnerAnnouncement from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.nominal.field_codec import AcpSessionId, MalformedRecord diff --git a/tests/test_selected_answer_forms.py b/tests/test_selected_answer_forms.py index 1e5d2d05bb..08b0b6926f 100644 --- a/tests/test_selected_answer_forms.py +++ b/tests/test_selected_answer_forms.py @@ -18,7 +18,7 @@ from agent_comms.comms import wire from agent_comms.coordination.cohort import sealed_cohort_assignments from agent_comms.coordination.coordinator import Coordination -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_failures import NativePiUnavailable from agent_comms.execution.selected.source_batch import ( SelectedSource, diff --git a/tests/test_selected_source_batch.py b/tests/test_selected_source_batch.py index 26a1a6daf4..94622d8c22 100644 --- a/tests/test_selected_source_batch.py +++ b/tests/test_selected_source_batch.py @@ -8,7 +8,7 @@ from agent_comms.comms import wire from agent_comms.coordination.cohort import pending_sealed_assignments from agent_comms.coordination.coordinator import Coordination -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.selected.participant import SelectedParticipant from agent_comms.projects.checkouts import Checkout from agent_comms.registry.thread_model import DeclaredModel diff --git a/tests/test_session_bridge_owner.py b/tests/test_session_bridge_owner.py index 6a2ff70e00..1a1957fa75 100644 --- a/tests/test_session_bridge_owner.py +++ b/tests/test_session_bridge_owner.py @@ -19,10 +19,7 @@ from agent_comms.cli_bridges.monitor import InspectSession, VerifySession from agent_comms.cli_bridges.session_watch import LiveWatch, SessionRefusedError, WatchClaim from agent_comms.cli_bridges.shared import Binding, Serve -from agent_comms.execution.child_process import ( - IdentityMismatchError, - ProcessIdentity, -) +from agent_comms.execution.process_identity import IdentityMismatchError, ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRuntime from agent_comms.execution.root_runtime import RootRuntime from agent_comms.projects.checkouts import Checkout diff --git a/tests/test_session_close.py b/tests/test_session_close.py index 65c7c9f0cc..f3de76243c 100644 --- a/tests/test_session_close.py +++ b/tests/test_session_close.py @@ -10,7 +10,7 @@ from agent_comms.execution.acp import CommsAgent, CommsClient from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.controller import CancelledOutcome from agent_comms.nominal.field_codec import AcpSessionId from agent_comms.projects.checkouts import Checkout diff --git a/tests/test_session_load_plan.py b/tests/test_session_load_plan.py index 9bb2e9971f..ae2aa99267 100644 --- a/tests/test_session_load_plan.py +++ b/tests/test_session_load_plan.py @@ -2,7 +2,7 @@ import pytest -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import FieldCodec from agent_comms.registry.thread_identity import ( OwnerIdentity, diff --git a/tests/test_stopped_claim_expiry.py b/tests/test_stopped_claim_expiry.py index ee30c2340a..1f08b8f49a 100644 --- a/tests/test_stopped_claim_expiry.py +++ b/tests/test_stopped_claim_expiry.py @@ -8,10 +8,7 @@ from agent_comms.comms import wire from agent_comms.coordination.session import NativeCapture -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.messaging.envelope_claim_transitions import NativeClaim, WakeClaims from agent_comms.messaging.messages import ClaimNoticeKind from agent_comms.nominal.field_codec import ClaimId, InputId, TurnId diff --git a/tests/test_storage_room.py b/tests/test_storage_room.py index 55eaa91307..4d9bbde507 100644 --- a/tests/test_storage_room.py +++ b/tests/test_storage_room.py @@ -8,7 +8,7 @@ import pytest from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import RoomTicket from agent_comms.projects.checkouts import Checkout from agent_comms.projects.shell_effects import shell_storage_effects diff --git a/tests/test_task_decisions.py b/tests/test_task_decisions.py index 328f304e81..acf75d0de3 100644 --- a/tests/test_task_decisions.py +++ b/tests/test_task_decisions.py @@ -10,7 +10,7 @@ from agent_comms.comms import wire from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.execution.turn_lease import NoTurnLease from agent_comms.messaging.bus_publication import AgentOrigin diff --git a/tests/test_team_deaf_monitor.py b/tests/test_team_deaf_monitor.py index bad27aef6c..b1aeb0bc4e 100644 --- a/tests/test_team_deaf_monitor.py +++ b/tests/test_team_deaf_monitor.py @@ -19,10 +19,7 @@ Serve, StoredBinding, ) -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.messaging.channel_targets import CommsTag from agent_comms.messaging.messages import Addressed from agent_comms.nominal.field_codec import FieldCodec diff --git a/tests/test_team_notifications.py b/tests/test_team_notifications.py index 9cce7f7e19..9db11fb62a 100644 --- a/tests/test_team_notifications.py +++ b/tests/test_team_notifications.py @@ -25,7 +25,7 @@ RelationViolationError, UnregisteredThreadError, ) -from agent_comms.execution.child_process import NoProcess, ProcessIdentity +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.launch_root import LaunchRoot from agent_comms.heartbeat_subjects import PhaseSubject, TeamHistory, TeammateSubject from agent_comms.messaging.bus_publication import AgentOrigin diff --git a/tests/test_thread_identity.py b/tests/test_thread_identity.py index c90f9cf615..03ea01792d 100644 --- a/tests/test_thread_identity.py +++ b/tests/test_thread_identity.py @@ -10,10 +10,7 @@ from agent_comms.comms import wire from agent_comms.coordination.coordinator import Coordination from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.queued_input import QueuedInputContext from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.execution.turn_lease import ( diff --git a/tests/test_thread_names.py b/tests/test_thread_names.py index 824fd26b48..3c4e80d0cb 100644 --- a/tests/test_thread_names.py +++ b/tests/test_thread_names.py @@ -49,7 +49,7 @@ from agent_comms.comms import wire from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.projects.checkouts import Checkout from agent_comms.registry.thread_results import ThreadTitleResult from agent_comms.registry.threads import NativeThread diff --git a/tests/test_thread_status.py b/tests/test_thread_status.py index 2a7a47658c..bd944d793f 100644 --- a/tests/test_thread_status.py +++ b/tests/test_thread_status.py @@ -13,7 +13,7 @@ from agent_comms.comms import wire from agent_comms.coordination.errors import StaleRevision from agent_comms.errors import RelationViolationError, UnregisteredThreadError -from agent_comms.execution.child_process import NoProcess, ProcessIdentity +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.pi_vocabulary import ServiceTier from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.nominal.field_codec import FieldCodec diff --git a/tests/test_todos.py b/tests/test_todos.py index 91425f08f2..e495dee849 100644 --- a/tests/test_todos.py +++ b/tests/test_todos.py @@ -22,7 +22,7 @@ from agent_comms.comms import wire from agent_comms.errors import TodoError -from agent_comms.execution.child_process import NoProcess, ProcessIdentity +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.turn_item import NativeItemId, NativeTurnId from agent_comms.installer.practice import PracticeCopy diff --git a/tests/test_tool_output.py b/tests/test_tool_output.py index c7cc1f36d4..223ef14e51 100644 --- a/tests/test_tool_output.py +++ b/tests/test_tool_output.py @@ -7,7 +7,7 @@ import pytest -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.input_key import AcpInputKey, BusInputKey from agent_comms.execution.reported_turn import ReportedTurn from agent_comms.input_attempt import BoundUnknownInput diff --git a/tests/test_turn_declaration.py b/tests/test_turn_declaration.py index d39e90aa87..2175fcfc14 100644 --- a/tests/test_turn_declaration.py +++ b/tests/test_turn_declaration.py @@ -3,10 +3,7 @@ import pytest from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ( - NoProcess, - ProcessIdentity, -) +from agent_comms.execution.process_identity import NoProcess, ProcessIdentity from agent_comms.execution.reported_turn import NoReportedTurn from agent_comms.execution.turn_lease import ( ActiveTurn, diff --git a/tests/test_turn_digests.py b/tests/test_turn_digests.py index dc91d59dc0..b846c003b8 100644 --- a/tests/test_turn_digests.py +++ b/tests/test_turn_digests.py @@ -23,7 +23,7 @@ from agent_comms.comms import wire from agent_comms.context_segments.wake import SelectedWakeSegment from agent_comms.context_store import ContextEntry -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.native_session_reopen import PiSessionId from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.execution.context_provenance import JournalProvenance, WireProvenance diff --git a/tests/test_turn_lease_release.py b/tests/test_turn_lease_release.py index 2618e3765f..a6f16f146e 100644 --- a/tests/test_turn_lease_release.py +++ b/tests/test_turn_lease_release.py @@ -3,7 +3,7 @@ import os from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.turn_lease import ( FinishedTurnFence, NoFinishedTurn, diff --git a/tests/test_turn_record.py b/tests/test_turn_record.py index aaec99bf8d..95be0c05da 100644 --- a/tests/test_turn_record.py +++ b/tests/test_turn_record.py @@ -7,7 +7,7 @@ from agent_comms.comms import wire from agent_comms.errors import RelationViolationError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import TurnId from agent_comms.projects.checkouts import Checkout from agent_comms.registry.registry_store import RegistryStore diff --git a/tests/test_unit_state.py b/tests/test_unit_state.py index 32091b6274..de1020527c 100644 --- a/tests/test_unit_state.py +++ b/tests/test_unit_state.py @@ -10,7 +10,7 @@ import pytest -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_runtime import LaunchRoot from agent_comms.execution.session_file import RegistrySessionLocation from agent_comms.execution.transcript_sources import ExternalTranscript diff --git a/tests/test_unowned_checkout_work.py b/tests/test_unowned_checkout_work.py index 14d58c2f3b..f03c0695ad 100644 --- a/tests/test_unowned_checkout_work.py +++ b/tests/test_unowned_checkout_work.py @@ -15,7 +15,7 @@ from agent_comms.comms import Comms, wire from agent_comms.coordination.service_passes import ServicePassStore from agent_comms.errors import TodoError -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.launch_root import LaunchRoot from agent_comms.execution.turn_item import ( NativeItemId, diff --git a/tests/test_wake_goal_execution.py b/tests/test_wake_goal_execution.py index b7b4695e22..7689ce7363 100644 --- a/tests/test_wake_goal_execution.py +++ b/tests/test_wake_goal_execution.py @@ -10,7 +10,7 @@ WakeGoalContext, WakeWorkContext, ) -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.nominal.field_codec import FieldCodec from agent_comms.planning.goal_actions import ( BlockedGoalAction, diff --git a/tests/test_wake_lifetime.py b/tests/test_wake_lifetime.py index 34d1bb2b91..d603d48490 100644 --- a/tests/test_wake_lifetime.py +++ b/tests/test_wake_lifetime.py @@ -6,7 +6,7 @@ from agent_comms.execution.acp import CommsAgent from agent_comms.comms import wire -from agent_comms.execution.child_process import ProcessIdentity +from agent_comms.execution.process_identity import ProcessIdentity from agent_comms.execution.controller import UNBOUND_CONTROLLER from agent_comms.execution.input_drain import WakeScheduleCheck from agent_comms.messaging.routing import ScheduledTurn diff --git a/tests/test_watch_git_preparation.py b/tests/test_watch_git_preparation.py index de4b817e53..4b3795221c 100644 --- a/tests/test_watch_git_preparation.py +++ b/tests/test_watch_git_preparation.py @@ -21,9 +21,12 @@ from agent_comms.comms import Comms from agent_comms.coordination.coordinator import Coordination from agent_comms.coordination.service_passes import ServicePassStore -from agent_comms.execution.child_process import ( +from agent_comms.execution.async_retirement import ( AsyncWork, ChildRetirementFailed, + join_retirement, +) +from agent_comms.execution.child_process import ( GitChildPermission, GitChildren, ObservedProcess, @@ -31,7 +34,6 @@ ReadWork, SpawnedProcess, SynchronousProcess, - join_retirement, ) from agent_comms.execution.watch_passes import Watch from agent_comms.installer.native_build_inputs import ( diff --git a/tests/worker_hosts.py b/tests/worker_hosts.py index e933a91504..a419f2ae99 100644 --- a/tests/worker_hosts.py +++ b/tests/worker_hosts.py @@ -4,11 +4,8 @@ from pathlib import Path -from agent_comms.execution.child_process import ( - ObservedProcess, - Platform, - ProcessIdentity, -) +from agent_comms.execution.child_process import ObservedProcess, Platform +from agent_comms.execution.process_identity import ProcessIdentity class TestWorkerHosts: diff --git a/tools/agent_comms_project.py b/tools/agent_comms_project.py index 968c063e37..eb422afb83 100644 --- a/tools/agent_comms_project.py +++ b/tools/agent_comms_project.py @@ -31,11 +31,8 @@ import agent_comms from agent_comms.coordination import schema as coordination_schema -from agent_comms.execution.child_process import ( - ForkedProcessPool, - ProcessName, - SpawnedProcess, -) +from agent_comms.execution.child_process import ForkedProcessPool, SpawnedProcess +from agent_comms.execution.process_identity import ProcessName from agent_comms.execution.launch_runtime import RestoredRuntime from agent_comms.installer.core_stamp import WheelStamp from agent_comms.installer.probes.carry import Carry