Repository navigation
feat: add team production remote sandbox baseline - #123
Conversation
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR implements ADR-0020's production baseline for Docker remote workspaces. It adds explicit ChangesProduction Docker Remote Sandbox Baseline
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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 363-364: The quota check is racy: calls to
_enforce_active_workspace_quota(provider_config) and the subsequent creation of
workspace_id must be made atomic to prevent concurrent creators from exceeding
max_active_workspaces; wrap the enforcement+reservation in a lock or atomic
reservation step (e.g., acquire a provider-level mutex or create an atomic
marker file under the workspace root) so that once
_enforce_active_workspace_quota passes a caller immediately reserves the slot
before releasing the lock and then proceeds to create the workspace directory;
update the code paths around _enforce_active_workspace_quota, workspace_id
generation, and the workspace directory creation (same pattern around the code
at lines referenced 612-623) to use this lock-or-reserve mechanism.
- Around line 433-437: The current cleanup_stale_cloud_workspaces() and
_cleanup_stale_docker_workspaces() flow deletes workspaces purely by age
(provider_config.max_workspace_age_seconds) which can remove containers still in
use; modify the logic to skip any workspace that has an active session/lease
binding before deleting: in cleanup_stale_cloud_workspaces() fetch the list of
active sessions or leases (or call a new helper like
is_workspace_active(workspace_id) or get_active_session_for_workspace) and pass
that predicate into _cleanup_stale_docker_workspaces(), or enhance
_cleanup_stale_docker_workspaces() to check session ownership/lease state for
each candidate workspace_id and skip deletion if active; ensure
provider_config.max_workspace_age_seconds still gates candidates but never
deletes workspaces with an active session.
In `@coding-agent/src/coding_agent/ui/auth.py`:
- Around line 20-29: The current _server_config_bearer_token swallows
ConfigError/OSError and returns None which upstream auth code (the auth
enable/disable path that calls _server_config_bearer_token) interprets as "no
token" and disables auth; change this to fail-closed by not swallowing the
exceptions: inside _server_config_bearer_token, on ConfigError/OSError log a
clear error (include _SERVER_CONFIG_ENV and configured_path) and re-raise the
exception (or return an explicit failure sentinel that the authentication
initialization treats as denial rather than disabling auth); also update the
caller that currently treats None as "disable auth" to treat an exception or the
failure sentinel as "deny all" so unreadable/malformed configured auth sources
do not permit anonymous access (refer to load_agent_toml and the auth
enable/disable logic that consumes _server_config_bearer_token).
- Around line 69-76: The code currently sets provided_token to X-API-Key
unconditionally, rejecting a valid Bearer when both headers are present; update
the assignment so that either credential is accepted by preferring a non-empty
bearer token first and falling back to X-API-Key. Specifically, replace the
provided_token assignment with logic that uses bearer_token if it is truthy,
otherwise uses x_api_key (with the existing isinstance(x_api_key, str) check);
keep the earlier bearer_token extraction logic (authorization, scheme, value)
and the subsequent null check unchanged.
In `@coding-agent/src/coding_agent/ui/http_server.py`:
- Around line 95-113: The code in _load_agent_config_section silently returns {}
on ConfigError/OSError even when an explicit config was requested; change the
except block to fail fast if the config path was provided via the
CODING_AGENT_SERVER_CONFIG env var (or otherwise explicitly set by
_server_config_path). In practice, inside _load_agent_config_section, detect
whether the config_path came from the explicit env var
(CODING_AGENT_SERVER_CONFIG) and if so re-raise the caught exception (or raise a
new descriptive exception) instead of logging and returning {}; otherwise
preserve the current fallback logging and return {}. Ensure this touches the
exception handling around load_agent_toml and keeps behavior for
implicit/missing default config while forcing failure for explicit server
configs so callers like _validate_production_config run.
🪄 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: 7dd0ea31-2a06-4368-91d2-e807a26c3954
📒 Files selected for processing (12)
coding-agent/docs/adr/0020-team-production-docker-remote-sandbox-baseline.mdcoding-agent/docs/remote-sandbox-production.mdcoding-agent/src/coding_agent/__main__.pycoding-agent/src/coding_agent/environment/__init__.pycoding-agent/src/coding_agent/environment/docker_workspace_provider.pycoding-agent/src/coding_agent/environment/workspace_provider.pycoding-agent/src/coding_agent/ui/auth.pycoding-agent/src/coding_agent/ui/http_server.pycoding-agent/tests/cli/test_remote_client.pycoding-agent/tests/coding_agent/environment/test_docker_workspace_provider.pycoding-agent/tests/ui/test_http_server.pycoding-agent/tests/ui/test_security.py
Summary
serve --configloading plus production-mode fail-fast validation and bearer token env supportNon-goals
Verification
Summary by CodeRabbit
Release Notes
New Features
--configcommand-line option to explicitly specify a custom server configuration file.Documentation