refactor(supervise): fold Supervise into the facade as Supervisor; drop dead flat-fallbacks
tracker-policy-pr / check-pr (pull_request) Successful in 8s
test / integration-docker (pull_request) Successful in 12s
test / unit (pull_request) Successful in 43s
lint / lint (push) Failing after 59s
test / integration-firecracker (pull_request) Successful in 3m16s
test / coverage (pull_request) Successful in 16s
test / publish-infra (pull_request) Has been skipped

Move the `Supervise` lifecycle out of its own `orchestrator/supervisor/
supervise.py` and into the package `__init__`, renaming the class to
`Supervisor`. Callers now import it from `bot_bottle.orchestrator.supervisor`
alongside the queue surface it belongs with.

Remove the dead `try/except ImportError` flat-import fallbacks from the
package-only store modules (db_store, audit_store, config_store, queue_store)
and image_cache. Those fallbacks existed for when the store files were
flat-copied into the gateway; post-PRD-0070 the data plane never opens the DB,
so these modules are only ever imported as part of the package. The two gateway
data-plane files that may still be loaded flat (egress_addon_core,
git_gate_render) keep their fallbacks.

Full unit suite green (2251).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 14:24:06 -04:00
parent 44e2b5a897
commit 3e2cbcab88
11 changed files with 47 additions and 84 deletions
+4 -10
View File
@@ -6,16 +6,10 @@ import os
import sqlite3
from pathlib import Path
try:
from ...supervisor.types import Proposal, Response
from ...paths import host_db_path
from ...store.db_store import DbStore
from ...store.migrations import TableMigrations
except ImportError:
from supervisor.types import Proposal, Response # type: ignore[import-not-found] # pylint: disable=import-error,no-name-in-module
from paths import host_db_path # type: ignore[import-not-found] # pylint: disable=import-error,no-name-in-module
from db_store import DbStore # type: ignore[import-not-found] # pylint: disable=import-error,no-name-in-module
from migrations import TableMigrations # type: ignore[import-not-found] # pylint: disable=import-error,no-name-in-module
from ...supervisor.types import Proposal, Response
from ...paths import host_db_path
from ...store.db_store import DbStore
from ...store.migrations import TableMigrations
class QueueStore(DbStore):
+27 -5
View File
@@ -1,10 +1,10 @@
"""The orchestrator's view of the supervise plane.
Bundles the orchestrator-owned supervise surface: the queue/audit I/O and diff
rendering (`queue`) and the `Supervise` lifecycle (`supervise`). For
convenience it re-exports the neutral vocabulary (`bot_bottle.supervisor`'s
types + `SupervisePlan`) so orchestrator-side callers — service, CLI, tests —
import from one place.
rendering (`queue`), and the `Supervisor` lifecycle (host-side database
staging). For convenience it re-exports the neutral vocabulary
(`bot_bottle.supervisor`'s types + `SupervisePlan`) so orchestrator-side
callers — service, CLI, tests — import from one place.
The data plane must NOT import this package; it imports `bot_bottle.supervisor`
(neutral) directly and reaches the queue over the control-plane RPC.
@@ -12,8 +12,12 @@ The data plane must NOT import this package; it imports `bot_bottle.supervisor`
from __future__ import annotations
from abc import ABC
from pathlib import Path
from ...supervisor.types import * # noqa: F401,F403 — re-export the neutral vocabulary
from ...supervisor.plan import SupervisePlan
from ..store.store_manager import StoreManager
from .queue import (
archive_all_proposals,
archive_proposal,
@@ -31,4 +35,22 @@ from .queue import (
write_proposal,
write_response,
)
from .supervise import Supervise
class Supervisor(ABC):
"""Per-bottle supervise lifecycle. Encapsulates host-side database staging;
the gateway's start/stop lifecycle is backend-specific.
`prepare` migrates the orchestrator's `bot-bottle.db` and returns the
neutral `SupervisePlan`. It touches the orchestrator store manager, so it
lives here rather than in the neutral `bot_bottle.supervisor` package; the
backend (which drives launch) may import it — backend → orchestrator is an
allowed direction, unlike gateway → orchestrator."""
def prepare(self, slug: str, stage_dir: Path) -> SupervisePlan:
"""Stage the host database. Returns the plan; `internal_network` must be
set by the launch step before .start runs."""
del stage_dir
mgr = StoreManager.instance()
mgr.migrate()
return SupervisePlan(slug=slug, db_path=mgr.db_path)
@@ -1,36 +0,0 @@
"""The `Supervise` lifecycle — host-side database staging (PRD 0013 / 0070).
`Supervise.prepare` migrates the orchestrator's `bot-bottle.db` and returns the
neutral `SupervisePlan`. It touches the orchestrator store manager, so it lives
here rather than in the neutral `bot_bottle.supervisor` package; the backend
(which drives launch) may import it — backend → orchestrator is an allowed
direction, unlike gateway → orchestrator.
"""
from __future__ import annotations
from abc import ABC
from pathlib import Path
from ..store.store_manager import StoreManager
from ...supervisor.plan import SupervisePlan
class Supervise(ABC):
"""Per-bottle supervise daemon. Encapsulates host-side database staging;
the gateway's start/stop lifecycle is backend-specific."""
def prepare(
self,
slug: str,
stage_dir: Path,
) -> SupervisePlan:
"""Stage the host database. Returns the plan; `internal_network` must be
set by the launch step before .start runs."""
del stage_dir
mgr = StoreManager.instance()
mgr.migrate()
return SupervisePlan(
slug=slug,
db_path=mgr.db_path,
)