mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 15:08:38 +01:00
feat/shared-knowledge-map
58
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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>
|
||
|
|
18d34dff0a |
fix(notify): OpenClaw jobs send only what has one tap; close the review's critical/high findings (#1542)
* fix(openclaw): every scheduled job sends only what has one tap, else NO_REPLY
On 2026-11-02 the chat still carried OpenClaw's own messages that fail the
owner's test: "Invoice / Payment Alert … if credit card is on file, no
action needed", "Gateway was not running. Restarted automatically. All good
now." The scheduled jobs' prompts live only on the box, so:
- contract.md: one short block appended (between markers, replaced on each
install) to every enabled job except the day plan: send only what needs
him, each item with the ONE link that does it, never status or counts, and
reply exactly NO_REPLY when nothing passes — OpenClaw's documented silent
token, which suppresses delivery.
- The installer lists, by path only, every file on the box that calls the
Telegram API or says "restarted automatically", so the remaining sender is
found from the public log without printing anything private.
- Notices carry no machine name ("orangecat-cat · …"); the source stays on
the list row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN
* docs(telegram): register the day-plan installer (it only searches for senders)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN
* fix(notify): close the review's critical and high findings
An independent review of the messaging system found real defects; these
are the ones that lose an urgent message, send a wrong one, or wake him:
- Intrusions could be dropped: the caps held urgent notices, every SSH
password login shared one dedupe key, and /api/notify/box answered 200
when nothing was recorded, so the box never used its direct fallback.
Urgent notices skip the caps, intrusion lines are keyed on the whole line,
and the route answers 503 when an urgent line was not delivered.
- A link chosen by an email could become a trusted one-tap button. Buttons
now open only own domains, Gmail, Google Calendar, GitHub or Hetzner.
- Long titles/labels or a fourth button dropped real notices into the list;
they are clipped instead. Only a missing or unsafe action refuses.
- SSH login from a new address and edits to authorized_keys/sudoers/shadow/
PAM/ld.so.preload are intrusion signs (both lists, kept equal by test);
the button opens /today, where the notice is listed; the title names the box.
- Customers' escalations and capped goals reached the owner's chat
(selfTelegramTarget); they now use telegramTargetFor. The gateway-down
message went once per fleet account; it is sent once.
- The notify routes accept bearer tokens only (no browser session/CSRF).
- countDeliveries ignored rows older than a week; it no longer does.
- Night silence (22:00–07:00 Zurich) for the direct senders too: lib-alert's
fallback, ivy-health, fleet-uptime, deploy-hetzner. ivy-health names what
broke and offers Redeploy only when Loki's app is the failure, Box doctor
otherwise, and reads the chat id from the box's telegram.env.
- Prompts: the day plan no longer asks for approve links it cannot get or a
page it cannot open, never uses links found inside emails, and says when a
source failed. The summaries he asked for (reflection, digests, scorecard,
evening wrap) get a digest contract instead of being silenced; jobs with no
text prompt are left untouched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN
* feat(day-plan): one morning message; the email scanner twice a day
Approved by the owner 2026-11-02. The day plan now carries a half-line on
each person he meets today, and the separate 07:30 "Meeting People Brief"
is switched off. The email deadline scanner runs at 08:00 and 17:00 instead
of four times a day.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
f8da012c95 |
feat(notify): Telegram only with a one-tap action — one gateway for every bot (#1540)
* fix(alerts): stop paging on transient systemd-run units; send digests silently The 5-minute host sweep announced every failed one-off systemd-run unit (run-p<pid>-i<id>) as its own incident. Each has a fresh name, so no per-unit cooldown held and the phone rang every five minutes. The sweep now resets those units and never announces them, and the STILL FAILING / RECOVERED digests are delivered with disable_notification. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN * fix(alerts): quiet by default, ring only for down/intrusion; stop deploy and cron echoes - lib-alert: all box alerts deliver silently except DOWN/deploy failure/ intrusion-class messages (_alert_silent) - host sweep: failed appcron oneshots are the OnFailure notifier's, not repeated - security check: files a deploy rewrites by design are journal-only Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN * ci(box): install the alerting scripts on the box when they change The alert fixes only take effect once install-host-alerts.sh and install-security-watch.sh run on the box, and nothing ran them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN * feat(notify): one tap or not at all — every bot reaches the owner through one gateway The owner's Telegram held ~1,200 unread messages and rang every five minutes with lines he could do nothing with ("STILL FAILING: run-p…", "SENSITIVE FILE(S) CHANGED … if this was a deploy, ignore", "built nothing"). New rule, enforced in code: a message reaches the phone only with a button that does the thing; everything else is recorded on /today or /system. - telegram-send: refuses a message without a URL button (NOT_ACTIONABLE); adds silent delivery and sendTelegramVoice. - lib/notify: one gateway (deliverNotice) with the policy — at most 3 buttons, one incident one message with backed-off reminders, 3/source/hour and 12/day caps, sound only for "now" and never 22:00–07:00 Zurich. Voice notes for paid plans; a monthly "voice notes come with Personal" notice with its pay button for free accounts. - Routes: /api/notify (token holders, `loki.sh notify`), /api/notify/box (the box's lib-alert), /api/orangecat/notify (OrangeCat's bots, signed). - Box: lib-alert posts every line to Loki's list instead of Telegram; only an intrusion goes straight to the phone when Loki is unreachable, with a Box doctor button. ivy-health pages only "down and restart failed" with Redeploy; clean deploy rollbacks are not paged; fleet-uptime pages only for Loki or 3+ apps down; sleeping apps are no longer conformance findings. - App senders: each kept one now carries its button (Triage it, Review it, Watch the fix, Write to them, Restart the gateway, Decide on Control …); telemetry/runner/model-id pings and run successes leave Telegram. - Day plan: the morning brief's prompt is in the repo (scripts/openclaw/day-plan) and installed on merge, which also switches off jobs that only post swap/memory warnings. - Workflows install the box alerting, ivy-health, the day plan and OpenClaw's photo/video understanding on merge instead of by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN * feat(telegram): every sender is silent between 22:00 and 07:00 unless it says otherwise Feedback, studio briefs and the other direct senders skipped the notify gateway's quiet hours. A send that does not ask for sound now arrives silently at night in the owner's zone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
410f6ffd74 |
feat(auth): the shared sign-in button on AccountKit, and a deploy check that follows the box's OIDC env (#1534)
Loki has run on AccountKit since 2026-11-01. The runtime mounts the shared sign-in (`bitbaum-signin`, SIGNIN_*) from env, and the compat layer can start it, but Loki's sign-in and sign-up pages had no button for it. The deploy check also expected only "email-password" on this runtime, so OrangeCat could vanish from /api/auth/providers without failing a deploy. - getEnabledAuthProviders().signin is AccountKit's signinBroker(env), on the AccountKit runtime only. Sign-in and sign-up show "Continue with Google, Apple, GitHub, X or Facebook" (AccountKit's own label) next to OrangeCat, started through next-auth/react like OrangeCat. - scripts/expected-auth-providers.ts expects, on AccountKit, the password form plus every OIDC client AccountKit mounts (oidcClients): orangecat with ORANGECAT_OAUTH_*, bitbaum-signin with SIGNIN_*. On Auth.js it behaves as before. - deploy-hetzner.sh reads the box's OIDC env for it from /opt/fleet/env and the app .env, a non-empty app line winning as in launch.sh. The issuers and client ids are passed as they are; each secret is passed only as "set". - scripts/test/deploy-expected-providers.ts covers both runtimes and the button. Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9 Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
133831e60e |
fix(deploy): expect the providers the box's auth runtime mounts (#1527)
Every Loki deploy since the AccountKit switch (#1513, AUTH_RUNTIME= accountkit on the box) failed post-deploy verification with 'auth provider missing: github' and rolled back. On that runtime GitHub, Google and X are not mounted by design (getEnabledAuthProviders), and the live build already served only orangecat, email-password and user-password, but expected-auth-providers.ts still listed github. deploy-hetzner.sh now reads AUTH_RUNTIME from the box's .env (a mode name, lowercase letters only) and the script drops the social providers when sharedRuntimeEnabled() says the shared runtime answers. A rollback to Auth.js (AUTH_RUNTIME unset) expects github again. Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9 Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
289221e324 |
fix(deploy): expect only the auth providers that are not paused (#1474)
#1471 paused Google and X (PAUSED_PROVIDERS) so neither is mounted, but the post-deploy check in deploy-hetzner.sh still required both. Every deploy since then shipped, failed "auth provider missing: google" and rolled back, so nothing after #1471 reached production. The expected list now comes from PAUSED_PROVIDERS through scripts/expected-auth-providers.ts, so pausing or restoring a provider needs no second edit here. Claude-Session: https://claude.ai/code/session_019MDtmreRmsJkmf3AcYy6DS Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
01d0c4fc65 |
feat(cloud): sealed builds — rootless podman and gVisor as readings, switched on per tenant by the operator (#1348)
Track 4.2 of docs/master-plan-2026-10.md, built; switched on by a reading. - SandboxExecutor gains a podman mode (buildPodmanRunArgs): rootless as the tenant (--userns=keep-id), the tenant's home bound at the same path so sign-ins, trust and transcripts stay where the runner looks, the project's real path as workdir, network on, capabilities dropped, --cgroups=disabled so the deploy's drain still counts the processes, and gVisor's runsc as the OCI runtime when the box has it. - scripts/hetzner/agent-image/Containerfile: the image (shell, git, gh, node, Claude Code, Codex). install-sealed-builds.sh, run by every deploy: rootless podman, runsc best-effort, the image built into a shared read-only store, and a reading in /etc/loki/sealed-builds. - Nothing switches on by itself: new-tenant.sh writes the unit drop-in (LOKI_EXECUTOR=sandbox, LOKI_SANDBOX_RUNTIME=podman, runsc when read) only when the reading says ready AND /etc/loki/sealed-builds.on exists. The roadmap milestone stays unticked until a tenant builds in a container. - Tests: sandbox-executor pins the sealed shape; private-builders pins the two-reading switch and that no tenant ever joins the docker group. Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
9c84c929e4 |
feat(engines): your own key builds when you say so; welcome builds, then the plan's, then your own; capacity you can read (#1347)
* feat(settings): your own key builds, when you say so — a key marked for building reaches your private builder
Track 1, PR 6 of docs/architecture/private-builders.md.
- user_model_keys.for_building (migration 0123), off by default; one
switch per key in Settings → AI, offered only on keys that can drive an
agent CLI (config/build-engines.ts: Anthropic → ANTHROPIC_API_KEY for
Claude Code, OpenAI → Codex, xAI → Grok, Google → Gemini CLI) and only
to an account with a builder on the cloud.
- scripts/write-tenant-engines.ts (root on the box, from the reconcile
timer) opens the marked keys with the app's sealing secret and writes
them to /etc/loki/runners/<short>.env; a unit whose file changed is
drain-restarted, so the key reaches its next agent without ending a
session mid-task. No route ever returns an opened key.
- Records: changelog {#your-engine}; roadmap milestones ticked.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* fix(settings): the building switch sits in one row with its sentence
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* feat(engines): welcome builds, then the plan's, then your own — and capacity you can read
Track 2 (2.1, 2.2, 2.5) and Track 4.1 of docs/master-plan-2026-10.md.
- users.build_engine (migration 0124): "own" by default — the person's
sign-in or a key marked for building, never counted — or "loki": Loki's
key within WELCOME_BUILDS (3, config/welcome-changes.ts) and the plan's
PLAN_LIMITS.buildsMonthly (10 / 40 / 100). Every run records which
engine paid for it (payload.engine); welcome and plan builds are counted
from that marker. A dispatch past the last build is refused with the way
forward (code engine-exhausted), and the kickoff screen shows it with
one tap to Settings. Loki's welcome spending stops for everyone at
WELCOME_MONTHLY_CAP_CHF (20), at CHF_PER_USD, a hand-set rate.
- The box writes Loki's key (LOKI_BUILD_ENGINE_ANTHROPIC_KEY from the
app's env) into a tenant's unit only while they chose Loki's engine and
have builds left; otherwise their own marked keys.
- Settings → AI: "Your engine for building", one Segmented choice with the
numbers; /api/settings/build-engine. The kickoff's no-builder copy says
the operator switches a private builder on per account.
- System → Capacity: how long work waited for a builder in the last day
per channel (median, worst), this month's builds, tokens and cost per
account, and welcome spend against its cap.
- /pricing and the whitepaper (0.3.3) state the builds a month on Loki's
engine and the rule. Records: changelog {#welcome-changes}
{#capacity-card}; roadmap milestones ticked.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* style(engines): format resolve.ts the way prettier wants it
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
944ed15747 |
feat(cloud): private builders — an allowlisted agent environment, a runner without the database, one sealed unit per account (#1346)
* feat(runner): agents get an allowlisted environment; the cloud builder asks Loki what to clone
Track 1, PRs 2 and 3 of docs/architecture/private-builders.md, together.
- src/lib/agent-execution/agent-env.ts: with LOKI_AGENT_ENV=allowlist (set
by the box units) an agent PTY is born with a shell's environment, the
engine keys the unit holds and what its own spec passes — never
DATABASE_URL, never the org GITHUB_TOKEN. Off the box nothing changes.
- GET /api/control/workspace-source?tab=: a runner asks with its own token
and gets its own account's repository and a token that account may write
with (github-org-token.ts). box-workspace.ts reads no database any more;
the runner passes the run's token to the one agent that needs it
(GITHUB_TOKEN/GH_TOKEN in the spec env).
- mint-box-runner-token.ts --user <id>: a token per tenant.
- Records: changelog {#agent-env} {#runner-no-db}; roadmap milestone ticked.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* feat(cloud): a private builder per account — the flag, the sealed unit, reconciled on the box
Track 1, PRs 4 and 5 of docs/architecture/private-builders.md.
- users.private_builder (migration 0122) is the one switch, set from
System → Plans (/api/system/private-builder). It grants cloud BUILDING
only: isCloudBuilderAllowed (founder or flag) for routing, Sessions and
the kickoff path; isFleetInfrastructureAllowed is the founder alone and
gates the org GitHub token, studio CD, own domains and the server's own
PTYs. LOKI_CLOUD_BUILDER_USER_IDS is retired.
- scripts/hetzner/loki-box-runner@.service: one unit per tenant as
lk-<short>, ProtectSystem=strict, ProtectHome=tmpfs with its own home
bound, the app and the runner env invisible, MemoryMax/CPUQuota/TasksMax,
its own dev root, the agent env allowlist, no database password.
- scripts/hetzner/new-tenant.sh: user, clean shell, dev root, a runner
token minted for THAT user, the agent contract, claude in its own home,
an env file for its engine keys, the unit. reconcile-tenants.sh runs
every minute from loki-tenants.timer (install-tenant-reconcile.sh, run by
the deploy) and brings units into step with the flag. The deploy ships
the scripts and template and drains and restarts every unit, each in its
own transient unit.
- A tenant's project path is written under its own root
(tenantDevRoot), which counts as box-rooted for routing.
- Records: changelog {#new-tenant} {#private-builder-flag}; roadmap.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* chore(runner): Fleet Runner 0.8.50 — the allowlisted environment and the API-backed clone
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
1f1f40429c |
fix(builder): sessions survive cloud builder updates (#1326)
Every deploy restarted the cloud builder, and a restart ends every session it holds. The drain waited for nobody to be mid-task, then logged "idle sessions resume on their next dispatch" — nothing resumed them. The owner found "No live sessions" after each of five deploys in one afternoon. - The builder writes down each session it opens (~/.loki/open-tabs.json) and crosses it off only when it really ends: closed from Loki, or the agent exited while the builder stayed up. On start it reopens the rest; Claude sessions come back as the same conversation (claude --resume). - Deploys compare runner files by content (rsync --checksum). A fresh checkout gives every file a new mtime, so every deploy, docs-only included, read as a runner change and restarted it. - The manifest sync no longer lists a package-lock.json this pnpm repo does not have; its rsync error blanked the output and hid real changes. - Runner 0.8.47; the drain log says what happens now. Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
adfbdcfe07 |
fix(session): the builder updates, the sheet changes things, one box, a preview is the site (#1305)
The owner used Loki from a phone (2026-10-18) and could not tell whether
anything worked. Four separate faults, each passing every check:
The cloud builder ran code days behind the app. Its restart waits for
every agent to be idle, and autopilot refilled the queue the instant one
finished: ten consecutive deploys (23:38 → 09:12) found "2 agent(s)
working — deferring restart". Hence "Model: not known yet" of an answer
the screen was showing. Now, while the cloud runner's heartbeat version is
behind the deploy's, the commands route hands it no work-starting
commands (dispatch, launch_agent, auto_continue, browser_task) — a
person's own words into a session still go through — so the idle moment
comes, the restart lands, the queue resumes on the new code. Server-side
on purpose: a runner-side rule would have waited for the very restart it
was meant to allow. Control's builder line says "a newer version waits
for its agents to finish" meanwhile.
An agent renamed a preview site, committed, and reported "the work lives
only on this machine — tell Loki where this preview's remote should
live". The box contract says push or fail loudly; a preview folder is
served from disk and has no remote by design, so the change had been live
since the save and the owner read a failure and a chore. Every dispatch
to a preview folder now carries "Where this goes" (lib/previews/
delivery-note), and the contract has the same section.
The session sheet's Change and Set typed /model and /effort into the
terminal and closed; Claude Code drew its picker behind the conversation
and nothing on screen moved. Each row now lists its choices; a tap sends
the command with the choice named (/model sonnet, /effort high), the
sheet stays open and says what is changing, and settles when the log
names it. The sheet is built like the Settings sheet.
The session box had a 26px library button beside 44px round ones, a 36px
chip and a 34px Keys pill, the microphone second from the left in one
view and beside Send in the other, and "claude" on the tab beside
"Message Claude…". One row, one size, one order in both views; the
agent's name everywhere (terminal-strip-tabs badgeNames).
Widget: the owner's change list reads what needs them first (the line
counted nine, the list showed none); "9 needs you" → "9 need you"; a
failed call is named ("my call to Loki to save your note failed… Your
words are still here — press it again") instead of "one of my calls to
Loki failed — nothing for you to do".
Tests: runner-update-hold, preview-delivery-note, owner-changes-order,
session-sheet-browser (new); builder-presence, widget-changes,
widget-self-report, inject-context-boundaries extended.
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
33ca923cad |
fix(deploy): install Chromium with the app's own Playwright; /api/health says whether pictures work (#1285)
Every picture on the box answered no-browser. The deploy installed Chromium with the runner's Playwright, which npm resolves from package.json's ranges (there is no package-lock.json), while the app is built from pnpm's lockfile: two versions, two Chromium revisions, and the app never found the one that was installed. The install now runs the Playwright the standalone ships, as the app user, and a failure's output stays in the deploy log. /api/health carries `pictures` (Playwright present, the browser path, ok), so a server that cannot photograph a page says so on the one line everyone reads. A missing Playwright is its own reason (no-playwright); the two places that word a missing browser treat it the same. Claude-Session: https://claude.ai/code/session_01Y9KbVEpxKLC9nhKhpWncU1 Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
96335c2ebe |
feat(terminal): the session names its effort; box agents ask for Loki's records in one line (#1245)
- Claude Code writes the effort level on each answer in its log, beside the model. The reducer reads it and SessionInfo shows it: "Opus 5.5 · high effort · Auto", and the sheet's Effort row names the current level. - The box agents' contract gains "What Loki knows that this machine does not": records arrive attached; when one is missing, say "I need the feedback reports for <project>." (which the box turns into an Attach button), never ask the operator to export them by hand. A test ties that sentence to the detector. - The contract was only installed when the builder was first set up, so every later edit stayed in the repo. deploy-hetzner.sh now re-applies it (merge-only, 60 s cap, never fails the deploy). Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
24c21ddf9c |
feat(ops): the cloud builder's liveness is public, deploys print its state, the queue says "offline" (#1158)
* feat(ops): the cloud builder's liveness is public, deploys print its state, the queue says "offline" The shared cloud builder was offline all night on 2026-10-11 → 12 and nothing outside a signed-in page said so: /api/health reported the web app green, the fleet sweep probes only HTTP codes, and the box journal is the one place the restart's outcome is written. The owner found out by trying to work from a second computer. - GET /api/health/builder: 200 while the owner's cloud builder is connected and heartbeating, 503 otherwise, with the last heartbeat and version. Public on purpose (one boolean, one timestamp, about a service the operator runs); registered in scripts/test/api-route-auth.ts. - install-watchdog.sh: the box watchdog now probes it, so a state flip alerts on Telegram like a dead site does. - deploy-hetzner.sh: before scheduling the runner restart, print `systemctl is-active loki-box-runner`, the last runner journal lines and the last drain lines into the CI log — the first place a person without an ssh session can read why the builder is down. Warn-only. - feedback run-step: a job on the cloud queue while the cloud builder is offline reads "Cloud builder offline — nothing starts until it reconnects", not "Watch shows why" (nothing showed why). Tests: feedback-run-step (+2), api-route-auth, watchdog-check. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Xssd1hFZCUSxqjACjoVBB * fix(terminal): a private cloud builder reads "private", not "offline" Walking Loki as a brand-new account (2026-10-12): the Terminal's chip said "Cloud builder offline" beside an empty state that said "Cloud builder is private for this account". Presence is per account and a new account has none, so the chip mistook "not yours" for "down". The chip derivation moves into terminalHonesty() (one helper, the component stays under its 510-line ratchet) and names the gate first. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Xssd1hFZCUSxqjACjoVBB --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
92802bc538 |
fix(deploy): install cron timers and the fix-check browser on every ship (#1148)
Two features merged, deployed and passed every check while the box lacked what they need, because each depended on a command someone had to run on the box by hand: - the 19:00 evening proposal (autopilot-plan) had no timer, so no night plan was ever made; - the picture Loki takes to settle a visual fix needs a Chromium for the app user, which nothing installed. deploy-hetzner.sh now ends with both, idempotent and warn-only (the app is already live and verified by then): it runs install-hetzner-crons.sh, and installs Playwright's Chromium for the app user with the runner's full Playwright CLI (same version the app ships, so the same browser revision). install-hetzner-crons.sh writes fc-cron.sh beside and renames it into place, since a timer can be mid-run when a deploy re-runs the installer. cron-schedule-coverage now also fails if the deploy stops running the installer — the one link it could not see. Claude-Session: https://claude.ai/code/session_011L2dmcydDLYAiNQwK4XcF4 Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
ccf93dfcdf |
fix(runner): a deploy never kills a working agent — the drain waits up to 6h, then leaves the old code (#902)
At 09:01 on 2026-09-25 the post-deploy drain reached its 30-minute cap while a Skif agent was genuinely working, and force-restarted the box runner, killing it mid-brief. Stale runner code is recoverable (the next drain lands it); an agent's half-done work is not. drain_decision is now pure and pinned: restart when nothing works, wait while something does, and at the cap LEAVE the runner on its current code, loudly. There is no forced-restart path. Default wait 6h. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
5f1e283117 |
fix(scripts): grep -q is never the reader of a pipe under pipefail (#874)
`echo "$x" | grep -q PAT` under `set -o pipefail` can report "not found" for text that IS there: grep -q exits on its first match and closes the pipe, the writer takes SIGPIPE (141), and pipefail makes the pipeline status 141. An `if` then takes the else branch on a successful match. #587 found this in one file and noted it "only fires when the payload exceeds the ~4KB pipe buffer". That is not so, and the belief is why 82 copies in 22 scripts survived. Measured today on retire-site's real 1,158-byte plan output with has()'s exact pattern, 3,000 calls each: 'DRY RUN' line 3 of 20 echo|grep -q 2/3000 false misses 'apps.conf row' line 11 of 20 echo|grep -q 2/3000 false misses last phrase line 20 of 20 echo|grep -q 0/3000 'DRY RUN' here-string 0/3000 Rare per call, but verify makes hundreds of these calls, and the retire-site suite went red on those two exact phrases twice this week, passing every rerun. It is worse in a NEGATIVE check - hasnt() read a false miss as a PASS. And several copies are not tests: deploy-hetzner.sh exits 1 on a false miss, and the sshd drift watch would raise a false security alert. All 82 rewritten to `grep -q PAT <<<"$x"` (a here-string is not a pipeline, so there is no writer to signal) by a script that only touched the simple quoted-variable form and reported anything else. Checked: all 22 files pass `bash -n`, every file is a 1:1 line swap (82 lines), and the 20 line-continuation sites keep the here-string before the trailing backslash (the first draft of the rewrite got those wrong; caught in a dry-run diff before anything was written). #587's comment is corrected so it stops teaching the wrong threshold. Gate: scripts/test/no-grep-q-in-a-pipe.ts ratchets it repo-wide, including forms the rewrite skipped (e.g. "$(cmd)" | grep -q), and self-tests that its detector still fires. Proven by restoring the original deploy-hetzner.sh line. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
690d47a0aa |
chore(register): factory-sep11-0040 on 4029 — created by the hosted runner, then lost by a deploy (#602)
The first site the fleet created without a human at a terminal. Dispatched as a `hosted_new_site` command (#598), claimed by the hosted runner 0.75 s later, executed in 37 s with ok:true: repo bitbaum/factory-sep11-0040, Caddy vhost, release 20260911-003309-c9d257c, unit factory-sep11-0040-app active, and the promoted day-zero page served on :4029. The register row it appended did not survive. The runner was pointed at /opt/fleetcrown/app/scripts/hetzner/new-site.sh — Next's standalone output, which deploy-hetzner.sh rsyncs with --delete on every ship. The vhost was written at 00:32:53; app/ was re-synced at 00:34:12; the row was gone. A site running on the box with no register entry is the camille failure again, eight days of it compressed into eighty seconds. This restores the row by hand and records what the runner should have been able to keep. Also ships scripts/new-site-dispatch.ts to the runner: deploy-hetzner.sh syncs an explicit list of scripts into /opt/fleetcrown/runner and the dispatch CLI was not on it, so the only way to enqueue a site from the box was to copy the file there by hand — which is how this one was enqueued. Gates: test-port-alloc (6), test-register-reality (10), check-client-ledger (demo kind, no terms owed) all pass with the row. Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
68afac5ccb |
fix(deploy): the runner's dependencies ship with the code that imports them (#343)
fleetcrown-reindex has been dying every night at 03:30 on `Cannot find module 'bip-kit'` — imported via src/lib/thoughts-content.ts. The module is not the bug. The bug is that the deploy re-syncs the runner's src/ on every ship and has never once shipped its manifest. /opt/fleetcrown/runner/package.json is a snapshot from original provisioning: 31 dependencies, no bip-kit. Meanwhile src/ arrives fresh every deploy. So the moment any file under src/ gains a new import, the runner breaks at its next run — and the deploy reports green, because nothing checks. - package.json, package-lock.json and vendor/ now sync alongside the code. vendor/ is part of the manifest, not an extra: package.json carries "@orangecat/sdk": "file:vendor/...tgz", so bumping that version without shipping the tarball fails the install for a path that exists only locally. - When any of them actually changed, install on the box and mark the runner changed so the new deps reach a fresh process via the existing drain-then-restart (which waits for in-flight agents first). - A failed install FAILS the deploy. Warn-and-continue is exactly how this stayed invisible for weeks: the runner was broken and the pipeline was green. Two things this must not do, both found by testing against the real box: - NOT `npm ci`, and NOT `--omit=dev`. tsx is a devDependency and it is the runner's own ExecStart (node_modules/.bin/tsx). `ci` deletes node_modules wholesale, so for the duration of the install the cloud builder's runtime does not exist; `--omit=dev` deletes it outright. Incremental install keeps the always-on executor runnable throughout. - HUSKY=0 is required, not cosmetic. package.json's `prepare` runs husky, the runner dir is not a git repo, and without the opt-out npm exits 127 — which, given the failure is now fatal, would have broken every future deploy. Verified with a REAL install in a scratch dir on the box, not a dry-run: a dry-run passes `prepare` vacuously because husky is never installed, so it cannot see the 127 at all. Full install returned exit 0, "HUSKY=0 skip install", 864 packages, with both bip-kit and tsx present — so this resolves the reindex crash and keeps the runner alive. Scratch dir removed; box disk unchanged at 15G free. The box is deliberately NOT patched by hand: three visitor-feedback runs are executing on it right now, and this deploy remediates it through the drain path instead. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
cc4e892559 |
perf(deploy): the pipeline was waiting, not working (#293)
Merge→live measured 14–27 minutes. The irreducible work in that window is about 80 seconds: build 66s, rsync 4s, restart 4s, verify 7s. Nearly all of the rest was waiting, so nearly all of the fix is removing waits rather than making anything faster. Two waits, measured: 1. The runner drain, 480 of the ship step's 570 seconds. The deploy watched one in-flight agent, then restarted anyway at the cap. The web app had been live and verified for eight of those minutes. Two systems with opposite needs were sharing one job's wall-clock — the app wants to be live now, the runner wants to not kill anyone's work — and the runner won every time. A shorter timeout would only kill agents sooner. The wait itself is fine; the place it happened is what cost. Waiting is expensive in CI and free on the box, so it now happens on the box: the deploy schedules a detached systemd-run unit and returns as soon as the app is verified. The drain gets *longer* (1800s, not 480) and cheaper at the same time, because nothing is holding a runner open for it. 2. The CD reconciler, up to 10 minutes and 18.6 of #284's 26.8. Deploy chains off CI via workflow_run, which never fires for a CI run that GITHUB_TOKEN started — i.e. for every auto-merged PR, the only path that merges code here. The sweep covered that by reconciling on its next tick: correct, self-healing, and late. A dispatch is not a push, so it is not subject to the no-cascade rule. ci.yml now dispatches Deploy itself the moment main goes green. The sweep keeps its reconciler as the safety net, which is the right shape for "did something get missed?" and the wrong one for "did something just happen?". Also caches .next/cache across deploys — the build is the one part of this that is genuinely work, so it is the one part worth shrinking. Not done, and worth saying: I thought CI and Deploy each built the app, so the tested artifact was never the shipped one. That was wrong. ci.yml deliberately skips `next build` because App-Router pages query Postgres during pre-render; the build happens once, in Deploy. There was no discarded build and no artifact to pass. The decoupling has a test, and it asserts the property rather than the patch: the deploy must not block on a drain, the restart must be detached, the script must be shipped before it is invoked, and the drain must stay bounded. Verified the first two assertions fail against the previous version (4 blocking markers, 0 systemd-run) rather than merely passing against this one. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
be7f9c2a71 |
fix(deploy): a deploy that dies silently should still say where (#292)
#289 fixed the command that killed three deploys with no output. This is about the ten seconds it took to see that, versus the investigation it actually took. deploy-hetzner.sh runs under `set -euo pipefail` and several of its commands redirect both streams to /dev/null, because they are questions about the box rather than steps of the deploy. When one of those exits non-zero the script dies where it stands, and the operator's entire trace is: → deploy FAILED (exit 1): |
||
|
|
5a5329d61f |
fix(deploy): the guard against bad deploys was blocking all of them (#289)
My own regression, shipped in #285 and broken within minutes: deploys of |
||
|
|
15faf227b8 |
fix(deploy): a week-old main still passes "are you on main?" (#285)
Production was rolled back today and self-healed before anyone looked.
CI shipped main at 09:47 and verified it live at 09:48 — the deploy log
says "live build is
|
||
|
|
7bd17c7104 |
fix(deploy): a marker that can lie is worse than no marker (#280)
Two flaws in #279, found before its deploy ran. 1. The stamp preferred GITHUB_SHA over the checked-out commit. deploy.yml's workflow_run path checks out `workflow_run.head_sha`, which is not always the run's GITHUB_SHA, so the marker could name a commit that was never compiled. Since the deploy compares the live marker against the shipped ref, a lying marker manufactures a false alarm. Git HEAD is literally what was built, so it now comes first; GITHUB_SHA is the last resort for checkouts with no .git. 2. A mismatch rolled the box back. The realistic cause of a mismatch is a second deploy landing behind this one — and reverting to app.prev would discard the NEWER build, turning a benign race into exactly the incident the check exists to catch. It now reports loudly and leaves the running build alone. What was missing before was never the ability to revert; it was ever being TOLD that the box serves something else. That, plus /api/health, is the fix. Both are pinned by tests, including one asserting the mismatch path does not call rollback_box. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
3bdaa28b11 |
fix(deploy): production could not say what commit it was running (#279)
/api/health advertised a `version` field that is `npm_package_version` — always null under systemd — and the box kept no deploy marker anywhere. The only way to answer "is prod on main?" was to ssh in and grep the compiled bundle for a symbol you knew was in the new source. That is not cosmetic. A hand-run `npm run deploy` ships whatever branch the worktree is on, and it has now rolled production back three times. The third was today, 14:19 UTC, WITH the off-main gate in place — that gate requires the commit to be *contained in* origin/main, and an ancestor passes it cleanly. Both `app` and `app.prev` were rotated to the stale build, so the correct CI build was destroyed, and the fix from #275 was live at 12:40 and gone by 14:20. It surfaced only because a live probe of /api/control disagreed with the database, and it cost about fifteen commands to pin down. Every previous occurrence presented the same way: a fix demonstrably on main, missing at runtime, indistinguishable from an application bug. Now the artifact carries its own identity: - scripts/record-build-ref.sh stamps the commit into .next/standalone at BUILD time — one writer, so the marker rides both deploy paths (the local script and the Deploy workflow, which builds the same way then ships with --no-build). Best-effort: an unresolvable commit degrades to `commit: null`, never a guess, and never a failed build. - /api/health reports it, so `curl .../api/health` answers the question. - The deploy reads the commit back OFF THE LIVE BOX and rolls back if it differs from what was just shipped. Health returning 200 proves the box is up, not that it is up on this build — which is precisely how a clobbered deploy passed verification three times. scripts/test/build-ref-marker.ts covers the whole chain (stamp → artifact → health → deploy assertion), because every link is deploy-time-only code, the kind that rots unnoticed until the incident. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
c8415a348b |
fix(loki,deploy): the approval queue survives a Groq outage; deploys can't ship off-main (#262)
* fix(loki,deploy): the approval queue survives a Groq outage; deploys can't ship off-main "What is pending for approval?" answered "Not in your data." in production while drafts were waiting. Two independent causes, both fixed here. 1. A hand-run deploy shipped a feature branch to the box — twice, minutes apart — rotating the correct CI build out through app.prev and reverting three merged PRs. Prod served a Loki with no approval-queue tool while main had shipped it hours earlier. The symptom was indistinguishable from an application bug and was chased through the app first. scripts/ci/check-deploy-ref.sh now refuses any deploy whose commit is not contained in origin/main, naming both the unreviewed commits and the ones it would roll back. Override is explicit and announces itself. deploy-hetzner.sh calls it before the schema step, so a refusal leaves the box untouched. The existing --ref guard only ever covered HEAD drift DURING a build; this is the invariant that was missing. Second occurrence of this class — see the comment it replaces. 2. Even on the right build the answer was wrong, because the queue was reachable ONLY by tool call. Groq's org-wide TPM window is exhausted: both the 70B and the 8B step-down 429 on every call, the bounded retry expires, the tool loop dies, and Loki answers from seed facts on a TOOLLESS fallback model — which cannot see a tool-only table, so it truthfully reports nothing. pendingApprovalFacts() moves to sources.ts and is seeded into the grounded context on an approval cue, so the question is answerable with the tool loop entirely unavailable. The tool now calls the same function: one definition, both paths. Approvals lead the fact list — the seed is head-sliced, so the subject of the turn must not sit in the tail. Tests: deploy-ref-gate.sh (7) covers the incident shape directly — an off-main branch is refused, an ancestor of main is not. approval-cues.ts (24) pins the cue against the operator's real phrasings, including the typo from the report, because a missed cue is silent and reads as a truthful "nothing is pending". Also folds the duplicated dateLabel (handlers.ts + an inline copy in sources.ts) into one exported helper. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(loki): drop the now-unused getPendingActions import The tool handler delegates to pendingApprovalFacts, so the direct query import is dead. tsc does not flag unused imports; eslint does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: test <test@test> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
2a8559f65b |
feat(terminal): tabs tell the truth — project + live agent, launch in place (#252) (#261)
The terminal knew a tab was called "Tab #1" and nothing else. The runner has been pushing full pane topology (tab, cwd, agentCli) in every runtime snapshot all along; nothing joined it to the tab strip. Now /api/terminal/context does: - Tab strip shows the resolved project name plus a badge naming the agent CLI actually running in that tab ("claude", "grok", "claude+codex"). Tab→project resolves by name first, then by pane cwd prefix against a project's dirPath — which also recovers `dir` for generically named tabs, un-breaking the agent switcher there. - Empty state can start an agent instead of only telling you to go elsewhere. TerminalLaunch reuses /api/agent/launch with the same eligibility rule as Control (projects with a linked directory) and pins the builder channel you are looking at, so the session appears on the terminal you started it from. - A ?tab=X deep link that matches no live session says so, instead of silently showing Tab #1 and letting you type into the wrong agent. - box-runner reads its version from desktop/package.json (the code it actually runs). The systemd unit pinned box-0.8.9 across three releases, so Settings reported a version the box was not running. Env demoted to fallback; deploy ships desktop/package.json alongside the modules. Co-authored-by: test <test@test> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
cb02928c14 |
fix(deploy): resolve --ref to a full SHA before the pinned-deploy guard (#121)
git_head returns a full 40-char SHA, so passing a short SHA to --ref always failed the literal HEAD compare and skipped the deploy even when the tree was on exactly that commit. Resolve the ref once at parse time; the guard compare and FLEETCROWN_DEPLOY_REF passthrough work unchanged. Co-authored-by: test <test@test> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
91a531e17d |
fix(deploy): pin LC_ALL=C so the box schema-drift check stops false-failing
Every deploy from a de_CH.UTF-8 laptop aborted at the schema-drift step with "comm: input is not in sorted order" (exit 1) — even when the box schema was perfectly in sync (verified: 0 missing tables/columns). glibc UTF-8 locales order some `table.column` strings inconsistently, so `sort` produced output that `comm` (same locale) then rejected as unsorted. Under `set -euo pipefail` that killed the whole deploy script before the event-bridge sync ran — the app was already live, so it looked "deployed" while silently skipping later steps. Pin LC_ALL=C on all four sorts and both comms in the block: byte-order collation is deterministic and self-consistent between sort and comm. Reproduced the failure against the real box (550 declared / 552 box columns) and confirmed the fix clears it. bash -n clean. |
||
|
|
ac9f05a42f |
feat(db): restore drizzle-kit generate + self-heal table ownership
Tier-3 schema tooling. Two coupled fixes so a schema change no longer means hand-writing DDL (the reflex that caused the box-ownership rollbacks): 1. `npm run db:generate` works again. drizzle/meta had no snapshots, so generate couldn't diff — new migrations were hand-numbered by hand. Reconstructed the current-schema snapshot (meta/0039_snapshot.json) and aligned the journal idx (1..39, was 0..38, which collided at 0039). Proven: baseline diff is empty; adding a column emits exactly `0040_*.sql` with the right ALTER; clean revert. This is pure local tooling — apply-schema.sh is filename-based and ignores meta, so zero prod-deploy risk. 2. Deploy self-heals table ownership. apply-schema.sh (shared infra) runs DDL as the postgres superuser, so a migrated table would be owned by postgres and invisible to the fleetcrown app role — the class that rolled back deploys. An idempotent reassignment now runs after the schema step: on a healthy box it touches zero tables; it hands any postgres-owned object to the app role before the drift-check. Verified live: it found + fixed 1 real mis-owned table on the box, then re-ran to 0 (idempotent). Flow now: edit schema → `npm run db:generate` → review 0040_*.sql → commit → deploy applies it (forward-only) and reconciles ownership. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
a2f88ce449 |
feat(hosted-runner): scripts/hermes-dispatch.ts — intentionally dispatch a task to Hermes
Until now Hermes only ran as an automatic offline-fallback; there was no way to say 'run this on Hermes on purpose.' This CLI resolves a project's git URL and enqueues a hosted_dispatch that the timer drains → clone → Hermes → PR. Synced to the runner dir on deploy. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
38c7d11ef9 |
feat(hosted-runner): make Hermes usage observable + reconcile parked-adapter truth
The hosted Hermes path (inject-core auto-routes offline coding dispatches → scripts/hosted-runner.ts → runHermesTask, drained by fleetcrown-hosted-runner.timer) ran with zero Activity visibility: successes went only to console + the project dev log, failures went to console ALONE. 'Is Hermes being used' required DB archaeology. - Instrument the path into orchestration_events (the SSOT Activity already reads): producer marks the offline→hosted routing (source=hosted-runner, adapter=hermes, deduped by command id); consumer emits task_started/task_completed/task_failed for both hosted_dispatch (Hermes) and hosted_analyze, attributing the real executor. Adapter recorded via a localized "hermes" as AdapterId cast — the same pattern close-sweep already uses for adapters outside ORCHESTRATION_ADAPTER_IDS. - Fix failure-invisibility: hosted failures now also append to the project dev log, not just console. - Reconcile the stale agents/index.ts comment: it claimed runHermesTask is unwired and the CLI 'isn't installed anywhere' — both false. Interactive adapter is parked (out of ALL_ADAPTERS by design); the HOSTED executor is wired + installed (box v0.17.0). Distinguish the two clearly. - deploy: sync scripts/hosted-runner.ts to the runner dir (the timer runs it there; it was never being updated on deploy). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
04ad52a2c7 |
fix(deploy): drain-guard the box-runner restart — stop killing in-flight agents
Every deploy unconditionally restarted fleetcrown-box-runner, whose systemd cgroup includes any claude/hermes the runner launched for a live dispatch — so an app-only deploy silently killed running agent work (an AI-review run died this way; I hand-checked 'any in-flight runs?' before ~6 deploys this session to work around it). Two guards: - Skip the restart entirely when no runner code changed (src/desktop/home/ box-runner scripts/tsconfig) — detected via rsync -i itemize. Most deploys touch only the app, so this alone ends the needless kills. - When runner code DID change, drain first: poll the runner cgroup for claude/hermes/codex/cursor-agent/grok processes and wait (cap 8min, FLEETCROWN_RUNNER_DRAIN_SECS) for them to finish before restarting. Idle runner drains instantly (cgroup holds only its 2 node procs). Best-effort, never fails the deploy; restarts anyway on timeout so a real fix still lands. Verified: drain detection returns 0 against the live idle box. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
d15fc267aa |
chore(db): refresh drizzle/meta/_journal.json — 0036-0039 were on disk but missing
Journal is what drizzle-kit generate orders against; the box schema history (public._deploy_schema_history, applied by scripts/hetzner/apply-schema.sh) is untouched. Regenerated via bootstrap-migration-ledger.ts --write-journal. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
7adaf874cc |
feat(deploy): CI-gated deploys, atomic releases + rollback, prisma migrations, fleetcrown schema step (#68)
Four DevOps hardening pieces (A+ run):
- ci-gate.sh + hook template: push-deploys WAIT for GitHub CI on the pushed
commit and are BLOCKED on red — prod only receives what CI verified
(was: deploy raced CI; only bypassable local hooks gated prod).
- deploy.sh: releases layout — /opt/<name>/releases/<ts>-<sha> + atomic
app-symlink swap (units unchanged), shared/{.env,launch.sh}, keep-3 prune,
AUTO-ROLLBACK on failed health check. Legacy dirs migrate in place.
- rollback.sh: one-command flip to previous/named release + restart + health.
- apply-schema.sh: prisma branch (prisma migrate deploy when prisma/migrations
exists) — covers aoz/datacat (tracked) + reparaturbonus/solon (baselined +
resolved on prod today).
- deploy-hetzner.sh: fleetcrown itself now schema-gates via the shared applier
(39-file set; drizzle journal desync documented in-line — number new
migrations by hand 0040+ until reconciled).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
||
|
|
2040322b2d |
refactor(audit): finish worst-first fixes — states SSOT, palette mirrors, timeout tiers, box git auth
Final audit wave (three fix agents died at the session limit mid-flight; completed by hand): - box-workspace: token no longer embedded in remote URLs — auth moves to a per-invocation http.extraheader (actions/checkout pattern) and legacy embedded credentials are scrubbed from origin on every workspace prep - ORCH_STATE keyed constants adopted at every raw run-state literal (dispatch-status, activity-status, presenters, run route writes, inject-core, openclaw execution, queries incl. the SQL literal) - lib/palette.ts: single JS mirror of the design tokens for contexts that cannot read CSS vars (satori OG x3, email HTML, themeColor, xterm base, mermaid fallbacks, brand-mark) — zero rendered values changed - HTTP/EXEC timeout tiers in constants/time.ts adopted across LLM and subprocess callers; widget polls join REFRESH_CADENCE - scripts: Hetzner IP exists exactly once (hetzner/_box-env.sh); all 15 scripts source it (bash -n clean, heredoc output byte-identical) - storage keys centralized in brand-storage (values unchanged); ControlDispatchButton's dead 'control:prefill' write replaced with the real ?focus= deep-link; investors copy no longer hardcodes a fleet count; bare exhaustive-deps disables annotated Not done, deliberately: public-git-history rewrite — the GitHub account ID (41178744) links the old and new handles regardless of history, so a 3-repo force-push would break the live fleet for cosmetic-only gain; real pseudonymity requires a fresh account (operator decision, see AUDIT_REPORT). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
286ef6c355 | fix: sync handoff watcher to box runner | ||
|
|
1c626b1874 |
feat(reliability): roadmap — deploy alerts, runner-stall recovery, context assembler
Three improvement-loop roadmap goals: 1. Deploy on origin/main + rollback/alert: deploy_alert() pings the operator on Telegram when a ship fails or rolls back (silent broken ships + silent rollbacks left the box in an unknown state). Schema-drift now rolls back + alerts too. Auto-rollback already existed. (Auto-applying prod schema stays a deliberate manual step — the loud gate + rollback is safer than auto-DDL.) 2. Runner stall: auto-recovery & alerting: new check-runner-stall cron (every 30m) runs getRunnerExecutionStall per autopilot user; on a stall it reclaims stuck claims (safe re-dispatch), raises one deduped in-app alert (insertActiveAlertOnce), and pings Telegram. Detection already existed but only ran when a human loaded /control — now it's on the clock. 3. One context assembler: close the cloud-orchestration bypass — Control's dispatch / Next-best path enqueued renderTaskForAdapter() raw, with no exit contract, so box agents finished work, wrote no handoff, and were reaped as timeouts. Append the same exit contract inject-prompt.ts uses so every dispatch path lands a session handoff. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016g8LdPdzoEbVwQ1SdYW5RY |
||
|
|
72b654e7c3 |
fix(deploy): SSH keepalive on rsync transports so a dead connection fails fast
A deploy wedged for 15+ min at 'rsync standalone → box': 0 bytes/s, box fully reachable — a dead TCP channel that never timed out. The restart-ssh already had ServerAlive guards (after a documented 47-min hang); the rsync calls did not. Add `-e "ssh -o ConnectTimeout=10 -o ServerAliveInterval=15 -o ServerAliveCountMax=6"` to the standalone, bridge, and runner rsyncs so a silent connection drops after ~90s and the deploy can be rerun instead of hanging past every downstream timeout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016g8LdPdzoEbVwQ1SdYW5RY |
||
|
|
4fbadfe2ee |
chore(deploy): sync reindex script, bound restart stop, cover share lifecycle
- deploy-hetzner.sh: sync scripts/reindex-knowledge.ts to the box runner so the nightly fleetcrown-reindex uses current (dossier-aware) code — it was pinned to a 2026-06-25 copy while src/ shipped daily, so project_profile embeddings never picked up the richer shared-dossier text. - deploy-hetzner.sh: poll /sign-in for readiness (up to 20s) instead of one immediate curl, so a slow-to-stop old Next process no longer rolls back a build that is actually fine. - systemd units (box-units + sync-infra): TimeoutStopSec=15 + KillMode=mixed so a `systemctl restart` can't block on Next draining keep-alive connections. - authenticated-smoke: add SH01–SH09 share-lifecycle probes (create → public render → update → revoke → public 404 → clean), non-destructive on already- shared projects. Validated green against production. - CLAUDE.md: note the per-project dossier + shareable public link. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
ca2150fc08 |
chore(devops): draft dedicated-fcrunner migration (thorough #1)
The stronger version of the blast-radius fix, beyond the InaccessiblePaths drop-in: run the box-runner as an unprivileged `fcrunner` that owns only its own dir instead of `ubuntu` (which owns every app's files). - scripts/hetzner/migrate-box-runner-to-fcrunner.sh: creates fcrunner, copies the agent runtime (.claude auth + credentials.json, the claude CLI in .local, .npm, .gitconfig, runner token) from /home/ubuntu → /home/fcrunner (NOT .ssh), chowns the runner dir, and installs a systemd drop-in (User=fcrunner + HOME/PATH repointed + InaccessiblePaths hiding ALL of /home/ubuntu and every co-tenant /opt/<app>). --dry-run / --revert. Idempotent. Prints the claude-auth verification + creds-copy fallback. - deploy-hetzner.sh + install-box-runner.sh now honor FLEETCROWN_RUNNER_OWNER (default ubuntu, so no change until you migrate) — otherwise the per-deploy runner chown would silently revert ownership to ubuntu. - Apply guide updated with the migration steps + the coupling reminder. Still NOT applied. bash -n clean; dry-run verified against the box. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
12e6ec3fca |
fix(deploy): serialize deploys, add rollback + result sink
Addresses the DevOps panel's release-engineering findings on scripts/deploy-hetzner.sh:
- flock(1) serialization around the whole deploy — two near-simultaneous main
pushes each background a deploy; without a lock both run `next build` in the
shared .next and collide ("Another next build process is already running"),
and the older ref could win. Blocking lock (-w 900) serializes so the newest
ref ships last; every step is idempotent so waiting is always safe.
- Rollback: snapshot the current box build to app.prev (excl. backups) before
rsync; if the restart or post-deploy verification fails, restore app.prev and
restart — a broken ship no longer strands the box.
- Deploy-result sink: a trap on EXIT reports every outcome (success/failure) as
a final status line, a desktop notification, and a row in the box debug_logs
(source=deploy) so a failed background deploy surfaces on /system instead of
dying silently in /tmp with an exit code nobody reads.
bash -n clean; flock confirmed present. Not triggered against prod (would ship).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|