Skip to content

Declarative service state: stopped / running (closes #100) - #101

Merged
wmantly merged 1 commit into
mainfrom
service-state
Nov 13, 2026
Merged

wmantly merged 1 commit into
mainfrom
service-state

Conversation

@wmantly

@wmantly wmantly commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Draft PR: declarative service state (state: stopped / state: running)

What

A service manifest may now declare whether its container runs:

state: stopped   # or: running. Absent = today's behaviour, unchanged.
  • plan: stopped on a running container yields exactly one
    stop-service item; running on a stopped container yields one
    start-service item. Absent state plans nothing new.
  • apply: a declared stop stops the container in place. It is never
    deleted, its volumes are never touched, nothing is purged, and the route
    stays as it is (a stopped service answers whatever the edge returns for
    a dead backend). A fresh container that declares stopped is stopped at
    the end of its first deploy (health, route and post-deploy run on the
    deploy that starts it). An explicit running starts a stopped container
    before the rest is converged.
  • load: any other state: value is refused with the manifest path.
  • hash: absent state: is omitted from the plan JSON, so manifests
    without it hash exactly as before (existing golden suites unchanged).

MCP needs no schema change: the stop/start items render in the plan text
that get_plan already returns. README services reference documents the
field.

Why

Some services must be stopped without being forgotten: removing a manifest
cannot stop anything (a plan only creates, replaces, attaches, sets
limits/labels/env, restarts, publishes routes or runs hooks), while
deleting the container by hand is invisible to GitOps and the next deploy
recreates it. state: stopped makes the stop declarative, reviewable, and
reversible (running or removing the field starts it again).

Verification

Test-first, mirroring the existing hostSim harness (extended with
incus start):

  • plan shows stop only for stopped-on-running;
  • apply stops, keeps volumes/data, second plan is empty (idempotent);
  • absent state plans nothing and keeps the plan hash;
  • explicit running starts a stopped container;
  • fresh stopped containers stop in the same deploy;
  • bad values refused at load.

go test ./pkg/... ./cmd/... green (includes the golden plan-hash suites),
go vet and gofmt clean.

References

A service manifest may declare state: stopped or state: running
(absent = today's behaviour, unchanged).

- plan: stopped + running container -> one stop-service item;
  running + stopped container -> one start-service item.
- apply: stop in place (never delete, volumes/route kept);
  start before converging; fresh stopped containers stop after
  create (health/route/post-deploy deferred to the starting deploy).
- load refuses any other state value.
- absent state is omitted from plan JSON, so existing plan hashes
  are unchanged (golden suites green).

@wmantly wmantly left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wmantly
wmantly marked this pull request as ready for review November 13, 2026 03:42
@wmantly
wmantly merged commit 91eb012 into main Nov 13, 2026
2 checks passed
@wmantly
wmantly deleted the service-state branch November 13, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant