Repository navigation
maintenance: resolve the workspace root by marker, not by sibling probe - #392
Merged
Merged
Conversation
`_is_root()` decided a directory was the workspace root when it held any of SIBLING_ORGANS, without checking it was a checkout. Group the organs into an `organs/` directory and `<root>/organs` itself satisfies that test, so the root resolves one level too deep — silently, because every consumer degrades rather than raises. Insert a `.pyauto-root` marker walk ABOVE that probe rather than replacing it: 1 $PYAUTO_ROOT, now validated (the reason says whether a marker confirmed it) 2 nearest ancestor holding .pyauto-root <- new, authoritative 3 parent, if it holds a sibling organ <- unchanged, demoted 4 parent regardless <- unchanged Keeping 3 is load-bearing: a remote session often checks out a single repo with no root above it and therefore no marker. Demoting rather than deleting means no currently-correct resolution can become wrong — the change can only add correctness, and CI (which lays repos out side by side with no marker) keeps resolving by the probe. The shell twin takes the identical order and exports PYAUTO_ROOT_REASON and PYAUTO_ROOT_MARKER; the module's docstring requires the two to agree, and the tests assert it on every case by running both. worktree_create now writes a marker into each new task bundle: its sibling symlink loop does not glob dotfiles, so the canonical marker was never propagated and every bundle would otherwise be unmarked. Witness: tests/test_workspace_root.py builds nested fixtures and pins the defect — `organs/` tests true under the old rule, and the marker moves the answer to the real root. Red before (7 failed), green after (11 passed). Full suite 929 passed. Part of PyAutoBrain#391 (phase 1a). No directory layout changes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0161NLKVzbBMzhaBfjpGogor
This was referenced Sep 18, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #391 (phase 1a). Changes no directory layout. Companions: PyAutoHeart, PyAutoHands, PyAutoMind — all on the same branch name, mergeable in any order (see Merge order).
The defect
agents/_pyauto_root.py:59decided a directory was the workspace root when it held any ofSIBLING_ORGANS, without checking it was a checkout. Group the organs intoorgans/and<root>/organsitself satisfies that test — the root resolves one level too deep, silently, because every consumer degrades rather than raises.Same fixture, old resolver vs new:
The change is additive
$PYAUTO_ROOTverbatim$PYAUTO_ROOT, validated — the reason says whether a marker confirmed it.pyauto-root← newKeeping step 3 is load-bearing. A remote session often checks out a single repo with no root above it and therefore no marker; Brain CI lays Brain/Mind/Cortex side by side the same way. Demoting rather than deleting means no currently-correct resolution can become wrong — the change can only add correctness, and CI keeps resolving by the probe. A marker-only assertion would have gone red in CI.
bin/_pyauto_root.shtakes the identical order and exportsPYAUTO_ROOT_REASONandPYAUTO_ROOT_MARKER. The module docstring requires the two halves to agree, so every test asserts it by running both.bin/worktree.sh::worktree_createnow writes a marker into each new task bundle — its sibling-symlink loop doesn't glob dotfiles, so the canonical marker was never propagated and bundles would otherwise be unmarked.Witness
tests/test_workspace_root.pybuilds nested fixtures intmp_pathand pins the defect explicitly:organs/tests true under the old rule, and writing the marker moves the answer to the real root.7 failed, 4 passed11 passed929 passed, no regressionsKnown limitation, stated deliberately
Step 3 is still wrong for a nested workspace with no marker, and a test pins that. It is the price of never breaking the remote single-repo case. The consequence matters for phase 3: whoever performs the actual regroup must create the marker in the same commit, or resolution silently goes one level deep again.
Merge order
Any. PyAutoHeart/PyAutoHands ship shims that tolerate a Brain predating this resolver (their
set -ushell path would otherwise hit an unboundPYAUTO_ROOT_REASON), so the four PRs are not a lockstep.Note for the issue
This makes the resolver a locator, not a writer's or grader's root: the reason strings say which rule fired, never that the root contains the caller. Three consumers needed that distinction during this phase — PyAutoMind's
--write(a bundle with a symlinked Brain resolves to canonical), PyAutoHeart's health grading, and the dashboard regen. Downstream guards handle it; this module is unchanged by it.🤖 Generated with Claude Code
https://claude.ai/code/session_0161NLKVzbBMzhaBfjpGogor