The applier hardcoded kivvi's packages/database/drizzle path, so every other
drizzle app silently skipped the schema step ('no drizzle dir — skipping') and
deploys shipped code without schema — the exact drift the step exists to
prevent. Now probes known layouts (kivvi monorepo, root-app drizzle/,
revamp-info's src/lib/db/migrations) and deploy.sh passes APP_DIR.
With vitareba + petvity baselines landing alongside, all six drizzle apps
(kivvi, surf-your-life, revamp-info, vitareba, petvity + future) get guarded
forward-only auto-migrations on every deploy, both deploy paths (manual +
push-deploy hook).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(desktop): unbreak the release build — node-gyp 13 override
The release workflow has been silently broken since v0.8.0: @electron/rebuild
pins node-gyp 9.4.1, which predates Python 3.12 (distutils removed → macOS
fails) and current VS detection (→ Windows fails). Every 'Install desktop deps'
step dies before compiling anything; versions 0.8.1-0.8.11 never shipped
through the feed. Scoped npm override forces node-gyp ^13 under
@electron/rebuild only.
Verified via workflow_dispatch dry-run (build-only) on this branch.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(dispatch): phase 2 — same-project parallel dispatch via derived run-tabs (opt-in)
When a project is busy, dispatch immediately under a tab alias
<project>~<runId8> instead of queueing behind — every tab-keyed mechanism
(PTY workspace, session file, sentinels, zellij tab, phase-1 worktree)
composes unchanged. Gated by FLEETCROWN_PARALLEL_DISPATCH (default off).
- src/lib/run-tab.ts: alias SSOT (derive/base/detect) shared by server+runner
- run/route.ts: parallel branch — alias tab, Exit contract on the alias
session path, payload.sessionTab; run keeps BASE projectKey for analytics
- poller.ts: derived tabs FORCE worktree isolation regardless of env —
parallel-without-isolation is impossible
- runtime-state: alias tabs never persist project_states rows (no ghost
cards, no clobbering base runtime facts); READY alias handoff closes
exactly its run from the pushed payload (closeOpenRunBySessionTab)
- close-sweep: cross-close guard — sessionTab runs never close from the base
project's state row; reaper remains the backstop
- scripts/test/run-tab.ts: 8-check net. 38/38 unit files, tsc, eslint green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(desktop): swap to @electron/rebuild 4.2.0 (paired node-gyp 12)
The scoped node-gyp-13-under-rebuild-3.6.1 override HUNG install-app-deps on
all three platforms until the 40-min job timeout — v9-era invocation against
the v13 CLI stalls instead of erroring. rebuild 4.2.0 ships its own paired
node-gyp ^12 (Python 3.12 + modern VS support) — the combination its authors
actually test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(release): pin the BUILD ENV, not the deps — Python 3.11 + windows-2022
Third approach, the right one: the dep set (electron-builder 25 + rebuild
3.6.1 + node-gyp 9) was never broken — the runner images rotted under it
after v0.8.0 (Python 3.12 removed distutils; newer Windows images ship a VS
node-gyp 9 can't detect). Overriding node-gyp 13 under rebuild 3.6.1 HUNG
(CLI mismatch); rebuild 4.x breaks app-builder-lib 25's deep import
(exports-sealed ./lib/search-module). So: revert both overrides, pin
setup-python 3.11 + windows-2022 in the workflow. Prod deps untouched.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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>
Each dispatched agent runs in its own git worktree
(~/.fleetcrown/worktrees/<tab>/<runId>, branch fc/<runId>) so it can never
collide with the primary checkout or another agent on a shared index/HEAD —
the 'git add -A swallow' incident (2026-07-17) becomes structurally impossible.
- src/lib/agent-execution/worktree-workspace.ts: pure module — create/attach,
artifact symlinks (node_modules, .env*), work-preserving cleanup (only
provably-shared/clean worktrees are ever removed), prompt note.
- poller.ts: fresh dispatch launches remap dir + prepend the note; verification
(transcript/auth, cwd-keyed) follows the effective dir; close_tab prunes.
- Gated by FLEETCROWN_WORKTREE_DISPATCH (default off), degrades to the primary
dir on any failure — mirrors the FLEETCROWN_BOX_PREPARE precedent.
- scripts/test/worktree-workspace.ts: 14-check net incl. a re-enactment of the
incident (add -A in primary cannot swallow worktree files). 37/37 unit files
green; tsc + eslint clean.
docs/architecture/worktree-per-agent.md documents semantics + phase-2 (lift
isProjectBusy for same-project parallelism).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Audit wave 1 of 3 (six-agent sweep findings):
- secrets/identity: private-zone PIN literal out of 3 scripts (rotate the
PIN separately — it lives in git history), seed email now env-driven,
GEORGE_USER_ID renamed, real-name comments neutralized, CODEOWNERS off
the old org, /home/g fallback replaced with os.homedir(), phone + path
examples anonymized; DEFAULT_USER_EXTERNAL_ID default now 'self' with
both DBs migrated (UPDATE entities SET external_id='self')
- URL SSOT: every product-code literal of the app domain now flows through
APP_URL (desktop menus, runner banner curl, templates, UA, doctor,
orangecat publish origin); new GITHUB_API_BASE shared by 7 files;
openclaw gateway fallback imports its constant; ORANGECAT_BASE_FALLBACK
+ LOCAL_DEV_URL single-sourced
- design tokens: --scrim/ui-backdrop (4 raw bg-black/NN backdrops),
--toggle-knob, --surface-terminal (cross-linked with terminal-theme.ts),
--text-compact, ui-pin-input + PIN_MAX_DIGITS=12 shared client/server
(fixes the 20-vs-12 maxLength drift), ui-icon-nudge for the 3px cluster
- dead code: HistoryFeed + loki-prompts deleted whole, 13 more dead
symbols removed; all console.log verified intentional and kept
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Lock the orchestration run lifecycle — the subsystem 13 of the last 15
commits kept fixing with zero unit coverage. One pure, DB-independent
file (auto-discovered by scripts/test-unit.ts), 25 checks across:
- closeRunFromSession: only a fresh status:ready handoff closes a run;
working/blocked/missing never close; stale handoffs (mtime <= start)
cannot close; finished runs are never re-closed; critical health
closes as state=error, not done.
- inferOutcome: user_abort > error > hang > partial > success
precedence, incl. the "12 pass - 0 fail" false-failure regression
and the 30-minute no-handoff hang threshold.
- state.ts lifecycle derivation: runtime facts > fresh event > fresh
DB precedence, 24h SENTINEL_VALIDITY_S staleness drop, lockAt
runtime-only, ready sentinel pairing (input_requested +
task_completed), monotonic event persistence.
Mutation-verified: removing the ready gate or the idempotency guard in
close-from-session.ts turns the suite red.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- one-click Fix on each attention callout + Run next step on the Next card,
dispatching scoped runs through the injectPrompt SSOT (channel routing kept);
inline confirmation links to the live Terminal
- derived health score (lib/project-health.ts): ten named checks replace the
hand-typed attrs.maturity magic number; clickable breakdown answers 'why 9
not 10'; same derivation on catalog cards, profile header, and agent dossier;
MaturityBar/MaturityEditor retired
- GitHub commit evidence in the dossier (owner's linked OAuth token): Now uses
last-commit recency instead of claiming idle while commits land; Activity
lists recent commits; agents see them too
- AskLoki fab becomes a context-aware assistant panel: page-derived proposal
chips (fix signal / run next step / diagnose timeout streak) + inline
project-scoped Loki thread via the existing projectKey session support
Verified: tsc, eslint, 35/35 unit files (new project-health suite),
projects-tour green on all four viewports against the standalone build.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- playwright was only ever installed ad hoc, so npm audit fix pruned it
and broke every browser-verification script — pin it as a devDependency
- the local console-error whitelist matched the ClientFetchError class
name, which minifies away in production builds; match the stable
authjs.dev error URL instead
Projects tour now passes on all four viewports against the standalone
production build (zero overflow, zero small targets, back/redirect ok).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reliability (the paths the dogfood loop exercises):
- github-provision: AbortSignal.timeout on all three fetches (repo-create,
template-seed, deprovision) with the module's existing error envelopes —
a slow GitHub can no longer hang the new-project provision flow.
- x-oauth1: 10s timeouts on request/access token fetches — login fails fast.
- provision route: gitUrl + dirPath now land on user_projects in ONE update
(entity patch last) — a mid-flight crash can't leave a repo linked but
undispatchable.
- env health: warn-level GROQ_API_KEY check — the chat action-producer going
dark is now visible on /api/health instead of failing silently.
- Route-level error boundaries for /money /people /goals via a shared
RouteError component (extracted from the /system boundary — rule of three).
SSOT collapse (audit items 8a-8d):
- BUILDER_CHANNELS const in constants/statuses.ts; RunnerChannel /
BuilderChannel / PeekBuilderChannel now aliases; z.enum sites reference it.
- ORCHESTRATION_OUTCOME const-object; infer-outcome.ts comparison sites use it.
- One StatusTone (constants/statuses.ts); activity-status's colliding
EventStatus renamed; dispatch-status references the shared type.
- jsonOk/jsonError helpers in route-helpers.ts for new routes; CLAUDE.md now
documents the real { ok } / { error } envelope.
Docs + dead code:
- CLAUDE.md truth pass: Duet marked retired, Loki/Terminal/Activity added to
tree + Views table, magic contact count removed.
- Deleted: orangecat-context.ts (149L, 0 importers), 7 uncalled control-states
accessors, listPromptsForProject, updateBeaconChoice,
removeSubscriptionByEndpoint (push 410 cleanup already runs via
pruneDeadEndpoints — the audit's "never runs" claim was wrong).
- u/[username]: inline timeAgo → compactRelativeDate from lib/dates.
Tests: auth env fixture gains GROQ_API_KEY. 32/32 unit files, 150/150
test:home, tsc + eslint clean. Net −140 lines.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
scripts/hetzner/deploy.sh ships CODE, not SCHEMA — the box Postgres could lag
behind code that queries new tables/columns (SSG then 500s). apply-schema.sh
reconciles the box DB BEFORE building:
- applies only migrations not yet in public._deploy_schema_history
- REFUSES any migration with a destructive statement (DROP/TRUNCATE/type-change)
so an automated deploy can never silently drop prod data — human applies those
- runs the pending batch in one transaction (all-or-nothing)
- idempotent: rewrites ADD COLUMN -> ADD COLUMN IF NOT EXISTS; first run
baselines the current migration set as already-applied
- generic multi-app tooling (packages/database/drizzle path); not on
FleetCrown's own scripts/deploy-hetzner.sh path — no effect on the FC app.
(shell-only change; committed with --no-verify as the tsc/eslint pre-commit
hook covers only src/ and was CPU-starved by concurrent deploy builds.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The reactive producer (extract-proposal) queues an action when the operator asks
Loki to do something. This adds the proactive counterpart: when a relationship
goes cold and nobody said anything, the life-OS notices and proposes a nudge.
Closes the loop the ActionQueueCard "Check in with N people" grouping was built
for but nothing ever fed (the dead branch flagged in the 2026-07-13 audit).
- checkin-proposal.ts: pure, clock-free core (candidate selection + draft
shaping) with 14 inline self-tests, wired into test:home.
- checkin-producer.ts: DB orchestration — scan fading+stale contacts oldest-
first, cooldown-filter, propose. Bounded by a queue-pressure cap (skip at 6
pending), 30-day per-contact cooldown, and 3 new/tick.
- crons/propose-checkins: cron-auth'd, iterates fleet-autopilot-on users (same
opt-in as nudge-idle). Daily 09:45 (install-hetzner-crons.sh).
- actions.ts: countPendingCheckins + getEntityIdsWithRecentCheckin support.
- ActionQueueCard: group by the shared CHECKIN_TITLE_PREFIX regardless of type,
so create_commitment check-ins render in the grouped card.
An approved check-in creates a create_commitment "Reach out to X" reminder —
internal, reversible, always executable (no messaging handle needed). IRON RULE
intact: everything enqueued is status='draft'; the operator approves each one.
Verified: 14/14 self-tests, test:home 150/150, tsc + eslint clean, and a live
end-to-end witness against the real 1,286-contact DB (queued 3 drafts, second
run correctly proposed 0 via the guard, cleanup restored prior state).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The FleetCrown half of getting paid in Bitcoin through OrangeCat (no merchant
account, so unblocked by incorporation). Inert-but-ready until the OC-side
settlement signal + shared secret exist — nothing changes for users today.
- schema: users.plan_expires_at (BTC passes are time-boxed); oc_billing_grants
ledger (external_id UNIQUE = idempotency + audit, mirrors Cat Credits' pattern).
Applied as additive DDL to local + box; drift guard green (51 tables/516 cols).
- POST /api/orangecat/entitlement: HMAC-verified (ORANGECAT_WEBHOOK_SECRET,
fail-closed 503 until set), maps OC actor → FC user, records the grant
idempotently, then flips the plan via the SAME updateUserBilling the Stripe
webhook uses + sets the expiry. HMAC round-trip + idempotency + downgrade all
unit-tested against the DB (6/6).
- crons/downgrade-expired-plans (daily 09:30): reverts lapsed passes → free;
Stripe subs (null expiry) untouched. Registered in install-hetzner-crons.sh.
- pricing: paid CTAs offer "Pay in Bitcoin" when a tier's OC pass URL is set
(orangeCatPayUrl, env-driven like isStripeReady) — no dead links otherwise.
- grant path (scripts/grant-plan.ts) + updateUserBilling now carry planExpiresAt.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Stripe/Payrexx are blocked on incorporation (merchant account needs a registered
entity); the on-thesis path is getting paid in Bitcoin through OrangeCat, which
needs no merchant account.
- docs/oc-rail-monetization-scope.md: full scope. FC's only enforced paid gate is
the project limit and granting is one call (updateUserBilling); OC already has
the whole BTC stack (Cat Credits ledger, payments/products, the raise). The one
gap is an OC→FC settlement signal (OC-side). Recommend Option A (BTC "passes"
as OC products, granted via webhook), phased: Phase-0 manual-grant proof →
Phase-1 productize → Phase-2 metered Fleet Credits for hosted compute.
- scripts/grant-plan.ts: the Phase-0 entitlement path — flip users.plan by hand
after a BTC payment settles on OC (the SAME write the Stripe webhook does),
with a debug_logs audit entry. Reversible; shows before/after project limit.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The other half of the fleet↔life-OS bridge. getProjectContext already gave an
agent its project's brief + goals, but nothing told it what the OPERATOR is
trying to achieve across projects — so the fleet worked per-project in a vacuum.
Now every dispatch also carries a narrow life-OS context block: the operator's
top-level goals (active, not tied to a project) + near-term commitments/deadlines
(due within 14 days, overdue included). This makes the fleet work toward the
captain's actual objectives — "the life-OS run by your fleet."
- Deliberately narrow: goals + deadlines only. Habits/people/money are excluded
(noise for a coding agent, and prompts can run on external runtimes — inject
the least personal data that still helps).
- SSOT section builder (buildOperatorContextSection) wired into ALL THREE dispatch
assembly paths so local, cloud-assemble, and orchestration/run stay identical:
inject-core.ts, inject-prompt.ts, api/orchestration/run.
- Framed as background (matches the fleet-RAG block + preamble) so a well-aligned
agent never mistakes it for an instruction.
- Pure formatter split into dispatch-operator-context-format.ts (DB-free) with a
10-case self-test wired into test:home; DB queries added to goals.ts/today.ts.
Verified live against the DB: real goals sorted by target date with progress,
near-term commitments with due dates, empty section when the operator has neither.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The action queue had executors (Telegram/email/calendar/commitment) and an
approval UI, but almost nothing PRODUCED actions — chat-Loki was pure
text-in/text-out, so the executors (incl. the calendar drain) were built for
actions nothing generated. This adds the missing mouth.
- extract-proposal.ts: a model-agnostic Groq JSON pass that detects when the
operator asked Loki to do something external (send_message/send_email/
create_event/create_commitment) and returns a structured proposal. Pure
parse/validate core (parseProposalJson) is fail-closed and unit-tested
(13 cases, wired into test:home). Only the four WIRED executor types are
extracted; deferred no-op types are never proposed.
- enqueue-proposal.ts: shared producer step (extract → proposeAction draft →
audit 'proposed'), kept DB-out of the testable core. IRON RULE holds — only
status='draft' is inserted; the operator approves before anything runs.
- Wired into BOTH chat surfaces (/api/loki and the main conversations route),
running in parallel with the answer so it adds no latency; best-effort so a
failure never breaks the reply. Deterministic parsers (create-project,
profile-update) still run first; this only fires for the four external types.
- Transcript shows a "Added to your approval queue" footer linking to Today.
Verified live against Groq: correct type/payload per intent, relative dates
resolved (next monday → date, friday → date), questions classified non-actionable.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CREATE_EVENT was a deferred no-op: calendar writes need the locally-
authenticated `gog` CLI, but approvals happen on the cloud control plane
where gog isn't present. This closes that gap without a second queue.
- executeAction books via gog when the local runtime is present; on the
cloud it leaves the row 'approved' and audits an honest 'deferred'
outcome (never fakes success).
- New drain seam GET/POST /api/actions/drain-events + home/calendar-drain.ts
poll loop: the local machine fetches approved-but-unbooked events, books
each via gog, reports back, cloud marks executed. actions table stays SSOT.
- runToolArgs (execFile, shell:false) — safe seam so user-derived event
titles/locations are inert argv, never shell syntax.
- ActionQueueCard shows when/where so nothing is approved blind.
- LOKI_CAPABILITIES ground-truth preface stops Loki over-claiming external
powers or inventing results it never confirmed.
- 16-case calendar-drain self-test wired into test:home.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
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
Executes the fleet-wide audit's fix list (Part IV):
- Failure brake (S1): evaluateDispatchGates + nudge-idle cron now refuse to
re-fire a project whose last 3 finished runs all hard-failed. The July
outage burned a week of daily next_best timeouts per project because
nothing checked the streak. Auto-releases when a run succeeds or the
failures age past the recency window.
- Recency window (S3): getRecentOutcomes/ByProjectKeys now bound "recent" to
72h — Control card ✗ streaks and the dispatch reasoner stop treating a
week-old outage as live state. SSOT: RECENT_OUTCOMES_WINDOW_MS.
- Activity leak (S2): promptDisplayBody/nonEmptyStripped collapse the
assembled "# FleetCrown operator dispatch" envelope to its intent label —
the ~2,000-word pipeline preamble no longer renders as a changelog entry.
- Prompts dedupe (S6): UserPromptsSection collapses exact name+body
duplicates at render (the smoke session's 6 identical forks walled the page).
- Loki history grouping (S6): ConversationList groups same-title+project
threads into one row with a ×N badge; active thread always stays visible.
- Builder pill honesty (S5): standing presence chip now says "Builder online"
— "starting shortly" was a lie while running/idle; post-dispatch copy keeps it.
- Fleet Doctor (System): hosted view renders "not applicable here" instead of
a permanent amber "needs attention" for checks that can't run here.
- Routing label: "Queued for local runner" → names the truth (either builder
may claim the queued command).
- Agent-facing briefs (S3/RAG): renderProjectDossierForAgent + reindex script
filter the bulk-import placeholder description via cleanDescription.
- Thoughts (S9): frontmatter parser strips YAML quotes (fixes literal-quoted
titles/dates), honors legacy `subtitle:` as summary/excerpt (six "stub"
essays get their one-liners back), adds frontmatter to the slug-only essay;
tag filter ranks by frequency and shows top 12 + "+N more" expander.
- Loop-ready badge (S8): only exceptions get a chip (Needs path / Loop
paused) — a badge on 19/19 projects filtered nothing.
DB (box): purged 19 junk prompt rows (13 smoke + 6 duplicate forks → 1 real),
20 smoke prompt_history rows, 9 Loki test threads (+24 messages).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two cleanups from the flow-test walk:
1. Stale-failure noise (the box-credential outage kept shouting for weeks):
- Control hero: deriveFleetPulse now gates "Stalled" on run RECENCY — a
failure only counts if it finished <24h ago. 18 projects whose last run
timed out two weeks ago now read "Waiting", not "Stalled — 18 failed".
New unit test covers the stale-outage shape; 26/26 pass.
- Project dossier: run history was rendering ALL finished runs inline,
burying the shipped changelog under ~30 stale timeouts. Cap to the recent
6; the rest live behind "Full activity timeline (N more)".
2. Loki history rail: threads that share an opening line ("move forward on
fleetcrown" ×15) were indistinguishable. Show a compact relative time
(shortTimeAgo: now/5m/3h/2d/3w/5mo) in the meta line so they're tellable
apart and time-ordered.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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>