[hotfix] orchestrator: strip /app/.venv pin from workspace uv env

_uv_subprocess_env inherited the image-baked VIRTUAL_ENV=/app/.venv (the
orchestrator gateway venv), so every workspace uv call (uv sync --extra dev
provisioning, dep-update uv lock, toolchain detect) warned on the NAS:
'VIRTUAL_ENV=/app/.venv does not match the project environment path .venv
and will be ignored'. uv already used the clone .venv via cwd discovery, so
stripping VIRTUAL_ENV + UV_PROJECT_ENVIRONMENT is noise-only and keeps
per-project isolation (each clone discovers its OWN .venv). Companion to the
agent-image VIRTUAL_ENV removal (7be10057); ships on orchestrator redeploy.

Verified: test_uv_subprocess_env_strips_app_venv_pin + the 3 clone-venv
resolution tests; ruff/mypy clean.
This commit is contained in:
Renn F
2026-06-30 11:05:22 +02:00
parent 7be10057d0
commit 9faf27631e
2 changed files with 22 additions and 1 deletions
@@ -19,7 +19,7 @@ from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from roboco.services.workspace import WorkspaceService
from roboco.services.workspace import WorkspaceService, _uv_subprocess_env
pytestmark = pytest.mark.skipif(
shutil.which("uv") is None, reason="uv CLI not installed"
@@ -132,3 +132,19 @@ async def test_clone_root_stays_on_default_after_worktree_add(clone: Path) -> No
)
assert _git(wt1, "branch", "--show-current").strip() == "feature/a"
assert _git(wt2, "branch", "--show-current").strip() == "feature/b"
def test_uv_subprocess_env_strips_app_venv_pin(tmp_path, monkeypatch):
# The orchestrator runs uv with cwd= a workspace clone, so the env it
# passes must NOT carry the image-baked VIRTUAL_ENV=/app/.venv (or the
# UV_PROJECT_ENVIRONMENT MCP pin) — uv would warn "does not match project
# .venv, will be ignored" on every sync. uv discovers the clone .venv via
# cwd either way; stripping is noise-only and keeps per-project isolation.
clone = tmp_path / "clone"
clone.mkdir()
monkeypatch.setenv("VIRTUAL_ENV", "/app/.venv")
monkeypatch.setenv("UV_PROJECT_ENVIRONMENT", "/app/.venv")
env = _uv_subprocess_env(clone)
assert "VIRTUAL_ENV" not in env
assert "UV_PROJECT_ENVIRONMENT" not in env
assert env["UV_PYTHON_INSTALL_DIR"] == str(clone / ".uv-python")