Skip to content

feat: add remote runtime profiles - #135

Merged
delete-cloud merged 3 commits into
mainfrom
feat/runtime-profiles-sandbox-policy
May 12, 2026
Merged

delete-cloud merged 3 commits into
mainfrom
feat/runtime-profiles-sandbox-policy

Conversation

@delete-cloud

@delete-cloud delete-cloud commented May 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add ADR-0022 separating runtime profiles from sandbox policy for remote workspaces
  • add server allowlisted runtime profile selection via remote run/repl --runtime
  • resolve Docker runtime profiles server-side and reject unknown/non-Docker profiles before docker run
  • document runtime profile usage and add a starter universal runtime Dockerfile

Validation

  • uv run pytest tests/coding_agent/environment/ tests/ui/test_http_server.py tests/cli/test_remote_client.py -q
  • uv run basedpyright --level error src/coding_agent/main.py src/coding_agent/remote/client.py src/coding_agent/ui/schemas.py src/coding_agent/ui/execution_binding.py src/coding_agent/ui/http_server.py src/coding_agent/environment/docker_workspace_provider.py tests/cli/test_remote_client.py tests/coding_agent/environment/test_docker_workspace_provider.py tests/ui/test_http_server.py tests/ui/test_execution_binding.py
  • uv run ruff format --check src/coding_agent/main.py src/coding_agent/remote/client.py src/coding_agent/ui/schemas.py src/coding_agent/ui/execution_binding.py src/coding_agent/ui/http_server.py src/coding_agent/environment/docker_workspace_provider.py tests/cli/test_remote_client.py tests/coding_agent/environment/test_docker_workspace_provider.py tests/ui/test_http_server.py tests/ui/test_execution_binding.py
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added a --runtime CLI option for remote run/repl to select server-configured runtime profiles.
    • Introduced server-side runtime profiles for Docker workspaces (selectable images, resource/tool defaults).
    • Added a "universal" Python 3.12 runtime profile.
  • Documentation

    • Updated production guide and ADR documenting runtime profiles and sandbox policy separation.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@delete-cloud has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 31 minutes and 27 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 254bb614-3df4-4f06-a99f-5dd0e01705b2

📥 Commits

Reviewing files that changed from the base of the PR and between b48e6c8 and f4d6f73.

📒 Files selected for processing (2)
  • coding-agent/src/coding_agent/environment/docker_workspace_provider.py
  • coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py
📝 Walkthrough

Walkthrough

This PR implements a server-configured Docker runtime profile selector threaded from CLI (--runtime) through session creation to the server. The server loads and validates runtime_profiles, the Docker provider resolves/merges profile overrides into an effective container configuration (image, network, resource limits, exec user), and tests plus a universal runtime image are added.

Changes

Runtime Profile Selection Feature

Layer / File(s) Summary
Architecture & Design Documentation
coding-agent/docs/adr/0022-runtime-profiles-and-sandbox-policy.md, coding-agent/docs/remote-sandbox-production.md
ADR-0022 and production docs introduce runtime_profiles.<name>, server-side resolution, default profile behavior, and --runtime CLI examples.
Docker Runtime Image
coding-agent/docker/runtime/universal.Dockerfile
Defines a Python 3.12 slim runtime image with minimal tooling, non-root agent user, /workspace working directory, and sleep infinity default command.
Binding Serialization & Request Schema
coding-agent/src/coding_agent/ui/execution_binding.py, coding-agent/src/coding_agent/ui/schemas.py
CloudWorkspaceBinding gains optional runtime_profile with conditional to_dict()/from_dict() handling; DockerWorkspaceSourceRequest adds optional runtime_profile with validation.
CLI Entry Points & Remote Client
coding-agent/src/coding_agent/__main__.py, coding-agent/src/coding_agent/remote/client.py
remote repl and remote run gain a --runtime option threaded to _remote_run_once; serve preserves any existing CODING_AGENT_SERVER_CONFIG; create_remote_session includes runtime_profile in the workspace_source when provided.
Server Config Loading & Validation
coding-agent/src/coding_agent/ui/http_server.py
Server loader reads [runtime_profiles] into cloud workspace config and enforces default_runtime_profile, non-empty runtime_profiles, profile image, and that the profile image is in image_allowlist during production validation.
Docker Provider Resolution & Provisioning
coding-agent/src/coding_agent/environment/docker_workspace_provider.py
Provider resolves requested or default runtime_profile, validates the profile exists and targets Docker, merges profile overrides (image, cpus, memory, pids_limit, exec_user, network) into an effective config, threads resolved profile into binding/client creation, and applies the effective config when starting containers.
Tests & Validation
coding-agent/tests/cli/test_remote_client.py, coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py, coding-agent/tests/ui/test_execution_binding.py, coding-agent/tests/ui/test_http_server.py, coding-agent/tests/.../test_docker_workspace_provider_transfer.py
Adds CLI test for --runtime propagation; provider tests for apply/default/unknown/non-Docker profile behavior and refactors via _docker_config; HTTP server tests for config loading/validation; binding test for serialization round-trip; transfer test updates.

Sequence Diagram

sequenceDiagram
  participant User as CLI User
  participant Client as Remote Client
  participant Server as HTTP Server
  participant Provider as Docker Provider
  participant Docker as Docker Engine

  User->>Client: remote run --runtime universal
  Client->>Server: POST /sessions (workspace_source.runtime_profile=universal)
  Server->>Server: Load runtime_profiles config
  Server->>Provider: Provision with runtime_profile=universal
  Provider->>Provider: Lookup profile & validate provider=="docker"
  Provider->>Provider: Merge profile overrides into effective config
  Provider->>Docker: docker run --image [profile.image] ...[overrides]
  Docker->>Docker: Create & run workspace container
  Provider->>Server: Return CloudWorkspaceBinding (runtime_profile)
  Server->>Client: Session response with binding
Loading

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

"I'm a rabbit in the code-laden glen,
I tuck profiles in every den,
Docker wakes with tools and care,
Workspaces bloom — safe and fair,
Hopping through PRs with grin and pen!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add remote runtime profiles' directly and clearly summarizes the main change—adding support for runtime profile selection in remote execution via the --runtime option.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/runtime-profiles-sandbox-policy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@coding-agent/src/coding_agent/environment/docker_workspace_provider.py`:
- Around line 687-690: The loop that copies keys from profile_config into
effective currently allows unsafe overrides (network, exec_user, pids_limit) via
the tuple ("image","network","cpus","memory","pids_limit","exec_user"); update
this so production sandbox constraints cannot be weakened by a profile: either
(A) restrict the allowed override keys to a safe whitelist (e.g., remove
"network", "exec_user", "pids_limit") when running in production/sandbox mode,
or (B) perform explicit validation when copying those keys by comparing
profile_config["network"/"exec_user"/"pids_limit"] against the validated
cloud_workspace baseline and reject or normalize any weaker values; implement
this logic around the existing effective/profile_config copy in
docker_workspace_provider.py so the effective dict cannot be weakened by
profiles.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6946070a-0956-4f1e-952d-43c81a08b5a4

📥 Commits

Reviewing files that changed from the base of the PR and between e54a564 and 60b2243.

📒 Files selected for processing (13)
  • coding-agent/docker/runtime/universal.Dockerfile
  • coding-agent/docs/adr/0022-runtime-profiles-and-sandbox-policy.md
  • coding-agent/docs/remote-sandbox-production.md
  • coding-agent/src/coding_agent/__main__.py
  • coding-agent/src/coding_agent/environment/docker_workspace_provider.py
  • coding-agent/src/coding_agent/remote/client.py
  • coding-agent/src/coding_agent/ui/execution_binding.py
  • coding-agent/src/coding_agent/ui/http_server.py
  • coding-agent/src/coding_agent/ui/schemas.py
  • coding-agent/tests/cli/test_remote_client.py
  • coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py
  • coding-agent/tests/ui/test_execution_binding.py
  • coding-agent/tests/ui/test_http_server.py

Comment thread coding-agent/src/coding_agent/environment/docker_workspace_provider.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py (1)

910-938: ⚡ Quick win

Clarify test intent by removing redundant configuration.

The test sets both default_runtime_profile="missing" (line 932) and explicitly passes runtime_profile="missing" (line 936). This makes the test intent ambiguous—is it validating the explicit runtime_profile parameter or the default_runtime_profile configuration?

Consider changing line 932 to reference a valid profile name (e.g., "python-basic") so the test clearly validates that an unknown explicitly-requested profile is rejected.

♻️ Proposed fix to clarify test intent
             _docker_config(
                 {
                     "workspace_root": str(workspace_root),
-                    "default_runtime_profile": "missing",
+                    "default_runtime_profile": "python-basic",
                     "runtime_profiles": {},
                 }
             ),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py`
around lines 910 - 938, The test
test_docker_workspace_provider_rejects_unknown_runtime_profile is ambiguous
because it sets default_runtime_profile to "missing" while also passing
runtime_profile="missing"; update the fixture created by _docker_config so
default_runtime_profile is a valid profile (e.g., "python-basic") and keep the
explicit runtime_profile="missing" in the provision_cloud_binding_from_config
call so the test clearly asserts that an explicitly-requested unknown
runtime_profile is rejected by provision_cloud_binding_from_config.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@coding-agent/src/coding_agent/environment/docker_workspace_provider.py`:
- Around line 678-680: When runtime_profile is None the code currently returns
the base config (if runtime_profile is None: return config) which causes
downstream fallback to _DEFAULT_DOCKER_IMAGE and image_allowlist validation
failures; instead resolve and apply the configured default by reading
cloud_workspace.default_runtime_profile and using it to select/merge the
appropriate entry from config.get("runtime_profiles") before returning. Update
the logic in docker_workspace_provider.py (the block that defines
runtime_profiles and handles runtime_profile) to: if runtime_profile is None,
read cloud_workspace.default_runtime_profile, look up that key in
runtime_profiles, and return the merged profile/config (or raise a clear error
if the default key is missing) so subsequent checks (e.g., image_allowlist
validation around _DEFAULT_DOCKER_IMAGE) see the correct resolved image. Ensure
the same fix is applied to the other similar places mentioned (around lines
591-594 and 639-642).

In
`@coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py`:
- Around line 761-834: The test
test_docker_workspace_provider_applies_requested_runtime_profile currently
passes because _effective_docker_workspace_config intentionally only merges
image, cpus, and memory from a runtime profile; update the test to include a
short comment above the provision_cloud_binding_from_config call (or near the
runtime_profiles dict) stating that runtime profiles only override image, cpus,
and memory and do not affect network, pids_limit, or exec_user to make this
explicit for future readers; alternatively, add a clarifying code comment inside
_effective_docker_workspace_config describing this deliberate limitation and why
those fields are excluded.

---

Nitpick comments:
In
`@coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py`:
- Around line 910-938: The test
test_docker_workspace_provider_rejects_unknown_runtime_profile is ambiguous
because it sets default_runtime_profile to "missing" while also passing
runtime_profile="missing"; update the fixture created by _docker_config so
default_runtime_profile is a valid profile (e.g., "python-basic") and keep the
explicit runtime_profile="missing" in the provision_cloud_binding_from_config
call so the test clearly asserts that an explicitly-requested unknown
runtime_profile is rejected by provision_cloud_binding_from_config.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2258c688-7101-4737-97b1-a68d07416be7

📥 Commits

Reviewing files that changed from the base of the PR and between 60b2243 and b48e6c8.

📒 Files selected for processing (7)
  • coding-agent/docs/adr/0022-runtime-profiles-and-sandbox-policy.md
  • coding-agent/docs/remote-sandbox-production.md
  • coding-agent/src/coding_agent/environment/docker_workspace_provider.py
  • coding-agent/src/coding_agent/ui/http_server.py
  • coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py
  • coding-agent/tests/coding_agent/environment/test_docker_workspace_provider_transfer.py
  • coding-agent/tests/ui/test_http_server.py
✅ Files skipped from review due to trivial changes (1)
  • coding-agent/docs/remote-sandbox-production.md

Comment thread coding-agent/src/coding_agent/environment/docker_workspace_provider.py Outdated
@delete-cloud
delete-cloud merged commit 8a15b8f into main May 12, 2026
1 check passed
@delete-cloud
delete-cloud deleted the feat/runtime-profiles-sandbox-policy branch May 12, 2026 02:19
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