Description
Overview
pyauto-brain intake --apply classify --file <raw.md> crashes when PYAUTO_MIND points at a temporary PyAutoMind worktree under PyAutoLabs-wt (the doctrine route for Mind writes). _memory_home(mind) treats mind.parent as the workspace root; under the worktree root that parent holds several task folders, each with its own PyAutoMind, so bootstrap_repo_path raises ValueError: PyAutoMind: ambiguous checkouts and the write fails. The dry run works, and organ-targeted prompts skip memory citations, so only --apply on a non-organ target fails. Workaround: export PYAUTO_MEMORY.
Plan
- Resolve PyAutoMemory from the workspace root (
pyauto_root(), which honoursPYAUTO_ROOTand the.pyauto-rootmarker) instead of the Mind checkout's parent, after the existingPYAUTO_MEMORYoverride. This matches the shellresolve_memory. - If resolution fails, file the prompt with no citations and say why on stderr, rather than crashing the write.
- Drop the
mindargument that no longer affects resolution. - Add a regression test for the apply path with a Mind whose parent holds several sibling
*/PyAutoMindcheckouts, and a test for the degrade path. - Keep the test suite hermetic: tests that file into a temporary Mind must never read a real PyAutoMemory on a developer box.
- Tier: notify.
pyauto-brain merge-modereportseffective level: supervised; merge mode: auto-merge on green; the plan the human approved for this session leaves the merge to the human (/prm).
Detailed implementation plan
Affected Repositories
- PyAutoBrain (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./organs/PyAutoBrain | main (2 behind origin/main) | clean |
Suggested branch: feature/intake-memory-workspace-root
Worktree root: ~/Code/PyAutoLabs-wt/intake-memory-workspace-root/
PyAutoBrain is claimed by digest-review-table (#718, PR #719) and parked-hold-grace (#720). Neither branch touches the files below; starting needs human-approved coordination.
Implementation Steps
agents/conductors/intake/_intake.py,_memory_home: take no argument. ReturnPath($PYAUTO_MEMORY)when set, elserepo_path(pyauto_root(), "PyAutoMemory")(importpyauto_rootfromagents/_pyauto_root.py). Wrap the resolution intry/except (ValueError, OSError): print one stderr line naming the reason and returnNone. ReturnNonewhen the path is not a directory, as now.memory_citations: drop themindparameter; update the call inwrite_prompt.tests/test_intake_memory.py:- regression test: a Mind directory whose parent holds two or more sibling
*/PyAutoMindcheckouts, a separate workspace root carrying.pyauto-root, a Mind withrepos.yamland a fixture PyAutoMemory;PYAUTO_ROOTat that root,PYAUTO_MEMORYunset; runmain()with--apply classify --fileon a non-organ target; assert the prompt is written with aMemory:line citing the fixture page. Confirm it fails onmainbefore the fix. - degrade test:
PYAUTO_ROOTpointed at the ambiguous directory; the write succeeds with noMemory:line. - existing tests: set
PYAUTO_ROOT=tmp_path(the fixture Memory sits beside the fixture Mind there); update the two directmemory_citations(mind, ...)calls.
- regression test: a Mind directory whose parent holds two or more sibling
tests/test_grouped_organ_consumers.py: call_memory_home()without the Mind argument.tests/conftest.py: autouse fixture pointingPYAUTO_MEMORYat a nonexistent path, so a test that files into a temporary Mind reads no real PyAutoMemory unless it opts in by deleting the variable.- Run the full test suite.
Key Files
agents/conductors/intake/_intake.py—_memory_home,memory_citations,write_promptagents/_pyauto_root.py—pyauto_root()(read only)agents/_repo_paths.py—repo_path,bootstrap_repo_path(read only)tests/test_intake_memory.py,tests/test_grouped_organ_consumers.py,tests/conftest.py
Out of scope
looks-shipped and reconcile --strong default --root to mind.resolve().parent (_intake.py, two call sites). They do not crash (_shipped.local_repos catches the error), but with a worktree Mind they scan only the Mind, and with the canonical Mind they see the organ family only. Separate task.
Original Prompt
Click to expand starting prompt
intake --apply crashes on memory citations when the Mind is a worktree
Type: bug
Target: PyAutoBrain
Repos:
- PyAutoBrain
Difficulty: small
Autonomy: safe
Priority: normal
Status: formalised
Consequence: notify
Witness: with a Mind directory whose parent holds several sibling*/PyAutoMindcheckouts,intake --apply classify --filewrites the prompt with aMemory:line from the workspace-root PyAutoMemory (unit test pins it; the test fails on main before the fix)
Review-minutes: 0
Unattended: ready
Lane: any
Source: human report in a Science session, 2026-11-25. Request copied verbatim below; the approved plan follows it.
PyAutoBrain bug (repo: ~/Code/PyAutoLabs/organs/PyAutoBrain). Follow ~/Code/PyAutoLabs/AGENTS.md and the PyAutoLabs dev workflow (plan first, wait for approval before editing source).
Symptom, observed 2026-11-25: pyauto-brain intake --apply classify --file <raw.md> crashes when PYAUTO_MIND points at a temporary PyAutoMind worktree created under ~/Code/PyAutoLabs-wt (the doctrine route for Mind writes: git worktree add --detach ~/Code/PyAutoLabs-wt/<name> origin/main). The dry run (no --apply) works; only the write path fails.
Traceback tail:
agents/conductors/intake/_intake.py:1036 write_prompt
agents/conductors/intake/_intake.py:933 memory_citations
agents/conductors/intake/_intake.py:919 _memory_home -> repo_path(mind.parent, "PyAutoMemory")
agents/_repo_paths.py:203 repo_path -> manifest_paths(root) -> manifest_text(root) -> bootstrap_repo_path(Path(root), 'PyAutoMind')
agents/_repo_paths.py:166 ValueError: PyAutoMind: ambiguous checkouts: ~/Code/PyAutoLabs-wt/digest-review-table/PyAutoMind, ~/Code/PyAutoLabs-wt/likelihood-lifecycle-p5f/PyAutoMind, ~/Code/PyAutoLabs-wt/parked-hold-grace/PyAutoMind
Cause: _memory_home(mind) treats mind.parent as the workspace root. For a worktree under /Code/PyAutoLabs-wt the parent holds many task folders each with their own PyAutoMind, so bootstrap_repo_path raises instead of resolving. Workaround that worked: export PYAUTO_MEMORY=/Code/PyAutoLabs/organs/PyAutoMemory.
Wanted: memory citations should resolve PyAutoMemory from the real workspace root (agents/_pyauto_root.py pyauto_root(), which honours PYAUTO_ROOT and the .pyauto-root marker) rather than from the Mind checkout's parent, or at least degrade to "no citations" instead of crashing the write, as the docstring of _memory_home ("or None when it is absent") implies. Add a regression test that runs the apply path with a Mind directory whose parent contains several sibling */PyAutoMind checkouts. Check whether other callers of repo_path(mind.parent, ...) in _intake.py have the same assumption.
Findings (read-only investigation, 2026-11-25)
- Reproduced:
_memory_home(<Mind worktree under PyAutoLabs-wt>)raises the ValueError above; the canonical Mind resolves. - Only non-organ targets reach
memory_citations(_cites_memory(target)), so organ-targeted prompts file without crashing. - The lookup is wrong even when it does not raise: with exactly one task folder holding a PyAutoMind, it would read that task's feature-branch
repos.yaml. _intake.py:919is the onlyrepo_path(mind.parent, ...).
Approved plan (human approved 2026-11-25)
_memory_home:PYAUTO_MEMORYoverride first, thenrepo_path(pyauto_root(), "PyAutoMemory"), matching the shellresolve_memory.- Catch
ValueError/OSErrorfrom resolution, returnNone, print one stderr line with the reason: no citations rather than a crashed write. - Drop the unused
mindargument from_memory_homeandmemory_citations(one source call site, the test call sites,tests/test_grouped_organ_consumers.py). - Regression test in
tests/test_intake_memory.py: a Mind directory whose parent holds several sibling*/PyAutoMindcheckouts, a separate marked workspace root with a fixture PyAutoMemory,--apply classify --filerun throughmain(); the prompt is written with aMemory:line from the workspace Memory. It must fail on main first. - Degrade test:
PYAUTO_ROOTpointed at the ambiguous directory; the write succeeds with noMemory:line. - The existing memory tests set
PYAUTO_ROOT=tmp_path; aconftest.pyautouse guard pointsPYAUTO_MEMORYat a nonexistent path unless a test opts in, so a test filing into a tmp Mind never reads the real PyAutoMemory on a developer box.
Out of scope (separate task, human decision)
looks-shipped and reconcile --strong default --root to mind.resolve().parent (_intake.py:4411, :4441). _shipped.local_repos catches the error, so they do not crash, but with a worktree Mind they scan only the Mind, and with the canonical Mind they see organs/ only (15 checkouts, no libraries; the workspace root has 54).
Activity