mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 14:47:44 +01:00
feat/parallel-implement
80
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ef96be9b91 |
feat(projects): invite anyone into a project by email, account or not (#872)
Inviting a collaborator required them to already have a Loki account. The members route answered "No Loki account uses that email. Ask them to register first." — a dead end with no way to ask. The only other invite path creates a LOCAL-PASSWORD account and adds it to the inviter's whole org: broader than one project, and a second identity path beside OrangeCat, which fleet STACK.md says our own products must not grow. Now any email works: - Has an account: added at once, as before. - No account: a one-time invite is created, emailed when mail is configured, and ALWAYS returned as a link to copy — an email that was sent is not an email that was received. They open it, sign in with OrangeCat (creating that account on the way), and join exactly this project with exactly the role chosen. No Loki password anywhere. The link is bound to the invited email. A token is a bearer secret that gets forwarded; on its own it would let whoever holds the link in. The wrong account is told which address it was for, masked (ge•••@gmail.com) because the link may be in the wrong hands. Only a sha-256 of the token is stored, so a leaked backup cannot be replayed as working links. Acceptance spends the invite and grants the membership in one transaction guarded on accepted_at/revoked_at IS NULL, so a double click or two tabs grants once. Re-inviting the same email revokes the old link rather than leaving two live ones. "emailed" is only reported when mail is configured AND the send succeeded: sendEmail returns quietly when mail is off, so trusting the call alone would have claimed an email nobody sent. The panel moved from a collapsed "Editors" disclosure inside the Feedback tab to the top of the project's Settings tab — where every other product keeps "people with access", and where George looked for it. It now offers Editor or Viewer, lists pending invites, and lets the owner withdraw one. Editors do not see pending invitees' emails. The accept API lives under /api/invitations/project/ so it inherits the existing public-route exclusion instead of widening the proxy allow-list. Migration 0080 is hand-written, like 0073-0079: drizzle/meta's snapshot stops at 0072, so `drizzle-kit generate` diffs against a stale picture — it believes beacon_sessions still exists and calendar_busy does not, and would have emitted a DROP and a duplicate CREATE alongside this table. Tests: 14 checks on the acceptance rule, proved by mutation — removing the email binding turns the suite red. tsc clean, lint 0 errors, check:design ok, format ok, test:unit 260/260, test:home 130/130. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
0464358605 |
fix(orangecat): the wall went silent, and every link on it pointed at a login (#839)
* fix(orangecat): the wall went silent, and every link on it pointed at a login
Three failures on one seam, each invisible from inside Loki because the
symptom is on somebody else's page.
THE WALL STOPPED. OrangeCat rotated this account's refresh token at
2026-09-17 07:42:44 and issued a replacement that is still valid and was
never used; Loki kept presenting the one that rotation REVOKED at that
instant. Every refresh since answered 400, getOrangeCatLink returned null,
and every promote was skipped as "feature unavailable" — across every
project, for four days. The last entry to reach any OrangeCat wall was
posted eight minutes before that access token expired. The only trace was
66 console.warn lines on the box.
Verified by hashing the stored token and finding its row in OrangeCat's
oauth_refresh_tokens: revoked_at = 2026-09-17 07:42:44.
Three rules follow, none of them a repair: one refresh at a time per
account (the backfill cron fires up to 50 promotes at once, so a burst was
guaranteed to look like a broken link); a spent refresh token is never
written back (`?? account.refresh_token` reads as defensive and stores a
credential that can only ever fail); and a dead link raises an alert,
because re-linking needs a human click and nobody clicks what nobody sees.
EVERY LINK POINTED AT A LOGIN. Wall entries carried a hardcoded
`${LOKI_PUBLIC_ORIGIN}/projects` — the private dashboard. A stranger
following "via Loki" from Heidi's OrangeCat page got a sign-in form; the
owner got all 36 projects instead of the one the entry was about. Twelve
such links on that page alone. The right page has existed the whole time:
/fleet/<slug>, now derived exactly as the register derives it.
THAT PAGE WAS UNREADABLE ON A PHONE. Measured at 390px: 737px of roadmap
content in a 390px column, clipped by .ui-public-surface's own
overflow-x:hidden — 47% of every milestone line unreachable, no scrollbar,
no ellipsis. Cause: unbreakable GitHub URLs in prose. Fixed on the
ui-public-* prose tokens in globals.css, so it holds for every public page.
Also on that page: three of six "changelog" entries were internal dispatch
bookkeeping (two announcing a FAILED dispatch, stored truncated mid-word),
a `Source: <url>` provenance pointer rendered as an untickable milestone,
"0% recorded progress" under every item, and a raw ISO timestamp.
NO GATE COULD HAVE CAUGHT IT. audit-covers-every-page skipped every route
containing "[", so /fleet/[slug] — the template behind all 36 public
profiles — had never been measured at any width. Dynamic routes now take
the same decision as static ones: a concrete sample (/fleet/heidi,
/u/cato, one essay) or a line in NOT_MEASURED saying what it would take.
The overflow detector could not have seen it either — it reads
documentElement.scrollWidth, which the clip holds at the viewport width —
so there is a new one asking the reader's question: can I get to the rest
of this sentence? A listed route that 404s now fails, because a rotted
sample looks exactly like a covered route.
Two gates lied and are fixed with it: the audit's list parser ended an
array at the first "]" in a comment, and alert-registry read
`grant_type: "refresh_token"` as an unregistered alert type.
AND THE FEED IS NOW A CHOICE. Publishing did two things under one press:
it created the public page and enrolled the project in a live feed of
everything its agents did, with no switch — "stop telling everyone what my
agents are doing" cost you the funding page. user_projects.orangecat_autopost
separates them, three-state like auto_ship (null = nobody has chosen, and
an unanswered question is not consent). Reversible either way, without
touching the page. Already-published projects are backfilled to true:
introducing consent must not silently stop a feed someone relies on.
Left on, it is the strongest thing a public project page can carry —
dated evidence of work, which is the half of a transparency claim that
better copy cannot manufacture.
/fleet/[slug] also now reads CONSENT rather than ownership (it resolved any
slug in the owner's map, which the catalogue beside it has never done), and
a slug with no public profile gets an invitation instead of a dead end.
verify: tsc, lint (0 errors, 2 pre-existing warnings), test:unit 231/231.
The page itself is measured against prod after deploy — it cannot be
measured before.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(smoke): the pre-push gate blocked a push over another app's dev server
`/api/health` answering with a `"commit"` field was the whole identity test,
and every app in the fleet serves that route from the same template. On
2026-09-22 a Heidi dev server held :3000 first; Loki's 48-route auth smoke ran
against it, reported 23 routes returning 404, and failed the push — a verdict
about somebody else's app, delivered as a verdict about this one.
A name cannot be mistaken for another name: health now says which app answered,
and the hook asks for "loki" instead of for a shape. Additive to the payload,
so the deploy assertion, the uptime sweep and check-deploy-ref are unaffected.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
93a6e3e1f2 |
refactor(beacon): delete the popup, and gate the class of bug that hid it (#804)
The beacon popup was retired on 2026-06-11 ( |
||
|
|
a02d31d996 |
Every public claim matches the code, and two gates can now fail (#802)
* fix(truth): every public claim now matches what the code and the licence say The /license page forbade what LICENSE grants. #791 relicensed the repo to MIT and fixed LICENSE, the README and the Terms — but missed the page, which still said "source-available", listed hosting and repackaging under "you may not", and promised a replacement licence that had already shipped. On a public repo, that revoked rights we had granted. Same shape, five more places: - Three live /thoughts pages and four front-matters carried "Mao Nakamoto", the retired identity, into the rendered byline and the OG social card. - legal/ named that identity as operator, data controller and IP assignor, and assigned the work to bitbaum AG / orangecat GmbH / loki GmbH — none of which were ever incorporated. Rewritten as a record of authorship and the MIT grant, which is what is actually true. - The desktop About dialog and the installer copyright metadata shipped "© 2026 Mao Nakamoto" in every build. No audit pass had looked there. - /pricing and the feedback-widget docs said the report loop "closes itself" months after close-loop.ts deliberately removed auto-resolve for being untrue; resolve is an operator act and has zero call sites. - /roadmap claimed signed installers under "Shipping now"; no signing secret exists and /download says the opposite two pages away. - /releases claimed "every shipped version" while missing nine, and listed a 0.8.25 that was never tagged — its "Binaries →" link 404'd. Removed per the file's own rule: one entry per tag pushed to loki-releases. - desktop/README pointed all five install commands at bitbaum/loki, which 404s; releases publish to loki-releases. Version pin replaced with a glob so it cannot rot again. - DEFAULT_USER_NAME greeted nameless OAuth users as "Mao". And the two that lied to agents rather than users: CLAUDE.md claimed pre-push runs the full verify bundle so "green locally means green in CI", and AGENTS.md claimed pre-commit runs tsc. The hook's own header documents why it stopped doing both — a docs-only push runs nothing. An agent trusting either line would skip the verification it needed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(gates): close the two gaps that let deleted things keep passing Two gates could not fail, and one migration ledger had silently drifted. MIGRATION JOURNAL — 13 files missing, next db:generate breaks the deploy. drizzle/ held 78 .sql files; meta/_journal.json had 65 entries. Production was fine and always had been: apply-schema.sh globs the directory and keeps its own _deploy_schema_history, so it never reads the journal. But drizzle-kit does, and its newest snapshot was 0072 — so the next generate would re-emit 0073-0077, including CREATE TABLE "calendar_busy" with no IF NOT EXISTS. apply-schema.sh rewrites ADD COLUMN only, and the batch is one transaction, so the deploy would abort on a change unrelated to it. Reconciled to 78 via bootstrap-migration-ledger.ts --write-journal, and added scripts/test/migration-journal-coverage.ts so it cannot drift again: files vs journal in both directions, plus idx contiguity. Proven by mutation — drop one entry and it exits 1; restore it and it exits 0. SMOKE — every authenticated probe passed whether or not the route existed. The auth middleware answers 401 before routing, and check_route accepted 401 for everything in AUTH_API_ROUTES. Measured: /api/definitely-not-a-real-route returns 401 exactly like /api/orgs. So the list proved nothing, and /api/checkout/personal sat in it for 15 days after the Stripe rail was removed. A 401 now only passes if a route file actually resolves on disk (dynamic and catch-all segments included); the dead entry is gone, and all remaining probes resolve. Also: bumping desktop/package.json to 0.8.29, because the retired-identity fix in the previous commit touched desktop/src/main/index.ts and desktop-release- drift.ts correctly refused to let a shipped file change without a release to carry it. That gate was right and is the model for the two above. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
04cedba195 |
Loki's public face belongs to the tenants who agreed to be on it (#798)
* fix(setup): the documented local setup produced a broken app Followed README.md and .env.example exactly on a clean checkout and got an app that renders but cannot read a session. Three separate gaps, each on the documented path: - AUTH_TRUST_HOST was undocumented. src/auth.ts gates trustHost on it, and scripts/hetzner/gen-env.sh writes it on the box — but .env.example, the README's "minimum local .env.local", docker-compose.yml and loki-app.sh all omitted it. Unset, Auth.js answers EVERY /api/auth/session with 500 UntrustedHost. Verified: 500 before, 200 after, nothing else changed. The auth.ts comment claimed the local production server set it; it did not. - The compose db image has no pgvector. knowledge-embeddings.ts declares vector(384), so `drizzle-kit push` dies on the first table with `type "vector" does not exist` and leaves an EMPTY database — which reads like a broken checkout rather than a missing extension. Switched to pgvector/pgvector:pg17 and added an initdb script that creates it before the migrate service runs. - drizzle.config.ts never loaded .env.local, though a dozen scripts under scripts/db and scripts/test do. `pnpm run db:push` therefore threw "DATABASE_URL is required" at someone who had just set DATABASE_URL where the README told them to. An exported variable still wins, so CI and the box are unaffected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(projects): the empty state named a button that does not exist A new account with no projects is told to "Register your first project with 'New project' above". There is no "New project" control on the page — the button reads "Add", and the dialog it opens is titled "Add Project". The component file is called NewProjectButton.tsx, which is most likely where the copy came from. Found by signing up as a new user and following the onboarding instruction literally: the first thing the product asks you to do names a control you cannot find. Now says "Add", matching what is rendered. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * feat(fleet): a project reaches Loki's public catalogue only by consent /fleet is unauthenticated and speaks for the PRODUCT, not for a user. It resolved a single account — getSelfImprovementTarget(), "whoever owns the oldest entity named loki" — and published every project that account had. Two things were wrong with that in a multi-tenant product: 1. No decision was ever recorded. A project was on a public page because it existed. Every other public surface here already goes through getPublicProjects (the landing hero, /u/[username]); /fleet was the only one reading the unfiltered query. 2. WHICH account got published was a side effect of the self-improvement loop's notion of "which product am I improving". Reseed that entity and the next-oldest match's whole project list becomes Loki's front page. So consent is now a stored property of the project: - user_projects.listed_publicly, DEFAULT FALSE. The default is the point — signing up must never enrol a tenant in the product's shop window. - getPubliclyListedProjects() reads consent instead of ownership, across all accounts, which is also what makes the page meaningful with more than one user. /fleet no longer selects by owner at all. - A per-project toggle on the project workspace, beside the existing "Publish to OrangeCat" opt-in and reversible from the same control. - 0075 backfills the account publishing the catalogue today, so the live page is unchanged for it while everyone else starts at false. Also: FleetRegisterNote told EVERY account "19 sites are hosted on the box with no project here" — apps.conf describes one box and is a file in this repo, so a brand-new user was being told about sites they do not own. It now renders only for the account that operates that box. A user's own profile (/u/[username]) is deliberately untouched: that page is the user speaking about themselves, and it was already scoped. scripts/test/public-catalogue-consent.ts pins all of it — swapping the query back is a one-word change, and a comment cannot hold that line. Verified against a real database: consent false -> absent from /fleet, true -> present, toggled both ways through the UI. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * feat(public): what a signed-out visitor sees is a decision, not an accident Answers "whose projects does a stranger see on Loki?" — with three tiers instead of three different hardcoded owner lookups. THE PROBLEM. Loki is multi-tenant and the founder is tenant #1, but every public surface resolved an owner and published whatever that account held: - the landing hero → getHeroFleetSnapshot(getDefaultUser()) - /fleet → getSelfImprovementTarget() (fixed in the last commit) - the /projects note→ nothing at all Three answers to one question is three chances to be wrong, and the landing was the worst of them: it never consulted consent at all. Verified locally — a project with listed_publicly = false was rendering in the hero console. It also ordered by a hardcoded FLAGSHIPS = ["loki", "orangecat"], the ad-hoc version of "featured", which could only ever name the founder's own projects. The same list sat in /u/[username], where it reordered EVERY tenant's profile by two names they will never have. THE MODEL. src/db/queries/public-visibility.ts is now the one place that says what a signed-out visitor may see: 1. AGGREGATE — fleet-wide counts. Identify nobody, need no consent, and grow honestly as Loki gains users. 2. CATALOGUE — /fleet: projects whose OWNER opted in (listed_publicly). 3. SHOWCASE — landing hero: the catalogue narrowed to what the OPERATOR featured (featured_at). Curated space cannot be first-come. Two gates because they answer to different people: consent is the tenant's and may be withdrawn; featuring is the operator's editorial act. The showcase predicate is BUILT ON the catalogue predicate, so revoking consent drops a project off the homepage immediately even while it is still featured — verified all three ways against a real database. This is the doctrine site_feedback.featured_at already had ("raw visitor text NEVER auto-publishes"). Projects now work the way feedback already did. Featuring is authorized by isSiteOperator (users.is_default — the account made at /setup, so it means "runs this instance" for self-hosters too) and lives on its own query rather than riding patchProject, because it is the one project field a tenant must not set for themselves. It also refuses to feature a project whose owner has not consented. UI: two separate controls on the project workspace, deliberately not merged — "List publicly" (owner) and "Feature" (operator, shown only to them, and explaining itself when consent is missing). ALSO, from auditing the public pages at 320/390/768/1440: - /fleet had 19 sub-44px tap targets — every one the site address that is the whole point of the row, and the only sub-44px targets left on any public route. .ui-public-fleet-site was missing from the touch floor AND was an inline box, where min-height does nothing. Both fixed; now zero. - The responsive auditor EXCLUDED public routes, deferring to `smoke` "which already covers them" — smoke asserts HTTP status, which says nothing about a layout. So the pages a stranger sees first were the only ones with no responsive coverage. They are in the auditor now and need no session, so a session is required only when authenticated pages are requested. No horizontal overflow at any width, before or after. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(fleet): a phone spent a screenful on filters before the catalogue Measured at 390x844: the first project row sat at y=1020px. Four facet rows (Where / Kind / For / Missing) took 366px of that, so you scrolled past more than a screen of controls before seeing any of the thing they control — on a page whose entire job is to show a catalogue. The rows now live in a <details> that is collapsed below md and forced open from md up, so desktop is unchanged and the phone leads with content: first row y=1020 -> 699. The summary carries a count of active facets, because a filter you cannot see is one you forget you set — and then an empty result reads as a broken page rather than a narrowed one. <details> rather than state, because this page deliberately ships no JavaScript ("the address bar is the state") and a filter panel that needed a bundle to open would be the one thing on it that did. One trap worth recording: hiding the closed panel has to be EXPLICIT. The UA sheet hides a closed <details>'s children with display:none, but author styles outrank the UA sheet and .ui-fleet-facet-row is `@apply flex` — so the first version rendered a toggle that changed nothing, with the element correctly reporting open=false while all four rows stayed visible. Verified both states at both widths after the fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * feat(public): credit the builder, ask before publishing, stop renting the box Four things, all following from the same rule: Loki is multi-tenant, so its public face belongs to the tenants who agreed to be on it. 1. ATTRIBUTION. A showcased project now carries a byline — @handle linked to /u/[handle], display name when there is no handle, and NOTHING when there is neither, because a stand-in label is a name we would be inventing for somebody. Showing a tenant's work unattributed reads as "our projects", which is untrue and is the opposite of why a showcase exists; being credited and linked is also most of what a tenant gets back for consenting. Joined in the query rather than fetched per row. 2. LOKI ASKS. Consent was reachable only from a toggle nobody knew about, and a control nobody finds collects exactly one answer. The empty catalogue that follows is what gets "fixed" by widening the query again — the bug 0075 removed. So the project workspace now invites the owner once, and listing_prompt_dismissed_at takes no for an answer: per project (declining for a client build says nothing about the open-source one beside it) and in the database (a refusal that resets on a new device is a product that nags). The rule lives in src/lib/listing-invitation.ts, pure and unit-tested. The bar is repo + active, deliberately NOT a live URL: /fleet's own facets list "Being built" beside "Live", so requiring a deployment would ask only the projects that least need the exposure. 3. THE BOX IS NOT THE FLEET. apps.conf describes ONE box and is a file in this repo, and unmatched entries MINTED rows — so a Loki with one consented project still published 19 sites belonging to someone the viewer has never heard of. buildFleetRegister now takes includeUnlinkedSites, true only for the operator, for whom those rows are the entire point (the register read sideways is a to-do list). A hosted app still ENRICHES a project that exists, so a consented project keeps its real address either way; only row creation is gated, because only row creation publishes something nobody asked to publish. Verified: operator sees 20 projects / 19 sites, the public sees 1 / 0. 4. THE COPY. "This is the studio's whole catalogue" was true when one account was the whole fleet. It now says what the page is: projects their owners chose to show. Also, from re-auditing: .ui-public-fleet-name (the row's PRIMARY link) measured 21px tall on a phone. It had been invisible to every previous audit because while the page listed hosted sites alone, nothing in a row was a link at all — the fix in 3 is what made a real project row render and the gap appear. Same cause as .ui-public-fleet-site last time: the coarse-pointer floor sets min-height, which does nothing to an inline box. Every public page: zero horizontal overflow and zero sub-44px targets at 320/390/768/1440. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(home): the hero console had an empty third column Making the hero tenant-agnostic dropped "runs this week", because the old one counted getRecentOrchestrationRuns(userId) — one account's week, which is not a number a visitor should be shown. But the console's metric row is grid-cols-3, so removing it left a visibly empty third of the panel. Caught by looking at the rendered page rather than the diff. Restored fleet-wide, counted the same way as the other two: it is the metric that answers "is anything actually happening here", and an aggregate across every tenant identifies nobody, so it needs no consent and grows with the product instead of describing one account. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(footer): the studio's sites were labelled as Loki's fleet Every public page's footer lists 14 sites generated from apps.conf under "Part of the fleet — 14 more sites". apps.conf describes ONE box, the studio's, and several of those sites belong to clients — so on a multi-tenant Loki the label told every visitor that one account's client work was what Loki is. Same error as the /fleet lede, and the same fix: say whose they are. "Built by the studio" now, and the link beside it points at the tenants' catalogue by its real name rather than calling it "the whole register". Deliberately a COPY change and nothing more. The links themselves stay, all 14 of them: they are real work, several had no inbound link from anywhere before this block existed, and the cross-linking is the entire reason it is here. Removing them would trade a genuine asset to fix a sentence. Only the claim was wrong. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(home): the hero console looked broken with nothing featured 0076 deliberately does not backfill a feature stamp — featuring is an editorial act nobody has performed yet — so the live hero will really render with zero project rows until someone features something. I had asserted that was fine without looking at it. It was not. The bar carries mb-4 + border-b and the metrics carry mt-4 + border-t, so with no rows between them the panel drew TWO horizontal lines with 32px of nothing in between: the shape of content that failed to load, on the first screen of the product. The metrics now sit flush under the bar's own border in that state, which is a panel with nothing to list rather than a panel that broke. Verified in both states: with rows the divider is back and the flush class is absent. Not fixed by falling back to showing consented-but-unfeatured projects, which was the tempting option: the invitation asks permission for the public fleet page specifically, so putting those projects in the hero would take more than the owner agreed to. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(fleet): an empty catalogue told visitors to clear filters they never set With nothing listed, /fleet rendered "Nothing matches that. Clear the filters →" — to a visitor who had set no filters, offering a link that changes nothing. That is the FIRST thing a freshly self-hosted Loki ever says on that page, and it reads as a fault rather than an empty shelf. Two states now, told apart by `rows` (the whole catalogue, before the query) rather than `result.rows` (after it): nothing listed at all → says so, and says why: owners choose which of their projects appear, and nothing is published without them saying so. Links to what Loki does. filtered away → unchanged: "Nothing matches that" + clear the filters. Found by putting the local database into the state a new install starts in, rather than only the state mine happened to be in. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
eadad2711f |
feat(calendar): warn on the card when a proposal clashes (#777)
* feat(approvals): standing approvals + one-tap decisions from Telegram
Asking Loki in Telegram to put an appointment in the calendar did not put an
appointment in the calendar. It sent you to a website.
Three separate causes, all fixed here:
1. THE CHAT HAD NO ROAD TO THE CALENDAR AT ALL. `gog calendar create` is
blocked on the box by the safety shim, and the fleetcrown skill could only
decide drafts that already existed — it had no way to create one. So the
agent hit the shim, read "route it through the approval queue", and passed
that on as advice. Adds `fc.sh book`, which proposes a structured event
through /api/actions/propose, and rewrites the shim's refusal to name it.
The shim still blocks every external Google write; unattended agents have
gained nothing.
2. THE GATE WAS ON THE WRONG SIDE OF THE REVERSIBILITY LINE. The queue enforced
"nothing runs that the operator did not TAP", which is stricter than the rule
it stands for ("nothing runs that the operator did not APPROVE"). For an
event in your own calendar — private, self-only, undone by deleting it — the
difference was pure latency (2026-08-04: proposed 14:15, booked 21:02).
Standing approvals let that yes be given once, in advance, with three rails
in code rather than in a docblock: eligibility is hard-coded (calendar events
and commitments only — never anything that reaches another person), the
payload is re-checked at decision time (guests mean invitations, so those go
back to the queue), and unknown is never yes (no resolvable time, or a slot
already past, queues). Default on for calendar events; toggle at /approvals.
3. THE NOTIFICATION HANDED BACK A CHORE. "2 actions are waiting… <url>" states
a problem and leaves the answer behind a login. Decisions now arrive as a
card carrying what/when/where plus one-tap Approve / Reject / Edit buttons,
backed by HMAC links scoped to one action and one verb — so a decision needs
no session and works when the gateway is down. Still two messages and only
two: one when a decision is owed, one when the effect really happened.
Also fixes a real data bug: propose_action had no event date fields, so the WHEN
of an appointment had nowhere to go and arrived as prose in `body`, which a Groq
pass then had to guess back — a model re-deriving a value the model one step
earlier knew exactly.
Behaviour that did NOT change: emails, messages, dispatches, and person-book
writes still require a per-item yes, and always will — they are ineligible in
code, and a preference row naming one authorises nothing. Every auto-approval is
audited with `via: standing-rule` and announced, so nothing is done in the
operator's name silently.
Tests pin the parts that must not be trusted: 37 cases on the standing-approval
rails (asserted from the side that hurts — a false `auto: true`), 21 on token
forgery and tampering.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(chat-skill): the chat's whole Loki skill was dead, and unversioned
Found while testing the previous commit end-to-end, and it is the largest of
the reasons appointments never got added.
On 2026-09-14 the product was renamed to Loki and `calendar-drain.env`'s keys
were renamed with it. The chat agent's skill script, which reads that file, was
not — because it lived only on the box, where no gate in this repo could see
it. Since then every command it offers has aborted on its first line:
line 14: <OLD>_AGENT_TOKEN: <OLD>_AGENT_TOKEN missing in calendar-drain.env
Verified live on bitbaum just now. So from Telegram the operator could not list
the approval queue, could not approve or reject anything, and could not
dispatch — silently, because a skill that errors just makes the agent talk
about something else instead. The only surviving route to a decision was the
website. That is the complaint, and it had a cause older than the UX.
Fixes:
- Renames the skill to `loki` (the retired product name is forbidden in this
repo by scripts/hetzner/test-no-retired-name.sh — which caught this commit,
correctly, when the box files were first imported verbatim) and reads the
env keys the file actually has.
- The installer REMOVES the superseded skill directory rather than leaving it.
Two skills claiming the same job, one of which cannot run, is how the agent
kept choosing the broken one.
- The installer now runs `loki.sh pending` as the openclaw user and fails if it
cannot authenticate. That is the check which would have caught the rename on
the day it happened: run the thing, as the user who runs it, and require real
output. Every other verification in that script only asserted that files
exist, and files existing is exactly what was true throughout the outage.
Also closes a gap in the previous commit: an auto-approved COMMITMENT executed
without telling anyone, while the comments claimed every auto-approval is
announced. Calendar events are announced from where gog succeeds (asynchronous,
on the box); everything else finishes inside enqueueAction, so that is the only
place that knows it finished at all. A standing approval nobody is told about
is not a standing rule, it is a silent one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(install): keep the gog shim parseable, and prove the block still fires
The replacement text I substituted into the shim carried double quotes. It
lands inside `block(){ echo "…" >&2; }` — a double-quoted bash string — so a
quote in the middle of it closes that string early and leaves the shim a
syntax error. Every gog call on the box would then fail, reads included, and
the calendar drain's real bookings with them: an install step meant to improve
an error message would have taken out the calendar entirely.
Caught by tracing the sed against the shim's actual text rather than running
it. Two checks added so the next one is caught by the machine:
- `bash -n` on the shim after the edit — it is a shell script we just modified
in place, so prove it still parses before trusting anything else about it.
- Actually attempt a calendar write as the openclaw user and require it to be
REFUSED. The old check grepped for the rule's text, and a rule you can read
in a file is not a rule you have seen refuse anything.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(ui): use tokens this design system actually defines
The new approvals control and decision page reached for `text-brand`,
`accent-brand`, `bg-surface-hover` and `rounded-card`. None of those exist in
globals.css — the real names are `accent-text`, `surface-raised` and the
`radius-*` scale. Tailwind emits nothing for an unknown utility and reports no
error, so the checkbox would have rendered browser-default blue and the hover
state simply would not have happened, on a page whose entire job is to be
tapped once and trusted.
The design check passes either way: it forbids arbitrary values (`bg-[#fff]`),
which is a different failure from naming a token that was never defined. Caught
by grepping whether any other component uses these names — none did, which is
the tell.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(notify,install): two silent no-ops found by running the thing
Both found by exercising the deployed feature end to end rather than reading
it, and both are the same failure: a step that could not succeed, reporting
nothing.
1. A REFUSED TELEGRAM SEND WAS INVISIBLE. sendTelegramMessage reports a bad
token, a blocked chat or an API error as `{ok:false}` — an ordinary return
value, not an exception — so the try/catch around it caught the case that
never happens and ignored the case that does. That matters more here than
in a normal notification: the confirmation message IS the review mechanism
for actions a standing rule took without asking. If it stops arriving, the
operator does not notice Loki went quiet; they notice Loki apparently
stopped doing things, which is the opposite of what is true. Both senders
now log a refusal.
2. THE INSTALLER'S CLEANUP STEP CLEANED NOTHING. It globbed the skills
directory as the ssh user, who cannot traverse the openclaw home: the glob
matched nothing, the loop ran zero times, and the script printed its success
banner. The superseded skill was still installed afterwards — the exact
"two skills claiming one job, one of them broken" state the step exists to
prevent, left in place by the step that prevents it.
Fixed by running the loop under sudo, and then ASSERTING no other skill
ships the old entrypoint. Trusting the loop's own silence is what let the
first version pass; verified on the box that it now removes the directory
and that the assertion sees an empty result afterwards.
Verified live on bitbaum after deploying the parent change: booking from the
chat skill returns auto-approved, the drain books it, the row reaches executed,
and the event is really in Google Calendar at the right time. Test event
deleted.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(auth): the one-tap approval link redirected to sign-in
The feature whose entire purpose is "decide from your phone without logging in"
sent you to a login page. Found by tapping it against production, not by
reading it:
GET /a/<token> → 302 /sign-in?callbackUrl=/a/<token>
Route auth here is one negative-lookahead regex in src/proxy.ts listing the
prefixes served without a session, and `a/` was not among them. Every unit test
on the token passed throughout — 21 of them — because they tested the TOKEN.
Nothing tested whether the route could be reached, which is the part that was
broken. A signature that verifies perfectly behind a login is worth nothing.
Adds `a/` with the same justification the file already records for `share/task/`:
the minted token IS the credential, the holder has no account by design, and the
link decides exactly one action with one verb (lib/actions/action-link.ts).
THE TRAILING SLASH IS LOAD-BEARING, and that is why this commit also adds a
gate. The list holds bare prefixes, so `a` instead of `a/` would have made
/approvals, /api/*, /agent — every path starting with that letter — publicly
readable, and nothing would have looked broken: the app would have worked
better, with nobody asked to log in. That is the one direction a reviewer will
not notice.
scripts/test/public-matcher.ts reads the real regex out of the real file and
asserts BOTH directions: what must be reachable without a session, and what must
not. Proven by mutation before committing — with `a` in place of `a/`, eight
assertions fail loudly (/approvals, /api/actions/pending, /api/me/preferences
among them). A test that only checked the public list would have passed just as
happily on a regex that made the whole app public.
Verified: pnpm verify green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feat(calendar): warn on the card when a proposal clashes
An approval card asks "shall I book Thursday 14:30?" and could not answer the
one question most likely to change the answer: is Thursday 14:30 already taken?
On 2026-09-17 a test booking for 14:30–15:30 was approved on top of an existing
15:00 meeting and the card said nothing at all.
It could not know. The calendar lives behind `gog`, authenticated on the
operator's machine only; the cloud control plane — where proposals are made and
cards are sent — gets `runtimeOnly: true` and an empty list.
So the box mirrors what is OCCUPIED, one way, and the card reads it:
home/calendar-drain.ts → POST /api/calendar/busy → calendar_busy
The drain already held both halves this needs (gog, and the ck_* token), so it
gains a second, slower clock rather than a second process. Start, end and title
only — no attendees, no descriptions, no locations leave that machine. Google
stays authoritative; nothing here is ever written back.
FOUR DECISIONS WORTH THE REVIEW:
1. REPLACE THE WINDOW, DO NOT MERGE. An event cancelled in Google stops
appearing in what the box sends; a merge would keep it forever and produce a
phantom clash on a slot that is free. A warning that cries wolf is worse than
no warning, because it is read exactly once.
2. BACK-TO-BACK IS NOT A CLASH. Overlap is half-open, so 14:00–15:00 against
15:00–16:00 stays silent. Inclusive ends would flag every adjacent pair in a
real diary and train the operator out of reading the line within a week.
3. STALE NEVER READS AS FREE. `conflictsFor` answers clear / conflict / UNKNOWN,
and unknown speaks: "your calendar hasn't synced recently, so I couldn't
check". An offline laptop leaves the mirror stale, and a stale empty window
is indistinguishable from an empty afternoon — collapsing the two would have
the card implying you are free on the app's behalf. Same failure this
codebase keeps meeting: absence of evidence rendered as evidence of absence.
4. CLEAR SAYS NOTHING. A card that announces the absence of a problem every
time is noise, and noise is what stops warnings being read.
Tests: 20 cases on the conflict rules, asserted from BOTH dangerous directions
(the false positive that kills trust, the false negative that hides a clash),
including the exact 2026-09-17 collision as a fixture; 10 new cases in the
drain's self-test on normalising gog events, where the null paths get as much
attention as the happy one — inventing a busy block is how you invent a clash.
The mirror is also the prerequisite for suggesting events that do not collide
with what is already booked.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
e6b8a17970 |
feat(approvals): standing approvals + one-tap decisions from Telegram (#761)
* feat(approvals): standing approvals + one-tap decisions from Telegram
Asking Loki in Telegram to put an appointment in the calendar did not put an
appointment in the calendar. It sent you to a website.
Three separate causes, all fixed here:
1. THE CHAT HAD NO ROAD TO THE CALENDAR AT ALL. `gog calendar create` is
blocked on the box by the safety shim, and the fleetcrown skill could only
decide drafts that already existed — it had no way to create one. So the
agent hit the shim, read "route it through the approval queue", and passed
that on as advice. Adds `fc.sh book`, which proposes a structured event
through /api/actions/propose, and rewrites the shim's refusal to name it.
The shim still blocks every external Google write; unattended agents have
gained nothing.
2. THE GATE WAS ON THE WRONG SIDE OF THE REVERSIBILITY LINE. The queue enforced
"nothing runs that the operator did not TAP", which is stricter than the rule
it stands for ("nothing runs that the operator did not APPROVE"). For an
event in your own calendar — private, self-only, undone by deleting it — the
difference was pure latency (2026-08-04: proposed 14:15, booked 21:02).
Standing approvals let that yes be given once, in advance, with three rails
in code rather than in a docblock: eligibility is hard-coded (calendar events
and commitments only — never anything that reaches another person), the
payload is re-checked at decision time (guests mean invitations, so those go
back to the queue), and unknown is never yes (no resolvable time, or a slot
already past, queues). Default on for calendar events; toggle at /approvals.
3. THE NOTIFICATION HANDED BACK A CHORE. "2 actions are waiting… <url>" states
a problem and leaves the answer behind a login. Decisions now arrive as a
card carrying what/when/where plus one-tap Approve / Reject / Edit buttons,
backed by HMAC links scoped to one action and one verb — so a decision needs
no session and works when the gateway is down. Still two messages and only
two: one when a decision is owed, one when the effect really happened.
Also fixes a real data bug: propose_action had no event date fields, so the WHEN
of an appointment had nowhere to go and arrived as prose in `body`, which a Groq
pass then had to guess back — a model re-deriving a value the model one step
earlier knew exactly.
Behaviour that did NOT change: emails, messages, dispatches, and person-book
writes still require a per-item yes, and always will — they are ineligible in
code, and a preference row naming one authorises nothing. Every auto-approval is
audited with `via: standing-rule` and announced, so nothing is done in the
operator's name silently.
Tests pin the parts that must not be trusted: 37 cases on the standing-approval
rails (asserted from the side that hurts — a false `auto: true`), 21 on token
forgery and tampering.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(chat-skill): the chat's whole Loki skill was dead, and unversioned
Found while testing the previous commit end-to-end, and it is the largest of
the reasons appointments never got added.
On 2026-09-14 the product was renamed to Loki and `calendar-drain.env`'s keys
were renamed with it. The chat agent's skill script, which reads that file, was
not — because it lived only on the box, where no gate in this repo could see
it. Since then every command it offers has aborted on its first line:
line 14: <OLD>_AGENT_TOKEN: <OLD>_AGENT_TOKEN missing in calendar-drain.env
Verified live on bitbaum just now. So from Telegram the operator could not list
the approval queue, could not approve or reject anything, and could not
dispatch — silently, because a skill that errors just makes the agent talk
about something else instead. The only surviving route to a decision was the
website. That is the complaint, and it had a cause older than the UX.
Fixes:
- Renames the skill to `loki` (the retired product name is forbidden in this
repo by scripts/hetzner/test-no-retired-name.sh — which caught this commit,
correctly, when the box files were first imported verbatim) and reads the
env keys the file actually has.
- The installer REMOVES the superseded skill directory rather than leaving it.
Two skills claiming the same job, one of which cannot run, is how the agent
kept choosing the broken one.
- The installer now runs `loki.sh pending` as the openclaw user and fails if it
cannot authenticate. That is the check which would have caught the rename on
the day it happened: run the thing, as the user who runs it, and require real
output. Every other verification in that script only asserted that files
exist, and files existing is exactly what was true throughout the outage.
Also closes a gap in the previous commit: an auto-approved COMMITMENT executed
without telling anyone, while the comments claimed every auto-approval is
announced. Calendar events are announced from where gog succeeds (asynchronous,
on the box); everything else finishes inside enqueueAction, so that is the only
place that knows it finished at all. A standing approval nobody is told about
is not a standing rule, it is a silent one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(install): keep the gog shim parseable, and prove the block still fires
The replacement text I substituted into the shim carried double quotes. It
lands inside `block(){ echo "…" >&2; }` — a double-quoted bash string — so a
quote in the middle of it closes that string early and leaves the shim a
syntax error. Every gog call on the box would then fail, reads included, and
the calendar drain's real bookings with them: an install step meant to improve
an error message would have taken out the calendar entirely.
Caught by tracing the sed against the shim's actual text rather than running
it. Two checks added so the next one is caught by the machine:
- `bash -n` on the shim after the edit — it is a shell script we just modified
in place, so prove it still parses before trusting anything else about it.
- Actually attempt a calendar write as the openclaw user and require it to be
REFUSED. The old check grepped for the rule's text, and a rule you can read
in a file is not a rule you have seen refuse anything.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(ui): use tokens this design system actually defines
The new approvals control and decision page reached for `text-brand`,
`accent-brand`, `bg-surface-hover` and `rounded-card`. None of those exist in
globals.css — the real names are `accent-text`, `surface-raised` and the
`radius-*` scale. Tailwind emits nothing for an unknown utility and reports no
error, so the checkbox would have rendered browser-default blue and the hover
state simply would not have happened, on a page whose entire job is to be
tapped once and trusted.
The design check passes either way: it forbids arbitrary values (`bg-[#fff]`),
which is a different failure from naming a token that was never defined. Caught
by grepping whether any other component uses these names — none did, which is
the tell.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
b71941be63 |
feat(providers): one-tap switch to a provider that still has quota (#757)
* feat(providers): one-tap switch to a provider that still has quota When the agent building a project hits a rate limit, the way out already existed — four other agent CLIs, most with untouched quota. Taking it was the problem. The only chooser lived in the Terminal right rail, it offered every agent in a fixed order whether or not the connected builder had it installed, and taking it swapped the live PTY without recording the choice, so the next dispatch went straight back to the agent that had just run out. One ranking, three surfaces: - src/lib/provider-switch.ts — the whole decision as pure functions. Ranks the operator's order, filters on two pieces of OBSERVED evidence (the builder's installed-agent report, and recent runs that died with capacity language), and holds the three-state rule provider_quota is built on: an agent nothing was reported about is unknown, and unknown reads as usable. Nothing is hidden — a provider that cannot answer still appears, disabled, saying why. 18 inline checks in scripts/test/provider-switch.ts. - GET /api/providers — that ranking, once, for every surface. Accepts either the user_projects id or the entity id, because the Feedback row holds one and Control/Terminal hold the other. - ProviderSwitch — "Try <next>" plus a menu of the rest, now the PRIMARY control on a Needs-you / Failed feedback row (Retry steps down beside it), in the Control inbox, and in the Terminal rail. And it sticks: POST /api/feedback/<id>/dispatch takes an `agent`, records it as the project's agentPref, then dispatches on it — no scavenger hunt through project settings. The order is the operator's, not the fleet's: user_preferences.agent_order (migration 0072, nullable and additive) with a reorder list in Settings → Agent. Null means "never stated", and the fleet default applies. Two SSOT repairs the work ran into: - AGENT_FALLBACK_ORDER was defined TWICE (agent-registry.ts and agent-resolution.ts) — the server reroute and the client reroute each read their own copy. agent-registry now re-exports the client-safe leaf. - QUOTA_ALTERNATIVE_AGENTS is derived from that order instead of being a second hand-written list of the same five ids. - TerminalRunView.alternatives is gone; quotaDeath stays as the flag that asks the shared chooser. provider_quota is deliberately NOT an input: it meters the ai-kit inference chain (groq, openrouter) behind Loki's own chat, not the agent CLIs. The agent-CLI equivalent is the run evidence above — observed, never probed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(providers): never offer the agent the project would actually run on Self-review caught a gap in the chooser's exclusion rule. It read "current" straight off `user_projects.agent_pref`, so a project that has never had a preference set reported no current agent at all — and dispatch does not work that way. Such a project still runs, on DEFAULT_ADAPTER_ID, which means the escape offered from a Claude Code rate limit could be Claude Code. currentProviderFor() answers the question the exclusion is actually asking — which agent just died — in the order the evidence deserves: 1. what this project LAST RAN on (freshest run inside the window). A stored preference can be stale by one switch; a run is what happened. 2. else its stored preference. 3. else the fleet default, because that is what the next dispatch picks. A run on an agent the chooser cannot offer (openclaw) is not "current" — it falls through rather than excluding nothing. Three more checks in scripts/test/provider-switch.ts, 21 total. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
8034cb629b | feat(feedback): add reporter tracking and project editors (#754) | ||
|
|
71a7b44ee6 |
feat(ai): show what the day's tokens were spent on (#723)
* feat(ai): show what the day's tokens were spent on
"What are the current providers, with limits, what is spent and on what" could
not be answered. The limits were there; the spend was one number with no
breakdown, and fifteen features were not in it at all.
ROUTING WAS NEVER THE PROBLEM
Worth saying plainly because I got it wrong first: every caller already goes
through ai-kit's chain. callTextDetailed walks the same chainFrom() with the
same fallback as the tool loop. There is one router, exactly as this file's own
header claims.
The gap was METERING. callOneLink did the fetch, read the body, and threw the
response headers away — so every digest, brief and form-fill drew on the same
Groq pool the capacity page was reading, and the page never saw them.
ONE LINE COVERS FIFTEEN FEATURES
recordVendorQuota() in callOneLink. They all reach the vendor through there.
Refusals record too: a 429 is the most reliable reading there is, because it
corrects a counter that had drifted optimistic.
`feature` IS NOW REQUIRED, AND THAT IS THE DESIGN
No default. The compiler then named every caller that had not named itself —
19 call sites in 15 files — and each now declares a slug the page can show a
person: activity-digest, form-assist, calendar-extract, project-brief,
frontier-propose, frontier-judge (its own slug: the panel's value is being an
uncorrelated second lineage, so its cost is worth seeing separately), dod-gate,
hosted-runner-analyze, and the rest.
A default would have let the twentieth caller be invisible again. That is how
the first fifteen got there — not by anyone hiding them, but because the
cheapest thing to write was the unnamed thing.
A SECOND TABLE, NOT A WIDER ONE
ai_spend answers "what has THIS USER spent today" and is read by the admission
gate on every turn; it must stay a point read on one row per (user, day).
Putting provider/model/feature in its key would make the rationing path pay for
reporting. ai_usage answers the orthogonal question and is keyed
(day, provider, model, feature). The user dimension is deliberately absent —
recording the same fact twice is how two tables start disagreeing.
VISION AND WHISPER REPORT TOO
They have their own transports and I nearly left them out. They spend the same
vendor pools, so omitting them would have made the page complete-looking and
wrong — the failure this surface exists to end.
EMPTY IS NOT ZERO
The ledger starts empty each UTC day, so the page says "nothing recorded yet
today", never "nothing spent". Same three-state discipline the provider rows
already keep.
5 coverage checks defend the guard itself, including that nobody can quietly
restore `options: GroqOptions = {}` and reopen the hole. Verify green, 237.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nm2REqtdsVsvjukBU2maCz
* chore: re-trigger CI (previous run stalled 5s after start)
The prior CI run for this branch froze with updatedAt five seconds after
creation and sat in_progress for 45 minutes, while every other branch's CI
completed in 3-5 minutes in the same window. A stuck runner, not a slow test —
two candidate causes in the change itself were tested and both disproved:
a unit test writing to a reachable database still exits, and importing the db
module against a live connection does not hold the event loop.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nm2REqtdsVsvjukBU2maCz
---------
Co-authored-by: Claude Opus 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> |
||
|
|
c9c65360c1 |
fix(ai): the capacity page was describing a subsystem as if it were the system (#684)
George's reaction to the page as shipped: "this looks bad and is not actionable
and the numbers look like bullshit". All three were fair, and the third was the
tell — the numbers looked wrong because the page was describing one of three
answer paths while presenting itself as the whole picture.
Three false claims, from the journal rather than from reading the code:
1. "groq — configured, but it has not served an answer yet. Will be measured on
the next answer it serves."
Both halves false. Groq HAD served (through callGroqText, a path with no
meter on it), and it is being SKIPPED on every turn:
skipped groq/openai/gpt-oss-120b (prompt ~10153 > 5400)
skipped groq/openai/gpt-oss-20b (prompt ~8312 > 5400)
Four skips in six hours. It will never be measured, and the operator was
told to wait for that. The actionable truth — prompts exceed the window, so
this vendor is never reached, which is WHY the next one burns out — had
nowhere to live, because a row could carry a number but not a reason.
2. "Every measured provider is spent." One of two had been measured. True, and
it reads as evasion, because it quietly redefines "every" to mean "the one".
3. The gateway served most of today's answers and was not on the page at all.
So the page could report everything spent while Loki plainly worked. The
omission, not the arithmetic, is what made it read as untrue.
WHAT CHANGES
- A fourth state, `skipped`, distinct from `exhausted` — opposite problem,
opposite fix. Its consequence names the fix ("shorten the prompt or raise its
budget") because waiting changes nothing, and it is URGENT: a provider walked
past on every turn is capacity held and never spent.
- `provider_quota.note` (0069) carries the reason. `source: "preflight"` marks
a skip; `remaining` is 0 there only to satisfy a non-null column, so the
presenter keys on source and never reads that 0 as empty.
- Counts are always out of the TOTAL: "1 spent, back in 4 hours · 1 never
reached · (of 2 configured)".
- Rows are ordered by CHAIN POSITION, not recency. Recency put the last link
above the link that precedes it, directly under the words "this is the last
link".
- The gateway is listed as an unmetered path, because it answers.
19 presenter checks (up from 15), 164/164 unit test files.
Claude-Session: https://claude.ai/code/session_01Nm2REqtdsVsvjukBU2maCz
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
6b2f1581f6 |
fix(db): rename provider_quota.window — it is a reserved word (#680)
The very first ad-hoc query written against this table failed:
select provider, model, scope, window, remaining from provider_quota
ERROR: syntax error at or near "window"
`window` is reserved in Postgres. The application was never at risk — drizzle
quotes identifiers, and 0067 declared the column as "window" — but every
hand-written query against this table would have needed the quotes forever, and
the error points at the wrong token, so the next person loses the same minutes
to it.
Renamed one day after the table shipped, while it held a single row. This is
the cheapest this rename will ever be.
0067 IS DELIBERATELY LEFT UNTOUCHED.
I edited it first, and that was wrong. It is recorded in the box's
_deploy_schema_history and describes what actually ran there; editing an
applied migration makes the file a lie about the database, and the audit trail
is the only thing that makes a forward-only applier trustworthy. Reverted.
So a fresh database creates "window" via 0067 and is renamed by 0068 — reaching
the same state by the same path production took, rather than a second path
nobody has exercised.
0068 is guarded on the OLD column existing, so it is re-runnable (the applier
requires that) and resolves a half-applied state the same way. Nothing is
dropped: a rename is not destructive, which also keeps it inside what the box's
applier will accept.
Verified live before renaming: one real Loki turn wrote
openrouter | nvidia/nemotron-3-super-120b-a12b:free
requests | day | 0 of 50 | x-ratelimit-remaining
which is the same 50/day ceiling measured by hand at the start of this work,
now recorded automatically from a header on an answer already paid for.
164/164 unit test files.
Co-authored-by: Cato <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
27b7e403f8 |
feat(ai): what is left at each vendor, and what happens when it runs out (#677)
FleetCrown enforced a daily AI budget with no interface at all: a user was
refused and never learned why, or what their share had been. And nothing
anywhere knew how much was left at the VENDORS — the constraint that actually
decides whether the next answer happens.
Settings → AI now shows it, and the numbers come from the answers we already
paid for rather than from asking.
WHY OBSERVED AND NOT POLLED
The obvious design is a cron that asks each provider how much quota remains.
That design reports a FULL TANK DURING AN OUTAGE. Measured on one live key,
within the same second:
GET /api/v1/key -> limit_remaining: null, usage_daily: 0
POST /chat/completions -> 429, x-ratelimit-remaining: 0 of 50,
"Rate limit exceeded: free-models-per-day"
Both are OpenRouter's answers about the same account, and the account was
locked out. Its usage endpoint tracks money, free models cost nothing, and the
limit that binds is a request count that endpoint never reports.
So the recorder hangs off the existing model call and reads the rate-limit
headers off every response, success and refusal alike. No extra request, and no
quota spent to discover how much quota is left.
A NUMBER WITHOUT AN ACTION IS DECORATION
No row shows a bare percentage. Each says what is left in ANSWERS, when it
returns, and which provider takes over — because "78%" tells you nothing you
can do and "about 40 answers, then it moves to OpenRouter" tells you whether to
care. Tokens are translated because nobody has an intuition for a token.
THREE STATES, NEVER TWO
known · unknown · exhausted. A vendor nobody has called today has no reading,
and it is drawn as UNKNOWN with the reason stated — listing only what has been
measured would let the page read as the whole fleet while omitting the provider
about to serve the next turn. A per-minute counter read six minutes ago also
reverts to unknown rather than reporting a number that expired.
DETAILS THAT ARE LOAD-BEARING
- `key_owner` is a non-null text column, not a nullable user_id. Postgres treats
NULLs as DISTINCT in a unique index, so a nullable owner would let the
platform accumulate one duplicate row per observation while the upsert never
found its target — a rollup silently becoming an append-only log.
- The recorder is never awaited, cannot throw, and imports the db lazily. A
telemetry write must not add latency to an answer someone is waiting for, nor
fail it and demote a working vendor off the chain.
- A unique INDEX rather than a CONSTRAINT so the migration can carry
IF NOT EXISTS, which the box's forward-only applier requires.
- 0067 is hand-written: drizzle-kit generate stops on an interactive prompt in
this schema, and apply-schema.sh globs numbered .sql rather than reading the
journal — as 0065 and 0066 already did.
FIVE DEFECTS CAUGHT ON THE WAY IN
Two by reading it back: a stale-write guard that was a tautology
(eq(observedAt, observedAt) is always true), and an unreachable sub-minute
branch (40 seconds rounds UP to 1). Three by the gates: prettier on the
workspace file, react-hooks on a synchronous setState in an effect (which also
exposed a real unmount race), and the dead-exports ratchet on a single-counter
read written for a router that does not exist yet — deleted rather than
baselined.
163/163 unit test files; 15 new checks on the presenter, which is pure.
Co-authored-by: Cato <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
8cd138bd1a |
feat(feedback): ship fixes automatically, per project, opt in (#656)
An agent's job ends at a pull request, so until somebody merges it the
visitor's report is not fixed. This adds the switch that decides who presses
merge — per project, off by default, in the Feedback section beside the
widget's Pause.
NOT an auto-merge.yml in the customer's repo. That would be a commit in
someone else's repository, would need back-filling into repos FleetCrown
never provisioned (annushka's was made by hand), would need another commit to
turn off, and — the real objection — it merges ANY green pull request,
including one a person opened for something unrelated. FleetCrown already
watches the exact PR its own dispatch produced (the fix ledger), so it merges
that one and nothing else: the setting applies to PRs already open, and
leaves no trace in the repo when it goes back off.
auto_ship is nullable on purpose. NULL = never chosen, and the project shows
an invitation rather than a switch sitting in the off position looking like
somebody's decision. FALSE = chosen off; stop offering. Off is the effective
default either way, which is what keeps client sites safe: FleetCrown cannot
tell a client site from its own — that ledger lives in apps.conf on the box,
not in this database.
Conditions, pure and pinned in scripts/test/feedback-auto-ship.ts:
- only a PR from FleetCrown's own dispatch;
- never on an "unverified" ledger — that is the agent's claim, and it is
the exact shape the org-restriction 403 produces;
- not a draft, and GitHub must say mergeable (null means it is still
computing, which is not permission);
- every check passed, and NO CHECKS AT ALL IS A HOLD. The dogfood site's
first agent PR had zero checks; absence of red is not evidence of green;
- one failed deploy pauses the project, so a broken fix cannot have the
next one land on top of it.
When it holds, the row says what it is waiting for — an operator who turned
the switch on should never have to wonder whether the feature works.
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
225217e014 |
feat(routing): the builder is a stored decision — cloud by default, local by the project's row (#615)
Where a dispatch runs used to be guessed from runner presence: "a desktop is connected" was read as "the operator is at the laptop", and every misroute this subsystem shipped came from that inference. A phone dispatch landed on a laptop nobody was watching and died when the lid shut. A repo-only project was pinned to a laptop that then hunted for a zellij tab that could not exist (Heidi, 2026-09-10). A product-created box workspace was sent to a runner that does not clone (velokiosk, 2026-09-10). Each was patched with one more tier — battery durability, a clone-only exception, a box-root lock — and the rule grew to four tiers that still guessed. Now the answer is stored. `pickDispatchChannel(project)` reads the project and nothing else: the locus lock (a laptop-only tree stays local, a box-rooted tree stays cloud), then the new `user_projects.builder_pref` column, then the cloud floor. DEFAULT_BUILDER_CHANNEL flips to "cloud" — the always-on box is the tier a project runs on when its row says nothing; "This computer" is chosen per project in Control → project profile → "Runs on", and honored whether or not that computer happens to be online. An offline builder queues visibly (`runnerConnected: false`); nothing is rerouted behind the operator's back. Removed with the guess: the battery-durability tier (channelDurability, getBuilderFitness, ExecutionAccess.localDurability) and isCloneOnlyProject. Power source stays in the heartbeat row as data; it no longer routes anything. Migration 0065 adds the nullable column. Routing tests rewritten to pin the stored rule, including that the same project routes the same way whatever is online, and that pickDispatchChannel takes exactly the project. Verified: pnpm run verify green (tsc, lint, design, desktop, 144/144 unit files, ops). Claude-Session: https://claude.ai/code/session_01WSNERoZZqW2TgqbAGHSQZf Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
abb00b911c |
feat(register): one register for every project, joined from the owners of each fact (#610)
* feat(register): one register for every project, joined from the owners of each fact
"Which projects do we have, and which one has a site, a FleetCrown profile, an
OrangeCat profile, a Solon organisation?" had no answer. It had seven: apps.conf,
this database, OrangeCat's, Solon's, bitbaum's companies.json, the public footer's
config, and 24 markdown dossiers. Each is right about its own facts and wrong
about the others; joined by hand they disagreed on 5 names, the footer named a
host that had been renamed and missed 12 live ones, the showcase listed hosts
the hosting register did not know, and Caddy served 38 vhosts of which the
register knew 23.
This does not add an eighth list. It adds the JOIN, computed from the owners:
src/lib/register/apps-conf.ts the one parser for apps.conf (hosting SSOT)
src/lib/register/build.ts pure join keyed on the canonical slug
src/lib/register/solon.ts Solon membership via its public org endpoint,
reported UNCHECKED (not "none") when unreachable
GET /api/fleet/register public JSON — consumers derive, never copy
/fleet the same join, rendered
The join key is the repository name. Names have drifted into several spellings
(aoz-housing/aoz-wohnen, datacat/datacat-web, s-ink/sink, sbb-fundbuero/
sbb-lost-found, wild-spirit/annushka); `canonicalSlug` folds every alias that
has actually bitten, and each is pinned by a test. The durable fix is three
nullable columns on user_projects — slug, hosted_app, solon_org_slug — with
scripts/backfill-project-registry.ts to assign them once (drizzle/0065; the
applier is filename-based, matching how 0064 was shipped).
The footer stops being a list anyone edits. src/config/fleet-sites.ts is now
GENERATED from apps.conf by scripts/generate-fleet-sites.ts (the footer is a
client component and cannot read the register at render, and Atlas needs static
anchors), with editorial copy kept in fleet-site-copy.ts keyed by slug. A gate,
scripts/test/fleet-sites-derived.ts, fails the moment the file drifts.
apps.conf itself gets two corrections found by comparing it with the box:
evig (live on 4004 from the main Caddyfile, never registered) and
hirnli.orangecat.ch, which revamp-info's app serves.
Not done here, on purpose: the bitbaum showcase still renders its own
companies.json — it moves to the API once this is live; annushka and bitbaum are
static Caddy roots with no app process and do not fit the register's app shape.
Verified: 145/145 unit files (24 new assertions in fleet-register, drift gate
green), tsc clean, register gates (port-alloc, register-reality, client-ledger)
green with the new rows.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY
* fix(register): evig row names its host database, revampit
The deploy-ready gate found drizzle migrations in the evig checkout and a
db of '-', which is the shape that let botsmann serve PGRST205 for months.
evig is not deployed by deploy.sh at all — its own workflow applies its
migrations — but the register should still say which database that is.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY
* fix(watchdog): evig left the hand-list the day it entered the register
The hand-list is built to die one row at a time: the test that failed is
the one that forces a duplicate out the moment apps.conf registers it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
|
||
|
|
cb7191bb1a |
fix(db): remove DROP substring from 0064 so deploy gate passes (#544)
The gate greps the whole migration file. A comment that said do-not-drop still matched and aborted ship. |
||
|
|
244642fd7b |
fix(db): feedback screenshots migration without DROP COLUMN (#542)
Deploy aborted on the DROP. Keep screenshot; add screenshots jsonb and copy data. Lets #537 and #540 reach the box. |
||
|
|
2ba52001f7 |
Fix feedback widget: multiple screenshots + prominent voice + dispatch fix (#537)
* Fix feedback widget: multiple screenshots + prominent voice + dispatch fix - Widget UI: Make voice recording and screenshots primary actions with larger buttons and camera/mic icons - Support multiple screenshots (up to 5) with array storage and individual thumbnails - Update API to accept screenshots array instead of single screenshot - Add database migration for screenshots jsonb column - Fix dispatch 'tab not found' by preferring user_projects.name over entities.name - Display multiple screenshot thumbnails in feedback inbox - Screenshots load on demand to keep inbox payload small Widget changes: - Voice button now says 'Record your feedback' instead of 'Speak' - Screenshot button shows 'Add screenshots' with camera icon - Multiple files can be selected or pasted - Each screenshot shown as thumbnail with remove button - Max 5 screenshots with clear count indicator Backend changes: - site_feedback.screenshots jsonb array replaces screenshot text - Migration preserves existing data by wrapping in array - getFeedbackWithProject now uses user_projects join for dispatch compatibility - API route returns JSON array instead of single image UI changes: - FeedbackItemRow shows all screenshots as thumbnails - Screenshots API returns JSON with array of data URLs - On-demand loading keeps initial page load fast * Fix dispatch flow and widget colors - complete end-to-end path Dispatch improvements: - Validate project exists in user_projects before dispatch - Only mark feedback as DISPATCHED if injection succeeds (status < 400) - Add helpful error hints for common failures (404 = project not found) - getFeedbackWithProject now prefers user_projects.name for dispatch compatibility - Prevents 'tab not found' errors by using correct project name source Widget color system: - Remove all hardcoded hex colors (#e0680f, stone grays) - Add WidgetTheme type with 18 semantic color tokens - Boot payload now serves theme colors - Widget builds CSS dynamically from theme - Falls back to DEFAULT_THEME if boot doesn't provide colors - Consistent branding across all widget states Fixes 'tab not found' issue where: 1. Feedback referenced entities.name 2. Dispatch looked up user_projects.name 3. Mismatch caused injection to fail 4. Now getFeedbackWithProject joins user_projects and prefers that name Work phase logic already correct: - UNCONFIRMED outcome shows as FAILED, not DONE - Run with no deliveredAt after 90s shows as STUCK - Only SUCCESS/PARTIAL outcomes show as DONE * Remove all hardcoded colors from widget - require theme from boot - Remove DEFAULT_THEME constant entirely - Widget now requires theme from /api/widget-boot payload - If boot doesn't provide theme, widget doesn't render - Zero hardcoded hex values in widget code - Boot payload is single source of truth for all colors No second palette - boot accent change changes widget without edit to main.ts * Use PALETTE.widget for theme - single source of truth for all colors - Remove WIDGET_THEME local object from widget-boot route - Add widget theme to PALETTE.ts (JS mirror of CSS design tokens) - PALETTE.widget maps to app's dark-mode tokens (widget always dark) - Boot route serves PALETTE.widget, not a second palette - To change widget colors: edit PALETTE.widget + matching CSS tokens One source: PALETTE.ts mirrors globals.css. Change both together. Widget receives resolved values via boot payload. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> |
||
|
|
81bf2041be |
chore(billing): remove the Stripe rail, which was never configured anywhere (#508)
STRIPE_SECRET_KEY and the seven other STRIPE_* vars appear zero times outside
src/ and zero times in .env.example, so isStripeReady() could only ever return
false. Three API routes, a checkout route, a tier grid and a "Manage
subscription" button were all gated on it and permanently unreachable.
Confirmed empty in production before touching the schema:
select count(*) filter (where stripe_customer_id is not null),
count(*) filter (where stripe_subscription_id is not null),
count(*) from users;
→ 0 | 0 | 7
So this removes no data and, more to the point, changes nothing a user sees:
every code path already fell through to the branch below it.
WHAT STAYS. Plans are real and untouched. They are granted through the
OrangeCat/Bitcoin rail (/api/orangecat/entitlement -> recordOcBillingGrant),
with the expiry cron reverting a lapsed pass to free. The pricing CTA cascade
loses only its unreachable middle step: free -> TBA -> [stripe] -> BTC ->
start-free.
WHAT WAS ACTIVELY WRONG. Because isStripeReady() was false, the one part of
Billing that DID render was a notice telling the reader to "add
STRIPE_SECRET_KEY and price IDs" — an environment variable shown to a person
who does not deploy the app and could not act on it. That is the same mistake
NotificationsPill's comment already calls out. Billing now states the plan and
links to /pricing.
Removed: lib/stripe.ts, api/stripe/{checkout,portal,webhook}, api/checkout/
[plan], getUserByStripeCustomerId, two user columns (migration 0063), two
entries from the user-client-view redaction lists, the api/stripe/webhook entry
in proxy.ts's public matcher, the stripe npm dependency, and the smoke/auth
probes for routes that no longer exist.
BillingSettings drops "use client" — with the handlers gone it holds no state,
no effect and no search-param read.
Two mentions deliberately KEPT because they are not the rail: the placeholder
prose describing what a user might build ("Simple dashboard, automated
reminders, Stripe payments…") and the demo project's stack string.
pnpm run verify green. 28 files, 519 deletions.
Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
7449bb7093 |
feat(widget): stop the launcher covering other people's buttons (#466)
Every mainstream chat/support widget — Intercom, Crisp, Tawk, Drift, and
most in-house AI assistants — defaults to the bottom-right corner. So did
ours, with a z-index near the 32-bit maximum, so on any site running both
we won and hid THEIR control. Reported on kivvi; it is structural, not
specific to that site.
The only escape was `data-fc-bottom` on the script tag, which means
editing the customer's HTML: not one click, and impossible on a site we
do not deploy.
Three layers now, because none is sufficient alone:
1. AUTO-AVOID, any viewport. The launcher measures its corner and steps
up past foreign fixed/sticky elements, re-checking on resize and at
800ms/2.5s to catch chat scripts that boot late. Matching is by
rectangle, so it works against a vendor we have never heard of.
Replaces a dodge() that only ran at ≤480px and RESET to the base
offset above it — which is exactly why desktop collisions survived.
Full-width bars are skipped (stepping over a cookie banner just lands
on the next one) and a shift larger than MAX_AVOID_SHIFT is abandoned
rather than chasing the launcher off-screen.
2. REMOTE PLACEMENT. Corner + nudge + an auto-avoid switch live on the
token and are served by /api/widget-boot, so moving a launcher on a
live customer site is a dashboard action that lands within the boot
cache window. The snippet stays a pointer — the same design idea as
the pause switch. Placement rides along with the render verdict, so
there is no window where the launcher paints in one corner and jumps.
3. VISITOR ESCAPE HATCH. Long-press (touch) or right-click (pointer) on
the launcher offers move / hide / reset, kept in localStorage per
token. For the case the other two missed, decided by the one person it
is actually blocking. The operator's kill switch still outranks it.
Also fixes a real bug found while reading the ingest path: PAUSE DID NOT
PAUSE. The boot call stopped the widget rendering, but the token is
public and sits in the customer's page source, so a paused project kept
accepting POSTs from anyone holding a copy — and the operator, seeing no
widget on the site, had no reason to suspect it. Ingest now rejects a
non-active token.
Operator surface, per the two places it is actually needed:
• project page: a position picker with a live preview box, because
"bottom-left, 16, 16" is not something anyone can picture
• Control inbox: Pause/Resume directly on the widget row, so the list
that told you it was off is where you turn it back on
38 assertions cover the geometry, including that the widget's normalizer
and the server's agree — the logic exists twice because widget/ cannot
import from src/, and drift there would make the dashboard preview lie
about where the launcher lands. One of those assertions caught a real
defect: after clearing one obstacle the launcher landed exactly flush
against the next, so the avoid test now runs against a gap-inflated box.
Migration 0062 adds a nullable placement column; NULL means the default.
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
|
||
|
|
caa0e41c3b |
chore: add a formatter (#449)
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (1062 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(lint): reattach two guards the reformat detached Both effects were one-liners, so a trailing eslint-disable-line covered the setState call: useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ... prettier expanded the block. The comment stayed on the closing line while the call moved above it, so the guard protected nothing and the rule its author had deliberately silenced failed the build. This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line variant. Both come from the same fact: an eslint directive binds to a line number, so reformatting can silently unbind it, which makes 'mechanical, no behaviour change' false for any bulk reformat. * chore(desktop): bump the runner version the reformat requires desktop-release-drift enforces that anything built into Fleet Runner which differs from the last released tag must carry a version ahead of that tag — main read 0.8.15 and fleet-runner-v0.8.15 already shipped. A whole-repo reformat changes bytes under desktop/, so the gate fires. The alternative was adding desktop/ to .prettierignore, which would buy a quiet PR by carving a permanent hole in the formatter's coverage — the precise shape of silent drift this test was written to catch. Bumping is what the rule asks for and costs one patch release whose only content is whitespace. * chore: merge main and re-format A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR runs no checks at all while reporting nothing. Conflicts resolved to main, which is correct because this branch changes formatting and nothing else. * chore: leave desktop/ out of this reformat desktop-release-drift is right to refuse this. Everything under desktop/ is built into Fleet Runner, so changing it means shipping: bump the version AND add a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed Fleet Runner and wants to know what changed'. For a whitespace-only build the honest answer is 'nothing', so that release should not exist — and I should not write release notes claiming otherwise. I had bumped to 0.8.16 to get the gate green. That was the wrong direction: publishing a build to three OS runners to keep a formatting PR quiet. Reverted. desktop/ is excluded in .prettierignore with the reasoning recorded there, to be formatted alongside the next real runner change, where the bump and the notes are true anyway. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
4bd2067339 |
feat(orchestration): a prompt records which run it became (#441)
Phase 0 of the fleet AI-engine plan — the smallest change that unparks the trajectory-learning loop docs/self-improvement-plan.md wrote down on 2026-08-07 and then could not start. The plan's own finding: FleetCrown improves from what it READS (the frontier loop), not from what it DOES, because the one dataset nobody else has — prompts joined to graded outcomes with cross-lineage verdicts and real costs — was not joinable. prompt_history had no runId; the only join was (userId, projectKey, adapter, intent, time-proximity), which is lossy under concurrency, and concurrency is the normal operating state. It was never a pure schema change. In the orchestration run route the prompt was logged fire-and-forget BEFORE the run row existed, so the id could not be recorded even once the column existed. That write now happens after the run is created — the ordered, linked pair — and stays fire-and-forget, because a ledger hiccup must not block a dispatch. inject-core and tab-inject already had the run id in scope at their writes and only needed the field passed. Activity-capture rows keep a null runId on purpose: a prompt typed straight into a terminal has no run to join. ON DELETE SET NULL: losing a run must not erase the prompt from the ledger. Migration 0061 adds the column, FK and index. Typecheck clean; 125/125 unit test files pass. 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> |
||
|
|
0d0e91657b |
feat(crew): assign work to humans, and pay them in bitcoin (#391)
* feat(crew): assign work to humans, not just agents FleetCrown dispatches intents to agents. Some work is not an agent's to do — calling twelve suppliers on the company's behalf, signing something, walking into a room. That half of the fleet had nowhere to live, so it lived in the operator's head. This adds it as a surface: /crew, the humans in the loop and the work handed to them. Three laws, each because the alternative is worse: A person is not a queue. `assigned` only ever means you ASKED. The answer is theirs — accept, decline, or deliver — and OPERATOR_MOVES cannot reach `accepted` or `declined`, so FleetCrown can never record consent nobody gave. Declining is a first-class button on the share page, not small print: an ask you cannot refuse is an order. Nothing reaches a human by accident. An assignment is born a DRAFT, and a draft has told nobody anything. Handing it over mints the share link, and that is the only act in the feature that reaches a person — which is what makes it safe to let Loki propose one (propose_human_task writes a draft, exactly as propose_action does). Money is OrangeCat's. A task states its fee so both sides see the terms; a paid one mirrors to OrangeCat as a service and keeps the pointer. FleetCrown decides WHO does the work; OrangeCat settles what it costs. That seam is the missing link between the two products. The roster is not a new table. A crew member is a person already in the operator's book (`entities`, type person) carrying `crew:member`, so enrolling someone you know adds no row, un-enrolling keeps every note and assignment, and the book can never disagree with the roster. The actor kernel gains a DELEGATE capability opposite MARKET: a robot physically cannot join the crew, and a person still cannot be listed, booked or sold — assertAttrAllowed enforces both directions. The assignee never signs in. They open a link and answer; the token is their credential, looked up with revoked links excluded, and it can only ever answer for its own assignment. Revoking an unanswered ask pulls it back to draft, because a board that says "asked" over a dead link lies to you every morning. Verified against real Postgres, not just types: the whole query layer end to end (enrol → draft → hand over → accept → deliver → accept the work → revoke → re-share), and the public surface over HTTP — page renders, accept succeeds, a replayed accept is 409, an invented action is rejected, unknown tokens 404, and /api/crew plus /crew stay gated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YKERdritcwNRuPW72zv8c3 * feat(crew): pay in bitcoin, to the person who did the work Three corrections, all of them about the same thing: a fee is a promise to a human, and every part of it has to be true. BTC is now an assignable currency. The list is exactly the enum OrangeCat's services API accepts (USD, EUR, CHF, GBP, BTC) — a currency FleetCrown offers but OrangeCat rejects is a fee that cannot be mirrored. fee_amount becomes NUMERIC(20,8), not real. float4 carries ~7 significant digits, so it cannot represent a satoshi: 0.00050001 BTC would have been silently rounded on the way to disk, and the amount someone is owed is the last field in this system allowed to drift. Verified against Postgres — that exact figure now round-trips to the last satoshi. Two-decimal formatting had the same bug on screen, printing "BTC 0.00" for 50,000 sats, on the page where a person decides whether to say yes. And the payment goes to THEM. `publishTaskToOrangeCat` creates a service under the studio's integration key, so paying that listing pays the studio — the SDK's actor_id is documented as ignored for integration keys, and OrangeCat has no endpoint that creates an actor, because a profile carries a wallet and a wallet belongs to whoever holds its keys. So the roles are split honestly: the listing is the record of the engagement, and `crew:orangecat_profile` — their own OrangeCat page, Lightning wallet and all — is the destination. It rides on the task as `assigneePayUrl`, gives the operator a "Pay Jana BTC 0.0005" button, and tells the assignee where the money lands before they accept. A paid assignment with no destination on file says so out loud on both sides rather than looking complete. Profile links are stored canonical (a handle and a pasted URL are one wallet, not two) and anything that is not a profile is refused rather than half-saved. The migration is regenerated rather than stacked: 0060 was never applied anywhere, so the column is born numeric instead of being altered later. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YKERdritcwNRuPW72zv8c3 --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
a294cc4549 |
fix(orchestration): narrow a claim I overshot — undelivered becomes unconfirmed (#385)
Yesterday's #383 added an outcome asserting the prompt "never reached an
agent". Reading the runner's actual acks afterwards does not support it:
{"ok": true, "text": "injected to running claude (pty)",
"verified": false,
"warning": "... isn't generating yet — may still be booting or already idle"}
The runner INJECTED. What it could not establish is whether the agent picked
the prompt up. Both readings stay open — the pane may have been idle with the
agent gone, or the agent may have been wedged — so the outcome must name the
observation and not pick a conclusion.
`undelivered` was also already taken. closeRunUndelivered handles a runner
NACK (ok:false, the prompt provably never landed) and closes as `error`.
Overloading that word with a weaker signal put two confidences behind one
name, which is the defect #383 existed to remove.
Nothing about behaviour changes. `unconfirmed` is still a failing outcome,
the brake still stops, the ladder still advances, and the ladder still
declines to tell an agent to re-plan work it never received. Only the claim
narrows — and the operator-facing copy now ends with the useful part:
nothing ran, so a retry is free.
Migration 0059 relabels the 29 rows and rewrites the explanation 0058 wrote
into them. Dry-run against prod inside a rolled-back transaction: 29
undelivered → 29 unconfirmed, timeouts untouched at 129.
A new assertion keeps the two words apart: `undelivered` must never appear in
ORCHESTRATION_OUTCOMES, so the stronger signal cannot be re-borrowed.
Root cause of the underlying dispatches, for the record: the laptop runner is
on 0.8.12, and the inject-hardening that retries a stuck paste and hard-fails
instead of acking softly landed 2026-08-23 in
|
||
|
|
d47779dfe4 |
fix(orchestration): a prompt that never arrived is not an agent timeout (#383)
`timeout` claimed one thing — an agent ran and ran out of time — while covering two. The other is "no agent ever saw this prompt", and measured on 2026-08-26 it was 29 of 157 timeouts, where "measured" means the runner itself acked the command `verified: false`. The reaper already computed that fact. `runNeverStarted` is used to disqualify liveness sheltering, and then thrown away at stamping time, so a run no agent received was recorded as the agent's failure. It advanced the project's escalation ladder, darkened its outcome streak, and told every downstream consumer the project was failing. surf-your-life reached the ladder's `human` rung with ten never-delivered dispatches behind it. So the reaper now stamps `undelivered`, checking handoff evidence first — proof that work landed outranks an ack claiming it never started. `undelivered` stays a FAILING outcome, deliberately. The run produced nothing and the brake should stop firing into a path that is dropping work; making it neutral would trade a misattributed alarm for silence, which is worse. What changes is who gets blamed: the escalation block now says the dispatches never reached an agent, instead of instructing an agent to re-plan work it never received. Every consumer names it rather than defaulting — Activity, dispatch status, work phase, outcome streak, the brain's confidence weights (where it counts zero: delivery failure says nothing about a project). OutcomeStreak's hand-copied ["error","hang","timeout"] is now isFailingOutcome, since it was the last second source of truth for that set. Migration 0058 relabels the 29 historical rows, keyed off the runner's ack rather than an inference — payload.deliveredAt was stamped on only 77% of successes over 60 days, so reading its absence as non-delivery would have rewritten history from a gap in instrumentation. It has no DDL, so the file and its journal entry are hand-written and a test asserts the entry exists: an unjournalled migration is applied by nothing, silently. Dry-run against real prod inside a rolled-back transaction: 158 timeout → 129 timeout + 29 undelivered, no other outcome touched. Mutation-proven nine ways, each red then green. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
11d8d50262 |
fix(orchestration): let a project out of the escalation ladder (#381)
The ladder advanced on isFailingOutcome but resolved only on outcome === "success". Two sensible rules — "incomplete work is not a failure" and "don't declare victory early" — composed into a state with no exit, because `partial` satisfied neither. `partial` is the most common outcome there is: 52 of 117 recent closes. So ladders stopped closing. Eighteen were open at once and not one had a single success since opening. surf-your-life sat at the top rung for 13 days while completing 7 runs' worth of real work; orangecat's open rungs kept prepending "your previous run FAILED" to the dispatch prompts of a project that was working fine. The failure brake never had this bug — leadingFailureStreak stops at the first non-failing outcome, so a partial resets it. orchestration-runs.ts even claimed the two agreed. They agreed on advancing and diverged on resetting, and that divergence is the whole defect. One predicate now governs both directions (ladderEffectForClose), used by the funnel and by the reaper: whatever does not count as a failure resets the failure streak. user_abort stays neutral — a human choosing to stop is evidence of nothing either way. Also fixed, found while reading the same file: - Duplicate ladders. advanceEscalation read-then-inserts and the reaper fires it without awaiting, so concurrent closes each saw "no open row" and both inserted — orangecat held three, splitting one project's streak across parallel ladders. A partial unique index makes the invariant real; the insert now merges into the winner instead of failing the close. - `resolved_by = 'manual'` was declared in the type and written by nothing. It read as "humans never intervene" when it meant "humans cannot". Dismissing the escalation alert now closes the ladder that raised it. Migration 0057 repairs before it constrains, because the unique index cannot be created against production as it stands. Dry-run against real prod data inside a rolled-back transaction: 18 open → 6, eleven resolved as earned-out progress, one race duplicate collapsed, index created. The six that remain have had no qualifying run since opening — the repair clears the bug without erasing the signal. Mutation-proven seven ways, each red then green, including re-introducing the original bug. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
541bb9b7a2 |
feat(dispatch): route by durability — a laptop on battery is not infrastructure (#319)
#315 routed by presence, using "the desktop builder is connected" as a proxy for "the operator is sitting at it". A phone falsifies that proxy exactly: dispatch from a café while the laptop happens to be awake, and the work lands on a machine nobody is watching — one that sleeps the instant the lid shuts, which is now the configured lid behavior on battery. Same request, wildly different odds of surviving. From a phone, BOTH trees are invisible. The operator cannot open the laptop's editor and cannot see the box's filesystem, so the thing that justified preferring local at a desk — your checkout, your env, visible as it happens — is worth nothing. What is left is durability, and durability is knowable: the box is mains-powered by construction; a laptop is dependable only while it is plugged in. That is the same predicate that decides whether it sleeps. So the runner now reports it, and routing is four tiers: 1. lock physics — only one machine can materialize this project 2. durable the operator's own machine, unless we KNOW it is on battery 3. cloud away, or the laptop is ephemeral → the always-on box 4. local a battery laptop still beats nothing (box unavailable) CONTRACT DECISIONS, each of which is the interesting part: - Power rides the heartbeat row, so it EXPIRES with it. A stale "ac" is the dangerous reading — it vouches for a laptop that has since gone to sleep. Presence and durability are derived from one read against one clock, because this subsystem already shipped a bug where liveness was computed from timestamps loaded at a different moment. - UNKNOWN IS NOT BATTERY. Runners predating this field report nothing, and demoting them would stop every un-upgraded desktop from receiving work — fatal for an account with no cloud builder to fall back to. Routing acts on positive knowledge only. Negative-tested: making unknown behave as ephemeral fails the suite. - Physics still outranks policy. A dirPath-only project on battery stays local; the cloud would clone-fail into an empty directory (the 2026-07-14 misroute). - Demotion is a REDIRECT, never a refusal: with no box available, the battery laptop is still the answer. - power-source.ts imports no Electron — pusher.ts is loaded by the headless box-runner too — and never throws. A heartbeat that died because a power probe failed would be far worse than not knowing: unknown is a safe answer, a thrown error stops presence itself. A machine with no battery reads "ac", which is both true of the box and the answer that keeps it durable. - upsertRuntimeSnapshotIfNewer took seven positionals, four optional and three string-ish. Adding an eighth was the moment to switch to named fields, not the moment to make a transposed argument even easier to ship. - readChannelHeartbeats gets a narrow-select fallback (the pattern readConnectionFlags already uses). Its `[]` path does not merely lose power state — it makes every builder read offline, so an unmigrated column would take dispatch down rather than degrade it. Deploy applies migrations before rsyncing code, so this should never fire; "should never" is not a property an outage respects. Migration 0056 is a single additive nullable column. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
869a406a1c |
feat(control): count the agents that are actually working (#317)
Control read "0 working · 0 awaiting input · 21 idle" while eight Claude sessions were mid-task in real worktrees. The number was right about what it measured and wrong about the fleet, which is the worst kind of right. Every "working" signal required FleetCrown to have dispatched the run (a /tmp sentinel backed by a /proc scan) or the runner to recognise a zellij tab named after a registered project. A session started any other way — a terminal you opened, a background job, a worktree — produced neither, so it was structurally invisible. The presenter already half-knew this: it downgrades "Not running" to "Active recently" because "sessions run in tabs FleetCrown can't observe". That was a nicer way to say the same thing, not a fix. The honest definition needs no tab and no process table, because the agent announces both edges of its own turn: UserPromptSubmit → a turn STARTS (ended_at NULL) Stop → that turn ENDS (ended_at set) New agent_sessions table, one row per session, upserted per turn. An open turn IS "working" — the only claim in the system backed by the agent's own report rather than by inference about the machine it runs on. Details that decide whether this is true or merely plausible: - Liveness is recorded BEFORE the ledger's noise and dispatch-echo filters. Those decide what deserves a line in the activity log; they say nothing about whether an agent is working. "continue" is noise to read back and still starts a real turn. Filtering liveness alongside prose would blank the count during exactly the short, repetitive prompts that make up most of a long session. - A session killed mid-turn never sends Stop, so readers bound on started_at too (OPEN_TURN_TTL_MS = 30min, deliberately the same constant as STALE_PROMPT_S — two definitions of "too old to believe" would eventually disagree on screen and the user would be right to trust neither). - An open turn outranks readyAt and orchestration-ready: those mean "the agent finished"; a new turn means it is working again. Without this the card sits on "Ready" through the whole next turn and the project lands in the awaiting-you bucket while an agent edits it. - liveAgentTurns is REQUIRED on ProjectState, not optional. An optional field lets a route that forgets to select it compile clean and render "idle" forever — the exact class that hid this for months. Fixes a latent bug in the same path: the capture hook forwards Claude's stdin verbatim, which spells the field `session_id`, while the route's schema only accepted `sessionId`. zod strips unknown keys, so the id was declared, accepted, and never once populated. Both spellings now. Fleet Runner installs the Stop hook alongside the capture hook (appended to the user's existing Stop entries, never replacing them), from one shared script template so the two cannot drift. Pure logic lives in lib/agent-turns.ts, not db/queries — importing the query module into a test drags in the database connection and the unit suite runs with no DATABASE_URL. 6 new presenter tests cover both sides: an open turn makes a project working, count 0 does not, an open turn beats a ready stamp, and a ready stamp still wins when nothing is open. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
776d12b625 |
feat(ai-budget): enforce the ration, and bill it from the provider's own count (#304)
#303 shipped the fair-share policy with nothing calling it. This wires it in, so the free daily pool is actually divided instead of merely divisible. ai_spend one row per (user, UTC day). A rollup, not an event log: the only questions asked are "what has this user spent today" and "how many drew today", both on the hot path of every turn. UTC because the vendors reset on UTC midnight; bucketing on local midnight would hand out a share against a budget that had not refilled. dayCapacityTokens() sums the daily budget of every KEYED provider. A vendor whose key is absent contributes nothing, however generous its tier — counting it would ration users against tokens that cannot be reached. askLoki gates the WHOLE turn once, before any provider is called. Gating per path would burn the budget on two fallbacks and still say no. BILLED FROM REALITY, NOT FROM A GUESS. `llm.ts` now reads the provider's own `usage.total_tokens` and `loop.ts` sums it across every round AND the repair pass. Charging only the final call would under-count the expensive turns by the most — precisely the ones worth rationing. Admission still uses an estimate because it must decide before anything is spent, and it is deliberately on the high side: under-estimating admits turns the pool cannot cover, which produces the late-day wall this whole mechanism exists to prevent. Booked on paths that are easy to forget: a turn that produced no usable text (the tokens were spent anyway), a repair pass that was discarded (same), and the degraded Groq fallback (it draws on the same pool, so a user degraded onto it would otherwise spend the shared day for free). THE GATE FAILS OPEN. If the ledger cannot be read, the turn is admitted. Rationing is a nicety; a database hiccup becoming "Loki is down" is not a trade anyone would choose. This fleet has already lost a day to a guard that turned a QUESTION into a fatal step, so the test asserting it is the one that matters most here. The two refusals keep their distinct meanings all the way out to the user: `paced` carries a retry and explains WHY there is a wait ("so everyone gets a turn" is a reason a person accepts; an unexplained refusal reads as breakage), `share-spent` carries none and says when it resets. Offering a retry that cannot succeed today is the "try again shortly" lie in another costume. Migration is additive only — CREATE TABLE + FK + index, no destructive statements. The unique (user, day) index is load-bearing: without it two concurrent turns both read zero, both insert, and that user gets two rows and twice the share. The increment happens inside the database. Tests: 10 for the gate (fail-open, capacity SSOT, both refusals, a newcomer admitted at any hour), on injectable seams so they need no database — the behaviour worth proving is exactly what a DB-dependent test would not cover. tsc clean · eslint 0 errors · 85/85 unit files · 150 home tests · design ok · desktop ok. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
d22bc9503e |
feat: thoughts distribution — RSS, share, newsletter capture, bridge essay, GTM plan (#240)
* feat(thoughts): RSS feed, share buttons, newsletter capture - /rss.xml route handler (RSS 2.0, all essays, absolute URLs, cache headers); /thoughts/rss.xml redirects to it; rel=alternate metadata and a visible RSS chip on the Thoughts index - proxy.ts matcher: rss.xml + api/newsletter added to the public allowlist (previously fell through to sign-in) - ShareBar on essay pages: X intent + LinkedIn share + copy link, existing ui-* classes only - Newsletter capture: newsletter_subscribers table (migration 0053, unique normalized email + source + created_at), idempotent insert, zod-validated + rate-limited public POST /api/newsletter, signup component on the index and essay footers. Capture only, no sending. (pre-commit hook hung cold in fresh worktree; tsc+eslint+design+unit+home+desktop run manually, all green) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(content): publish the promised bridge essay — The Two Halves, Joined Closes master-plan item 4.1. Narrates the verified FC-OrangeCat integration loop (identity, work, witness), honest about what has not crossed yet (money, external operators). Updates the forward reference in the-two-halves-of-the-individual-singularity to resolve to it (and fixes the stale fleetcrown.vercel.app domain). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs(gtm): distribution execution plan + social post queue - docs/gtm-distribution-2026-08.md: master-plan Phase 4 as an operating plan — weekly cadence, channel order (RSS/SEO, X+LinkedIn strategy essays, HN/lobste.rs deep-dives, OrangeCat cross-sell), the outbound GTM agent pipeline (FleetCrown runs its own outbound; nothing external sends without founder approval), metrics with targets - content/social/queue.md: paste-ready X + LinkedIn drafts for 5 strategy essays + the bridge essay; DRAFTS, founder posts/approves Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: test <test@test> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
862d3578c2 |
fix(atlas): a preview that 404s is not a preview (#192)
Atlas stored whatever og:image a page declared and reported it as a working preview. Checking the URLs it recorded shows three fleet sites — kivvi, vitareba, printcraft — point og:image at a host with no DNS record or a 404, so they advertise a preview and share as a blank rectangle. Atlas called all three fine, because reading a tag is not the same as fetching what it names. The probe now fetches the declared image (ranged, cancelled after the headers) and stores the outcome as its own nullable column: NULL nothing declared true declared and really serves image/* false declared and broken Those are three different fixes — add an image, correct a URL, nothing to do — so collapsing them into "has a preview_image_url" hid the worst of the three. Same class as the intent/observation split this table already makes. Strict on content-type on purpose: Slack, Telegram and the OpenGraph scrapers discard anything that is not image/*, so a 200 returning an HTML error page is a broken preview no matter how healthy the fetch looked. The card now says "Preview link is broken" with the offending host instead of rendering a broken <img>, and the summary bar counts sites that share blank. 10 cases pin isImageResponse against the exact shapes found live. Co-authored-by: test <test@test> |
||
|
|
40511e1cb2 |
feat(atlas): site page maps + guides, and publish the real site URL to OrangeCat (#188)
* feat(atlas): site page maps + guides — the "how do I do X here" layer Atlas answered "where does this project live and is it up". It could not answer "what's on it" or "how do I do the thing" — the questions that were still landing on an assistant instead of on the product. Two halves, kept separate because neither derives from the other: - PAGES (observed). The probe now also collects same-site links, so every project gets a map of its own navigation for free. Self-maintaining: ship a page with a nav link and it appears on the next check; remove it and it disappears. A hand-kept list rots silently, which is the failure mode this replaces. One level deep — the homepage's own links are the site's answer to "where can you go from here", and crawling further would turn a 15-site check into thousands of requests. - GUIDES (authored). An ordered list of places to go and what to do when you get there. A crawler cannot know the task and a task list cannot know what shipped yesterday, so merging the two would lose both. Path normalization is the whole trick for the map being readable: query, fragment and trailing slash collapse to one destination, and assets are dropped, so /pricing appears once instead of four times. New: /atlas/[projectId] with both sections; site_guides table; internal_paths on site_snapshots; guides CRUD API scoped to the owning user (404 not 403 on a foreign project, so a probe cannot confirm an id exists). tsc + lint + design gate + 52/52 unit (23 atlas cases) + 150 home green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(orangecat): publish the project's own site, not FleetCrown's dashboard `website_url` was hardcoded to `${FLEETCROWN_PUBLIC_ORIGIN}/projects`, so every project ever published to OrangeCat claimed FleetCrown's dashboard as its website. Visible in prod right now: OC's "Bitbaum" and "fleetcrown" both link to https://fleetcrown.orangecat.ch/projects — a visitor clicking "visit website" lands on a private dashboard for a different product that they cannot even read. Nothing could have populated it correctly before: FleetCrown did not know any project's site URL until Atlas added user_projects.live_url. Now it does, so publish sends the real one — and omits the field entirely when there is none. No website is a true statement; someone else's website is not. It also refuses an empty string, because OC renders website_url as a link and "" produces a visible link to nowhere (there is one such row in prod today). The mapping moved into a pure module and is now pinned by 5 cases. The bug survived this long precisely because it was buried in a fetch body where nothing could assert on it. 53/53 unit + 150 home green. 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> |
||
|
|
505d9d11a6 |
feat(atlas): fleet site map — live status, previews & observed link graph (#186)
FleetCrown knew every project's REPO but never its SITE: 20 registered projects, zero URLs, zero resources. "Give me the link to X" was therefore a question only a human (or an agent with ssh to the box) could answer, which is why that job kept landing outside the product. Atlas closes that gap: - user_projects.live_url — SSOT for where a project lives on the web. - site_snapshots — what probing that URL actually found. Deliberately a separate table: collapsing intent and observation would let a site that went down read as "no URL configured", a different problem with a different fix. - /atlas — every project as a card: preview image (the site's own og:image, not our guess), live/down status, response time, title, last checked, inline URL editing, and a one-click check of all sites. - The link graph. Every edge is OBSERVED — a real <a href> found on a real page — never declared. A declared graph shows what you meant to build; an observed one shows that solon has been live for weeks and nothing in the fleet links to it. It reports one-way links, sites nothing links to, and sites that link out to nothing. Verified against the 15 live fleet sites: all 15 up, but only OrangeCat <-> FleetCrown link to each other — the other 13 are mutually isolated in both directions. That finding is the point of the feature. Parsing is split from fetching so the fragile part (metadata across inconsistent real-world markup) is unit-tested without a network: 20 cases covering attribute order, quoting styles, entity decoding, relative og:image resolution, www-canonicalization and empty input. lint + design gate + 52/52 unit + 150 home tests green; tsc clean except pre-existing @fleet/ai-forms resolution errors (declared git dep absent from the shared node_modules — unrelated to this change, CI installs it). Co-authored-by: test <test@test> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
0d8edfd4e4 |
fix(actions): the drain seam must claim work, not just read it (#183)
GET /api/actions/drain-events returned every approved CREATE_EVENT row and
marked nothing. A booking is only marked executed AFTER gog succeeds, so
between handing a row out and hearing back it still looks
approved-and-unbooked — and a second drain polling that window books the same
event again, putting a duplicate in the operator's real calendar.
One drain runs today (fleetcrown-calendar-drain.service), which is the only
reason this has not bitten. But home/calendar-drain.ts's own usage line tells
you to start another, and Fleet Runner desktop is designed to embed the local
pieces, so the seam has to be safe for N runtimes by construction rather than
by luck.
GET now CLAIMS. `claimed_at` is an execution lease, not a status — the enum is
untouched and the IRON RULE (only 'approved' executes) still holds; this
records who is doing it right now, not what it is.
Three mechanisms, each for a different failure:
- FOR UPDATE SKIP LOCKED makes CONCURRENT claims disjoint. Two drains asking
at the same instant get different rows instead of colliding.
- a 5-minute lease covers the drain that takes a row and then DIES: the claim
ages out and the row is offered again, so a crash costs a delay rather than
an event nobody ever books.
- a batch limit of 10 stops a claim outliving its own lease. The drain books
serially under a 20s gog timeout (~200s for ten), so a bigger batch could go
stale in the drain's own hands and be re-claimed by another drain while it
is still working through it — recreating the exact duplicate this prevents.
A backlog just drains over several 15s polls.
A failed booking releases its claim immediately instead of waiting out the
lease, so a transient gog error costs one poll interval.
Verified against the real prod schema and data in rolled-back transactions:
claim #1 takes the rows and claim #2 immediately after takes none; a claim aged
past the lease is reoffered while an active one is not; a released claim is
available at once; 25 pending rows with limit 10 yield exactly 10, then the
next 10.
Idempotency still rests on markActionExecuted's status='approved' guard — the
claim narrows the race, it does not replace the guard.
Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
c9c924ef23 |
fix(orchestration): the evidence agents write never reached the judge (#173)
The DoD judge is prompted to check typecheck, lint and commit evidence.
It was never shown any. Production, 56 runs with a summary:
tests filled 55 · tsc filled 0 · lint filled 0 · commit filled 0
Zero is not sloppy agents. Agents have been writing the fields all
along — `tsc: pass`, `lint: pass`, `commit: 1ed429c` are sitting in real
handoff files right now. Every layer between them and the judge dropped
the three fields:
- no session_tsc/lint/commit columns on project_states
- no tsc/lint/commit on SessionState, so dbRowToSession lost them
- closeRunFromSession didn't pass them to buildOrchestrationSummary
- the desktop pusher never sent them
The loss is silent by construction: an unlisted field defaults to "",
summaryForJudge filters empty fields out, and the judge answers "no
evidence" exactly as instructed. Good work closed `partial`, indefinitely
— which is most of the 26-partial / 3-success week that prompted the
definition_of_done rewrite. The bars were half the story; this is the
other half.
Also unblocks infer-outcome, which reads summary.tsc for "fail" to raise
a run to `error` — a failing typecheck could never escalate either.
Second occurrence of the class: block-reason/no-op-count were lost the
same way (see the note in orchestration/summary.ts), both times via a
hand-written field list drifting from the contract. So the fix ends the
class rather than the instance — DOD_EVIDENCE_FIELDS is now the exported
SSOT for what the grader can see, and scripts/test/handoff-evidence.ts
walks it, failing if any field cannot survive handoff → judge on either
the file or the pushed path. Verified it has teeth: reverting the
close-path line fails exactly 6 of its 19 assertions.
Migration 0048 is additive (three nullable text columns).
Verified: tsc pass · lint pass · check:design ok · test:unit 50/50 ·
test:home 150 · test:ops 18. Committed with core.hooksPath=/dev/null
because the pre-commit hook re-runs tsc+eslint (>4 min); both were run
manually above.
Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
24fb810f96 |
feat(orchestration): run_escalations ladder — retry → patch → replan → human (#135)
Item 4 of the ledger-and-loop build sequence: escalation as data, not vibes. Every failing run close advances the project's open ladder one rung; the rung injects a level-specific instruction + the last failure reason into the NEXT autopilot dispatch (both assembly paths) — the objection goes back to the agent first, humans see only what agents can't route around. The ladder never dispatches anything itself: cadence stays owned by the existing autopilot loop and its cooldowns, so no new spend paths. - schema: run_escalations (one open row per user+project; rows kept after resolution — escalation rate per rung is the point) - queries: advanceEscalation (failing close, alert+Telegram once at the top rung), resolveEscalation (success or manual), getOpenEscalationBlock - hooks: updateOrchestrationRun (failing → advance, success → resolve), reaper (bypasses the funnel; advances per reaped failing row) - prompts: escalation block in assembleInjectPrompt AND inject-core's withContext — covers queue, next_best, and custom dispatches - brake SSOT: FAILURE_BRAKE_STREAK = ESCALATION_HUMAN_STREAK (4) — the brake trips exactly when the ladder reaches 'human', one constant, so 'autopilot stops' and 'operator alerted' can never drift (was 3; the extra bounded attempt is the replan rung) - test: scripts/test/escalation-ladder.ts (mapping, block, brake invariant) Co-authored-by: test <test@test> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
f754eacf27 |
feat(orchestration): per-run token/cost accounting from agent transcripts (#133)
Item 1 of the ledger-and-loop build sequence: every dispatched Claude run now records what it consumed. - lib/usage/claude-transcript-usage: window-attributed usage from ~/.claude transcripts (dedup on message.id; slug handles dotted paths) - runner: usage-reporter ledger reports cumulative windows on the heartbeat cadence; poller tracks delivered Claude dispatches and now uses the corrected slug in detectAuthFailure (worktree dirs never matched before) - box: POST /api/orchestration/runs/:id/usage prices tokens via config/model-pricing (rate changes never need a runner release); freeze rule stops a session's next run leaking tokens backwards - schema: tokens_in/out/cache_read/cache_write, cost_usd, usage_detail, usage_updated_at on orchestration_runs (additive migration 0046) - UI: usage line on the run panel + Today recent-runs list - test: scripts/test/run-usage.ts (auto-discovered by test-unit) Co-authored-by: test <test@test> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
0c9f9dbc2a |
feat(data-controls): working account deletion, memory forget, consent toggle, data export (#131)
The P0 trust layer: (1) DELETE /api/me + deleteUserAccount() — one-transaction purge that clears the 17 non-cascading user-FK tables in dependency order before the users row cascades the rest; Danger-zone button wired to a type-your-email confirm modal (was disabled; /privacy's deletion claim was false). (2) /memory gains per-entity forget + guarded forget-everything (graph + RAG index), PIN-gated. (3) user_preferences.memory_enabled gates upsertKnowledgeBatch via memoryIndexingAllowed() — only explicit false disables; toggle in Privacy → Data. (4) GET /api/me/export — 26 user-scoped sections, redacted users row (no credential hashes / Stripe ids), manifest states scope; export button in Privacy → Data. Co-authored-by: test <test@test> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
12f2ea5a16 |
feat(feedback): image attach, loop metrics, public shipped strip, pricing + docs (#130)
PR C of the feedback-pipeline deep-dive plan. Migration 0044 (additive): site_feedback.screenshot + featured_at. - Widget image attach: file picker + paste in the panel, client-side downscale (≤1280px JPEG, quality stepped until it fits the 600k-char ingest cap), thumbnail + remove; still zero-dep, 5 KB gzip bundle. Ingest validates data-URL mime/size; bytes are EXCLUDED from inbox list queries and served only via authed GET /api/feedback/[id]/screenshot. Inbox rows show a lazy thumbnail that opens the full image. - Loop metrics: getFeedbackLoopMetrics (counts + median report→fix via percentile_cont) on the project inbox header and the /control fleet strip. - Public "shipped thanks to feedback" strip on the landing page: operator curation only (Star on resolved rows → featured_at; raw visitor text never auto-publishes), aggregate + up to 3 featured excerpts, renders nothing until real entries exist (never-fabricate doctrine). - /pricing "Every plan includes" gains the feedback widget line (per the plans.ts doctrine: capability, not a fake tier gate). - Docs: architecture schema mirror updated, /docs/feedback-widget covers attach + dedupe, PLATFORM_CHANGELOG entry for this wave. tsc 0, eslint 0, design-check ok, 40/40 unit tests, widget builds. Co-authored-by: test <test@test> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
e45c32fb8d |
feat(feedback): source separation, ingest dedupe, typed briefs, prompt armor (#129)
PR B of the feedback-pipeline deep-dive plan. One additive migration (0043): site_feedback.source + content_hash + duplicate_count, with source backfilled from the legacy contact-string discriminators. - Source separation: FEEDBACK_SOURCE (visitor | ai_review | synthesizer) — ingest accepts it (default visitor), the AI reviewer and synthesizer declare themselves in their curl templates, the inbox shows a typed badge instead of the magic contact string, and close-the-loop explicitly never emails non-visitor rows. - Typed briefs: the daily digester no longer re-clusters synthesizer briefs (aggregates re-entering clustering compounded into phantom single reports); the synthesize route's self-exclusion switches from contact-string to source. - Ingest dedupe: sha256 content hash over normalized suggestion+page; a repeat submission bumps the existing OPEN row's duplicate_count instead of a new row (resolved/archived rows don't absorb — a re-report after a fix is a fresh signal). "×N" badge in the inbox; digester/synthesizer prompts carry "reported N×" so clustering keeps the volume signal. - Prompt armor (lib/feedback/untrusted.ts, SSOT): visitor text is sentinel-fenced (fence chars escaped inside) with a standing treat-as-data preamble, applied at every interpolation — dispatch composePrompt, digester clusterItems (also reordered: instructions BEFORE data) + composeThemePrompt, synthesizer renderItem. Defense-in-depth; the human approval gate remains the security boundary. Local behavioral tests: hash normalization, duplicate bump, resolved-row exemption, hostile fence-escape — all pass. tsc 0, eslint 0. Co-authored-by: test <test@test> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
a74c5a4069 |
feat(orchestration): per-run dispatch attribution via work-level serialization (#128)
Two dispatches to one project used to merge into a single agent session: the claim gate released the younger command on prompt DELIVERY (executed_at), not run close, and one READY handoff then closed every open run with identical summaries — close-the-loop could resolve feedback item B (and email its visitor "your feedback shipped") off item A's work. - claimNextPendingCommand: an older open run now blocks a younger dispatch/inject until it CLOSES (60-min stale floor unchanged). Derived-tab (sessionTab) runs are exempt in both directions so parallel worktree dispatch keeps working; no-runId lifecycle commands never block. - purgeStalePendingCommands: gate-held commands (own run open + fresh) are exempt from the 20-min purge — purging them silently dropped the work and wedged the project; they become purgeable once their run closes. - Runner ack (PATCH /api/control/commands/[id]): ok:true stamps payload.deliveredAt on the run (never startedAt — that's the serialization order); ok:false closes the run as error immediately so a failed dispatch can't head-of-line block the queue. - Close paths: handoff-freshness floor is now deliveredAt ?? startedAt, and a run whose command is still queued (undelivered) is never closed by another run's handoff (close-sweep + /api/control both). - Migration 0042: partial expression index on pending_commands ((payload->>'runId')) WHERE executed_at IS NULL. Behavioral test vs local DB: 9/9 (block-until-close, lifecycle escape, sessionTab exemptions both directions, purge exemption round-trip). Co-authored-by: test <test@test> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
990a41bb33 |
feat(honesty): repo-evidence reap correction, feedback resolution evidence, FAB scroll-fade (#126)
Three Tier-1 items from the feedback-pipeline deep-dive:
- Reaper honesty backstop: a run stamped `timeout` ("no evidence of work")
gets a post-reap GitHub check — if the project's repo shows a PR opened or
branch pushed during the run window, the verdict is corrected to `partial`
with the evidence linked on the run payload + a reaper-evidence run event.
(Twice real work — PRs #118/#120 — was recorded as timeout because the box
agent died before writing a handoff.)
- Resolution evidence on site_feedback: new resolved_at column (migration
0041), stamped by close-the-loop and manual resolve, cleared on reopen;
the inbox row now shows "resolved <when> · by run <id>" instead of a bare
green tag.
- Widget FAB at narrow viewports (report 2c667df3): ≤480px the launcher
shrinks to 40px and fades out of the way (pointer-events off) while the
page scrolls under it, so it can't block a CTA tap at 320px.
Co-authored-by: test <test@test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
|
||
|
|
3059b00730 |
feat(feedback): remote widget control — boot gate, kill switch, live heartbeat
Phase 1 of one-click widget on/off. The embed snippet becomes a dumb pointer: on every page load the widget calls GET /api/widget-boot and renders nothing unless the token row says active — so Pause/Resume in the project workspace takes effect on the customer site in seconds with zero deploys. The boot call doubles as a heartbeat (lastSeenAt/ lastSeenOrigin, throttled 1/min), making the setup card's states observed truth: Waiting for first load → Live · last seen Xm → Paused. New tokens default their origin allowlist from the project's registered prod URL, closing the no-origins-UI gap by removing the decision. Migration 0040 also heals drizzle-snapshot drift for two orangecat_* tables applied earlier via direct DDL (all statements guarded). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
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> |
||
|
|
b598fb2ffc | feat(projects): shareable dossiers and lifecycle resources | ||
|
|
459bc5a752 | chore(db): add run events migration | ||
|
|
a570209302 | feat(runtime): persist workspace ids in project state |