From a5a9fd68a189de4f98274681a65976dbc9078a30 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sat, 19 Sep 2026 11:57:55 +0100 Subject: [PATCH] refactor: support grouped infrastructure checkouts --- scripts/board.py | 10 ++++++++-- tests/test_board.py | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/scripts/board.py b/scripts/board.py index 07b1fff..fe35e86 100644 --- a/scripts/board.py +++ b/scripts/board.py @@ -95,13 +95,18 @@ def _workspace_root() -> Path: - """Where the sibling PyAuto checkouts live: `$PYAUTO_ROOT`, else `~/Code`. + """Find the workspace containing the sibling PyAuto checkouts. The org's own directory name is an instance fact, so it is never written here — a workspace that does not follow the default sets `$PYAUTO_ROOT` (the same variable the dev-flow doors read). """ - return Path(os.environ.get("PYAUTO_ROOT") or Path.home() / "Code") + if os.environ.get("PYAUTO_ROOT"): + return Path(os.environ["PYAUTO_ROOT"]) + for parent in (MEMORY_HOME, *MEMORY_HOME.parents): + if (parent / ".pyauto-root").is_file(): + return parent + return Path.home() / "Code" def theme(): @@ -112,6 +117,7 @@ def theme(): """ for cand in (os.environ.get("PYAUTO_BRAIN"), MEMORY_HOME / "PyAutoBrain", MEMORY_HOME.parent / "PyAutoBrain", + _workspace_root() / "organs" / "PyAutoBrain", _workspace_root() / "PyAutoBrain"): if not cand: continue diff --git a/tests/test_board.py b/tests/test_board.py index 82f4efe..18a0951 100644 --- a/tests/test_board.py +++ b/tests/test_board.py @@ -24,6 +24,29 @@ BODY_MARKER = "the-secret-claim-text-that-must-never-leak" + +def test_theme_finds_grouped_brain_from_outer_workspace(tmp_path, monkeypatch): + brain_board = tmp_path / "organs" / "PyAutoBrain" / "board" + brain_board.mkdir(parents=True) + (brain_board / "_theme.py").write_text("GROUPED_THEME = True\n") + monkeypatch.setenv("PYAUTO_ROOT", str(tmp_path)) + monkeypatch.setattr(board, "MEMORY_HOME", tmp_path / "PyAutoMemory") + monkeypatch.delitem(sys.modules, "_theme", raising=False) + monkeypatch.setattr(sys, "path", sys.path.copy()) + try: + assert board.theme().GROUPED_THEME + finally: + sys.modules.pop("_theme", None) + + +def test_workspace_root_marker_stays_at_outer_root(tmp_path, monkeypatch): + memory = tmp_path / "organs" / "PyAutoMemory" + memory.mkdir(parents=True) + (tmp_path / ".pyauto-root").touch() + monkeypatch.delenv("PYAUTO_ROOT", raising=False) + monkeypatch.setattr(board, "MEMORY_HOME", memory) + assert board._workspace_root() == tmp_path + # The freshness/staleness banners are computed against `snapshot["generated"]`, # so a fixture with fixed dates and a live clock ages out of its own window and # the suite goes red on a calendar day rather than on a code change (it did, on