Condense `.raw.md` prompt-IO logs, add `diff_cmd` refs
Replace verbose inline code dumps in `.raw.md` entries with terse summaries and `git diff` cmd references. Add `diff_cmd` metadata to each entry's YAML frontmatter so readers can reproduce the actual output diff. Also, - rename `multiaddr_declare_eps.md_` -> `.md` (drop trailing `_` suffix) (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codesubint_spawner_backend
parent
ed65301d32
commit
3152f423d8
|
|
@ -3,6 +3,7 @@ model: claude-opus-4-6
|
||||||
service: claude
|
service: claude
|
||||||
timestamp: 2026-04-06T22:26:48Z
|
timestamp: 2026-04-06T22:26:48Z
|
||||||
git_ref: f086222
|
git_ref: f086222
|
||||||
|
diff_cmd: git diff f086222~1..f086222
|
||||||
---
|
---
|
||||||
|
|
||||||
Here's the problem. The per-key locking doesn't fix this race because the **lock lifetime is decoupled from `run_ctx`'s lifetime**. Trace through what happens:
|
Here's the problem. The per-key locking doesn't fix this race because the **lock lifetime is decoupled from `run_ctx`'s lifetime**. Trace through what happens:
|
||||||
|
|
|
||||||
|
|
@ -3,200 +3,25 @@ model: claude-opus-4-6
|
||||||
service: claude
|
service: claude
|
||||||
timestamp: 2026-04-13T20:50:48Z
|
timestamp: 2026-04-13T20:50:48Z
|
||||||
git_ref: 269d939c
|
git_ref: 269d939c
|
||||||
|
diff_cmd: git diff 269d939c~1..269d939c
|
||||||
---
|
---
|
||||||
|
|
||||||
## Implementation output
|
## Implementation output
|
||||||
|
|
||||||
### `tractor/discovery/_multiaddr.py` — appended after line 133
|
### `tractor/discovery/_multiaddr.py`
|
||||||
|
|
||||||
```python
|
> `git diff 269d939c~1..269d939c -- tractor/discovery/_multiaddr.py`
|
||||||
# type aliases for service-endpoint config tables
|
|
||||||
#
|
|
||||||
# input table: actor/service name -> list of maddr strings
|
|
||||||
# or raw unwrapped-address tuples (as accepted by
|
|
||||||
# `wrap_address()`).
|
|
||||||
EndpointsTable = dict[
|
|
||||||
str, # actor/service name
|
|
||||||
list[str|tuple], # maddr strs or UnwrappedAddress
|
|
||||||
]
|
|
||||||
|
|
||||||
# output table: actor/service name -> list of wrapped
|
Type aliases `EndpointsTable` and `ParsedEndpoints`
|
||||||
# `Address` instances ready for transport binding.
|
plus `parse_endpoints()` helper that wraps each
|
||||||
ParsedEndpoints = dict[
|
entry via `wrap_address()`.
|
||||||
str, # actor/service name
|
|
||||||
list['Address'],
|
|
||||||
]
|
|
||||||
|
|
||||||
|
### `tests/discovery/test_multiaddr.py`
|
||||||
|
|
||||||
def parse_endpoints(
|
> `git diff 269d939c~1..269d939c -- tests/discovery/test_multiaddr.py`
|
||||||
service_table: EndpointsTable,
|
|
||||||
) -> ParsedEndpoints:
|
|
||||||
'''
|
|
||||||
Parse a service-endpoint config table into wrapped
|
|
||||||
`Address` instances suitable for transport binding.
|
|
||||||
|
|
||||||
Each key is an actor/service name and each value is
|
Add import of `parse_endpoints` to existing import
|
||||||
a list of addresses in any format accepted by
|
block, then 7 new test functions.
|
||||||
`wrap_address()`:
|
|
||||||
|
|
||||||
- multiaddr strings: ``'/ip4/127.0.0.1/tcp/1616'``
|
|
||||||
- UDS multiaddr strings using the **multiaddr spec
|
|
||||||
name** ``/unix/...`` (NOT the tractor-internal
|
|
||||||
``/uds/`` proto_key)
|
|
||||||
- raw unwrapped tuples: ``('127.0.0.1', 1616)``
|
|
||||||
- pre-wrapped `Address` objects (passed through)
|
|
||||||
|
|
||||||
Returns a new `dict` with the same keys, where each
|
|
||||||
value list contains the corresponding `Address`
|
|
||||||
instances.
|
|
||||||
|
|
||||||
Raises `ValueError` for unsupported multiaddr
|
|
||||||
protocols (e.g. ``/udp/``).
|
|
||||||
|
|
||||||
'''
|
|
||||||
from tractor.discovery._addr import wrap_address
|
|
||||||
|
|
||||||
parsed: ParsedEndpoints = {}
|
|
||||||
for (
|
|
||||||
actor_name,
|
|
||||||
addr_entries,
|
|
||||||
) in service_table.items():
|
|
||||||
parsed[actor_name] = [
|
|
||||||
wrap_address(entry)
|
|
||||||
for entry in addr_entries
|
|
||||||
]
|
|
||||||
return parsed
|
|
||||||
```
|
|
||||||
|
|
||||||
### `tests/discovery/test_multiaddr.py` — appended after line 252
|
|
||||||
|
|
||||||
Added import of `parse_endpoints` to existing import block, then
|
|
||||||
7 new test functions:
|
|
||||||
|
|
||||||
```python
|
|
||||||
# ------ parse_endpoints() tests ------
|
|
||||||
|
|
||||||
def test_parse_endpoints_tcp_only():
|
|
||||||
'''
|
|
||||||
`parse_endpoints()` with a single TCP maddr per actor
|
|
||||||
produce the correct `TCPAddress` instances.
|
|
||||||
|
|
||||||
'''
|
|
||||||
table = {
|
|
||||||
'registry': ['/ip4/127.0.0.1/tcp/1616'],
|
|
||||||
'data_feed': ['/ip4/0.0.0.0/tcp/5555'],
|
|
||||||
}
|
|
||||||
result = parse_endpoints(table)
|
|
||||||
|
|
||||||
assert set(result.keys()) == {'registry', 'data_feed'}
|
|
||||||
|
|
||||||
reg_addr = result['registry'][0]
|
|
||||||
assert isinstance(reg_addr, TCPAddress)
|
|
||||||
assert reg_addr.unwrap() == ('127.0.0.1', 1616)
|
|
||||||
|
|
||||||
feed_addr = result['data_feed'][0]
|
|
||||||
assert isinstance(feed_addr, TCPAddress)
|
|
||||||
assert feed_addr.unwrap() == ('0.0.0.0', 5555)
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_endpoints_mixed_tpts():
|
|
||||||
'''
|
|
||||||
`parse_endpoints()` with both TCP and UDS maddrs for
|
|
||||||
the same actor produce the correct mixed `Address` list.
|
|
||||||
|
|
||||||
'''
|
|
||||||
table = {
|
|
||||||
'broker': [
|
|
||||||
'/ip4/127.0.0.1/tcp/4040',
|
|
||||||
'/unix/tmp/tractor/broker.sock',
|
|
||||||
],
|
|
||||||
}
|
|
||||||
result = parse_endpoints(table)
|
|
||||||
addrs = result['broker']
|
|
||||||
|
|
||||||
assert len(addrs) == 2
|
|
||||||
assert isinstance(addrs[0], TCPAddress)
|
|
||||||
assert addrs[0].unwrap() == ('127.0.0.1', 4040)
|
|
||||||
|
|
||||||
assert isinstance(addrs[1], UDSAddress)
|
|
||||||
filedir, filename = addrs[1].unwrap()
|
|
||||||
assert filename == 'broker.sock'
|
|
||||||
assert str(filedir) == '/tmp/tractor'
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_endpoints_unwrapped_tuples():
|
|
||||||
'''
|
|
||||||
`parse_endpoints()` accept raw `(host, port)` tuples
|
|
||||||
and wrap them as `TCPAddress`.
|
|
||||||
|
|
||||||
'''
|
|
||||||
table = {
|
|
||||||
'ems': [('127.0.0.1', 6666)],
|
|
||||||
}
|
|
||||||
result = parse_endpoints(table)
|
|
||||||
|
|
||||||
addr = result['ems'][0]
|
|
||||||
assert isinstance(addr, TCPAddress)
|
|
||||||
assert addr.unwrap() == ('127.0.0.1', 6666)
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_endpoints_mixed_str_and_tuple():
|
|
||||||
'''
|
|
||||||
`parse_endpoints()` accept a mix of maddr strings and
|
|
||||||
raw tuples in the same actor entry list.
|
|
||||||
|
|
||||||
'''
|
|
||||||
table = {
|
|
||||||
'quoter': [
|
|
||||||
'/ip4/127.0.0.1/tcp/7777',
|
|
||||||
('127.0.0.1', 8888),
|
|
||||||
],
|
|
||||||
}
|
|
||||||
result = parse_endpoints(table)
|
|
||||||
addrs = result['quoter']
|
|
||||||
|
|
||||||
assert len(addrs) == 2
|
|
||||||
assert isinstance(addrs[0], TCPAddress)
|
|
||||||
assert addrs[0].unwrap() == ('127.0.0.1', 7777)
|
|
||||||
|
|
||||||
assert isinstance(addrs[1], TCPAddress)
|
|
||||||
assert addrs[1].unwrap() == ('127.0.0.1', 8888)
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_endpoints_unsupported_proto():
|
|
||||||
'''
|
|
||||||
`parse_endpoints()` raise `ValueError` when a maddr
|
|
||||||
string uses an unsupported protocol like `/udp/`.
|
|
||||||
|
|
||||||
'''
|
|
||||||
table = {
|
|
||||||
'bad_actor': ['/ip4/127.0.0.1/udp/9999'],
|
|
||||||
}
|
|
||||||
with pytest.raises(
|
|
||||||
ValueError,
|
|
||||||
match='Unsupported multiaddr protocol combo',
|
|
||||||
):
|
|
||||||
parse_endpoints(table)
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_endpoints_empty_table():
|
|
||||||
'''
|
|
||||||
`parse_endpoints()` on an empty table return an empty
|
|
||||||
dict.
|
|
||||||
|
|
||||||
'''
|
|
||||||
assert parse_endpoints({}) == {}
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_endpoints_empty_actor_list():
|
|
||||||
'''
|
|
||||||
`parse_endpoints()` with an actor mapped to an empty
|
|
||||||
list preserve the key with an empty list value.
|
|
||||||
|
|
||||||
'''
|
|
||||||
result = parse_endpoints({'x': []})
|
|
||||||
assert result == {'x': []}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Test run output
|
### Test run output
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,15 @@ model: claude-opus-4-6
|
||||||
service: claude
|
service: claude
|
||||||
timestamp: 2026-04-14T16:33:00Z
|
timestamp: 2026-04-14T16:33:00Z
|
||||||
git_ref: befedc49
|
git_ref: befedc49
|
||||||
|
diff_cmd: git diff befedc49~1..befedc49
|
||||||
---
|
---
|
||||||
|
|
||||||
### Add a `prefer_addr()` helper
|
### `tractor/discovery/_api.py`
|
||||||
|
|
||||||
Added transport preference selection to
|
> `git diff befedc49~1..befedc49 -- tractor/discovery/_api.py`
|
||||||
`tractor/discovery/_api.py` with two new functions:
|
|
||||||
|
Add `_is_local_addr()` and `prefer_addr()` transport
|
||||||
|
preference helpers.
|
||||||
|
|
||||||
#### `_is_local_addr(addr: Address) -> bool`
|
#### `_is_local_addr(addr: Address) -> bool`
|
||||||
|
|
||||||
|
|
@ -38,21 +41,18 @@ Within each tier, the last-registered (latest) entry
|
||||||
is preferred. Falls back to `addrs[-1]` if no
|
is preferred. Falls back to `addrs[-1]` if no
|
||||||
heuristic matches.
|
heuristic matches.
|
||||||
|
|
||||||
|
### `tractor/discovery/_registry.py`
|
||||||
|
|
||||||
|
> `git diff befedc49~1..befedc49 -- tractor/discovery/_registry.py`
|
||||||
|
|
||||||
|
`Registrar.find_actor()` return type broadened from
|
||||||
|
single addr to `list[UnwrappedAddress]|None` — full
|
||||||
|
addr list lets callers apply transport preference.
|
||||||
|
|
||||||
#### Integration
|
#### Integration
|
||||||
|
|
||||||
- `Registrar.find_actor()` in `_registry.py`: changed
|
`query_actor()` and `wait_for_actor()` now call
|
||||||
return type from `UnwrappedAddress|None` to
|
`prefer_addr(addrs)` instead of `addrs[-1]`.
|
||||||
`list[UnwrappedAddress]|None` — returns the full
|
|
||||||
addr list so callers can apply transport preference.
|
|
||||||
|
|
||||||
- `query_actor()` in `_api.py`: now calls
|
|
||||||
`prefer_addr(addrs)` on the list returned by
|
|
||||||
`Registrar.find_actor()` instead of receiving a
|
|
||||||
single pre-selected addr.
|
|
||||||
|
|
||||||
- `wait_for_actor()` in `_api.py`: replaced
|
|
||||||
`addrs[-1]` with `prefer_addr(addrs)` for
|
|
||||||
consistent transport selection.
|
|
||||||
|
|
||||||
### Verification
|
### Verification
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue