Repository navigation
Description
Overview
find_script in the Cortex conductor walks (root, *root.resolve().parents) — the start path unresolved, its ancestors resolved — so inside a task worktree (where the Cortex checkout is a symlink) it returns the canonical checkout's script instead of the worktree's. This makes the ancestor walk symlink-preserving, restores the deleted witness test under its original name, and adds a tmp_path regression test.
Part of bundle pyautobrain-worktree-guards (one issue + one PR per member).
Plan
- find_script walks ancestors without following symlinks:
root.resolve().parents→root.absolute().parents. - Restore the deleted test verbatim with its ORIGINAL NAME (
git show d04e3a0^:tests/test_cortex_conductor.py), assertion unweakened — keeps the prompt's witness valid. First confirm its fixture contract still holds (skeleton has no scripts/; Cortex ships tests/fixtures/skeleton); adapt only fixture plumbing if the rewrite moved helpers, never the assertion. - New tmp_path regression test: real/scripts/cortex.py + real/tests/fixtures/skeleton/, wt/PyAutoCortex -> real symlink; assert find_script(wt/PyAutoCortex/tests/fixtures/skeleton) == wt/PyAutoCortex/scripts/cortex.py. Red before fix, green after.
- Run: python -m pytest tests/test_cortex_conductor.py -q (from the task worktree root too), then full suite.
Tier: notify — merge mode: auto-merge on green (in-turn wait, then /prm close-out). Brain has no PR test CI, so "green" = full Brain pytest suite passing locally in the worktree, reported before merge.
Detailed implementation plan
Affected Repositories
- PyAutoBrain (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoBrain | main | clean |
Suggested branch: feature/cortex-find-script-symlink
Shared bundle worktree: ~/Code/PyAutoLabs-wt/pyautobrain-worktree-guards/ (PyAutoBrain only); members worked sequentially 1 → 4, each branch cut from origin/main. Human approved running in parallel with Codex's dashboard-minimal-text claim on PyAutoBrain.
Findings
the named test was deleted in d04e3a0 (2026-09-12 conductor rewrite); the mismatch remains in agents/conductors/cortex/_cortex.py find_script (~L121): it iterates (root, *root.resolve().parents) — given root unresolved, ancestors resolved. The conductor's convention elsewhere keeps caller paths unresolved and resolves only for identity keys (resolve_root, load_cortex cache key, _repo_paths dedup). Only caller is load_cortex, which doesn't need a resolved return.
Implementation Steps
- find_script walks ancestors without following symlinks:
root.resolve().parents→root.absolute().parents. - Restore the deleted test verbatim with its ORIGINAL NAME (
git show d04e3a0^:tests/test_cortex_conductor.py), assertion unweakened — keeps the prompt's witness valid. First confirm its fixture contract still holds (skeleton has no scripts/; Cortex ships tests/fixtures/skeleton); adapt only fixture plumbing if the rewrite moved helpers, never the assertion. - New tmp_path regression test: real/scripts/cortex.py + real/tests/fixtures/skeleton/, wt/PyAutoCortex -> real symlink; assert find_script(wt/PyAutoCortex/tests/fixtures/skeleton) == wt/PyAutoCortex/scripts/cortex.py. Red before fix, green after.
- Run: python -m pytest tests/test_cortex_conductor.py -q (from the task worktree root too), then full suite.
Original Prompt
Click to expand starting prompt
Cortex conductor test resolves through the worktree symlink and fails in every task worktree
Type: bug
Target: PyAutoBrain
Repos:
- PyAutoBrain
Difficulty: small
Autonomy: safe
Priority: low
Status: formalised
Consequence: notify
Witness:python3 -m pytest PyAutoBrain/tests/test_cortex_conductor.py::test_a_fixture_tree_finds_the_schema_its_checkout_shipspasses from inside a task worktree root created byworktree_create(where the Cortex checkout is a symlink to the canonical checkout) as well as from the canonical root
Review-minutes: 0
Unattended: ready
Symptom (observed 2026-09-02, task batch-review-integration)
Inside ~/Code/PyAutoLabs-wt/<task>/, test_a_fixture_tree_finds_the_schema_its_checkout_ships asserts
_cortex.find_script(skeleton) == cortex_root()/"scripts"/"cortex.py" and gets
the canonical checkout's scripts/cortex.py instead: find_script resolves the symlinked Cortex checkout
entry to its real path while cortex_root() returns the unresolved worktree path. Same test
passes on the canonical checkout, so every Brain task ships with one deselected test and every subagent has to
be told it is an artefact.
Fix direction
Compare resolved paths on both sides (Path.resolve() in the test, or make find_script and cortex_root
agree on resolution), whichever the conductor's own convention is. Do not weaken the assertion.
Activity
Jammy2211 commentedon Oct 6, 2026
Shipped
pyautobrain-worktree-guards; tiernotify. No workspace impact (Brain tooling only); no release obligation.Closed by /prm close-out.