Cleanup backend and agent provider abstractions #216

Merged
didericis merged 21 commits from issue-215-dockerfile-colocation into main 2026-06-08 23:01:36 -04:00
4 changed files with 15 additions and 24 deletions
Showing only changes of commit 8ede486280 - Show all commits
+5 -8
View File
@@ -128,16 +128,13 @@ class AgentProvider(ABC):
template."""
@property
def dockerfile(self) -> Path | None:
"""Path to the provider's Dockerfile, or None if no Dockerfile
is declared.
def dockerfile(self) -> Path:
didericis marked this conversation as resolved Outdated
Outdated
Review

This should always return a docker/should never return None

This should always return a docker/should never return `None`
"""Path to the provider's Dockerfile.
Default: looks for a `Dockerfile` file next to this provider's
Default: the `Dockerfile` file next to this provider's
`agent_provider.py` module. Override to point at a non-standard
path, or return None to signal that no Dockerfile exists (the
provider relies on a pre-built image)."""
path = Path(inspect.getfile(type(self))).parent / "Dockerfile"
return path if path.is_file() else None
path."""
return Path(inspect.getfile(type(self))).parent / "Dockerfile"
@abstractmethod
def provision_plan(
@@ -95,7 +95,7 @@ def fetch_current_dockerfile(slug: str) -> str:
if override is not None:
return override
repo_dockerfile = get_provider("claude").dockerfile
if repo_dockerfile is not None and repo_dockerfile.is_file():
if repo_dockerfile.is_file():
return repo_dockerfile.read_text()
raise CapabilityApplyError(
f"no per-bottle Dockerfile for {slug} and no provider Dockerfile at "
1
+5 -8
View File
1
@@ -102,14 +102,11 @@ def resolve_plan(
dockerfile_path = _resolve_manifest_dockerfile(provider.dockerfile, spec)
else:
didericis marked this conversation as resolved Outdated
Outdated
Review

A provider should always have a dockerfile now, so this else shouldn't be necessary.

A provider should always have a dockerfile now, so this else shouldn't be necessary.
p_dockerfile = provider_obj.dockerfile
if p_dockerfile is not None:
if provider.template in PROVIDER_TEMPLATES:
image_default = provider_runtime.image
else:
image_default = f"bot-bottle-{provider.template}:{slug}"
dockerfile_path = str(p_dockerfile)
else:
if provider.template in PROVIDER_TEMPLATES:
image_default = provider_runtime.image
else:
image_default = f"bot-bottle-{provider.template}:{slug}"
dockerfile_path = str(p_dockerfile)
image = image_default
didericis marked this conversation as resolved Outdated
Outdated
Review

This rename used to make sense, but not anymore: places where we're assigning image_default should be changed so we assign to image and we should just remove this image = image_default assignment.

This rename used to make sense, but not anymore: places where we're assigning `image_default` should be changed so we assign to `image` and we should just remove this `image = image_default` assignment.
derived_image = ""
runtime_image = image
1
@@ -217,7 +214,7 @@ def resolve_plan(
)
dockerfile_content = (
supervise_dockerfile_path.read_text(encoding="utf-8")
if supervise_dockerfile_path is not None and supervise_dockerfile_path.is_file()
if supervise_dockerfile_path.is_file()
else ""
)
supervise_dir = supervise_state_dir(slug)
+4 -7
View File
@@ -122,14 +122,11 @@ def resolve_plan(
image_default = f"bot-bottle-{provider.template}:{slug}"
else:
p_dockerfile = provider_obj.dockerfile
if p_dockerfile is not None:
agent_dockerfile_path = str(p_dockerfile)
if provider.template in PROVIDER_TEMPLATES:
image_default = provider_runtime.image
else:
image_default = f"bot-bottle-{provider.template}:{slug}"
else:
agent_dockerfile_path = str(p_dockerfile)
if provider.template in PROVIDER_TEMPLATES:
image_default = provider_runtime.image
else:
image_default = f"bot-bottle-{provider.template}:{slug}"
agent_image_ref = image_default
agent_provision = agent_provision_plan(
template=provider.template,