diff --git a/ai/prompt-io/opencode/20260817T231825Z_359fe75c_prompt_io.md b/ai/prompt-io/opencode/20260817T231825Z_359fe75c_prompt_io.md new file mode 100644 index 00000000..81173fed --- /dev/null +++ b/ai/prompt-io/opencode/20260817T231825Z_359fe75c_prompt_io.md @@ -0,0 +1,39 @@ +--- +model: openai/gpt-5.6-sol +service: opencode +session: pr475-review-fixes-20260817 +timestamp: 2026-08-17T23:18:25Z +git_ref: 359fe75c +scope: code +substantive: true +raw_file: 20260817T231825Z_359fe75c_prompt_io.raw.md +--- + +## Prompt + +Continue the `/code-review-changes` pass for PR #475 in its isolated +worktree. Address the seven accepted manual-review findings in +`tractor/ipc/_types.py` and `tractor/ipc/_uds.py`, preserve the existing +Windows capability behavior, verify the result, and prepare the work for +human-controlled commit and review-reply steps. Do not publish replies, +stage, commit, or push without the required explicit authorization. + +## Response summary + +Restored project quote, docstring, multiline-expression, and +`match/case` conventions while retaining the Windows-safe UDS guard. +Removed unnecessary structural and comment churn, then verified the +focused transport, discovery, and lazy-import paths plus the missing +`AF_UNIX` behavior. + +## Files changed + +- `tractor/ipc/_types.py` - restore project style and guarded + socket-family dispatch. +- `tractor/ipc/_uds.py` - format the UDS capability gate + consistently. + +## Human edits + +None - the generated patch remains uncommitted and awaits human +review. diff --git a/ai/prompt-io/opencode/20260817T231825Z_359fe75c_prompt_io.raw.md b/ai/prompt-io/opencode/20260817T231825Z_359fe75c_prompt_io.raw.md new file mode 100644 index 00000000..f9a2dcdd --- /dev/null +++ b/ai/prompt-io/opencode/20260817T231825Z_359fe75c_prompt_io.raw.md @@ -0,0 +1,45 @@ +--- +model: openai/gpt-5.6-sol +service: opencode +timestamp: 2026-08-17T23:18:25Z +git_ref: 359fe75c +diff_cmd: git diff HEAD~1..HEAD +--- + +Applied the seven accepted manual-review fixes for PR #475 while +preserving the Windows transport capability behavior. + +> `git diff HEAD~1..HEAD -- tractor/ipc/_types.py` + +The generated changes restore the project's single-quote docstring and +string conventions, remove the unnecessary helper divider, simplify the +transport-registry comments, and restore `match/case` socket-family +dispatch. The UDS case retains a `HAS_UDS` guard that short-circuits +before `socket.AF_UNIX` is evaluated on unsupported hosts. Nearby error +messages are wrapped without changing their content. + +> `git diff HEAD~1..HEAD -- tractor/ipc/_uds.py` + +The generated change reformats the `HAS_UDS` conjunction according to +the project's multiline boolean-expression convention and simplifies +the adjacent capability comment. + +Verification: + +`/home/goodboy/repos/tractor/py313/bin/pytest -q tests/test_lazy_imports.py tests/discovery tests/ipc/test_server.py` + +Result: `66 passed, 2 xpassed in 60.62s`. + +`ruff check --no-cache --output-format=json tractor/ipc/_types.py tractor/ipc/_uds.py` + +Result: no findings. + +`git diff --check` + +Result: no whitespace errors. + +An explicit missing-`AF_UNIX` probe set `HAS_UDS = False`, removed the +socket constant, and exercised an unsupported socket family. It raised +the expected `NotImplementedError` instead of `AttributeError`. + +No review replies, commits, or pushes were published. diff --git a/tractor/ipc/_types.py b/tractor/ipc/_types.py index 50403d7a..244da48b 100644 --- a/tractor/ipc/_types.py +++ b/tractor/ipc/_types.py @@ -36,16 +36,14 @@ from tractor.ipc._uds import ( HAS_UDS, ) -# the UDS backend is importable everywhere but only *usable* where -# `trio` reports `has_unix` (i.e. POSIX). On Windows / no-`AF_UNIX` -# hosts `HAS_UDS` is `False` and the runtime registers TCP only. +# the UDS backend is importable everywhere but only *usable* when +# `HAS_UDS` is `True`; otherwise the runtime registers TCP only. Address = TCPAddress|UDSAddress # the available msg-transport backends on this host: TCP always, -# UDS only where usable (`HAS_UDS`). The lookup maps below are all -# DERIVED from this single list via each backend's ClassVars -# (`codec_key`, `address_type`) — register a backend here and every -# map picks it up; no per-map `if HAS_UDS` to keep in sync. +# UDS only where usable (`HAS_UDS`). The lookup maps below derive +# from this single list via each backend's `codec_key` and +# `address_type`: register a backend here and every map picks it up. _msg_transports: list[Type[MsgTransport]] = [ MsgpackTCPStream, ] @@ -65,55 +63,63 @@ _addr_to_transport: dict[Type[Address], Type[MsgTransport]] = { } -# ------------------------------------------------------------ -# Helpers -# ------------------------------------------------------------ def transport_from_addr( addr: Address, - codec_key: str = "msgpack", + codec_key: str = 'msgpack', ) -> Type[MsgTransport]: - """ + ''' Given a destination address and a desired codec, find the corresponding `MsgTransport` type. - """ + + ''' try: - return _addr_to_transport[type(addr)] # type: ignore[call-arg] + addr_type = type(addr) + return _addr_to_transport[addr_type] + except KeyError: raise NotImplementedError( - f"No known transport for address {repr(addr)}" + f'No known transport for address ' + f'{addr!r}' ) def transport_from_stream( stream: trio.abc.Stream, - codec_key: str = "msgpack", + codec_key: str = 'msgpack', ) -> Type[MsgTransport]: - """ + ''' Given an arbitrary `trio.abc.Stream` and a desired codec, find the corresponding `MsgTransport` type. - """ - transport = None + + ''' + transport: str|None = None if isinstance(stream, trio.SocketStream): sock: socket.socket = stream.socket - fam = sock.family + match sock.family: + case socket.AF_INET | socket.AF_INET6: + transport = 'tcp' - if fam in (socket.AF_INET, getattr(socket, "AF_INET6", None)): - transport = "tcp" + # `HAS_UDS` short-circuits before `socket.AF_UNIX` on + # hosts where that constant is absent. + case fam if ( + HAS_UDS + and + fam == socket.AF_UNIX + ): + transport = 'uds' - # only consider `AF_UNIX` when the UDS backend is active; - # `HAS_UDS` short-circuits before `socket.AF_UNIX` so this - # stays safe on hosts where that constant is absent. - if transport is None and HAS_UDS and fam == socket.AF_UNIX: # type: ignore[attr-defined] - transport = "uds" - - if transport is None: - raise NotImplementedError(f"Unsupported socket family: {fam}") + case fam: + raise NotImplementedError( + f'Unsupported socket family: {fam}' + ) if not transport: raise NotImplementedError( - f"Could not figure out transport type for stream type {type(stream)}" + f'Could not figure out transport type for stream type ' + f'{type(stream)}' ) key = (codec_key, transport) + return _key_to_transport[key] diff --git a/tractor/ipc/_uds.py b/tractor/ipc/_uds.py index 262cc2e1..49a9322d 100644 --- a/tractor/ipc/_uds.py +++ b/tractor/ipc/_uds.py @@ -114,12 +114,13 @@ _SUN_PATH_LIMIT: int = ( ) -# single source of truth for "is the UDS backend usable on this -# host?" Windows can expose `AF_UNIX`, but this backend remains +# single source of truth for whether the UDS backend is usable on this +# host. Windows can expose `AF_UNIX`, but this backend remains # POSIX-only until its credential and lifecycle paths are supported. HAS_UDS: bool = ( sys.platform != 'win32' - and has_unix + and + has_unix )