The product, its assistant, the repo, the host and every unit on the box now
share one name. 638 files, ~3,000 mentions: UI copy, config, env keys
(FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs,
articles, the deploy workflow other repos reuse, and nine file names.
- Three article slugs carried the old name and had been shared; permanent
redirects keep those links alive (next.config.ts).
- test-no-retired-name.sh now also forbids the old product name across the
whole repo, so the rename cannot creep back through templates and examples.
- ASSISTANT_STACK collapses the product and the assistant into one entry,
because they are now the same name.
Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki`
database and role, loki.orangecat.ch (old host 308s to it; /api, /widget,
/embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases.
The Resend sending domain stays fleetcrown.orangecat.ch until the new domain
is verified in DNS.
Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Two flaws in #279, found before its deploy ran.
1. The stamp preferred GITHUB_SHA over the checked-out commit. deploy.yml's
workflow_run path checks out `workflow_run.head_sha`, which is not always the
run's GITHUB_SHA, so the marker could name a commit that was never compiled.
Since the deploy compares the live marker against the shipped ref, a lying
marker manufactures a false alarm. Git HEAD is literally what was built, so
it now comes first; GITHUB_SHA is the last resort for checkouts with no .git.
2. A mismatch rolled the box back. The realistic cause of a mismatch is a second
deploy landing behind this one — and reverting to app.prev would discard the
NEWER build, turning a benign race into exactly the incident the check exists
to catch. It now reports loudly and leaves the running build alone. What was
missing before was never the ability to revert; it was ever being TOLD that
the box serves something else. That, plus /api/health, is the fix.
Both are pinned by tests, including one asserting the mismatch path does not
call rollback_box.
Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
/api/health advertised a `version` field that is `npm_package_version` — always
null under systemd — and the box kept no deploy marker anywhere. The only way to
answer "is prod on main?" was to ssh in and grep the compiled bundle for a symbol
you knew was in the new source.
That is not cosmetic. A hand-run `npm run deploy` ships whatever branch the
worktree is on, and it has now rolled production back three times. The third was
today, 14:19 UTC, WITH the off-main gate in place — that gate requires the commit
to be *contained in* origin/main, and an ancestor passes it cleanly. Both `app`
and `app.prev` were rotated to the stale build, so the correct CI build was
destroyed, and the fix from #275 was live at 12:40 and gone by 14:20. It surfaced
only because a live probe of /api/control disagreed with the database, and it
cost about fifteen commands to pin down. Every previous occurrence presented the
same way: a fix demonstrably on main, missing at runtime, indistinguishable from
an application bug.
Now the artifact carries its own identity:
- scripts/record-build-ref.sh stamps the commit into .next/standalone at BUILD
time — one writer, so the marker rides both deploy paths (the local script and
the Deploy workflow, which builds the same way then ships with --no-build).
Best-effort: an unresolvable commit degrades to `commit: null`, never a guess,
and never a failed build.
- /api/health reports it, so `curl .../api/health` answers the question.
- The deploy reads the commit back OFF THE LIVE BOX and rolls back if it differs
from what was just shipped. Health returning 200 proves the box is up, not
that it is up on this build — which is precisely how a clobbered deploy passed
verification three times.
scripts/test/build-ref-marker.ts covers the whole chain (stamp → artifact →
health → deploy assertion), because every link is deploy-time-only code, the
kind that rots unnoticed until the incident.
Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>