1.1 KiB
Raw output - compose WireGuard bindspace lifecycles
After committing the owned WireGuard interface lifecycle, the human requested the next incremental change.
git diff HEAD~1..HEAD -- tractor/discovery/_tunnel.py tractor/discovery/__init__.py tests/discovery/test_wg_iface_lifecycle.py ai/tpt-backends/03_wg_tunnel_bindspace.md
Added open_wg_bindspace() to compose one declared bindspace with an ordered sequence of WireGuard interface layers. The context enters the bindspace first, enters interfaces outermost-first through AsyncExitStack, yields the live BindspaceHandle, and removes interfaces inside-out before releasing or removing the namespace.
The caller’s layer sequence is snapshotted before the first checkpoint, so concurrent mutation cannot alter resource entry or unwind order. Fake lifecycle tests clear a mutable input list during bindspace entry, cancel from the yielded scope, and prove the original stack unwinds in dependency-safe order.
Ruff passed and focused bindspace/WireGuard coverage passed 39 tests.