Skip to content

maintenance: one location contract for root, repo, main and task checkouts #391

Closed

Description

@Jammy2211

Overview

The organism has no single answer to "where is the workspace root", and the six private answers it does have already disagree today — independent of any directory regroup. This is the prerequisite for phase 3 (grouping the science repos into lens/ galaxy/ fit/ cti/ reduce/ with the organs staying flat), but it is worth landing on its own merits.

Phase 1a of the workspace regroup. Changes no directory layout. Scoped to 4 organ repos; the mechanical fan-out that consumes this resolver is phase 2 (draft/maintenance/pyautobrain/workspace_resolver_fanout.md).

Plan

  • Add a .pyauto-root marker at the workspace root and make both resolvers walk up to it — inserted above the existing sibling-organ probe, never replacing it, so no currently-correct resolution can become wrong.
  • Validate $PYAUTO_ROOT instead of taking it verbatim; today it bypasses every check.
  • Make Heart, Hands and Mind consume that one resolver in place of their ~13 private answers.
  • Make repos_sync.py drift-check in both directions — it is currently blind each way.
  • Commit the location inventory the later phases need as data, not a one-off sweep.
Detailed implementation plan

Affected Repositories

  • PyAutoBrain (primary) — the resolver pair
  • PyAutoHeart, PyAutoHands, PyAutoMind — adopt it

Branch Survey

Repository Current Branch Dirty?
./PyAutoBrain main clean
./PyAutoHeart main clean
./PyAutoHands main clean
./PyAutoMind main clean

worktree_check_conflict workspace-location-contracts PyAutoBrain PyAutoHeart PyAutoHands PyAutoMind → exit 0.

Suggested branch: feature/workspace-location-contracts

1. The resolver

PyAutoBrain/agents/_pyauto_root.py resolves in three steps and step 2 is the defect: _is_root() (:59) returns True for any directory containing one of SIBLING_ORGANS, without checking it is a checkout. Move the organs into an organs/ directory and PyAutoLabs/organs itself tests True — the root resolves one level too deep, silently, and every root / <repo> join below it misses.

The change is additive:

Today After
1 $PYAUTO_ROOT verbatim $PYAUTO_ROOT, validated — the reason string says whether the marker confirmed it
2 parent, if it holds a sibling organ walk up for .pyauto-root ← new, authoritative
3 parent regardless, "unverified" parent, if it holds a sibling organ (unchanged, demoted)
4 — parent regardless, "unverified"

Keeping the sibling probe as a fallback is deliberate: a remote/web session often checks out a single repo with no root above it and therefore no marker. Demoting rather than deleting means the change can only add correctness.

PyAutoBrain/bin/_pyauto_root.sh takes the identical order — the module docstring requires the two to agree. Model the walk-up on autolens_profiling's profiling_root(), which already walks to a ruff.toml marker and is the one layout-independent path helper in the workspace.

Preserve the module's existing workspace_root_reason() contract: callers that degrade report why, so "resolved to a directory that does not exist" stays distinguishable from "resolved fine, found nothing".

2. Organs adopt it

Replace with the shared resolver:

  • PyAutoHeart/heart/_common.sh:31 — hardcodes $HOME/Code/PyAutoLabs
  • PyAutoHeart/heart/dashboard.py:171-179,188 — falls back to ~/Code, not ~/Code/PyAutoLabs
  • PyAutoHeart/heart/checks/worktree_drift.py:46-51 — literal _p3.name == "PyAutoLabs" test
  • PyAutoHeart/scripts/health_audit.sh:25, health_sync.sh:57, health_release.sh:31, heart/tick.sh:31
  • PyAutoHands/autohands/board.py:56-78 — also ~/Code
  • PyAutoHands/autohands/run_all.py:37 — fixed parents[2]
  • PyAutoHands/pre_build.sh:20 — fixed depth
  • PyAutoMind/scripts/spawn.py:507 — fixed parents[2]
  • PyAutoMind/scripts/repos_sync.py:1663

3. Bidirectional drift

Folds in the separately-filed draft/maintenance/pyautomind/autolens_jax_joss_manifest_gap.md; retire it on merge.

  • Declared-but-missing is silently skipped — repos_sync.py:882 (CLAUDE pointer checks), :1318 (origin checks), :1607 (codex hook checks). After any move these pass while checking nothing. A successful check that means reduced coverage is the failure to remove.
  • On-disk-but-undeclared is silence — repos_sync walks the manifest and asks whether each entry is present, so it structurally cannot see a checkout absent from repos.yaml.

These are independent of presence on disk: admin_jammy is a genuine manifest entry that is deliberately never cloned, so "missing" must be expressible as intentional rather than as drift.

4. Inventory as data

Commit the worktree / dependency-symlink / runtime-import-location inventory the later phases need, rather than re-deriving it by sweep.

Testing / Witness

  • A pytest fixture builds a nested workspace (lens/PyAutoLens beside a flat PyAutoBrain) and asserts both entry points return the true root, not the family directory. Must be red before the fix and green after.
  • repos_sync.py --check exits non-zero on a declared-but-missing repo and on an undeclared on-disk checkout; today both pass.
  • Existing coverage must stay green: PyAutoMind/tests/test_session_bootstrap.py, tests/test_session_hook_sync.py.

Key Files

  • PyAutoBrain/agents/_pyauto_root.py, PyAutoBrain/bin/_pyauto_root.sh
  • PyAutoHeart/heart/_common.sh, dashboard.py, checks/worktree_drift.py
  • PyAutoHands/autohands/board.py, run_all.py, pre_build.sh
  • PyAutoMind/scripts/repos_sync.py, spawn.py

Explicitly not in this phase

The physical move, the repos.yaml path: field, the ~12 root enumerators, worktree.sh, and the smoke_install.sh flat pip chain. Do not introduce a universal root / manifest.path rule here — the ordering hazard named by the independent Codex review is that such a rule breaks CI immediately (whose trees are legitimately flat) and misroutes task worktrees later.

Context

Phase 1b (workspace-dead-weight-cleanup) shipped 2026-09-18 — PyAutoBrain#390, PyAutoMind#413 — and removed ~80 worktree paths this phase no longer has to reason about.

Heart at start: RELEASE VALIDATION not release-ready and INSTALL VERIFY warnings, both pre-existing and unrelated; this is not an --auto run.

Original Prompt

Click to expand starting prompt
# Workspace location contracts: one resolver for root, repo, main and task checkouts

Type: maintenance
Target: PyAutoBrain
Repos:
- PyAutoBrain
- PyAutoHeart
- PyAutoHands
- PyAutoMind
Difficulty: large
Autonomy: supervised
Priority: high
Status: formalised
Consequence: judge
Witness: a pytest fixture builds a nested workspace (lens/PyAutoLens beside a flat PyAutoBrain) and asserts the resolver returns the TRUE root, not the family directory, for both the Python and the shell entry point; and repos_sync.py --check exits non-zero when a manifest-declared repo's directory is absent (today it passes silently, checking nothing).
Review-minutes: 25
Unattended: needs-slicing

Phase 1a of the PyAutoLabs workspace regroup. Changes NO directory layout.

## Why

The workspace root has 45 entries and is hard to navigate. The human approved (2026-09-18, in chat)
regrouping the science repos into per-family subfolders `lens/ galaxy/ fit/ cti/ reduce/`, leaving the
8 organs plus PyAutoArray, PyAutoScientist and pyautolabs.github.io flat at root. Lowercase family
names were chosen because none collides with an importable package name; the human explicitly rejected
naming a group after its library (PyAutoLens/PyAutoLens) because $ROOT/PyAutoLens would still resolve
to an existing directory after the move, converting loud failures into silent wrong-path ones.

Three read-only sweeps plus an independent Codex (gpt-6-astra) review, all 2026-09-18, established
that the blocking problem is not the move — it is that the organism has no single answer to where
anything is. Six organs disagree TODAY: PyAutoHeart/heart/_common.sh:31 hardcodes $HOME/Code/PyAutoLabs;
PyAutoHeart/heart/dashboard.py:171 and PyAutoHands/autohands/board.py:56 fall back to ~/Code (not
~/Code/PyAutoLabs); PyAutoHeart/heart/checks/worktree_drift.py:46 tests `_p3.name == "PyAutoLabs"`;
PyAutoHands/autohands/run_all.py:37 and PyAutoMind/scripts/spawn.py:507 use fixed parents[N]. Only
PyAutoBrain uses the canonical _pyauto_root pair, and that pair decides the root by probing for a
sibling organ directory (agents/_pyauto_root.py:59) without checking it is a checkout.

## Scope

1. Define four SEPARATE concepts and one API, rather than one conflated "root":
   workspace-root discovery / repo identity / main-checkout location / task-checkout location.
   This separation is the review's central recommendation: the dangerous end state is "organs resolve
   by sibling arithmetic, science resolves through a manifest". Placement must be a location property,
   not a second classification system. Note PyAutoArray stays flat but is a library, not an organ.
2. Add a `.pyauto-root` marker file at the workspace root and make root discovery walk up to it instead
   of probing SIBLING_ORGANS. Model it on autolens_profiling's profiling_root(), which already walks up
   to a ruff.toml marker and is the one layout-independent path helper in the workspace. Keep
   $PYAUTO_ROOT as an override but validate it (today _pyauto_root.py:76 bypasses every check, so a
   wrong value exported by a hook is accepted silently).
3. Make PyAutoHeart, PyAutoHands and PyAutoMind consume that single resolver instead of their six
   private answers.
4. Make the drift check work in BOTH directions, folding in the separately-filed
   `draft/maintenance/pyautomind/autolens_jax_joss_manifest_gap.md` (retire it on merge):
   - declared-but-missing is silently SKIPPED at repos_sync.py:882 (CLAUDE pointer checks),
     :1318 (origin checks) and :1607 (codex hook checks) — after any move these would pass while
     checking nothing. A successful check that means reduced coverage is the failure to remove.
   - on-disk-but-undeclared is SILENCE: repos_sync walks the manifest and asks whether each entry is
     present, so it structurally cannot see a checkout absent from repos.yaml. That is the
     manifest_gap defect, and it survived the removal of its example (autolens_jax_joss).
   Note the two are independent of presence on disk: admin_jammy is a genuine manifest entry that is
   deliberately never cloned, so "missing" must be expressible as intentional rather than as drift.
5. Record the inventory the later phases need, as committed data rather than a one-off sweep:
   existing worktrees, dependency symlinks, and runtime import locations.


## Not in this phase

The physical move, the repos.yaml `path:` field, the ~12 root enumerators, worktree.sh, the
smoke_install.sh flat pip chain, and the IDE/PYTHONPATH/symlink migration are phases 2 and 3. Do not
introduce a universal `root / manifest.path` rule here: the review's named ordering hazard is that such
a rule breaks CI immediately (whose trees are legitimately flat) and misroutes task worktrees later.
The fan-out that CONSUMES this resolver is phase 2:
`draft/maintenance/pyautobrain/workspace_resolver_fanout.md` — the 37-copy session-start hook,
the 14 run_smoke/retime PyAutoHands joins, and the 7 hardcoded absolute paths. It cannot land
first and is mechanical once this phase exists.

The dead-weight cleanup was the sibling task workspace-dead-weight-cleanup, SHIPPED
2026-09-18 (PyAutoBrain#390, PyAutoMind#413) — record
`complete/2026/09/workspace-dead-weight-cleanup.md`. Two findings from it land here:
the `.worktrees/` trees it removed are ~80 paths this phase no longer has to migrate, and
its `autolens_jax_joss_manifest_gap` sibling is the MIRROR of scope item 4 — `repos_sync.py`
is blind in both directions (declared-but-missing is skipped; on-disk-but-undeclared is
silence). Fix both together.

Activity

  1. Jammy2211 commented on Sep 18, 2026

    @Jammy2211
    ContributorAuthor

    Decision: admin_jammy leaves the body map (user ruling, 2026-09-18)

    admin_jammy is not part of the PyAutoLabs ecosystem and is leaving the workspace. This supersedes the reasoning in the plan above, and simplifies the hardest part of scope item 3.

    The codebase already anticipated it — PyAutoBrain/bin/README.md:12: "admin_jammy hosts no skills and is slated to leave PyAutoLabs/".

    What this changes

    The plan justified an "intentional absence" mechanism — a way for repos.yaml to say declared, but not expected on disk — on the grounds that admin_jammy was a legitimate never-cloned entry. That justification is withdrawn.

    Verified: admin_jammy is the only declared-but-absent entry (39 declared, 38 on disk). With it removed, declared in the manifest but not on disk can simply be an error, full stop — no new key, no parallel idiom, nothing invented. The simplest rule that is actually true.

    The reverse direction still needs a minimal allowance: on-disk-but-undeclared must not go red on legitimate non-repo directories at the root. The case that proves it is .github/ — a real checkout with a real remote (the org .github repo) that is deliberately not a body-map repo.

    Work added

    • Remove the admin_jammy entry from PyAutoMind/repos.yaml and regenerate the root AGENTS.md routing table; drop the now-possibly-empty admin: category if nothing else uses it.
    • PyAutoHeart/config/repos.yaml:188 (- admin_jammy # personal tooling) — removed alongside, after checking what that list governs (if it is an exclusion list, dropping an entry could newly include something).
    • PyAutoHands/bin/autohands:16 (ADMIN_JAMMY="$PYAUTOBASE/admin_jammy") — vestigial, and a flat-layout assumption regardless.
    • PyAutoHeart/scripts/health_sync.sh:340 — comment referencing an already-dead admin_jammy/skills/ path.

    Left alone deliberately: PyAutoBrain/bin/{install.sh,check_skill_line_counts.sh,README.md}, which scan admin_jammy/skills/ and already document it as vestigial, auto-skipped once admin_jammy leaves — they degrade correctly today. Retiring that scan is its own cleanup, not this contract's.

    Note euclid_assistant is likewise in the personal Jammy2211/ namespace but stays — it is on disk and part of the science work. The namespace is not the criterion.

    This also supersedes one line in the phase-1b completion record (complete/2026/09/workspace-dead-weight-cleanup.md), which described admin_jammy as a genuine body-map repo that is simply not cloned. That was true when written and is not now.

  2. Jammy2211 commented on Sep 18, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    PR Merged
    #392 19:50:24Z
    PyAutoLabs/PyAutoHeart#232 19:50:28Z
    PyAutoLabs/PyAutoHands#283 19:50:33Z
    PyAutoLabs/PyAutoMind#414 19:50:37Z

    All legs green before merge — 10 successful jobs across four repos (Brain 3.12/3.13, Heart 3.12/3.13, Hands 3.12/3.13/3.14, Mind refresh/privacy/firewall). Mind's drift leg is skipped by construction on pull requests. Heart freeze: not frozen, and all four are category: organ so the library gate does not apply. Every branch proven merged by git merge-base --is-ancestor (0 unmerged commits each).

    Verified live on canonical after merge

    check workspace checkouts (manifest ↔ disk): OK
    check tenant firewall (organ code): OK
    repos_sync.py --check -> exit 0        (the new leg now ENFORCING, marker present)
    
    heart._workspace.workspace_root() -> /home/jammy/Code/PyAutoLabs
    heart._workspace.canonical_root() -> /home/jammy/Code/PyAutoLabs
    

    Integration step done: repos_sync.py --write run once from the assembled tree — root AGENTS.md regenerated (0 admin_jammy references), .pyauto-root now generated rather than hand-placed, and PyAutoBrain/skills/WORKFLOW.md's owner map synced (PyAutoBrain 9091d9e).

    What the phase actually established

    The scope item I expected to be most theoretical — "define four separate concepts rather than one conflated root" — earned its place three times in one session:

    1. Heart would have graded a task bundle instead of canonical. Health is a release gate, and the resolver would have inverted the documented default: from a bundle it reported 0 orphan / 5 dirty where canonical reports 6 orphan / 7 dirty. The more flattering answer, reached by running Heart where you happen to be working. Now split: workspace_root() locates, canonical_root() grades, derived from git --git-common-dir.
    2. Mind's --write would have regenerated another tree. The resolver is Brain-anchored, and a bundle's PyAutoBrain is normally a symlink to canonical — so --write from a bundle resolved to canonical. Guarded: both adopters refuse a root that does not contain their own checkout.
    3. The dashboard regen hit it during this very close-out. Running the canonical pyauto-brain binary from inside the bundle regenerated canonical, and --check reported "are current" because it checked canonical too — while the bundle's page kept offering a prompt that had just been retired. Caught only by grepping for the slug.

    All three are the same shape: locating is not writing, and not grading.

    Corrections made along the way

    • spawn.py:507 was not a workspace-root site — that parents[2] is inside a template string for a generated satellite repo's smoke runner.
    • admin_jammy is not part of the PyAutoLabs ecosystem (user ruling). Removing it meant the declared-but-missing check needed no exception mechanism at all — 38 declared ↔ 38 on disk. Only the reverse direction needed one entry, .github, proven load-bearing by unlisting it.
    • The Heart scope widened from 4 sites to ~13 plus two new shim files; converting only the scoped four would have left Heart internally disagreeing, which is the defect being fixed.

    Found on the way, filed separately

    PyAutoHeart/heart/manifest_drift.py:45 anchors its check-line parse to end-of-line, so any leg printing a suffix after its status is invisible to Heart — not green, unparsed. Measured: 16 legs parse, 1 does not (generated hooks), meaning that leg has never reached Heart's verdict. Filed as draft/bug/pyautoheart/manifest_drift_parser_drops_suffixed_check_legs.md.

    Carried into phase 3

    Step 3 of the resolver is still wrong for a nested workspace with no marker, deliberately, to protect the remote single-repo case — a test pins it. So the marker is the only thing protecting a regrouped workspace: whoever performs the move must create the marker in the same commit, or resolution silently goes one level deep again.

    Phase 2 is draft/maintenance/pyautobrain/workspace_resolver_fanout.md (the 37-copy hook, the 14 smoke shims, the 7 hardcoded paths), which was Blocked-by: this and is now unblocked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions