From 52e8fb43ee9c68080ef4ea74c1570f62416b37aa Mon Sep 17 00:00:00 2001 From: goodboy Date: Fri, 13 Mar 2026 15:50:06 -0400 Subject: [PATCH] Tighten UDS addr validation and sockname prefixes - add `is_valid` and `sockpath.resolve()` asserts in `get_rando_addr()` for the `'uds'` case plus an explicit `UDSAddress` type annotation. - rename no-runtime sockname prefixes from `''`/`'root'` to `'no_runtime_root'`/`'no_runtime_actor'` with a proper if/else branch in `UDSAddress.get_random()`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tractor/_testing/addr.py | 6 +++++- tractor/ipc/_uds.py | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tractor/_testing/addr.py b/tractor/_testing/addr.py index 1b066336..b1ccf005 100644 --- a/tractor/_testing/addr.py +++ b/tractor/_testing/addr.py @@ -61,7 +61,11 @@ def get_rando_addr( # NOTE, file-name uniqueness (no-collisions) will be based on # the runtime-directory and root (pytest-proc's) pid. case 'uds': - testrun_reg_addr = addr_type.get_random().unwrap() + from tractor.ipc._uds import UDSAddress + addr: UDSAddress = addr_type.get_random() + assert addr.is_valid + assert addr.sockpath.resolve() + testrun_reg_addr = addr.unwrap() # XXX, as sanity it should never the same as the default for the # host-singleton registry actor. diff --git a/tractor/ipc/_uds.py b/tractor/ipc/_uds.py index 4b393fb6..a7d450a6 100644 --- a/tractor/ipc/_uds.py +++ b/tractor/ipc/_uds.py @@ -197,9 +197,11 @@ class UDSAddress( # sockname: str = '.'.join(actor.uid) + f'@{pid}' # -[ ] CURRENTLY using `.` BREAKS TEST SUITE tho.. else: - prefix: str = '' if is_root_process(): - prefix: str = 'root' + prefix: str = 'no_runtime_root' + else: + prefix: str = 'no_runtime_actor' + sockname: str = f'{prefix}@{pid}' sockpath: Path = Path(f'{sockname}.sock')