Do not approve a coding-agent service patch because the unit file contains Restart=on-failure. Prove the merged unit that systemd will actually load, inspect its effective properties, then exercise a controlled process failure and record the resulting restart, delay, journal, and rate-limit evidence. The useful result is not merely a green syntax check: it is a small, repeatable record showing which failure restarts, when systemd stops retrying, and what an operator must do next.

The distinction matters because systemd combines several controls that are easy to confuse. The systemd.service reference describes the service-level restart policy, delay, and startup timeout. The systemd.unit reference describes the start-rate limit that can stop an otherwise valid restart loop. A patch can set each directive correctly in isolation and still produce the wrong runtime behavior after a drop-in, template instance, unit alias, or inherited manager setting changes the effective configuration.

Last reviewed: 2026-11-27

Define the restart contract before reading the diff

Write the expected behavior in plain language first. For a long-running worker, a reasonable contract might say:

  • A non-zero process exit is retried automatically.
  • A clean administrative stop does not create an unwanted restart.
  • Each retry waits for the configured RestartSec interval.
  • Startup that exceeds TimeoutStartSec is classified as a failure and follows the documented recovery path.
  • Repeated failures eventually hit an explicit start-rate limit rather than consuming the host indefinitely.
  • The service name, instance, environment, and dependency ordering remain unchanged.

The exact contract depends on the service type and operational policy. Restart=on-failure is not interchangeable with Restart=always, and neither setting is a health check for an application that remains alive while serving bad responses. Keep process supervision separate from application-level readiness and endpoint checks. If a patch changes Type=, ExecStart=, ExecStop=, TimeoutStartSec=, or dependency relationships, include those changes in the same review boundary.

For context around the repository side of the change, pair this test with the site’s Git patch audit and its deterministic lifecycle-hook guide . The first exposes file and mode changes that a normal diff can hide; the second helps keep automated evidence collection bounded and reviewable.

Validate the merged unit, not only the edited file

Start from a clean checkout of the patch and a disposable host or virtual machine that matches the supported systemd environment. Do not validate only the file the agent edited. A unit can be altered by a drop-in, an alias, a generated file, an instance substitution, or a package installation step.

Use the official verifier against the staged unit files:

systemd-analyze verify ./agent-worker.service

If the patch includes related units, verify them together:

systemd-analyze verify ./agent-worker.service ./agent-worker.socket

The systemd-analyze documentation shows verify reporting unknown settings, invalid sections, and dependency-load problems. Treat every diagnostic as a review item. A clean verifier result establishes that systemd can parse and load the supplied files; it does not prove that the process exits, restarts, or reaches readiness as intended.

Next inspect the unit after installation into the test host. systemctl cat shows the main unit together with visible drop-ins, while systemctl show exposes properties in a form that is easier to capture in a machine-readable evidence record:

systemctl cat agent-worker.service
systemctl show agent-worker.service -p FragmentPath -p DropInPaths -p Restart -p RestartUSec -p StartLimitIntervalUSec -p StartLimitBurst -p TimeoutStartUSec -p NRestarts -p Result

Compare the effective output with the contract, not with the patch’s preferred formatting. Record the loaded fragment path, drop-in paths, restart policy, restart delay, startup timeout, start-rate values, restart count, and current result. If FragmentPath or DropInPaths points somewhere unexpected, stop before running the behavioral test: you may be exercising a different unit than the reviewer inspected.

Exercise a controlled process failure

Use a temporary fixture or staging instance whose only deliberate fault is a predictable non-zero exit. Do not inject a crash into production or use an unbounded loop on a shared host. The fixture should match the production unit’s important settings, including service type, user, working directory, environment, and dependencies.

A minimal failure program can be as small as:

#!/bin/sh
exit 75

Point the test unit at that fixture, keep the failure reason documented, and use a short but observable RestartSec value. Start the service once, then collect both the human-readable state and the journal:

systemctl start agent-worker.service
systemctl status agent-worker.service --no-pager
journalctl -u agent-worker.service -b --no-pager
systemctl show agent-worker.service -p ExecMainStatus -p Result -p NRestarts -p ActiveState -p SubState

For Restart=on-failure, the expected evidence is a non-zero main-process status followed by another start attempt. The journal should make the sequence visible, and NRestarts should increase. Capture timestamps so the observed gap can be compared with RestartSec. Do not describe this as a test that was already run in the article or review package; the procedure is the acceptance test the patch owner must execute on the target environment.

Repeat the exercise for the failure classes that matter to the service. A clean exit, an explicit administrative stop, a startup timeout, and a dependency failure are not automatically equivalent. For each case, record the triggering condition, the expected action, the observed Result, whether a new process started, and the next owner action. If the contract intentionally excludes one class from automatic restart, make that exclusion an explicit assertion rather than an unexplained absence of evidence.

Separate restart delays from start-rate limits

A restart delay controls the wait between attempts. A start-rate limit controls how many starts systemd permits within a configured interval. The latter is the protection against a service that fails immediately and loops forever. The systemd.unit reference documents StartLimitIntervalSec and StartLimitBurst as the controls for this rate limit.

To test the boundary, configure a temporary fixture with a deliberately small burst and interval. Start it repeatedly through the same path the deployment uses. Expected evidence should show the first failures and then a refusal once the limit is reached. Preserve the journal and systemctl show output at the point of refusal. A later successful start after the configured interval is a different result from an immediate retry after the limit has been hit.

Be careful with systemctl reset-failed. The systemctl reference explains that this command resets the failed state and also resets the start-rate and restart counters. That makes it useful for beginning a fresh test run, but dangerous when inserted between each failure: it can erase the very evidence that the rate-limit assertion is meant to prove. Record when it is used and never treat a post-reset start as proof that the original limit did not exist.

Also separate TimeoutStartSec from RestartSec. The first bounds how long startup may take; the second controls the pause before a restart. If a patch changes both, create separate assertions so a slow startup does not get misreported as an unexpectedly long restart delay.

Record expected results and failure paths

A reviewer should receive a compact evidence packet rather than a screenshot of systemctl status. Include:

  1. The exact revision and unit instance tested.
  2. The output of systemd-analyze verify and any diagnostics it produced.
  3. The loaded fragment and drop-in paths from systemctl cat and systemctl show.
  4. Effective restart, timeout, and start-rate properties.
  5. Sanitized journal excerpts with timestamps for each controlled failure.
  6. The observed process status, result class, restart count, and final state.
  7. Any environment difference between the test host and the deployment host.
  8. A clear pass, hold, or repair decision for each contract assertion.

Keep secrets, full environment dumps, private paths, and unrelated logs out of the handoff. If the service reads credentials at runtime, record only the variable name or configuration source. If a failure cannot be reproduced because the test host lacks a dependency, mark the assertion unverified; do not convert an absent test into a pass.

Failure modes

The edited file passes verification but a drop-in wins. Inspect the installed unit and every drop-in. The effective configuration is the review target.

The service restarts, but the wrong process is being supervised. Check Type=, ExecStart=, process ownership, and the observed main PID. A wrapper can exit successfully while the child process fails separately.

A manual stop looks like a restart failure. Keep administrative stops separate from process exits. Document the command that triggered each state transition.

The restart loop is tested with reset-failed after every attempt. That resets counters and destroys rate-limit evidence. Use it only to initialize a new, explicitly labeled run.

A syntax pass is treated as a behavioral pass. systemd-analyze verify cannot prove that the application reaches readiness or that a particular exit status follows the intended policy. Run the controlled fixture.

A stale service state contaminates the result. Record the initial state, stop the fixture, clean up old processes, and begin from a known unit state. Preserve the cleanup result in the evidence packet.

FAQ

Is Restart=on-failure enough for a reliable worker?

No. It covers a class of process failures, but reliability also depends on startup timeouts, dependency ordering, rate limits, readiness checks, logging, and the application’s own recovery behavior.

Should every service use Restart=always?

No. Choose the policy that matches the service contract. Restarting after a clean exit can hide an intentional shutdown or turn a one-shot task into a loop. Review the service type and exit semantics together.

Does a successful restart prove that the patch is safe?

No. It proves only that one controlled failure followed the observed restart path. Review permissions, environment handling, dependencies, resource limits, and the deployment transition separately.

Sources checked

  • systemd.service — restart policies, restart delays, and startup timeout semantics.
  • systemd.unit — start-rate limiting and failed-state counter behavior.
  • systemd-analyze — static unit verification.
  • systemctl — effective-property, unit-state, and counter inspection.
  • journalctl — unit- and boot-scoped journal review.

These official latest man pages were checked on 2026-11-27. They document stable systemd behavior; the acceptance procedure still needs to run against the systemd version and service environment that will host the patch.

Reader next step

Choose one open coding-agent patch that changes a service unit or drop-in. Write the restart contract before running commands, verify the installed unit, exercise one controlled non-zero exit, and test the configured start-rate boundary in a disposable environment. Attach the sanitized properties, journal timestamps, and pass-or-hold decision to the review. If the patch cannot show which failure restarts and which failure stops, keep it blocked until the unit contract is explicit and reproducible.