Commit Graph
17 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 e0f98d97f7 fix(box): a sleeping app naps with SIGKILL so a slow stop is not a page (#1590)
SuccessExitStatus=143 only covers a Node that exits within the template's
3s TimeoutStopSec. biaslens-app (2026-11-04) did not: systemd killed it,
recorded Result=timeout, the unit read failed and the nap paged as an
incident. A nap follows 15min with no connection, so nothing is left to
drain; stop sleeping apps with SIGKILL and count it as a clean exit. OOM
kills still read failed (Result=oom-kill comes from the cgroup).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 07:26:51 +00:00
CatoandClaude 987f77d61b feat(box): an accounts database beside a supabase schema (#1562)
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>
2026-11-02 21:53:29 +01:00
CatoandClaude 9e953a8c1f fix(sites): a site retired offline stays offline; one name per site (#1330)
center-com.orangecat.ch (the older Center SOM build) was taken offline with
retire-site.yml and its repository archived; the preview at
centersom.orangecat.ch is Center SOM. Its apps.conf row is now archived, and
an archived row is skipped by a full sync (lib.sh app_names), the push-deploy
installer and the watchdog — otherwise the next sync-sites run would have put
it back online, and the watchdog would have paged it as down.

The previews doc gains the rule the owner asked for: address, project and
repository are one word.


Claude-Session: https://claude.ai/code/session_01HyfPCAeTFi2sjpVY44Y1JJ

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-19 18:09:16 +02:00
CatoandClaude Sonnet 5.5 0c5ee9199b feat(previews): a preview is the whole of its own address, and a finished site can be brought in (#1193)
* feat(previews): a preview is the whole of its own address, and a finished site can be brought in

"create website for Murphy's Bar" now ends at murphys-bar.orangecat.ch, behind
the access code, with the widget on it.

- attach-preview-host.sh + lib.sh preview_vhost: a Caddy vhost per preview.
  Wildcard DNS already points every label at the box, so there is no record
  to set. "/" opens the entry file, everything else moves under /p/<label>/,
  and X-Preview-Root tells Loki the preview is the root
- handle.ts: with that header the cookie is scoped to "/", the gate posts to
  "/", and the widget loads from Loki's own origin
- createPreview takes an address (default: the name) and attaches the host,
  falling back to the /p/ path with the reason when the server cannot
- Build a preview takes a .zip of a finished site (unpack.ts: no unsafe paths,
  no symlinks, no .git, byte-counted) and commits it as it arrived
- Docs: prospect-previews.md ("Its own address", "A site that already exists",
  "Create website for <name>") and the standing flow in CLAUDE.md
- Tests: previews, previews-route (own-address cases), preview-unpack,
  test-preview-host.sh (in test:ops)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpakL9C3TESU4H45fXMFfc

* fix(previews): read the base domain from its one source

address.ts read SITES_BASE_DOMAIN itself; the env-example test caught that
the variable Loki actually reads is LOKI_SITES_BASE_DOMAIN, owned by
site-cd.ts sitesBaseDomain(). Use that.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpakL9C3TESU4H45fXMFfc

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-14 07:56:33 -07:00
CatoandClaude Opus 5.5 f6b9dd701f fix(hetzner): a sleeping app naps cleanly; ivy-health checks what Loki runs (#1087)
* fix(hetzner): a sleeping app naps cleanly; ivy-health checks what Loki runs

Sleep-when-idle stops the app with SIGTERM when its proxy idles out, and
Node exits 143. Without SuccessExitStatus systemd recorded that as
Result=exit-code, so every nap read as `failed` and paged Telegram as
"DOWN" quoting the boot banner, then "RECOVERED" on the next visit — ~10
sites flapping all day, burying real alerts. The generated app unit now
counts 143/SIGTERM as a clean stop; the test pins it (mutation-checked).

ivy-health.sh was box-only and still checked fleetcrown-app/-bridge and
the retired OpenClaw gateway, paging "DEGRADED (restart failed)" every 4h
for units that no longer exist. Versioned here, now heals postgres and the
loki-* units and probes loki-app /api/health; installed on the box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(telegram): register ivy-health.sh as a sender

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(hetzner): ivy-health history without the retired name

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 07:14:22 -07:00
CatoandClaude Opus 5.5 c9044a8151 feat(sites): sites that are not live yet sleep when idle (#1066)
* wip(sites): sleep-when-idle building blocks (not wired in yet)

Adds the status list and idle time (_box-env.sh) and the pure generators
(lib.sh: sleeps_when_idle, wake_inner_port, sleep_app_unit, wake_socket_unit,
wake_proxy_unit). Nothing calls them yet: sync-infra.sh is unchanged, so no
site's units change. Wiring them in waits on the owner's go-ahead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0191FbipnTCBDKHiKftp9W7B

* feat(sites): sites that are not live yet sleep when idle

Every site ran around the clock with up to 1 GB, which capped the 16 GB box at
roughly 50 sites however rarely they were visited. A site whose register status
is prospect, demo, validating or unverified now sleeps: systemd listens on its
port, the first request starts it (a second or two), and it stops after 15
idle minutes. Live sites (clients, products, evig, the 4001-4004 services) are
untouched; a row that becomes live is switched back to always on on its next
sync.

- sync-infra.sh: for a sleeping row, the app listens on port+20000 and is bound
  to <name>-wake.service (systemd-socket-proxyd --exit-idle-time) behind
  <name>-wake.socket on the public port. Caddy and deploy.sh keep talking to
  127.0.0.1:$PORT, so neither changes; a deploy's restart pulls the proxy up.
  Falls back to always on, out loud, if the box's proxyd lacks idle exit.
- install-watchdog.sh: a sleeping site is checked by its socket, not by a
  request every 5 minutes (which would keep it awake forever).
- uptime-sweep.sh: sleeping sites are health-probed on the first sweep of
  00/06/12/18 UTC instead of every 15 minutes, so botsmann's kind of outage
  is still caught within hours; certificates are still checked daily.
- Sync sites workflow: re-applies sync-infra.sh to named sites and checks each
  one answers — the rollout for sites already on the box.

Tests: test-sleep-when-idle.sh runs sync-infra and the watchdog installer end
to end against a recording ssh; test-uptime-sweep.sh covers the 6-hourly probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0191FbipnTCBDKHiKftp9W7B

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-07 07:01:59 -07:00
CatoandClaude Opus 5.5 5aa521e08d feat(sites): give a site its own domain — evig.orangecat.ch → evig.ch (#1065)
* feat(sites): give a site its own domain — evig.orangecat.ch → evig.ch

A site starts on <slug>.orangecat.ch. When its owner buys a domain, Loki can
now make that domain the site's address: the domain (and www. when it points
here) is served, the free address answers with a 308 to it, and the project's
live URL, production URL and widget origin list follow. Nothing the visitor
sees says where the site is hosted, and the site stays one repo, one Loki
project, on the same box.

- lib.sh caddy_vhost: the one rule for what a row's domains field means. A
  row mixing an own domain with its free host serves the own domain and 308s
  the free one. sync-infra now calls it; every existing row's vhost is
  byte-identical (pinned against the real register in test-custom-domain.sh).
- attach-domain.sh <slug> <domain> | --detach: checks DNS first (A to the box,
  no stray AAAA) and refuses with the exact records when it is not set —
  Caddy would otherwise retry a failing certificate for hours while the free
  address already redirects there. Edits the row, publishes it to main via
  the shared publish_register_row (moved out of register-site.sh), syncs,
  waits for HTTPS. Refuses the handcrafted 4001-4004 services (evig among
  them) whose Caddy blocks are hand-written.
- GET/POST/DELETE /api/projects/[id]/domain + an "Own domain" panel next to
  the live link: type the domain, see the records and whether they are set,
  connect, or go back to the free address. Studio-box gating is the same as
  site registration; everyone else gets the command.

Docs: docs/infrastructure/custom-domains.md, including why sites are not
hosted inside OrangeCat (removed 2026-08-27) and the two things a site's own
code may still need after a move (metadataBase, OrangeCat OAuth redirect URIs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0191FbipnTCBDKHiKftp9W7B

* fix(env): document LOKI_SITES_IP / LOKI_SITES_IPV6 in .env.example

env-example-covers-src requires every variable src/ reads to be named there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0191FbipnTCBDKHiKftp9W7B

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-07 05:53:32 -07:00
CatoandClaude Opus 5.5 5f1e283117 fix(scripts): grep -q is never the reader of a pipe under pipefail (#874)
`echo "$x" | grep -q PAT` under `set -o pipefail` can report "not found"
for text that IS there: grep -q exits on its first match and closes the
pipe, the writer takes SIGPIPE (141), and pipefail makes the pipeline
status 141. An `if` then takes the else branch on a successful match.

#587 found this in one file and noted it "only fires when the payload
exceeds the ~4KB pipe buffer". That is not so, and the belief is why
82 copies in 22 scripts survived. Measured today on retire-site's real
1,158-byte plan output with has()'s exact pattern, 3,000 calls each:

  'DRY RUN'        line 3 of 20    echo|grep -q   2/3000 false misses
  'apps.conf row'  line 11 of 20   echo|grep -q   2/3000 false misses
  last phrase      line 20 of 20   echo|grep -q   0/3000
  'DRY RUN'                        here-string    0/3000

Rare per call, but verify makes hundreds of these calls, and the
retire-site suite went red on those two exact phrases twice this week,
passing every rerun. It is worse in a NEGATIVE check - hasnt() read a
false miss as a PASS. And several copies are not tests: deploy-hetzner.sh
exits 1 on a false miss, and the sshd drift watch would raise a false
security alert.

All 82 rewritten to `grep -q PAT <<<"$x"` (a here-string is not a
pipeline, so there is no writer to signal) by a script that only touched
the simple quoted-variable form and reported anything else. Checked: all
22 files pass `bash -n`, every file is a 1:1 line swap (82 lines), and
the 20 line-continuation sites keep the here-string before the trailing
backslash (the first draft of the rewrite got those wrong; caught in a
dry-run diff before anything was written).

#587's comment is corrected so it stops teaching the wrong threshold.

Gate: scripts/test/no-grep-q-in-a-pipe.ts ratchets it repo-wide,
including forms the rewrite skipped (e.g. "$(cmd)" | grep -q), and
self-tests that its detector still fires. Proven by restoring the
original deploy-hetzner.sh line.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 02:57:19 -07:00
CatoandClaude Opus 5 baa8e2e6fb chore(aoz): follow bitbaum/aoz-housing -> bitbaum/aoz-begleitung (#732)
The repo was renamed today. It was the last place the product was still called
Housing: the name row in fleet's registers/retired.json retired "AOZ Housing" as
the PRODUCT name on 2026-09-10, but the repo kept it, and the repo is public.

The deploy name `aoz-wohnen` is deliberately NOT renamed with it. It is an
infrastructure identifier — systemd unit, /opt path, database — nothing on the
box keys on the repo name, and moving it would touch a live site for no visible
gain. apps.conf's comment block already said as much and still does.

The load-bearing change is apps.conf's fourth field. repo-metadata-audit.mjs
keys the register on that path's BASENAME, so while it read /home/g/dev/
aoz-housing the join against GitHub missed and every metadata check for this
repo was silently skipped — the audit went green by not looking at it. The local
checkout was moved to match and its three worktrees repaired (`git worktree
repair`), not pruned: they hold branches.

Two test failures worth keeping, because both were the rename telling the truth:

  - project-mention asserted that "the AOZ housing rebuild" resolves to the
    project. With the slug renamed it does not, and should not. The case exists
    to prove "a slug with a hyphen, typed with a space" matches, so the INPUT
    moved to the current name rather than the expectation being loosened.
  - tab-match asserted a terminal tab literally named "AOZ Housing" matches the
    slug. Same thing: the fixture now uses the name the tab would actually have.

Consequence worth naming: someone who types "aoz housing" at Loki will no longer
be understood. There is an alias mechanism for exactly this shape
(register/build.ts maps the deploy name to the repo), but wiring the retired
name into mention-matching is a product decision, not a rename chore.

Left alone on purpose: scripts/db/retire-stale-projects.ts, whose data row
records the project names the database actually held when that migration ran;
and content/thoughts/*.md, published essays — one of which quotes a filesystem
path observed during a debugging session, so rewriting it would falsify the
anecdote.

The production user_projects row was updated too (name and git_url), because the
database is a second copy of the repo identity and a past rename left 21 rows
pointing at a dead account. New URL proven to resolve: 431bae7.

Tests green: fleet-register 44, project-mention 28, tab-match 10, fleet-map 7,
loki-project-ranking all.


Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 12:17:25 -07:00
CatoandClaude Fable 5.1 95c40a9cd8 refactor: rename the product from FleetCrown to Loki (#695)
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>
2026-09-13 16:13:10 -07:00
CatoandClaude Fable 5.1 71762e4649 fix(cold-start): register lands deploy.yml; scaffold installs/builds/serves (#585)
* fix(register): a site registered from the box gets its shim, its port, and its builder

Walked the cold start on production after #569 (velokiosk-sep10). The repo
was seeded; then four defects on the register-and-run path:

- The OAuth grant had no workflow scope, so GitHub refused to write
  .github/workflows/deploy.yml and register-site.sh carried on saying the
  remote may already have it. The grant now requests workflow; the script
  falls back to the host's own gh login for the shim and fails when the file
  is not on the remote.
- box() named no SSH identity; ubuntu's only key is the CI deploy key, so the
  box refused itself. box() passes DEPLOY_KEY_PATH when readable.
- The durable register was behind main and handed out a port main had already
  given away. Ports and conflicts are read from both registers, the durable
  checkout is fast-forwarded when all its rows are on main, and every new row
  goes to main as a PR.
- A dirPath under the box clone root was routed to the operator's laptop
  because it was present; that runner cannot clone on demand and reported
  "inject did not stick". projectChannelLock returns cloud for box-rooted
  workspaces.

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

* fix(scaffold): a new site that actually installs, builds and serves

Diplodoctor was scaffolded on 2026-09-10, provisioned completely — repo,
systemd unit, Caddy vhost, register entry — and served 502. Its session
diagnosed it and fixed it IN THE DIPLODOCTOR REPOSITORY. The template was left
exactly as it was, so the next site would have rediscovered the same three
faults from scratch. This is that fix moved to where it belongs.

The template was never internally consistent about its package manager. It
shipped no lockfile at all, yet its CI ran `npm ci`, which REQUIRES
package-lock.json — so a freshly scaffolded site's CI could not pass on its
first commit, or any commit. Meanwhile the box deploys with `pnpm run build`.
Two managers, one repo, and the half that ran in production was not the half CI
described. Everything here converges on pnpm, which is what actually ships.

  pnpm-workspace.yaml   NEW. `allowBuilds: sharp, unrs-resolver`. pnpm 11
                        refuses to run a dependency's build script unless it is
                        approved and EXITS NON-ZERO when one is not, so without
                        this a fresh clone cannot install and the deploy dies
                        before the build. It must not go in package.json's
                        `pnpm` field: pnpm 11 no longer reads that field and
                        ignores it with a warning, which makes the setting look
                        present while doing nothing.
  .nvmrc                20 -> 22. pnpm 11 imports node:sqlite, absent before
                        Node 22.13. Harmless while CI used npm; fatal the moment
                        it uses pnpm.
  ci.yml                npm -> pnpm throughout, and the Next cache key now
                        hashes pnpm-lock.yaml instead of package-lock.json — a
                        file that never existed here, and hashFiles() returns
                        an empty string for a missing path, so the key was
                        constant and the cache could never invalidate.
  package.json          `verify` uses pnpm; `packageManager` pins pnpm@11.25.0
                        so a stray `npm i` cannot mint a second lockfile.

Two things this also fixes that were not in diplodoctor's repair.

**The scaffold now resolves a lockfile into the first commit.** Without one the
repository is born unbuildable in two places at once: CI's
`pnpm install --frozen-lockfile` refuses to invent a lockfile, and the box
resolves versions afresh on every release, so the site that was verified is not
the site that ships. `--lockfile-only` keeps this to a few seconds and unpacks
no node_modules.

**next 16.2.4 -> 16.3.4.** The template was minting every new site with a
CRITICAL unauthenticated RCE — GHSA-2xp9-vwfh-vxw4, the Next image-optimization
hole, patched at >=16.3.3. orangecat was patched for this today; the scaffold
would have kept issuing fresh vulnerable sites afterwards.

**And the port race, which nearly shipped an hour ago.** Ports are allocated
from `apps.conf` in a LOCAL checkout, and this studio runs five to ten agent
sessions at once, each in its own worktree. A stale copy reports a stale highest
port. A dry run in one such checkout offered 4024 for a new site while origin
already had diplodoctor on 4024 and heidi on 4025 — two sites, one port, caught
by hand one command before it would have shipped. The script now fetches and
REFUSES when its register differs from origin/main, naming the pull that fixes
it, rather than guessing a number another session already took.

Verified: `bash -n` clean; a dry run against an up-to-date register allocates
4026 and the staleness guard passes.

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

* chore(register): causius on 4026 — the first site the fixed scaffold built

causius.orangecat.ch is live: systemd active, HTTP 200, its own certificate, on
the first deploy. Diplodoctor needed two follow-up pull requests to reach that
same state yesterday; this one needed none, because the template was repaired
before it was used rather than after.

Registered as `product` / `validating` — ours, and not yet claiming to be a
live client engagement, so the client-ledger gate is satisfied without inventing
terms for something that has no customer.

Port 4026 came from a register that the new staleness guard had just verified
against origin. The stale local copy this was first attempted from offered 4024,
which diplodoctor already holds.

Deliberately NOT bought: causius.com and causius.ch are unregistered and stay
that way for now, by George's call. The site therefore lives at its free
orangecat.ch address, which is exactly the ladder /domains sells — start free,
move to your own domain later, keep every link alive. Dogfooding it means the
first customer of that offer is us.

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

* fix(scaffold): site-template CI floor test expects pnpm

The scaffold now installs with `pnpm install --frozen-lockfile` (#583 onto
main). The floor test still demanded `npm ci`, so verify would fail every
run after the template switch even though the template itself is correct.

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-10 15:00:27 -07:00
CatoandClaude Opus 5 e1f2dec430 fix(new-site): allocate a port the BOX agrees is free, not just the register (#581)
new-site.sh took `max(port in apps.conf) + 1` and stopped there. The register is
not the only thing listening on that box and never claimed to be — the
handcrafted services on 4001-4004 are excluded by design, and annushka's enquiry
API holds 4030 behind a hand-written vhost precisely so sync-infra will not
regenerate it.

So allocation was walking toward an occupied port. Measured 2026-09-10: highest
registered 4025, three rows added that day, 4030 live. Four sites away.

A port collision does not fail at allocation. It fails later, when the new unit
starts, binds nothing, and the OTHER app is the one that looks broken.

Both directions are now checked, and they are different questions:

  the REGISTER owns "claimed"  — a port free on the box but claimed here
                                 belongs to something not currently running,
                                 which is why the existing line stays
  the BOX owns "occupied"      — a port live on the box but absent from the
                                 register is invisible to the register by
                                 construction

`next_free_port` (lib.sh) is pure — the caller passes what is taken — so it is
tested without the box or the network. `listening_ports` does the one ssh sweep.

If the box cannot be reached the sweep returns nothing, which is
indistinguishable from "nothing is listening". That case now says so explicitly
rather than letting an unchecked port print as a checked one.

Live-verified against the box: 38 listeners read, 4030 among them; the real next
allocation (4026) is unchanged, and 4030 correctly advances to 4031.

Verified: port-alloc 6 passed (new, wired into test:ops), apply-schema 34,
uptime-sweep 66, ci-gate 15, launch-template ok, site-template 11,
client-ledger 13, deploy-ready green. lib.sh is sourced widely, so all of it
was re-run rather than assumed.


Claude-Session: https://claude.ai/code/session_01HVudRzEmLqLHvGNqFSpJq6

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 13:55:51 -07: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
45938e60cf fix(ci): unbreak the gates — dependency graph, agent-core drift, desktop release (#400)
* refactor(infra): studio constants get one home, and the rename gets a command

Fair criticism: I spent the day arguing for SSOT and then wrote new-site.sh with
its own copies of GH_OWNER, BASE_DOMAIN and DEV_ROOT, and hardcoded
'maonakamoto' again in provision-widget.ts. Worse, the pattern already existed —
_box-env.sh is literally labelled 'SSOT' for the box address. I did not extend
it, I duplicated around it.

_box-env.sh now owns GH_OWNER, SITES_BASE_DOMAIN and DEV_ROOT alongside the box
address, and new-site.sh and provision-widget.ts read them instead of carrying
their own.

The 41 workflow files are a different case and worth being precise about:
GitHub Actions requires a LITERAL owner/repo in  and will not accept a
variable, so that duplication cannot be removed. But a duplication you cannot
remove is one you have to OWN — leaving it as 'remember to edit 41 files' is
exactly the shape of step that gets skipped, the same shape as the git
repository Camille never got. So sweep-gh-owner.sh is committed: one command,
dry-runnable, optionally self-committing.

Dry run against the fleet: 24 repos, all detected correctly. Renaming to an org
is now  plus one line in _box-env.sh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(infra): split WORKFLOW_OWNER from GH_OWNER before they diverge

Same bug as the last commit, one layer down. The site template hardcoded
maonakamoto/fleetcrown in its deploy.yml uses: line, derived from nothing — so
every new site would bake in a literal that follows neither an account rename
nor a move to an org.

And GH_OWNER was quietly doing two jobs: where new site repos are CREATED, and
where fleetcrown LIVES. They look identical today and are about to diverge —
sites go to an org while fleetcrown stays on the personal account. One name for
two values is how a rename half-works.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(ci): GitHub owner maonakamoto -> catomean

* chore(infra): owner is catomean

Account renamed maonakamoto -> catomean. sweep-gh-owner.sh swept 24 repos and
the SSOT now agrees; 32 local remotes repointed. This is the commit the sweep
script exists for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(ci): GitHub owner maonakamoto -> catomean

* chore(ci): GitHub owner maonakamoto -> catomean

* fix(desktop): cut 0.8.14 — the owner rename touched desktop code

My owner sweep changed two files in desktop/ (an update URL and a package
reference) without bumping the version. That is precisely the failure #370
existed to prevent: desktop code that changes without a release ships to the
server and to no machine at all, silently.

The gate caught it, four commits after it was written. Working as intended, and
worth saying plainly — I was the one it caught.

GitHub redirects repository URLs after a rename, but only until somebody claims
the freed name. An auto-updater should not depend on a redirect.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(ci): the gate fails on your diff, not on your laptop

Three things in this hook blocked pushes for reasons unrelated to the change
being pushed, and together they are why --no-verify became reflex here. I passed
it eight times in one day and blamed the hook; the hook was reporting real
problems with misleading attribution.

1. STALE INSTALL. An unresolvable dependency surfaced as 'Cannot find module' —
   indistinguishable from a type error in your code. Now a precondition that
   fails first, loudly, naming npm ci. A day was spent on this exact confusion.

2. AGENT-CORE DRIFT. Drift arises either because you changed canonical without
   syncing, or because somebody changed the mirror in the other repo. Only the
   first is yours. It now checks whether this branch touched
   src/lib/agent/core/ and warns instead of blocking when it did not.

3. SCHEMA DRIFT. The guard already skipped an unreachable database but not a
   reachable stale one, so a local scratch DB missing someone else's columns
   blocked pushes touching no schema. Now scoped: if the branch changes schema a
   mismatch is yours and blocks; otherwise it reports and continues.

The pattern is taken from desktop-release-drift, which self-scopes to files
changed since the last release and is the only check here that has never blocked
an unrelated push. It caught me correctly today, four commits after it was
written.

Where scope cannot be established the checks still fail closed — a gate that
cannot establish innocence should not grant it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(ci): resolve the default branch, never assume main

The diff-scoping added in the previous commit compares against origin/main. 28
repos here use main — but aoz-housing, dotfiles and sbb-lost-found use master,
and six had no origin/HEAD set at all.

On those, merge-base fails, the scoping falls through to 'cannot tell', and
every check treats every change as in-scope. The gate I had just fixed would
have gone back to blocking unrelated pushes on a fifth of the fleet, for a
reason nobody would have connected to a branch name.

default_branch() now lives in lib.sh and resolves in order: the remote's own
origin/HEAD, then whichever of main/master exists, then fail. Never a guess. The
pre-push hook and agent-core-drift both use it.

Also ran 'origin/HEAD' is unchanged and points to 'main' on the six repos missing origin/HEAD.
32 of 33 now resolve; wild-spirit has no remote at all, which is a separate
finding and the same shape as camille this morning.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(scaffold): every new site is born with CI

ci-gate.sh cannot tell 'CI green' from 'no CI configured' — both exit 0. So a
scaffolded site without a workflow deployed every push unverified while looking
identical to one that passed. Substrata shipped to production that way for a day.

The template now emits ci.yml alongside deploy.yml: npm ci, type-check, lint,
build — the same bundle verify runs locally.

Plus eslint.config.mjs, because ESLint 9 without a flat config exits non-zero on
a migration notice and a new site's FIRST CI run would be red for reasons
unrelated to its code. A red first run teaches people to ignore the light.
Config copied from the fleet's working Next 16 apps, not invented.

postcss.config.mjs assigns before exporting — the anonymous default export is a
lint warning, and a scaffold should not emit its own warnings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(ci): no deployed app ships without CI, ratcheted to zero

ci-gate.sh exits 0 for 'CI green' AND for 'no CI configured'. Absence is
indistinguishable from success, so an app with no workflow deploys every push
unverified while looking exactly like one that passed. Nothing reported it,
because nothing was looking.

The audit found two: camille-boulangerie, and sink — which is sinktattoo.com, a
real client's site.

sink turned out to be a FALSE POSITIVE, and that is the more useful finding:
apps.conf pointed at /home/g/dev/s-ink, a path that does not exist, so the gate
reasoned about an absent repository and reported the wrong fault. It sent me to
add a workflow to a repo that already had one. The register was the bug.

So the gate now distinguishes a stale register entry from a missing workflow and
fails loudly on the former — a gate that lies about what to fix is worse than no
gate. apps.conf repointed at /home/g/dev/aslan-tattoo.

Camille genuinely had none and now does. Baseline is 0: a new deployed app
without CI is a build failure.

Tested in all four directions — over baseline fails, at baseline passes, under
baseline passes and prompts, stale path fails. The first version could never
fail at all: it set HERE before sourcing lib.sh, which overwrites HERE, so
BASELINE_FILE pointed at a missing file and silently fell back to the current
count. Found by testing the gate rather than trusting it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(scaffold): template ships .nvmrc

Every new site now pins Node once, and both CI and the deploy read it. Without
it the deploy warns and the two pipelines pick a version independently — the
kind of difference that surfaces as 'green in CI, broken on the box'.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(hetzner): scaffold sets the deploy key itself, from one configured path

new-site.sh printed `gh secret set ...` and called that operator hygiene.
What it actually produced was substrata live in production deploying only
from a laptop, because a printed instruction is a step that gets skipped.

The key is piped from DEPLOY_KEY_PATH straight into `gh secret set` — never
read into a variable, a log, or an agent's context — so the safety argument
that motivated the manual step is kept while the step disappears.

Per-repo on purpose: GitHub Free does not expose org-level secrets to PRIVATE
repositories, so an org secret alone would silently cover only part of the
fleet. DEPLOY_KEY_PATH joins the other constants in _box-env.sh so there is
one path, not one per script.

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

* fix(ci): make the deploy-ready gate judge the diff, not the workstation

The gate inspected the sibling checkouts under DEV_ROOT and nothing else.
All 15 are cloned on the workstation, so it printed "all 15 deployed apps
have CI"; CI clones this repo only, so the same commit printed fifteen
missing repos and exited 1 — red on a diff that touched none of them.

Third instance of one class: a gate judging state outside the commit. Its
real cost is not the red run, it is that everyone learns the gate is noise
and reaches for --no-verify.

Split into the two halves that were tangled:

  REGISTER INTEGRITY — apps.conf lives in this repo, so it is in the diff,
  so CI must judge it. Now actually checked: field count, unique names,
  unique numeric ports. Previously nothing validated the register at all.

  FLEET INSPECTION — needs the checkouts. Where none exist it is announced
  as NOT RUN and exits 0. Announced, because "no output" and "all clear"
  looking identical is the bug this file was written to fix. Where some
  exist, a bad path is still drift and still fails.

test:deploy-ready-gate locks it shut from both sides: a malformed register
must fail even with no checkouts present, and a bare environment must never
claim the fleet passed. Added to verify, so CI runs it in exactly the
environment that used to break it.

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

---------

Co-authored-by: Mao Nakamoto <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: t <t@t.t>
2026-08-28 05:04:32 +00:00
84706fb9c1 feat(infra): the site scaffold — register, new-site.sh, widget provisioning (#395)
#394 auto-merged on its first commit, so the rest of this work landed on a
branch that was already closed. This is that remainder, rebuilt on main.

**apps.conf becomes the register.** It knew port, domain, repo and database; it
did not know who anything belongs to or whether they pay, so "what am I owed
this month" was unanswerable and the answers lived as prose in bitbaum Status
lines — "first client in progress", "city relationship unverified", "one real
clinic". Six fields added: owner, kind, status, plan, price, since. plan and
price are '-' everywhere on purpose; the gaps are the point.

lib.sh needed its parser widened first — `read -r ... DB` lets bash's last
variable swallow every extra field, so appending columns would have silently
turned DB into "petvity|bitbaum|product|live|-|-". A 6-field line still parses
exactly as before.

**new-site.sh** does repo → register → box → deploy in one command. Substrata
took nine manual steps today; Camille took the same route a week ago and skipped
two of them — creating the repository and registering it — then ran in
production for eight days with no version control, which made the studio's
central claim untestable for the site built to demonstrate it. Those two steps
have no visible payoff on the day, which is exactly why a machine should do them.

Guards, because a slug becomes a DNS label, a certificate subject, a directory
and a systemd unit: non-DNS-safe slugs, slugs already registered, hostnames
already served, and reserved names — infrastructure like supabase, and
impersonation like security, where a valid certificate on our own domain is a
phish rather than a website. Ports come from the register, not ss -ltnp: a port
free on the box but claimed here belongs to something not currently running.

**provision-widget.ts** creates the FleetCrown project and mints a token bound
to that site's origin. The widget is why this is not a dev shop — the owner
points at their own page and an agent changes it — so it is provisioned at birth
rather than later. Idempotent and deliberately non-rotating: rotating would
silently invalidate a snippet already live on a customer's site. Non-fatal in
the scaffold, because a missing widget is a minute's work while a half-finished
scaffold is a mess.

**The template ships tokens that say in the file that leaving them unchanged is
a bug.** Twenty-four identical sites would destroy the thing being sold.

Verified: guards refuse five bad inputs, dry-run allocates the next port and
prints every step, template installs and builds static pages clean, and the
widget provisioner was proved against the live database by giving Substrata its
project and token — now serving in production.

Co-authored-by: Mao Nakamoto <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 13:47:30 +00:00
Mao NakamotoandClaude Fable 5 2040322b2d refactor(audit): finish worst-first fixes — states SSOT, palette mirrors, timeout tiers, box git auth
Final audit wave (three fix agents died at the session limit mid-flight;
completed by hand):
- box-workspace: token no longer embedded in remote URLs — auth moves to a
  per-invocation http.extraheader (actions/checkout pattern) and legacy
  embedded credentials are scrubbed from origin on every workspace prep
- ORCH_STATE keyed constants adopted at every raw run-state literal
  (dispatch-status, activity-status, presenters, run route writes,
  inject-core, openclaw execution, queries incl. the SQL literal)
- lib/palette.ts: single JS mirror of the design tokens for contexts that
  cannot read CSS vars (satori OG x3, email HTML, themeColor, xterm base,
  mermaid fallbacks, brand-mark) — zero rendered values changed
- HTTP/EXEC timeout tiers in constants/time.ts adopted across LLM and
  subprocess callers; widget polls join REFRESH_CADENCE
- scripts: Hetzner IP exists exactly once (hetzner/_box-env.sh); all
  15 scripts source it (bash -n clean, heredoc output byte-identical)
- storage keys centralized in brand-storage (values unchanged);
  ControlDispatchButton's dead 'control:prefill' write replaced with the
  real ?focus= deep-link; investors copy no longer hardcodes a fleet count;
  bare exhaustive-deps disables annotated

Not done, deliberately: public-git-history rewrite — the GitHub account ID
(41178744) links the old and new handles regardless of history, so a
3-repo force-push would break the live fleet for cosmetic-only gain; real
pseudonymity requires a fresh account (operator decision, see AUDIT_REPORT).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 16:29:47 +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