From 1175e17d4e993ab8d5c27224570233bd6fbbab23 Mon Sep 17 00:00:00 2001 From: didericis Date: Mon, 13 Jul 2026 14:30:13 -0400 Subject: [PATCH] refactor: drop the vestigial bot_bottle_root/host_db_path re-exports (#352) paths is the single home now, so stop re-exporting the path helpers from supervise: remove host_db_path from supervise's imports + __all__ (it was re-export-only) and drop bot_bottle_root from __all__ (kept as an import, still used by audit_dir). supervise_types was already clean. Repoint the last readers (test_supervise imports host_db_path from paths; test_supervise_edge calls paths.bot_bottle_root) and refresh the doc mentions. No supervise.bot_bottle_root / supervise.host_db_path references remain. Behavior-preserving: full unit suite unchanged (only the pre-existing /bin/sleep sidecar-init errors). Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01WBMWTEtQdJ4W5UrWuLHCck --- bot_bottle/supervise.py | 6 ++---- tests/unit/__init__.py | 6 +++--- tests/unit/test_supervise.py | 2 +- tests/unit/test_supervise_cli.py | 2 +- tests/unit/test_supervise_cli_crash_logging.py | 5 ++--- tests/unit/test_supervise_edge.py | 3 ++- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/bot_bottle/supervise.py b/bot_bottle/supervise.py index d1d9596..b086ad4 100644 --- a/bot_bottle/supervise.py +++ b/bot_bottle/supervise.py @@ -74,9 +74,9 @@ except ImportError: try: - from .paths import bot_bottle_root, host_db_path + from .paths import bot_bottle_root except ImportError: # flat imports inside the sidecar bundle - from paths import bot_bottle_root, host_db_path # type: ignore[import-not-found,no-redef] # pylint: disable=import-error,no-name-in-module + from paths import bot_bottle_root # type: ignore[import-not-found,no-redef] # pylint: disable=import-error,no-name-in-module SUPERVISE_HOSTNAME = "supervise" @@ -289,8 +289,6 @@ __all__ = [ "archive_proposal", "audit_dir", "audit_log_path", - "bot_bottle_root", - "host_db_path", "list_pending_proposals", "list_all_pending_proposals", "read_audit_entries", diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 7e69d1d..be349dc 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -2,7 +2,7 @@ Isolates ``HOME`` to a throwaway directory for the entire unit suite so no test ever reads or writes the real ``~/.bot-bottle`` (state, queue, -and audit dirs all derive from ``supervise.bot_bottle_root()`` → +and audit dirs all derive from ``paths.bot_bottle_root()`` → ``Path.home()``). Without this, a test that takes a ``flock`` on the real audit log can **block indefinitely** when a live bottle's supervise sidecar holds that lock — observed as a hung ``coverage run`` at 0% CPU — @@ -49,8 +49,8 @@ def use_bottle_root(root: Path) -> Callable[[], None]: ``BOT_BOTTLE_ROOT`` — the supported override. Returns a callable that undoes it (store it as the test's restore hook, or pass to addCleanup). - Replaces monkey-patching ``supervise.bot_bottle_root``; one env var - covers every module and the flat/package copies alike (they all read it).""" + Replaces monkey-patching ``paths.bot_bottle_root``; one env var covers + every module and the flat/package copies alike (they all read it).""" patcher = mock.patch.dict(os.environ, {"BOT_BOTTLE_ROOT": str(root)}) patcher.start() return patcher.stop diff --git a/tests/unit/test_supervise.py b/tests/unit/test_supervise.py index 01198a8..6381af0 100644 --- a/tests/unit/test_supervise.py +++ b/tests/unit/test_supervise.py @@ -8,6 +8,7 @@ from datetime import datetime, timezone from pathlib import Path from bot_bottle import supervise +from bot_bottle.paths import host_db_path from tests.unit import use_bottle_root from bot_bottle.audit_store import AuditStore from bot_bottle.queue_store import QueueStore @@ -21,7 +22,6 @@ from bot_bottle.supervise import ( TOOL_EGRESS_ALLOW, TOOL_GITLEAKS_ALLOW, archive_proposal, - host_db_path, list_pending_proposals, read_audit_entries, read_proposal, diff --git a/tests/unit/test_supervise_cli.py b/tests/unit/test_supervise_cli.py index 9b74ec5..9c680c9 100644 --- a/tests/unit/test_supervise_cli.py +++ b/tests/unit/test_supervise_cli.py @@ -51,7 +51,7 @@ def _proposal(slug: str = "dev", tool: str = TOOL_EGRESS_ALLOW) -> Proposal: class _FakeHomeMixin: - """Patch supervise.bot_bottle_root to a temp dir for the test.""" + """Point bot_bottle_root at a temp dir (via BOT_BOTTLE_ROOT) for the test.""" def _setup_fake_home(self): self._tmp = tempfile.TemporaryDirectory(prefix="supervise-test.") diff --git a/tests/unit/test_supervise_cli_crash_logging.py b/tests/unit/test_supervise_cli_crash_logging.py index 3fca465..05c5463 100644 --- a/tests/unit/test_supervise_cli_crash_logging.py +++ b/tests/unit/test_supervise_cli_crash_logging.py @@ -40,9 +40,8 @@ class TestDieCarriesMessage(unittest.TestCase): class _FakeHomeMixin: - """Point supervise.bot_bottle_root (what _write_crash_log resolves - through) at a temp dir so the crash log doesn't touch the real - ~/.bot-bottle.""" + """Point bot_bottle_root (what _write_crash_log resolves through) at a + temp dir so the crash log doesn't touch the real ~/.bot-bottle.""" def _setup_fake_home(self): self._tmp = tempfile.TemporaryDirectory(prefix="supervise-crash-test.") diff --git a/tests/unit/test_supervise_edge.py b/tests/unit/test_supervise_edge.py index 3cde845..4cedbfa 100644 --- a/tests/unit/test_supervise_edge.py +++ b/tests/unit/test_supervise_edge.py @@ -12,6 +12,7 @@ from unittest.mock import patch from bot_bottle import supervise from bot_bottle.audit_store import AuditStore +from bot_bottle.paths import bot_bottle_root from bot_bottle.queue_store import QueueStore from bot_bottle.supervise import ( AuditEntry, @@ -39,7 +40,7 @@ def _proposal() -> Proposal: class TestPathHelpers(unittest.TestCase): def test_bot_bottle_root(self) -> None: - self.assertTrue(str(supervise.bot_bottle_root()).endswith(".bot-bottle")) + self.assertTrue(str(bot_bottle_root()).endswith(".bot-bottle")) class TestReadMalformed(unittest.TestCase):