Commit Graph
13 Commits
Author SHA1 Message Date
CatoandClaude Fable 5.1 a1aed85daa fix(cold-start): a brief becomes a repo and a live site through the normal path (#569)
* 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>
2026-09-10 12:51:11 -07:00
CatoandClaude Opus 5 f518a1c566 fix(hetzner): sync-infra generated a launch.sh that cannot find server.js (#530)
`/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>
2026-09-08 09:00:22 -07:00
65dea6f303 chore: pnpm — the fleet has one package manager (#478)
* chore: pnpm — the fleet has one package manager

- packageManager pnpm@11.25.0; lockfile via pnpm import, package-lock.json
  removed; npm "workspaces" replaced by pnpm-workspace.yaml packages
  (packages/agent), and bridge/ joins the workspace — one install, one
  lockfile, its own package-lock.json removed
- npm "overrides" (fast-uri pin) moved to pnpm-workspace.yaml (pnpm ignores
  the npm-only field)
- allowBuilds: better-sqlite3, node-pty, @sentry/cli, native toolchain, and
  the two git-hosted deps (@fleet/ai-forms, limitkit — pnpm wants the exact
  resolved spec, keys move with the pinned tags); temporary
  minimumReleaseAgeExclude for our own @bitbaum/ai-kit@0.6.2
- phantom deps declared: @auth/core (src/auth.ts augments @auth/core/jwt —
  TS2664 under pnpm's strict layout), dotenv, sharp (scripts)
- CI/audit/deploy workflows: pnpm/action-setup@v6, store-dir pinned outside
  the action's bin dir, cache: pnpm, frozen-lockfile; deploy's separate
  `npm --prefix bridge ci` is covered by the workspace install; Next cache
  key hashes pnpm-lock.yaml; npm audit → pnpm audit
- desktop-release: root install → pnpm; desktop/ itself STAYS an npm package
  (own package-lock.json, electron toolchain untouched)
- husky: pre-push staleness gate now compares pnpm-lock.yaml against
  node_modules/.modules.yaml; hooks + scripts (deploy-hetzner, hetzner/deploy,
  install-app, doctor, smoke) converted to pnpm
- check-deploy-ready fleet gate now recognizes pnpm verify/test lines too

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

* fix: prettier-format pnpm-workspace.yaml — format:check gates verify

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

---------

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-04 10:35:27 +00:00
644de633b0 fix(ops): a message is worth sending only if a human must act on it (#433)
* 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>
2026-08-28 20:48:02 +00:00
GandClaude Opus 5 4b2dc46db7 fix(deploy): wait for the DB tunnel before running migrations (#189)
`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>
2026-08-07 06:45:55 +00:00
5769fb846a feat(infra): one reusable CD workflow for every self-hosted app (#144)
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>
2026-08-03 09:33:58 +02:00
GandClaude Opus 4.8 799ffa1754 feat(ops): push-based box alerting + memory guards (no Grafana needed) (#71)
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>
2026-07-17 19:52:51 +02:00
GandClaude Opus 4.8 567b0c845e fix(deploy): pwd -P in shared launch.sh + 60s health poll (#69)
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>
2026-07-17 18:48:53 +02:00
GandClaude Opus 4.8 7adaf874cc feat(deploy): CI-gated deploys, atomic releases + rollback, prisma migrations, fleetcrown schema step (#68)
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>
2026-07-17 18:39:45 +02:00
GandClaude Opus 4.8 225fe3d8a0 fix(deploy): resolve script dir before cd — relative invocation broke schema step (#67)
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>
2026-07-17 18:09:56 +02:00
GandClaude Opus 4.8 87f5edea97 fix(deploy): apply-schema resolves migrations dir per app layout (#66)
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>
2026-07-17 18:05:38 +02:00
Mao NakamotoandClaude Opus 4.8 d14fc3b607 feat(infra): guarded forward-only DB schema applier for box deploys
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>
2026-07-14 19:14:06 +02:00
Mao NakamotoandClaude Fable 5 625595db93 feat(infra): full Vercel/Supabase/Neon exit — SSOT manifest + deploy tooling for 16 self-hosted apps
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>
2026-06-12 19:42:46 +02:00