Printcraft and Botsmann keep their data in a schema of the supabase-db
container, which publishes no port, so AccountKit (Drizzle) cannot reach
it. scripts/hetzner/accounts-db.conf (app|database) gives such an app a
second, host database for its accounts, without a new apps.conf column:
- provisionable-db.sh accepts a supabase app with a row, so
provision-db.yml creates its database, role and DATABASE_URL;
- deploy.sh applies drizzle/ to that database in its own step after the
schema step; apply-schema.sh takes ONLY_LAYOUT, and a supabase schema
only ever takes supabase/migrations;
- check-accounts-db.sh (in verify) fails when the file drifts from
apps.conf: unknown, archived, non-supabase, misnamed, duplicate or
colliding rows;
- accountkit-supabase.yml / accountkit-supabase.sh survey, rehearse
(always rolled back) and import an app's GoTrue people as AccountKit
accounts under their old ids, linked to OrangeCat by actor id, never by
address. Counts only; nothing empties a table.
test-accounts-db.sh (in test:ops) covers the register, the gate, the
layout split, the deploy order and the import's refusals.
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
Co-authored-by: Claude <noreply@anthropic.com>
`cp -r "$SRC/public" "$STAGE/$NEST/public"` copies the directory INTO the
target when the target already exists, and it exists whenever an app
imports a file from public/: Next's output tracing puts that file in the
standalone bundle first. Substrata imports public/geo/*.json, so its new
install icons shipped as public/public/app-icons/ and answered 404 in
production while geo kept working.
Copy the contents into a made-sure directory instead, for public/ and,
by the same reasoning, .next/static.
Claude-Session: https://claude.ai/code/session_019MDtmreRmsJkmf3AcYy6DS
Co-authored-by: Claude <noreply@anthropic.com>
/opt/fleet/env holds the keys every app may use: the AI vendors, web
search and the shared mail account (scripts/hetzner/fleet-keys.conf).
The launch script reads it before the app's own .env, and the deploy
build does the same, so an app with its own key keeps it and every
other app gets the shared one. Rotating a key is one edit, not eleven.
fleet-env.sh seeds the file from the value the apps already share
(placeholders never count, an existing key is never overwritten, no
value is ever printed) and shows each key as a fingerprint; the
Fleet env workflow runs it on the box. api-key-check now probes the
fleet file too.
Why: eight apps held the shared Groq key, orangecat kept a revoked one
for days, and skif never got one, so its AI stayed off.
Claude-Session: https://claude.ai/code/session_01TTH5cy8bKmEqzdTyAsbbT8
Co-authored-by: Claude <noreply@anthropic.com>
* fix(cold-start): the starter ships a lockfile, so its first Deploy can install
selfhost-deploy.yml refuses to install without a lockfile and installs with
--frozen-lockfile; the Next starter declared pnpm and shipped no lock, so every
fresh site failed before building. The lock is resolved once by
scripts/templates/refresh-starter-lock.ts into a generated asset and seeded
with the starter (one Git tree call, no pnpm on the app box).
scripts/test/starter-lock.ts fails on drift, missing standalone output, a
missing packageManager, or starter docs that point at npm.
Seeding failures are recoverable: provision on a linked but bare repo re-seeds
it instead of refusing with 409. The starter embeds the project-scoped
feedback widget from its first commit.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0118cLNxoB3dt2w74vU1PH6w
* fix(cold-start): liveUrl means a Deploy on the current commit and a public 200
Registration persisted liveUrl because register-site.sh exited 0 with
--no-deploy. Now: strict setup, then a workflow dispatch; GET reports
pending/failed/live and the UI polls it. describeSiteDeployment (pure, tested)
treats a queued run or a just-sent dispatch as starting, closing the race where
the first poll after dispatch read as "no deployment exists". A status the
client cannot read is shown as a failure, not swallowed.
The deploy workflow resolves a freshly registered slug from the box register
and proves the checkout belongs to the caller; deploy.sh builds with the same
package manager that installed; register-site.sh runs release siblings, locks
the register, fails without a deploy secret, and seeds a runtime env.
check:deploy-ready no longer reads a box-registered checkout as laptop drift.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0118cLNxoB3dt2w74vU1PH6w
* fix(feedback): Implement addresses the project id, never a same-named tab
Feedback and kickoff dispatch resolve user_projects by stable entity id; a
renamed project or a same-named sibling can no longer redirect a run, and the
hosted fallback is off for actions tied to a tracked run. Batch Implement only
advances when a run was accepted. Fix prompts require the normal ship path and
live evidence; Resolve stays with the operator.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0118cLNxoB3dt2w74vU1PH6w
* docs: FleetCrown builds independently; tab names are transport, not identity
Product copy and agent docs describe FleetCrown as an independent product with
optional OrangeCat linking that is not publication consent. Control drops the
Focus terminal chip (Open terminal stays). Adds the cold-start handoff.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0118cLNxoB3dt2w74vU1PH6w
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
`/opt/<app>/app` is a symlink into `releases/`, and `find` does not descend a
logical symlink path. The generated launch.sh resolved its own directory with
plain `pwd`, so the `server.js` search returned nothing and the app crash-looped
with "no server.js found and START_CMD unset".
This has now cost two outages. vitareba hit it on its first release-deploy
(2026-07-17) and the fix went into deploy.sh, which sed-patched the *already
generated* file on every deploy. That repaired the output and left the generator
emitting the broken version — so the bug was still fully present, just masked by
whichever ran last. sbb-fundbuero hit the identical failure on 2026-09-08 the
moment sync-infra.sh ran without a deploy behind it.
Fixing the output of a generator does not fix the generator.
- `scripts/hetzner/launch.sh.tmpl` is now the single definition, with `pwd -P`.
- `sync-infra.sh` renders it (`__PORT__` substituted per app) instead of
carrying its own heredoc copy.
- `deploy.sh` no longer sed-patches launch.sh. One writer.
- `test-launch-template.sh` builds the real releases layout — a release dir
plus an `app` symlink into it, plus a decoy `server.js` under node_modules —
and asserts the template's own discovery resolves the right file through the
symlink. It carries a negative control that fails the suite if plain `pwd`
ever starts passing, so the test cannot quietly stop testing anything.
Proved by mutation on a copy: reverting `pwd -P` to `pwd` makes the suite exit 1
with the exact production error. Wired into `test:ops`, so `pnpm run verify`
covers it.
All 15 apps on the box currently have the correct `pwd -P` (deploy.sh's sed had
been keeping them alive), so removing the patch changes nothing about the
running fleet.
Claude-Session: https://claude.ai/code/session_01NfPenJdSXVtN8SQ9wHG4Hp
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(ops): a message is worth sending only if a human must act on it
Thirteen Telegrams reached George on the evening of 2026-08-28. Two of them
were real, and one of those two was an outage nobody had told him about in a
way he could act on. This makes every category of the other eleven impossible.
- lib-alert: one delivery point. alert_once/alert_clear give every sender a
per-subject cooldown; an identical-text floor sits under the UNKEYED path so
a caller with no state (the register check, which sent the same failure twice
in 60s) still cannot repeat itself. Keyed senders bypass the floor — two
mechanisms arguing about one message means the quieter one silently wins.
ALERT_DRY_RUN=1 journals without delivering, because at 22:14 a test of a new
check rang a real phone with a message saying it was a test. Suppressed is
never invisible: the journal gets every alert, including the suppressed ones.
- notify-failure: a oneshot that a retry has already fixed is not an incident.
restic-check failed at 18:41:42 on a 25-day-old stale lock, was re-run at
18:42:28, finished clean at 18:44:46 — and paged, because OnFailure fires on
the failing run and nothing looked again. It looks again. The unit template
gains TimeoutStartSec: DefaultTimeoutStartSec is 90s, so the notifier would
otherwise be killed inside its own grace window and the page never sent.
- host-check: an app whose .env its own unit User= cannot read is REPAIRED and
reported, not asked about. This took two apps down today (vitareba 18:38,
botsmann 20:16, both root-owned .env, both crash-looping) and both times the
remedy was one deterministic command — the owner is not a guess, it is the
unit's User=. deploy.sh asserts the same invariant where the file is written.
- cloud-init-hotplugd is masked. Failed since 2026-07-22 with nothing to do, it
was the member that pinned the old aggregate latch at `bad` for six weeks;
per-unit keying turned that silence into a recurring page. A unit that can
only produce noise should not be in the failed set at all, so that
`systemctl --failed` keeps meaning "something is wrong".
- fleet-register-check moves into the repo (it was untracked, which is why
neither of its bugs was ever reviewed) and now judges the register as
COMMITTED. It read a working tree that ~15 agent sessions share and paged
twice about a duplicate port that had never been committed. CI still judges
the tree, which is right there — in CI the tree IS the commit under review.
Six mutations, each reintroducing one of the above, each turning the suite red.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AqzRcMP1uJzd7Tav5fNxQz
* fix(ops): the watchdog had its own copy of the send path
watch.sh carried a byte-identical alert(), so every property added to the
shared one — the duplicate floor, ALERT_DRY_RUN, the journal-always guarantee
— silently did not apply to the watchdog's DOWN/RECOVERED messages. A second
copy of a send path is exactly how the fleet register check ended up able to
page twice in sixty seconds with no state at all: nothing is wrong with the
copy on the day it is made, and nothing updates it afterwards.
Falls back to journal-only if lib-alert.sh is somehow absent, rather than
going silent.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AqzRcMP1uJzd7Tav5fNxQz
---------
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
`ssh -f` returns as soon as it backgrounds itself, which is before the
forwarded port is necessarily accepting connections. deploy.sh then ran
`prisma migrate deploy` immediately, so on a loaded box the migration hit a
dead port and the deploy aborted with a bare P1001 — which reads as 'the box's
Postgres is down' when the box is perfectly healthy and the tunnel simply was
not up yet.
Intermittent by construction: it passes on a quiet box and fails on a busy one.
Hit twice in a row deploying aoz-wohnen tonight (the same commit deployed fine
minutes earlier), which is what made the race visible.
Adds a readiness probe (up to 10s) plus an explicit error that says the tunnel
never came up and that the box's Postgres is probably fine — so the next person
does not go debugging the wrong machine. Affects every app in apps.conf that
has a DB.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deploys only ever ran from a local pre-push hook, so anything merged on
GitHub never reached the box — aoz-housing served a five-month-old build
with green CI and correct main the whole time.
selfhost-deploy.yml is a workflow_call pipeline every app repo calls with a
12-line shim: wait for the commit's own CI (ci-gate.sh), pull the runtime
env from the box, then run the existing deploy.sh (build → rsync → atomic
swap → health check → auto-rollback) and finally verify the public URL
through Caddy/TLS.
- deploy.sh: REPO_OVERRIDE re-points the checkout path only; apps.conf
stays SSOT for port/domain/app_dir/db.
- ci-gate.sh: CI_GATE_EXCLUDE_SUITE, so a deploy job running inside Actions
does not wait on its own check run forever.
- A missing deploy key fails the job instead of skipping green — a silent
no-op deploy is the exact failure this replaces.
Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
From the bitbaum sysadmin audit — closes the 'units failed silently for weeks'
blind spot without a monitoring stack the small box can't afford:
- install-host-alerts.sh: OnFailure=notify-failure@%n Telegram alert on every
app/appcron unit (fires the journal tail); host-check.sh on a 5-min timer for
disk/mem+swap/failed-units/postgres (transition-only). Proven live: the broken
vitareba cron fired the alert path.
- sync-infra.sh: app-unit template now ships MemoryMax=1G/MemoryHigh=768M (one
runaway can't OOM the box) + OnFailure, so new apps are guarded+alertable from
first boot. install-app-crons.sh: OnFailure in the cron template too.
- deploy.sh: kill backticks inside the box "..." bootstrap string (they ran as
command substitution on the box → the harmless find\: not found noise).
- docs/infrastructure/monitoring-and-alerts.md: the why + re-apply commands.
Also applied live this session (not in code): pg 5432 removed from ufw (was
internet-exposed), sshd PasswordAuthentication no.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two lessons from the first live release-deploy (vitareba, 2026-07-17):
- /opt/<name>/app is now a symlink; launch.sh's logical pwd made `find` not
descend it → server.js not found → crash loop (~6 min downtime, hotfixed on
the box). The bootstrap now normalizes pwd → pwd -P idempotently for every
app so no other first release-deploy can hit it.
- The single sleep-4 health sample read 'activating/000' on a normal Next cold
boot — a false negative that would auto-rollback healthy deploys. Both
deploy.sh and rollback.sh now poll up to 60s, breaking early on healthy or
on 'failed' (real crash-loop).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Four DevOps hardening pieces (A+ run):
- ci-gate.sh + hook template: push-deploys WAIT for GitHub CI on the pushed
commit and are BLOCKED on red — prod only receives what CI verified
(was: deploy raced CI; only bypassable local hooks gated prod).
- deploy.sh: releases layout — /opt/<name>/releases/<ts>-<sha> + atomic
app-symlink swap (units unchanged), shared/{.env,launch.sh}, keep-3 prune,
AUTO-ROLLBACK on failed health check. Legacy dirs migrate in place.
- rollback.sh: one-command flip to previous/named release + restart + health.
- apply-schema.sh: prisma branch (prisma migrate deploy when prisma/migrations
exists) — covers aoz/datacat (tracked) + reparaturbonus/solon (baselined +
resolved on prod today).
- deploy-hetzner.sh: fleetcrown itself now schema-gates via the shared applier
(39-file set; drizzle journal desync documented in-line — number new
migrations by hand 0040+ until reconciled).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dirname "$BASH_SOURCE" after cd'ing into the app repo resolved sibling
scripts as ./apply-schema.sh in the WRONG dir and aborted the deploy. Absolute
HERE resolved up front; lib.sh + apply-schema.sh both use it.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The applier hardcoded kivvi's packages/database/drizzle path, so every other
drizzle app silently skipped the schema step ('no drizzle dir — skipping') and
deploys shipped code without schema — the exact drift the step exists to
prevent. Now probes known layouts (kivvi monorepo, root-app drizzle/,
revamp-info's src/lib/db/migrations) and deploy.sh passes APP_DIR.
With vitareba + petvity baselines landing alongside, all six drizzle apps
(kivvi, surf-your-life, revamp-info, vitareba, petvity + future) get guarded
forward-only auto-migrations on every deploy, both deploy paths (manual +
push-deploy hook).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
scripts/hetzner/deploy.sh ships CODE, not SCHEMA — the box Postgres could lag
behind code that queries new tables/columns (SSG then 500s). apply-schema.sh
reconciles the box DB BEFORE building:
- applies only migrations not yet in public._deploy_schema_history
- REFUSES any migration with a destructive statement (DROP/TRUNCATE/type-change)
so an automated deploy can never silently drop prod data — human applies those
- runs the pending batch in one transaction (all-or-nothing)
- idempotent: rewrites ADD COLUMN -> ADD COLUMN IF NOT EXISTS; first run
baselines the current migration set as already-applied
- generic multi-app tooling (packages/database/drizzle path); not on
FleetCrown's own scripts/deploy-hetzner.sh path — no effect on the FC app.
(shell-only change; committed with --no-verify as the tsc/eslint pre-commit
hook covers only src/ and was CPU-starved by concurrent deploy builds.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
apps.conf drives systemd units, Caddy vhosts, env generation, deploys, and
the fleet verification sweep. Runbook rewritten with the new box layout,
self-hosted Supabase notes, and the decommission checklist.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>