Repository navigation
Description
Overview
Running the PyAutoBrain suite from a task worktree after source <wt>/activate.sh fails test_grouped_organ_consumers::test_hygiene_map_and_heart_board_find_grouped_checkouts: activate.sh exports the organ-path variables (PYAUTO_ROOT, PYAUTO_BRAIN, PYAUTO_MIND, PYAUTO_HEART, PYAUTO_HANDS, PYAUTO_TASK) and _hygiene_repos.candidate_map_paths() honours PYAUTO_MIND as a hard override, so the test resolves the worktree's Mind instead of its tmp tree. CI has none of these variables, so it is green there; the PyAutoBrain#676 ship had to run with env -u PYAUTO_MIND.
Plan
- Add one autouse fixture to
tests/conftest.pythat clears the organ-path variablesactivate.shexports, so every test starts from CI's environment. - Tests that need one of them keep setting it themselves (autouse runs first, so their
setenvwins). - Prove it: the full suite passes with
activate.shsourced and without it, no deselects. - Tier + merge mode:
effective level: supervised; merge mode: auto-merge on green(declaredConsequence: notify).
Detailed implementation plan
Affected Repositories
- PyAutoBrain (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoBrain | main | clean |
Suggested branch: feature/brain-tests-hermetic-worktree-env
Implementation Steps
tests/conftest.py: new autouse fixture_no_task_worktree_paths(monkeypatch)deletingPYAUTO_TASK,PYAUTO_ROOT,PYAUTO_BRAIN,PYAUTO_MIND,PYAUTO_HEART,PYAUTO_HANDS(raising=False), with a docstring citingbin/worktree.shand this issue.- Run
pytest tests/with the task worktree'sactivate.shsourced, and again in a clean env; both all-pass. - Ship via
/ship_library, auto-merge on green.
Key Files
tests/conftest.py— suite-wide isolation fixturesbin/worktree.sh:70-75— the exports (unchanged)agents/conductors/hygiene/_hygiene_repos.py—candidate_map_paths(unchanged; its override is by design)
Original Prompt
Click to expand starting prompt
Brain test suite is not hermetic against a task worktree's activate.sh organ paths
Type: bug
Target: PyAutoBrain
Repos:
- PyAutoBrain
Difficulty: small
Autonomy: safe
Priority: normal
Status: formalised
Consequence: notify
Witness: with a task worktree'sactivate.shsourced (PYAUTO_ROOT, PYAUTO_BRAIN, PYAUTO_MIND, PYAUTO_HEART, PYAUTO_HANDS, PYAUTO_TASK exported),pytest tests/in PyAutoBrain passes in full, includingtests/test_grouped_organ_consumers.py::test_hygiene_map_and_heart_board_find_grouped_checkouts; CI stays green
Review-minutes: 0
Unattended: ready
Lane: any
Bug
Running the PyAutoBrain suite from a task worktree after source <wt>/activate.sh
(as start_library / ship_library instruct) fails
tests/test_grouped_organ_consumers.py::test_hygiene_map_and_heart_board_find_grouped_checkouts:
_hygiene_repos.resolve_map() returns $PYAUTO_MIND/repos.yaml (the worktree's
Mind) instead of the test's tmp tree. candidate_map_paths() treats PYAUTO_MIND
as a hard override by design; the test only sets PYAUTO_ROOT. CI has none of
these variables, so it passes there; the gap shows only locally, and it forced
env -u PYAUTO_MIND during the PyAutoBrain#676 ship (2026-11-18). The same failure
reproduces on origin/main.
bin/worktree.sh writes activate.sh exporting PYAUTO_TASK, PYAUTO_ROOT,
PYAUTO_BRAIN, PYAUTO_MIND, PYAUTO_HEART and PYAUTO_HANDS.
Fix
tests/conftest.pygains one autouse fixture thatmonkeypatch.delenvs those
organ-path variables (raising=False), matching CI. Tests that need one set it
themselves (autouse runs first, so theirsetenvstill wins). Keep it
alongside the existing isolation fixtures, with a docstring saying why.- Run the full suite twice: plain, and with a task worktree's
activate.sh
sourced. Both must pass with no deselects.
Activity
Jammy2211 commentedon Nov 18, 2026
Shipped in #678 (merged). New autouse fixture
_no_task_worktree_pathsintests/conftest.pyclears the organ-path variables a task worktree'sactivate.shexports. Full suite: 2370 passed, 1 skipped, both withactivate.shsourced and without.