Section-chunking grew the index to ~669 chunks; embedTexts sent them in ONE
request, which overran the local embed server ("fetch failed") → 0 embedded.
Combined with deleting owned rows BEFORE inserting, that emptied the index.
- embedTexts pages requests (48/batch); a failed page nulls only its inputs.
- reindexer is insert-first, prune-after (pruneKnowledgeToIds); an embed outage
can no longer empty the index.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Push toward "useful even on a modest model": make the harness so good and so
robust that model quality matters less.
- Robustness: askLoki now treats an empty or "couldn't generate a response"
gateway reply as a failure (not just !ok) and falls back — so a flaky/thinking
model that emits no final payload never surfaces a broken answer as Loki's.
- Precision: chunkMarkdown splits essays into section-sized passages (h2/h3, then
paragraph) so retrieval returns the relevant passage, not a truncated 6k blob.
Reindexer re-chunks essays; deleteKnowledgeByTypes clears owned types first so
the index is a true mirror (no orphans from id changes / removed docs).
- Coverage: Loki's retrieved-detail now pulls a larger pool and caps chunks per
source, so a cross-project question gets breadth instead of six chunks of one
project.
Pure chunker unit-tested (32/32). tsc + lint clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ask: "everything I have, Loki should have." The RAG index held only project
dossiers + dev logs. Extended reindex-knowledge.ts to also embed:
• goal — every project's roadmap/task-list (title, description, %, milestones,
joined to its project) — the raw material for cross-project synthesis.
• thought — the published strategic essays, where the operator has written
down HOW the projects relate (three-layer thesis, the two halves) — so Loki
reasons about synergies from first-hand sources, not guesses.
Added "goal" to KnowledgeSourceType (free-text column, no migration).
Loki's retrieved-context block is now source-aware: each line is labelled by
kind + project (or essay title) — "[BiasLens · goal]", "[essay: The Two
Halves]" — and Loki is told to cite the [source], so it shows its work.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
askLoki injected zero project context — it sent the raw message to the gateway
with a generic system prompt, so Loki only knew what the shared OpenClaw agent
happened to remember. The fleet-knowledge RAG (pgvector) was wired into
dispatches, never into Loki chat.
Now every Loki turn prepends a read-only fleet-context block:
• BREADTH — a compact index of every active project (name, stack, description,
latest dev-log state) so Loki can answer across the whole fleet, not just
whatever RAG retrieved. (buildFleetIndex, pure + unit-tested.)
• DEPTH — top-K semantically-relevant chunks from knowledge_embeddings
(searchKnowledge / pgvector) scoped to the question — the dossiers + dev logs
reindexed this session.
Injected on both the gateway and Groq-fallback paths; best-effort (a failed
lookup degrades to plain Loki, never a broken turn). Pure index split into
loki-fleet-index.ts so it unit-tests without a DB (31/31).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closes the named trust gap (audit: "no pricing visible; looks abandoned or
confused about whether it's commercial"). Founder can't connect Stripe yet, so
the page is honest by construction: paid CTAs open checkout only when
isStripeReady(); until then every CTA routes to a free signup — no dead Buy
buttons — and flips live automatically when keys land, no code change.
- src/config/plans.ts: SSOT for tiers (free/personal/pro/team) deriving the
project limit from PLAN_LIMITS (lib/plan.ts, the only gate the code enforces).
Prices are the master-plan §7.2 anchors (CHF 15/40/90) — one edit to change.
Rich capabilities live in PRICING_INCLUDED ("every plan includes") rather than
faked as per-tier gates the product doesn't apply — honest by construction.
- src/app/pricing/page.tsx: responsive card grid, reuses ui-public-* classes,
works 320px+, semantic tokens only (no palette/hex).
- Wired into public nav (PUBLIC_NAV), footer Product group, and smoke.sh.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Dogfooding the shipped share feature on the box surfaced a dead link: the API
built the shared URL from req.nextUrl.origin, which behind Caddy is the internal
bind (https://0.0.0.0:4002). Every copied/opened/displayed share link was
unreachable. Build it from appUrl() (NEXTAUTH_URL) instead — the same canonical
base URL email links already use. authenticated-smoke now asserts SH03b: the
returned url is a public https link containing the token, never 0.0.0.0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- 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>
Realizes the /goal loop pattern for FleetCrown: a project declares what "done"
means and how many tries it gets, and the existing cross-model DoD judge loops
the fleet until the bar holds or the cap is hit — instead of stopping on the
agent's own say-so.
- dod-gate.ts: applyDoDGate gains an optional turn cap. Under the cap it still
downgrades success→partial (loop continues); AT the cap it stops downgrading
so the run keeps success (no gap → the continue-loop halts naturally) and
records the cap in `next` for the captain. Enforced entirely at the gate — no
continue-loop change. +7 pure test cases (12/12).
- getProjectGoalConfig sources definition_of_done + a new goal_max_turns attr
(clamped 1–20, null = loop until met = unchanged behavior).
- gateAndCloseRun uses per-project DoD + cap, counting consecutive prior partial
closes (from the outcomes the handler already fetched) as the turn count.
- POST /api/control/goal sets both attributes; GoalEditor (in the project
dossier Now section) is the UI to set/clear the goal + cap.
tsc + lint + design-system + dod-gate tests all green. On a branch (no deploy).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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>
Both prepared, NOT applied. Inert until you act — see
docs/development/devops-prep-apply-guide.md.
#1 — box-runner blast radius:
- scripts/hetzner/harden-box-runner.sh installs a systemd drop-in that makes the
co-tenant /opt/<app> dirs, /opt/backups, and /home/ubuntu/.ssh kernel-
inaccessible to the runner AND every agent PTY it spawns. Keeps User=ubuntu
(the claude CLI lives in /home/ubuntu, so no user migration needed). Safe: the
runner only touches its own dir + fresh clones under /home/ubuntu/dev, never a
co-tenant /opt (verified in box-workspace.ts). --dry-run / --revert supported.
- install-box-runner.sh bakes the same InaccessiblePaths into the unit for fresh
installs.
#2 — CI-gated deploy:
- .github/workflows/deploy.yml runs ONLY after CI succeeds on main, builds
(schema-only Postgres service), and ships via deploy-hetzner.sh --no-build so
the flock/rollback/verify logic carries over. A red CI → no deploy. Needs a
HETZNER_SSH_KEY secret; the local push-deploy hook must be disabled to avoid
double deploys (documented).
- scripts/setup-branch-protection.sh (opt-in, separate) requires the CI check
before merge — rejects direct pushes to main, so only for a PR-based flow.
bash -n + deploy.yml structural checks clean; drop-in dry-run verified.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses the Infra/SRE S2 "prod unit + Caddy blocks are handcrafted on the box,
unauditable and unrecoverable":
- scripts/hetzner/box-units/ captures the live fleetcrown-app.service and the
fleetcrown + bridge Caddy blocks (reference copies, with apply instructions),
so a disk loss doesn't take the only copy. Repo unit adds StartLimitIntervalSec=0.
- verify.sh now asserts the bridge SSE block stays `encode`-free (compression
buffers the stream → disconnect never fires → stale presence). Verified green
against the live box.
Ground-truth corrections from inspecting the box (memory was stale):
- Off-box backups are LIVE: pg-backup.sh pushes encrypted restic snapshots to
Backblaze B2 (b2:orangecat-restic), 6 snapshots, latest today, fail=0. The
panel's S1 "single-disk total loss" was based on a stale 'restic pending' note.
- Alerting is NOT dormant: HEARTBEAT_URL (healthchecks.io dead-man's-switch) is
set and the watchdog timer is active. Telegram push is optional-not-wired.
- Caddy SSE: the load-bearing bridge block is correctly encode-free (deliberate,
commented); the 4002 app encode is an intentional keep (compressible pages +
flush_interval -1). Lower risk than flagged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses the Infra/SRE + Security panel findings that don't need box access:
- gen-env.sh stripped only ONE trailing literal \n; the prior secret-corruption
incident (broke all email + the private-zone PIN) had MULTIPLE embedded \n.
Now strips all \n/\r sequences and real CR/LF anywhere in a value. Verified
against the multi-\n case.
- StartLimitIntervalSec=0 on the generated app units (sync-infra.sh) and the
embeddings unit (install-fleet-rag.sh) so a crash-loop keeps retrying instead
of locking to "failed" until a manual `systemctl reset-failed` — the observed
historical failure mode. (box-runner already sets it.)
- RandomizedDelaySec=300 on the fixed-time timers (app-crons, pg-backup,
reindex) so the herd of 08:00/02:30/03:30 jobs doesn't fire builds+curls
simultaneously on the shared 8-vCPU box.
These take effect on the next install/sync of each unit. bash -n clean.
NOT done (flagged — needs your input): MemoryMax/CPUQuota needs real usage
numbers to avoid OOM-killing legit builds; the dedicated box-runner user
(fcrunner + secret broker) is a box migration that could break the always-on
builder — both are box-apply changes deferred to your review.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses the Test/Quality panel finding that only ~12 of ~32 test:* scripts
ran automatically and a newly-added test:* was born dead (never in CI):
- scripts/test-unit.ts globs scripts/test/*.ts and runs every pure test in
parallel. New pure tests are picked up for free. Infra-dependent tests are
skipped with an explicit reason (server/DB/Groq/embeddings). Classification
was verified under true CI conditions (.env.local hidden + dead DATABASE_URL,
since dotenvx otherwise injects a live DB and masks the dependency): 29/29
pure tests green, 6 correctly skipped.
- ci.yml and .husky/pre-push both now run `npm run test:unit` (+ test:home), so
a green push and a green CI run the same suite and can't diverge.
- Runner avoids top-level await (tsx→CJS rejects it), uses the local tsx bin at
concurrency 2 (esbuild-friendly on a 2-core box), and handles spawn errors.
NOT done (needs your decision — flagged): required-status-checks branch
protection would REJECT direct pushes to main, breaking the push-to-main-deploy
flow, unless the deploy also moves into CI (needs the box SSH key as a GitHub
secret — your call). `next build` in CI still needs a Postgres service to
pre-render; deferred (deploy-time build + the new rollback already gate it).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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>
Realizes the message-taxonomy lesson from Anthropic's multi-agent orchestration
model: agents already agreed to echo a {type, status} schema in message bodies,
so lift `type` (task|result|question|escalation) and `status` and render `type`
as a coloured ui-tag in the comms feed — escalation negative (captain can't miss
it), result positive, question warning, task accent.
Extraction is a targeted regex over the two constrained fields (KISS — no
full-JSON parse), tolerant of pretty-printing and prose, and the body stays SSOT
(payload is not stripped). Degrades to no badge when a message carries no schema.
Verified against the live inbox: the t0-handshake result shows type=result
status=done; prose messages show none. +7 test cases (23 total).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Grounded the comms parser against the real ~/.claude/cross-project/inbox-*.md
files, which surfaced three defects in the shipped version:
- `---` message delimiters leaked into message bodies (feed noise). A rule
line now closes the current message instead of being appended.
- Plain `Re:` subject lines (not just `**Re**:`) were dropped into the body.
Both forms are now parsed.
- The dedupe id `from->to@ts` collapsed distinct same-day messages when a
header carried a date with no time. The id now includes a content hash, so
distinct bodies stay separate while byte-identical copies still dedupe.
Moved the pure parser out of the HTTP route into src/lib/agent-comms.ts
(SoC + testable), re-exported the AgentMessage type there as SSOT (AgentsCockpit
now imports it), and added scripts/test/agent-comms.ts (16 cases, inline
assertions per house convention) + a test:agent-comms npm script. Verified
against the live inbox files end-to-end.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pre-push prod dogfood and headless dogfood scripts source .env.local so
git push runs the full prod suite without exporting the PIN manually.
Co-authored-by: Cursor <cursoragent@cursor.com>
Expose GET /api/memory/rag-stats for ME02 smoke, add local-builder
open-tabs/peek probes when Fleet Runner is connected, and skip machine
dogfood cleanly when only the cloud builder is online.
Co-authored-by: Cursor <cursoragent@cursor.com>
Extend Loki dogfood to verify the Terminal This computer shell after
dispatch, and grade X05 as partial when Fleet Runner is not connected.
Co-authored-by: Cursor <cursoragent@cursor.com>
Extend the opt-in pre-push prod dogfood path to include authenticated smoke,
verify goal-card dispatch when a builder is online, and document manual
runbooks for third-party flows.
Co-authored-by: Cursor <cursoragent@cursor.com>
Run ui-flow-dogfood on every push with SMOKE_PRIVATE_PIN; run loki dogfood
only when the builder is online (or DOFOOD_LOKI_ON_PUSH=1).
Co-authored-by: Cursor <cursoragent@cursor.com>
Add headless Playwright dogfood covering Ask Loki from card, habit
heatmap, goal Control prefill, prompt fork, and Run with Loki modal.
Co-authored-by: Cursor <cursoragent@cursor.com>
Add X01–X09 API probes to authenticated smoke (97 total), print-session-token
helper, dogfood:loki:ci with JWT mint, and grade execution flows in the audit doc.
Co-authored-by: Cursor <cursoragent@cursor.com>
Round-trip POST/PATCH/DELETE for people, goals, habits, events,
subscriptions, and prompts when SMOKE_PRIVATE_PIN is set. Updates
user-flow-audit checkboxes (89/89 on prod).
Co-authored-by: Cursor <cursoragent@cursor.com>
Claude Code writes live per-PID status to ~/.claude/sessions/<pid>.json
(status idle|working, cwd). Three fixes hang off it:
- Dispatch verify: isPtyBusy was fooled by boot-screen redraw — on a
fresh clone the trust-folder dialog ate the injected paste and six
agents were acked 'launched + injected' while idle at an empty
composer. waitForAgentGenerating() now polls the CLI's own status
(fallback to isPtyBusy for agents without live status files) and
re-injects once when verifiably idle.
- Pusher lifecycle: readFastState synthesizes the direct_terminal
observation from live status, so headless PTY agents mid-task read
as Working instead of 'process detected, no lifecycle signal'
(the producer the presenter test always described but nothing built).
- Deploy hardening: the restart ssh runs under timeout 180 +
keep-alives after hanging 47 minutes post-restart and freezing the
deploy before verification and the runner sync.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Dogfood session drove FleetCrown against production and found the fleet
had been silently dead for 2 days behind a green light:
- nudge-idle raw-queried beacon_settings WHERE mode != 'off', so users
with NO row (missing row = default 'on') were invisible to the
scheduler — autopilot dispatched nothing while the hero said
'Autopilot on'. New SSOT getFleetAutopilotUserIds() decides
enrollment for schedulers; missing rows count as on.
- The stale-run reaper only ran on /api/control page loads: 16 runs sat
'waiting' for 51h until a human looked, then got stamped with
fabricated 51h durations. New hourly reap-stale-runs cron reaps all
users; finishedAt = startedAt + STALE_RUN_MINUTES (truthful).
- Hero headline was mode-derived ('Building' + pulsing green with 0
working and 16/16 failed runs). deriveFleetPulse() (pure, tested)
now derives Building / Waiting to dispatch / Stalled(+Review
failures link) / Paused from live counts + latest outcomes.
- OutcomeStreak ✗ glyphs were unlabeled dead-ends; the streak now
deep-links to /activity?window=week&project=<key>.
- box-runner logged 'connected · last poll 0s ago' every 2s to journald
(~40k lines/day); now logs on state change + 15-min heartbeat.
Presenter tests 25/25 (6 new fleet-pulse cases).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Closes the two operational gaps in bridge Parts A/C (FC master plan
Phase 0.4/0.5):
- /api/crons/orangecat-promote-backfill re-emits project_published +
recent devlog promotes for every OC-linked project daily (09:00 UTC
timer added to install-hetzner-crons.sh). Deterministic external ids
make re-posting idempotent — 'best-effort must not mean silently
lossy' is now true.
- promoteMomentToOrangeCat/promoteDevLogEntry return a PromoteOutcome
so the janitor can count posted/skipped/failed (user-action call
sites still fire-and-forget via void).
- Settings → Account gains a Connect OrangeCat row for existing users
(env-gated like the sign-in button); links via the same OIDC flow,
which also unlocks Publish to OrangeCat.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Wrap the dispatch-footer wait in a non-throwing gotDispatch check (local +
prod paths). On timeout, record a high-severity weakness and a timeout
screenshot instead of throwing on waitForSelector, so a hung Send produces a
report rather than aborting the whole run. Also force-click the owner-key tab
with a bounded timeout. (Concurrent-session edit, committed to keep the tree
clean — see pattern-concurrent-autopilot-worktree-race.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
npm run dogfood:self drives Control → Loki "Move forward" → Terminal Cloud →
Projects against local or prod (fleetcrown.orangecat.ch), screenshots each
step, and emits a weakness report. Mirrors dogfood:loki (same playwright/
chromium convention, undeclared dep shared by both — tracked as follow-up).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cloud inject always queues even when box-runner is connected; distinguish
runnerConnected in Loki footer, Control toasts, and dispatch-status SSOT.
Add prod dogfood script and dispatch-status tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
Browser-first onboarding and executor-copy SSOT; Loki imperatives and move-forward
route to the same builder queue as Control with cloud-first Terminal links; fleet-kick
queues when offline; deploy script syncs box-runner.
Co-authored-by: Cursor <cursoragent@cursor.com>
Add Build/Pause selected on Control, multi-project command fan-out in Loki,
and route scoped screenshots to dispatch with vision preflight instead of chat.
Co-authored-by: Cursor <cursoragent@cursor.com>
Start building now batch-dispatches next_best on eligible idle projects
(capped at three concurrent) and Loki accepts develop-all phrasing; restore
the daily idle nudge for users with autopilot on after the mode collapse.
Co-authored-by: Cursor <cursoragent@cursor.com>
Route shell FAB and loki:open to /loki with composer prefill; retire the
chat-only modal. Add fleet list/create NL fast paths, project picker chips
for ambiguous dispatches, and a db helper to inspect recent conversations.
Co-authored-by: Cursor <cursoragent@cursor.com>
Merge SLH into surf-your-life on prod, drop orphaned box DB, remove SLH from
hetzner manifest, and wire Bitbaum user_projects dir for local dispatch.
Co-authored-by: Cursor <cursoragent@cursor.com>
Merge Cockpit and empty dupes into canonical entities, delete infra/stub
rows, and ship retire-stale-projects.ts plus merge helpers for future hygiene.
Co-authored-by: Cursor <cursoragent@cursor.com>
Re-ran enrich-prod-profiles against Hetzner — 16 projects now have
architecture/conventions/DoD. Add Groq retry for transient fetch failures.
Co-authored-by: Cursor <cursoragent@cursor.com>
Surface fleet-knowledge chunk counts on /memory, document box RAG ops via
install-fleet-rag.sh, and add rag-retrieval test script. Reindex on production
already active (24 chunks across 21 project profiles).
Co-authored-by: Cursor <cursoragent@cursor.com>