Repository navigation
feat: provision git workspace sources - #145
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR enables Docker workspace provisioning to support Git-backed workspace sources alongside the existing snapshot-based flow. Docker workspace provider now clones a remote Git repository into the workspace root before Docker setup phases, and the HTTP API removes the "not implemented" rejection for Git sources. Git operations are guarded by configurable timeouts and binary paths. ChangesGit Workspace Source Support
Sequence DiagramsequenceDiagram
participant Client
participant HTTPServer as HTTP Server
participant DockerProvider as Docker Provider
participant Git as git subprocess
participant DockerSetup as Docker Setup Phase
Client->>HTTPServer: POST /sessions with git workspace source
HTTPServer->>HTTPServer: validate workspace source phase policy
HTTPServer->>DockerProvider: provision cloud workspace binding
DockerProvider->>Git: git clone --no-checkout --branch <base_ref> <remote_url> (timeout)
Git->>DockerProvider: repository initialized (files, .git)
DockerProvider->>Git: git -C <workspace_root> checkout --detach <base_sha> (timeout)
Git->>DockerProvider: workspace updated to base SHA
DockerProvider->>DockerSetup: run setup phase with cloned workspace
DockerSetup->>DockerSetup: observe cloned repository
HTTPServer->>Client: return 200 with execution binding and origin
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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: 1
🧹 Nitpick comments (1)
coding-agent/src/coding_agent/environment/docker_workspace_provider.py (1)
1102-1127: ⚡ Quick winPrevent interactive hangs and surface git failure output.
Two reliability gaps in the clone/checkout invocations:
env=Noneinherits the parent process environment and stdin is inherited as well, so a private/auth-required remote will trigger a credential prompt that blocks until_GIT_OPERATION_TIMEOUT_SECONDSfires. SetGIT_TERMINAL_PROMPT=0(andstdin=subprocess.DEVNULL) to fail fast.- With
check=True, a failed clone/checkout raisesCalledProcessErrorbut the capturedstdout/stderrare not attached as notes. The setup phase already uses_add_setup_failure_output_notesfor this; mirroring that here would make diagnosing remote/auth/branch errors much easier.♻️ Sketch of the change
+ git_env = {**os.environ, "GIT_TERMINAL_PROMPT": "0"} clone_command = [...] - _ = subprocess.run( - clone_command, - shell=False, - capture_output=True, - text=True, - timeout=_GIT_OPERATION_TIMEOUT_SECONDS, - env=None, - check=True, - ) + try: + _ = subprocess.run( + clone_command, + shell=False, + capture_output=True, + text=True, + timeout=_GIT_OPERATION_TIMEOUT_SECONDS, + env=git_env, + stdin=subprocess.DEVNULL, + check=True, + ) + except subprocess.CalledProcessError as exc: + if exc.stdout: + exc.add_note(f"git clone stdout:\n{exc.stdout}") + if exc.stderr: + exc.add_note(f"git clone stderr:\n{exc.stderr}") + raiseThe same treatment can be applied to the checkout invocation.
🤖 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/src/coding_agent/environment/docker_workspace_provider.py` around lines 1102 - 1127, The clone and checkout subprocess.run calls (for variables clone_command and checkout_command) must be hardened to avoid interactive hangs and surface git output: set stdin=subprocess.DEVNULL and pass an env dict that includes GIT_TERMINAL_PROMPT="0" (instead of env=None) so git fails fast for auth prompts, and wrap each call in a try/except for subprocess.CalledProcessError to capture the failed process output and call the existing _add_setup_failure_output_notes helper with the exception and relevant context (same pattern used elsewhere in this module), retaining timeout=_GIT_OPERATION_TIMEOUT_SECONDS and check=True.
🤖 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 1093-1127: The clone_command currently passes remote_url as a
positional arg which allows argument injection; update the clone_command
(symbol: clone_command) to insert a "--" separator before remote_url so git
stops parsing further args as options; additionally, validate base_sha (used in
checkout_command) against a hex SHA regex (e.g., ^[0-9a-fA-F]{4,64}$) before
calling the checkout_command (symbol: checkout_command) and reject or raise a
clear error if it fails validation to avoid passing unsafe values; reference
provider_config.git_binary and the GitWorkspaceSourceRequest inputs when
locating the variables to change.
---
Nitpick comments:
In `@coding-agent/src/coding_agent/environment/docker_workspace_provider.py`:
- Around line 1102-1127: The clone and checkout subprocess.run calls (for
variables clone_command and checkout_command) must be hardened to avoid
interactive hangs and surface git output: set stdin=subprocess.DEVNULL and pass
an env dict that includes GIT_TERMINAL_PROMPT="0" (instead of env=None) so git
fails fast for auth prompts, and wrap each call in a try/except for
subprocess.CalledProcessError to capture the failed process output and call the
existing _add_setup_failure_output_notes helper with the exception and relevant
context (same pattern used elsewhere in this module), retaining
timeout=_GIT_OPERATION_TIMEOUT_SECONDS and check=True.
🪄 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: 3f396f3d-9a32-4d8e-96af-3187901ada92
📒 Files selected for processing (4)
coding-agent/src/coding_agent/environment/docker_workspace_provider.pycoding-agent/src/coding_agent/ui/http_server.pycoding-agent/tests/coding_agent/environment/test_docker_workspace_provider.pycoding-agent/tests/ui/test_http_server.py
💤 Files with no reviewable changes (1)
- coding-agent/src/coding_agent/ui/http_server.py
Summary
workspace_source.kind = gitbase_shabefore setup and agent containers start.gitin the remote workspace so later ADR-0024 diff/patch/publish work has Git metadataValidation
uv run pytest tests/coding_agent/environment/test_docker_workspace_provider.py -k "clones_git_source_before_setup_phase" -quv run pytest tests/ui/test_http_server.py -k "provisions_git_workspace_source" -quv run pytest tests/coding_agent/environment/test_docker_workspace_provider.py -quv run pytest tests/ui/test_http_server.py -k "workspace_source or git_workspace or docker_cloud_workspace or RemoteResultPublicationContract" -quv run pytest tests/coding_agent/environment/test_docker_workspace_provider.py tests/coding_agent/environment/test_docker_workspace_provider_transfer.py tests/ui/test_http_server.py tests/ui/test_http_server_workspace_transfer.py tests/cli/test_remote_client.py -k "git_workspace or workspace_source or docker_workspace or workspace_transfer or remote_run or RemoteResultPublicationContract" -quv run basedpyright --level error src/coding_agent/environment/docker_workspace_provider.py src/coding_agent/ui/http_server.py src/coding_agent/ui/schemas.py tests/coding_agent/environment/test_docker_workspace_provider.py tests/ui/test_http_server.pyuv run ruff format --check src/coding_agent/environment/docker_workspace_provider.py src/coding_agent/ui/http_server.py src/coding_agent/ui/schemas.py tests/coding_agent/environment/test_docker_workspace_provider.py tests/ui/test_http_server.pygit diff --checkSummary by CodeRabbit
New Features
Bug Fixes
Tests