Skip to content

feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772

Closed
11 of 11 issues completed

Description

@dan-petty

Tracking issue

This issue tracks the later parts in the section "Status after v0.2.39". One pull request closes each child issue. No pull request closes this issue. This issue closes when every later part is delivered.

Order (2026-10-24): #1983, #1984 and #1435 first, as they change no file in common. Then #1982 and #1978, then #2098, then #2096. This issue closes when all of its child issues close.


Problem

Re-scoped on 2026-10-03 as phase P1a of the evidence-first review (#1137). The original scope is kept: the orchestrator takes its workspace, scanners and enrichers instead of reaching for Path.cwd(), so tests inject a temporary workspace and fakes (the slowest review tests spent about 12 of 18 s in stat calls on the real checkout). The executor below is the injection point for tools. The persona-loop engine removal that was part of this item moved to #995 on 2026-10-02.

Acceptance criteria

  • One ToolExecutor protocol.
    • Production uses HostSandbox: --unshare-all --clearenv, the worktree read-only, a temporary HOME, and databases and rules bound read-only.
    • Tests inject a fake, and the bwrap argv is asserted.
  • The executor starts processes only through core/process, building on refactor(cli): one process runner owns execution, process groups and dry-run #775's first stage (fix(security): the async process runner redacts telemetry and kills the process group on timeout #780). It adds no fifth kill-and-timeout implementation.
  • The orchestrator receives the reviewed workspace (root, listing, reading, sibling and manifest discovery), its scanners and its enrichers through its constructor, and no review module probes Path.cwd(). tests/test_review_pipeline.py::test_review_pipeline_stages, tests/test_review_repos.py::TestReviewReposSubdirectories::test_review_path_summary_in_repos_directory and tests/test_review_security_tools.py::test_pipeline_multi_scanner_aggregation pass a temporary workspace and fakes, and each runs in under 5 s.
  • Limits:
    • RLIMIT_CPU and a wall-clock timeout for every tool;
    • an address-space limit of at least 2 GiB, with GOMEMLIMIT set for Go tools.
    • No process-count limit (RLIMIT_NPROC counts the user's other processes); this is documented.
  • Each ToolRun records: tool, version, binary sha256, config and ruleset digests, the argv template, a digest of the targets, and the commit.
  • (person-run) Every pinned tool runs in the sandbox on the loop input with no network.
  • Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each new test runs under 1 s (the three existing pipeline tests named above have the 5 s bound).
  • uv run devops ci passes.

Key questions

Strategic alignment

Test design: the review-tool fake (2026-10-07)

The owner decided on 2026-10-07, in the test design #1307, that tests double only process edges, each through one seam, and that every fake ships with a contract suite. This item's ToolExecutor is the seam for the review-tool edge. The fake its tests inject becomes that edge's shared fake.

Acceptance criteria (added).

Strategic alignment (added).

Proposed design

Problem statement

The review pipeline's security scanners run as plain subprocesses with the parent's environment and network access, tests cannot inject scanners because the orchestrator reads the working directory, and the HostSandbox imposes no resource limits. This issue introduces a single ToolExecutor protocol as the injection point for all review tools, runs them inside a network-less bubblewrap sandbox with CPU, memory, and wall-clock limits, and refactors the orchestrator to receive its workspace, scanners, and enrichers through its constructor so tests can substitute fakes and a temporary workspace.

Acceptance criteria

  • Criterion 1: A ToolExecutor protocol exists; production uses HostSandbox with --unshare-all --clearenv, the worktree read-only, a temporary HOME, and databases and rules bound read-only; tests inject a fake and assert the bwrap argv.
    Verification: A test constructs the production executor, inspects the bwrap argv it would pass, and asserts the flags --unshare-all, --clearenv, read-only bind of the worktree, a tmp HOME, and read-only binds for databases and rules; a separate test injects a fake executor and confirms the orchestrator calls it.
  • Criterion 2: The executor starts processes only through core/process (building on refactor(cli): one process runner owns execution, process groups and dry-run #775/fix(security): the async process runner redacts telemetry and kills the process group on timeout #780) and adds no fifth kill-and-timeout implementation.
    Verification: grep -r 'subprocess.' src/devops_cli/ai/review/ shows no direct subprocess calls outside core/process; a test asserts the executor delegates to the core/process runner and that no new timeout/kill logic is introduced.
  • Criterion 3: The orchestrator receives the reviewed workspace (root, listing, reading, sibling and manifest discovery), its scanners, and its enrichers through its constructor; no review module probes Path.cwd().
    Verification: grep -rn 'Path.cwd()' src/devops_cli/ai/review/ returns no matches; the three named tests (test_review_pipeline_stages, test_review_path_summary_in_repos_directory, test_pipeline_multi_scanner_aggregation) pass a temporary workspace and fakes and each completes in under 5 s.
  • Criterion 4: RLIMIT_CPU and a wall-clock timeout are applied to every tool; an address-space limit of at least 2 GiB is set with GOMEMLIMIT for Go tools; no RLIMIT_NPROC is applied and this is documented.
    Verification: A test asserts the executor sets RLIMIT_CPU, RLIMIT_AS >= 2 GiB, and GOMEMLIMIT in the environment for Go tools; a test asserts RLIMIT_NPROC is not set; the documentation or code comment explains why no process-count limit is used.
  • Criterion 5: Each ToolRun records: tool name, version, binary sha256, config and ruleset digests, the argv template, a digest of the targets, and the commit.
    Verification: A test runs a fake tool through the executor and asserts the returned ToolRun object carries all seven fields with non-empty values.
  • Criterion 6: Every pinned tool runs in the sandbox on the loop input with no network (person-run verification).
    Verification: A person runs each pinned tool (trivy, kube-linter, pluto, popeye, bandit, semgrep, gitleaks, osv-scanner) inside the sandbox against the loop input and confirms no network egress occurs and the tool completes.
  • Criterion 7: Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each new test runs under 1 s and the three existing pipeline tests run under 5 s.
    Verification: Run the new and modified tests with network disabled (e.g., unshare -n) and assert each new test completes in under 1 s and the three named existing tests complete in under 5 s.
  • Criterion 8: changelog.d/.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
    Verification: git diff --name-only shows changelog.d/772.md added and no changes to CHANGELOG.md or docs/ROADMAP.md.
  • Criterion 9: uv run devops ci passes.
    Verification: Run uv run devops ci in a clean checkout with the change applied and confirm exit code 0.
  • Criterion 10: The edge's fake ships under tests/support/fakes/ with its contract suite (fake and real side, the real side against recorded responses or a local tool, never a live service), per the ADR 'Tests double only process edges, through seams' that docs(cli): docs/TESTING.md holds the test conventions, ADR 0005 records that tests double only process edges, and AGENTS.md and the contributor docs point to them #1308 delivers.
    Verification: tests/support/fakes/ contains the ToolExecutor fake; a contract test file exercises both the fake and the real executor against recorded responses; no test in the suite makes a live network call or invokes a real scanner binary.

Key questions

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#1142, #1312


Decisions for the last part D (owner, 2026-10-22: follow best practices)

Part D switches the sandboxed executor on as the production default. The survey of 2026-10-22 left two policies open. They are decided here:

  1. Hosts without bubblewrap fail closed. A review tool that needs the sandbox does not run on a host that cannot make a user namespace. The review reports a coverage gap for that tool with the reason, as it does for files Semgrep did not scan. There is no opt-out flag and no unsandboxed fallback, because an escape that makes a check pass is not a check (the rule "skip checks, do not build escapes"). GitHub-hosted runners that refuse unprivileged user namespaces therefore report the gap.
  2. popeye runs with the network that it needs and nothing else. popeye reads the cluster API, so it cannot run in a network-less sandbox. The executor has one named profile with the network allowed. Only popeye uses it, and the recorded ToolRun says network: allowed. Every other tool keeps the network-less profile.

Part D also needs the OSV database and the Trivy database or checks to be fetched before the sandboxed run, because neither tool can fetch them inside the sandbox. That fetch step is part of D. Part D needs its own child issue, as each of the other remaining parts has (see "Tracking issue").


Status after v0.2.39 (owner decision 2026-10-23: the remaining parts come later)

Three parts are merged in v0.2.39:

The later parts follow. The section "Tracking issue" lists the child issue of each part. One pull request closes each child issue:

  1. (refactor(security): mypy and the review canary start their tools through a ToolExecutor #1978) mypy and the canary runner take a ToolExecutor. A request must first name a program that is not a tool of the lock.
  2. (no child issue yet) No review or scanner module probes Path.cwd(). The three named pipeline tests pass a temporary workspace and fakes and run under 5 s.
  3. (test(review): scanner_fake answers the review scanners through the ToolExecutor fake, not through patched subprocess calls #1982) scanner_fake is rebuilt over the executor fake.
  4. (no child issue yet) Part D: the sandboxed executor becomes the production default. The decisions of the section above apply: a host without bubblewrap fails closed, popeye has one named profile with the network, and the fetch step for the OSV and Trivy databases belongs here. Ruff gets a cache directory outside the tree. The sandbox binds the Trivy cache and the osv-scanner database. The ruleset digest of osv-scanner and the Ruff config digest are settled here.
  5. (feat(review): the SARIF export of a review carries the ToolRun of each scan under its SARIF 2.1.0 names #1983) The SARIF export lists the records with the names of SARIF 2.1.0. A person first decides whether a clean tool gets a run. A record also needs the exit code of the run.
  6. (fix(review): the binary digest of a Python review tool names its package, not its launcher script #1984) The binary digest of a Python tool names the package and not its launcher script.

Checks only a person can run stay open: every pinned tool in the sandbox on the loop input with no network, and a devops review path comparison of review.md before and after Part C. The Gitleaks command needs --report-path - to print its report. A person decides that point (see the Part B task file).

Sub-issues

Sub-issues

11 of 11 Issues completed
Loading 11 sub-issues

Activity

  1. added this to the v0.2.25 milestone on Oct 1, 2026
  2. added
    type/refactor
    scope/review
    priority/p0-critical
    on Oct 1, 2026
  3. added
    priority/p1-high
    and removed
    priority/p0-critical
    on Oct 1, 2026
  4. removed this from the v0.2.25 milestone on Oct 1, 2026
  5. changed the title [-]refactor(review): review orchestrator takes its workspace, scanners and enrichers instead of the cwd[/-] [+]feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits[/+] on Oct 3, 2026
  6. added
    type/feature
    scope/security
    and removed
    type/refactor
    on Oct 3, 2026
  7. 23 remaining items

  8. dan-petty commented on Oct 25, 2026

    @dan-petty
    OwnerAuthor

    Status, 2026-10-25.

    Every child issue of this tracking issue is closed as completed: #1978, #2098, #1982, #2096, #1983 and #1984, and the dependency #1435.

    The open points of the section "Status after v0.2.39":

    • The Gitleaks command. Decided with the standard answer of Gitleaks: gitleaks dir --report-format json --report-path - --redact <path>. Without --report-path, Gitleaks 8.30.1 writes no report on stdout, so a leak (exit 1) read as a failed scan: devops scan secrets on a directory with a GitHub token said "Gitleaks was not run" and exited 0. fix(security): the pluto, popeye and gitleaks adapters read what those tools actually write #1434 already held this defect, and PR fix(security): the pluto, popeye and gitleaks adapters read what those tools actually write #2220 fixes it, with the Popeye and Pluto adapters.
    • Every pinned tool in the sandbox (person-run). An agent ran devops review path <dir> --static-scan-only with the default sandbox and no model. On src/devops_cli/security (37 Python files), Bandit, Semgrep and Gitleaks ran (3 min 10 s). On k8s/gitea (3 manifests), kube-linter, Pluto, Semgrep and Gitleaks ran (19 s). These inputs did not reach osv-scanner, Trivy, Ruff, mypy, zizmor, golangci-lint or Popeye, and with the reporting stage off no session was kept to read the network field of each ToolRun. So this check stays with a person. A static-scan-only review of the whole tree (1514 files) did not finish in 30 minutes; about 1.8 s of each Python file goes to a sandboxed Gitleaks run for each file.
    • The review.md comparison before and after Part C (person-run). Not run.

    This issue can close when #2220 merges, with the two person-run checks above as the only open points.

  9. dan-petty commented on Oct 25, 2026

    @dan-petty
    OwnerAuthor

    Closed as completed. PR #2220 merged and fixed the last open point that an agent can do, the Gitleaks command. Every child issue is closed.

    The two checks that only a person can run stay as written in the comment of 2026-10-25 above: every pinned tool in the sandbox, and the review.md comparison before and after Part C. The cost of one sandboxed Gitleaks run for each file is a separate item.

  10. removed
    status/in-progress
    on Oct 30, 2026
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

    priority/p1-highscope/reviewscope/securitytype/feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions