Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions scripts/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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
Expand Down
23 changes: 23 additions & 0 deletions tests/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading