tractor/examples
Gud Boi 4c8188652b Peel `wg` maddrs w/ `py-multiaddr`'s own tunnel API
`py-multiaddr` already ships the entire tunnel compose/peel
surface and this module was reimplementing it — a raw
`maddr.split('/')` plus index arithmetic, sitting directly under
a comment congratulating itself for not hand-rolling a parser.
Same NIH trap gh #429 existed to close, just one layer up. The
API was linked from gh #443's own 2nd bullet the whole time.

So every cut now goes through the real thing,

| need | API |
| --- | --- |
| isolate the bearer | `.decapsulate_code(P_WG)` |
| per-seg maddrs | `.split()` |
| rejoin a seg tail | `Multiaddr.join()` |
| read the key | `.value_for_protocol('wg')` |
| recompose | `.encapsulate()` |

`.decapsulate_code()` turns out to handle the infix `/wg/` seg
cleanly *because* it cuts on proto-code and never tries to match
an addr value — the key seg has no addr of its own, which was
the exact thing I'd assumed would need bespoke handling.

Deats,
- rename the role fields `inner`/`inner_proto` ->
  `overlay`/`overlay_proto`, matching `py-multiaddr`'s
  encapsulation model (earlier segs wrap later ones) and #443's
  owner table. `inner` collided head-on w/ call-stack `inner`,
  where it reads as higher-up + later-called, while here the
  encapsulated addr is bound *first* and sits deeper.
- drop `_segments()` and its degraded hand-split path entirely.
  W/o the codec there's now one actionable `RuntimeError`
  instead of a silent downgrade, superseding the swallow fix in
  7d6e7955.
- add `.as_multiaddr()` so callers can stay in `Multiaddr` land;
  `.maddr` is now just `str()` of it.
- accept `str|Multiaddr` on the way in.
- carry `bearer_ip`/`overlay_ip` so a v6 stack re-renders as v6
  — the old `.maddr` hardcoded `/ip4/` and would silently
  mangle it.
- both host scripts follow the rename to `.overlay`.

⚠️ `value_for_protocol('ip4')` on a *full* tunnelled maddr
silently returns the **first** match, i.e. the bearer's host, so
it's only ever called here on an already-peeled sub-maddr.

(this patch was generated in some part by `claude-code` using `claude-opus-5` (`anthropic`))
2026-08-29 22:02:56 -04:00
..
advanced_faults Include `TransportClosed` in tpt-layer err handling 2026-02-19 13:55:02 -05:00
debugging Polish the debugger examples 2026-08-29 19:01:34 -04:00
discovery Harden the dedicated registrar example 2026-08-29 20:05:28 -04:00
integration Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
multihost/wg_lan Peel `wg` maddrs w/ `py-multiaddr`'s own tunnel API 2026-08-29 22:02:56 -04:00
parallelism Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
trio Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
__init__.py Make example a subpkg for `python -m <mod>` testing 2022-07-27 11:40:02 -04:00
__main__.py Use trio.run() in windows tests 2021-05-07 11:21:40 -04:00
a_trynamic_first_scene.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
actor_spawning_and_causality.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
actor_spawning_and_causality_with_daemon.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
asynchronous_generators.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
full_fledged_streaming_service.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
infected_asyncio_echo_server.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
multiple_streams_one_portal.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
nested_actor_tree.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
quick_cluster.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
remote_error_propagation.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
rpc_bidir_streaming.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
service_daemon_discovery.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
service_discovery.py Show the discovered actor address 2026-08-29 20:24:25 -04:00
streaming_broadcast_fanout.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
typed_payloads.py Polish the non-debug docs examples 2026-08-29 18:58:43 -04:00
uds_transport_actor_tree.py Widen `accept_addr` in the UDS example 2026-08-29 21:46:38 -04:00