diff --git a/docs/audits/architecture_n_z_development.json b/docs/audits/architecture_n_z_development.json index 78b0415766..3d583b9137 100644 --- a/docs/audits/architecture_n_z_development.json +++ b/docs/audits/architecture_n_z_development.json @@ -910,7 +910,7 @@ }, { "path": "openhcs/agent/dto/execution.py", - "sha256": "9cabb87dec2c865d2fddd3babe298b200e2830ae6dd0bfe5a26afa8b8ad9bf1c", + "sha256": "1fbdc008937e3a043cf077e2243b40f6a0efba34d9166716c423af9b85445684", "role": "Declares the typed public job status and delegates terminal semantics to the generic lifecycle declaration." }, { @@ -2612,7 +2612,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns nominal gallery scenario identity, publication targets, representative images, copy, accessibility text, dimensions, contextual and stable-window capture targets, and derivative contracts." }, { @@ -2869,7 +2869,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the nominal gallery scenario lattice, stable-window and contextual capture targets, publication targets, derivative inventory, source evidence, card rendering, and generated release record." }, { @@ -3027,7 +3027,7 @@ }, { "path": "openhcs/agent/dto/execution.py", - "sha256": "9cabb87dec2c865d2fddd3babe298b200e2830ae6dd0bfe5a26afa8b8ad9bf1c", + "sha256": "1fbdc008937e3a043cf077e2243b40f6a0efba34d9166716c423af9b85445684", "role": "Declares the public typed execution status and progress observation result." }, { diff --git a/docs/audits/gallery_connection_owner_review_20260924.md b/docs/audits/gallery_connection_owner_review_20260924.md new file mode 100644 index 0000000000..373440cc95 --- /dev/null +++ b/docs/audits/gallery_connection_owner_review_20260924.md @@ -0,0 +1,25 @@ +# Gallery connection declaration owner review (2026-09-24) + +The shared `ExecutionConnectionSpec` declaration moved unchanged from +`openhcs/agent/dto/execution.py` into +`openhcs/agent/dto/execution_connection.py`. The former module re-exports the +same class for existing clients. `scripts/gallery_catalog.py` now imports the +lightweight owner at runtime, so its `GallerySourceCaptureRequest` annotation +is resolvable by `typing.get_type_hints` and `dataclass_from_mapping` without +loading the heavy execution DTO graph or pandas during website validation. + +This is an import/ownership change, not a gallery scenario, capture target, +connection field, protocol, job-status, or progress-projection change. The +existing audited user and development pages that cite `scripts/gallery_catalog.py` +retain their scenario and publication claims. The two pages citing +`openhcs/agent/dto/execution.py` for job/progress DTOs retain those claims; +the moved connection declaration was not the authority for those claims. + +Validation: the focused gallery request round-trip test passed; a fresh import +of the catalog left `pandas` unloaded and `get_type_hints` resolved the +connection type. The gallery and website unit group passed (63 tests), and +documentation validation passed (155 audited sources). The agent-service group +passed 106 tests; its one function-catalog preparation test initially hit an +`EDQUOT` disk-quota error in a subprocess, then passed when `TMPDIR` was placed +on the analysis drive (107 tests passing across the two runs). Full CI remains +the publication gate. diff --git a/docs/audits/user_docs.json b/docs/audits/user_docs.json index 79b610ca7a..fdd4572088 100644 --- a/docs/audits/user_docs.json +++ b/docs/audits/user_docs.json @@ -1192,7 +1192,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the documentation-enabled Function Selector capture declaration, accessibility text, capture target, and generated visual projection." }, { @@ -1349,7 +1349,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the documentation-enabled global, pipeline, step, and nested function configuration capture declarations, accessibility text, capture targets, and generated visual projections." } ], @@ -1557,7 +1557,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the documentation-enabled source-image browser capture, caption, accessibility text, dimensions, and source evidence." }, { @@ -1808,7 +1808,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the documentation-enabled synthetic generator, plate metadata, and live measurement result capture declarations used by the first-workflow tutorial." } ], @@ -2832,7 +2832,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the landing-page workspace scenario, representative image, caption, description, alt text, dimensions, and release evidence." } ], @@ -3219,7 +3219,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Projects every registered stable-window identity into its documentation scenario, capture target, filename, and accessibility text." }, { @@ -3396,7 +3396,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the lazy-inheritance scenario, representative poster, caption, description, alt text, dimensions, and release evidence." }, { @@ -3594,7 +3594,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the documentation-enabled Custom Function Manager capture declaration, accessibility text, capture target, and generated visual projection." }, { @@ -3922,7 +3922,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the documentation-enabled execution-log capture, caption, accessibility text, dimensions, and source evidence." } ], @@ -3994,7 +3994,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the local-MCP endpoint-startup scenario, representative poster, caption, description, alt text, dimensions, and release evidence." }, { @@ -4142,7 +4142,7 @@ }, { "path": "scripts/gallery_catalog.py", - "sha256": "bda42a36c1c510af7ac587dc2642548758d28c4a0061d581ebe38a5be4fb3743", + "sha256": "7f493e0cb305e14ee4cf7d3e995c67df4200186a8a8aaf00eef0bc66d8d191cf", "role": "Owns the Napari ROI-navigation and Fiji ROI-review scenarios, representative images, captions, descriptions, alt text, dimensions, and release evidence." } ], diff --git a/openhcs/agent/dto/execution.py b/openhcs/agent/dto/execution.py index 762df9458b..e7e1000e63 100644 --- a/openhcs/agent/dto/execution.py +++ b/openhcs/agent/dto/execution.py @@ -4,15 +4,14 @@ from abc import abstractmethod from collections.abc import Mapping, Sequence -from dataclasses import asdict, dataclass, field, replace +from dataclasses import dataclass, field, replace from functools import wraps -from typing import TYPE_CHECKING, Self +from typing import Self -from python_introspect import project_dataclass, validate_annotated_dataclass +from python_introspect import validate_annotated_dataclass from zmqruntime.config import ( NonBlankString, PositiveInteger, - SocketPort, TransportMode, ) from zmqruntime.execution import ExecutionProgressObservation @@ -23,7 +22,6 @@ RunningExecutionInfo, WorkerState, ) -from zmqruntime.transport import TransportEndpoint, resolve_transport_mode from openhcs.agent.dto.common import ( SCHEMA_VERSION, @@ -35,6 +33,7 @@ JsonObject, JsonValue, ) +from openhcs.agent.dto.execution_connection import ExecutionConnectionSpec from openhcs.agent.ui_bridge_identities import ( PlateManagerOrchestratorCodeDocumentIdentity, ) @@ -43,109 +42,9 @@ from openhcs.runtime.zmq_config import OPENHCS_ZMQ_CONFIG from openhcs.runtime.zmq_execution_signature import ZMQRuntimeObservationExportScope -if TYPE_CHECKING: - from openhcs.runtime.zmq_config import OpenHCSZMQConfig - from openhcs.runtime.zmq_execution_client import ZMQExecutionClient - - MAX_EXECUTION_STATUS_TRACEBACK_CHARS = 3000 -@dataclass(frozen=True, slots=True) -class ExecutionConnectionSpec: - host: NonBlankString = "localhost" - port: SocketPort | None = None - transport_mode: TransportMode | None = None - persistent: bool = True - - def __post_init__(self) -> None: - validate_annotated_dataclass(self) - - def require_port(self, purpose: str) -> int: - if self.port is None: - raise ValueError(f"{purpose} requires an explicit port.") - return self.port - - def transport_mode_value(self) -> str | None: - return TransportMode.optional_to_text(self.transport_mode) - - def runtime_arguments(self) -> dict[str, object]: - """Project exact typed constructor arguments for this connection.""" - - return asdict(self.public_connection()) - - def specified_runtime_arguments(self) -> dict[str, object]: - """Project typed constructor arguments while omitting unset optionals.""" - - return { - name: value - for name, value in self.runtime_arguments().items() - if value is not None - } - - def tool_arguments(self) -> JsonObject: - """Project the canonical JSON-compatible tool argument fields.""" - - arguments = self.runtime_arguments() - arguments["transport_mode"] = self.transport_mode_value() - return arguments - - def public_connection(self) -> ExecutionConnectionSpec: - """Return the credential-free base connection declaration.""" - - return project_dataclass(ExecutionConnectionSpec, self) - - def zmq_data_url(self, config) -> str: - from zmqruntime.transport import get_zmq_transport_url - - return get_zmq_transport_url( - self.require_port("ZMQ data URL"), - host=self.host, - mode=self.transport_mode, - config=config, - ) - - def zmq_control_port(self, config) -> int: - from zmqruntime.transport import get_control_port - - return get_control_port(self.require_port("ZMQ control port"), config) - - def zmq_control_url(self, config) -> str: - from zmqruntime.transport import get_control_url - - return get_control_url( - self.require_port("ZMQ control URL"), - self.transport_mode, - host=self.host, - config=config, - ) - - def transport_endpoint(self) -> TransportEndpoint: - """Project this connection declaration to its generic endpoint identity.""" - - return TransportEndpoint( - host=self.host, - port=self.require_port("ZMQ transport endpoint"), - transport_mode=resolve_transport_mode(self.transport_mode), - ) - - def execution_client( - self, - config: "OpenHCSZMQConfig", - ) -> "ZMQExecutionClient": - """Construct the OpenHCS execution client for this exact connection.""" - - from openhcs.runtime.zmq_execution_client import ZMQExecutionClient - - return ZMQExecutionClient( - port=self.port, - host=self.host, - persistent=self.persistent, - transport_mode=self.transport_mode, - config=config, - ) - - @dataclass(frozen=True, kw_only=True) class ExecutionConnectionProjection: connection: ExecutionConnectionSpec = field(default_factory=ExecutionConnectionSpec) diff --git a/openhcs/agent/dto/execution_connection.py b/openhcs/agent/dto/execution_connection.py new file mode 100644 index 0000000000..9bc9b0bdc6 --- /dev/null +++ b/openhcs/agent/dto/execution_connection.py @@ -0,0 +1,111 @@ +"""Typed connection declaration shared by execution and lightweight clients.""" + +from __future__ import annotations + +from dataclasses import asdict, dataclass +from typing import TYPE_CHECKING + +from python_introspect import project_dataclass, validate_annotated_dataclass +from zmqruntime.config import NonBlankString, SocketPort, TransportMode +from zmqruntime.transport import TransportEndpoint, resolve_transport_mode + +from openhcs.agent.dto.common import JsonObject + +if TYPE_CHECKING: + from openhcs.runtime.zmq_config import OpenHCSZMQConfig + from openhcs.runtime.zmq_execution_client import ZMQExecutionClient + + +@dataclass(frozen=True, slots=True) +class ExecutionConnectionSpec: + host: NonBlankString = "localhost" + port: SocketPort | None = None + transport_mode: TransportMode | None = None + persistent: bool = True + + def __post_init__(self) -> None: + validate_annotated_dataclass(self) + + def require_port(self, purpose: str) -> int: + if self.port is None: + raise ValueError(f"{purpose} requires an explicit port.") + return self.port + + def transport_mode_value(self) -> str | None: + return TransportMode.optional_to_text(self.transport_mode) + + def runtime_arguments(self) -> dict[str, object]: + """Project exact typed constructor arguments for this connection.""" + + return asdict(self.public_connection()) + + def specified_runtime_arguments(self) -> dict[str, object]: + """Project typed constructor arguments while omitting unset optionals.""" + + return { + name: value + for name, value in self.runtime_arguments().items() + if value is not None + } + + def tool_arguments(self) -> JsonObject: + """Project the canonical JSON-compatible tool argument fields.""" + + arguments = self.runtime_arguments() + arguments["transport_mode"] = self.transport_mode_value() + return arguments + + def public_connection(self) -> ExecutionConnectionSpec: + """Return the credential-free base connection declaration.""" + + return project_dataclass(ExecutionConnectionSpec, self) + + def zmq_data_url(self, config) -> str: + from zmqruntime.transport import get_zmq_transport_url + + return get_zmq_transport_url( + self.require_port("ZMQ data URL"), + host=self.host, + mode=self.transport_mode, + config=config, + ) + + def zmq_control_port(self, config) -> int: + from zmqruntime.transport import get_control_port + + return get_control_port(self.require_port("ZMQ control port"), config) + + def zmq_control_url(self, config) -> str: + from zmqruntime.transport import get_control_url + + return get_control_url( + self.require_port("ZMQ control URL"), + self.transport_mode, + host=self.host, + config=config, + ) + + def transport_endpoint(self) -> TransportEndpoint: + """Project this connection declaration to its generic endpoint identity.""" + + return TransportEndpoint( + host=self.host, + port=self.require_port("ZMQ transport endpoint"), + transport_mode=resolve_transport_mode(self.transport_mode), + ) + + def execution_client( + self, + config: OpenHCSZMQConfig, + ) -> ZMQExecutionClient: + """Construct the OpenHCS execution client for this exact connection.""" + + from openhcs.runtime.zmq_execution_client import ZMQExecutionClient + + return ZMQExecutionClient( + port=self.port, + host=self.host, + persistent=self.persistent, + transport_mode=self.transport_mode, + config=config, + ) diff --git a/scripts/gallery_catalog.py b/scripts/gallery_catalog.py index 701d45636b..498ecbaadf 100644 --- a/scripts/gallery_catalog.py +++ b/scripts/gallery_catalog.py @@ -25,6 +25,7 @@ from pyqt_reactive.services.system_monitor_actions import SystemMonitorAction from python_introspect import dataclass_from_mapping +from openhcs.agent.dto.execution_connection import ExecutionConnectionSpec from openhcs.agent.ui_bridge_actions import PlateManagerAction from openhcs.agent.ui_bridge_identities import ( GlobalConfigWindowIdentity, @@ -40,7 +41,6 @@ from openhcs.serialization.json import JsonValue, to_jsonable if TYPE_CHECKING: - from openhcs.agent.dto.execution import ExecutionConnectionSpec from openhcs.pyqt_gui.services.step_scope_identity import StepEditorScope RELEASE_MEDIA_SCHEMA_VERSION = "openhcs.release-media.v7"