2026-04-14 16:57:13 +00:00
|
|
|
---
|
|
|
|
|
model: claude-opus-4-6
|
|
|
|
|
service: claude
|
|
|
|
|
timestamp: 2026-04-14T16:33:00Z
|
|
|
|
|
git_ref: befedc49
|
2026-04-16 21:44:14 +00:00
|
|
|
diff_cmd: git diff befedc49~1..befedc49
|
2026-04-14 16:57:13 +00:00
|
|
|
---
|
|
|
|
|
|
2026-04-16 21:44:14 +00:00
|
|
|
### `tractor/discovery/_api.py`
|
2026-04-14 16:57:13 +00:00
|
|
|
|
2026-04-16 21:44:14 +00:00
|
|
|
> `git diff befedc49~1..befedc49 -- tractor/discovery/_api.py`
|
|
|
|
|
|
|
|
|
|
Add `_is_local_addr()` and `prefer_addr()` transport
|
|
|
|
|
preference helpers.
|
2026-04-14 16:57:13 +00:00
|
|
|
|
|
|
|
|
#### `_is_local_addr(addr: Address) -> bool`
|
|
|
|
|
|
|
|
|
|
Determines whether an `Address` is reachable on the
|
|
|
|
|
local host:
|
|
|
|
|
|
|
|
|
|
- `UDSAddress`: always returns `True`
|
|
|
|
|
(filesystem-bound, inherently local)
|
|
|
|
|
- `TCPAddress`: checks if `._host` is a loopback IP
|
|
|
|
|
via `ipaddress.ip_address().is_loopback`, then
|
|
|
|
|
falls back to comparing against the machine's own
|
|
|
|
|
interface IPs via
|
|
|
|
|
`socket.getaddrinfo(socket.gethostname(), None)`
|
|
|
|
|
|
|
|
|
|
#### `prefer_addr(addrs: list[UnwrappedAddress]) -> UnwrappedAddress`
|
|
|
|
|
|
|
|
|
|
Selects the "best" transport address from a
|
|
|
|
|
multihomed actor's address list. Wraps each
|
|
|
|
|
candidate via `wrap_address()` to get typed
|
|
|
|
|
`Address` objects, then classifies into three tiers:
|
|
|
|
|
|
|
|
|
|
1. **UDS** (same-host guaranteed, lowest overhead)
|
|
|
|
|
2. **TCP loopback / same-host IP** (local network)
|
|
|
|
|
3. **TCP remote** (only option for distributed)
|
|
|
|
|
|
|
|
|
|
Within each tier, the last-registered (latest) entry
|
|
|
|
|
is preferred. Falls back to `addrs[-1]` if no
|
|
|
|
|
heuristic matches.
|
|
|
|
|
|
2026-04-16 21:44:14 +00:00
|
|
|
### `tractor/discovery/_registry.py`
|
2026-04-14 16:57:13 +00:00
|
|
|
|
2026-04-16 21:44:14 +00:00
|
|
|
> `git diff befedc49~1..befedc49 -- tractor/discovery/_registry.py`
|
2026-04-14 16:57:13 +00:00
|
|
|
|
2026-04-16 21:44:14 +00:00
|
|
|
`Registrar.find_actor()` return type broadened from
|
|
|
|
|
single addr to `list[UnwrappedAddress]|None` — full
|
|
|
|
|
addr list lets callers apply transport preference.
|
|
|
|
|
|
|
|
|
|
#### Integration
|
2026-04-14 16:57:13 +00:00
|
|
|
|
2026-04-16 21:44:14 +00:00
|
|
|
`query_actor()` and `wait_for_actor()` now call
|
|
|
|
|
`prefer_addr(addrs)` instead of `addrs[-1]`.
|
2026-04-14 16:57:13 +00:00
|
|
|
|
|
|
|
|
### Verification
|
|
|
|
|
|
|
|
|
|
All discovery tests pass (13/13 non-daemon).
|
|
|
|
|
`test_local.py` and `test_multi_program.py` also
|
|
|
|
|
pass (daemon fixture teardown failures are
|
|
|
|
|
pre-existing and unrelated).
|