Skip to content

Add shared Podman and Apptainer runtimes - #2528

Open
xeophon wants to merge 8 commits into
mainfrom
feat/local-container-runtimes
Open

Add shared Podman and Apptainer runtimes#2528
xeophon wants to merge 8 commits into
mainfrom
feat/local-container-runtimes

Conversation

@xeophon

@xeophon xeophon commented Sep 4, 2026

Copy link
Copy Markdown
Member

Overview

Adds podman and apptainer as local runtimes through one shared command, process, and file implementation. Docker and Podman use engine-managed bridge networking and the existing Verifiers proxy so host callbacks and published services remain reachable during restricted execution.

Details

  • Extract the common CLI execution machinery from Docker into ContainerRuntime; Podman shares Docker's lifecycle and networking with native NVIDIA CDI device selection. Use native detached exec for Docker/Podman background servers.
  • Use private container and instance names, and provision MCP runtimes through the existing context manager so failed startup releases owned resources.
  • Run Apptainer in contained instances with writable workspaces initialized from the image, cached SIF images, and process-group cancellation. Apptainer uses host networking and rejects execution-time network policies; its NVIDIA GPU count and local disk requests are advisory.
  • Send framework-owned host-loopback HTTP(S) callbacks through one tokenized listener, preserving certificate checks, IPv6 destinations, and redirect credential boundaries. Scope cookie names and paths to each callback so redirected sessions can establish their own cookies while retaining upstream TLS and credential boundaries. Bound request-body reads and close active handlers during teardown while allowing long-running callback responses.
  • Reuse task images containing Python 3 for Linux callback listeners; other images use the shared Python helper. Offline prerequisites are documented in the architecture guide.
  • Cache the Alpine networking helper with iptables installed. Preserve host-published service traffic while blocking peer requests and replies after the egress cut, retain background-server proxy settings, and route MCP exposure through Runtime.expose().

Performance

Isolating the helper-cache change on main (1e3e729) on an Apple M4 Max running macOS 27.0 and OrbStack Docker 29.4.0 reduced median DockerRuntime.start() + prepare_execution() latency from 0.823 s to 0.291 s: 64.6% lower latency (2.82×), saving 0.531 s per restricted start. This used six warm samples per variant, interleaved in three ABBA blocks after warmups. One cold helper build took 1.107 s, with 1.486 s for that first full start and policy application; base images were already cached. These measurements cover the helper cache on this machine only. Whole-PR performance, registry-cold pulls, Linux, model latency, and full evaluation throughput remain unmeasured.

Supersedes #2469, #2470, #2473, and #2509. Related to #2319 and #2359.


Note

High Risk
Changes sandbox networking, egress filtering, and MCP/interception URL routing across rollouts; mistakes could break tool reachability or weaken restricted execution.

Overview
Adds podman and apptainer as first-class v1 runtimes (config unions, public exports, architecture notes, pytest podman/apptainer marks, and conditional e2e placement rows when the CLI is installed).

Shared container stack: Docker’s exec/process/file helpers move into ContainerRuntime in container.py. Podman reuses Docker’s lifecycle, bridge networking, egress proxy, and published SERVICE_PORT. Apptainer runs contained instances on the host network with cached SIF pulls and no execution-time network policy.

Reachability refactor: Base Runtime.expose() always returns a URL (loopback by default). Docker/Podman publish one host port and route framework loopback HTTP(S) through the egress proxy via tokenized /.vf-host/ callback URLs (cookie/path scoping, redirect handling). MCP serving uses provision_runtime, applies host_url to full paths (/v1, /state, /tool), gates MCP_HOST on exposed published ports, and simplifies reachable_url around expose plus tunnels.

Restricted Docker/Podman execution shifts to bridge mode (not host networking), caches the verifiers-network iptables helper image, and tightens post-cut firewall rules while keeping published service traffic working.

Reviewed by Cursor Bugbot for commit f012c79. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add Podman and Apptainer runtimes with shared container runtime base

  • Adds PodmanConfig/PodmanRuntime and ApptainerConfig/ApptainerRuntime to the v1 runtime discriminated unions, with pytest markers and conditional e2e placement rows for both engines.
  • Extracts shared container runtime machinery (config fields, CLI helpers, process wrappers, file read/write, cleanup) from the Docker runtime into container.py, which Docker, Podman, and Apptainer now share.
  • Adds egress proxy callback URLs in egress.py so loopback framework services inside a container are reachable through capability-scoped proxy URLs, with redirect/cookie rewriting and loopback classification for all named and numeric loopback forms.
  • Fixes MCP and rollout URL mapping in launch.py and rollout.py to apply runtime.host_url to complete endpoint paths including /state, and only sets MCP_HOST for exposed runtimes with a published port.
  • Behavioral Change: runtimes.Runtime.expose base implementation now returns a concrete host-loopback URL instead of None; runtimes.NetworkPolicy.permits no longer treats recognized loopback destinations as ordinary egress targets.

Macroscope summarized f012c79.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-06T16:34:47.730593Z 72bfe97 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread verifiers/v1/runtimes/docker/egress.py
Comment thread verifiers/v1/runtimes/docker/__init__.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0373dc6973

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/__init__.py
Comment thread verifiers/v1/runtimes/docker/__init__.py
Comment thread verifiers/v1/runtimes/docker/__init__.py
Comment thread verifiers/v1/runtimes/docker/__init__.py
@macroscopeapp

macroscopeapp Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — The PR adds Podman and Apptainer capabilities while refactoring shared container execution and changing existing Docker, service-exposure, callback, and egress-policy behavior. Its cross-cutting runtime and network-boundary impact requires human review.

No code changes detected at f012c79. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4caf3c4057

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/apptainer.py
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/runtimes/docker/egress.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef30215d05

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/apptainer.py
Comment thread tests/v1/test_e2e.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/runtimes/docker/__init__.py
Comment thread verifiers/v1/runtimes/container.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6112ce7447

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py
Comment thread verifiers/v1/runtimes/docker/egress.py
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3c46865fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c3c4686. Configure here.

Comment thread verifiers/v1/runtimes/docker/egress.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38cf0c2941

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py
Comment thread verifiers/v1/runtimes/docker/egress.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72bfe978e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +491 to +496
forward_authorization=(
callback.forward_authorization
and redirected.scheme == scheme
and redirect_host == callback.host
and redirect_port == callback.port
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore destination credentials after redirect round trips

When a callback flow redirects A → B → A, this propagates forward_authorization=False onto the return URL for A. Because _Callback includes that flag in the callback-token key, the return uses a different token from A's original URL; A's session cookie is scoped to the original token path and is therefore not sent, breaking common OAuth/login round trips. Fresh evidence in the post-fix code is that token-prefixed cookies now preserve B's session but still cannot restore A's earlier session when the redirect returns; credential suppression needs to apply only to credentials from the origin being left, while reusing the destination origin's scoped state.

Useful? React with 👍 / 👎.

@xeophon
xeophon force-pushed the feat/local-container-runtimes branch from 72bfe97 to f012c79 Compare September 10, 2026 08:49
@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.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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