Skip to content

feat: restart sockets around their running service - #53

Merged
outergod merged 6 commits into
masterfrom
socket-restart-sequence
Nov 30, 2026
Merged

outergod merged 6 commits into
masterfrom
socket-restart-sequence

Conversation

@outergod

Copy link
Copy Markdown
Owner

Summary

Archives OpenSpec change socket-restart-sequence and releases as 3.2.0 (minor). Fixes field-report point 4: a ListenStream= change on traefik.socket while traefik.service ran made systemd refuse the socket restart, so apply failed halfway and the old listener stayed.

  • Each created or changed socket (base unit or added/changed drop-in) is started or restarted exactly once per plan.
  • The service the socket activates is resolved with the verifier's rule (last Service= across base unit and desired drop-ins, else <stem>.service). If it was active, the plan stops it before the socket action and starts it again once after all diff actions; an inactive or failed service is left alone, so socket activation still starts it on demand.
  • A container diff's restart of that service moves behind the socket restart (one RestartUnit), config-driven restarts skip a service the sequence already starts, and a changed socket no longer starts its same-stem service unconditionally (still done for created sockets, once).
  • Observation now also queries each desired socket's service, even when no managed artifact owns it; it never becomes a plan entry or verification target. Template sockets get no stop/start, since the activation guard removes them.
  • plan shows the stop/start on the socket's entry: JSON activated_service: {unit, disposition: "stop_start"} and the human line service <unit> will be stopped for the socket change and started again. Apply reports the steps under that entry, and a failed stop/start names the service, e.g. (service traefik.service).
  • No new action type; apply's two-phase execution is unchanged apart from where events are attributed.

Verification

  • cargo build --locked, cargo test (65 lib + 579), cargo clippy --all-targets -- -D warnings, openspec validate --all --strict, core-ops-release validate --base-ref origin/master all pass.
  • New accepted VM scenarios, all passed on the blessed VM profile on ulthar (28/28 assertions): accepted-socket-restart-active-service, accepted-socket-restart-inactive-service, accepted-socket-added-running-service, with the socket-restart-history fixture.
  • The E2E gate (full accepted corpus) still needs homelab-e2e approval.

Notes

  • The scenarios assert the activated-service line on a plan step: apply output does not render it, per the spec (as with template instance lines). The task wording was corrected before archiving.
  • Known follow-up, recorded in docs/follow-ups.md: a socket change still classifies the socket-activated container as restart ("dependency changed"), so plan and apply report container/frontend.container restarted and 1 restart although the executable plan never restarts it. The VM runs show it for both active and inactive services. This was already there (reconciliation D22 / operator-output D17); the follow-up entry proposes a fix. Also recorded: the activation race, Service= retargeted in the same change, and removed socket drop-ins (design D7).

🤖 Generated with Claude Code

outergod and others added 3 commits November 29, 2026 18:38
Adding or changing a socket whose service is running no longer fails apply: core-ops stops the service, starts or restarts the socket once, and starts the service again. Plan shows it as activated_service on the socket's entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pport

support-template-quadlets landed in v3.1.0. Record how the restart
bracket meets its activation guard (design D9, task 3.6), derive
`activated_service` after the guard, and list the field in
operator-output "Plan JSON document" now that the parallel change no
longer owns that requirement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A created or changed .socket whose service runs was started or restarted
directly, so systemd refused ("Socket service ... already active") and
apply failed halfway with the old listener in place.

The planner now starts or restarts each created or changed socket exactly
once. When the service it activates (resolved like the verifier, from
Service= across the base unit and drop-ins) was active, the plan stops it
before the socket action and starts it again once after all diff actions;
an inactive service is left alone. Container restarts of that service move
behind the socket restart, config-driven restarts deduplicate against it,
and a changed socket no longer starts its same-stem service unconditionally.
Observation now also queries each desired socket's service, even when
unmanaged.

plan shows the bracket as `activated_service` on the socket entry and a
"service <unit> will be stopped for the socket change and started again"
line; apply reports the stop and start under the socket entry.

Covered by three accepted VM scenarios (passed on ulthar), archives the
socket-restart-sequence change and prepares release 3.2.0. Records the
phantom container restart seen in those runs and the design's follow-ups
in docs/follow-ups.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T08:17:27.869232Z 0024c17 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2fcde30923

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/planner.rs Resolved
An Accept=yes socket starts one service instance per connection and
activates no shared service, but the restart sequence resolved it to
<stem>.service like any socket. A changed echo.socket therefore stopped
and started an unrelated active echo.service, and observation queried it.

Resolve Accept= like Service= (last assignment across the base unit and
desired drop-ins, empty resets to no). An accepting socket is still
started or restarted once, with no stop, start or observation of a
service on its behalf. Specified as quadlet-artifacts "Accepting sockets
activate no shared service"; recorded as design D10 and task 3.7 of the
archived socket-restart-sequence change, which has not shipped yet.

Addresses the Codex review finding on PR #53.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c10ac653f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/planner.rs Resolved
A template socket is never started, but the restart sequence still
resolved its Service=. With `Service=shared.service` on app@.socket, a
drop-in change under app@.socket.d/ stopped and started an active
shared.service; the activation guard then dropped the app@.socket
restart (a template target) but kept the stop and start (a
non-template target), bouncing the service without touching any
listener. Template sockets are now skipped before services are
resolved (design D9 revised, task 3.8, new scenario "Template socket
names a shared service").

Also adds the accepted regression scenario for accepting sockets
(task 6.5): accept-socket-history changes an Accept=yes echo.socket next
to a running echo.service, then moves Accept=yes into a drop-in, and
checks that echo.service keeps its InvocationID. It passes on the VM and
fails with a core-ops built before the Accept= fix.

Addresses the two Codex review findings on 5c10ac6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d9b52215d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/verify.rs Resolved
systemd accepts `Service = x.service` and `Accept = yes`, but the socket
directive lookup only matched `Service=` and `Accept=` verbatim. A spaced
Service= therefore resolved to <stem>.service: the planner bracketed the
wrong service (or none) and systemd refused the socket start because the
real service ran; a spaced Accept= was ignored and an unrelated service
was bracketed. Assignments are now split at `=` and the key trimmed
(task 3.9, scenarios "Whitespace around ...").

Adds accepted VM regression coverage for this and for the template
socket fix in 9d9b522 (task 6.6): socket-shared-service-history changes a
template socket's drop-in while shared.service runs (invocation must be
kept), then adds web.socket with `Service = shared.service` (apply must
converge). accept-v3 now spells `Accept = yes`. Both scenarios pass on
the VM; a core-ops built from 5c10ac6 fails exactly those assertions,
with systemd logging "Socket service shared.service already active,
refusing".

Addresses the two Codex review findings on 9d9b522.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@outergod
outergod deployed to homelab-e2e November 30, 2026 08:15 — with GitHub Actions Active
@outergod
outergod merged commit 9dd1255 into master Nov 30, 2026
5 checks passed
@outergod
outergod deleted the socket-restart-sequence branch November 30, 2026 10:35

This branch was successfully deployed

1 active deployment
homelab-e2e — 0024c17e Deployed Nov 30, 2026 by outergod via e2e-gate #122
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