feat(deckies): live service add/remove without full redeploy

decnet.engine.services_live exposes add_service / remove_service for
both fleet and topology decky scopes.  The host's _compose() wrapper
already supported per-service targeting (up --no-deps -d <svc>,
stop, rm -f); what was missing was the orchestration around it:

* add: validate against decnet.services.registry (rejects unknown +
  fleet_singleton); persist the new services list; re-render the
  per-scope compose file (so future redeploys reflect the change);
  run docker compose up -d --no-deps --build <decky>-<svc>.
* remove: stop + rm -f the service container; persist; re-render
  compose so a future up -d doesn't bring it back.

Both publish decky.<name>.service.added / .removed on the bus, with
the post-mutation services list.  Topic constants added to
decnet.bus.topics; the matching wiki entry in wiki-checkout/Service-Bus.md
ships in a separate commit on the wiki repo (wiki-checkout/ is gitignored).

Four new admin endpoints:

* POST/DELETE /api/v1/deckies/{name}/services{,/svc}
* POST/DELETE /api/v1/topologies/{id}/deckies/{name}/services{,/svc}

ServiceMutationError messages are mapped at the API boundary to 404
(decky/topology missing), 409 (idempotency violation), 422 (unknown
or fleet_singleton service).
This commit is contained in:
2026-04-28 22:51:42 -04:00
parent 0bc4b05c73
commit 6ac8cac908
9 changed files with 965 additions and 0 deletions

View File

@@ -14,8 +14,18 @@ from __future__ import annotations
from fastapi import APIRouter
from .api_file_drop import router as file_drop_router
from .api_services import (
fleet_services_router,
topology_services_router,
)
deckies_router = APIRouter()
deckies_router.include_router(file_drop_router)
deckies_router.include_router(fleet_services_router)
# Topology service routes live under /topologies/{id}/... — the prefix
# is set on the router itself. Mounted under the same `deckies_router`
# umbrella because the *operation* (add/remove a service on a deployed
# decky) is identical; only the addressing scheme differs.
deckies_router.include_router(topology_services_router)
__all__ = ["deckies_router"]