carlos / platform Public

stage-foreign-restart-452

Human

Fixes #452. On Tito production (IE, v0.28.15), carlos-stage rolled back a healthy titogo build (2bf0a40) as "did not come up: systemd restarted it (new invocation)". titogo's control daemon had restarted the same unit at the same second as the staging pass. The refusal then stuck for the whole box until the next merge.

Cause. 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.

Change. settleUnit now sorts each extra invocation into one of three cases:

  • NRestarts > 0: systemd's own Restart= started it. That is a crash-restart, and it fails at once, as before.
  • NRestarts 0: something else restarted the unit (an operator, or an app's own supervisor). The check moves onto the new invocation and keeps applying the same proof until the original deadline: active, MainPID's exe in the new version's directory, then the Ready probe. With no probe, the Hold starts again. The new invocation also gets its own exe check.
  • inactive/dead: this counts as an operator stop only when the unit has no pending Job (systemctl show now reads -p Job). Another caller's restart passes through that state with its start job queued, so the check now waits for it and judges what it starts. Before, it was read as an operator's stop and nobody checked the result.

A failed unit, a crash-restart, the old build still running at the deadline, or a build that never answers still fails. Any failure after a foreign restart now says "during the check it was also restarted N time(s) by something other than this pass, not by systemd's Restart=". It no longer reads like a crash.

Nothing is special-cased to titogo. Spec ยง2.3 of 2026-10-06-console-release-defences-design.md is amended to match.

Tests. New settleUnit cases:

  • the #452 sequence (written first, failing with the production message)
  • the Hold restarting in the new invocation
  • a foreign restart onto the old build
  • a foreign restart then never ready
  • a crash loop after a foreign restart, including the RestartSec wait
  • the stop half of a foreign restart, followed by healthy and by failed
  • the exe check not inherited across invocations
  • parseShow reading Job

agent_test.go's pinned systemctl argv is updated for -p Job. Full gate: see the reply on #452.

Review. Astra (gpt-6-astra) ran three rounds:

  • round 1: two blockers, both fixed
  • round 2: census not yet proposed, plus one P3
  • round 3: READY

Census approved for systemdUnits.Show and the internal/host envelope, recorded on #280. Findings are in docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r{1,2,3}.md.

Not merged, not released. Waiting for Paul. Follow-up (P3, task 905): a foreign restart whose invocations never reach active is not counted in the message. The verdict in that case is still correct.

Commits 10
Files changed 11 +385 −6
Discussions 0 0 open
Tasks 7/8 done

Discussions

  • No discussions on this branch yet.

Tasks 7/8 done

  • Failing tests: a concurrent foreign restart onto the new build fails settleUnit Done
  • Fix settleUnit: wait out a non-systemd restart, re-baseline, keep the same proof Done
  • Failure message names a restart by something other than this pass Done
  • Full gate (go build, vet, make test) Done
  • Independent review (Astra via codex) Done

Activity