Add WireGuard bindspaces and netns bootstrap - #511
Open
goodboy wants to merge 22 commits into
Open
Conversation
goodboy
force-pushed
the
wkt/addr_unpacking
branch
from
August 28, 2026 19:18
5d92595 to
7d0b84e
Compare
goodboy
force-pushed
the
wkt/wg_pyroute2_read
branch
2 times, most recently
from
August 30, 2026 02:00
1ee980f to
a834487
Compare
goodboy
force-pushed
the
wkt/addr_unpacking
branch
from
August 30, 2026 02:01
7d0b84e to
5b606ba
Compare
Add async `read_wg_pubkey()` and `read_wg_peers()` helpers which offload `WireGuard.info()` calls to a `trio` worker thread. Deats, - add the Linux-only `wg` extra and pin `pyroute2` - pass `flags=0` so a read never creates a named netns - normalize multipart replies, validate keys and de-dup peers - always close the netlink client, including error paths - test thread offload, netns forwarding and client cleanup Prompt-IO: ai/prompt-io/opencode/20260821T233204Z_5d92595f_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add a candidate Layer-C architecture where a private, eagerly spawned manager owns pyroute2 and tunnel provisioning for a simple WG-enabled actor tree. Deats, - overlap manager reconciliation with sibling process startup - contain `AsyncWireGuard` in an infected-asyncio child - limit requests and capabilities by bindspace security domain - define readiness, crash, restart and teardown semantics - retain pre-provisioned and multi-manager escape hatches (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Validate a declared tunnel key against one `pyroute2` snapshot containing the iface's own key and configured peers. Deats, - share worker offload across all WireGuard key readers - forward `WGTunnelSpec.iface` and `.netns` to the read - reject malformed declarations before netlink I/O - export the async helper and cover local, peer and absent keys - replace multihost's `wg show` subprocess probe Prompt-IO: ai/prompt-io/opencode/20260822T023226Z_59a8ecfd_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Make `TCPAddress` and `UDSAddress` explicitly satisfy `Address.namespace`, then retain each original listener declaration beside its peeled, resolved transport address. Deats, - remove `TunnelledAddress`'s attribute fallback - add required `Endpoint.declared_addr` metadata - report declaration namespaces in endpoint/server formatting - preserve concrete `Endpoint.addr` for transport reflection - cover plain and tunneled namespace visibility Prompt-IO: ai/prompt-io/opencode/20260822T032520Z_d35c802b_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Separate serializable `BindspaceSpec` and `BindspaceIdentity` values from a process-local `BindspaceHandle` carrying FD and ownership authority. Deats, - add global `ProcessLocal` wire guards for local handle structs - derive valid kinds and ownership from their `Literal` aliases - require a positive inode while keeping the mutable name optional - pin supplied FDs to identity inodes with `fstat()` - cover round trips, nested encoding and stale capabilities Caught-during: review remediation Found-via: `/run-tests` test_bindspace_handle_pins_local_capability Prompt-IO: ai/prompt-io/opencode/20260822T042026Z_29141f0b_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add `attach_netns()` to pin a current or named Linux netns in a borrowed `BindspaceHandle` without creating or entering it. Deats, - name the current-namespace default `CURRENT_NETNS` - derive stable identity from the opened FD with `fstat()` - open descriptors with `O_CLOEXEC` and close them on context exit - constrain named lookup beneath the standard iproute2 run directory - report field-specific validation and missing-resource errors Prompt-IO: ai/prompt-io/opencode/20260825T045557Z_fdccfd7e_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add `open_netns()` to create a named Linux netns through pyroute2, pin its identity and yield an owned `BindspaceHandle`. Deats, - run synchronous creation and removal in Trio worker threads - shield both privileged side effects from caller cancellation - reuse `attach_netns()` to pin identity and manage the FD - close the FD before removing the owned namespace - fake privileged operations while testing ordering and cancellation Prompt-IO: ai/prompt-io/opencode/20260825T190529Z_e1007547_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add serialized `BindspaceSpec.lifecycle` policy and dispatch it through `open_bindspace()` without inferring ownership from transport role. Deats, - distinguish borrowed `attach` from owned `open` policy - validate handle ownership against the declared lifecycle - share policy-neutral FD pinning between both netns contexts - reject unsupported lifecycle values before side effects - exercise both dispatcher branches and owned cancellation cleanup Prompt-IO: ai/prompt-io/opencode/20260825T191845Z_5b2a064a_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add process-local `WGInterfaceConfig` for key material, interface addresses and peer-routing policy required by future provisioning. Deats, - redact private and preshared keys from representation - block config from default actor-IPC encoding via `ProcessLocal` - validate keys, interface CIDRs, allowed CIDRs and bounded integers - keep public endpoint and peer identity in `WGTunnelSpec` - move allowed-IP policy out of the serializable tunnel declaration Prompt-IO: ai/prompt-io/opencode/20260825T234631Z_b973e78c_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add process-local `WGPeerConfig` entries and make `WGInterfaceConfig` own a unique peer tuple for listener and dial provisioning. Deats, - carry peer public keys, allowed CIDRs and optional endpoints - redact per-peer preshared keys while blocking wire encoding - validate peer routes, endpoint ports and keepalive intervals - reject duplicate peers before future kernel mutation - support multi-peer listeners without overloading tunnel identity Prompt-IO: ai/prompt-io/opencode/20260826T001442Z_dcdf4d82_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add `open_wg_iface()` to create, configure and remove one WireGuard interface inside a pinned bindspace through pyroute2. Deats, - validate listen/dial bearer policy before kernel side effects - configure local addresses, private key, listen port and peers - fill an omitted dial endpoint from the selected tunnel bearer - clean partial synchronous failures before returning to Trio - shield owned interface creation and teardown from cancellation Prompt-IO: ai/prompt-io/opencode/20260826T003430Z_6dd39da0_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add `open_wg_bindspace()` to enter one declared bindspace and an ordered WireGuard interface stack as one async lifetime. Deats, - snapshot caller layer ordering before the first checkpoint - enter interfaces outermost-first through `AsyncExitStack` - unwind interfaces before releasing the namespace capability - yield the live `BindspaceHandle` for endpoint allocation - test mutable input and cancellation ordering with lifecycle fakes Prompt-IO: ai/prompt-io/opencode/20260826T022434Z_2245f094_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Replace the unshipped `BindspaceIdentity` and `BindspaceHandle` names with `BindspaceRef` and `Bindspace` across existing lifecycle APIs. Deats, - define refs as wire-safe, host-local and non-owning records - reserve `Bindspace` for the live FD-backed capability - rename the capability's realized-resource field to `.ref` - update lifecycle tests and active design contracts - omit compatibility aliases for the unshipped model names Prompt-IO: ai/prompt-io/opencode/20260827T211115Z_d130431c_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add `TunnelledAddress.with_bindspace_ref()` to annotate frozen tunnel declarations with stable, serializable namespace metadata. Deats, - omit absent refs from the existing msgspec shape - reject declared and realized namespace-name mismatches - report the declared key before realization and inode afterward - keep transport peeling free of live bindspace capability state - expose realized refs through real listener diagnostics Prompt-IO: ai/prompt-io/opencode/20260826T030534Z_d130431c_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Record native tagged encoding for complete `TunnelledAddress` graphs as a deferred design follow-up. Deats, - cover concrete overlay-address and tunnel-spec unions - preserve optional `BindspaceRef` metadata through decoding - replace untyped payload inspection with typed roundtrip tests (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Add private `enter_netns()` bootstrap validation before actor runtime integration. Deats, - verify the inherited FD against its expected namespace inode - constrain `setns()` to Linux network namespaces - verify `/proc/self/ns/net` after the entry syscall - leave inherited FD ownership to the future spawn caller - exercise guards with real FDs and unprivileged syscall fakes Prompt-IO: ai/prompt-io/opencode/20260827T232500Z_d067505a_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Consume an optional child-owned `(fd, inode)` capability before multiprocessing or Trio child bootstrap begins runtime setup. Deats, - enter the netns before Trio patching and actor construction - close the inherited FD before actor runtime startup - preserve entry errors when descriptor cleanup also fails - reject malformed FD values without closing unrelated descriptors - cover multiprocessing and Trio ordering with real stand-in FDs Prompt-IO: ai/prompt-io/opencode/20260828T012205Z_9ae7cd86_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Race the initial peer handshake against process exit during Trio child bootstrap so a dead child cannot park its spawning task. Restore and harden the design originally implemented in `3b0724eb`. Deats, - register peer events before provisional nursery publication - raise `ActorFailure` with child status when process death wins - prioritize observed death over a simultaneous handshake - preserve waiter exceptions without `ExceptionGroup` wrapping - log expected losing-waiter cancellation at debug level - remove exact failed-startup peer events during backend cleanup - cover controlled schedules and full Trio backend cleanup Based-on: 3b0724e Prompt-IO: ai/prompt-io/opencode/20260828T045119Z_fb6d81d3_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Thread an optional live `Bindspace` through actor spawn APIs and give each Trio exec child an inherited namespace descriptor before runtime bootstrap. Deats, - duplicate the namespace FD without changing parent ownership - preserve caller `pass_fds` and process options - send the `(fd, inode)` pair through the `_child` CLI - close the parent duplicate on success, failure and cancellation - reject MP backends until descriptor reduction is implemented - avoid cleanup before child publication - exercise real E2E namespace relay through handshake and RPC - verify parent FD-table cleanup after successful child spawn Prompt-IO: ai/prompt-io/opencode/20260828T172943Z_2ca8c570_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
goodboy
force-pushed
the
wkt/wg_pyroute2_read
branch
from
August 30, 2026 02:03
a834487 to
b1f6ade
Compare
goodboy
force-pushed
the
wkt/addr_unpacking
branch
from
August 30, 2026 02:03
5b606ba to
51f4e31
Compare
Move bindspace, tunnel and WireGuard lifecycles out of actor discovery and expose them through one lazy public package. Deats, - keep `import tractor` free of multiaddr, pyroute2 and WG impls - move network-focused tests under `tests/net` - update IPC, spawn, docs and multihost callers to the new API - pin `CURRENT_NETNS` through the calling thread's procfs link Prompt-IO: ai/prompt-io/opencode/20260830T025201Z_b1f6ade8_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
Enter a realized netns before root registry, IPC and runtime startup, then restore the calling thread before owned bindspace teardown. Deats, - duplicate the namespace FD so caller ownership stays intact - preserve primary body errors across restore and close failures - reject persistent `mp_forkserver` roots with stale netns risk - cover cancellation, real netns entry, UDS RPC and public WG composition Prompt-IO: ai/prompt-io/opencode/20260830T025202Z_b1f6ade8_prompt_io.md (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core spawn/root bootstrap and introduces substantial new networking surface area, so it needs careful human validation beyond the small issues noted.
Pull request overview
This PR introduces a new lazy tractor.net public surface for network declarations (multiaddr, tunnels, bindspaces) and wires Linux network-namespace (“bindspace”) capabilities through root and child actor bootstrap, including a wg optional dependency for pyroute2-backed WireGuard inspection/provisioning workflows.
Changes:
- Add
tractor.netas the public (lazy) home for multiaddr/tunnel/bindspace/WireGuard APIs; remove legacy exports fromtractor.discovery. - Extend spawn/bootstrap to (a) race child handshake vs process death and (b) optionally pass a netns FD/inode tuple into Trio-spawned children; allow root actor to enter/restore a provided bindspace.
- Add
wgoptional dependency (pyroute2on Linux) plus expanded tests/docs/examples for the new networking boundary and behaviors.
File summaries
| File | Description |
|---|---|
| uv.lock | Adds locked pyroute2 package and wg extra metadata. |
| pyproject.toml | Defines optional extra wg with Linux-only pyroute2 constraint. |
| tractor/to_actor/_api.py | Threads optional bindspace through actor run API. |
| tractor/spawn/_trio.py | Trio spawn: netns FD dup/pass_fds + handshake/death race + cleanup. |
| tractor/spawn/_spawn.py | Adds handshake-vs-death helper; threads bindspace to backends. |
| tractor/spawn/_netns.py | Adds synchronous netns enter/restore primitives. |
| tractor/spawn/_mp.py | Rejects bindspace transport for multiprocessing backends. |
| tractor/spawn/_entry.py | Consumes inherited netns bootstrap tuple before mp child runtime. |
| tractor/runtime/_supervise.py | Threads bindspace into child actor spawn. |
| tractor/net/_bindspace.py | Introduces bindspace spec/ref/capability + netns attach/open lifecycles. |
| tractor/net/init.py | Adds lazy, symbol-mapped tractor.net public API facade. |
| tractor/msg/_local.py | Adds ProcessLocal msgspec marker to block default wire encoding. |
| tractor/msg/init.py | Re-exports ProcessLocal. |
| tractor/ipc/_uds.py | Adds .namespace and lazy-imports mk_maddr via tractor.net. |
| tractor/ipc/_tcp.py | Adds .namespace and lazy-imports mk_maddr via tractor.net. |
| tractor/ipc/_server.py | Retains declared addresses for namespace diagnostics; updates tunnel imports. |
| tractor/ipc/_chan.py | Moves tunnel peeling import to runtime; avoids eager network imports. |
| tractor/discovery/_tunnel.py | Removes old tunnel implementation module. |
| tractor/discovery/_multiaddr.py | Repoints tunnel helpers to tractor.net._tunnel. |
| tractor/discovery/_addr.py | Updates tunnel type refs; routes maddr parsing through tractor.net. |
| tractor/discovery/init.py | Removes prior network-related re-exports (now in tractor.net). |
| tractor/_root.py | Adds optional root bindspace entry/restore and forkserver guard. |
| tractor/_child.py | Adds netns bootstrap CLI parsing + early consume; introduces main(argv=...). |
| tractor/init.py | Adds lazy loading for tractor.net alongside to_asyncio. |
| tests/test_spawning.py | Adds deterministic tests for handshake/death race and Trio cleanup. |
| tests/test_lazy_imports.py | Expands cold-import and lazy-network API boundary regressions. |
| tests/net/init.py | Adds net test package marker. |
| tests/net/test_wg_inspection.py | Adds pyroute2 WireGuard read/verify tests with fakes. |
| tests/net/test_wg_iface_lifecycle.py | Adds WG iface/bindspace lifecycle and root composition tests. |
| tests/net/test_wg_config.py | Adds process-local WG config tests and redaction/encoding guards. |
| tests/net/test_tunnelled_addr.py | Updates tunnel namespace/ref tests to use tractor.net. |
| tests/net/test_multiaddr.py | Updates multiaddr tests to use tractor.net public APIs. |
| tests/net/test_bindspace.py | Adds bindspace declaration/ref/capability and netns lifecycle tests. |
| tests/msg/test_process_local.py | Adds tests proving ProcessLocal blocks msgspec encoding. |
| tests/ipc/test_server_tunnel_boundary.py | Verifies tunnel peeling and retained namespace diagnostics at server boundary. |
| tests/ipc/test_channel_tunnel_boundary.py | Updates tunnel boundary tests to use tractor.net. |
| tests/discovery/test_tpt_bind_addrs.py | Switches mk_maddr import to tractor.net. |
| tests/discovery/test_registrar.py | Switches mk_maddr import to tractor.net. |
| examples/multihost/wg_lan/wg_maddr.py | Removes subprocess-based wg probe example. |
| examples/multihost/wg_lan/README.md | Documents --extra wg install and new tractor.net boundary/composition. |
| examples/multihost/wg_lan/host_b_client.py | Uses async tractor.net.verify_wg_peer() for tunnel verification. |
| examples/multihost/wg_lan/host_a_srv.py | Uses async tractor.net.verify_wg_peer() for tunnel verification. |
| docs/guide/discovery.rst | Points multiaddr note at tractor.net. |
| docs/api/net.rst | Adds new API docs page for tractor.net declarations/lifecycles. |
| docs/api/ipc.rst | Updates cross-links to reference api/net. |
| docs/api/index.rst | Adds net to API index. |
| ai/tpt-backends/03_wg_tunnel_bindspace.md | Updates design doc to reflect new module boundaries and implemented contracts. |
| ai/tpt-backends/00_shared_backend_contract.md | Updates shared backend contract terminology (BindspaceRef/Bindspace). |
| ai/prompt-io/prompts/multiaddr_declare_eps.md | Updates prompt doc to reference tractor.net.parse_endpoints. |
| ai/prompt-io/opencode/20260830T025202Z_b1f6ade8_prompt_io.raw.md | Adds prompt-io artifact for root bindspace bootstrap work. |
| ai/prompt-io/opencode/20260830T025202Z_b1f6ade8_prompt_io.md | Adds summarized prompt-io artifact for root bindspace bootstrap work. |
| ai/prompt-io/opencode/20260830T025201Z_b1f6ade8_prompt_io.raw.md | Adds prompt-io artifact for tractor.net extraction work. |
| ai/prompt-io/opencode/20260830T025201Z_b1f6ade8_prompt_io.md | Adds summarized prompt-io artifact for tractor.net extraction work. |
| ai/prompt-io/opencode/20260828T172943Z_2ca8c570_prompt_io.raw.md | Adds prompt-io artifact for Trio bindspace FD transport work. |
| ai/prompt-io/opencode/20260828T172943Z_2ca8c570_prompt_io.md | Adds summarized prompt-io artifact for Trio bindspace FD transport work. |
| ai/prompt-io/opencode/20260828T045119Z_fb6d81d3_prompt_io.raw.md | Adds prompt-io artifact for pre-handshake child-death detection work. |
| ai/prompt-io/opencode/20260828T045119Z_fb6d81d3_prompt_io.md | Adds summarized prompt-io artifact for pre-handshake child-death detection work. |
| ai/prompt-io/opencode/20260828T012205Z_9ae7cd86_prompt_io.raw.md | Adds prompt-io artifact for child netns bootstrap entry work. |
| ai/prompt-io/opencode/20260828T012205Z_9ae7cd86_prompt_io.md | Adds summarized prompt-io artifact for child netns bootstrap entry work. |
| ai/prompt-io/opencode/20260827T232500Z_d067505a_prompt_io.raw.md | Adds prompt-io artifact for verified netns entry primitive work. |
| ai/prompt-io/opencode/20260827T232500Z_d067505a_prompt_io.md | Adds summarized prompt-io artifact for verified netns entry primitive work. |
| ai/prompt-io/opencode/20260827T211115Z_d130431c_prompt_io.raw.md | Adds prompt-io artifact for bindspace terminology rename work. |
| ai/prompt-io/opencode/20260827T211115Z_d130431c_prompt_io.md | Adds summarized prompt-io artifact for bindspace terminology rename work. |
| ai/prompt-io/opencode/20260826T030534Z_d130431c_prompt_io.raw.md | Adds prompt-io artifact for realized bindspace ref retention work. |
| ai/prompt-io/opencode/20260826T030534Z_d130431c_prompt_io.md | Adds summarized prompt-io artifact for realized bindspace ref retention work. |
| ai/prompt-io/opencode/20260826T022434Z_2245f094_prompt_io.raw.md | Adds prompt-io artifact for WG bindspace composition work. |
| ai/prompt-io/opencode/20260826T022434Z_2245f094_prompt_io.md | Adds summarized prompt-io artifact for WG bindspace composition work. |
| ai/prompt-io/opencode/20260826T003430Z_6dd39da0_prompt_io.raw.md | Adds prompt-io artifact for owned WG iface lifecycle work. |
| ai/prompt-io/opencode/20260826T003430Z_6dd39da0_prompt_io.md | Adds summarized prompt-io artifact for owned WG iface lifecycle work. |
| ai/prompt-io/opencode/20260826T001442Z_dcdf4d82_prompt_io.raw.md | Adds prompt-io artifact for explicit WG peer model work. |
| ai/prompt-io/opencode/20260826T001442Z_dcdf4d82_prompt_io.md | Adds summarized prompt-io artifact for explicit WG peer model work. |
| ai/prompt-io/opencode/20260825T234631Z_b973e78c_prompt_io.raw.md | Adds prompt-io artifact for process-local WG config split work. |
| ai/prompt-io/opencode/20260825T234631Z_b973e78c_prompt_io.md | Adds summarized prompt-io artifact for process-local WG config split work. |
| ai/prompt-io/opencode/20260825T191845Z_5b2a064a_prompt_io.raw.md | Adds prompt-io artifact for bindspace lifecycle dispatch work. |
| ai/prompt-io/opencode/20260825T191845Z_5b2a064a_prompt_io.md | Adds summarized prompt-io artifact for bindspace lifecycle dispatch work. |
| ai/prompt-io/opencode/20260825T190529Z_e1007547_prompt_io.raw.md | Adds prompt-io artifact for owned netns lifecycle work. |
| ai/prompt-io/opencode/20260825T190529Z_e1007547_prompt_io.md | Adds summarized prompt-io artifact for owned netns lifecycle work. |
| ai/prompt-io/opencode/20260825T045557Z_fdccfd7e_prompt_io.raw.md | Adds prompt-io artifact for borrow-only netns lifecycle work. |
| ai/prompt-io/opencode/20260825T045557Z_fdccfd7e_prompt_io.md | Adds summarized prompt-io artifact for borrow-only netns lifecycle work. |
| ai/prompt-io/opencode/20260822T042026Z_29141f0b_prompt_io.raw.md | Adds prompt-io artifact for bindspace capability model work. |
| ai/prompt-io/opencode/20260822T042026Z_29141f0b_prompt_io.md | Adds summarized prompt-io artifact for bindspace capability model work. |
| ai/prompt-io/opencode/20260822T032520Z_d35c802b_prompt_io.raw.md | Adds prompt-io artifact for endpoint namespace retention work. |
| ai/prompt-io/opencode/20260822T032520Z_d35c802b_prompt_io.md | Adds summarized prompt-io artifact for endpoint namespace retention work. |
| ai/prompt-io/opencode/20260822T023226Z_59a8ecfd_prompt_io.raw.md | Adds prompt-io artifact for WG peer verification helper work. |
| ai/prompt-io/opencode/20260822T023226Z_59a8ecfd_prompt_io.md | Adds summarized prompt-io artifact for WG peer verification helper work. |
| ai/prompt-io/opencode/20260821T233204Z_5d92595f_prompt_io.raw.md | Adds prompt-io artifact for pyroute2 WG read helpers work. |
| ai/prompt-io/opencode/20260821T233204Z_5d92595f_prompt_io.md | Adds summarized prompt-io artifact for pyroute2 WG read helpers work. |
Review details
Suppressed comments (1)
tractor/spawn/_spawn.py:447
- Type annotation uses the built-in
anyfunction instead oftyping.Any, which will confuse type checkers (and is likely unintended).
- Files reviewed: 88/89 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+81
to
85
| bindspace: Bindspace|None = None, | ||
| infect_asyncio: bool = False, | ||
| task_status: TaskStatus[Portal] = trio.TASK_STATUS_IGNORED, | ||
| proc_kwargs: dict[str, any] = {} | ||
|
|
Comment on lines
76
to
81
| *, | ||
| bindspace: Bindspace|None = None, | ||
| infect_asyncio: bool = False, | ||
| task_status: TaskStatus[Portal] = trio.TASK_STATUS_IGNORED, | ||
| proc_kwargs: dict[str, any] = {} | ||
|
|
Keep platform-independent spawn coverage active while avoiding Linux `/proc` and `os.setns()` assumptions on macOS and Windows. Deats, - define one reusable Linux netns test mark - apply it only to tests requiring real Linux namespace APIs - preserve cross-platform bootstrap and transport unit coverage (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
wg pyroute2 readWireGuard bindspaces and netns bootstrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
WireGuardbindspaces andnetnsbootstrapMotivation
Tunnel-bearing multiaddrs can describe a WireGuard path, but actor
startup had no explicit capability or lifecycle for realizing and
entering that network stack. WireGuard inspection also depended on
an example-local
wgsubprocess instead of a composable API.This patch provides the low-level pieces to inspect, provision and
own a WireGuard bindspace, then run root and Trio child actors inside
its network namespace before they create registry or IPC resources.
Src of research
The implementation follows these upstream APIs and Linux namespace
semantics:
wg(WireGuard) protocol support multiformats/py-multiaddr#108Summary of changes
Add Linux-only, read-only WireGuard inspection through
pyroute2.Reads run in Trio worker threads, avoid creating missing netns
state and always close their netlink clients.
Add explicit bindspace and WireGuard realization under lazy
tractor.net. Serializable declarations stay separate from theprocess-local FD-bearing
Bindspace;open_wg_bindspace()owns anordered, cancellation-safe interface stack.
Preserve declared and realized namespace metadata at IPC
boundaries while peeling tunnel wrappers before transport
reflection.
Bootstrap bound roots and explicit alternate Trio children inside
their realized netns before registry, IPC, socket or worker setup.
Root startup preserves caller FD ownership and restores the calling
thread before outer bindspace teardown.
Move network declarations and lifecycles from
tractor.discoveryinto lazytractor.net, keeping base importsfree of optional networking implementation dependencies.
Update API documentation and the two-host WireGuard example to
demonstrate explicit root-actor composition.
Scopes changed
tractor.netconfiguration and interface realization.
tractor._root,tractor.spawntractor.discovery,tractor.ipctests.net,tests.test_netns_spawnVerification
unshareE2Es.d80dcbe6.TODOs before landing
independently landing runtime change before merging this stack.
This branch already contains the behavior needed by netns child
bootstrap.
Future follow up
Finish declaration-driven endpoint bootstrap for the full actor
tree. Apply parsed endpoint tables to named root and subactor
spawns, realize tunnel-bearing multiaddrs through the explicit
bindspace contexts and supply each live capability at startup.
Add a real WireGuard dataplane proof with two local netns, a WG
pair, root/subactor placement and
find_actor()across the tunnel.Current public composition coverage fakes interface provisioning.
Probe runtime-managed namespace and interface privileges before
actor startup, report actionable failures and cover the missing
capability path.
Transport explicit alternate bindspaces through multiprocessing
backends. Those backends currently reject unsupported FD transport,
and persistent
mp_forkserverroots are rejected when bound.Preserve the exact child namespace-bootstrap exception before the
IPC handshake instead of reporting only process death and its
return code.
Make netns teardown tolerant of already-removed namespaces, then
extend bindspace realization to later veth, VRF or VXLAN kinds as
needed.
Revisit native tagged
TunnelledAddressdecoding and a persistentfirst-child
wgman/netlink manager if reconciliation or long-livedownership requires them.
Replace the temporary
py-multiaddrVCS pin after a release shipsthe
/wg/codec.Related issues & PRs
TunnelledAddressand tagged address forms #505, whosewkt/addr_unpackinghead is this PR's base.(this pr content was generated in some part by
opencodeusinggpt-5.6-sol(openai))