refactor(backend): introduce BottleProvisioner ABC + DockerBottleProvisioner
test / run tests/run_tests.py (pull_request) Successful in 17s
test / run tests/run_tests.py (pull_request) Successful in 17s
Lift the file-copying-into-the-running-container step out of
DockerBottleBackend._provision_container into its own class. The
backend now holds a DockerBottleProvisioner instance and delegates
the post-launch provisioning to it.
- BottleProvisioner (abstract) in backend/__init__.py with a
`provision(plan, target) -> str | None` method.
- DockerBottleProvisioner (concrete) in backend/docker/provisioner.py
inheriting from the base, narrowing plan to DockerBottlePlan via
isinstance, and carrying the prompt/skills/SSH/.git copy logic
unchanged.
- DockerBottleBackend keeps a class-level DockerBottleProvisioner()
and calls self._provisioner.provision(plan, container) from launch.
_provision_container method removed.
No behavior change.
This commit is contained in:
@@ -104,6 +104,22 @@ class Bottle(ABC):
|
||||
def close(self) -> None: ...
|
||||
|
||||
|
||||
class BottleProvisioner(ABC):
|
||||
"""Copies host-side files (prompt, skills, SSH keys, .git) into a
|
||||
running bottle after the container/machine is up. Owned by a
|
||||
BottleBackend; called from its launch step before yielding the
|
||||
Bottle handle."""
|
||||
|
||||
@abstractmethod
|
||||
def provision(self, plan: BottlePlan, target: str) -> str | None:
|
||||
"""Provision the running bottle described by `plan`. `target`
|
||||
identifies the running instance in backend-specific terms
|
||||
(Docker: resolved container name; fly: machine id). Returns the
|
||||
in-container prompt path if a prompt was provisioned, else
|
||||
None — the Bottle handle uses it to decide whether to add
|
||||
--append-system-prompt-file to claude's argv."""
|
||||
|
||||
|
||||
class BottleBackend(ABC):
|
||||
"""Abstract base for selectable bottle backends. Concrete subclasses
|
||||
(e.g. DockerBottleBackend) own their own prepare/launch impls.
|
||||
@@ -162,6 +178,7 @@ __all__ = [
|
||||
"BottleBackend",
|
||||
"BottleCleanupPlan",
|
||||
"BottlePlan",
|
||||
"BottleProvisioner",
|
||||
"BottleSpec",
|
||||
"get_bottle_backend",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user