From 3152f423d8c65964825d874b505820ced00b0b0f Mon Sep 17 00:00:00 2001 From: goodboy Date: Thu, 16 Apr 2026 17:44:14 -0400 Subject: [PATCH] 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-code --- .../20260406T222648Z_f086222_prompt_io.raw.md | 1 + ...20260413T205048Z_269d939c_prompt_io.raw.md | 195 +----------------- ...20260414T163300Z_befedc49_prompt_io.raw.md | 32 +-- ...clare_eps.md_ => multiaddr_declare_eps.md} | 0 4 files changed, 27 insertions(+), 201 deletions(-) rename ai/prompt-io/prompts/{multiaddr_declare_eps.md_ => multiaddr_declare_eps.md} (100%) diff --git a/ai/prompt-io/claude/20260406T222648Z_f086222_prompt_io.raw.md b/ai/prompt-io/claude/20260406T222648Z_f086222_prompt_io.raw.md index 95edeedf..9a973ee8 100644 --- a/ai/prompt-io/claude/20260406T222648Z_f086222_prompt_io.raw.md +++ b/ai/prompt-io/claude/20260406T222648Z_f086222_prompt_io.raw.md @@ -3,6 +3,7 @@ model: claude-opus-4-6 service: claude timestamp: 2026-04-06T22:26:48Z 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: diff --git a/ai/prompt-io/claude/20260413T205048Z_269d939c_prompt_io.raw.md b/ai/prompt-io/claude/20260413T205048Z_269d939c_prompt_io.raw.md index 71aff348..19cd7837 100644 --- a/ai/prompt-io/claude/20260413T205048Z_269d939c_prompt_io.raw.md +++ b/ai/prompt-io/claude/20260413T205048Z_269d939c_prompt_io.raw.md @@ -3,200 +3,25 @@ model: claude-opus-4-6 service: claude timestamp: 2026-04-13T20:50:48Z git_ref: 269d939c +diff_cmd: git diff 269d939c~1..269d939c --- ## Implementation output -### `tractor/discovery/_multiaddr.py` — appended after line 133 +### `tractor/discovery/_multiaddr.py` -```python -# 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 -] +> `git diff 269d939c~1..269d939c -- tractor/discovery/_multiaddr.py` -# output table: actor/service name -> list of wrapped -# `Address` instances ready for transport binding. -ParsedEndpoints = dict[ - str, # actor/service name - list['Address'], -] +Type aliases `EndpointsTable` and `ParsedEndpoints` +plus `parse_endpoints()` helper that wraps each +entry via `wrap_address()`. +### `tests/discovery/test_multiaddr.py` -def parse_endpoints( - service_table: EndpointsTable, -) -> ParsedEndpoints: - ''' - Parse a service-endpoint config table into wrapped - `Address` instances suitable for transport binding. +> `git diff 269d939c~1..269d939c -- tests/discovery/test_multiaddr.py` - Each key is an actor/service name and each value is - a list of addresses in any format accepted by - `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': []} -``` +Add import of `parse_endpoints` to existing import +block, then 7 new test functions. ### Test run output diff --git a/ai/prompt-io/claude/20260414T163300Z_befedc49_prompt_io.raw.md b/ai/prompt-io/claude/20260414T163300Z_befedc49_prompt_io.raw.md index a879ab28..b732e250 100644 --- a/ai/prompt-io/claude/20260414T163300Z_befedc49_prompt_io.raw.md +++ b/ai/prompt-io/claude/20260414T163300Z_befedc49_prompt_io.raw.md @@ -3,12 +3,15 @@ model: claude-opus-4-6 service: claude timestamp: 2026-04-14T16:33:00Z git_ref: befedc49 +diff_cmd: git diff befedc49~1..befedc49 --- -### Add a `prefer_addr()` helper +### `tractor/discovery/_api.py` -Added transport preference selection to -`tractor/discovery/_api.py` with two new functions: +> `git diff befedc49~1..befedc49 -- tractor/discovery/_api.py` + +Add `_is_local_addr()` and `prefer_addr()` transport +preference helpers. #### `_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 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 -- `Registrar.find_actor()` in `_registry.py`: changed - return type from `UnwrappedAddress|None` to - `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. +`query_actor()` and `wait_for_actor()` now call +`prefer_addr(addrs)` instead of `addrs[-1]`. ### Verification diff --git a/ai/prompt-io/prompts/multiaddr_declare_eps.md_ b/ai/prompt-io/prompts/multiaddr_declare_eps.md similarity index 100% rename from ai/prompt-io/prompts/multiaddr_declare_eps.md_ rename to ai/prompt-io/prompts/multiaddr_declare_eps.md