stage-foreign-restart-452
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 pendingJob(systemctl shownow 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
parseShowreadingJob
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.
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
- claude agent, operated by paul@keymail.dev pushed 63a5038d3 stage-foreign-restart-452: re-run CI (internal/edge TestProbedDelayedProbeServedWithinR timing flake; internal/edge is identical to main)
- claude agent, operated by paul@keymail.dev pushed 2db213046 Merge remote-tracking branch 'origin/main' into stage-foreign-restart-452
- claude agent, operated by paul@keymail.dev pushed 1734c1c71 Merge origin/main into stage-foreign-restart-452; census overlay re-sealed on top of rootfs-apps-4 (same unit, claim and envelope)
- claude agent, operated by paul@keymail.dev pushed 103109b9a stage-foreign-restart-452: re-run CI (TestOfflineSealFinishingLiftsOnlyAfterEverySourceIsGone flaked in one host shard; passes 50/50 locally, untouched by this branch)
- claude agent, operated by paul@keymail.dev pushed 1236a5dd9 Merge origin/main into stage-foreign-restart-452; census overlay re-sealed on top of fresh-box-446 (same unit and claim; internal/host envelope re-pinned for main's changes)
- task updated: Full gate (go build, vet, make test)
- task updated: Push, describe, reply on #452
- claude agent, operated by paul@keymail.dev pushed 68da4b7f6 ci: re-run the gate (00a7dee6 failed TestLargeManifestReleaseThenKeep and TestDBForwardThroughTheBackhaulHop, both unrelated and passing on local re-run)
- task updated: Census: propose overlay for systemdUnits.Show (+ internal/host envelope), Astra verdict on #280
- task updated: Fix settleUnit: wait out a non-systemd restart, re-baseline, keep the same proof
- task updated: Failure message names a restart by something other than this pass
- task updated: Independent review (Astra via codex)
- task updated: Failing tests: a concurrent foreign restart onto the new build fails settleUnit
- claude agent, operated by paul@keymail.dev pushed 00a7dee61 review: Astra round 3 for #452 (READY; census approved)
- claude agent, operated by paul@keymail.dev pushed 250c74660 census: propose systemdUnits.Show (-p Job) for #452; review rounds 1-2 and the round-3 brief
- claude agent, operated by paul@keymail.dev added task Follow-up (P3, Astra r2): count a foreign restart whose invocations never reach active (activating/A โ activating/B โ failed/B), so the note appears in that failure too
- claude agent, operated by paul@keymail.dev added task Census: propose overlay for systemdUnits.Show (+ internal/host envelope), Astra verdict on #280
- claude agent, operated by paul@keymail.dev pushed 776d3748f settle: a foreign restart's stop half is not an operator stop (#452 review 1)
- claude agent, operated by paul@keymail.dev pushed 9156bc899 settle: wait out a restart this pass did not make (#452)
- claude agent, operated by paul@keymail.dev added task Push, describe, reply on #452
- claude agent, operated by paul@keymail.dev added task Fix settleUnit: wait out a non-systemd restart, re-baseline, keep the same proof
- claude agent, operated by paul@keymail.dev added task Failure message names a restart by something other than this pass
- claude agent, operated by paul@keymail.dev added task Full gate (go build, vet, make test)
- claude agent, operated by paul@keymail.dev added task Independent review (Astra via codex)
- claude agent, operated by paul@keymail.dev added task Failing tests: a concurrent foreign restart onto the new build fails settleUnit