Commit Graph
334 Commits
Author SHA1 Message Date
Cato b1a8ab38b8 fix(deploy): establish receipt visibility from the workflow event (#1737) 2026-11-15 17:38:15 +01:00
Cato 247fa9d9b3 fix(crons): a job cut off by a deploy waits for the new app before giving up (#1731)
sync-package-updates paged on 15 Nov with 'Connection reset by peer'
during a Loki deploy, although the runner reruns a converging job when
loki-app restarts mid-request. It checked loki-app's start time the
instant curl failed, but a reset or empty reply is the old process going
down: the new one starts only after that stop finishes (up to ~13 s).
So it never saw the restart. Wait up to 60 s for the start time to move
before deciding; send-once jobs are still never repeated, and a cut with
no restart still fails (after the wait).

The test now also covers the production order (restart lands after the
cut); it fails on the old runner.
2026-11-15 14:26:16 +01:00
CatoandClaude Fable 5.2 137ff5d1fb fix(ai): Loki reads and writes the box's AI usage log; fleet-env usage-log points every app at it (#1709)
* ops(fleet-env): usage-log points every app at one AI usage log through the fleet file

launch.sh.tmpl sets AI_USAGE_DIR, but a launch script is only rewritten by
a site sync, so after #1704 no running app had it and Settings > AI said
the server is not writing the log. Every launch script already sources
/opt/fleet/env with export on. usage-log makes the directory, writes the
one line there once, and restarts the apps one at a time.

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

* fix(ai): Loki reads and writes the box's usage log without the launch variable

Loki's launch script predates /opt/fleet/env, so after the box was pointed
at one usage log Loki still had no AI_USAGE_DIR: the card said the server
was not writing a log. lib/ai/usage-dir takes the box's directory when the
variable is unset and it exists; instrumentation adopts it at boot (and
names the app LOKI). Loki walks its own chain, so the package cannot see
its calls: recordUsage reports each answered call to the log.

scripts/test/usage-dir.ts.

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

* docs(env): AI_APP_ID in .env.example

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

* ops(fleet-env): where and retire look beyond the app layout

The platform's Google key was retired from /opt/fleet/env and the app env
files on 2026-11-13, but nothing had looked at the builder's env
(/opt/loki/runner/.env), the named runners' (/etc/loki/runners/*.env) or the
Telegram gateway's (~openclaw/.openclaw/.env), where a copy of the same key
could still be read by a process that spends. where and retire now also
sweep /opt, /etc/loki, /home and /root for env files (not examples, not
node_modules, not releases), reading root-owned ones through sudo.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 13:41:20 +01:00
CatoandClaude Fable 5.2 3889d7e7c2 feat(settings): every app on this server and every AI vendor, today (#1705)
* ops(fleet-env): retire a key everywhere in one command; GEMINI_API_KEY is no longer a fleet key; ai-kit 1.26

GEMINI_API_KEY sat in /opt/fleet/env as a free tier. The Google project had
billing and every app read the key: about $567 on 10-11 Nov 2026. On
2026-11-13 it was still set there, with eight apps on an ai-kit that puts
Google in the free chain.

- fleet-env.sh where KEY: every env file on the box that sets KEY, by
  fingerprint. retire KEY: its line in /opt/fleet/env and in every app env
  becomes a dated comment (the value is kept), and the app units restart one
  at a time so none keeps the value it started with.
- fleet-keys.conf drops GEMINI_API_KEY, so seed never brings it back.
- fleet-env.yml offers where and retire with a key input.
- @bitbaum/ai-kit ^1.26.0: Google out of the free chain, paid AI off unless
  an app opts in, daily caps.

test-fleet-env.sh covers where, retire (value kept, other lines untouched,
no value printed, seed does not restore) and the refusal of a non-credential.

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

* test(ops): four .env cases that need an unreadable file are not run as root

chmod 000 is how the section makes a .env unreadable, and root reads any
file. In an agent's sandbox (uid 0) the four cases could only fail, on main
too, and stopped every push that touched scripts/hetzner. They print as not
run; CI and a developer's machine run them as an ordinary user.

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

* ops(launch): every app on the box writes to one AI usage log; ai-kit 1.27.0

launch.sh.tmpl exports AI_USAGE_DIR=/opt/fleet/ai-usage where that
directory exists and AI_APP_ID from the app's directory name, unless the
app's own .env sets them. @bitbaum/ai-kit 1.27.0 then writes one line per
model call there (app, vendor, model, outcome; never content). fleet-env.yml
creates the directory. Kivvi canaries 1.27.0, so the rollout gate no longer
passes 1.26.0.

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

* feat(settings): every app on this server and every AI vendor, today

The owner, 2026-11-13: 'I never know what is used up, what isn't, what it
was used up for, and when. Is it just one app, or is it all the apps?'
About $567 had gone to Google and nobody could say which app spent it.

Settings > AI gains the operator's card 'Every app on this server'. It
reads the one usage log every app writes (@bitbaum/ai-kit usage-log,
AI_USAGE_DIR) and shows, per vendor: free or billing, whether its key is on
this server, what today looked like, the last trouble in words, what that
means for the next request, and which apps used it; then the same by app.
A log that could not be read is never drawn as nothing used; a vendor
nobody called is 'not called today', not full and not empty; a person's own
key is counted apart.

- lib/ai/fleet-usage.ts (pure view), /api/ai/fleet (operator only, key
  NAMES only), components/settings/AiFleetSettings.tsx
- scripts/test/fleet-usage.ts: 12 checks

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

* docs(env): AI_USAGE_DIR in .env.example

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

* fix(fleet-env): retire edits the file a symlinked .env points at, never the link

/opt/<app>/app/.env is a symlink to shared/.env. An in-place sed on the
link replaces it with a regular copy, which later changes to shared/.env
never reach. where and retire resolve each file first, so the 13 paths the
box listed for GEMINI_API_KEY are the 8 files they really are.

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

* test(npm-publish): tamper with the first character of the sealed body, not the last

The last base64url character of a body carries bits that belong to no
byte, so replacing only the tail could decode to the same bytes, and
openSecret rightly accepted it: 'tampering is refused' failed on an unlucky
random IV (CI on #1705, 2026-11-13). The first character always changes a
byte. 40 of 40 runs pass.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 12:27:51 +01:00
CatoandClaude Fable 5.2 8b3727e464 ops(fleet-env): retire a key everywhere in one command; GEMINI_API_KEY is no longer a fleet key; ai-kit 1.26 (#1704)
* ops(fleet-env): retire a key everywhere in one command; GEMINI_API_KEY is no longer a fleet key; ai-kit 1.26

GEMINI_API_KEY sat in /opt/fleet/env as a free tier. The Google project had
billing and every app read the key: about $567 on 10-11 Nov 2026. On
2026-11-13 it was still set there, with eight apps on an ai-kit that puts
Google in the free chain.

- fleet-env.sh where KEY: every env file on the box that sets KEY, by
  fingerprint. retire KEY: its line in /opt/fleet/env and in every app env
  becomes a dated comment (the value is kept), and the app units restart one
  at a time so none keeps the value it started with.
- fleet-keys.conf drops GEMINI_API_KEY, so seed never brings it back.
- fleet-env.yml offers where and retire with a key input.
- @bitbaum/ai-kit ^1.26.0: Google out of the free chain, paid AI off unless
  an app opts in, daily caps.

test-fleet-env.sh covers where, retire (value kept, other lines untouched,
no value printed, seed does not restore) and the refusal of a non-credential.

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

* test(ops): four .env cases that need an unreadable file are not run as root

chmod 000 is how the section makes a .env unreadable, and root reads any
file. In an agent's sandbox (uid 0) the four cases could only fail, on main
too, and stopped every push that touched scripts/hetzner. They print as not
run; CI and a developer's machine run them as an ordinary user.

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

* ops(launch): every app on the box writes to one AI usage log; ai-kit 1.27.0

launch.sh.tmpl exports AI_USAGE_DIR=/opt/fleet/ai-usage where that
directory exists and AI_APP_ID from the app's directory name, unless the
app's own .env sets them. @bitbaum/ai-kit 1.27.0 then writes one line per
model call there (app, vendor, model, outcome; never content). fleet-env.yml
creates the directory. Kivvi canaries 1.27.0, so the rollout gate no longer
passes 1.26.0.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 11:26:30 +01:00
Cato d7da5375a0 fix(crons): a job cut off by a Loki restart runs once more on the new process (#1702)
fc-cron@sync-package-updates paged on 13 Nov with "curl: (52) Empty reply
from server" while four Loki deploys landed in 50 minutes (07:27-08:09 UTC).
Each deploy restarts loki-app; the runner already retried a refused
connection (exit 7) through that window, but not a request the old process
accepted and then dropped (52 empty reply, 56 reset, 28 timeout). The 120 s
timeouts that paged for every job on 12 Nov have the same shape.

Now, when curl fails that way AND loki-app.service's start time moved since
the run began, the job runs once more on the new process. A job that sends
or starts something exactly once (digest email, canary, autopilot,
check-ins, chat review) is not repeated: it may already have acted, so it
fails as before. An empty reply with no restart still fails.

Test: scripts/hetzner/test-cron-runner.sh gains the three cases (restart:
rerun and succeed; send-once job: no rerun; no restart: no rerun); 17 pass.
2026-11-13 09:37:13 +01:00
CatoandClaude Opus 5.5 c8713738e4 fix(runs): delivery falls back to the claim time, so a finished agent's handoff closes its run while the runner is behind (#1691)
* feat(ops): runs-db runs=open lists every open run, read-only

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

* fix(runs): a run's delivery falls back to the claim time, so the agent's own handoff closes it while the runner is behind

2026-11-12 17:00: the orangecat probe was claimed at 16:59:5x, Claude did it
and wrote its handoff at 17:00:00, and the runner, still on the morning's code
because its update waits on the drain, acked at 17:00:05 without its injection
time. deliveredAt was the ack time, the handoff "predated" it, and the run sat
at Needs you.

The prompt cannot reach the agent before the runner claimed it, so the claim
time is a floor that never postdates the injection. Used only when the
runner reports none; deliveryStampFor still bounds it.

scripts/test/delivery-claim-floor.ts (shows the old stamp leaving the run
open and the claim time closing it). Checkpoint updated.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 19:20:35 +01:00
CatoandClaude Opus 5.5 74183f9410 fix(runner): a sealed session between tasks does not hold the runner's update; ops: runs-db (#1690)
* fix(check): the loop check prints the agent's screen before it aborts a quiet run

2026-11-12 16:30: the orangecat probe went to Claude Code (Grok's balance was
spent, #1689 routed around it), started, and at 16:55 read "Needs you: no
output for a while" with a clean checkout. Nothing said what the agent was
showing. The check now opens the session's peek stream for twelve seconds
and prints the last twenty lines, masked, before the abort.

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

* feat(ops): runs-db prints a project's last runs and stored handoff, read-only

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

* fix(ops): runs-db reads summary as text and finds the project's session row by name

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

* fix(runner): a sealed session whose project has no open run does not hold the runner's update

The drain counted a sealed session as idle only when its podman relay went
quiet. On 2026-11-12 an idle session's relay moved 3 to 10 KB a minute, so
every open session counted as working, each deploy's drain waited its six
hours behind them, and the runner on the box kept the morning's code all day.

That mattered at 17:00: a probe task to orangecat finished in seconds and
wrote its handoff at 17:00:00, but the old runner acked delivery at 17:00:05
without its injection time (the fix that sends it is on main and not on the
box), so the handoff "predated" its own delivery and the run sat at Needs you.

count_agents now reads the open runs from Loki's database, as
sealed-builds-ctl.sh stop-idle does: a sealed session older than fifteen
minutes whose project or lane has no open run is between tasks. When the
database cannot be read, the old rule stands. between_runs is pinned by
test-drain-and-restart-runner.sh (51 of 51).

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

* revert(check): the loop check's screen look; the peek stream takes a browser session only

It answered 401 to the check's agent token (2026-11-12 17:15), so it printed
nothing useful. runs-db (sealed-builds.yml) answers the same question from
the database: the handoff, its time and the run's delivery stamp.

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

* docs(handoff): Claude did the probe; the late delivery stamp and the drain that never restarts the runner

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 18:39:30 +01:00
CatoandClaude Opus 5.5 b0c6d58ebe fix(dispatch): a chat task does not walk into an agent that has run out; ops: agent-probe asks an agent on the box what it says (#1689)
* feat(ops): agent-probe opens one agent CLI in a sealed container and prints what it says

On 2026-11-12 the runner refused claude 16 times between 14:42 and 14:50 UTC
and grok once at 15:21, "usage limit is exhausted", and kept no screen to
show why. agent-probe (sealed-builds.yml, runs=<agent>) launches the agent as
the runner does, with the credentials sandbox.ts passes through (names only),
sends "Reply with the single word PONG" and prints the masked screen.

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

* fix(ops): the PTY probe answers a modern TUI's terminal queries and its trust prompt

grok drew nothing until the terminal answered its version query (ESC[>0q),
and claude stopped at the trust prompt of the probe's new folder, so the
first agent-probe runs (2026-11-12) never reached the composer.

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

* feat(ops): agent-probe asks one headless turn before the interactive one

grok draws nothing in the probe's terminal; a headless turn has no terminal
to negotiate and prints a quota wall as plain text.

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

* fix(dispatch): a task nobody pinned to an agent does not walk into one Loki has just watched run out

Live 2026-11-12: the orangecat project's agent was Grok, whose Grok Build
balance was used up ("402 Payment Required: Grok Build usage balance
exhausted", read with sealed-builds agent-probe), and every chat message to it
failed in fifteen seconds while Claude Code on the same builder answered.
Kickoff, Implement and the retry already route around a spent agent; the
chat's path, injectPrompt with no agent pinned, did not.

- lib/dispatch-agent-route: agentAvoidingSpent, the same providerChoiceFor +
  routeAroundSpent the kickoff uses; anything unreadable keeps the project's
  agent. Not a preference change.
- inject-core: used only when the caller pinned no agent; a rerouted run
  records reroutedFrom/reroutedBecause for the Watch page; agentNotice in the
  body.
- The chat's dispatch reply says which agent took the task and why.

scripts/test/dispatch-agent-route.ts. Checkpoint updated.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 17:22:59 +01:00
CatoandClaude Opus 5.5 43e1782b22 fix(builder): five agent sessions at once, not eight; idle sealed sessions can be stopped to free memory (#1687)
* docs(handoff): #1678 merged; the box still drops requests and Loki's deploys do not land

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

* docs(handoff): memory ceiling set at 10 GiB; Gemini spending cap in OrangeCat #1672

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

* fix(builder): five agent sessions at once, not eight; idle sealed sessions can be stopped to free memory

Measured on the box on 2026-11-12: a sealed session holds about 1 GiB, not
the 0.4 GB the cap of eight was sized at. With seven or eight open the
builder held 6.3 to 8.3 GiB, the box had 0.6 GiB left, swap was full, and
the kernel had stopped 37 processes for memory, live sites and the gateway
among them.

- AGENT_MAX_OPEN_DEFAULT is 5. LOKI_AGENT_MAX_OPEN raises it where there is
  room.
- sealed-builds-ctl.sh stop-idle (sealed-builds.yml): stops the sealed
  sessions that relayed less than 512 bytes over two minutes, the line the
  idle rule already uses for "no work". A working agent prints far more
  (its spinner alone). runs=dry lists without stopping. idle_sessions is
  pinned by scripts/hetzner/test-sealed-builds-memory.sh.

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

* fix(spend): the platform's Gemini key is not used where nothing caps it

The audit after the Gemini spend (2026-11-12) found the same platform key in
three places with no cap that refuses a call:

- Loki's own chat chain called Google whenever GEMINI_API_KEY was in its
  env. Google is left out of CHAT_CHAIN (UNCAPPED_PAID_PROVIDERS) until Loki
  has a cap that refuses, like OrangeCat's reserve_vendor_call.
- install-builder-agents.sh copied OrangeCat's key into the builder's env
  for the Antigravity CLI. An agent CLI cannot be capped in code; the
  builder now uses Gemini only with a key of its own, from a Google project
  with a per-day request quota.
- openclaw-media.yml fell back to OrangeCat's key for the Telegram gateway's
  image and video reading. No fallback: with no key of its own, media
  understanding stays off.

Keys already copied on the box stop mattering when the platform key is
replaced; the new key is never copied anywhere.

scripts/test/chat-chain.ts pins all three.

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

* fix(builder): stop-idle stops only sessions whose project has no open run

Bytes are not the signal: on 2026-11-12 eight sealed sessions at their
prompt each relayed 3 to 10 KB a minute through podman, so a 512-byte line
would have stopped none, and an agent waiting on CI prints nothing at all.
A session whose project (or lane) has no open run in Loki's database is
between tasks; one that does is kept, and so is any session under fifteen
minutes old. between_tasks is pinned by test-sealed-builds-memory.sh.

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

* fix(builder): between_tasks reads its list without a pipe into grep -q

scripts/test/no-grep-q-in-a-pipe.ts: grep -q exits at the first match and
can cut off the writer. A here-string has no writer.

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

* docs(handoff): the box recovered; spend caps; the owner's key steps

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 16:39:19 +01:00
CatoandClaude Fable 5.2 54a7024cdc fix(queue, runs, chat, ops): an idle run is closed before the next task starts; a blocked pull request is said in the thread; an address to Loki is not the loki project; the builder can be given a memory ceiling (#1678)
* fix(check): the on-demand loop check signs in on the box, and is red when it cannot ask

The first run of loki-loop-check.yml (2026-11-12, run 43188095136) printed
"down: loki e2e could not mint a session on the box" two seconds in, and
the job was green. Three things were wrong:

- The deploy ships the runner a fixed list of scripts and nothing under
  scripts/test, so on the box there was no test to run and no token
  script. The workflow now carries the check's own files with it.
- The check minted an Auth.js session cookie. Sign-in moved to AccountKit
  on 2026-11-01, where that cookie is no session. It now signs in the way
  a runner does: scripts/test/mint-check-token.ts mints an agent token for
  the operator that expires in two hours, the check uses it as a bearer
  and removes it on exit. The cookie mint stays as the fallback.
- A check that could not sign in exited 0. With the verdict asked for, it
  exits 1, and it says why (long strings masked).

scripts/test/loop-check-signs-in.ts pins all of it.

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

* docs(handoff): what production showed after the first fix, and why the check could not sign in

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

* fix(check): the loop check prints Loki's own reason for a task that does not start

Its first full run on the live site (2026-11-12, run 43191224470) ended
"still queued (Queued) after 35 min" and then guessed at the builder's
sign-in. The run route already answers the track's sentence for an open
run (detail), and the chat's reply says where the task went: the check
prints both, right after the dispatch and again when it gives up.

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

* docs(handoff): the first full check on the live site, 4 of 5

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

* docs(handoff): why the probe did not start, in Loki's own words

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

* fix(chat): an address to Loki is not the loki project; the loop check reaches the project it was sent to

A project named in a message outranks the selected project, on purpose
(lib/loki-fleet-commands). The assistant is called Loki and so is one of
the projects, so "Loki, add a dark mode toggle" typed with orangecat
selected was sent to the loki project.

Found through the loop check on the live site (2026-11-12, run
43198552471): asked for project orangecat, it came back "Sent loki to the
cloud runner", because its marker was "[loki-e2e]". Three runs in a row
had waited behind the loki project's open run while reporting on a
project the probe never reached.

- project-mention: withoutAddressTo removes an address to the assistant
  before matching: the name at the start followed by punctuation, after a
  greeting, "@loki", or set off by a comma at the end. "Loki's sidebar",
  "in loki" and a bare "Loki fix the header" still name the project.
- loki-loop-e2e: the marker is "[e2e-probe]" and names no project, and the
  check fails at once when Loki dispatched to another project than the
  one it asked for.

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

* docs(handoff): the probe had been going to the loki project; the routing fix

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

* fix(queue): a run that has gone silent gives its project to the waiting message

A project's shared session takes one message at a time: the claim gate holds
the next one until the run ahead has closed. A run closes when its agent
reports. An agent that ended its turn without reporting still has a process
at its prompt, and the reaper shelters a run with a live process for up to
MAX_RUN_HOURS, so the next message could wait twelve hours behind a session
that was doing nothing. On the live site (2026-11-12) messages sent through
Loki's chat read "This project is still on an earlier task" and were still
queued 25 to 35 minutes later.

- lib/orchestration/quiet-lane: the rule, pure. The runner beats while the
  terminal prints and while the agent waits at a sign-in or an approval. No
  beat for 20 minutes (twice the window after which every surface says
  Stalled), not waiting for a person, no command outstanding, and still so
  90 seconds after it was first seen: release. The second look covers a
  runner that could not beat for a while and whose first request back is
  the claim.
- db/queries/quiet-lane: reads those facts for the run at the head of each
  lane a message waits in, through olderOpenRunSql, and closes it with the
  reaper's own verdict (partial with the handoff note, else timeout with the
  sentence), ended at its last beat. No escalation.
- claimNextPendingCommand calls it before the gate, so the message is
  claimed in the request that closed the run.
- The waiting sentence carries the bound.

A working agent prints, so its beat is seconds old at any age and it keeps
its lane. Nothing is closed when nobody is waiting.

scripts/test/quiet-lane.ts, and five scenarios in
scripts/test/lane-and-reaper.ts against a real Postgres (13 of 13 locally).

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

* fix(runs): a pull request that cannot merge is said in the thread, with the message that repairs it

The fleet's sweep merges a green pull request and leaves a red or conflicted
one waiting. A task sent from the chat that ended at such a pull request read
"done, it merges on its own" until somebody opened GitHub.

- feedback/fix-shipping: PrBlocker, prBlockerFor (a conflict when GitHub says
  mergeable: false, else the names of the checks that failed; cancelled and
  still-running are not failures), prBlockerNews (once per commit and reason).
- feedback/fix-shipping-refresh: readBlockers on the refresh input; only then
  are the head commit's check runs and statuses read.
- run-follow-notify: the fifteen-minute follower asks, and on news writes one
  line into the thread the task came from and sends one push. The line ends
  with the message to send ("<project>: fix the failing checks on <pull
  request> and push to the same branch."): a message naming a project is a
  task for it.
- Loki does not send the repair itself: no agent run nobody asked for
  (lib/auto-dispatch).

scripts/test/run-follow-notify.ts.

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

* docs(handoff): the 11:17 rehearsal failed on a slow box: sign-up 504, 96% memory, a 503 window

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

* docs(handoff): bots do not answer on the live site (502, 11:39 UTC); OrangeCat #1672; #1678 green

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

* fix(queue): only a run whose runner has reported output can be read as having stopped

A runner from before the beat existed reports nothing while its agent works.
Silence since delivery would have closed such a run after twenty minutes and
typed the waiting message into a working session. A run that has never
beaten now keeps its lane; one that truly never printed is the reaper's,
which closes it as never started from the runner's own unverified ack.

scripts/test/quiet-lane.ts, and a sixth scenario in
scripts/test/lane-and-reaper.ts (14 of 14 locally).

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

* fix(ops): the box usage report prints the builder's memory budget and finishes on a slow box

On 2026-11-12 the box had 0.6 GiB available and no swap left, and the report
was cancelled at its 20-minute limit inside the first du. Each disk walk now
gets a minute. A new section prints what the runner unit holds, whether it
has a memory ceiling, and which cgroup the sandboxes' processes are in:
sandbox.ts relies on the unit's MemoryMax to bound sealed sessions.

Read-only, names and sizes only.

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

* docs(handoff): what holds the box's memory, measured; the builder has no ceiling

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

* fix(queue): an idle run is closed before the next task starts; the runner's six-hour stop and a turn answered in seconds are read correctly

Three faults in the idle rule (#1680), found by an independent review and
shown failing first in scripts/test/lane-and-reaper.ts against main (13
passed, 4 failed; 17 of 17 after):

- An idle run stopped holding its project but stayed open until the hourly
  reaper. The next task went into the same session, and its ready handoff
  closes every delivered open run of the project, so the idle run was
  recorded as done with the other run's summary. The claim now closes the
  idle run first, with the reaper's own function and sentence, and only when
  a task is waiting in that project (db/queries/idle-run-close).
- The runner stops beating six hours into a run. Half an hour later the run
  read as idle while it printed, and the next prompt went into a working
  session. A last working beat at that horizon is not read as silence
  (RUN_PROGRESS_HORIZON_SECONDS).
- A turn that ended before the runner began reporting on it never had a
  working beat, read as unknown and held its project for up to twelve hours.
  Every beat stamps lastBeatAt; a run the runner reports on that has printed
  no work since delivery is idle after the same half hour. A run with no
  beat of any size keeps its lane, as before.

scripts/test/idle-run-release.ts, scripts/test/lane-and-reaper.ts.

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

* fix(ops): the box usage report can be asked for memory alone

The disk walks took the whole 20 minutes twice on 2026-11-12, on a box that
was swapping, when only the memory was wanted. what=memory stops after the
memory sections.

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

* feat(ops): the builder can be given a memory ceiling, read and set from the Sealed builds workflow

Measured on the box, 2026-11-12 12:19 UTC: loki-box-runner.service held 6.3
GiB with MemoryHigh and MemoryMax at infinity, every sandbox process is in
that unit's cgroup, the box had no swap left, and the kernel had stopped 30
processes for memory since boot: the gateway 15 times, a live site 3 times,
a sandbox 3 times. Every site unit has a 1G ceiling; the builder had none,
though sandbox.ts relies on the unit's MemoryMax to bound sealed sessions.

sealed-builds-ctl.sh gains three modes, run from sealed-builds.yml:
- memory: read. What the builder holds, what bounds it, what the box has left.
- memory-set, runs="<GiB>": MemoryMax and MemoryHigh one below it, and the
  builder's processes are marked to give first when the whole box runs out.
  Refused when the ceiling is below what the builder holds now, because that
  stops sessions at once; "force" after the number sets it anyway. Nothing
  is restarted.
- memory-clear: undo.

Nothing is set by a deploy. It is a decision, applied by a person.

scripts/hetzner/test-sealed-builds-memory.sh, in test:ops.

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

* fix(runs, chat): the blocked pull request notice is said once and its repair reaches the right project; an address to Loki is set off, and is the project when nothing else is

From the independent review of this branch, each finding confirmed by a
second agent told to refute it.

The notice:
- It would have repeated every tick. "Already said" lived in the ledger, the
  ledger is rebuilt on every refresh, and the dispatch card's own refresh
  does not read blockers. It is kept beside the ledger now
  (payload.prBlockerSaid, per reason), written once the line is in the thread.
- Its repair line named the pull request by link. The link carries the
  repository owner's name, and a project of that name won the match: the
  repair for loki went to Bitbaum. The line names the number, opens with
  "In <project>," and uses a verb the chat's own rule takes as a task, for a
  conflict as well. The test sends it through projectMentionedIn and
  looksLikeDispatchTask for four projects and both reasons.
- action_required and stale count as failed: neither turns green by waiting.

The address:
- "ok loki is broken, fix its header", "loki-loop-check is red" and "run the
  tests on @loki" lost the project; "Loki - add a toggle" kept it. An address
  is the name set off from the sentence (a comma, a colon, any dash with
  space around it, "please", "can you"), at the start of any sentence.
- "loki: fix the header" is read as an address, so a selected project gets
  the work; with nothing selected and no other project named, the name is
  the project (projectNamedByAddress, the last resort of both paths).

scripts/test/run-follow-notify.ts, scripts/test/project-mention.ts (114).

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

* fix(ops): the builder's ceiling is a ceiling only; docs(handoff): the box's memory, the review's findings, what is ready and not applied

memory-set no longer sets MemoryHigh one below the ceiling: at the moment it
is set the builder holds close to the ceiling, and a mark under what it holds
would slow every session at once.

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

* docs(handoff): the box's memory now holds up OrangeCat merges: Browser smoke is red on main

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 14:09:49 +01:00
CatoandClaude Fable 5.2 7718294354 fix(builder, composer): a silent sealed session no longer holds a runner update; the composer falls back to the cloud runner (#1676)
* fix(builder): a sealed session that has been silent for half an hour no longer holds a runner update

The drain restarts the box runner only when no agent is working. A sealed
session has no status file the drain can read: its agent lives inside
gVisor and the unit's cgroup holds only the `podman run` that relays its
terminal, so it counted as working for as long as it was open, and
sessions stay open for days.

Measured on the box, 2026-11-12 07:56 UTC (Sealed builds run 43178274733,
mode=activity): three open sealed sessions, one of them eighteen hours
old, relayed 0, 40 and 96 bytes in a minute while the drain logged
"3 agent(s) working — deferring restart" on every look. The runner stayed
two releases behind for hours, so the runner fixes merged that morning
were not running, and the commands route held new work for the restart.

- agent_is_busy: a sealed session that has relayed under 512 bytes a look
  for 30 minutes is not working. Shorter than that, or a quiet that
  cannot be told, still is: unknown is not idle.
- quiet_for reads the relay's cumulative byte counters and keeps its note
  under /run/loki-drain/<unit>, outside the drain's own process: every
  deploy starts a new drain, and a clock that restarted with it would
  never reach thirty minutes on a box that deploys several times an hour.
- The rule is the sealed session's alone. An unsealed agent that is not
  Claude still always holds the restart: its output was not measured.

What it can cost: a sealed agent stopped at a permission prompt in the
middle of a task prints nothing, so after thirty minutes of that the
restart goes ahead; the session reopens and its open run is closed.

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

* fix(composer): the project composer falls back to the cloud runner when the project's own builder is off

The chat reroutes a project pinned to an offline computer to the cloud
runner and says so (inject-core). The project composer for an idle project
(/api/control/tab-inject) asked for the routing decision without that
fallback: a project registered from a laptop queued for the laptop while it
was shut, with the laptop's folder as the place to start, and the answer
named no builder. The row sat until the reaper closed it an hour later.

- tab-inject passes the project's offline fallback, starts a rerouted
  dispatch in the folder the cloud runner clones into, and answers with the
  builder that took it and the reroute sentence.
- execution-access test pins the three.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 10:23:40 +01:00
CatoandClaude Fable 5.2 64e2c6b543 fix(builder, runs): a held task waits minutes and says so; a build says when it is live (#1663)
* docs(handoff): checkpoint for building with Loki and with a Cat bot

The objective, the two journeys that count as done, how production can be
reached from an agent session, and the state when the work began.

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

* docs(handoff): what the investigation found, and what it did not reach

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

* fix(builder): a task held for the runner's update waits minutes, not for ever, and says so

While the cloud runner is behind the deploy the commands route hands it no
work-starting command, so the idle moment its restart waits for comes. The
hold had no end, and on 2026-11-12 the restart did not come: two runner
releases landed 35 minutes apart, the drain read "5 agent(s) working" on
every look for an hour, and the builder claimed screen peeks and nothing
else (Sealed builds run 43165605499). Every task a person sent sat queued
while the chat said a runner would claim it shortly.

- runner-update-hold: a held command is handed over once it has waited
  five minutes, and the hold applies only within two hours of the newest
  runner release. Running on last week's runner is recoverable; a task
  that never starts is not.
- claimNextPendingCommand takes the overdue rule. While holding, an empty
  at-once list claims nothing (it used to claim everything).
- The person is told why and for how long: in the chat reply, in the
  /api/inject answer (builderUpdating, message) and as the run track's
  headline while the job is unclaimed.
- loki-loop-check.yml: the end-to-end check of the live site on demand,
  with an optional real no-change task that must come back into its
  thread. loki-e2e-check.sh --report takes the project, the wait and the
  dispatch choice from its caller.
- sealed-builds.yml mode=activity: read-only, what each agent process of
  the runner read and wrote over a minute, so the drain's "working" can be
  measured for sessions it cannot read a status for.
- pre-push: the watchdog's sleep no longer holds the caller's output open
  for fifteen minutes after the push has landed.

Server and box scripts only: no runner code, no runner version.

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

* fix(runs): a build tells the truth after the agent finishes, and says when it is live

A task sent from the chat ended at "done, pull request opened". What it
said next was wrong in several ways, and the one thing a person waits for,
that it went live, was said to nobody.

- The "done" message reads the pull request the runner itself reported
  (payload.prUrl from closeRunShipped, read by nothing until now) and asks
  GitHub with the token that can read the repository. The person's own
  OAuth token is refused on the organisation's repositories, so a run that
  shipped could be posted as "No pull request or push was found". The
  reaper's evidence lookup asks the same way.
- "Live" is read from the site: a merged change is live when the commit in
  the site's /.well-known/fleet-release.json is the merge or comes after
  it (feedback/served-release). Workflow-run labels are wrong on this
  fleet: a Deploy run is labelled with main's tip at its start, a batched
  merge has no Deploy run of its own, and OrangeCat's deploy is named CD.
  It only upgrades; with no receipt the workflow-run verdict stands.
- A chat build is followed to live on the fifteen-minute cron that already
  follows feedback fixes (run-follow-notify): on the change to live, or to
  a failed deploy, one line in the thread the task came from and one push.
  GitHub and the release receipt only, no model. Old news is not announced.
- A task that waits behind the project's earlier run says so in the chat,
  the /api/inject answer (queuedBehind, message) and the track, instead of
  "will claim it shortly".
- Isolated runs ship through a pull request: worktreePromptNote told every
  lane and one-off session to push straight to main.
- The close message no longer prints "Live: <address>" beside a pull
  request that has not merged.

Server only, plus one prompt line the runner reads at its next start. No
file under desktop/, no runner version.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 09:48:29 +01:00
CatoandClaude 8d2101068a chore(crons): call Solon's Places import hourly (#1656)
The route no longer does the work inside the request: it starts a worker
that drains the queue of sources its run log says are behind, and answers
at once (solon src/lib/places/importer/queue.ts). Called hourly, a publisher
that was down is tried again the same day, and a day with hundreds of
sources due no longer needs one request longer than the runner's 300 s.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 08:40:50 +01:00
Cato 51c6e238dc ops(box): see who holds Postgres connections, reap idle ones on request (#1651)
* ops(box): read who holds Postgres connections, and reap idle ones on request

* ops(box): reap also caps idle loki sessions at 15 minutes
2026-11-12 08:03:07 +01:00
Cato 0d8a06f099 ops(hetzner): check and repair a corrupt grubenv from a workflow, dry run first (#1636) 2026-11-12 05:14:12 +01:00
CatoandClaude ddd57fe562 fix(builder): sealed agents start after a reboot; the cloud builder caps open agent sessions (#1634)
* fix(runner): the cloud builder keeps at most eight agent sessions open

On 2026-11-11 the box had 27 agent CLIs open, about 0.4 GB each, beside 21
live sites on 16 GB. Memory ran out and every site went down. Plain shells
were capped at three; agent sessions were not capped at all.

- lib/agent-session-limit: eight by default (LOKI_AGENT_MAX_OPEN changes
  it), cloud builder only, shells not counted, re-opening an open tab is
  never refused
- /api/agent/launch refuses the ninth with a sentence that says to close
  one; Resume and New session already show that error
- launchAgentPty refuses it again: every way in ends there (launch,
  dispatch, switch, tabs restored after a restart) and the server's count
  can be one heartbeat old

Idle sessions are still not closed by themselves.

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

* fix(builder): sealed agents start again after a reboot; runner 0.8.64

After the power reset of 2026-11-11 every sealed agent failed with 'the
container failed to start: it exited before printing anything'. podman keeps
its runtime state under the runner's $HOME/.run, a real directory, so the
state outlived the reboot and podman refused every container ('current
system boot ID differs from cached boot ID').

- the sealed drop-in gets an ExecStartPre that removes that state when it
  was written before this boot, and leaves it alone otherwise
- sealed-builds.yml mode reset-runtime does the same by hand for a runner
  that is already up
- desktop/package.json 0.8.64 with its release note: the session limit
  changed the runner

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 14:39:00 +01:00
CatoandClaude c403e23fb2 ops(hetzner): the disk cleanup reaches what actually fills the box (#1631)
Its first complete run (2026-11-11, dry) would have freed nothing: every
app was already at two releases and the 127G in use was elsewhere. Six
tiers written from that day's usage report, each dry-run first:

- container logs over 200M are truncated (one was 2.2G), syslog rotated
- /opt/<app>/app-prev-* copies older than 14 days (kivvi kept seven from
  July), never the live app or the rollback target
- superseded browser downloads under ~/.cache: the newest of each is kept
- superseded agent CLI versions: the two newest are kept
- pnpm store prune
- node_modules and build output inside checkouts and agent worktrees idle
  for 14 days and not in use; source is never touched

The target percentage is an input (default 75). Database dumps and
Solon's 17G of places-snapshots are deliberately not here.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 13:07:04 +01:00
CatoandClaude 1d44192e3a ops(hetzner): the usage report looks one level into the large directories (#1630)
* ops(hetzner): the usage report looks one level into the large directories

The first report (2026-11-11) named what was large and not why: /opt/solon
at 18G with two releases, 22G of caches under /home/ubuntu, 16G of
checkouts. The cleanup's dry run then showed it would free nothing, since
none of that is in the places it prunes.

The report now lists the largest entries inside each of those directories,
counts node_modules and build output inside checkouts, and names files
over 500M. Each listing has a time budget. Still read-only.

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

* ops(hetzner): the usage report measures databases and their dumps

Solon keeps place photographs as bytes in Postgres, and every database is
dumped nightly and kept 14 days. Neither shows in a du of /opt or /home,
and the first report did not look at /var/lib/postgresql at all. It now
prints the size of each database, the five largest tables of the three
largest (names and sizes only), and the dumps' total per database.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 12:24:53 +01:00
CatoandClaude cf7b404820 fix(ux): signed in means the app; a task shows what was asked; sessions lead with what needs you; key names for OrangeCat (#1629)
* design: Loki has no orange; the public call to action is the achromatic accent

The app's own buttons went monochrome on 2026-10-19; the public site kept
a warm orange (#ff5c00) on Start a project, Get started, the auth submit,
the focus ring and the essay progress bar. It is not Bitcoin orange and it
means nothing on a product that is not about Bitcoin (owner, 2026-11-11).

- --accent-warm, --accent-warm-hover and --public-accent are removed; every
  class that used them reads --accent-primary / --accent-hover, so one
  filled button exists in Loki and it is theme-aware
- --on-accent is the inverted text. It was a fixed near-black, which on the
  near-black light-theme accent left .ui-btn-xs.ui-btn-primary unreadable
- the focus ring and the public glow are neutral
- token-drift declares the divergence from @bitbaum/design-tokens; the
  widget theme is regenerated from the tokens

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

* fix(workbench): a failed task says why and gives the words back

Sent an OrangeCat task from the workbench on 2026-11-11. Claude was signed
out on the cloud runner; the status API said so with the fix, and the
composer showed the two words 'Dispatch failed' over an emptied box.

- dispatchFailureForPerson: a signed-out agent is named in the sender's
  words; any other reason is passed through instead of dropped
- the composer shows that reason under the label and offers 'Put my words
  back', since the box is cleared on send

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

* fix(nav): the phone's chat screen names Home, Projects and Terminal

The owner, signed in on a phone on 2026-11-11, could not find the terminal.
The chat is the default screen and hides the tab bar; its left button opened
a list of chats and nothing else, and its menu offered 'Projects' (which
only set the chat's project) and 'Everything else'. The page itself was
called Sessions, so no menu contained the word.

- CHAT_PLACES (config/navigation.ts) is one list of Home, Projects, Terminal
- the chat menu lists them by name, then 'All pages'; the item that sets
  the chat's project says so
- the chats panel the left button opens lists the same three, phones only
- the page is called Terminal in the nav, its title and its links

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

* fix(sessions): a signed-out Claude is one button in the chat view

A session opens in its Chat view. When Claude's login had expired, that view
showed the agent's own line, 'Please run /login', and reply chips that would
fail the same way; the 'Sign in /login' button existed only in the Terminal
view. The owner, on a phone, could not find how to sign in (2026-11-11).

The chat view reads the reply through the same detector as the terminal
(screenActions) and offers 'Sign Claude in', which types /login and switches
to the terminal where the link is printed.

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

* fix(ux): signed in means the app, and a retried task shows what was asked

Two more things the owner met on a phone on 2026-11-11.

- Opening loki.orangecat.ch while signed in showed the marketing page and
  its marketing menu; the way in was a button. A signed-in visitor now lands
  in the app (APP_HOME; RUNNER_HOME inside Fleet Runner). ?site still opens
  the homepage on purpose, and signed-out visitors are unchanged.
- A retried dispatch opens with the escalation block, longer than the 200
  characters isOperatorEnvelope read, so the whole packet ('Escalation
  state … rung 3/4', 'Exit contract') was drawn as the person's message. It
  is recognised now; the bubble shows the task, the packet is one tap away.

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

* feat(orangecat): tell OrangeCat which provider keys a person holds here, by name

The owner's xAI key was on Loki and not on OrangeCat: for the same linked
person Loki's chat answered on grok while OrangeCat's Cat sat on an
exhausted free pool, and neither product could say the other had a key.

The signed actor-status reply now carries modelKeys: vendor, model and the
last-characters hint, one per vendor, never a custom endpoint and never a
key. OrangeCat uses it to suggest adding the same key there.

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

* fix(sessions): the phone's session list leads with what needs you

The picker listed every open session in the order it was opened: 27 rows,
'Loki 2' to 'Loki 15', with the three waiting on the owner somewhere among
them (2026-11-11). orderSessions puts waiting, working and finished
sessions first, with the one in use, and folds the merely-open ones behind
one row, 'N more open sessions'.

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

* ops(hetzner): a read-only report of what uses the box's memory and disk

On 2026-11-11 the box sat at 91-95% memory and 91-93% disk; both sites
reset connections and CI could not sign in against production auth, and
nothing could say what was using either. disk-cleanup.sh reclaims disk;
nothing measured memory.

box-usage.yml runs scripts/hetzner/box-usage.sh over the same SSH setup as
box-doctor. It prints memory by program (names only, never a command
line), agent CLI and browser counts, out-of-memory kills, container
memory, and the largest directories, and changes nothing.

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

* fix(ops): the disk cleanup measures within a budget, so it reaches its plan

Its first run (2026-11-11, dry) was cancelled at 30 minutes having printed
four sizes and planned nothing: du on /opt alone took 14 minutes on a disk
full of node_modules, and the script measures every release before it
plans a single tier. Sizes are for the reader; what was freed is read from
df. Each size now gets 45 seconds and prints 'over 45s' instead of waiting.
The inventory also names /home/ubuntu and the agent directories under it,
which the first run never reached. Workflow limit raised to 60 minutes.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 10:38:32 +01:00
Cato 7909050674 ops(hetzner): add a dry-run-first box disk cleanup workflow (#1623)
The bitbaum root disk is over 90%. This adds a workflow_dispatch job,
defaulting to dry_run=true, that SSHes with the existing deploy key and
reclaims reconstructible space only: journals, apt and npm caches, release
dirs beyond current+previous, unused Docker images and build cache, old
rotated logs, and Postgres dumps older than 14 days. It never touches
volumes, databases, running containers, shared env, or the live/previous
release. It also reports and, when the unit already exists, re-enables
disk-gc.timer and pg-backup.timer if they were simply disabled.
2026-11-10 12:21:24 +01:00
Cato 57f9cfe467 ci-gate: count only push and pull-request runs as CI, so the sweep cannot hold deploys (#1618)
The auto-merge sweep (event workflow_run) runs on main's SHA every time any
pull request's CI finishes. The gate counted it as CI, so a deploy waited at
PENDING until the sweep went quiet: solon's #484 had CI green at 09:24 UTC on
2026-11-10 and its deploy only passed the gate at 09:36, and every merge in
the queue waited behind that. A chained data job (places-data) failing would
also have blocked a deploy, the same class as the 2026-11-01 data-load bug.

The event test becomes an allowlist (push, pull_request, pull_request_target,
merge_group), matching the rule the comment already states. Four new cases in
test-ci-gate.sh; 22 pass.
2026-11-10 11:26:32 +01:00
Cato 5cc51575f0 fix(box-env-keys): refuse GITHUB_-prefixed secret names (#1615)
GitHub Actions reserves the GITHUB_ prefix and will not store a secret
under such a name, so a names list that includes one can never work.
The shared script and reusable workflow now fail with a clear message.
The fixture in the tests uses GH_CLIENT_ID, matching Morulia.
2026-11-10 08:48:49 +01:00
CatoandClaude Opus 5.5 fc73653347 fix(ops): the OOM killer no longer picks the user manager itself as its victim (#1609)
user@1000 failed three times on 2026-11-08 with "Main process exited,
code=killed, status=9/KILL": the kernel killed systemd --user itself, which
OOMPolicy=continue (#1606) cannot survive. Upstream user@.service ships
OOMScoreAdjust=100, which makes the ~10 MB manager outrank most real memory
hogs. The drop-in now sets OOMScoreAdjust=0 so the manager is ranked by its
real size and the OOM killer goes after the process using the memory.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:32:47 +00:00
CatoandClaude Opus 5.5 dfb69d33bc fix(alerts): the failed-unit sweep clears a failed unit whose file is gone instead of paging it (#1607)
signin-wake.service failed on 2026-10-31. Its unit files were deleted when
signin went live and was later retired, but nothing ran reset-failed, so
systemd kept it as LOAD=not-found / failed. host-check's sweep paged it and
dispatched a fix agent every day from 2026-11-05 to 2026-11-08, each time
with an empty journal. #1603 stops the live switch from leaving new ghosts
behind. This clears the existing one, and any later one, with no hand on
the box.

The sweep now runs reset-failed on failed services whose LOAD column is
not-found, writes one journal line for each, and leaves them out of the
paged set. Nothing can start such a unit again, so there is nothing to fix.
A deleted unit file that a live site needs is still caught: the watchdog
probes the site itself.

install-box-alerts.yml installs this on merge (it watches this file).
test-host-alerts.sh: four new checks (a ghost is cleared and never paged
or tracked, and a real failure beside it still pages and is not cleared);
110 passed.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 06:30:35 +00:00
CatoandClaude Opus 5.5 4e5a5725a0 fix(ops): an OOM kill no longer takes down the ubuntu user manager (#1606)
* fix(rag): the embed server drops work nobody is waiting for, so one slow page cannot fail the reindex

The 2026-11-07 03:30 loki-reindex ran 15 minutes of "[embeddings] failed: The
operation was aborted due to timeout" and was killed by TimeoutStartSec. The
first user got 384/637 chunks, the second 0/632, with 3.9s of client CPU.

#1594 serialized inference behind one lock. The client aborts a page after
30s, but the server kept computing the abandoned page under the lock, so the
next page queued behind dead work, timed out too and left its own behind.
After the first slow page every page failed.

- embed-server.py checks whether the caller is still connected when it takes
  the lock and between batches, drops the work if not, and logs the drop.
- embeddings.ts pages at 16, the server's own batch, instead of 48: a third
  of the time per request against the same 30s timeout, and a third of the
  wait for a live caller queued behind the reindex.
- scripts/test/embed-server-drops-abandoned.ts runs the real server.py on a
  slow stub model. Against the old server the next caller waited 1761ms
  behind abandoned work; now it does not.

Every deploy syncs server.py and restarts loki-embed when it changed (#1595).

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

* fix(ops): an OOM kill no longer takes down the ubuntu user manager

user@1000.service (the ubuntu account's systemd manager on bitbaum) failed
with "The kernel OOM killer killed some processes in this unit" followed by
"Failed with result 'signal'", and paged as a failed unit. It is the same
failure #1601 fixed for the openclaw manager (user@1001): systemd's default
OOMPolicy=stop stops the whole manager when the kernel kills any one process
inside it.

The deploy step from #1601 now installs the same OOMPolicy=continue drop-in
for both the openclaw and the ubuntu managers. It still writes only the
drop-in and runs daemon-reload (only when a file changed), restarts nothing,
skips users that do not exist, and warns without failing the deploy. The conf
and its guard test drop the openclaw- prefix, since they now cover both; the
test fails if ubuntu leaves the list.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 06:20:43 +00:00
CatoandClaude Opus 5.5 804d0a2919 fix(hetzner): a site that goes live leaves no failed wake unit behind (#1603)
sync-infra's live branch stopped <app>-wake.service and deleted its unit
files, but stopping a failed unit does not clear its failed state. systemd
then keeps it as a not-found, failed unit that nothing ever starts again,
and host-check's failed-unit sweep reports it as still failing.

signin-wake.service failed on 2026-10-31 (Result: resources, #1491). signin
went live minutes later (#1490). On 2026-11-01 an older retire-site.sh that
did not yet know about wake units retired signin. The ghost unit was still
dispatching an incident on 2026-11-05.

The live branch now runs reset-failed on both wake units before it removes
their files. retire-site.sh --mode delete already does the same.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 06:18:40 +00:00
CatoandClaude Opus 5.5 33cfe39459 fix(ops): an OOM kill no longer takes down the openclaw user manager (#1601)
2026-11-05 07:10 UTC the box ran out of RAM. The kernel OOM-killed
openclaw-gateway (797.5M peak), then its restarts and the user's dbus.
systemd's default OOMPolicy=stop then stopped user@1001.service, the
openclaw user's manager and the only thing that restarts the gateway, so
WhatsApp and the Telegram chat stayed down for more than a day.

Ship a drop-in, user@<openclaw uid>.service.d/10-oom-continue.conf, with
OOMPolicy=continue (same lesson as loki-box-runner, 2026-09-25). Every
deploy installs it with daemon-reload only. It restarts nothing, warns on
failure, and is skipped where there is no openclaw user.
openclaw-gateway-up.sh and doctor-messaging.sh report whether it is in
place. The doctor now asks systemd for the manager's state instead of
trusting the bus socket, which outlives a dead manager.
scripts/test/openclaw-survives-oom.ts guards both halves.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 20:26:46 +01:00
Cato 31d82135f5 fix(ops): do not fail app crons when CRON_SECRET is absent (#1598)
grep exits 1 when the key is missing, and set -e aborted the shared
runner before curl. A daily job whose app does not use the secret
(botsmann /api/rebuild) then paged as status=1 with no HTTP line.
2026-11-06 10:40:15 +01:00
CatoandClaude Opus 5.5 7fddc81f46 fix(deploy): every deploy ships the embed server, so #1594 reaches the box (#1595)
The memory bound from #1594 merged and changed nothing on the box: server.py
and the loki-embed unit were written only by install-fleet-rag.sh, which needs
a laptop's ssh key (and this morning the laptop's agent could not sign). The
unit lived as a heredoc inside that installer, so the deploy had nothing to
ship.

Move the unit to scripts/hetzner/loki-embed.service, have the installer copy
it, and have deploy-hetzner.sh content-sync server.py + the unit, restarting
loki-embed (and waiting on /health) only when one changed. Warn-only, skipped
where the install never ran. scripts/test/deploy-ships-embed.ts guards both
halves.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 07:05:57 +01:00
CatoandClaude Opus 5.5 66e1d48fd2 fix(rag): bound the embed server's memory so a reindex cannot starve the box (#1594)
* fix(rag): bound the embed server's memory so a reindex cannot starve the box

The 03:30 loki-reindex drove loki-embed (ThreadingHTTPServer, one onnxruntime
run per concurrent request, arena never returned) to 2GB, filled swap, and
pushed load to 53. Postgres connects timed out, so six other apps' crons
failed — sbb-fundbuero purge among them — until the OOM killer took the
embed process at 03:33:05.

Serialize inference behind a lock with a small batch size, and give the unit
MemoryHigh/MemoryMax so the kernel reclaims or kills this process alone.

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

* fix(test): box-register-follow fixture no longer commits into the real repo

Under the husky pre-push hook the inherited GIT_DIR turned the suite's
`git init` into the pushing checkout: commits "one"/"two" landed on the
branch (emptying its tree) and core.bare=true reached the shared .git/config,
breaking the main checkout. Source git-fixture-env.sh like its siblings, and
add test-git-fixtures-isolated.sh to test:ops so a new fixture suite that
skips it fails instead of becoming the fourth incident.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 05:25:21 +01:00
CatoandClaude Opus 5.5 8454c0acaa fix(ops): cron installer prunes timers for retired jobs (#1593)
fc-cron@nudge-idle kept failing with HTTP 404 every night: the route was
retired on 2026-10-10 (replaced by autopilot-night), but
install-hetzner-crons.sh only ever wrote and enabled timers, so the old
timer stayed on the box calling a route that no longer exists.

The installer now treats SCHED as the whole list: any fc-cron@*.timer on
the box whose name is not in SCHED is disabled, deleted, and its service's
failed state reset. The deploy already re-runs the installer, so the merge
clears the nudge-idle unit with no hand step. test-cron-runner.sh covers
the prune against a stubbed systemctl.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 17:22:08 +01:00
CatoandClaude Opus 5.5 c9bec3c028 fix(deploy): ship widget/ to the box-runner so loki-reindex can load its imports (#1592)
loki-reindex.service died on MODULE_NOT_FOUND: scripts/reindex-knowledge.ts
reaches src/lib/feedback/tour-token.ts, which imports widget/tour (since
#1534), but deploy-hetzner.sh and install-box-runner.sh never rsynced widget/
into /opt/loki/runner. Ship widget/ alongside src/ and chown it.

scripts/test/runner-ships-imports.ts walks the static import graph from every
runner entrypoint the deploy ships and fails if any reached file is not
covered by a sync_runner line — it reproduces this incident on the old deploy.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 14:49:25 +00:00
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 c03cecbcfe feat(ops): delete-synthetic-user workflow for OrangeCat's auth server (#1581)
A live check that dies halfway leaves its throwaway account behind, and only
GoTrue's admin API can remove it (orangecat#1533 left one). The workflow finds
the user by an exact match of the email, deletes it with
DELETE /auth/v1/admin/users/<id> using the service-role key already on the box,
and reads the lookup back. Only example.com, example.test and .invalid
addresses are accepted, a second match is never guessed between, and no key is
printed. Tested against a fake admin API in test:ops.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-03 03:24:14 +01:00
CatoandClaude 32af8519e2 fix(ops): lightning-on finds a monorepo release's receipt (#1580)
kivvi serves apps/web from its release, so its receipt is under
app/apps/web/public, and lightning-on said "no AccountKit in its release".
The receipt is now looked for up to five levels into the release.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-03 02:40:51 +01:00
CatoandClaude d6fdc750f9 feat(ops): lightning-off, the way back for one app (#1579)
lightning-on all reached every app whose release carries AccountKit 0.26.1+,
including three whose sign-in other work owns right now (aoz-wohnen,
botsmann, vitareba). lightning-off removes the flag from one app and restarts
it; it refuses all.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-03 01:51:37 +01:00
CatoandClaude 5aa5b318ef fix(ops): lightning-on reads a standalone release's receipt (#1578)
On the box, biaslens's release had no @bitbaum/accountkit/package.json (a
standalone build traces only the files it runs), so lightning-on said "no
AccountKit in its release". The release receipt names the locked version;
it is read first, then the package files as before.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-03 01:35:25 +01:00
CatoandClaude f387c7a66c fix(backups): an unreachable off-box target fails in minutes, not half an hour (#1575)
The first run of install-backups.yml (#1572) wrote every local dump in 45
seconds, then waited 29 minutes on restic before "restic repo unreachable",
and the job's 30-minute limit cancelled the check after it. It had already
printed all 412 files in /opt/backups/pg at mode 600, the newest dump too.

restic's reachability check now gets 120 seconds, the push an hour and the
prune half an hour, and the job 90 minutes, so a dead target is reported
quickly and the mode check always reports. The off-box target itself is
unreachable and needs its owner (Storage Box); that is not fixed here.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-03 00:59:19 +01:00
CatoandClaude 3b010a6519 feat(ops): lightning-on switches Lightning login on per app (#1573)
AccountKit 0.26.1 mounts Lightning login (LNURL-auth) only with
ACCOUNTKIT_LIGHTNING=1. app-secrets.yml action=lightning-on adds it to one
app, or with app=all to every app whose running release carries AccountKit
0.26.1 or later, and restarts it. An older copy anywhere in the release holds
an app back; a value someone set is kept; nothing is paired, there is no key.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-03 00:34:39 +01:00
CatoandClaude fe9f8dc3b6 fix(ops): the passkeys switch waits out the auth restart, and lists www (#1571)
The first apply (orangecat#1533) set the four variables and recreated the
auth container, and passkeys_enabled reads true; but the read-back ran into
the few seconds the restarting server answers 5xx, curl -f failed under set -e,
and the run reported failure. A failed read is now "not yet".

www.orangecat.ch serves the site itself (200, no redirect), so a passkey
ceremony there needs its origin listed; the RP id orangecat.ch covers it.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-03 00:08:55 +01:00
CatoandClaude Opus 5.5 42435de738 feat(ops): OrangeCat passkeys switch, a workflow for GoTrue's four variables (#1569)
* feat(ops): OrangeCat passkeys switch, a workflow for GoTrue's four variables

OrangeCat's code offers passkeys and hides them while GoTrue says
passkeys_enabled: false. GoTrue's env lives in /opt/supabase/docker, which no
workflow wrote, so the switch could only be thrown by hand (orangecat#1533).

orangecat-passkeys.yml (show / apply / rollback) sets GOTRUE_PASSKEY_ENABLED
and the relying party (orangecat.ch, OrangeCat, https://orangecat.ch) in
.env, passes them through the auth service's environment once, recreates
only that container and reads passkeys_enabled back from the public
settings. An RP id someone already set is never moved: passkeys made for it
would be stranded. Names and verdicts only in the log.

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

* fix(ops): no grep -q at the end of a pipe in the passkeys switch

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 23:43:43 +01:00
CatoandClaude 89914e6096 fix(auth): the cutover's proofs work where an address must be confirmed first (#1568)
AOZ refuses an unconfirmed address at sign-in when mail is configured
(emailConfirmation: 'before-sign-in'). Two proofs would have read that as a
failure:

- switch: the imported legacy proof account was written unconfirmed, so its
  live sign-in would be refused and the switch rolled back. It is now written
  with a confirmed address, as a claimed AOZ account has.
- prove: a fresh sign-up there waits for its mailed link instead of signing
  in. An .invalid address receives no mail, so the journey confirms the
  address as that link would, says so, and signs in.

Vitareba (no confirmation wall) is unchanged: its sign-up signs in at once.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 23:10:37 +01:00
CatoandClaude fc0712e80c feat(box): provider keys pasted in GitHub reach the box, and the shared sign-in switches itself on (#1563)
box-env-keys.yml (reusable) copies the names a caller lists from its
repository secrets into the app's env on the box (box-env-keys.sh: a value
set in GitHub wins, a name GitHub does not hold is left alone, names only
in the log), restarts the app when something changed, and with signin-on
runs app-secrets.sh signin-on all once Morulia lists a provider.

signin-on now skips an app whose AccountKit predates 0.24.0: its button
names a fixed list of providers, which may not be on.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 22:20:57 +01:00
CatoandClaude 7f13d4be0f fix(auth): the cutover's live proof expects a kept account to refuse its own deletion (#1565)
Vitareba (medical records) and AOZ (provisioned identities) create AccountKit
with accountDeletion: false, so /delete-user answers 404. prove expected 200
and would have failed on a correct deployment. It now checks the refusal with
the account and its session intact, then removes the throwaway account from
both tables itself and confirms nothing of it remains.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 22:11:12 +01:00
CatoandClaude 2eb76924d8 fix(backups): nightly dumps are written readable by root only (#1564)
The rehearsal of Vitareba's import read last night's dump and reported it as
mode 644. /opt/backups is 700, so nobody else could open it, but a dump holds
every row of a product, patients' and residents' among them, and one copied
or moved out of that directory keeps its mode. The runner now sets umask 077,
as the AccountKit cutover's own dumps already do.

It reaches the box when install-backups.sh is next run; no workflow installs it.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 22:00:29 +01: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 Opus 5.5 6e0944d620 feat(auth): the AccountKit switch for Vitareba and AOZ, with a restore-proven rehearsal (#1560)
* feat(auth): the AccountKit switch for Vitareba and AOZ, with a restore-proven rehearsal

Vitareba (patients) and AOZ (residents) keep their accounts in their own
tables, so accountkit-switch.sh's survey and proofs do not fit them, and its
rollback empties the shared tables. scripts/hetzner/accountkit-cutover.sh
serves both from the same workflow:

- survey: counts per schema (Vitareba's Google-only patients among them),
  the shared tables' counts and a 12-character digest of who may do what.
- rehearse: last night's box dump (or one made now, mode 600) restored into
  a temporary database; the product's import SQL run there with a throwaway
  legacy account, counts printed, rolled back, the database dropped. It fails
  if an imported hash differs from its source, is in a format AccountKit
  cannot read, or the proof account's imported bcrypt hash does not verify.
- switch: a fresh dump, rehearsed first; the app stopped for the import so no
  legacy write lands after it; AUTH_RUNTIME=accountkit; then, on the public
  site, the imported proof account refuses a wrong password and signs in with
  its own, and the role digest is unchanged. Any failure rolls back.
- rollback: AUTH_RUNTIME emptied and a restart. No table is emptied.
- prove: sign up, sign out, a wrong password refused, sign in, delete, with
  an .invalid account, checking no row of it remains.

Tested locally on both products' committed migration chains with synthetic
rows: survey, rehearse, and a switch whose proof fails and rolls back.

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

* test(auth): the switch check covers the cutover script and its guarantees

The workflow now offers Vitareba and AOZ and the rehearse action, served by
accountkit-cutover.sh; the check reads both registers and both action lists.
For the cutover it also refuses an unknown action and an unregistered app,
finds no TRUNCATE and nothing in rollback but emptying AUTH_RUNTIME, a dump
written 600 from its first byte, and no proof secret echoed.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 21:34:32 +01:00
CatoandClaude 6704b56636 feat(auth): GitHub signs in on AccountKit through Loki's own GitHub app (#1551)
Loki's GitHub sign-in, and the repo and workflow grant "Start a new
project" acts with, waited on the bitbaum sign-in getting provider
credentials. AccountKit 0.22 brings a product's own GitHub app across at
its existing callback: GitHub is offered again on this runtime, with
githubScopes repo and workflow; a signed-in person pressing GitHub links
it ("Connect GitHub"); a new link's token goes to Loki's accounts, where
the GitHub features read it. GitHub links made under Auth.js are recorded
in AccountKit's table (the import, and migration 0133 on the switched
box), so they sign the same person in. The deploy's provider check
expects GitHub when the box has the app.

Also: prove's real-inbox step retries mail.tm when several proofs run at
once.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 16:13:09 +01:00
CatoandClaude 0bdf3d79b4 feat(ops): prove a real password reset, and Loki's OrangeCat token (#1546)
prove now also runs a real password reset on every switched product: the
product's own forgot-password page, the mail in a real inbox (a
throwaway mail.tm address), its link, a new password set on the
product's reset page, and that password signing in. On Loki, after the
real OrangeCat sign-in, the token it left in Loki's accounts is checked
against OrangeCat's userinfo, as publish needs. Nothing printed names an
address, a link, a password or a token.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 09:21:56 +01:00