Commit Graph
91 Commits
Author SHA1 Message Date
CatoandClaude 57cf15e6ba fix(deploy, projects): a hung page check no longer holds a deploy for 45 minutes; a closed run no longer reads "Building now" (#1079)
Deploy (every fleet site, via selfhost-deploy.yml):
- page-check.mjs gets one 90s deadline for the whole look. On a host that
  accepts and never answers, goto gave up at 45s and the next call waited
  on the pending navigation forever; farmaciadelparco's deploys #3 and #4
  sat in "Look at the live page before the deploy" until the job's 45m
  limit. Verified against a never-answering socket: records "did not load"
  at 90s and exits 0; a normal page still checks in ~3s.
- timeout-minutes on both page-check steps as the backstop.

Project page:
- deriveBuildStatus: agent_running=t is a live process, not a live build.
  After a run closes Claude Code idles at its prompt, so the page said
  "Building now · An agent is working" beside "Finished · PR #1 merged".
  Building now needs an open run, or a prompt given after the last close.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-07 13:15:24 -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 Fable 5.1 f260f0bc52 feat(selfhost): a copy of Loki is a copy — own hostname, own OrangeCat, a complete env contract (#1023)
* feat(selfhost): a copy of Loki is a copy — own hostname, own OrangeCat, a complete env contract

- APP_DOMAIN reads NEXT_PUBLIC_APP_DOMAIN (fallback loki.orangecat.ch), so
  callbacks, emails and copy carry a fork's own name; brand-sync still
  holds the shell mirror to the fallback.
- orangeCatProjectUrl() in config/orangecat.ts replaces the literal
  https://orangecat.ch/projects/… in three components, built on
  NEXT_PUBLIC_ORANGECAT_URL.
- .env.example names every variable src/ reads — 68 were not named, so a
  fork found Google sign-in, embeddings, the Telegram bot or the daemon
  token only by grepping process.env — each with the file that reads it,
  and scripts/test/env-example-covers-src.ts (picked up by test:unit) fails
  when one is missing. A comment that mentions a variable is not a read.
- README: "Run your own copy" — docker compose up, /setup, hostname,
  optional OrangeCat, agents on your own machine, the env contract; the
  name and identity are not part of the licence.

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

* fix(deploy): hand the newly declared NEXT_PUBLIC_* to the build, readers treat "" as unset

public-env-inlined on 070f951b: declaring NEXT_PUBLIC_APP_DOMAIN,
NEXT_PUBLIC_LOKI_BRIDGE_URL and the two ecosystem addresses in
.env.example made them "something an operator may set" — and none reached
the build, so a box that set one would render a different tree than the
browser (the production-only hydration failure that check exists for).

deploy.yml's build step now inlines all four from repo variables. An unset
variable arrives as "", so the readers use || rather than ??: an empty
inlined value falls back to the same default on both sides.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-03 01:09:28 -07:00
CatoandClaude Opus 5.5 0c6e05508e fix(ops): a site that hangs is DOWN, not up; raw sql Date comparisons fixed (#996)
loki.orangecat.ch was down ~06:00-07:53 UTC on 2026-10-01 (next-server
alive, no listening socket; Caddy 502 after 20s) and nobody was paged. The
watchdog's curl times out at 15s, prints 000 itself, and the fallback
'|| echo 000' appended another: "000000" is neither "000" nor a number, so
check() kept the site UP. Any app that hangs rather than refuses was invisible.
check() now counts UP only on a proven 2xx/3xx; test-watchdog-check.sh runs the
shipped check() against a fake curl (old code fails timeout/refused/garbage).
The deploy verifiers had the same append (failing closed) and are normalised.

Also from the same journal: closeStaleAgentTurns threw ERR_INVALID_ARG_TYPE
every hour — postgres-js cannot serialise a Date in a raw sql fragment. Same
shape in the calendar overlap, the digest previous window and two more;
all now use lt/gt/gte, and no-raw-sql-comparisons.ts keeps it that way.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 01:23:15 -07:00
CatoandClaude Fable 5.1 3f5bf104a8 feat(openclaw): a workflow that installs media understanding on the box (#982)
* feat(openclaw): the Telegram agent reads screenshots, photos and videos

The Telegram agent is OpenClaw on bitbaum, and OpenClaw already describes
inbound media before the chat model reads the turn — but on defaults that
cut every description at 500 characters and read one attachment per
message. A screenshot lost most of its text; an album was read as its
first picture; video had a one-line "Describe the video." prompt.

- scripts/openclaw/media-understanding.json: versioned tools.media.image
  and tools.media.video blocks (Gemini; screenshots transcribed verbatim,
  albums read whole; videos returned as transcript + visuals + claims +
  authenticity signs so the agent can argue about whether a clip holds up).
  tools.media.audio is deliberately untouched — voice notes already work.
- scripts/openclaw/install-media-understanding.sh: the only way it reaches
  the box. Refuses without a Gemini key, writes through OpenClaw's own
  schema-validating `config set`, restarts the gateway, then proves an
  image (and, where ffmpeg exists, a video) is actually described.
- scripts/test/openclaw-media-config.ts: pins the limits and the audio
  hands-off rule.

Validated against openclaw@2026.4.23's schema locally. Not yet applied to
the box.

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

* refactor(actions): share the decision and the enqueue report; let a turn be read-only

Groundwork for the MCP server, so it calls the same code the chat seams do
instead of a copy of it:

- lib/actions/decide-action.ts: approve/reject one draft, lifted out of
  POST /api/actions/[id]/decision (which now calls it; wire shape unchanged).
- lib/actions/enqueue-report.ts: what an enqueue outcome may truthfully be
  called (auto-approved / awaiting-approval / deduped), lifted out of
  POST /api/actions/propose (wire shape unchanged).
- config/orangecat.ts: the OrangeCat origin and OAuth issuer in a DB-free
  module; Auth.js and the identity bridge read the issuer from here instead
  of each re-deriving it.
- askLoki / runLokiTurn take `readOnly`: the tool loop drops its propose
  tools and the OpenClaw gateway fallback is skipped, so a caller granted
  conversation but not action cannot get Loki to act by asking.

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

* feat(mcp): a remote MCP server so AI apps can message Loki and have it act

POST /api/mcp speaks MCP Streamable HTTP (stateless JSON-RPC 2.0; protocol
2025-11-25 / 2025-06-18 / 2025-03-26). claude.ai and ChatGPT connectors,
Claude Code and Cursor can ask Loki, list the approval queue and projects,
dispatch work, book appointments and decide queued actions.

Auth: a ck_* agent token (both scopes), or an OrangeCat RS256 access token
verified with node:crypto against the issuer's JWKS — iss, aud (must be the
Loki resource URL, never a client id), exp. `sub` maps to the Loki user via
orangecatActorId; an unlinked actor gets the sign-in step, not a 500. A
missing or bad token is a 401 whose WWW-Authenticate points at the RFC 9728
metadata served at /.well-known/oauth-protected-resource(/api/mcp).

Scopes loki.chat / loki.act and the tool map are SSOT in src/config/mcp.ts.
Act tools go through injectPrompt, enqueueAction and decideAction — the
functions the Telegram skill's routes call — so the approval queue gates
them exactly as it does there. Both paths are excluded from the session
middleware (proxy.ts, with the reason), registered in api-route-auth and
the demo sandbox. Docs: docs/development/mcp.md.

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

* fix(openclaw): match the installer's smoke output with a here-string, not a pipe

printf | grep -q can report a miss on a match under pipefail (grep exits,
the writer takes SIGPIPE). no-grep-q-in-a-pipe caught it.

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

* feat(openclaw): a workflow that installs media understanding on the box

install-media-understanding.sh needs SSH to bitbaum and a Gemini key, which
a sandboxed agent session has neither of. This workflow_dispatch job has
both: it reuses deploy.yml's HETZNER_SSH_KEY / HETZNER_IP, takes the key
from the GEMINI_API_KEY repo secret or, failing that, from OrangeCat's env
already on the box, writes it into the openclaw user's ~/.openclaw/.env only
when none is there, and runs the installer, which proves a describe.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-29 08:16:36 -07:00
CatoandClaude Opus 5.5 2cdc648145 fix(sites): a new private site's CI can ship it; registration clears every message it wrote (#946)
* fix(sites): a new private site's CI can ship it; registration clears every message it wrote

The site template's ship job granted its token only actions:write. A
job-level permissions block switches everything else off, so on a PRIVATE repo
checkout answered "Repository not found": CI went red on main, the fleet
sweep never ships a red main, and a brand-new site stopped one step before
going live (probe-loop, 2026-09-26). contents:read added to the template and
to loki's own ship job; ci-jobs-can-read-their-repo.ts fails any job that
checks out without it.

isRegistrationNextStep missed the deployment verdicts from
site-cd-deployment.ts, so Farmhouse kept telling its owner "Deployment
failed" after it was live. The test now collects every reason sentence from
the source and requires the matcher to know it.

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

* test(cron-runner): free ports and a subshell that always records its exit

Several sessions run verify on one machine at once; two runs on the fixed
ports 4997/4998 answered each other's jobs, and the retry subshell inherited
errexit so a failing job never wrote its rc file. The retry case failed
twice in one day. Four parallel runs: old test 1/4 pass, this one 4/4.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 13:20:39 -07:00
CatoandClaude Opus 5.5 5c5d201426 feat(deploy): every site deploy looks at the page on a phone before and after, and rolls back if it got worse (#943)
A green deploy proved only that the site answered 200: an agent's change could
pass its checks and still leave the page scrolling sideways on a phone,
throwing in the browser, with broken images or most of its text gone, and on
autopilot nobody looks. The shared self-host deploy now reads the live page in
headless Chrome at 390px before and after shipping (page-check.mjs); if the
change ADDED any of those problems (page-check-compare.mjs), it rolls back to
the previous release and fails with the reasons. No baseline is never a
regression, and a checker that cannot run warns instead of blocking.
Screenshots are kept as an artifact for 14 days.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 12:50:55 -07:00
CatoandClaude Opus 5.5 2105d3e358 fix(widget): the launcher finds a free slot on every host page, with a host contract for the rest (#918)
The launcher knew its corner, an offset, a global data-fc-bottom and one
foreign fixed launcher. Everything else it could miss: any layer wider than
90% of the viewport was ignored, so on substrata /atlas at 390px it parked on
the country bottom sheet; and it re-measured only on load, resize, window
scroll and URL change, so a sheet mounted later was never seen.

One engine now, for every width and obstacle:
- placement.slotOrder: preferred corner up its near band, the mirrored
  corner, then the rest of each edge (pure, unit-tested).
- host-scan: hit-tests each slot (launcher + 12px gap) with
  elementsFromPoint and judges free / surface / layer / blocked. Controls
  (incl. [tabindex], iframes, cursor:pointer) block; fixed/sticky bars and
  inner scroll panels are layers; a control >=25% of the viewport (a
  pannable map) is a surface.
- placement.chooseSlot: first free, else least-bad, else HIDE - never sit
  on a control.
- Re-measures on DOM mutation (throttled 1/s) and on inner-panel scroll.
- Host contract: data-fc-avoid (never overlap), data-fc-place=
  left|right|hidden on <html> or a page region. Documented in
  widget/README.md.

Also fixes a latent bug the browser test caught: clearing inline edges to ""
let the shadow stylesheet's right:16px survive a move to a LEFT corner, so
"Move to other corner" stretched the launcher across the page.

Tests: widget-placement.ts (pure) and widget-host-avoid-browser.ts (real
Chromium, 9 fixtures). Against the pre-fix bundle 7 assertions fail; each
new rule (layer, surface) fails its fixture when mutated out. CI installs
chromium-headless-shell so the browser test runs rather than skips.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 09:11:52 -07:00
CatoandClaude Opus 5.5 bcadb1bd88 fix(ci): the deploy reconciler reads the live commit from /api/health (#914)
The fleet sweep compared main's tip against the last successful Deploy
run's headSha. GitHub labels a workflow_run-triggered run with main's
CURRENT tip, so on 2026-09-25 run 36135832127 shipped f2f6206 while
labelled 4622869, and the sweep believed 4622869 was live and never
dispatched it. bitbaum/fleet#145 added live_commit_url; this opts in.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 06:07:19 -07:00
Cato 064cad655d fix(runs): one clock for the lane and the reaper — no second prompt into a live session (#896)
* wip: one clock for the lane and the reaper

* wip: database test for the lane and the reaper, wired into CI
2026-09-25 00:09:11 -07:00
Cato d58cead44f feat(ci): allow exact SHA for workflow-run deploys (#867) 2026-09-23 13:51:52 -07:00
CatoandClaude Opus 5 58174f45ef fix(hardcoded): give every duplicated constant one home (#758)
* fix(hardcoded): give every duplicated constant one home

A sweep of all 44 repos' default branches for literals that duplicate an
existing source of truth. Loki's share, in four groups.

WRONG, and live on the public footer. src/config/fleet-site-copy.ts still
called the Zürich clinic "VitaReBa", a name retired on 2026-09-10 — its own
title says "Vita · Metabolische Psychiatrie & Systemische Longevity". The
generated fleet-sites.ts carried it onto loki.orangecat.ch, where it was
serving until this commit. Fixed at the copy file, which is the one place that
owns a site's own words, and the footer regenerated from it.

WOULD HAVE WRITTEN STALE DATA. scripts/seed-fleet-site-urls.ts kept a hand-typed
slug → URL map "read 2026-08-06". Two of its fifteen entries pointed at hosts
retired since (aoz-wohnen.orangecat.ch, revampit.orangecat.ch), so running it
would have filled empty live_url columns with addresses that only 308. It now
derives the map from apps.conf — the same register the footer is generated from
— which also fixes the six live sites the hand list never had. Verified: 19
sites, zero retired hosts.

THE BOX ADDRESS, in seven places. scripts/hetzner/_box-env.sh has been the SSOT
for it all along and sixteen scripts source it; four did not, and the shared
deploy workflow — reused by ~20 repos — had the IP inline twice, so moving the
box meant twenty edits. The workflow now reads the org-level Actions variable
HETZNER_IP and fails loudly if it is unset, rather than ssh-ing to an empty
string. loki's own deploy.yml had `vars.HETZNER_IP || '<literal>'`, a fallback
that guaranteed the variable was never needed and so never noticed if wrong.

ONE LAPTOP, baked into shipped code. site-cd-local.ts listed /home/g/.ssh and
/home/ubuntu/.ssh as deploy-key candidates beside os.homedir() — which already
IS those paths, since loki-app runs as `ubuntu` and a laptop runs as its owner;
both spelled one homedir for one named person. install-push-deploy.sh wired
hooks to /home/g/dev/loki, link-prod-runtime.ts to /home/g/dev/bitbaum, and
scripts/fleet printed an install line only true on one machine: all now DEV_ROOT
or the script's own resolved path.

The two scripts in scripts/local are INSTALLED BY COPY into ~/.local/bin and run
there by systemd timers, so they resolve _box-env.sh beside the real file first,
then under DEV_ROOT, and exit loudly if neither exists — a security check that
cannot find its target must not look like one that found nothing.

Deliberately unchanged: the slug alias map (the mechanism that makes a rename
safe), an executed migration's data row, the retired-handle detector's own
handle list, and test fixtures reproducing past incidents.

Verified: fleet-sites-derived in sync (14 sites), bash -n on every edited
script, and the branch's only remaining literals are in scripts/test fixtures.

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

* fix(push-deploy): the generated hook must not bake one laptop's path

install-push-deploy.sh writes the hook body through an UNQUOTED heredoc, so
$HERE expanded at generation time and the absolute path of one machine was
committed into every repo's .husky/pre-push. kivvi and botsmann both carried it;
anyone cloning those repos got a hook pointing into a stranger's home directory,
and re-running the installer would have put it straight back after those repos
were cleaned.

The hook now resolves ${DEV_ROOT:-$HOME/dev}/loki/... at RUN time, so the
generator stops re-introducing what the cleanup just removed.

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

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 02:03:58 -07:00
Cato 05e7d32a6d ci: fast verify on main after green PR merge (#743)
Full pnpm verify is ~60m. Squash merges already paid that cost on the PR;
re-running it on main doubled merge→live. Main tips whose subject contains
(#N) now run verify:main (format/tsc/lint/design/gates). PRs and manual
main pushes still get full verify. Docs: docs/infrastructure/merge-to-live.md
2026-09-16 09:28:47 -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 Opus 5 b6a086b0f2 fix(ci): ship a commit once, not twice (#664)
Making main's runs stop cancelling each other exposed the duplicate they
were hiding. Both paths now survive, so both fire: d5c83e66 was built,
rsynced and restarted twice — once from the push chaining through
workflow_run, once from ci.yml's own ship job.

The ship job is the fallback. A merge made with GITHUB_TOKEN triggers no
workflows at all, so nothing else would carry it; that is why the job
exists and why it must stay. But the sweep now merges with a PAT, which
DOES produce a push-triggered run, and that run reaches Deploy on its own.

So the job asks the one question that distinguishes the two cases: has a
push-triggered CI run for THIS commit already succeeded? If yes, Deploy is
already on its way and the dispatch declines. If no, this dispatch is the
only path to the box and it goes.

The check is on the commit, not on a timer or a guess about which merge
mechanism was used, so it stays correct if the PAT is ever removed and
merges go back to producing no push run.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 13:43:58 -07:00
CatoandClaude Opus 5 d5c83e66b5 fix(ci): a merge on main stopped having a path to the box (#662)
Four merges reached main on 2026-09-11 and never left the repository.
Every check was green, no job was red, nothing anywhere was marked failed.
Each one needed a Deploy dispatched by hand, and the only way to notice was
to compare the box's build stamp against main's tip.

Two paths ship a commit, and exactly one fires per commit by design: a push
to main chains through workflow_run, and a dispatch runs ci.yml's own ship
job. Under a concurrency group keyed only by branch, auto-merge's re-armed
dispatch cancels the push run for the same commit — which is intended, and
the comment on the ship job says so.

What was never intended is the NEXT merge cancelling the surviving run of
the previous one. That kills both paths at once. For the stranded commit,
gh run list showed a cancelled push run AND a cancelled dispatch run, with
a clean success five minutes later belonging to a different commit.

So main is now keyed per commit. Same-commit cancellation is preserved, so
a commit still ships exactly once; cross-commit cancellation is gone, so it
ships at all. Branch behaviour is unchanged.

The gate that comes with it states the property narrowly — on main, one
commit's CI must never cancel another's — and also pins the five premises
that make it matter, because if the chain is ever rewired the gate must
fail loudly rather than guard a ghost.

Both were proved by mutation on a copy, six mutations, each asserted to
have actually applied. That assertion earned its keep immediately: the
first draft of this gate checked for `workflow_dispatch` with a plain
substring, which matched a comment and an `if:` elsewhere in the file, so
removing the actual trigger left it green. A mutation that silently no-ops
makes a gate look proven when nothing was tested.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 12:58:34 -07:00
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
CatoandCato 27626d0340 ci: remove temporary dogfood one-shot workflows (#564)
Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-10 04:17:14 -07:00
CatoandCato a02412e5d2 ci: one-shot set dogfood liveUrl by name (#563)
Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-10 04:16:24 -07:00
CatoandCato 0427927e17 ci: migrate legacy /opt/app dir before dogfood symlink swap (#561)
Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-10 04:14:36 -07:00
CatoandCato 5a26b4f521 ci: ensure dogfood next standalone before on-box build (#560)
Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-10 04:12:54 -07:00
CatoandCato fe8b6df363 ci: fix dogfood bootstrap git safe.directory for release tag (#559)
Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-10 04:11:16 -07:00
CatoandCato f9c0975d03 ci: dogfood bootstrap via root — authorize key, build, ship, liveUrl (#558)
ubuntu CI deploy key does not authenticate from GHA. Use the working root
deploy key: authorize it for ubuntu, set dogfood's secret, sync unit/Caddy,
build the starter on-box, atomic release swap, set liveUrl.

Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-10 04:08:48 -07:00
CatoandCato 0e5c687d20 fix(register): resilient deploy.yml push; finish dogfood bootstrap deploy (#557)
Register no longer dies when Contents API already landed the secrets fix.
Bootstrap resets the dogfood checkout, treats register push races as
non-fatal, and always runs deploy.sh for the slug.

Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-10 04:06:06 -07:00
CatoandCato 7f7d66177c ci: fix dogfood bootstrap reset + /opt scripts (#556)
* ci: fix dogfood bootstrap — reset dirty apps.conf, prefer /opt scripts

Durable checkout had an uncommitted apps.conf that blocked pull. Hard-reset
to origin/main and run register/deploy from the just-shipped /opt release.

* ci: pass register/deploy paths into ubuntu env correctly

---------

Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-10 04:03:29 -07:00
CatoandCato 0a72ffbf05 ci: one-shot dogfood box bootstrap (pubkey + deploy + liveUrl) (#555)
Temporary workflow_dispatch to finish dogfood-site-sep10-1201 after cross-owner
secrets: inherit left Deploy unable to SSH. Installs the CI deploy pubkey for
ubuntu, runs idempotent register-site + deploy.sh for this slug only, sets
liveUrl. Remove after dogfood returns 200.

Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-10 04:00:02 -07:00
dependabot[bot] 312f42f571 chore(deps): bump actions/cache from 4 to 6 (#522)
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 6.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-07 22:57:45 +00:00
CatoandClaude Opus 5 c878f9ba81 ci(auto-merge): hand the sweep a PAT so workflow PRs stop stalling (#521)
GITHUB_TOKEN cannot merge a PR that touches .github/workflows. The sweep tries,
the merge API refuses, it logs "leaving for the next sweep", and repeats — while
still exiting 0. So the failure is invisible: every run reports success and the
PR simply never merges.

That is not hypothetical. ai-kit #11 (bump actions/checkout) sat green, CLEAN
and MERGEABLE for nine days; aoz-housing #122 (bump actions/upload-artifact)
for nine more. Both had to be merged by hand today. Every Dependabot
`github_actions` bump in the fleet is in this class, permanently.

A PAT fixes a second thing that costs more: THROUGHPUT. A dispatch made with
GITHUB_TOKEN emits no workflow_run, so after each merge nothing wakes the sweep
to take the next PR — it waits for the cron, and GitHub throttles scheduled
workflows to roughly hourly regardless of what the cron says. Observed in
fleetcrown: sweeps ~50-65 minutes apart against a */10 schedule. A PAT-created
dispatch does emit workflow_run, so the queue drains at CI speed instead.

The reusable workflow has always supported this — GH_TOKEN is
`secrets.token || github.token`. This just passes it.

SAFE BEFORE THE SECRET EXISTS: an undefined secret resolves to empty, and the
fallback picks github.token. So this changes nothing until FLEET_PAT is created
as an organisation secret, and needs no second pass afterwards.


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

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 15:17:43 +00:00
CatoandClaude Opus 5 3686d2e24b ci(deploy): cache Next's build output — every consumer's deploy built cold (#520)
This workflow runs a full `npm run build` on the runner (deploy.sh) for every
repo that calls it, and nothing restored `.next/cache`. So the same compile CI
just did was repeated from scratch, every deploy, in every consumer repo.

Measured across 8 repos on 2026-09-07: not one deploy cached this, and only
orangecat's CI did. Deploy medians ran 2.9m (fleetcrown) to 12.7m (evig)
against CI medians of 1.9m to 10.7m on the same commits — two cold builds of
one commit.

One change here reaches kivvi, botsmann, vitareba, hirnli and every other
consumer, which is the reason to fix it at this layer rather than in each repo.

Keyed by app so two apps in one repo cannot evict each other, and by lockfile
so a dependency change invalidates it. The bare restore-key comes last on
purpose: a stale cache is still much cheaper than no cache, and Next validates
its own entries rather than trusting them blindly.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 13:10:31 +00:00
cf3d9ed52e fix(deploy): hand the VAPID public key to the build, so push can work at all (#490)
#488 stopped the hydration failure by rendering nothing until past the server
render. It could not restore the feature: the browser still received an empty
NEXT_PUBLIC_VAPID_PUBLIC_KEY, so subscribe() had no application server key and
push notifications were dead in production regardless.

The missing half was never in the code. deploy.yml's build step declared no
`env:` at all, so every NEXT_PUBLIC_* was inlined empty while the box ran with
this one set. Fixed by creating the repo variable and passing it to the build.

A variable, not a secret: the value is compiled into the client bundle and
handed to every browser that subscribes. Hiding it would be theatre, and a
secret's log masking would only obscure the verification.

Verified before trusting the value, because a wrong key fails silently at send
time and this one gets baked into every future bundle:

  - decodes to 65 bytes, first byte 0x04 — a valid uncompressed P-256 point
  - the public key is the MATE of VAPID_PRIVATE_KEY on the box (derived the
    point from the private scalar and compared; no secret printed)
  - VAPID_SUBJECT is a valid mailto:/https: scheme

One trap on the way: the box stores the value quote-wrapped (len 89 = 87 + 2).
dotenv strips those when the server loads them, so runtime was fine — but
copying it verbatim into the variable would have inlined literal quotes and
produced a broken key that looks correct in every listing.

The gate's KNOWN_GAPS entry is deleted rather than edited, so removing either
the variable or the env: line now fails the check instead of silently killing
push again. Mutation-proven both ways: line removed -> 4 passed, 1 failed
naming the var; restored -> 5 passed, 0 failed.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 08:27:25 +00: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
5b0c5a0468 fix(deploy): the .nvmrc fallback tracks the box, not history (#461)
aoz-housing's vitest merge deployed red: CI (Node 24, npm 11) wrote the
lockfile, the shared deploy fell back to Node 20 (npm 10) for the .nvmrc-less
repo and npm ci rejected it — 'Missing: esbuild from lock file' — stranding
two merged commits until a hand-regenerated npm-10 lockfile landed. The box
has been on Node 24 since 2026-08-31 and fleet CI defaults to 24; a 20
fallback here re-arms that npm-major split for every .nvmrc-less repo.


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-02 08:40:41 -07:00
dependabot[bot] b6e1de8d34 chore(deps): bump actions/setup-node from 4 to 7 (#455)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4 to 7.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v4...v7)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-08-31 23:09:28 +00:00
dependabot[bot] 3e454ee420 chore(deps): bump actions/checkout from 5 to 7 (#454)
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-08-31 22:58:47 +00:00
21a051487b chore(ci): CI and .nvmrc follow the box to Node 24 (#452)
The box ran Node 20 four months past EOL; it moved to 24.20.0 today with
every service health-verified. CI validating on 20 now validates against
a runtime nothing uses.


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-08-31 16:11:14 +00:00
GandClaude Opus 5 caa0e41c3b chore: add a formatter (#449)
* chore: add a formatter, matching the style this repo already writes

singleQuote=false was chosen by counting this repo's own
imports, not by fleet decree. The fleet is genuinely split and the two repos
that already had a .prettierrc disagreed with each other, so there was no
standard to restore. Quote style does not cross repo boundaries; having a
gate does.

Markdown is ignored for now — prettier rewraps prose, which would bury the
real diff.

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

* style: format with prettier (1062 files)

Mechanical. No behaviour change. This SHA is listed in
.git-blame-ignore-revs so `git blame` skips it.

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

* chore: teach git blame to skip the reformat

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

* fix(lint): reattach two guards the reformat detached

Both effects were one-liners, so a trailing eslint-disable-line covered the
setState call:

  useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ...

prettier expanded the block. The comment stayed on the closing line while the
call moved above it, so the guard protected nothing and the rule its author had
deliberately silenced failed the build.

This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line
variant. Both come from the same fact: an eslint directive binds to a line
number, so reformatting can silently unbind it, which makes 'mechanical, no
behaviour change' false for any bulk reformat.

* chore(desktop): bump the runner version the reformat requires

desktop-release-drift enforces that anything built into Fleet Runner which
differs from the last released tag must carry a version ahead of that tag —
main read 0.8.15 and fleet-runner-v0.8.15 already shipped.

A whole-repo reformat changes bytes under desktop/, so the gate fires. The
alternative was adding desktop/ to .prettierignore, which would buy a quiet PR
by carving a permanent hole in the formatter's coverage — the precise shape of
silent drift this test was written to catch. Bumping is what the rule asks for
and costs one patch release whose only content is whitespace.

* chore: merge main and re-format

A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR
runs no checks at all while reporting nothing. Conflicts resolved to main,
which is correct because this branch changes formatting and nothing else.

* chore: leave desktop/ out of this reformat

desktop-release-drift is right to refuse this. Everything under desktop/ is
built into Fleet Runner, so changing it means shipping: bump the version AND add
a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed
Fleet Runner and wants to know what changed'. For a whitespace-only build the
honest answer is 'nothing', so that release should not exist — and I should not
write release notes claiming otherwise.

I had bumped to 0.8.16 to get the gate green. That was the wrong direction:
publishing a build to three OS runners to keep a formatting PR quiet. Reverted.

desktop/ is excluded in .prettierignore with the reasoning recorded there, to be
formatted alongside the next real runner change, where the bump and the notes are
true anyway.

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-31 09:23:30 +00:00
1a342fa6d6 refactor(ops): one voice on the phone — grace, digests, backoff, subjects (#444)
George, 2026-08-29, pasting his Telegram: 'refactor whatever is sending this
abomination.' The morning read as: identical FAILED triples at 08:01, 08:31,
09:01, 09:32, 10:02, 10:33; a six-pack of FAILED+RECOVERED for a 5-minute
deploy blip; closures naming state keys ('RECOVERED:
rtc_revampit_configured_host_does_not_resolve__typing_static_nvi',
'agentwork_reparaturbonus-zh'); UNIT DOWN bodies that repeat the unit name
four times in systemd boilerplate while burying the app's actual error; and
two URL monitors speaking two dialects.

One rule set, all in lib-alert.sh and its callers:

- Reminders BACK OFF: the claim stamp holds 'ts count'; each claim quadruples
  the next wait (30m, 2h, 8h, capped at a day). alert_clear resets the
  ladder. claim_once is the decision without the delivery, so callers can
  digest.
- The sweep gets ONE-TICK GRACE: first sighting watches, never pages — the
  OnFailure notifier owns the instant page and already declines deploy blips.
  A blip inside the grace produces zero messages, failure or closure.
- DIGESTS: N failures on one tick are one 'STILL FAILING: a; b' message; same
  for recoveries.
- Recovery names the SUBJECT, never the key: alert_transition remembers the
  human subject at bad-time (explicit arg, else text-to-first-colon, else
  key) — fixes every alert_transition caller fleet-wide at one seam.
- The notifier page shows the APP's error: systemd liturgy filtered from the
  journal tail; '🔴 DOWN: appcron-kivvi-dunning — curl: (22) … HTTP 500'.
- fleet-uptime.yml speaks the same dialect ('🔴 DOWN: app (…)',
  '✅ RECOVERED: app', no ISO timestamp — Telegram stamps messages).

92 tests green; mutation-verified per area: no-grace → 8 red, key-recovery →
3 red, flat-backoff → 1 red.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-29 10:29:22 +00:00
27115b1659 feat(ops): watch the certificates, three weeks before they take the box down (#426)
Nothing watched TLS expiry. Caddy renews at 30 days remaining and has never
missed, which is exactly why: the check felt unnecessary because it had never
been needed. But renewal breaks for reasons no app ever sees — an ACME rate
limit, port 80 closed by a firewall change, a DNS record moved — and the first
symptom is every site on the box going dark at once. Twenty domains, one
failure. The warning exists for weeks; nobody was reading it.

Measured today, all twenty are fine: 65-88 days, staggered. That is the moment
to add the check, not after the outage that proves it was needed.

Reuses the uptime sweep's target list rather than taking a copy — verified
identical, 20 targets and 20 certificates. A second list of domains is the gap
that hid botsmann for weeks, and it would open here in exactly the same way: a
new app registered in apps.conf would be probed for HTTP and silently
unprotected against expiry.

Thresholds are Caddy's, not arbitrary. ok at 21+ days, because Caddy renews at
30 and has therefore had nine days of attempts; warn from 7 to 20, when renewal
should have happened and did not; critical under a week. Unreadable is CRITICAL,
never ok: "we could not check the certificate" and "the certificate is fine"
must not share an outcome — that conflation is how botsmann's 503 read as
healthy for weeks.

Daily, not every fifteen minutes. A certificate does not change between sweeps,
and twenty TLS handshakes a quarter-hour to relearn the same number is noise
that earns nothing — and noise gets muted.

No issue/Telegram machinery: fleet-uptime.yml owns that, and a second alerting
path to keep in step is not worth it for a check with three weeks of slack.
Stated in the workflow rather than left to be discovered.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 15:05:35 +02:00
GandClaude Opus 5 d1517949fc docs(ci): the sweep lives in bitbaum/fleet, not dotfiles (#425)
The `uses:` line is already correct. What was stale is the prose next to
it, which told the reader the policy lives in bitbaum/dotfiles and to go
change it THERE. That file no longer exists in dotfiles — the sweep moved
to bitbaum/fleet on 2026-08-28, because a repo holding someone's .bashrc
is not where a fleet's deploy policy belongs.

A comment that misroutes a fix is worse than a missing one: it sends the
next person to edit a repo where the change would reach nobody, which is
the precise failure the shared sweep exists to prevent.

Files: .github/workflows/auto-merge.yml, CLAUDE.md


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

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 12:00:28 +00:00
GandClaude Opus 5 be37b710fc feat(ops): the reference audit now reaches Telegram, from the box (#422)
The audit landed on an Actions schedule, which closed detection and left
notification wide open — a red Actions run is a channel nobody watches, so it
had the same "green everywhere and nothing ships" shape it exists to catch.

Moves the schedule to the Hetzner box as fleetcrown-fleet-refs.timer (every 6h)
and alerts through the watchdog Telegram channel that host-check and the
OnFailure notifier already use.

NO NEW SECRETS. The GitHub token comes from root gh on the box; Telegram comes
from /opt/monitoring/telegram.env. Nothing was copied into GitHub secrets.

ONE IMPLEMENTATION. The timer runs the same scripts/ci/fleet-refs-audit.mjs the
deploy already rsyncs to /opt/fleetcrown/app. A shell reimplementation would
have drifted from the CI one the moment either changed. Actions keeps the same
job as a manual button (workflow_dispatch), so there is no second schedule.

Three failure modes are alerted rather than assumed:
  - script missing or no GitHub token -> its OWN state key, so "could not look"
    can never overwrite a real finding or read as "checked and clean"
  - the audit failing -> transition-only, so it pages on change, not every 6h
  - the UNIT failing -> OnFailure=notify-failure@%n, because a script that
    cannot start is otherwise exactly as quiet as a clean fleet

The check is `set -u`, deliberately not `set -e`: its whole job is to run a
command expected to exit non-zero, and -e would kill it before it could alert.
It uses if/else rather than `check && alert || alert` — that shape read the
alert branch exit status as the check result and caused the 2026-08-05 storm,
40 alert/RECOVERED pairs in 3h.

Verified end to end, not assumed: Telegram API returned ok:true, message_id
3402, private chat. Forced-failure run through the identical code path produced
the alert; the clean run produced silence.


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

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 11:42:57 +02:00
GandClaude Opus 5 1697d93bc8 feat(ci): audit every workflow reference in the org, on a schedule (#418)
Three times in three days a rename or a transfer stopped every merge and every
deploy across the fleet, and all three times nothing looked wrong. GitHub
follows a rename for REST and for git; the Actions `uses:` resolver does not.
The run dies before any job exists — zero jobs, no log — so the workflow that
would report the failure is the one that cannot start, and pull requests stay
green and mergeable while nothing ships.

That is why this cannot be a per-repo check. A copy inside each repo only
protects repos that already have CI, and petvity and solon and datacat each had
a dead deploy with no auto-merge.yml to notice it. This asks GitHub, from
outside, what every referenced repo is really called and compares that to what
the workflow says.

Found on its first run, before this was even committed: datacat and solon both
called catomean/fleetcrown and had been unable to deploy since the org move.

Two deliberate details:
  - Comment lines are stripped before the retired-handle check. Workflows that
    EXPLAIN this outage name the old account on purpose, and a gate that fires
    on its own documentation is one people learn to ignore.
  - MIN_REPOS is a floor. "0 problems" across 0 repos is not a pass; if the
    token stops seeing the fleet that must fail, not report clean.

Not closed by this: it fails red in Actions, which nobody watches. It closes
detection, not notification. Routing it through FleetCrown alerts is the
follow-up.


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

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 08:50:55 +00:00
GandClaude Opus 5 1779ef7873 chore(ci): call the auto-merge sweep from bitbaum/fleet (#417)
The fleet automation moved out of dotfiles on 2026-08-28; the dotfiles path
is now a forwarding shim. This points the caller at the sweep's real home.
One line; the reusable workflow's interface is unchanged.


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

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 10:40:55 +02:00
dependabot[bot] fe067a1960 chore(deps): bump actions/checkout from 5 to 7 (#410)
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-08-28 06:04:53 +00:00
4d1c9f1fe7 chore: migrate the fleet to the bitbaum org (#415)
* chore(ci): GitHub owner catomean -> bitbaum

* docs(hetzner): update _box-env.sh comments for the completed org migration

The GH_OWNER/WORKFLOW_OWNER comments described a future state (repos moving
to bitbaum while fleetcrown stayed personal) that sweep-gh-owner.sh just
made true, then obsolete: fleetcrown itself is in bitbaum now too. Comments
describing a plan that already happened are worse than no comment — they
send the next reader looking for a divergence that isn't there.

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

* chore(desktop): release 0.8.15 — the org-migration owner literals

Same shape as 0.8.14: desktop/ carries two literal owner references (issue
link, updater feed owner) that a fleet-wide rename touches, and
desktop-release-drift.ts correctly refuses to let that ship without a
version bump — a repo whose desktop app silently points at a dead update
feed is worse than one that fails the gate.

This should be the last time it's an account name: the org is the stable
home from here.

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

---------

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 07:45:50 +02: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
9db221a211 feat(ops): watch every app on the box, not just the one with a monitor (#404)
botsmann answered 503 from /api/health for weeks and nobody knew. Not
because a check failed — because there was no check. Nineteen services run
on bitbaum and the fleet's only uptime monitor probes orangecat.ch.

Targets come from scripts/hetzner/apps.conf, the same manifest deploy.sh
reads, so registering an app for deployment is what enrols it in
monitoring. A hand-maintained copy of "what is deployed" is how the gap
that hid botsmann opens again.

Two decisions carry the whole thing, and both are pinned by tests:

- Probe /api/health, not `/`. botsmann's homepage served 200 throughout
  the outage — Next renders marketing pages from disk with no database in
  the path. A monitor pointed at `/` would have been green the entire time.
- An app with no health route reports LIMITED, never UP. Eleven apps are
  in that state today; calling their homepage check a pass would put a
  green tick beside eleven apps whose database could be on fire.

Two defects found by running it against production rather than trusting it:

- `curl ... || echo 000` emits "000000" on a connection failure — curl
  prints its own 000 and the fallback adds another. That matched no
  verdict, fell through to "no health route", and re-probed `/`. For an
  app that serves static pages without its database (botsmann's exact
  shape) it would have downgraded a hard outage to a soft LIMITED. A
  monitor whose failure mode is to soften failures is worse than none.
- bridge is an SSE fan-out service, not a Next app: it answers /healthz
  and 404s on `/` by design. The first run reported a perfectly healthy
  service as DOWN, which is how a monitor teaches people to mute it.
  Targets may now declare their own health path.

Current sweep: up=7 limited=11 down=1 (botsmann — the real outage).

Does not replace orangecat's uptime.yml, which also reports box-level
disk, backup freshness and auth — properties of the machine, not of an app.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 21:53:25 +02:00
09a68fc476 fix(ci): point the auto-merge sweep at the renamed org (#403)
Shipping has been down since 18:14 UTC. Every auto-merge sweep since then
failed before starting a job — "this run likely failed because of a
workflow file issue" — and the last success was 17:07.

Nothing in this repo changed. The GitHub org was renamed
maonakamoto -> catomean, and a reusable-workflow reference does NOT follow
that rename. `gh api repos/maonakamoto/dotfiles` redirects to
catomean/dotfiles, and `git clone` of the old URL still works, so the
rename looks complete from every angle except the one that matters:
Actions resolves `uses: owner/repo/...` against the literal owner at parse
time, and the workflow is invalid the moment it cannot.

That failure mode is quiet in the worst way. A broken sweep does not mark
any PR red — the PRs simply sit at MERGEABLE/CLEAN forever, which is
indistinguishable from waiting for a slot. Three PRs were queued behind it.

catomean/dotfiles has the sweep workflow at .github/workflows/
auto-merge-sweep.yml@master (verified via the API before this change).

Deliberately minimal: only the `uses:` reference and its two adjacent
comments. The wider maonakamoto -> catomean rename is in flight in another
change set and this must not collide with it — this is the one line that
has to land now, because nothing else can merge until it does.


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

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 21:15:42 +02:00
81f5bee2ff fix(desktop): ship the six commits that never left the server (#370)
Fleet Runner reaches a machine only when a `fleet-runner-v*` tag exists, and
the tag is minted only when someone remembers to bump desktop/package.json.
Nothing ever checked that they did, so it stopped happening quietly.

Measured on main: seven files changed since v0.8.12 — a power-source router
(#319), a usage double-billing fix (#349), capture-hook and poller changes —
with the version still reading 0.8.12, byte-identical to the tag. All of it
live on the server, none of it on any machine, and no signal anywhere.

Three parts:

- bump to 0.8.13, which releases the stranded work
- scripts/test/desktop-release-drift.ts fails the build when desktop/ differs
  from the last released tag without a bump. Absent tags report UNCHECKED
  rather than passing, since actions/checkout fetches none by default — hence
  fetch-depth: 0 on the check job.
- a `release-desktop` job mints the tag and dispatches the build once main is
  green. It dispatches rather than relying on the tag push, because a push
  made with the default GITHUB_TOKEN triggers no workflow.

The bump stays human — it is the statement that a change is meant to ship.
The tag is mechanical, which is exactly why a person forgets it.

Note this is NOT the cause #227 names: the publish-token break it was filed
for is already fixed and v0.8.12 published fine. The chain broke one link
further back, at the human step, where a break leaves no trace.

Mutation-proven six ways, each red then green: blinded checkout, deleted tag
job, removed dispatch, forgotten bump, backwards version, and no tags at all.
The first draft passed two of those — the gate matched its own explanatory
comment, and read a sibling job's setting as the one it was asserting on.

Closes #227

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 09:09:38 +00:00
Gandt a577014533 chore: clear the code-debt audit — gates, auth coverage, deps, CI database (#362)
* perf(gates): stop charging 8 minutes to push and 3 minutes to commit

Measured on main today: `npm run verify` took 490s and `.husky/pre-commit`
took 172s of it on EVERY commit. That is not a safety property, it is a tax on
committing and pushing — the two habits that keep work off a single disk. The
same fleet audit found 206 finished files stranded uncommitted for ten days.

Nothing here weakens a check. Every one still runs, on the same files:

  disk-gc /proc scan   110s -> 16s   in_use() forked a readlink per PID on
                                     every call. Hundreds of processes times
                                     several candidate dirs is thousands of
                                     forks per run. Now one `ls -l` pass,
                                     cached for the run. This is SHIPPED code,
                                     so bitbaum's hourly GC gets it too — and
                                     caching is the more correct reading
                                     anyway: "in use when the sweep started"
                                     should not flip between tiers.

  eslint               132s ->  7s   --cache. Cold is 150s (+18s to write it),
                                     paid once by CI; developers pay warm.

  test-disk-gc fixture              sparse files via truncate instead of
                                     dd-ing ~300MB of zeros nothing reads.
                                     The code under test only calls df, which
                                     the test already stubs, so it cannot tell.

  pre-commit           172s ->  ~0   lints STAGED files only. tsc cannot be
                                     scoped to a file set and moves to the
                                     push side, where the full bundle already
                                     runs. A commit is local and reversible; a
                                     push is shared. Gate them differently.

verify 490s -> 334s, still green. `npm run verify` remains the single
definition of verified and CI still calls it verbatim.

* fix(deps): clear every high-severity advisory (15 -> 4, 0 high)

`npm audit fix` took 9 of the 15. The two HIGH ones it left were both the same
root cause — ajv's advisory is *via* fast-uri — and the vulnerable range is
3.0.0-3.1.4 with 3.1.6 already published inside the same major. So an override
closes both with no breaking change:

  HIGH  fast-uri  host confusion via literal backslash authority delimiter
  HIGH  ajv       (inherits the above)

  before  1 low   7 moderate  7 high
  after   0 low   4 moderate  0 high

The remaining 4 moderates are deliberately NOT fixed. They are one chain —
drizzle-kit -> @esbuild-kit/* -> esbuild — and npm's offered remedy is
drizzle-kit@0.18.1, thirteen minor versions back, which would take the schema
tooling with it. The advisory is esbuild's DEV SERVER accepting cross-origin
requests; drizzle-kit is a devDependency, esbuild is not referenced by
next.config.ts, and neither reaches production. Downgrading working migration
tooling to silence a dev-server advisory that does not apply is a worse trade
than carrying it, so it is carried knowingly rather than silently.

verify green at 372s.

* test(api): make auth coverage checkable instead of archaeological

There is no middleware.ts — all 214 routes guard themselves, through ELEVEN
different mechanisms: four session getters, two private-zone wrappers, a cron
secret, a runner bearer, a widget token, an agent token, and signed webhook
secrets. Each is reasonable on its own. They are layers, not duplicates, and
collapsing them would be worse than leaving them.

The defect is that the SET is not knowable by inspection. Auditing it today
took seven passes. The first reported 44 unguarded routes including
/api/people and /api/memory — every one a false alarm from a helper the grep
had not met yet. Each later pass found another mechanism and shrank the list:

    44 -> 27 -> 18 -> 25 -> 18

Nothing was actually wrong. That is the problem: a property needing seven
attempts to verify is a property nobody verifies, and its failure mode is
silent — a new route with no guard looks exactly like the 18 that are public
on purpose.

So this asserts the checkable version of the rule: every route either names a
known mechanism, or appears on a PUBLIC list with a reason a human wrote. The
reasons are the real artifact; until now the answer to "why is this endpoint
open?" existed only in whoever wrote it.

The list is self-cleaning — it also fails when an entry names a route that now
guards itself, or one that no longer exists, so it cannot rot into exemptions
nobody re-examined. All three failures verified red before committing.

Current state: 214 routes, 196 guarded, 18 public with a recorded reason.
No unguarded route was found. Runs in verify via the unit glob; no DB, no
network, 1s.

* test(ci): give CI a database, so the billing test stops being skipped forever

Six suites sat on a permanent skip list for want of a Postgres. One of them
is the OrangeCat entitlement end-to-end — signature verification, actor
lookup, grant write, dedupe, expiry sweep. That is the billing boundary, and
it had never run in CI once. "Only passes locally via .env.local" means, in
practice, that nobody runs it.

It turns out it needs a MIGRATED database, not a seeded one, so CI can just
have one. It now runs green there.

Two things this surfaced that are worth writing down:

  * drizzle/*.sql does NOT replay from empty. 0001_canonical_project_identity
    references `user_projects`, which 0000 never creates; 51 of 56 migrations
    fail against a fresh database. The journal is history, not a rebuild
    recipe — so CI uses `drizzle-kit push`, and anyone reaching for those
    files to rebuild an environment should know they will not work.

  * push is only non-interactive because the CI database is EMPTY. Its
    truncate prompts fire for tables holding rows, and an empty database has
    none. The comment says so at the call site, because pointing this at a
    database with data would be a very bad afternoon.

pgvector/pgvector:pg16 rather than stock postgres — knowledge-embeddings
declares a `vector` column and push dies without the extension.

Skips are now conditional rather than permanent: SKIP_UNLESS_ENV keeps a test
out of the run only while its prerequisite is missing, instead of excluding it
on every machine forever because some machines lack a database. Verified both
ways — 103 tests with no DATABASE_URL, 104 with one, full verify green at 191s.

---------

Co-authored-by: t <t@t.t>
2026-08-25 19:55:23 +00:00