Skip to content

fix(workspace): let the worktree import hook serve the canonical venv - #1362

Merged
rennf93 merged 1 commit into
slavefrom
fix/worktree-import-hook-canonical-venv
Nov 3, 2026
Merged

rennf93 merged 1 commit into
slavefrom
fix/worktree-import-hook-canonical-venv

Conversation

@rennf93

@rennf93 rennf93 commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to trail #65 (change 213): since #1355, make codegen in a task worktree imports the clone root's code instead of the worktree's.

What happened

On the live run of 2026-11-03, task f28b1d75 (PR #1359, two doc files) went round the PM review six times:

  1. Every push runs the project's codegen_command (make codegen for roboco-api) before it goes out (git.py _run_codegen_and_commit).
  2. fix(workspace): keep a worktree's path out of the shared venv's shebangs #1355 runs a worktree's commands in the workspace container with UV_PROJECT_ENVIRONMENT set to readlink -f .venv, which is the clone root's venv (workspace_container.py:89,138). So sys.prefix is <clone>/.venv.
  3. The import hook only acts when sys.prefix is <clone>/.worktrees/<id>/.venv (worktree_imports.py _worktree_whose_venv_is), so it left sys.path alone and the script imported the clone root's roboco.
  4. fe-doc's clone root sits on slave at 3f96eba (2026-08-31). Its codegen wrote agents/prompts/_generated/verbs.md as blob c3870cb3. The PR base, slave and master all hold eca32f19.
  5. fe-doc committed "regenerate generated artifacts" on every i_documented, fe-pm sent it back ("PR diff holds only CHANGELOG.md and docs/positioning/..."), and fe-dev-2 reverted. PR [f28b1d75] Write ETR positioning note and CHANGELOG entry #1359 has 6 of each.

Fix

When sys.prefix is a clone root's own .venv, the hook now points the clone root's sys.path entries at the worktree that holds the working directory. The container already runs the command there (-w is the worktree). A process outside .worktrees/<id>, or a prefix that is not that clone's .venv, is left alone as before. A vanished working directory counts as none.

Behavior change: code run in a worktree on the canonical venv imports the worktree's source. Nothing else changes. #1355 stays as it is, since reverting it brings back worktree paths in the shared venv's shebangs.

Not in this PR: why the clone roots stopped fast-forwarding to slave after Aug 31. I didn't check.

Verified

  • New tests in tests/unit/services/test_workspace_worktree_imports.py: a parametrized one for the canonical prefix (6 cases), and one that runs a script in a worktree through the clone root's venv python and checks it imports the worktree's package. On the old hook, 3 of them fail (3 failed, 17 passed). With the fix: 20 passed.
  • pytest tests/unit/services/ -k 'workspace or worktree': 331 passed, 4266 deselected.
  • ruff check and ruff format --check clean, mypy clean on both files, xenon exits 0, vulture and bandit report nothing, verify_codebase_map.py reports 0 errors and 0 warnings, and _complete_map.md is in sync.

#1355 runs a worktree's commands in the workspace container with
UV_PROJECT_ENVIRONMENT set to the clone root's venv, so sys.prefix is
<clone>/.venv and the import hook left sys.path alone. make codegen then
imported the clone root's Aug 31 roboco: fe-doc committed a stale verb
table into every push of f28b1d75 and fe-pm bounced the PR six times.

When sys.prefix is a clone root's own .venv, the hook now points the
clone root's sys.path entries at the worktree the process runs in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Entire-Checkpoint: 01M6FQR4576061DZE7ZB7MEBX7
@github-project-automation github-project-automation Bot moved this to Backlog in RoboCo Kanban Nov 3, 2026
@github-actions github-actions Bot added documentation Docs, README, CHANGELOG, governance files tests Test suite changes labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request on RoboCo!

Quick checklist before review (most of these are enforced by CI, but worth a glance):

  • make quality — ruff format check, ruff check, mypy, pytest (≥80% coverage), and the rest of the gate
  • Panel changes pass pnpm lint and pnpm exec tsc --noEmit (run from panel/)
  • No # noqa / # type: ignore shortcuts; pre-existing violations in touched files are fixed
  • Added an entry under ## [Unreleased] in CHANGELOG.md
  • Signed the CLA (the bot will prompt you on this PR)
  • Signed your commits — master requires verified signatures (SSH signing setup)
  • Updated any affected docs under docs/

See CONTRIBUTING.md for the full workflow and the Code of Conduct for the community standards we follow.

Welcome aboard — a maintainer will review shortly.

@rennf93 rennf93 changed the title fix/worktree-import-hook-canonical-venv fix(workspace): let the worktree import hook serve the canonical venv Nov 3, 2026
@rennf93
rennf93 marked this pull request as ready for review November 3, 2026 03:39
@rennf93
rennf93 merged commit 43045c3 into slave Nov 3, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in RoboCo Kanban Nov 3, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

documentation Docs, README, CHANGELOG, governance files tests Test suite changes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant