Skip to content

fix(ci): the bwrap row passes when the sandbox command fails #5119

Done

Description

@dan-petty

Problem Description

The bwrap row of devops ci (added by #5110) starts its test only after a host check. The host check uses the code that the row must test, so the row can pass when that code is broken.

_sandbox_host_refusal() in src/devops_cli/commands/ci.py calls SandboxToolExecutor().host_refusal(). That method calls _host_cause() in src/devops_cli/security/tool_executor.py, which makes its probe with HostSandbox.build_bwrap_args. tests/sandbox/test_host_sandbox.py tests that same method. _execute_check_async treats each refusal string as a skip: passed=True, skipped=<cause>.

Thus, when a change breaks the sandbox command, the probe fails, the host check reports bubblewrap cannot make a sandbox on this host: ..., and the row starts no test and passes. Static Analysis runs the row on its GitHub-hosted runner, so the required check is green when the sandbox is broken. No other test starts real bubblewrap, so no other check finds this regression.

The host check also returns a cause when the probe does not end in CONST_TOOL_SANDBOX_CHECK_TIMEOUT_SECONDS (30 s). Thus a slow host stores a skip as a pass, also in the cached verdict.

Reproduction Steps

  1. Use a host where bubblewrap can make a sandbox (the devcontainer or a GitHub-hosted runner).
  2. Run uv run python -c "from devops_cli.commands import ci; print(ci._sandbox_host_refusal())". It prints None.
  3. Change HostSandbox.build_bwrap_args so that it adds --ro-bind /no/such/source /x before --.
  4. Run uv run pytest -m bwrap -n 0 tests/sandbox/test_host_sandbox.py tests/ai/test_tool_executor_contract.py. The measured result is 46 failed, 9 passed.
  5. Run the command of step 2 again. It prints bubblewrap cannot make a sandbox on this host: bwrap: Can't find source path /no/such/source: No such file or directory.
  6. Run uv run devops ci --only bwrap. The row shows skipped and the gate exits 0.

Expected vs Actual Behavior

Expected: the row skips only when the host cannot run any sandbox. When the product's own sandbox command fails on a host that can run a sandbox, the row runs the suites and the suites fail. A probe that does not end in time is a failure, not a skip.

Actual: any failure of the product's sandbox command, and a probe timeout, make the row skip and pass.

Proposed fix:

  • Probe the host with a fixed bubblewrap command that does not come from HostSandbox.build_bwrap_args, for example bwrap --unshare-all --ro-bind / / -- true, after a check that bwrap and prlimit are on PATH.
  • Treat a probe timeout as a failure of the row, not a skip.
  • Add a test: when a stand-in bwrap accepts the fixed probe and refuses the product command, the row runs pytest and does not show skipped.
  • Change the requirement The bwrap row runs the sandbox contract suites where the host can make a sandbox in openspec/specs/ci-gate-rows/spec.md to match.

Environment Diagnostics

Logs, Traces, or Terminal Output

clean: None
broken: bubblewrap cannot make a sandbox on this host: bwrap: Can't find source path /no/such/source: No such file or directory

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #5110

Alternatives check of 2026-11-27: none.
Tool: none found.
Reason: Searches found no maintained tool or library that decides host sandbox support for a CI row; bubblewrap is the sandbox itself, and the fix is a change to the project's own bwrap row probe and timeout handling.

Lacks:

  • No tool decides whether a host can run a bubblewrap sandbox
  • No probe that is independent of the product's own sandbox arguments
  • No rule that turns a probe timeout into a failed check instead of a skip
  • No stand-in bwrap harness for a product-command-failure regression test

Proposed design

Problem statement

The bwrap row of devops ci can pass when the product's sandbox command is broken. Its host check calls SandboxToolExecutor().host_refusal(), which uses HostSandbox.build_bwrap_args, and _execute_check_async treats every refusal string as a skip. A probe timeout also becomes a skip. The fix uses a fixed bubblewrap probe, fails on a probe timeout, and adds a regression test.

Acceptance criteria

Requirement: The bwrap host check uses a fixed probe

The bwrap row SHALL decide host sandbox support with a fixed bubblewrap command that does not call HostSandbox.build_bwrap_args.

Scenario: A broken product command does not make the host check refuse

  • WHEN A test makes HostSandbox.build_bwrap_args add a missing bind and puts a stand-in bwrap on PATH that exits 0 for bwrap --unshare-all --ro-bind / / -- true, then it calls _sandbox_host_refusal().
  • THEN _sandbox_host_refusal() returns None, so the row does not skip.

Requirement: The bwrap row skips only when the host cannot run a sandbox

The bwrap row SHALL return a skip refusal when bwrap or prlimit is missing from PATH, or when the fixed probe exits nonzero.

Scenario: The fixed probe fails

  • WHEN A test puts a stand-in bwrap on PATH that exits 1 for the fixed probe, then it awaits _execute_check_async for the bwrap row.
  • THEN The result has skipped set, passed is True, and the row started no command.

Requirement: A probe timeout fails the bwrap row

The bwrap row MUST report a fixed-probe timeout as a failure and not as a skip.

Scenario: The fixed probe exceeds its timeout

  • WHEN A test gives _execute_check_async a bwrap CheckSpec whose host_refusal raises subprocess.TimeoutExpired, then it awaits the row.
  • THEN The result has passed is False, skipped is None, and timed_out is True.

Requirement: A failed product sandbox command does not make the row skip

The bwrap row SHALL run its command when the fixed probe succeeds, even if the product sandbox command fails.

Scenario: The fixed probe succeeds and the product command fails

  • WHEN A test uses a stand-in bwrap that exits 0 for the fixed probe and nonzero for the product arguments, then it awaits _execute_check_async for the bwrap row with a sentinel command that records its start and exits 1.
  • THEN The sentinel command recorded its start, result.skipped is None, and result.passed is False.

Requirement: The ci-gate-rows spec states the fixed probe and timeout behavior

The ci-gate-rows spec SHALL state that the bwrap row uses a fixed probe and treats a probe timeout as a failure.

Scenario: The OpenSpec row validates the updated spec

  • WHEN A developer runs uv run devops ci --only openspec after the spec change.
  • THEN The openspec row passes.

Existing Tool Considered

No open, maintained tool or library covers the need: the alternatives check of 2026-11-16 found none. No new build is needed: the change edits existing functions and adds a regression test.

Key questions

  • Which command should the bwrap row use to probe host sandbox support?: Use the fixed command bwrap --unshare-all --ro-bind / / -- true after shutil.which finds bwrap and prlimit. Do not call SandboxToolExecutor.host_refusal() or HostSandbox.build_bwrap_args. (best practice) [sources: src/devops_cli/commands/ci.py, src/devops_cli/security/tool_executor.py, src/devops_cli/sandbox/host.py, tests/sandbox/test_host_sandbox.py, openspec/specs/ci-gate-rows/spec.md]
    • Chosen: Fixed probe command. It does not call the product command that the row must test.
    • Rejected: SandboxToolExecutor.host_refusal. It calls _host_cause() and HostSandbox.build_bwrap_args, so a product defect becomes a skip.
    • Rejected: HostSandbox.build_bwrap_args. The row would test the same code that it must verify.
  • How should the bwrap row report a fixed-probe timeout?: Raise subprocess.TimeoutExpired from _sandbox_host_refusal(). Catch it in _execute_check_async and return a CheckResult with passed=False, skipped=None, timed_out=True and a stderr line that names the row and timeout. (best practice) [sources: src/devops_cli/commands/ci.py, src/devops_cli/config/constants.py:5078]
    • Chosen: Fail the check result. A timeout shows that the host cannot prove sandbox support and must fail the gate.
    • Rejected: Return a skip refusal. _execute_check_async turns a refusal string into passed=True, skipped=<cause>.
    • Rejected: Run the suites after a timeout. It gives no explicit failure and can still pass on a slow host.
  • Where should the regression test for the bwrap row live?: Extend tests/commands/test_ci_bwrap_row.py. Use a stand-in bwrap on PATH and patch _run_check_commands when the test must not run the full suites. (best practice) [sources: tests/commands/test_ci_bwrap_row.py, tests/support/fakes/process.py]
    • Chosen: Extend test_ci_bwrap_row.py. The file already owns the bwrap row tests and keeps the regression close to the row.
    • Rejected: Add a new test file. It splits the row tests and adds no new coverage.
    • Rejected: Use the real bwrap only. It needs a host that can make a sandbox and cannot simulate a product failure.
  • Should the fix change SandboxToolExecutor.host_refusal() for every caller?: No. Keep the change in the bwrap row. _sandbox_host_refusal() stops calling that method. Other callers keep their current contract. (best practice) [sources: src/devops_cli/commands/ci.py, src/devops_cli/security/tool_executor.py]
    • Chosen: Scope the fix to the bwrap row. The issue is the row's skip behavior; a wider contract change is not needed.
    • Rejected: Change SandboxToolExecutor.host_refusal for all callers. It broadens the change and can alter other rows without a test need.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/ci
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The issue asks for a fix to the project's own CI host-check code (use a fixed bubblewrap probe command instead of the product's own HostSandbox.build_bwrap_args), not for a new external tool or library. Web searches for a bubblewrap CI host-capability probe tool or library returned no relevant maintained project that covers this need.

    Tool: none found

    Lacks:

    • No external tool or library was found that performs CI-gate host-sandbox capability probing with a fixed bubblewrap command independent of the product's own code.

    Searches run:

    • bubblewrap CI host sandbox capability probe tool library detect if host can run bwrap, results: 5
    • CI gate detect sandbox capability "bwrap" OR "bubblewrap" probe timeout failure skip, results: 5
    • "devops ci" bwrap row sandbox host check probe failure skip test runner, results: 5

    Checked on 2026-11-16. A person decides what this means for the item. The check changes no label and closes no issue.

  5. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at c58b592 (see proposed design in issue body).

  7. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 28, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 28, 2026
  9. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 00:41 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/cisource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions