3.0 KiB
PRD 0040: Backend-Aware Resume and Dashboard Reattach
- Status: Active
- Author: didericis-codex
- Created: 2026-06-02
- Issue: #137
Summary
Persist the backend name in BottleMetadata and thread it through resume and
dashboard reattach so both flows construct the correct backend bottle without
relying on env overrides or defaulting to Docker.
Problem
BottleMetadata records identity, agent, cwd, started_at, and compose project,
but not the backend name. Without it:
cli/resume.pycannot select the right backend from a preserved state dir alone; operators must remember to setBOT_BOTTLE_BACKEND=smolmachinesseparately.cli/dashboard.py_bottle_for_slugconstructs aDockerBottlefor any externally discovered slug, so reattaching to a live smolmachines agent from the dashboard sends Docker commands to a smolvm machine.
Goals / Success Criteria
BottleMetadataincludes the backend name, written at bottle creation time for both Docker and smolmachines.cli resumereads the persisted backend name and constructs the correct bottle type without requiring an env override.- Dashboard reattach (
_bottle_for_slug) reads the persisted backend name and constructs the correct bottle type. - Existing Docker bottles without a persisted backend name fall back to Docker (backward-compatible default).
- Unit tests cover write, read, backward-compatible fallback, and both resume/reattach code paths.
Non-goals
- No changes to manifest or egress configuration.
- No new CLI flags (backend selection at resume time should be automatic).
- No smolmachines capability-apply implementation (see PRD 0039).
Scope
In scope:
bot_bottle/backend/docker/bottle_state.pyBottleMetadataschema and write path.bot_bottle/backend/docker/bottle.pyandbot_bottle/backend/smolmachines/bottle.pymetadata write at creation.bot_bottle/cli/resume.pybackend selection from metadata.bot_bottle/cli/dashboard.py_bottle_for_slugbackend selection.- Unit tests covering the above.
Out of scope:
- Migration tooling for existing state dirs.
- Integration tests that exercise full resume across process restarts.
Design
Add a backend field to BottleMetadata with a default of "docker" for
backward compatibility. Both DockerBottle and SmolmachinesBottle write
their backend name into metadata at creation time.
resume reads the metadata before constructing the bottle object and selects
the appropriate backend class. _bottle_for_slug does the same. A helper
function in the metadata module can encapsulate the backend-name-to-class
mapping so the logic is not duplicated.
Testing Strategy
- Unit tests for
BottleMetadataserialisation with and without the backend field. - Unit tests for the backward-compatible default.
- Unit tests for
resumeselecting smolmachines vs Docker from metadata. - Unit tests for
_bottle_for_slugselecting smolmachines vs Docker.
Run:
python3 -m unittest discover -s tests/unit
Open Questions
None.