Repository navigation
Description
Problem Statement
The Tests & Coverage job changes the runner in one step at .github/workflows/ci.yml:90-94. No other workflow or composite action does: grep -rnE 'apt-get|sudo|sysctl' .github/ matches only those lines (checked at 9da1309, re-checked at 9c879ae). The step:
- runs
sudo apt-get update -yandsudo apt-get install -y bubblewrap python-is-python3; - runs
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 || true, which turns off Ubuntu 24.04's AppArmor limit on unprivileged user namespaces for the whole runner. That sysctl is mentioned nowhere else in the repository.
It arrived with v0.2.23 (ea49d6e, #681) so that the live bubblewrap tests from #592 and #663 could run in CI.
What the step does in practice, taken from run 36895839743 (2026-10-01):
- It takes 10 s per run and downloads
bubblewrap 0.9.0-1ubuntu0.3from the Ubuntu mirror. python-is-python3is already in the runner image ("already the newest version (3.11.4-1)"), so that half of the step does nothing.- None of the 161 failed CI runs on record failed in this step.
So the problem is hermeticity, not flakiness. Every run depends on a package mirror and weakens a kernel security setting. It also tests the sandbox against Ubuntu's bwrap and system Python, not the devcontainer's (#847).
The devcontainer already installs bubblewrap (.devcontainer/Dockerfile:23). The pre-push hook runs uv run devops ci there (.pre-commit-config.yaml:70-77, AGENTS.md:59-62), so the live tests keep running before every push.
Removing the step on its own breaks CI. With /usr/bin/bwrap masked, the three affected files at 9da1309 end with 17 failed and 43 passed (re-measured during refinement; the issue's full-suite figure at ef21785 was 17 failed, 6491 passed). The failures are in three files, not only tests/test_host_sandbox.py:
tests/test_host_sandbox.pyhas 8 live tests (:16,:30,:41,:54,:68,:172,:187,:208). It also hastest_host_sandbox_handles_namespace_refusal(:125). That test patchessubprocess.Popen, butHostSandbox.executechecksis_available()first (src/devops_cli/sandbox/host.py:430-438), so it still needs a real bwrap.test_host_sandbox_build_args_structure(:108) andtest_host_sandbox_consumes_custom_policy(:146) only callbuild_bwrap_argsand pass without bwrap;test_host_sandbox_fails_closed_when_bwrap_missing(:90) passes a nonexistent binary on purpose.tests/test_executable_criteria.pyhas 7 tests that run criteria through the sandbox (:169,:184,:195,:211,:225,:254,:283).tests/test_verdict_writers.py:116(test_criteria_execution_verdict_finality).
HostSandbox.__init__ resolves the binary as bwrap_binary or shutil.which("bwrap") or DEFAULT_HOST_SANDBOX_BINARY (sandbox/host.py:325; /usr/bin/bwrap at config/defaults.py:415), and is_available() checks that the path is an executable file (sandbox/host.py:329-331). Once is_available() is true, a patched subprocess.Popen returning a MagicMock takes the explicit mock branch in _communicate_bounded (sandbox/host.py:226, _is_mock_subprocess at :71), so a stub binary is enough to make the refusal test hermetic (verified during refinement: a #!/bin/sh stub under a temp dir plus the test's mock yields passed=False, exit_code=1, error="Host sandbox error: bwrap: Setting up uid map: Permission denied" with the system bwrap masked). No test skips on is_available() today, and pyproject.toml:101-105 registers no pytest markers.
Coverage: CI enforces fail_under = 90 (pyproject.toml:113). The last green CI run reached 90.43%. Measured locally over the full suite (73,372 statements):
- With bwrap present: 90.46%.
- With bwrap hidden: 90.34%. That is 85 more statements missed, mostly in
sandbox/host.py, which drops from 86% to 48%.
Proposed Solution
- Delete the "Install bubblewrap host sandbox dependencies" step (
ci.yml:90-94). No workflow runsapt-get,sudoorsysctlafterwards. - Register a
bwrapmarker in[tool.pytest.ini_options](pyproject.toml:101-105). Its description says the test needs a working bubblewrap and is skipped where bwrap is not installed. - Add one
pytest_collection_modifyitemshook intests/conftest.py, beside the existing session hooks (:726-763). WhenHostSandbox().is_available()is false, it adds a skip to every item markedbwrap, with a reason that names bubblewrap. It constructsHostSandboxonce per collection, not per item. - Mark the 16 live tests listed above with
@pytest.mark.bwrap.test_host_sandbox_build_args_structure(:108),test_host_sandbox_consumes_custom_policy(:146) andtest_host_sandbox_fails_closed_when_bwrap_missing(:90) are not marked: they never execute bwrap. - Make
test_host_sandbox_handles_namespace_refusalhermetic. PassHostSandboxan executable stub file undertmp_pathasbwrap_binary, sois_available()is true and the patchedsubprocess.Popenreturns the mocked refusal through the mock branch atsandbox/host.py:226. The test then runs everywhere, CI included. - Add one offline invariant to
tests/test_architectural_invariants.py, next to the existing ci.yml and Dockerfile check (test_devcontainer_image_path_filter_covers_dockerfile_sources,:428-460, helpers at:397-425). It checks two things:- no
run:step in any job of.github/workflows/*.ymlcallsapt-get,sudoorsysctl; .devcontainer/Dockerfileinstallsbubblewrap.
- no
- Add
changelog.d/832.mdanddocs/agent/tasks/task-832-<slug>.mdin the delivering PR.
Scope
- Files changed:
.github/workflows/ci.yml(delete the step),pyproject.toml(the marker),tests/conftest.py(the hook),tests/test_host_sandbox.py,tests/test_executable_criteria.py,tests/test_verdict_writers.py(markers and the stub-binary rewrite),tests/test_architectural_invariants.py(the invariant),changelog.d/832.md, the task file. - Do not change
src/devops_cli/sandbox/: fix(security): the host sandbox declares a noexec /tmp it never applies #798 and fix(review): criteria commands run in the reviewed project's environment with a measured python timeout #847 own changes to sandbox behavior. - Gate budget: the invariant test runs in milliseconds, and the skip hook checks one file per worker. The local gate runs the same live tests as today.
- Tests stay offline. Use structural tuple assertions until test(cli): retire the tuple-assert mandate and detect opaque tuple asserts and presence-only tests #851 settles that.
AGENTS.md:57forbids weakening security checks unless the user explicitly instructs it. The owner's issue is that instruction for moving the live tests out of GitHub CI.- Existing workflow tests in
tests/test_ci.py(:594-597,:608-613,:624-628) read the test job's steps byuses:and job names only; none references the bubblewrap step, so deleting it breaks nothing there. - Sequencing in v0.2.26: this item lands after feat(cli): extend the ruff rule set to the correctness families #420 (the first merge of the release, which edits
tests/test_architectural_invariants.pyandpyproject.toml) and before refactor(ci): github ci runs the gate throughdevops cifrom one check table #843, in the fixed chain feat(cli): extend the ruff rule set to the correctness families #420, then refactor(ci): ci installs nothing on the runner, and live bubblewrap tests skip where bwrap is missing #832, then refactor(ci): github ci runs the gate throughdevops cifrom one check table #843, then feat(cli):devops ci testselects tests from a coverage index built on demand bydevops ci coverage --build-index#406. - A local stash on the owner's machine (
stash@{0}:On release/v0.2.24: wip-issue-832-remove-workflow-package-installs, commit8106953, not an ancestor of HEAD) holds an earlier partial attempt. It deletes the step and adds a per-filerequires_bubblewrap = pytest.mark.skipif(not HostSandbox().is_available(), ...)totest_host_sandbox.pyandtest_executable_criteria.py; it also markstest_host_sandbox_consumes_custom_policy, leaves the namespace-refusal test untouched, and does not touchtest_verdict_writers.py. That design is not this item's: it offers no-m bwrapselection, marks a test that does not need bwrap, and would still fail on the refusal test. Nothing from it has been delivered.
Key Questions
- Where do the confinement tests run once CI skips them? Answered: in the devcontainer. The pre-push hook runs
uv run devops cithere, and bubblewrap is in the image. GitHub CI stops checking confinement. When chore(github): required CI checks bind merges into release and main, and ADR 0004 records the verification policy #842 (v0.2.27) makes Tests & Coverage a required check, that check still won't cover confinement. The owner's issue asks for this split, and fix(review): criteria commands run in the reviewed project's environment with a measured python timeout #847 already assumes it. - Should the tests skip only when bwrap is absent, or also when bwrap is present but can't create namespaces? Answered: only when it is absent. A refusal means a host that has the sandbox but can't use it, and reviews on that host would hit the same failure. Failing makes that visible. If a future runner image ships bwrap with the AppArmor limit still on, CI fails loudly and a person decides then.
- Should the four verdict and confidence tests (
test_executable_criteria.py:225,254,283,test_verdict_writers.py:116) get a stub sandbox so they keep running in CI? Answered: no. They test criteria end to end through the real sandbox, and the pre-push gate runs them. A fake sandbox would win back only about 10 statements ofreview_environment.pycoverage in CI (measured). - Should the job run inside the devcontainer image instead? Answered: no. That image is built only for PRs into main (
ci.yml:101-103). Running bwrap in a job container on the runner would likely need extra container privileges or the same kernel setting, which brings back what this item removes. refactor(ci): github ci runs the gate throughdevops cifrom one check table #843 owns the CI job structure. - Where does the skip logic live: a registered marker plus one
conftest.pyhook, or askipifdecorator per file? Answered: a registeredbwrapmarker and one hook intests/conftest.py. The marker givesuv run pytest -m bwrapand a single reason string; a per-fileskipif(the stash's design) gives neither. fix(test): the test network guard refuses loopback connects to services the test did not start #837, which also editedconftest.py, shipped in v0.2.24 (d3b2b64,e6ce3db), so there is nothing to rebase on; its loopback guard is nowprevent_external_network_callsattests/conftest.py:98-99. - Does dropping
python-is-python3change anything? Answered: no. The runner image already ships it, and the only tests that runpython(notpython3) inside the sandbox are the 7 marked tests intest_executable_criteria.pyandtest_verdict_writers.py:116, which skip in CI.test_host_sandbox_fails_closed_when_bwrap_missing(:90) namespython -cbut never executes it. - Does CI coverage stay at or above 90%? Answered: yes, at about 90.3% (measured above). The margin shrinks from about 0.43 to about 0.31 points.
- Does the invariant cover every workflow, or only
ci.yml? Answered: every file in.github/workflows/*.yml(ci.yml,cleanup-devcontainer.yml,codeql.yml,release.yml,update-prs.yml). None of them usesapt-get,sudoorsysctltoday, so the invariant passes at landing and stops any workflow from starting. The composite action.github/actions/setup-toolchain/action.ymlhas onlyuv syncandmkdirrun steps (:46,:50) and is out of the invariant's glob; refactor(ci): github ci runs the gate throughdevops cifrom one check table #843's allowlist covers the composite action.
Acceptance Criteria
- No workflow changes the runner.
grep -rnE 'apt-get|sudo|sysctl' .github/workflowsprints nothing, and the new invariant test intests/test_architectural_invariants.pypasses. - The invariant test fails if a
sudo apt-get installstep is added back toci.yml, and fails ifbubblewrapis removed from the Dockerfile. Verified by the builder making each edit locally, watchinguv run pytest tests/test_architectural_invariants.py -k <new test name>fail, and reverting it. The PR notes the result. The test takes under 1 s, checked with--durations=0. -
bwrapis a registered marker:uv run pytest --markerslists it with a description that names bubblewrap, anduv run pytest -m bwrap --collect-only -qcollects exactly 16 tests. - Where bwrap is missing, the 16 marked tests skip and nothing fails. Verified on the PR's own CI run: the Tests & Coverage log reports
16 skippedand 0 failed, and the skip reason names bubblewrap (-rs). -
test_host_sandbox_handles_namespace_refusalpasses without bwrap. Verified by the same CI run, where it passes and is not among the skipped tests (16 skipped, not 17). Locally,uv run pytest tests/test_host_sandbox.py -k namespace_refusalpasses withHostSandboxgiven an executable stub undertmp_pathasbwrap_binary. - In the devcontainer,
uv run pytest -m bwrap -rsruns 16 tests with 0 skipped, anduv run devops cipasses. Verified by the builder in the devcontainer, with the output in the PR. - CI coverage stays at or above
fail_under = 90. Verified on the PR's CI run, where about 90.3% is expected. -
uv run actionlintpasses on the editedci.yml, and the existingtests/test_ci.pyworkflow tests (:594-628) still pass. -
src/devops_cli/sandbox/is unchanged:git diff --stat <base>..HEAD -- src/devops_cli/sandbox/prints nothing. -
changelog.d/832.mdanddocs/agent/tasks/task-832-<slug>.mdare in the delivering PR;CHANGELOG.mdanddocs/ROADMAP.mdare not edited (devops pr check-readinesspasses).
Out of Scope
- Any change under
src/devops_cli/sandbox/(fix(security): the host sandbox declares a noexec /tmp it never applies #798, fix(review): criteria commands run in the reviewed project's environment with a measured python timeout #847). - Replacing the remaining raw
run:steps inci.ymlwithdevops cicalls, or the parity test and allowlist (refactor(ci): github ci runs the gate throughdevops cifrom one check table #843). - The
actions: writeallowlist invariant intests/test_architectural_invariants.py(feat(ci):devops pr update --dispatch-cistarts ci.yml on each branch it updates, and only update-prs.yml may holdactions: write#984, v0.2.27, lands after refactor(ci): github ci runs the gate throughdevops cifrom one check table #843). - Running the live tests in a job container or a self-hosted runner.
- Skipping on namespace refusal when bwrap is present.
- A stub sandbox for the verdict and confidence tests.
- The
service-imagejob and itsrun:steps (feat(release): production service image for scheduled jobs and webhook handlers #753).
Dependencies
- Depends on: none. fix(test): the test network guard refuses loopback connects to services the test did not start #837, which edited
tests/conftest.py, shipped in v0.2.24. - Lands after:
- feat(cli): extend the ruff rule set to the correctness families #420 (v0.2.26): the first merge of the release; it edits
tests/test_architectural_invariants.pyandpyproject.toml, so this item's PR passes the widened lint set instead of rebasing mid-release.
- feat(cli): extend the ruff rule set to the correctness families #420 (v0.2.26): the first merge of the release; it edits
- Lands before:
- refactor(ci): github ci runs the gate through
devops cifrom one check table #843 (v0.2.26): its parity test's allowlist of rawrun:steps is empty only once the step atci.yml:90-94is gone (refactor(ci): github ci runs the gate throughdevops cifrom one check table #843 body: "Nothing, once refactor(ci): ci installs nothing on the runner, and live bubblewrap tests skip where bwrap is missing #832 has landed"; "Land after refactor(ci): ci installs nothing on the runner, and live bubblewrap tests skip where bwrap is missing #832"; "Depends on: refactor(ci): ci installs nothing on the runner, and live bubblewrap tests skip where bwrap is missing #832"). - feat(cli):
devops ci testselects tests from a coverage index built on demand bydevops ci coverage --build-index#406 (v0.2.26, may move to v0.2.28 at the v0.2.25 cut): lands after refactor(ci): github ci runs the gate throughdevops cifrom one check table #843 in the fixed chain refactor(ci): ci installs nothing on the runner, and live bubblewrap tests skip where bwrap is missing #832, then refactor(ci): github ci runs the gate throughdevops cifrom one check table #843, then feat(cli):devops ci testselects tests from a coverage index built on demand bydevops ci coverage --build-index#406; it edits no file this item edits (its test files aretests/test_coverage_index.py,tests/test_test_selection.pyandtests/test_ci.py, which this item only runs).
- refactor(ci): github ci runs the gate through
- Shares files with:
- feat(release): production service image for scheduled jobs and webhook handlers #753 (v0.2.26): adds a
service-imagejob toci.ymland parametrizestests/test_architectural_invariants.py:428over both images; different hunks, whichever lands second rebases, and feat(release): production service image for scheduled jobs and webhook handlers #753 may land either side of refactor(ci): github ci runs the gate throughdevops cifrom one check table #843. - fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858 (v0.2.27): keeps "one worker setting" between
commands/ci.py:374-376andaddopts(pyproject.toml:105), the table where the marker goes; different lines of the same table. - feat(ci):
devops pr update --dispatch-cistarts ci.yml on each branch it updates, and only update-prs.yml may holdactions: write#984 (v0.2.27): adds itsactions: writeallowlist invariant beside the same ci.yml check intests/test_architectural_invariants.py; it lands after refactor(ci): github ci runs the gate throughdevops cifrom one check table #843, so after this item, and rebases on it.
- feat(release): production service image for scheduled jobs and webhook handlers #753 (v0.2.26): adds a
- Related:
- fix(review): criteria commands run in the reviewed project's environment with a measured python timeout #847 and fix(security): the host sandbox declares a noexec /tmp it never applies #798 (backlog): add or change live tests in
tests/test_host_sandbox.py; those tests should carry thebwrapmarker. - chore(github): required CI checks bind merges into release and main, and ADR 0004 records the verification policy #842 (v0.2.27): makes Tests & Coverage a required check; that check does not cover confinement. After its split, chore(github): required CI checks bind merges into release and main, and ADR 0004 records the verification policy #842 no longer edits
ci.ymlortests/test_architectural_invariants.py(that work is feat(ci):devops pr update --dispatch-cistarts ci.yml on each branch it updates, and only update-prs.yml may holdactions: write#984). - feat(ci): changed-line coverage on pull requests (diff-cover) #850 (backlog): its changed-line coverage will see
sandbox/host.pyas covered only locally. - feat(cli): bubblewrap confinement for criteria commands and one sandbox policy #592 and fix(security): host sandbox applies no output, process or tmpfs limits and binds the wrong repository root #663: added the live tests.
- fix(review): criteria commands run in the reviewed project's environment with a measured python timeout #847 and fix(security): the host sandbox declares a noexec /tmp it never applies #798 (backlog): add or change live tests in
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 1, 2026
Descoped from v0.2.24 to v0.2.25 under #740's Cap rule. Admitting the critical fix #837 descopes the lowest-priority item that hasn't started, and this was the only one. #843 (CI parity) builds on it.
[-]Remove ad-hoc package updates and installs from CI workflow[/-][+]refactor(ci): ci installs nothing on the runner, and live bubblewrap tests skip where bwrap is missing[/+]dan-petty commentedon Oct 1, 2026
Moved from v0.2.25 to v0.2.26 to bring v0.2.25 to its cap of 12. #740's cap rule had descoped this item from v0.2.24, so no person placed it in v0.2.25, and it comes last in the trim order: P1, Medium value, highest number. In v0.2.26 it lands before #843, which depends on it.
refactor(ci): ci installs nothing on the runner, and live bubblewrap …
dan-petty commentedon Oct 4, 2026
Closed by #1156, merged into
release/v0.2.26.GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by
devops gh issues close-merged.feat(release): v0.2.26 (#1178)