Skip to content

fix(sandbox): gate auto_detect noop assertion to windows only#245

Merged
emal-avala merged 1 commit intomainfrom
fix/sandbox-test-guard-windows-only
Apr 24, 2026
Merged

fix(sandbox): gate auto_detect noop assertion to windows only#245
emal-avala merged 1 commit intomainfrom
fix/sandbox-test-guard-windows-only

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

auto_detect_off_macos_is_noop was gated on #[cfg(not(target_os = "macos"))] and asserted auto_detect().name() == "noop". That assumption is wrong on any Linux box with bwrap on $PATHauto_detect correctly returns "bwrap" there (see make_bwrap_or_noop). The companion test auto_detect_on_linux_picks_bwrap_or_noop already handles Linux with the right predicate (bwrap OR noop), so the non-macos test was redundantly covering Linux with a stricter-than-true contract.

Fix

Narrow the gate to Windows, where no sandbox strategy is registered, so auto_detect genuinely returns noop. Renamed to auto_detect_on_windows_is_noop to match the invariant, and added a comment so the reason for the narrower gate doesn't regress.

Effect

  • cargo test now passes on any Linux dev machine regardless of whether bwrap is installed.
  • GitHub Actions ubuntu-latest runners don't have bwrap, so CI was already passing and continues to pass.
  • macOS and Windows coverage unchanged.

Test plan

  • cargo test -p agent-code-lib --lib sandbox:: — all 51 pass locally (Linux with bwrap)
  • cargo clippy --workspace --tests --no-deps -- -D warnings
  • cargo fmt --all --check

`auto_detect_off_macos_is_noop` used `#[cfg(not(target_os = "macos"))]`
and asserted `auto_detect().name() == "noop"`. That assumption is
false on any Linux box with `bwrap` on $PATH — auto_detect correctly
returns `"bwrap"` there (see `make_bwrap_or_noop`). The companion
test `auto_detect_on_linux_picks_bwrap_or_noop` already handles
Linux correctly, so the non-macos test was redundantly covering
Linux with a stricter-than-true contract.

Narrow the gate to Windows, where no sandbox strategy is currently
registered, so auto_detect genuinely returns noop. Rename to
`auto_detect_on_windows_is_noop` to match the invariant. Add a
brief comment explaining why the previous gate was wrong so this
doesn't regress.

Effect: `cargo test` now passes on any Linux dev machine regardless
of whether bwrap is installed. CI on GitHub Actions ubuntu-latest
(no bwrap) was already passing and continues to pass.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@emal-avala emal-avala merged commit 610fd07 into main Apr 24, 2026
14 checks passed
@emal-avala emal-avala deleted the fix/sandbox-test-guard-windows-only branch April 24, 2026 06:54
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.

1 participant