A fix is ready for review on stage-foreign-restart-452. It is not merged and not released; that is Paul's call. Tito production stays on v0.28.15.
What was wrong. settleUnit (internal/host/unitsettle.go) is the "did it come up" check behind every named-unit restart: stage/adopt, the rollback restart, and the legacy and root restart requests. It fixed on the first new invocation it saw and failed on any later one, as "systemd restarted it (new invocation)". titogo-controld's restart at the same second was exactly that.
What changed. The fix is in the check itself; nothing is specific to titogo.
- A later invocation with
NRestarts0 is now treated as a restart by something else. A crash-restart by systemd'sRestart=bumps that counter and still fails at once. For the NRestarts-0 case, the check moves onto the new invocation and keeps the same proof until the original deadline: active, MainPID's exe in the new version's directory, then the Ready probe (socket or HTTP). With no probe, the Hold starts again in the new invocation. A restart onto the same healthy new build now passes. inactive/deadcounts as an operator stop only with no pendingJob. Another caller's restart passes through that state with its start job queued. Before, that read as "stopped, not judged" and the new build went unchecked.- It still fails on a failed unit, a crash loop, the old build at the deadline, or a build that never answers.
- The message says when the restart wasn't a crash. Failures after a foreign restart now add "during the check it was also restarted N time(s) by something other than this pass, not by systemd's Restart=".
How it was tested.
- The #452 sequence was written first as a test and failed with the production message ("did not come up: systemd restarted it (new invocation)").
- New
settleUnitcases cover: a foreign restart onto the new build (passes), the Hold restarting, onto the old build (fails, with the note), never ready (fails, with the note), a crash loop after a foreign restart including the RestartSec wait (fails at once), the stop half of a foreign restart followed by healthy and by failed, and the exe check not carried across invocations. go test ./internal/host/ -run 'TestSettle|TestParseShow|TestNamedRestart|TestRollbackRestart|Restart'passes. The census tests (./internal/provision -run 'Census|Plan14') pass.- amadan CI on the tip 68da4b7f6e8ce525edc907f33dd016532adab4e4: passed. - The run before it, on 00a7dee6, failed two tests in other packages:
TestLargeManifestReleaseThenKeep(activator) andTestDBForwardThroughTheBackhaulHop(root). Both pass on local re-run (×5, ×3), so they look like flakes. - A local fullmake testhit only environment failures that CI does not have (VCS stamping inside a linked worktree, a privileged-mount test).go build ./...andgo vet ./...are clean.
Review. Astra (gpt-6-astra) ran three rounds; findings are under docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r*.md.
- Round 1 found two blockers, both fixed: the stop half above, and a
/procpermission skip leaking into the next invocation. - Round 2 found the census overlay missing (now proposed) and one P3.
- Round 3: READY, census approved and recorded on #280.
Left open.
- Follow-up P3 (branch task 905): a foreign restart whose invocations never reach
activeisn't counted in the message. The verdict is still right. - This branch does not cover the downstream point in the issue: letting the box publish "refused 2bf0a40" somewhere titogo's deploy check can read. That is a separate change if wanted.
- The fix relies on systemd's
NRestartssemantics (a manual start resets it;Restart=increments it before the new invocation). The existing check already relied on them, and Astra checked them against systemd v257's source.