Skip to content

refactor(proxy): rename and unix-generalize the shared cooperative proxy machinery#654

Merged
MGudgin merged 5 commits into
microsoft:mainfrom
caarlos0:unix-proxy
Jul 16, 2026
Merged

refactor(proxy): rename and unix-generalize the shared cooperative proxy machinery#654
MGudgin merged 5 commits into
microsoft:mainfrom
caarlos0:unix-proxy

Conversation

@caarlos0

@caarlos0 caarlos0 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Note

📚 Base of a stack. #629 (feat(seatbelt): add cooperative network proxy support) builds on this PR and should merge after it. This PR renames and unix-generalizes the shared proxy machinery; the Seatbelt backend itself lands in #629.

📖 Description

Prepares the Bubblewrap cooperative network-proxy machinery for reuse by the
macOS/Seatbelt backend, in two commits:

1. Rename linux_*unix_* (pure rename, no behavior change):

  • Coordinator (wxc_common): module linux_proxy_coordinator
    unix_proxy_coordinator; struct LinuxProxyCoordinatorUnixProxyCoordinator.
  • Test proxy crate/binary: linux_test_proxy / linux-test-proxy
    unix_test_proxy / unix-test-proxy (directory, Cargo.toml, workspace member,
    Cargo.lock, clap name, log prefixes).
  • Call sites & tooling: bwrap_runner.rs, build.sh, GitHub Actions + Azure
    Pipelines templates, SDK integration-test helpers (startUnixTestProxy /
    findUnixTestProxyBinary), and docs.

2. Make the shared machinery genuinely cfg(unix) so it builds and runs on
all Unix targets (not just Linux):

  • Gate unix_proxy_coordinator on cfg(unix) (was target_os = "linux"); the
    private-temp-dir chmod is now unconditional under the unix module.
  • unix_test_proxy: linux_mainunix_main (cfg(unix)), and the Linux-only
    PR_SET_PDEATHSIG parent-death mechanism is replaced with a portable
    stdin-EOF parent-lifetime watcher
    — functionally equivalent, no libc.
    Port-stripping is folded into HostFilter::permits.
  • bwrap_runner.rs: sort the coordinator import (fixes a latent cargo fmt
    failure the mechanical rename introduced).

The Bubblewrap backend gate stays cfg(target_os = "linux") — only the shared
machinery it depends on becomes Unix-wide. Enabling proxy on the macOS SDK surface
and adding the Seatbelt backend is deferred to #629.

🔗 References

None — preparatory refactor for macOS/Seatbelt proxy reuse (#629).

🔍 Validation

Native macOS + Linux cross-target (from macOS; cargo check/clippy need no
cross-linker), toolchain 1.93:

  • cargo fmt --all --checkclean (this PR fixes a pre-existing formatting
    failure on bwrap_runner.rs / unix_test_proxy/proxy.rs).
  • cargo test -p wxc_common -p unix_test_proxy — 328 + 12 passed (11 unit + a
    new parent_disconnect integration test). The cfg(unix) change means the
    coordinator and test-proxy tests now also run on macOS (previously Linux-only
    / stubbed).
  • Review follow-up: the stdin-EOF parent-death watcher now has a regression
    test (unix_test_proxy/tests/parent_disconnect.rs, exercising the
    parent_disconnected shutdown arm) plus a portable pre-bind/pre-publish guard
    — the analog of the old getppid() == 1 check — so an already-dead parent
    can't leak a bound socket; the fd-inheritance and startup-race caveats versus
    PR_SET_PDEATHSIG are documented on parent_disconnect_signal.
  • cargo clippy -p wxc_common -p unix_test_proxy --all-targets -- -D warnings
    (macOS, now checks the unix_main path) and the same cross-compiled to
    x86_64-unknown-linux-gnu for bwrap_common — no warnings.
  • Repo-wide grep confirms zero stale linux_proxy_coordinator /
    LinuxProxyCoordinator / linux_test_proxy / linux-test-proxy references.

Cargo.lock changes are the crate-rename, removal of the libc edge from
unix_test_proxy, and a tempfile dev-dependency edge for the new test (all
already-vendored crates; no new external crates), so dependency-feed-check is
unaffected.

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

Rename the Bubblewrap cooperative network-proxy machinery from
"linux"-prefixed names to "unix" so it can be reused for macOS later:

- wxc_common module `linux_proxy_coordinator` -> `unix_proxy_coordinator`
  and struct `LinuxProxyCoordinator` -> `UnixProxyCoordinator`
- crate/binary `linux_test_proxy` / `linux-test-proxy` ->
  `unix_test_proxy` / `unix-test-proxy` (directory, Cargo manifest,
  workspace member, Cargo.lock)
- update call sites, docs, build.sh, CI (GitHub Actions + Azure
  Pipelines), and SDK integration-test helpers (`startUnixTestProxy` /
  `findUnixTestProxyBinary`)

Genuine platform-specific behavior is preserved: `#[cfg(target_os =
"linux")]` gates, the internal `linux_main` entry point, the "only
supported on Linux" messaging, and the SDK's Linux-only proxy-support
gate. No behavior change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c57605d1-6f24-4c9c-ac7c-7e9cb524dbcb
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 16, 2026 11:59
@caarlos0
caarlos0 requested a review from a team as a code owner July 16, 2026 11:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR performs a repo-wide rename of the Bubblewrap cooperative network-proxy plumbing from linux-prefixed names to unix-prefixed names, so the same coordinator and bundled test proxy can be reused for future macOS/Seatbelt work while keeping current Linux-only gating intact.

Changes:

  • Renamed wxc_common::linux_proxy_coordinator::LinuxProxyCoordinator to wxc_common::unix_proxy_coordinator::UnixProxyCoordinator and updated Bubblewrap call sites.
  • Renamed the test-proxy crate/binary from linux_test_proxy / linux-test-proxy to unix_test_proxy / unix-test-proxy, including log prefixes and CLI name.
  • Updated build scripts, CI pipelines, SDK integration tests/helpers, and docs to reference the new names.
Show a summary per file
File Description
src/testing/unix_test_proxy/src/proxy.rs Updates proxy stderr log prefixes to unix-test-proxy.
src/testing/unix_test_proxy/src/main.rs Updates crate docs, clap name, runtime messages, and log prefixes to unix-test-proxy.
src/testing/unix_test_proxy/Cargo.toml Renames the crate and bin target names.
src/core/wxc_common/src/unix_proxy_coordinator.rs Renames the coordinator type/module references and updates log/error strings accordingly.
src/core/wxc_common/src/lib.rs Switches exported module from linux_proxy_coordinator to unix_proxy_coordinator (still Linux-gated).
src/Cargo.toml Updates workspace member path from testing/linux_test_proxy to testing/unix_test_proxy.
src/Cargo.lock Replaces the linux_test_proxy package entry with unix_test_proxy (same dependency set).
src/backends/bubblewrap/common/src/bwrap_runner.rs Updates imports/usages to UnixProxyCoordinator.
sdk/node/tests/integration/test-helpers.ts Renames helper APIs and expected binary from linux-test-proxy to unix-test-proxy.
sdk/node/tests/integration/linux-bubblewrap.test.ts Updates integration test to use the renamed startUnixTestProxy helper.
README.md Updates documented clippy command to reference unix_test_proxy.
docs/bwrap-support/bubblewrap-backend.md Updates docs to reference unix-test-proxy.
build.sh Updates package list and copy steps to build/copy unix-test-proxy.
.github/workflows/Package.NpmSdk.Job.yml Restores execute bit for unix-test-proxy instead of linux-test-proxy.
.github/workflows/Build.Linux.Job.yml Builds/uploads unix_test_proxy / unix-test-proxy instead of the Linux-prefixed names.
.github/copilot-instructions.md Updates the testing/ directory example entry to unix_test_proxy/.
.azure-pipelines/templates/Rust.Build.Job.yml Updates signing pattern and explicit build step to unix_test_proxy / unix-test-proxy.
.azure-pipelines/templates/Package.NpmSdk.Job.yml Updates chmod step and display name to unix-test-proxy.

Review details

  • Files reviewed: 17/18 changed files
  • Comments generated: 0
  • Review effort level: Low

…euse

The rename to `unix_*` prepared the coordinator and test proxy for reuse by
the macOS Seatbelt backend, but the code was still gated to Linux. Generalize
the shared machinery so it actually builds and runs on all Unix targets:

- wxc_common: gate `unix_proxy_coordinator` on `cfg(unix)` (was
  `target_os = "linux"`); the private-temp-dir chmod is now unconditional
  under the unix module.
- unix_test_proxy: rename `linux_main` -> `unix_main` (`cfg(unix)`) and
  replace the Linux-only `PR_SET_PDEATHSIG` parent-death mechanism with a
  portable stdin-EOF parent-lifetime watcher; drop the now-unused `libc`
  dependency. Fold port-stripping into `HostFilter::permits` so the CONNECT
  path passes the full authority.
- bwrap_runner: sort the `unix_proxy_coordinator` import, fixing a latent
  `cargo fmt` failure introduced by the mechanical rename.

The Bubblewrap backend gate stays `cfg(target_os = "linux")`; only the shared
machinery it depends on becomes Unix-wide. The test proxy's parent-death
mechanism becomes portable but is functionally equivalent on Linux.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d3191c12-2deb-452b-8379-3abbcd5eeb68
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0 caarlos0 changed the title refactor(proxy): rename linux proxy coordinator and test proxy to unix refactor(proxy): rename and unix-generalize the shared cooperative proxy machinery Jul 16, 2026
The unix-test-proxy now uses a cross-platform stdin-EOF watcher for
parent-death detection (replacing the Linux-only PR_SET_PDEATHSIG). The
external-launch helper startUnixTestProxy still spawned it with
'stdio: ignore', which gives the child a /dev/null stdin that is at EOF
immediately: the proxy bound its port, wrote its ready-file, then shut
down right away. The Linux Bubblewrap integration test then failed with
'curl: (7) Couldn't connect to server' because the proxy was already dead.

Spawn the proxy with stdin as an open pipe held by the test process
(stdio: ['pipe','ignore','ignore']), mirroring how the Rust coordinator
holds Stdio::piped() for the builtinTestServer proxy. EOF (and shutdown)
now only fires when the test process exits. run-tests.js already passes
--test-force-exit and the test's after() hook SIGTERMs the proxy, so the
held pipe cannot hang the runner.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d3191c12-2deb-452b-8379-3abbcd5eeb68
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Comment thread src/testing/unix_test_proxy/src/main.rs
caarlos0 and others added 2 commits July 16, 2026 14:49
Address review feedback on the stdin-EOF parent-lifetime watcher that
replaced Linux's PR_SET_PDEATHSIG:

- Add a regression test that spawns unix-test-proxy, closes its stdin,
  and asserts it exits promptly. The parent_disconnected select! arm was
  previously uncovered (integration tests tear down via SIGTERM).
- Restore a portable pre-bind/pre-publish guard (a non-blocking
  parent_already_disconnected check), the analog of the old getppid()==1
  guard, so an already-dead parent can no longer leak a bound socket.
- Document the fd-inheritance and startup-race caveats versus
  PR_SET_PDEATHSIG on parent_disconnect_signal.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 13fe9b88-1cac-4df3-99da-c92b7bda7d6a
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Behavior-preserving cleanup of the guard code added in 9ba6d7b:

- Consolidate the two duplicated startup guards and the
  parent_already_disconnected predicate into a single
  exit_if_parent_disconnected(receiver, stage) helper.
- Replace the hand-rolled read-until-EOF loop with std::io::copy into
  io::sink (identical Interrupted-retry / EOF / hard-error behavior) and
  drop the now-unused std::io::Read import.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 13fe9b88-1cac-4df3-99da-c92b7bda7d6a
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@MGudgin
MGudgin merged commit cb16800 into microsoft:main Jul 16, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants