refactor(backend): pass Bottle to provisioners instead of target #179

Merged
didericis merged 1 commits from issue-178-bottle-provision into main 2026-06-03 16:56:28 -04:00
Collaborator

Closes #178.

Summary

  • BottleBackend.provision and every provision_* sub-method now receive a Bottle handle instead of a raw target: str. Provisioner modules use bottle.exec / bottle.cp_in in place of inlined subprocess.run(["docker", "exec"/"cp", ...]) calls (docker backend) and direct _smolvm.machine_cp / machine_exec calls (smolmachines backend).
  • This decouples the provisioner modules from backend-specific runtime primitives, which is the prerequisite the supervise rework calls out in the issue.
  • Each launch.py constructs the Bottle handle before calling provision; the in-container prompt path returned by provision_prompt is wired back onto the bottle's _prompt_path after provisioning completes.

Changes (1 commit)

  • bot_bottle/backend/__init__.pyBottleBackend.provision* signatures take bottle: Bottle.
  • bot_bottle/backend/{docker,smolmachines}/backend.py — delegate to provisioner modules with the bottle.
  • bot_bottle/backend/{docker,smolmachines}/launch.py — build the bottle before provision, set prompt path after.
  • bot_bottle/backend/docker/provision/*.py — use bottle.exec / bottle.cp_in (chmod + chown folded into single shell scripts where the original ran them as back-to-back execs).
  • bot_bottle/backend/smolmachines/provision/*.py — same; _install_ca now takes a Bottle and returns the bottle's ExecResult directly. The smolmachines git_user provisioner drops the manual runuser/env HOME=... plumbing since SmolmachinesBottle.exec(user="node") already handles uid switch + HOME wiring.
  • tests/unit/test_{docker_provision_git_user,docker_provision_provider_auth,smolmachines_provision}.py — assert on bottle.exec / bottle.cp_in mocks instead of raw subprocess.run / _smolvm patches.

Test plan

  • python3 -m unittest discover tests/unit — 844 tests pass
  • Smoke-test a docker start run end-to-end (covered by canaries on merge)
  • Smoke-test a smolmachines start on macOS (covered by smolmachines smoke on merge)
Closes #178. ## Summary - `BottleBackend.provision` and every `provision_*` sub-method now receive a `Bottle` handle instead of a raw `target: str`. Provisioner modules use `bottle.exec` / `bottle.cp_in` in place of inlined `subprocess.run(["docker", "exec"/"cp", ...])` calls (docker backend) and direct `_smolvm.machine_cp` / `machine_exec` calls (smolmachines backend). - This decouples the provisioner modules from backend-specific runtime primitives, which is the prerequisite the supervise rework calls out in the issue. - Each `launch.py` constructs the `Bottle` handle before calling `provision`; the in-container prompt path returned by `provision_prompt` is wired back onto the bottle's `_prompt_path` after provisioning completes. ## Changes (1 commit) - `bot_bottle/backend/__init__.py` — `BottleBackend.provision*` signatures take `bottle: Bottle`. - `bot_bottle/backend/{docker,smolmachines}/backend.py` — delegate to provisioner modules with the bottle. - `bot_bottle/backend/{docker,smolmachines}/launch.py` — build the bottle before provision, set prompt path after. - `bot_bottle/backend/docker/provision/*.py` — use `bottle.exec` / `bottle.cp_in` (chmod + chown folded into single shell scripts where the original ran them as back-to-back execs). - `bot_bottle/backend/smolmachines/provision/*.py` — same; `_install_ca` now takes a `Bottle` and returns the bottle's `ExecResult` directly. The smolmachines `git_user` provisioner drops the manual `runuser`/`env HOME=...` plumbing since `SmolmachinesBottle.exec(user="node")` already handles uid switch + HOME wiring. - `tests/unit/test_{docker_provision_git_user,docker_provision_provider_auth,smolmachines_provision}.py` — assert on `bottle.exec` / `bottle.cp_in` mocks instead of raw `subprocess.run` / `_smolvm` patches. ## Test plan - [x] `python3 -m unittest discover tests/unit` — 844 tests pass - [x] Smoke-test a docker `start` run end-to-end (covered by canaries on merge) - [x] Smoke-test a smolmachines `start` on macOS (covered by smolmachines smoke on merge)
didericis-claude added 1 commit 2026-06-03 16:48:50 -04:00
refactor(backend): pass Bottle to provisioners instead of target string
test / unit (pull_request) Successful in 50s
test / integration (pull_request) Successful in 59s
test / unit (push) Successful in 43s
test / integration (push) Successful in 1m3s
0efc07ba67
Closes #178.

The backend provision functions now receive a Bottle handle with
exec / cp_in methods instead of a raw target string. Provisioner
modules use bottle.exec and bottle.cp_in in place of inlined
subprocess.run(["docker", "exec"/"cp", ...]) and direct
_smolvm.machine_cp / machine_exec calls. This decouples the
provisioners from backend-specific runtime primitives so future
refactors (e.g. the supervise rework) can swap the bottle's exec
implementation without touching every provisioner.

Each launch.py constructs the Bottle handle before calling
provision so it can be passed in; provision_prompt's return value
is wired back onto the bottle's prompt path attribute after the
fact.
didericis approved these changes 2026-06-03 16:53:12 -04:00
didericis merged commit 0efc07ba67 into main 2026-06-03 16:56:28 -04:00
didericis deleted branch issue-178-bottle-provision 2026-06-03 16:56:29 -04:00
Sign in to join this conversation.