Repository navigation
maintenance: one location contract, and grade the canonical checkout - #232
Merged
Merged
Conversation
Heart answered "where is the workspace root" in nine places and they disagreed:
_common.sh hard-coded a path under $HOME; dashboard.py fell back to ~/Code
(NOT ~/Code/PyAutoLabs, so `root/"PyAutoBrain"` pointed at a path that does not
exist — a real bug, masked only because it is last in a candidate chain and an
earlier candidate catches it); eight checks tested whether a parent directory
was *literally named* after this workspace.
heart/_workspace.{py,sh} is now the single door, and it separates two concepts
that were conflated:
workspace_root() — "where am I": siblings, config, the Brain, the theme.
Follows the marker, so inside a bundle it is the bundle.
canonical_root() — the MAIN checkout: THE TREE HEALTH GRADES.
$PYAUTO_ROOT -> git --git-common-dir -> workspace root.
That split is the point. Health is a release gate, and the established rule is
that it grades the canonical checkout while `PYAUTO_ROOT=<worktree>` is the
documented opt-in for grading a branch. Following the resolver would have
inverted that default: run from a bundle, Heart reported 0 orphan / 5 dirty
where canonical reports 6 orphan / 7 dirty — the more flattering answer,
reached by the easy mistake of running Heart from the directory you are working
in. A gate must not relax because of cwd. Deriving canonical from git rather
than a literal keeps it true on any machine; wt_root() follows canonical too.
Every grading path is repointed: worktree_drift, manifest_drift,
profiling_drift, script_timing, version_skew, test_run, unit_test_timing,
workspace_testmode_timing, tick.sh's three guards, repo_state.sh, url_sweep.sh
and the three health_*.sh scripts (which resolve inside a subshell so sourcing
them from a shell profile does not export PYAUTO_ROOT into every interactive
shell).
With no PyAutoBrain in reach the shim degrades exactly as the surrounding code
already does, suffixing every reason string so a degraded answer never reads as
authoritative. It also tolerates a Brain that predates the resolver, so this can
merge before or after PyAutoBrain#391's half.
admin_jammy dropped from config/repos.yaml: it is not part of the PyAutoLabs
ecosystem. `excluded:` is documentation only — no leg consumes it — so removing
an entry cannot newly include anything.
Suite 1026 passed (baseline 1026). Acceptance: from inside a task bundle with no
environment set, Heart reproduces the canonical verdict exactly; PYAUTO_ROOT
still grades the bundle.
Part of PyAutoBrain#391 (phase 1a). smoke.py deliberately untouched — its flat
`pip install ./PyAutoFit ...` chain is phase 3.
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
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 PyAutoLabs/PyAutoBrain#391 (phase 1a). Changes no directory layout. Companion to PyAutoLabs/PyAutoBrain#392; mergeable in any order.
What was wrong
Heart answered "where is the workspace root" in nine places and they disagreed:
heart/_common.sh:31hard-coded a path under$HOMEheart/dashboard.py:172fell back to~/Code— not~/Code/PyAutoLabs— soroot/"PyAutoBrain"named a path that does not existThe
dashboard.pyfallback is a real bug, masked only because it is last in a candidate chain an earlier candidate satisfies. Reproduced before the fix:The split that matters
heart/_workspace.{py,sh}is now the single door, and it separates two concepts that were conflated:workspace_root()canonical_root()$PYAUTO_ROOT→git --git-common-dir→ workspace root.Health is a release gate. The established rule is that it grades the canonical checkout, with
PYAUTO_ROOT=<worktree>as the documented opt-in for grading a branch. Naively following the resolver would have inverted that default: run from a bundle, Heart reported0 orphan / 5 dirtywhere canonical reports6 orphan / 7 dirty— the more flattering answer, reached by the easy mistake of running Heart from the directory you happen to be working in. A gate must not relax because of cwd.Canonical is derived from git, not a literal, so it stays true on any machine. Verified in all four layouts (linked worktree, canonical, symlinked repo, non-repo → honest fallback).
wt_root()follows canonical too.Acceptance: from inside a task bundle with
env -u PYAUTO_ROOT -u PYAUTO_WT_ROOT -u PYAUTO_BRAIN, Heart reproduces the canonical verdict exactly (6 orphan / 0 missing / 7 dirty).PYAUTO_ROOT=<bundle>still grades the bundle (0 orphan / 5 dirty) — the opt-in survives.Scope note
Every grading path is repointed —
worktree_drift,manifest_drift,profiling_drift,script_timing,version_skew,test_run,unit_test_timing,workspace_testmode_timing,tick.sh's three guards,repo_state.sh,url_sweep.sh, and the threehealth_*.shscripts (which resolve inside a subshell so sourcing them from a shell profile doesn't exportPYAUTO_ROOTinto every interactive shell).That is wider than the four sites originally scoped. Converting only those would have left Heart internally disagreeing — which is the defect being fixed. Flag it if you'd rather the extra files were a separate PR.
Degradation and skew
With no PyAutoBrain in reach the shim degrades exactly as
dashboard.theme()already does, suffixing every reason string so a degraded answer never reads as authoritative. It also tolerates a Brain that predates this resolver — canonicalmainsetsPYAUTO_ROOTbut notPYAUTO_ROOT_REASON, which underset -uwas a crash. That is what makes the four PRs order-independent.admin_jammy
Dropped from
config/repos.yaml— not part of the PyAutoLabs ecosystem. Verifiedexcluded:is documentation only: no leg consumes it, so removing an entry cannot newly include anything.Verification
pytest tests→ 1026 passed (baseline 1026). Escape hatches spot-checked live:$PYAUTO_ROOT,$PYAUTO_WT_ROOT,$PYAUTO_BRAIN,$PYAUTO_AUDIT_ROOT,$HEART_STATE_DIRall still override.Deliberately untouched
heart/smoke.py— it drives a flatpip install ./PyAutoFit ./PyAutoArray …chain withcwd=organism_root, and (contrary to an early assumption) Heart runs that script locally, not only in CI. Adopting the marker rule would hand it a regrouped root it cannot honour. Phase 3.🤖 Generated with Claude Code
https://claude.ai/code/session_0161NLKVzbBMzhaBfjpGogor