From b49281800a07068ffd79de78ffbd673a6f0b9ca8 Mon Sep 17 00:00:00 2001 From: didericis Date: Mon, 11 May 2026 13:57:18 -0400 Subject: [PATCH] refactor(pipelock): move Docker-specific naming helpers to docker/pipelock.py The three slug-based naming helpers were nominally on pipelock.py but each assumed a Docker container topology (the container name is 'claude-bottle-pipelock-', the proxy URL uses that container name). Move them next to DockerPipelockProxy: pipelock_container_name -> claude-bottle-pipelock- pipelock_proxy_url -> http://: pipelock_proxy_host_port -> : backend.py imports them directly from .pipelock; the orphan-cleanup test imports container_name from the same place. --- claude_bottle/backend/docker/backend.py | 10 +++++++--- claude_bottle/backend/docker/pipelock.py | 13 ++++++++++++- claude_bottle/pipelock.py | 12 ------------ tests/test_orphan_cleanup.py | 6 ++++-- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/claude_bottle/backend/docker/backend.py b/claude_bottle/backend/docker/backend.py index b0e50ce..e47a82e 100644 --- a/claude_bottle/backend/docker/backend.py +++ b/claude_bottle/backend/docker/backend.py @@ -29,7 +29,11 @@ from . import util as docker_mod from .bottle import DockerBottle from .bottle_cleanup_plan import DockerBottleCleanupPlan from .bottle_plan import DockerBottlePlan -from .pipelock import DockerPipelockProxy +from .pipelock import ( + DockerPipelockProxy, + pipelock_proxy_host_port, + pipelock_proxy_url, +) # Where the repo root lives, for `docker build` context. Computed once. @@ -204,7 +208,7 @@ class DockerBottleBackend(BottleBackend): """Build the `docker run` argv and execute it, handling name-conflict races by incrementing the suffix (unless the name was user-pinned). Returns the resolved container name.""" - proxy_url = pipelock.pipelock_proxy_url(plan.slug) + proxy_url = pipelock_proxy_url(plan.slug) docker_args: list[str] = [ "--rm", "-d", "--name", plan.container_name, @@ -411,7 +415,7 @@ class DockerBottleBackend(BottleBackend): return container = target - proxy_host_port = pipelock.pipelock_proxy_host_port(plan.slug) + proxy_host_port = pipelock_proxy_host_port(plan.slug) container_home = os.environ.get("CLAUDE_BOTTLE_CONTAINER_HOME", "/home/node") container_ssh = f"{container_home}/.ssh" agent_socket = "/run/claude-bottle-agent.sock" diff --git a/claude_bottle/backend/docker/pipelock.py b/claude_bottle/backend/docker/pipelock.py index 82bcebd..0e0bdc1 100644 --- a/claude_bottle/backend/docker/pipelock.py +++ b/claude_bottle/backend/docker/pipelock.py @@ -12,10 +12,21 @@ from ...pipelock import ( PIPELOCK_PORT, PipelockProxy, PipelockProxyPlan, - pipelock_container_name, ) +def pipelock_container_name(slug: str) -> str: + return f"claude-bottle-pipelock-{slug}" + + +def pipelock_proxy_url(slug: str) -> str: + return f"http://{pipelock_container_name(slug)}:{PIPELOCK_PORT}" + + +def pipelock_proxy_host_port(slug: str) -> str: + return f"{pipelock_container_name(slug)}:{PIPELOCK_PORT}" + + class DockerPipelockProxy(PipelockProxy): """Brings the pipelock sidecar up and down via Docker.""" diff --git a/claude_bottle/pipelock.py b/claude_bottle/pipelock.py index 0835aca..9d799d8 100644 --- a/claude_bottle/pipelock.py +++ b/claude_bottle/pipelock.py @@ -42,18 +42,6 @@ DEFAULT_ALLOWLIST: tuple[str, ...] = ( ) -def pipelock_container_name(slug: str) -> str: - return f"claude-bottle-pipelock-{slug}" - - -def pipelock_proxy_url(slug: str) -> str: - return f"http://{pipelock_container_name(slug)}:{PIPELOCK_PORT}" - - -def pipelock_proxy_host_port(slug: str) -> str: - return f"{pipelock_container_name(slug)}:{PIPELOCK_PORT}" - - # --- Allowlist resolution -------------------------------------------------- diff --git a/tests/test_orphan_cleanup.py b/tests/test_orphan_cleanup.py index 40218e2..928fbf3 100644 --- a/tests/test_orphan_cleanup.py +++ b/tests/test_orphan_cleanup.py @@ -13,8 +13,10 @@ from claude_bottle.backend.docker.network import ( network_create_internal, network_remove, ) -from claude_bottle.backend.docker.pipelock import DockerPipelockProxy -from claude_bottle.pipelock import pipelock_container_name +from claude_bottle.backend.docker.pipelock import ( + DockerPipelockProxy, + pipelock_container_name, +) from tests._docker import skip_unless_docker