Addresses the DevOps panel's release-engineering findings on scripts/deploy-hetzner.sh:
- flock(1) serialization around the whole deploy — two near-simultaneous main
pushes each background a deploy; without a lock both run `next build` in the
shared .next and collide ("Another next build process is already running"),
and the older ref could win. Blocking lock (-w 900) serializes so the newest
ref ships last; every step is idempotent so waiting is always safe.
- Rollback: snapshot the current box build to app.prev (excl. backups) before
rsync; if the restart or post-deploy verification fails, restore app.prev and
restart — a broken ship no longer strands the box.
- Deploy-result sink: a trap on EXIT reports every outcome (success/failure) as
a final status line, a desktop notification, and a row in the box debug_logs
(source=deploy) so a failed background deploy surfaces on /system instead of
dying silently in /tmp with an exit code nobody reads.
bash -n clean; flock confirmed present. Not triggered against prod (would ship).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>