Commit Graph
279 Commits
Author SHA1 Message Date
CatoandClaude Opus 5 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>
2026-09-05 17:04:53 +00:00
CatoandClaude Opus 5 b5394c98fb fix(widget): a long name in "Name / email" threw the whole report away (#505)
Found by a code-health audit; these are the two findings that were verifiably
BREAKING something rather than merely untidy.

── The widget dropped reports ────────────────────────────────────────────────

/api/feedback validates with zod and, on ANY failure, returns the single string
"Invalid submission" naming no field. The widget renders that and the visitor's
report is gone.

Of the five string fields it sends, three were clamped to exactly the route's
`.max()` and two were not:

    url        .slice(0, 1000)   matches max(1000)   ✅
    pageTitle  .slice(0, 300)    matches max(300)    ✅
    suggestion textarea maxLength = MAX_LEN 2000     ✅
    contact    (unclamped)       server max(200)     ✗
    page       (unclamped)       server max(300)     ✗

The contact <input> had no `maxLength` either, so a visitor pasting a signature
into "Name / email" — or anyone on a page with a very long pathname — lost
everything they had typed, with no field named and nothing logged. This is the
only surface strangers on other people's sites touch.

The author plainly knew the rule: MAX_SHOT_CHARS carries the comment "ingest
caps the data URL at 600k chars". It was applied 3 times of 5, which is what a
hand-mirrored constant does.

scripts/test/widget-server-caps-mirror.ts now reads the caps out of the zod
schema and asserts the widget clamps to the same numbers, so the two cannot
drift again. Mutation-proven: drop the contact clamp -> 8 passed, 1 failed.

── A tap target 16px under the floor ─────────────────────────────────────────

ProjectProvision's chip carried `ui-btn-chip gap-1.5 px-3 py-1.5 text-xs`.

`ui-btn-chip` is NOT in the coarse-pointer floor list in globals.css — it
reaches 44px through its own `py-3`. Overriding that to `py-1.5 text-xs`
without adding `ui-tap` produced roughly 28px on a phone, visibly shorter than
the seven identical sibling chips (ProjectBriefFill ×4, BusinessPlanSection,
ProjectDocSync) which all carry `ui-tap`.

audit:responsive reports zero undersized targets and is right to: this button
lives on /projects/[id], and the audit's page list has /projects but no detail
page. The gate is not wrong, its coverage is — worth knowing before trusting a
green run on a page it never opens.

pnpm run verify green.


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

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 09:17:29 -07:00
9017717127 feat(mobile): summary stats become one line, and the widget stops covering Loki (#496)
Two things, both measured rather than assumed.

── The stat cards ────────────────────────────────────────────────────────────

StatCard rendered a kicker, a 2xl number and a sub-line inside a padded card —
about 130px — and three of them stacked two-up. /goals therefore spent ~280px
of an 844px phone on "19 active · 24% avg progress · 23 total" before the first
goal, and none of those figures is a decision. You scrolled past all of it to
reach the list the page is named after.

Below `sm` they are now one horizontally scrollable line of chips, value first.
Nothing is dropped — label, value and sub all survive; the layout reorders with
flex `order` rather than duplicating markup. From `sm` up, where height is free,
it stays the card grid it always was.

The chip strip is not a new invention: /today's SummaryBar already answers this
exact job, so this borrows an idiom the app has proven instead of adding a
second way to show the same thing. Lands on /goals, /money, /habits and /memory
from one change.

StatCard no longer builds on <Card>: Card hard-codes the padding and radius the
chip shape would have to fight.

Checked before trusting it, because this repo has a recorded Tailwind 4 trap
about variants inside `@layer components`: the LIVE stylesheet already compiles
`.ui-card-padding`'s sm:/md: variants to real `@media (min-width:40rem)` and
`(min-width:48rem)` rules, so the pattern works in this build.

── The goal row ──────────────────────────────────────────────────────────────

Four icon controls per goal — Loki, copy, archive, delete. `ui-hover-reveal`
kept them out of the way on desktop, but a phone has no hover, so on the
viewport with the least room all four were permanently visible next to the
goal's own title. None of them is the action a person repeats (that is editing
progress, inline in the card body), so all four move behind one RowActions
trigger. The two prompt helpers gain optional `className`/`label` so they can
render as words in a menu instead of a lone glyph among sentences.

── The feedback widget on /loki ──────────────────────────────────────────────

Measured at 390px: the launcher's centre resolved to
`textarea.ui-loki-composer-input`. It covered the box you type into, on the
page whose whole purpose is typing into it.

NOT a failure of the widget's avoidance logic, which is worth stating because
the obvious fix would have been wrong: `INTERACTIVE` already matches `textarea`
and the 260px shift cap was never reached. autoAvoid moved the launcher 164px
up and correctly found a clear spot — then the composer reflowed under it when
the conversation list loaded. The widget re-checks at two fixed moments after
paint, not on layout change, so a late reflow wins. Fixing that properly means
a ResizeObserver in a bundle that runs on other people's sites.

So /loki joins /terminal in FEEDBACK_WIDGET_EXCLUDED_PREFIXES, for the reason
already written there: the surface has its own composer.

feedback-widget-reach.ts asserted /loki WAS reachable and duly failed. It now
asserts the exclusion with the measurement behind it, so the change reads as a
decision rather than a typo, plus a /lokis near-miss case.

pnpm run verify green.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 13:21:25 +00:00
ee52eabfb7 refactor(email): move transport to @bitbaum/mail-kit (#495)
Replace the Resend SDK transport in src/lib/email.ts with the fleet's
@bitbaum/mail-kit. Templates and the sendEmail/sendEmailFire signatures
stay; the transport underneath is now sendMail (never throws — the
awaitable sendEmail preserves its old throw-on-failure contract for
callers). Sender SSOT moves from EMAIL_FROM to RESEND_FROM (mail-kit's
env contract) with conventionalFrom(APP_NAME) as the fleet-default
fallback; APP_EMAIL_FROM is gone from brand.ts and the env preflight now
warns on missing RESEND_FROM. The email-canary cron probes via
mailHealth() instead of a hand-rolled /domains fetch, and the digest
cron passes an idempotency key so a retried tick cannot double-send.
The resend dependency is removed.


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>
2026-09-05 11:24:54 +00:00
87bac87e96 fix(activity): pin the time formatters, ending the React #418 on /activity (#494)
/activity threw away its hydrated tree on every viewport, in production only.
This was written off earlier as "intermittent, diminishing returns". It was
neither — it was two faults of the same kind, one of them rare enough to look
like noise.

MEASURED, on ONE page load: 1798 words server, 1798 words client, and every
clock differing by exactly two hours.

    server   Sent 10:18   Sent 09:54   Partial 04:00
    client   Sent 12:18   Sent 11:54   Partial 06:00

UTC on the box, Europe/Zurich in the browser. Five formatters in
activity-shared.ts called toLocaleTimeString/toLocaleDateString with no
`timeZone`, so they read the RUNTIME's zone — and their callers
(ActivityEventRow, EventStream, NeedsYouCard, ActivityTimeline) are
"use client", so they render in both processes.

Pinned to DEFAULT_TIMEZONE, which already exists as the app's SSOT. Pinning
beats the mounted-gate the greeting uses: these are PAST events, not "now", so
there is no reader-dependent answer to defer to and deferring would only trade
a wrong first paint for an empty one.

formatDayHeading carried the same fault in a two-hour window: it compared
`new Date(y, m-1, d)` against now.getFullYear()/getMonth()/getDate(), all
runtime-zone, so between 00:00 and 02:00 Zurich the box was still on yesterday
while the browser was already on today. THAT is why the failure presented as
intermittent — one run in three. It now compares calendar-date strings in a
fixed zone, and formats the fallback as UTC midnight rendered in UTC, because
a bucket key names a calendar day rather than an instant.

The first hypothesis was WRONG and is worth recording: the pulse's
"busiest: 20 at 09:21" label looked like the culprit, but ActivityPulse is a
server component and the client never re-renders it. Two measurement attempts
were wrong before one worked — a detached DOMParser document has no layout so
innerText collapsed the page to a single line, and rendering with JS disabled
skipped everything because React streams suspended content into `<div hidden>`
that only a script unhides. Both made the page look like it had no server
render at all.

The gate (scripts/test/activity-time-zone-stable.ts) runs the formatters in
three child processes — UTC, Europe/Zurich, Pacific/Honolulu — and compares
their output. Grepping the source for "timeZone" would pass a formatter pinned
to the WRONG zone and would say nothing about date arithmetic. Its fixture is
22:30 UTC deliberately: that is 00:30 the next day in Zurich, so a noon
fixture would pass on the broken code.

Mutation-proven: remove the pins → 4 of 5 fail, reporting 22:30 / 00:30 /
12:30 — the production symptom exactly; restore → 5/5. Picked up automatically
by test-unit's directory glob.

pnpm run verify green.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 10:49:10 +00:00
a3dc681e0c fix(activity): show the ask, not the retrieval block wrapped around it (#492)
/activity exists to answer "what did I ask for?". Every row of the Needs-you
list on production answered:

    asked: ## Relevant context from your other projects…

That is retrieval scaffolding, presented as the operator's own question.

The recovery machinery was already right. ENVELOPE_BLOCK_PATTERNS carried

    ## Background context from your other projects        (inject-prompt.ts)

while the RAG block emits

    ## Relevant context from your other projects (retrieved)
                                       (db/queries/knowledge-embeddings.ts)

Different heading, so the pattern never matched, so the block survived into
the preview. Nothing failed — the list's own comment predicts exactly this:
"a block that changes upstream stops matching". It did, and the degraded
behaviour was invisible because a noisy preview still renders.

A second hand-kept list checking the first would rot the same way, so
scripts/test/dispatch-headings-stripped.ts DISCOVERS the headings from the
pipeline source and tests behaviour: build a dispatch around each one, assert
the heading does not survive and the task does. It is picked up automatically
by test-unit's directory glob (134/134).

Getting that fixture right mattered twice: background blocks run to
end-of-input unless the "Project context & goals" sentinel follows them, and
the exit contract genuinely consumes to the end. The first version failed on
every heading for reasons unrelated to the bug.

Mutation-proven: drop the new pattern → 9 passed, 1 failed, naming that
heading; restore → 10/10.

Also on the pages themselves:

/people printed the name twice. The alias filter excluded an alias equal to
the WHOLE name, so a person stored as ["Manuel", "Riegner"] rendered
"Manuel Riegner" with "Manuel · Riegner" beneath it — the name again, split
up, dressed as extra information, on most of 2,749 rows. An alias whose every
word already appears in the name is now dropped.

Its "+ Details" button did not show details — clicking the card does that.
It opens the log form with channel/direction/summary, so it says "Log details".

/money's burn tile joined currencies with " + ": "50.00 CHF + 329.60 USD",
which wrapped mid-figure at 390px and claimed a sum that cannot exist without
an FX rate this page does not have. One line per currency. StatCard's `value`
widens to ReactNode; every existing caller passes a string and is unaffected.

pnpm run verify green.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 09:53:04 +00:00
cf3d9ed52e fix(deploy): hand the VAPID public key to the build, so push can work at all (#490)
#488 stopped the hydration failure by rendering nothing until past the server
render. It could not restore the feature: the browser still received an empty
NEXT_PUBLIC_VAPID_PUBLIC_KEY, so subscribe() had no application server key and
push notifications were dead in production regardless.

The missing half was never in the code. deploy.yml's build step declared no
`env:` at all, so every NEXT_PUBLIC_* was inlined empty while the box ran with
this one set. Fixed by creating the repo variable and passing it to the build.

A variable, not a secret: the value is compiled into the client bundle and
handed to every browser that subscribes. Hiding it would be theatre, and a
secret's log masking would only obscure the verification.

Verified before trusting the value, because a wrong key fails silently at send
time and this one gets baked into every future bundle:

  - decodes to 65 bytes, first byte 0x04 — a valid uncompressed P-256 point
  - the public key is the MATE of VAPID_PRIVATE_KEY on the box (derived the
    point from the private scalar and compared; no secret printed)
  - VAPID_SUBJECT is a valid mailto:/https: scheme

One trap on the way: the box stores the value quote-wrapped (len 89 = 87 + 2).
dotenv strips those when the server loads them, so runtime was fine — but
copying it verbatim into the variable would have inlined literal quotes and
produced a broken key that looks correct in every listing.

The gate's KNOWN_GAPS entry is deleted rather than edited, so removing either
the variable or the env: line now fails the check instead of silently killing
push again. Mutation-proven both ways: line removed -> 4 passed, 1 failed
naming the var; restored -> 5 passed, 0 failed.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 08:27:25 +00:00
bfaf7b67cc fix(shell): the React #418 on every authenticated page, and the gate for its class (#488)
A NEXT_PUBLIC_* value has TWO origins and nothing checked they agree: the
SERVER reads it at RUNTIME, the BROWSER gets whatever was INLINED at BUILD
time. deploy.yml's build step declares no `env:` at all, so the client bundle
ships with every NEXT_PUBLIC_* empty while the box runs with
NEXT_PUBLIC_VAPID_PUBLIC_KEY set.

NotificationsPill returns null when `publicKeyMissing`. So the server said
"configured, render the bell" and the client's first render said "not
configured, render nothing" — React threw the tree away. Every authenticated
page, production only.

PROVEN, not inferred:
  server-rendered HTML          1 notifications button
  hydrated DOM                  0
  VAPID key in client chunks    0 of 17 (1.1MB scanned)
  /opt/fleetcrown/app/.env      sets exactly one NEXT_PUBLIC_* — that key

Six other hypotheses were tested and DISPROVED first, each by a discriminating
test rather than a plausible story: the feedback widget (blocking widget.js
leaves the error), the banner's localStorage (flag is null, both sides compute
false), ThemeToggle (already mounted-guarded), AppShell (defers to an effect),
HTML caching (no-store), and the server's UTC clock vs the browser's — that
last one fit the evidence perfectly and was killed by forcing three browser
timezones and getting one error in all three.

THE FIX. Render nothing until past the server render, so the first render is
unconditional whatever the environment says. Via useSyncExternalStore rather
than mounted-in-an-effect, because BrandVersion already does it that way and
react-hooks/set-state-in-effect bans the other. Verified against a local
production build: the SSR HTML went from 1 notifications button to 0.

This is defence, not the whole cure. While the key is missing from the bundle,
push notifications are genuinely DEAD in prod — the browser sees an empty key,
so subscribe() cannot run. Closing that needs a repo secret (none exists:
`gh secret list` shows only HETZNER_SSH_KEY and RELEASES_REPO_TOKEN) plus an
env: entry on the build step. That is George's to do; it is recorded in the
gate rather than in a message that scrolls away.

THE GATE. scripts/test/public-env-inlined.ts compares what src/ reads against
what actually reaches the bundle — deploy.yml's build env AND next.config.ts's
own `env:` block, because a checker that knows one mechanism and not the other
cries wolf. It narrows to vars .env.example says a deployment SETS: one absent
from both build and runtime cannot diverge, both sides just use the default.
Both narrowings came from the check being wrong first — it initially flagged
six vars including NEXT_PUBLIC_BUILD_SHA, which visibly renders in the footer.

Mutation-proven: remove a recorded gap -> 5 passed, 1 failed, naming the var;
restore -> 6/6.

pnpm run verify passes (133/133 unit files, `✓ public-env-inlined`).


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 16:30:21 +00:00
55a3c0e4e0 fix(ci): catch an unbumped desktop change on the PR, not on main (#486)
Today a dependabot bump turned main red and stopped the merge queue. The gate
was right; its TIMING was racy, and the race is the whole bug.

What happened, in order:

  #482 merges, mints fleet-runner-v0.8.16.
  #411 (dependabot, touches ONLY desktop/package-lock.json) had already run its
       CI while v0.8.15 was newest. Against v0.8.15 its base ALREADY read
       0.8.16, so "version is ahead of released" held — CI PASSED.
  #411 merges. Newest tag is now v0.8.16, the only desktop change since it is
       that lockfile, and the identical check goes RED on main.

Both evaluations were correct. The gap is between them, and everyone else pays:
the sweep merges nothing onto a red base, so every unrelated PR stalls behind a
bot's dependency bump. #483 failed CI on a diff that touched no desktop file.

The existing question is cumulative — "has anything changed since the last
tag" — and its answer moves when a tag is minted, i.e. for reasons outside the
branch. So ask a second question that has no race in it:

  does the diff of THIS BRANCH touch desktop/, and if so
  does THIS BRANCH bump desktop/package.json?

Decided entirely within the branch, identically before and after any tag
appears. It fires on the PR — one blocked bot PR a human can see — instead of
after the merge, where it is a red main and a stopped queue. On main itself the
branch diff is empty and the rule does not apply; the cumulative check still
guards there.

Mutation-proven:
  desktop change, no bump  -> exit 1, "this branch changes desktop/ but does
                              not bump desktop/package.json", naming the file
  + bump, no changelog     -> exit 1 on the pre-existing changelog rule
                              (the two compose; a bump alone is still not
                              publishable)
  neither                  -> passes, rule correctly silent

This is the fix I would rather have than the automation I had offered — opening
a bump PR after the fact repairs the outage; this prevents it.

pnpm run verify passes.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 13:50:19 +00:00
5e4192e4d1 fix(control): stop offering back the prompts nobody reuses, and the clamp that never clamped (#482)
Found by using /control in a browser as a user, on a phone-width window,
start to finish: pick a project, type a prompt, send it, follow the outcome.

1. "PASTE FROM HISTORY" WAS SHOWING THE OPPOSITE OF WHAT IT PROMISES

The card offered back conversational asides — "you do it. open in browser and
do it" — as reusable work. Not a rendering bug: those really were dispatches.
The selection was wrong.

Measured on prod, 30 days: 1859 distinct custom prompts, of which 1823 (98%)
were sent exactly ONCE. The query ordered by recency, so it surfaced the three
most recent one-offs — by definition the prompts least likely to be wanted
again — while the genuinely reused ones sat unoffered: "continue" 115×, a
git-diff review prompt 63×, "go ahead" 14×, "keep going" 8×.

Requiring two uses cuts the pool from 1859 to 36 and leaves exactly what the
feature is named for. Nothing is lost: Activity keeps every dispatch with a
re-run control. One-offs just stop competing for space on the card.

2. THE CLAMP I SHIPPED IN #479 WAS INERT, AND I COULD NOT SEE IT

`block ... line-clamp-2` computes to `display: block; -webkit-line-clamp: 2`.
`-webkit-line-clamp` does nothing without `display: -webkit-box`, and
Tailwind's `block` utility overrode it. It LOOKED fixed because an unclamped
box just wraps — which reads fine until the sentence is long.

Checked live in the browser: a 460-character next_step grew that box from 48px
to 96px and pushed the composer, the thing you act with, off the bottom of the
viewport. So my "it renders fully now" was measuring the ABSENCE of a clamp.

Dropping `block` makes it work; three lines, not two, so a typical next_step
(~256 chars) still reads in full and a pathological one is bounded and
reachable (clicking loads the whole text into the composer).

THE GATE: responsive-audit now flags a line-clamp that is declared but not
enforced. It cannot test `display === "-webkit-box"` — Chrome reported
`flow-root` for a clamp working correctly — so it tests BEHAVIOUR: an element
declaring N lines that renders more than N. Run against live prod it says:

  "Suggested next (profile)…"[ui-link-subtle-button.block.line-clamp-2]
  declared 2 lines, renders 4 (display:block)

naming the offending class. That is this exact bug, caught in shipped code.

3. A FAILURE MESSAGE THAT NAMED THE WRONG AGENT

A real dispatch returned: "launched claude (pty) + injected, but the agent
isn't generating yet … Retry, or switch the project agent away from grok if
this repeats." One sentence naming the agent that ran and, as advice, one that
did not — a literal left over from when grok was the default. `agent` was in
scope; the auth branch above it interpolates it correctly.

Gated in failure-message-pairing: a failure message that NAMES an agent must
interpolate ${agent}. Stated that way rather than "no agent ids", because the
auth message legitimately says `~/.claude/.credentials.json` and `claude
setup-token` — a real path and a real command — and already names the right
agent. The check joins `+` continuations so a message split across two lines is
judged whole; per-line it got that one wrong.

Mutation-proven: restoring the "grok" literal → 20 passed, 1 failed, naming the
line. Restored → 21/21.

pnpm run verify passes.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 12:20:44 +00:00
1647fe7987 fix(sweep): a test that rotted behind a wrong excuse, and a box spec off by 2x (#480)
Three follow-ups from sweeping the earlier findings. Two of the four I had
carried forward did NOT survive checking and are dropped: /api/control/dispatch
is a real route, so the docs referencing it are correct; and
scripts/test/push-notifications.ts exists. Verifying first is why this commit
is smaller than the list that prompted it.

1. THE TEST NOBODY RAN, FOR A REASON THAT WAS NEVER TRUE

scripts/test/push-notifications.ts read scripts/agent-hook-bridge.sh, which was
deleted on 2026-06-11 in 956ccf64 ("delete the bash daemon and bridge files").
It threw ENOENT and the suite exited 1. Its entry in test-unit.ts SKIP said
"needs push/web-push env — run manually". That was never the reason: every
check in the file is a static file read and it needs no environment at all.

A wrong skip reason is worse than no skip. It answers the question that would
have found the bug, so the red looked accounted for and nobody looked again for
three months.

Retargeted rather than deleted. The behaviour moved instead of going away — a
closing run reaches the operator through notify-close.ts → pushToUser →
push-fanout — and scripts/test/notify-close.ts covers that module without
mentioning push at all. So "an agent finished, tell the operator" was asserted
by nobody. Deleting the check would have quietly ratified that hole.

Removed from SKIP, so it now runs in test:unit (132/132) and therefore in CI.
Mutation-proven: renaming the pushToUser call fails with "notify-close must
call pushToUser" (exit 1); restored, exit 0.

2. THE BOX IS HALF THE MACHINE THE DOCS DESCRIBE

Measured 2026-09-04: nproc 4, 7746 MiB, 75 G disk, 4 GB swap. That is a CX33.
Three docs said CX43, 8 vCPU / 16 GB, 40 GB disk — every figure but the swap
wrong, in the direction that matters: planning against 16 GB on an 8 GB box is
how you meet the OOM killer.

src/app/api/system/hetzner/route.ts has said "the box is a cx33" all along, so
this was code and docs disagreeing with the code being right. Note the shape of
the drift: CPU and RAM went DOWN while disk went UP (40→75), which is what a
disk-inclusive rescale to a smaller tier looks like — plausibly to escape the
disk-full problem the old caveat describes. The June runbook entry is kept as
history and marked superseded rather than rewritten.

The docs now point at /api/system/hetzner instead of restating numbers. A
hardcoded spec is a second source of truth that rots silently, which is exactly
what happened here between June and September.

3. THE COMPOSER STATUS, FINISHED

#479 gave this line its own row below `sm` but kept `sm:truncate`, which left it
at 57% on a 1440 viewport — "Autopilot on: queue is empty, so FleetCr…". That is
the same defect as the phone's 14%, just less obvious, and there is no `title`
here so the remainder is unreachable at every width. It now wraps everywhere.
Costs one toolbar line when the sentence is long; truncating cost the half of
the sentence that says what will happen.

pnpm run verify passes (repo moved to pnpm in #478).


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 11:16:58 +00:00
60dac488b1 fix(control): a sentence you can read, and the check that noticed it (#479)
/control's "Suggested next" line carried `truncate` — one line, ellipsis. On
prod that rendered "Suggested next (profile): Conduct a 1-month baseline m…":
594 of its 644 pixels hidden at 390px, 432 at 1440. The remainder existed
only in the `title` tooltip, and a phone has no hover.

It is the card's one actionable sentence, and clicking it loads the text into
the composer — so the sentence IS the decision, and a tenth of a sentence is
not one. OutcomeStreak.tsx, in this same directory, documents having already
fixed this exact mistake for its glyph row. /activity has always clamped the
same "what's next" content to two lines (ActivityEventRow). This makes the
three agree: line-clamp-2.

Same class in the composer's status line, worse: it shared a row with four
icons and Send, leaving it 72px — measured at 0% shown at 320px and 14% at
390px. Shorter copy cannot fix that; no sentence fits 72px. It needed the
width, so below `sm` it wraps onto a row of its own (order-last w-full) and
from `sm` up it stays exactly as it was.

THE GATE, and why it is not a lint rule.

responsive-audit already looks for clipped text, and deliberately EXEMPTS
`text-overflow: ellipsis` as "a deliberate design choice". That exemption is
right for what it was written for — a project name in a narrow rail, a
filename, an id — and 76 files under src/components truncate exactly that way.
A rule banning `truncate`, or `truncate` beside a `title`, would fire on ~42
legitimate sites and be turned off within a week.

The distinction is prose, which a static rule cannot judge but a real viewport
can measure. So the check lives where the viewports are: flag an ellipsis only
when the text READS as a sentence (>=60 chars, >=8 spaces — an id has neither)
AND under half of it is visible (a chip losing its tail is fine; a line showing
its first eight words is not).

Proven by mutation, in one environment, with only the classNames differing:
  - with `truncate`  -> 2 findings ("40% shown, -552px", "22% shown, -402px")
  - with the fix     -> silent at 320 / 390 / 768 / 1440
and it flags none of the 76 legitimate truncations.

Verified against prod before the fix (2 findings at 320 and at 390, silent at
768/1440 where the line fits) and against a local server after it.

npm run verify passes.

Separately observed and NOT addressed here: /control logs a React #418
hydration mismatch at every viewport.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 10:30:47 +00:00
1572e993e7 fix(control): the second wording of "no zellij", and a remedy nothing rendered (#477)
Two defects, one class, found by sweeping for the neighbours of #476.

1. `no zellij session found` fell through to RETRY. This is how the Fleet
   Runner desktop app words the condition that the cloud words as "no zellij
   session is running on the connected computer" — poller.ts:881, three lines
   from the `tab not found:` string fixed in #476. Only one of the pair had
   been taught to the classifier, so fixing that one left this one shipping a
   Retry that can never succeed.

2. FAILURE_REMEDY.START_TERMINAL had ZERO consumers in AttentionBar. So
   fixing (1) alone would have made things worse, not better: a correctly
   classified failure would render no action at all, leaving the row with
   nothing but Dismiss. A remedy nothing renders is a classification that
   silently does nothing.

Also names FOCUS_TIMED_OUT_DESKTOP (`did not gain focus`). That one already
reached the right answer — a focus race IS retryable — but by accident, via a
default that happened to suit it. An accidental right answer is
indistinguishable from a wrong one until the default changes.

The gate is the point. scripts/test/failure-message-pairing.ts reads the
literals poller.ts actually throws and asserts each is recognised by a NAMED
phrase, then asserts every remedy the classifier can return is rendered by
AttentionBar. Producer and matcher are two definitions of the same sentence in
two independently-released codebases; counting instances was never going to
work. Reword either side, or add a remedy with no UI, and this fails first.

Proven by mutation, both halves:
  - drop the NO_TERMINAL_DESKTOP matcher  -> 14 passed, 1 failed
  - drop the START_TERMINAL render branch -> 14 passed, 1 failed

npm run verify passes; the test runs inside test:unit by directory glob, so
it is live in CI without wiring.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 09:45:40 +00:00
CatoandMao Nakamoto 0c932c2251 fix(control): a Retry button that could never work, reported through the widget (#476)
Filed from /control via the feedback widget — "what is this? can you fix?"
against an element reading:

  focus_tab → fleetcrown failed: tab not found: fleetcrown … Retry

focus-failure.ts already exists to prevent exactly this. Its own note says a
Retry beside "tab not found" is a lie, because retrying re-issues an
identical command against a target that is identically absent. It also
predicts how the protection would break:

  "a message and a classifier that each spell the same sentence
   independently are two definitions that drift the first time someone
   rewords the copy — and the drift is silent, since a misclassified
   failure still renders a plausible button."

That is what happened, across a boundary the note did not consider. Two
codebases word the SAME condition differently:

  cloud    "no zellij tab with that name in any active session"  → matched
  desktop  "tab not found: <name>"  (desktop/src/main/poller.ts) → NOT matched

So focusing a project through a local Fleet Runner fell through to RETRY and
drew a button that could never succeed.

Fixed in the classifier rather than only in the desktop app, deliberately:
Fleet Runner is versioned and released independently, so every operator on
an older build would keep sending the old wording. A classifier that only
understands the newest client is one that lies about older ones.

Tests use the reported string verbatim — including the trailing "4m agoOpen
on ControlRetry" the element picker captured, since that is what actually
reaches the function — plus casing, precedence against NO_TERMINAL, and two
near-misses ("tab closed by user") that must stay retryable. Proven by
mutation: removing the new match fails the assertion.

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
2026-09-03 18:17:02 -07:00
CatoandMao Nakamoto 39aae9a651 fix(widget): don't offer a mic the site's policy forbids (#474)
Reported: "Microphone permission denied" on both FleetCrown and OrangeCat.
Measured in the browser rather than guessed:

  orangecat.ch  featurePolicyAllowsMic: false
                permissionState: "denied"   (not "prompt")
                getUserMedia -> NotAllowedError
  fleetcrown    featurePolicyAllowsMic: true
                permissionState: "prompt"   (works)

Two different situations behind one error message. OrangeCat sends
`permissions-policy: camera=(), microphone=(), geolocation=()` from
next.config.js. `microphone=()` is an EMPTY allowlist — denied for every
origin including the site itself — so the browser never shows a prompt at
all. There is nothing the visitor can allow.

The bug is ours: navigator.mediaDevices.getUserMedia still EXISTS in that
state, so isVoiceSupported() passed and we drew a "Speak" button that could
only ever fail, then blamed the visitor's permissions for it.

isVoiceSupported now consults document.featurePolicy, so a policy-blocked
site simply never sees the button — the same progressive enhancement the
function already applied to a missing MediaRecorder or an insecure origin.

An unknown answer means ALLOWED, deliberately: featurePolicy is
non-standard and absent in some browsers, and hiding a working mic there
would be a worse failure than a click that fails with a readable message.

This is the half that is centrally fixable — one bundle, every customer
site, including sites we will never see. The other half is not, and cannot
be: Permissions-Policy is the host document's decision by design and no
script can override it. So the customer-facing docs now say plainly that
the mic needs `microphone=(self)`, what the symptom looks like, and that
everything else in the widget works regardless.

Pinned by four assertions in scripts/test/widget-voice.ts covering denied,
allowed, API-absent and API-throwing. Proven by mutation: making the check
always return true turns exactly the "denies the microphone" assertion red.

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
2026-09-03 17:20:06 -07:00
d97fd69db1 refactor(deps): ai-kit comes from npm — @bitbaum/ai-kit ^0.6.2 (#473)
The package is now published to the npm registry as @bitbaum/ai-kit
(npm's typosquat guard blocked the bare name "ai-kit", hence the scope;
ai-kit PR #25 documents the rename — content is identical to the
github:bitbaum/ai-kit#v0.6.2 tag). The git pin is retired: the lockfile
no longer records the writer's ssh transport and npm-major-specific
resolution for this dependency, so the whole lockfile-writer trap class
dies with it. All imports move from 'ai-kit' / 'ai-kit/grounding' to
'@bitbaum/ai-kit' / '@bitbaum/ai-kit/grounding'.


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>
2026-09-04 00:11:06 +00:00
GandMao Nakamoto 46c21c22d4 feat(feedback): FleetCrown users can finally report bugs in FleetCrown (#472)
Asked directly: where is the feedback widget on FleetCrown itself, and how
does a user give feedback about the site they are using? Measured on the
live app — feedbackWidgetPresent: false, no widget script loaded at all.
The only thing in the corner is the Loki assistant button.

The widget was scoped to eleven public marketing routes by an allowlist
whose comment gave two reasons. Both were checked:

  "the FAB would collide with the app shell's mobile nav"
    True when written, and fixed earlier today. The widget now measures its
    corner and steps aside — rectangle matching for the desktop Loki FAB
    (56px at bottom:28, which the feedback FAB overlapped exactly), and an
    interactive hit-test below 480px for the mobile nav, which is inset-x-3
    and therefore too wide for the rectangle scan to treat as an obstacle.

  "in-app feedback already has Loki"
    Not true. insertSiteFeedback has exactly one caller — the widget's
    ingest route — and the word "feedback" does not appear in loki-core.ts.
    Telling the assistant "this button is broken" produces no site_feedback
    row, nothing in the triage inbox, nothing dispatchable. A signed-in
    user's only option was to tell the operator out of band.

So the rule is inverted: render everywhere EXCEPT a short list, each entry
carrying its reason — /terminal (a FAB over live PTY output covers what you
are reading), the auth routes (you are not in the product yet), and
/docs/feedback-widget (a launcher on the page documenting launchers is an
unanswerable "is this yours or the demo's?").

An allowlist meant every new page shipped with no way to report a bug on
it, and nobody noticed, because a missing feedback channel is invisible
exactly the way the problems it would have caught are.

PublicFeedbackWidget is now DogfoodFeedbackWidget: it is no longer public-
only, and a name that says otherwise is the kind of stale label this page
already had too much of.

Pinned by scripts/test/feedback-widget-reach.ts (42 assertions): every app
surface reachable, public ones still reachable, exclusions excluded
including nested paths, near-misses like /terminals and /settings NOT
swallowed by prefix matching, the widget mounted from the root layout so
new pages inherit it, and loki-core still unable to file feedback — the
premise that justified the old scoping.

Proven by mutation: restoring a public-only allowlist turns 20 assertions
red, including every app surface.

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
2026-09-03 13:11:59 +00:00
GandMao Nakamoto e654e8baed fix(projects): one element per anchor — tab panels own the hash (#471)
Left over from the tab conversion. The sections had ids from when they were
scroll anchors (`id="feedback"`, `id="settings"`, ...), and the new panels
took ids of their own — so both existed for the same concept: a panel
`panel-feedback` wrapping a section still called `feedback`.

That is not cosmetic. Every panel stays mounted, because they hold unsaved
drafts and poll while work is in flight. So loading /projects/<id>#feedback
handed the browser a real element to scroll to that was inside a HIDDEN
panel — native anchor behaviour racing the tab logic over the same name.
ControlInbox and FeedbackItemRow both link exactly that way, so it is the
common path, not an edge case.

The panel is the anchor now: `id={tab.id}`, `aria-controls={tab.id}`,
`scroll-mt-28` to clear the sticky tab bar. The six nested ids are gone.
What the browser scrolls to is what becomes visible.

Pinned by scripts/test/project-tab-anchors.ts rather than left to review:
it reads the tab ids out of ProjectWorkspaceView, asserts the panel uses
them, asserts no component under components/projects re-declares one as an
element id, and asserts ControlInbox still deep-links to #feedback — the
link that makes the invariant matter in the first place.

Proven by mutation: reintroducing id="feedback" on the section turns
exactly that one assertion red.

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
2026-09-03 12:44:39 +00:00
GandMao Nakamoto 1260cab156 fix(widget): auto-avoid did nothing in production — DOMRect does not spread (#467)
Shipped in #466, verified green by 38 assertions, and completely inert on
a real page. Found by probing the deployed bundle rather than trusting
the suite.

avoidOffsetY cloned its input with `{...own}`. At runtime `own` is a
DOMRect from getBoundingClientRect(), and DOMRect exposes left/top/right/
bottom as GETTERS ON THE PROTOTYPE, not own enumerable properties. So the
spread produced `{}`; every comparison became `undefined < number`, which
is false; and the function concluded, silently and without error, that
nothing was ever in the way. The launcher stayed at bottom:16 on top of
whatever it was covering.

Every existing assertion passed because their fixtures are object
literals, and those spread perfectly. The suite could not have caught
this — it was testing a shape the browser never produces.

Fixed by reading the four fields explicitly (toRect) at every boundary
rather than relying on the source object's shape: in avoidOffsetY, in the
loop's box arithmetic, and in probeCorner.

The regression test builds its fixture with Object.create over prototype
getters and NO own properties — the actual DOMRect shape. A class with
fields would not have reproduced it, since TypeScript compiles those to
own properties and the spread survives. Proven by mutation: restoring the
spread turns exactly that one assertion red.

Diagnosis path, since it was not obvious: reposition() WAS running (it
reset a vandalised inline style), probeCorner's filters all passed when
replicated by hand in the page, no exception was thrown, and boot served
autoAvoid:true. The only remaining suspect was the data crossing between
them.

Also: w-25 on the position preview was the only use of that utility in
the repo; w-24 is on the conventional scale.

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
2026-09-03 10:25:24 +00:00
GandMao Nakamoto 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>
2026-09-03 02:50:15 -07:00
GandMao Nakamoto f487cc3862 chore: delete 1,190 lines of dead code, two dependencies, and two lying snapshots (#463)
* chore: delete dead code, and two dependencies with it

Each deletion verified by grep in both directions before removal, and
`npm run verify` passes with all of it gone.

src/components/ui/button.tsx — zero importers. It was also the ONLY
consumer of @base-ui/react and class-variance-authority, so both come out
of package.json with it. A shadcn-style Button was always going to sit
unused in a repo whose buttons are ui-btn-* classes in globals.css; what
it actually cost was two dependencies in every install and audit.

The Atlas cluster. /atlas redirects to /projects and the NAV entry points
there too, so the only link to /atlas/[projectId] lived inside AtlasCard —
which nothing rendered. Removed:
  • AtlasCard.tsx, LinkSuggestions.tsx — zero importers
  • lib/atlas/suggest.ts, graph.ts — reachable only from LinkSuggestions
    and their own test, which is the shape of code kept alive by the thing
    that proves it works rather than by anything that uses it
  • scripts/test/atlas.ts — that test
  • GET /api/atlas and POST /api/atlas/refresh — zero callers
  • scripts/atlas-probe-once.ts, whose own first line calls it a
    "TEMPORARY ops runner (deleted after use)"

DELIBERATELY KEPT, because they are live: /api/atlas/site (HealthScore and
LiveUrlField both PATCH it), /api/atlas/guides, lib/atlas/probe.ts,
SitePages, SiteGuides, getAtlasRow, and the /atlas/[projectId] page they
render — it is reachable by URL even though nothing links to it, and that
is a different question from being dead. The /api/atlas demo-sandbox deny
prefix also stays: it still covers the site and guides routes.

* docs: date the two snapshots that are read as if they were current

HANDOFF.md and AUDIT_REPORT.md are point-in-time reports with no staleness
marker, so both keep being read as the present tense. Neither is rewritten
here — the reasoning in them is still worth having — but each now opens
with what was re-verified today and what it got wrong.

HANDOFF.md matters most because it literally opens "Read this first", so
a wrong number in it travels further than one in a reference doc. Verified:
desktop is v0.8.15 not v0.7.5, Electron ^43.4.1 not 33, ~57 schema modules
not 39 tables, the deploy uses the forward-only applier not drizzle-kit
migrate, its "next up" list is fully ticked, and the manual mirror step it
describes is automated.

AUDIT_REPORT.md has drifted in BOTH directions, which is the more
interesting failure: item 3 (bare box IPs) largely closed once
scripts/hetzner/_box-env.sh landed, while item 8 (god files) got worse —
1254→1297, 963→1044, 789→948. An unticked "LOW" item is not a stable one.

It also carried the private-zone PIN twice in its own text, including in
the line telling the operator to rotate it "because it is in git". Having
scrubbed that value from three scripts, the report had become the only
file in HEAD still publishing it. Both occurrences redacted. The item
stays OPEN: redaction is not rotation, and the history leak is unchanged.

---------

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
2026-09-03 01:27:19 -07:00
GandMao Nakamoto c41c1809e2 feat(widget): speak your feedback — plus the signals, escaping and docs that were lying (#462)
* fix(email): escape visitor text before it reaches an email body

feedbackShippedTemplate interpolated `excerpt` and `page` raw. Both are
visitor-authored — excerpt is the free-prose suggestion typed into the
widget on a customer's site, page is location.pathname read off that
site — and the resulting HTML is mailed from our own domain to an
address the same visitor supplied.

operatorMailTemplate, four lines below, escaped correctly with an inline
replace-chain. That is the tell: escaping was something each template had
to remember separately, and this one forgot. rss.xml had a third copy of
the same chain.

So the escape is now a named helper both callers share, covering the five
XML predefined entities (the two extra quote forms make it safe in an
attribute as well as a text node, so no caller has to pick a variant).

Also makes the templates importable without a database. logSend's
debug-logs import opened a DB client at module load, which every pure
template in the file inherited — the reason none of them had tests. It is
deferred into the function now; sending logs exactly as before.

Proven by mutation: reverting the escape turns exactly the three
injection assertions red, not the whole file.

* fix(feedback): stop a failed request from answering "nothing needs you"

Three surfaces read an empty array as an empty queue. An empty array is
also what a failed fetch leaves behind, so a 500 or a timeout rendered as
the confident answer "there is nothing here" — on the exact screens an
operator checks to be sure nothing is waiting.

- ControlInbox returned null when total === 0, so both fetches failing
  produced total silence. It now stays quiet while requests are still in
  flight (a failure that resolves fast should not flash), and once they
  settle with nothing, says which of the two happened. When one list
  loads and the other does not, the count renders with a note that it
  may be low rather than presenting a partial total as complete.

- FeedbackInbox dropped `error` from useFetch entirely and fell through
  to "No feedback yet". The load error is now aliased `loadError` —
  `error` was already the mutation error from useFeedbackActions, and
  that collision is how the load error came to be dropped.

- ProjectFeedbackSection treated a failed token GET as "no token", which
  offered "Enable & install" for a widget that may already be live on the
  customer's site. Not knowing is now its own state.

Every new branch is reachable only when a request actually failed; the
genuine empty states are untouched.

* feat(widget): let visitors speak their feedback instead of typing it

Typing a bug report on a phone, on someone else's site, is where most
reports die. The widget now offers a mic: record, the clip is transcribed,
and the text lands in the same textarea appended to whatever was already
typed. The visitor still presses Send — speech-to-text mishears things,
and a mic that auto-sent would file those mistakes under their name.

FleetCrown already had working transcription (terminal, Loki composer,
command palette) but the widget never got it. Two things were missing:

- CORS. /api/beacon/transcribe is public but answers no preflight and
  sets no ACAO, so a cross-origin caller can never read the response.
- Authorization. That route takes no token — it is guarded only by a
  per-IP limiter. Opening it cross-origin would have made it an
  anonymous endpoint that spends our Groq quota for anyone with the URL.

So this adds /api/widget/transcribe rather than widening the beacon
route: same fcw_* token that already authorizes ingest, same per-token
origin allowlist, per-IP and per-token rate limits, and Groq only — the
local-Whisper fallback spawns ffmpeg + python3 on the host, which is not
something to expose to anonymous traffic. The Groq step itself moved to
lib/transcribe.ts so both routes share one implementation instead of
growing two copies of the error mapping.

Also in the widget, from the same audit:
- Recording stops and the mic is released when the panel closes, so the
  browser's recording indicator never outlives the panel on a host site.
- Sub-44px touch targets (the 18px remove-image dot, attach button) get
  a coarse-pointer hit area without changing how they look.
- The pulsing record dot honours prefers-reduced-motion.

Progressive enhancement throughout: no MediaRecorder, or an insecure
origin where getUserMedia is undefined, renders no button at all rather
than a control that cannot work. Bundle 16.3KB -> 20.8KB.

/api/widget is classified "spend" in the demo sandbox — the repo's own
gate caught that omission before this commit existed.

* docs(claude): correct the claims that were sending agents the wrong way

CLAUDE.md is loaded into every agent session, so a false line in it is not
a stale doc — it is an instruction. Each of these was verified against the
code in both directions before editing.

- Session helpers. It named `getCurrentUserId()` and `DEFAULT_USER_ID`;
  neither has existed since 98e88b65. Zero hits in src/. The real API is
  `getApiUserId()` (routes) and `requirePageUserId()` (pages), 64 files.

- The executor model. It said home/ runs on the user's machine "not the
  hosted box", and that Fleet Runner desktop is the "sole" local executor.
  scripts/box-runner.ts is a systemd service ON the box that imports the
  same startWatcher, added in b62e3aeb to delete the laptop dependency,
  and is the DEFAULT per this repo's own SSOT. A third executor,
  scripts/hosted-runner.ts, also exists. Neither was mentioned. An agent
  reading the old text would reason about the wrong machine.

- Husky hooks. Documented as pre-commit tsc+eslint / pre-push test:home.
  Actually pre-commit is eslint on staged files with no tsc, and pre-push
  runs the whole `npm run verify` bundle plus smoke and prod dogfood. The
  practical consequence — pre-push takes minutes — is now stated.

- Dark mode. "always dark mode (.dark on html)" is not true: ThemeProvider
  sets defaultTheme="dark" and a ThemeToggle ships in 8 places. Light is a
  real state, so the old advice to lean on text-white/* would break it.

- Six named components do not exist (ProjectTile, AutopilotCard, PromptRow,
  FeaturedCard, CategoryBar) or survive only as type names
  (ProjectGrid/ProjectDetail). Replaced with what is actually on disk.

- /feedback had no row in the Views table and widget/ had no entry at all,
  despite being a top-level nav surface and the only code strangers on
  other people's sites execute.

Also closes the gap that let widget/ drift unnoticed: `npm run lint` now
covers it alongside src/ and home/. It passes clean today, so this costs
nothing and stops the next regression rather than documenting it.

* docs: delete the agent CLI registry spec

Three independent reasons, any one sufficient:

1. It contains a slur — "A new engineer (or the 'retard' user)" — in a
   public repo. That alone is not something to leave sitting in docs/.

2. Every script it analyses is gone: scripts/cockpit-daemon.sh,
   agent-hook-lib.sh, agent-hook-bridge.sh, and the _agent_definitions.sh
   it proposes creating. Its "high duplication areas" list describes a
   codebase that no longer exists.

3. Its central decision is now false. It names src/lib/agent-registry.ts
   the "Primary SSOT"; that file's own header says it is a compatibility
   shim over src/lib/agents/, kept only for back-compat, and that new code
   should import from @/lib/agents directly. An agent following this spec
   would extend the shim it is supposed to be migrating off.

The refactor this document proposed did happen — differently and better
(per-agent adapter modules, ~300 lines removed). The plan that lost is
not worth keeping as a description of the system that won.

README's link to it goes too, so the docs index has no dead entry.

* docs(widget): stop the architecture note describing a system that moved on

Corrections, each verified against code:

- It said "No rate limiter exists in FleetCrown yet — port revampit's".
  src/lib/rate-limit.ts exists, is owned by the shared limitkit package,
  and is already imported by the ingest route the same document describes.
  Left alone, that bullet is an instruction to write a second one — the
  precise mechanism by which this fleet accumulated 14 rate limiters.

- The API table listed 5 routes and omitted GET /api/widget-boot, which is
  the render gate, the remote kill switch, and the heartbeat behind the
  "Live" badge — i.e. most of what the surrounding prose sells. Added,
  along with the new /api/widget/transcribe pair.

- It claimed /widget.js is "immutable-cached with a version query". There
  is no version query and no cache rule for it; next.config.ts sets those
  for /sw.js only. The "upgrades ship centrally" story rested on caching
  behaviour nobody configured.

- Screenshot capture, the submitter email loop and auto-triage drafts were
  all listed under "Later (not now, YAGNI)" and "not in v1" while being
  shipped and documented elsewhere in the same file.

---------

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
2026-09-02 09:27:19 -07:00
GandMao Nakamoto e0cc0b52d4 feat(ai): wire an AI chain health tracker into every completion path (#460)
The chat/tool/vision chains (groq.ts, agent/llm.ts, vision.ts) already walk
Groq -> OpenRouter on failure and are correctness-complete, but nothing
recorded whether that walk was still succeeding. A chain that always has
somewhere else to try also always returns success-shaped output to its
caller, right up until every link is dead — at which point the failure looks
like any other and only a user complaint would surface it. A full AI outage
would have been invisible with zero observability anywhere.

- src/lib/ai/health.ts: shared ai-kit createHealthTracker({downAfter: 3})
  instance, matching the convention already adopted fleet-wide (aoz-housing,
  surf-your-life, truthseeker).
- src/lib/groq.ts callTextDetailed, src/lib/agent/llm.ts callModelWithTools,
  src/lib/vision.ts analyzeImages: each hand-rolled chain walker now records
  one success/failure per top-level call at its real success/exhaustion
  points (not per link — a later link answering is the fallback working, not
  a health problem).
- src/app/api/health/route.ts: exposes the tracker's getHealth() as a new
  informational-only `ai` field. It is deliberately NOT folded into the
  200/503 status code — a dead vendor key can't be fixed by a restart, so
  gating the restart decision on it would bounce a healthy app for someone
  else's outage.
- scripts/test/ai-health.ts, scripts/test/health-route.ts: new coverage —
  the tracker's status transitions, and that the health route's status code
  is unaffected by AI health regardless of state.

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
2026-09-02 08:47:20 +00:00
GandClaude Opus 5 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>
2026-08-31 09:23:30 +00:00
bc0493f68f refactor(agent): the grounding harness is imported, not mirrored (#448)
FleetCrown half of the mirror retirement (fleet AI-engine plan, Phase 2).
src/lib/agent/core was the CANONICAL copy of the harness, mirrored
byte-for-byte into OrangeCat and policed by scripts/test/agent-core-drift.ts
plus scripts/sync-agent-core.ts. Its own README called the duplication
"deliberate and temporary" and named extraction to a package as the exit.
ai-kit v0.6.2 is that exit; OrangeCat's twin PR (#846, merged) deletes the
other side.

Fourteen imports across nine files collapse from three deep paths to one
subpath import. The sync script, the drift check and the npm script that ran
it are deleted rather than kept green: with a single copy there is nothing
left to drift, and a gate with no possible failure mode is noise wearing a
uniform. ai-kit also moves v0.2.1 -> v0.6.2 (still the ai-ration name in the
old lock entry); the three root imports this repo uses (chain, fair-share,
limits) are unchanged surfaces across that jump, which typecheck confirms.

The packaged copy differs from the deleted canonical by two mechanical
deltas, both made where the code now lives: .js extensions on relative
imports (pure ESM) and two null-guards under ai-kit's
noUncheckedIndexedAccess.

tsc clean; 124/124 unit test files pass (one fewer than before: the drift
check no longer exists to run).


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>
2026-08-31 09:45:07 +02:00
GandClaude Opus 5 3dcfe4bf18 fix(ci): the audit never looked at steps written as - uses: (#429)
* fix(ci): the audit never looked at steps written as `- uses:`

`^\s*uses:` matches a `uses:` that is the first key on its line. A step in the
compact list form — `- uses: actions/checkout@v5` — has a dash in front and was
never matched, so the audit skipped it while printing a ref count that made it
look like it had checked everything.

Measured across the fleet before the fix: 59 of 155 workflow files contained at
least one reference the audit never looked at.

Nothing was broken by it, and the reason is worth recording. A job-level
`uses:` — the reusable-workflow call, the thing all three outages came through
— is a mapping key and never a list item, so it was always matched. Only
step-level action references were invisible, and today those are five
third-party refs (actions/checkout, actions/labeler, pnpm/action-setup) which
all resolve. No bitbaum-owned reference is currently written as a step.

So this is a latent hole, not a live outage: the moment a fleet-owned action is
referenced as a step — the natural way to write one — it would be invisible to
precisely the check built to catch it.

Found by auditing the audit for its own class: a reference that resolves for
every tool you would check it with, but not for the consumer that uses it. Here
the consumer was the gate itself.

Mutation-proven: reverting the dash fails the compact-form test, restoring it
passes. Coverage widened from 24 to 26 distinct refs against the real fleet,
still green, no false positives. Suite is 26 assertions.

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

* fix(ci): push the actual regex fix, not the mutation of it

The previous commit on this branch shipped the MUTATED lib. A verification
script copied the deliberately-broken variant back over the file being pushed
(the restore put back only the copy under ci/, not the one at the top level),
so the branch carried the dash-less regex while the test asserting the dash
went with it.

CI caught it immediately, which is the point: the test written alongside the
fix is what proved the fix was absent. A gate that only ever sees the intended
input would not have.

Rebuilt from main plus the single intended edit, and the artifact is checked
for the dash before the push rather than after.

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

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 20:09:20 +02:00
d0029f2665 feat(ci): fail the build when an app ships migrations it never applies (#428)
botsmann shipped eleven migrations that were applied nowhere. /api/health served
PGRST205 from a table that did not exist, for months, while every deploy went
green — because deploy.sh skips apply-schema.sh entirely when the manifest's db
field is `-`. Nothing failed. Nothing ran. Those look identical from outside,
and that is the whole bug.

Then printcraft did it too: five more migrations the pipeline never saw (#407).
Twice is a class. The third is what this prevents.

The gate: an app whose repo contains migrations while declaring `db=-` fails
the build, naming the app and the directory holding the SQL. A zero-check, not
a ratchet — no app violates this today, so any occurrence is a regression
rather than inherited debt. The four apps that legitimately declare `db=-`
(camille, sbb-lost-found, sink, substrata) genuinely have no migrations, and a
test pins that this stays legal.

ONE LIST, NOT TWO

A gate with its own idea of where migrations live would drift from the applier
and start lying in the other direction — passing an app whose SQL sits in a
directory it never checks. So apply-schema.sh's candidate paths moved into a
`migration_dirs` function above its lib-only return, and both consumers read
it. Its five drizzle candidates, one prisma and two supabase homes had never
been unit-testable before, because the discovery sits below that return; they
are pinned now, in the applier's own order.

Proven able to fail before shipping: fixtures assert a supabase-layout app and
a drizzle-layout app each go red, that an app declaring its database is
untouched, and that db=- with no migrations stays legitimate. The gate is about
the lie, not about having SQL.

34 apply-schema tests, 18 deploy-ready-gate tests, whole ops suite green.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 16:21:27 +00:00
GandClaude Opus 5 a7e1279bbe feat(ci): the audit checks the referenced FILE, not just the repo (#427)
verdictFor proves the OWNER resolves. Nothing proved the file inside it still
exists at that ref — and those are different failures with the same symptom.

A rename leaves the file intact under a new owner. MOVING a shared workflow and
deleting the old copy leaves the owner perfectly canonical and the file gone.
Both kill the run identically: it dies before any job exists, zero jobs, no
log, "workflow file issue", and the caller PR stays green and mergeable.

This is not hypothetical. Sixteen repos called
bitbaum/dotfiles/.github/workflows/auto-merge-sweep.yml; the shim was deleted
today once they had all migrated to bitbaum/fleet. `bitbaum/dotfiles` is and
remains canonical, so the owner check sees nothing wrong. Verified live: that
path now returns 404 while bitbaum/fleet returns 200.

Structure follows the existing split — pure decision in the lib
(pathVerdictFor, no network, fully testable), lookup in the script
(pathExists, cached per owner/path@ref). USES gained two capture groups for
the subpath and ref; callers destructuring [, owner, name] are unaffected,
which the existing tests already pin.

A missing subpath is never a finding: `actions/checkout@v5` has no file to
check beyond the repo. A failed lookup is `unreadable`, never clean and never
a false stale — same rule the owner check already follows.

Mutation-proven, each red then green:
  exists===false treated as ok      -> exit 1
  failed lookup treated as clean    -> exit 1
  USES stops capturing subpath/ref  -> exit 1
  restored                          -> exit 0
Plus end-to-end against the real deleted reference: caught, while the live
replacement and a plain action pass. Suite is 22 assertions; the full audit
runs clean over the real fleet (32 repos, 155 workflow files) with no false
positives.


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

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 18:04:18 +02:00
56e2187f07 test(ci): cover the mechanism that actually catches the outage, not just the newer bug (#423)
Only fleet-refs-audit's RETIRED_HANDLES self-match had test coverage. The
USES regex and the stale/missing/ok verdict decision — the part that would
have caught all three real outages this tool exists for (2026-08-26/27/28) —
had zero tests. A regex bug there would silently miss exactly the class of
breakage the whole tool was built to catch, which is a bigger risk than the
bug just fixed.

Extracted verdictFor(slug, real) into fleet-refs-audit-lib.mjs as a pure
decision function — no network call, so it's directly testable — replacing
the inline if/else in fleet-refs-audit.mjs with the same behavior.

10 new assertions: USES correctly matches plain and path-qualified uses:
lines, correctly excludes local (./…) and docker:// references (no owner to
be wrong about), matches multiple lines independently, tolerates
indentation; verdictFor correctly reports ok/stale/unreadable for all four
real outcomes resolve() can produce, including the failed-lookup case, which
must report unreadable rather than silently pass OR falsely fail.

Documented one known, narrow limitation rather than silently claiming full
coverage: USES matches by line shape, not YAML structural position, so a
run: block whose first physical line happens to read literally like a
uses: key would be misread. Not observed in this fleet; a real YAML parse
would close it at the cost of a dependency this script deliberately avoids.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 11:41:35 +00:00
a06e650063 fix(ci): harden the fleet-refs-audit self-match exclusion, add the missing test (#421)
#420 already fixed this audit's first production failure (it flagged its own
RETIRED_HANDLES: maonakamoto declaration as a live reference) — that landed
first and this rebases on top of it, replacing the approach rather than
duplicating the fix.

#420's exclusion was file-level: `SELF_REPO='fleetcrown'` +
`SELF_WORKFLOW='fleet-refs-audit.yml'`, matched by repo name and filename.
Two problems with that shape specifically:

  - it goes stale the moment this tooling changes address. Memory already
    has this fleet's audit/template infra mid-move to bitbaum/fleet — the
    exact rename-and-forget pattern this whole audit exists to catch, now
    baked into the audit's own exclusion list.
  - it exempts the entire file from retired-handle detection, not just the
    one line that's actually a declaration rather than a reference. A
    genuine stale mention added anywhere else in that same file later would
    go uncaught.

Replaced with a line-level exclusion: strip the RETIRED_HANDLES: declaration
line specifically (scripts/ci/fleet-refs-audit-lib.mjs), the same way
comment lines were already stripped for the identical reason one level up.
Works regardless of which repo or filename hosts the audit.

#420's PR body describes manual mutation-style checks (toggling SELF_REPO
and RETIRED_HANDLES by hand) but landed with no committed test — nothing
would catch a regression here. scripts/test/fleet-refs-audit.ts pins it: the
production line no longer self-matches, a genuine `uses: maonakamoto/...`
still fails, a documentation comment still passes, and stripping the
declaration line doesn't hide a real reference elsewhere in the same file.
Picked up automatically by test:unit (glob-discovered) — confirmed via
`npx tsx scripts/test-unit.ts`. Also ran the matcher directly against the
real .github/workflows/fleet-refs-audit.yml: zero matches.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 11:45:25 +02:00
a58961aac8 fix(ci): deploy-ready gate now checks CD, not just CI — and fixes a live drift it just found (#419)
Two real gaps surfaced by a fleet-wide CI/CD audit, both now closed:

1. This gate only ever verified CI existence. camille-boulangerie had ci.yml
   (verify ran green on every push) and no deploy.yml at all — a green push
   there has never once reached the box. The gate's own stated purpose is
   "absence must not read as success," and it was doing exactly that for CD.
   Fixed in a companion PR (bitbaum/camille-boulangerie#2): the gate now
   detects a Deploy-shaped workflow the same way it detects CI, ratcheted
   independently so a CI regression and a CD regression can never mask each
   other under one shared count. deploy-ready-cd.baseline seeded at 0 — every
   deployed app now genuinely has both, verified fresh, not assumed.

2. apps.conf's `sink` entry pointed at /home/g/dev/aslan-tattoo, which no
   longer exists — some prior autonomous session renamed the checkout to
   /home/g/dev/s-ink and nothing updated the register. Running this gate
   locally caught it immediately (the "drift, not a bare environment" path
   added earlier today). Fixed the path.

Neither of these was visible from CI passing: (1) needs a live check that CI
has never run, and (2) can ONLY be caught locally, since it depends on the
actual fleet checkouts existing — nothing schedules that check anywhere. That
residual gap (no cron ever runs the fleet-inspection half) is reported
separately, not fixed here — it needs a real decision about where such a
check could run unattended, not a quick patch.

scripts/test/deploy-ready-gate.sh gets 4 new cases using synthetic fixture
repos (not the real fleet, which could coincidentally look fine) to prove CI
and CD are detected independently, including camille's exact shape: a repo
with only a CI workflow must be flagged for missing CD, not CI.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 10:56:09 +02:00
4d1c9f1fe7 chore: migrate the fleet to the bitbaum org (#415)
* chore(ci): GitHub owner catomean -> bitbaum

* docs(hetzner): update _box-env.sh comments for the completed org migration

The GH_OWNER/WORKFLOW_OWNER comments described a future state (repos moving
to bitbaum while fleetcrown stayed personal) that sweep-gh-owner.sh just
made true, then obsolete: fleetcrown itself is in bitbaum now too. Comments
describing a plan that already happened are worse than no comment — they
send the next reader looking for a divergence that isn't there.

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

* chore(desktop): release 0.8.15 — the org-migration owner literals

Same shape as 0.8.14: desktop/ carries two literal owner references (issue
link, updater feed owner) that a fleet-wide rename touches, and
desktop-release-drift.ts correctly refuses to let that ship without a
version bump — a repo whose desktop app silently points at a dead update
feed is worse than one that fails the gate.

This should be the last time it's an account name: the org is the stable
home from here.

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

---------

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 07:45:50 +02:00
45938e60cf fix(ci): unbreak the gates — dependency graph, agent-core drift, desktop release (#400)
* refactor(infra): studio constants get one home, and the rename gets a command

Fair criticism: I spent the day arguing for SSOT and then wrote new-site.sh with
its own copies of GH_OWNER, BASE_DOMAIN and DEV_ROOT, and hardcoded
'maonakamoto' again in provision-widget.ts. Worse, the pattern already existed —
_box-env.sh is literally labelled 'SSOT' for the box address. I did not extend
it, I duplicated around it.

_box-env.sh now owns GH_OWNER, SITES_BASE_DOMAIN and DEV_ROOT alongside the box
address, and new-site.sh and provision-widget.ts read them instead of carrying
their own.

The 41 workflow files are a different case and worth being precise about:
GitHub Actions requires a LITERAL owner/repo in  and will not accept a
variable, so that duplication cannot be removed. But a duplication you cannot
remove is one you have to OWN — leaving it as 'remember to edit 41 files' is
exactly the shape of step that gets skipped, the same shape as the git
repository Camille never got. So sweep-gh-owner.sh is committed: one command,
dry-runnable, optionally self-committing.

Dry run against the fleet: 24 repos, all detected correctly. Renaming to an org
is now  plus one line in _box-env.sh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(infra): split WORKFLOW_OWNER from GH_OWNER before they diverge

Same bug as the last commit, one layer down. The site template hardcoded
maonakamoto/fleetcrown in its deploy.yml uses: line, derived from nothing — so
every new site would bake in a literal that follows neither an account rename
nor a move to an org.

And GH_OWNER was quietly doing two jobs: where new site repos are CREATED, and
where fleetcrown LIVES. They look identical today and are about to diverge —
sites go to an org while fleetcrown stays on the personal account. One name for
two values is how a rename half-works.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(ci): GitHub owner maonakamoto -> catomean

* chore(infra): owner is catomean

Account renamed maonakamoto -> catomean. sweep-gh-owner.sh swept 24 repos and
the SSOT now agrees; 32 local remotes repointed. This is the commit the sweep
script exists for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(ci): GitHub owner maonakamoto -> catomean

* chore(ci): GitHub owner maonakamoto -> catomean

* fix(desktop): cut 0.8.14 — the owner rename touched desktop code

My owner sweep changed two files in desktop/ (an update URL and a package
reference) without bumping the version. That is precisely the failure #370
existed to prevent: desktop code that changes without a release ships to the
server and to no machine at all, silently.

The gate caught it, four commits after it was written. Working as intended, and
worth saying plainly — I was the one it caught.

GitHub redirects repository URLs after a rename, but only until somebody claims
the freed name. An auto-updater should not depend on a redirect.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(ci): the gate fails on your diff, not on your laptop

Three things in this hook blocked pushes for reasons unrelated to the change
being pushed, and together they are why --no-verify became reflex here. I passed
it eight times in one day and blamed the hook; the hook was reporting real
problems with misleading attribution.

1. STALE INSTALL. An unresolvable dependency surfaced as 'Cannot find module' —
   indistinguishable from a type error in your code. Now a precondition that
   fails first, loudly, naming npm ci. A day was spent on this exact confusion.

2. AGENT-CORE DRIFT. Drift arises either because you changed canonical without
   syncing, or because somebody changed the mirror in the other repo. Only the
   first is yours. It now checks whether this branch touched
   src/lib/agent/core/ and warns instead of blocking when it did not.

3. SCHEMA DRIFT. The guard already skipped an unreachable database but not a
   reachable stale one, so a local scratch DB missing someone else's columns
   blocked pushes touching no schema. Now scoped: if the branch changes schema a
   mismatch is yours and blocks; otherwise it reports and continues.

The pattern is taken from desktop-release-drift, which self-scopes to files
changed since the last release and is the only check here that has never blocked
an unrelated push. It caught me correctly today, four commits after it was
written.

Where scope cannot be established the checks still fail closed — a gate that
cannot establish innocence should not grant it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(ci): resolve the default branch, never assume main

The diff-scoping added in the previous commit compares against origin/main. 28
repos here use main — but aoz-housing, dotfiles and sbb-lost-found use master,
and six had no origin/HEAD set at all.

On those, merge-base fails, the scoping falls through to 'cannot tell', and
every check treats every change as in-scope. The gate I had just fixed would
have gone back to blocking unrelated pushes on a fifth of the fleet, for a
reason nobody would have connected to a branch name.

default_branch() now lives in lib.sh and resolves in order: the remote's own
origin/HEAD, then whichever of main/master exists, then fail. Never a guess. The
pre-push hook and agent-core-drift both use it.

Also ran 'origin/HEAD' is unchanged and points to 'main' on the six repos missing origin/HEAD.
32 of 33 now resolve; wild-spirit has no remote at all, which is a separate
finding and the same shape as camille this morning.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(scaffold): every new site is born with CI

ci-gate.sh cannot tell 'CI green' from 'no CI configured' — both exit 0. So a
scaffolded site without a workflow deployed every push unverified while looking
identical to one that passed. Substrata shipped to production that way for a day.

The template now emits ci.yml alongside deploy.yml: npm ci, type-check, lint,
build — the same bundle verify runs locally.

Plus eslint.config.mjs, because ESLint 9 without a flat config exits non-zero on
a migration notice and a new site's FIRST CI run would be red for reasons
unrelated to its code. A red first run teaches people to ignore the light.
Config copied from the fleet's working Next 16 apps, not invented.

postcss.config.mjs assigns before exporting — the anonymous default export is a
lint warning, and a scaffold should not emit its own warnings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(ci): no deployed app ships without CI, ratcheted to zero

ci-gate.sh exits 0 for 'CI green' AND for 'no CI configured'. Absence is
indistinguishable from success, so an app with no workflow deploys every push
unverified while looking exactly like one that passed. Nothing reported it,
because nothing was looking.

The audit found two: camille-boulangerie, and sink — which is sinktattoo.com, a
real client's site.

sink turned out to be a FALSE POSITIVE, and that is the more useful finding:
apps.conf pointed at /home/g/dev/s-ink, a path that does not exist, so the gate
reasoned about an absent repository and reported the wrong fault. It sent me to
add a workflow to a repo that already had one. The register was the bug.

So the gate now distinguishes a stale register entry from a missing workflow and
fails loudly on the former — a gate that lies about what to fix is worse than no
gate. apps.conf repointed at /home/g/dev/aslan-tattoo.

Camille genuinely had none and now does. Baseline is 0: a new deployed app
without CI is a build failure.

Tested in all four directions — over baseline fails, at baseline passes, under
baseline passes and prompts, stale path fails. The first version could never
fail at all: it set HERE before sourcing lib.sh, which overwrites HERE, so
BASELINE_FILE pointed at a missing file and silently fell back to the current
count. Found by testing the gate rather than trusting it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(scaffold): template ships .nvmrc

Every new site now pins Node once, and both CI and the deploy read it. Without
it the deploy warns and the two pipelines pick a version independently — the
kind of difference that surfaces as 'green in CI, broken on the box'.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(hetzner): scaffold sets the deploy key itself, from one configured path

new-site.sh printed `gh secret set ...` and called that operator hygiene.
What it actually produced was substrata live in production deploying only
from a laptop, because a printed instruction is a step that gets skipped.

The key is piped from DEPLOY_KEY_PATH straight into `gh secret set` — never
read into a variable, a log, or an agent's context — so the safety argument
that motivated the manual step is kept while the step disappears.

Per-repo on purpose: GitHub Free does not expose org-level secrets to PRIVATE
repositories, so an org secret alone would silently cover only part of the
fleet. DEPLOY_KEY_PATH joins the other constants in _box-env.sh so there is
one path, not one per script.

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

* fix(ci): make the deploy-ready gate judge the diff, not the workstation

The gate inspected the sibling checkouts under DEV_ROOT and nothing else.
All 15 are cloned on the workstation, so it printed "all 15 deployed apps
have CI"; CI clones this repo only, so the same commit printed fifteen
missing repos and exited 1 — red on a diff that touched none of them.

Third instance of one class: a gate judging state outside the commit. Its
real cost is not the red run, it is that everyone learns the gate is noise
and reaches for --no-verify.

Split into the two halves that were tangled:

  REGISTER INTEGRITY — apps.conf lives in this repo, so it is in the diff,
  so CI must judge it. Now actually checked: field count, unique names,
  unique numeric ports. Previously nothing validated the register at all.

  FLEET INSPECTION — needs the checkouts. Where none exist it is announced
  as NOT RUN and exits 0. Announced, because "no output" and "all clear"
  looking identical is the bug this file was written to fix. Where some
  exist, a bad path is still drift and still fails.

test:deploy-ready-gate locks it shut from both sides: a malformed register
must fail even with no checkouts present, and a bare environment must never
claim the fleet passed. Added to verify, so CI runs it in exactly the
environment that used to break it.

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

---------

Co-authored-by: Mao Nakamoto <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: t <t@t.t>
2026-08-28 05:04:32 +00:00
7cb53c9567 fix(frontier): salvage the proposals that finished when the reply is cut off (#409)
Verifying #406 in production found it half-right. The budget raise fixed
most nights, and the very next run failed again — but the raw sample #401
captures showed why, and it was a different failure wearing the same name:

  {"proposals":[{"title":"Calendar adapter accelerated with GLM-5.3-Flash
   inference","rationale":"GLM-5.3-Flash delivers 3.3x faster inference ...
   We wil

That is valid JSON that stopped mid-word. `extractJson` needs a balanced
top-level object, so one proposal cut in half discarded the ones before it
that were perfectly well-formed, and the run reported `unparseable` — which
reads as "the model said something unreadable" rather than "the model said
more than we let it".

Raising the budget again would not settle this. The model decides how long
a rationale is, so no ceiling is a guarantee; a large enough answer can
always run off the end. So:

- salvageProposals walks the `proposals` array and keeps every element that
  closed, tracking string state so a brace or an escaped quote inside a
  rationale is treated as text rather than structure.
- `truncated` becomes its own outcome, separate from `unparseable`. They
  need different fixes — more room versus a different prompt or model — and
  collapsing them is what put the last investigation back at the start.
- maxTokens 3000 -> 4000 anyway, so salvage is the safety net rather than
  the normal path. ~6.2k against Groq's 8000 TPM per-model cap.
- The raw sample is kept even when salvage SUCCEEDS: that run worked, on
  less than the model tried to say, and that is worth seeing before it
  becomes a night that yields nothing.

Five mutations, each red then green: salvage removed, string-awareness
dropped, no-JSON prose conflated with truncation, half-written objects
accepted, <think> preamble no longer stripped.

One of them (string-awareness) initially stayed GREEN. The test used a
BALANCED "{curly}" inside a rationale, and a balanced brace leaves the depth
counter correct on its own, so the case passed with the handling removed.
Replaced with an unpaired brace, plus a case for an escaped quote. A
mutation that does not go red is a hole in the test, not a passing test.


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

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 20:43:01 +00:00
3e094dffeb fix(models): a judge that exists, is listed, and 400s on every call (#408)
Firing the frontier loop after #406 produced the first proposals since
2026-06-24 — and the run's own report named a second fault:

  judgeFailures: qwen3.6-27b -> groq 400:
    `reasoning_effort` must be one of `none` or `default`

Groq narrowed the values that model accepts. This app sends "low", so every
call to it has been failing. qwen is the frontier judge panel's SECOND
lineage, and a judge that cannot be called abstains — which left proposals
scored only by gpt-oss-120b while the GENERATOR is gpt-oss-20b. Same
lineage marking its own homework. The veto floor ("one lineage can veto
what another loves") had silently stopped existing, and `verifierScores`
still reported a panel.

Verified against the live API: with the parameter omitted the model answers
normally and emits its <think> preamble, which stripReasoning already
handles and the judge's 3500-token budget already accommodates. So the
allow-list was simply wrong, and qwen/ is removed from it.

The part that matters more: `check-model-ids` reported `rotted: 0` for the
whole outage. It asks "does this id still EXIST at the provider", and
qwen3.6-27b existed the entire time it was unusable. Existence is not
callability — the same "it is there, therefore it works" mistake that this
week has now produced in an alert surface, a cron journal, a lint hook and
an env checker.

So the check now also asks whether the provider accepts the request THIS
APP BUILDS: a one-token completion whose parameters come from
`supportsReasoningEffort`, the same predicate the real call path uses. That
sharing is deliberate. A probe with its own opinion about which models get
the parameter would be a second source of truth and would pass while
production 400s — precisely the checker/consumer split fixed in #402.

Three states, as everywhere else in this module: 400 is a refusal (the
provider understood us and said no), 429/5xx/401 is "could not look", and
only a removal is rot. A rate limit must never be reported as a dead model.
Refusals are counted WITH removals because the consequence is identical —
the feature is dark — and only the remedy differs, so the alert now carries
the provider's own message, which names the parameter and is the fix.

Cost stays small: a refusal is rejected before inference and an acceptance
is capped at one token, so the daily probe does not meaningfully compete
with the product for the 100k/day org-wide free tier. The probe is OFF by
default and the cron opts in, so the unit tests never call a paid API.

Six mutations, each red then green: qwen back in the allow-list, refusals
dropped from the report, a 429 counted as rot, transcription ids probed as
chat, and the provider's message dropped from the alert text.


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

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 20:24:43 +00:00
d3f55225d3 fix(signals): three checks that reported something other than what they measured (#402)
* fix(crons): a scheduled job that records nothing cannot be diagnosed

The frontier self-improvement loop ran from 2026-06-24 to 2026-08-27 and
surfaced zero proposals. A taxonomy shipped on 2026-08-25 to say WHY —
dead model / unreadable reply / model found no match / everything deduped
— and it worked: the first night it ran it answered "unparseable".

That answer was going to expire the next morning. The outcome existed only
in the HTTP response body, which fc-cron.sh echoes into the systemd
journal, and this box's journal is size-capped with no time limit: the
frontier-digest unit holds about ONE day. Sixty-four nights of evidence
about the loop had already been discarded one day at a time, which is why
"drafted: 0" was all anyone could ever recover.

Two of eighteen cron-authed routes persisted nothing. The other sixteen
already used logDebug, so this conforms to the convention rather than
inventing one — and it is the right sink because prune-debug-logs keeps
error rows 90 days and info/warn 30, so the runs worth a postmortem are
the ones that survive to have one.

- frontier-digest logs generation outcome, drafts, surfaced, judge
  failures and panel reachability, at a level that separates a fault in
  the machinery (dead model, unreadable reply, panel never voted) from
  the loop working as designed (no match today). Both used to end in the
  same drafted: 0.
- send-digest-emails logs its send results. It catches per-user failures
  so one bad address cannot stop the batch, which also means every send
  could fail while the route answered ok: true and systemd recorded a
  success.
- generateProposals now returns rawSample on "unparseable". Without the
  text, "unparseable" is the same which-of-several-causes question one
  level down: a refusal, a prose preamble and a truncated object all fail
  to parse and each needs a different fix.

Also normalises the log source to crons/<name>. Twelve routes used that
and five used api/crons/<name>, so a query for cron activity silently
returned about two-thirds of it. Nothing filters on source today, so this
is hygiene rather than a live bug — but it was a wrong answer waiting for
the first person to ask.

The gate closes the class rather than the two instances: every route
demanding requireCronAuth must call logDebug under its own source name.
Comments are stripped before matching, the match is call-shaped so an
import cannot satisfy it, and a floor fails the scan if it stops finding
routes. Proven by six mutations, each red then green.

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

* fix(signals): three checks that reported something other than what they measured

Last week this app produced 231 warnings. 216 of them meant "nothing
happened", and six real errors sat underneath — a telemetry sensor dead
for 78 days, a runner two versions behind, an email probe timing out.
A channel degrades to the reliability of its worst entry, and the rational
response to a mostly-wrong list is to stop reading it.

Three separate causes, one shape: the signal was not attached to the thing
it claimed to describe.

1. The pre-commit hook lints nothing, and says so reassuringly.

   GLOBS was unquoted, so the SHELL expanded "src/**/*.ts" before git saw
   it — and POSIX sh has no globstar, so ** collapsed to one level. The
   variable became 230 literal paths, all exactly two levels deep, and
   nothing deeper could ever match. Almost all code here is deeper.
   Measured on a commit touching 10 TypeScript files: it matched 0 and
   printed "no staged TypeScript — nothing to lint", which is a statement
   about its own pathspec wearing the clothes of a statement about the
   commit.

   ':(glob)' does two jobs: it makes ** mean "any depth" to git, and since
   no file can be named ':(glob)…' the unquoted expansion stays literal.
   Reach goes from 230 shallow paths to 1147 files, 905 of them deeper
   than two levels.

   verify still runs in full on pre-push and in CI, so nothing unlinted
   reached origin. What was lost is the fast local loop the hook exists
   for.

2. The env checker read a different variable than the app.

   checkEnv() tested the bare TELEGRAM_CHAT_ID; every consumer reads it
   through envAlias, which looks only at APP_/FLEETCROWN_/COCKPIT_ and
   never the bare name. Wrong in both directions:

     - false alarm — prod has APP_TELEGRAM_CHAT_ID set and delivery works
       (confirmed live with a read-only getChat), yet it warned at every
       boot: 48 of the week's 231 warnings.
     - false quiet — and the message told the operator to set
       TELEGRAM_CHAT_ID, which silences the warning while
       selfTelegramTarget() still returns null and every notification
       still vanishes. A fix that removes the signal and not the fault is
       worse than no check.

   The message now names the prefixed variable that actually works.

3. check-pending-approvals warned about the world, hourly.

   It warned whenever a stale approval existed — a fact about the world,
   and the world does not change hourly. 168 identical warnings in seven
   days, every one with expired/raised/pinged/cleared all zero. The state
   is not lost: an open pending_approvals alert already represents an
   ongoing condition once instead of sixty-eight times.

   The alert records what is true; the log records what happened.

Gates, both derived from source rather than a list, six mutations each red
then green: the pathspec test is behavioural — it re-runs the hook's own
assignment in the hook's own shell and asks git what it matches, so it
stays honest however the line is rewritten, where a grep for ':(glob)'
would only prove today's spelling. The env test derives the rule: whatever
the app resolves through envAlias, the checker must too.

No gate for (3). "Log level reflects work done, not state observed" is a
real class, but every static check I could write for it produces false
positives on jobs whose work IS an observation. Verified by watching the
warn rate in prod instead, and left un-encoded deliberately rather than
silently.

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

---------

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 19:38:18 +00:00
daae793a36 fix(crons): a scheduled job that records nothing cannot be diagnosed (#401)
The frontier self-improvement loop ran from 2026-06-24 to 2026-08-27 and
surfaced zero proposals. A taxonomy shipped on 2026-08-25 to say WHY —
dead model / unreadable reply / model found no match / everything deduped
— and it worked: the first night it ran it answered "unparseable".

That answer was going to expire the next morning. The outcome existed only
in the HTTP response body, which fc-cron.sh echoes into the systemd
journal, and this box's journal is size-capped with no time limit: the
frontier-digest unit holds about ONE day. Sixty-four nights of evidence
about the loop had already been discarded one day at a time, which is why
"drafted: 0" was all anyone could ever recover.

Two of eighteen cron-authed routes persisted nothing. The other sixteen
already used logDebug, so this conforms to the convention rather than
inventing one — and it is the right sink because prune-debug-logs keeps
error rows 90 days and info/warn 30, so the runs worth a postmortem are
the ones that survive to have one.

- frontier-digest logs generation outcome, drafts, surfaced, judge
  failures and panel reachability, at a level that separates a fault in
  the machinery (dead model, unreadable reply, panel never voted) from
  the loop working as designed (no match today). Both used to end in the
  same drafted: 0.
- send-digest-emails logs its send results. It catches per-user failures
  so one bad address cannot stop the batch, which also means every send
  could fail while the route answered ok: true and systemd recorded a
  success.
- generateProposals now returns rawSample on "unparseable". Without the
  text, "unparseable" is the same which-of-several-causes question one
  level down: a refusal, a prose preamble and a truncated object all fail
  to parse and each needs a different fix.

Also normalises the log source to crons/<name>. Twelve routes used that
and five used api/crons/<name>, so a query for cron activity silently
returned about two-thirds of it. Nothing filters on source today, so this
is hygiene rather than a live bug — but it was a wrong answer waiting for
the first person to ask.

The gate closes the class rather than the two instances: every route
demanding requireCronAuth must call logDebug under its own source name.
Comments are stripped before matching, the match is call-shaped so an
import cannot satisfy it, and a floor fails the scan if it stops finding
routes. Proven by six mutations, each red then green.


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

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 19:18:54 +00:00
b065fc6e90 fix(alerts): stop an alert type outliving the code that raised it (#392)
Ten alerts were open in production and four were fossils. `bill_due`,
`stale_relationship`, `overdue_commitment` and `stalled_goal` were raised
between 2026-05-10 and 2026-06-23 by features that no longer exist — grep
finds their names only in a comment. Nothing could refresh them, nothing
could auto-resolve them, and `alerts` records no "last confirmed" timestamp,
so from the row alone a live alarm and a 108-day-old fossil look identical.

Forty per cent of the surface was permanent noise, and the correct response
to a list that is mostly wrong is to stop reading it. Queued underneath those
fossils: a telemetry sensor dead for 77 days, and a machine running a Fleet
Runner we replaced. A channel degrades to the reliability of its worst entry
— which is the failure every alert here exists to prevent, aimed at the
alerts themselves.

Three parts:

- src/config/alert-types.ts is the SSOT. Seven types, each naming the file
  that raises it.
- scripts/test/alert-registry.ts enforces BOTH directions. producer ⊆
  registry stops an unregistered alarm being swept the morning after it first
  fires; registry ⊆ producer is the one that matters — delete a producer and
  CI goes red until the alert type is retired with it.
- sweep-orphan-alerts (daily 06:55) clears open alerts whose type no code can
  raise. Safe by construction: a type absent from the registry has no
  producer, so no live condition can be hidden by clearing it.

A clock rather than a migration on purpose. A migration fixes the four that
exist; the sweep means the NEXT retired feature cleans up after itself
instead of depending on whoever deletes it to remember rows they never
thought about.

Mutation-proven nine ways, each red then green. Two initially passed: the
sweep's "only OPEN alerts" assertion was satisfied by a SIBLING function in
the same file, and the zombie check was pre-empted by a producer mismatch so
it never diagnosed on its own terms. Both are the scope blind spot that let a
CI gate read a neighbouring job's setting this morning.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 21:31:22 +00:00
GandClaude Opus 5 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>
2026-08-26 18:46:03 +00:00
20fb952ef1 fix(system): give the runner-version check a path that actually runs (#389)
#388 put the comparison in Fleet Doctor. Probing the live authenticated
endpoint afterwards returned HTTP 200 with exactly ONE check:

  {"runtime": false, "checks": [{"id": "runtime", ...
    "Fleet Doctor runs full checks only on the local install."}]}

On the hosted box `isRuntimeAvailable()` is false, so the route
short-circuits and executes none of its checks. A check that lives only in
Doctor never runs in production — present, plausible, and incapable of
firing where it matters. Exactly the shape of bug this check was written to
catch, one level up.

So the live path is a clock: /api/crons/check-runner-version, daily 06:50
UTC, mirroring the telemetry freshness cron proved this morning. Deduped
alert, Telegram once per episode rather than per tick, auto-resolve when
every runner is accounted for — and never auto-resolve while one is UNKNOWN,
which would turn "we cannot tell" into "fixed".

`ahead` stays a pass: the box builds from main and reaches a version before
that version is tagged, so alerting on it would fire every merge and train
the surface out.

Two new assertions keep the live path alive: the cron must CALL the checker,
and it must appear in the SCHED table. The first version of the call
assertion used .includes(), which the surviving import line satisfied while
the call site was gutted — a mention is not a use. Comments are stripped
before matching, for the same reason.

Mutation-proven nine ways now, each red then green.

Fleet Doctor keeps the check for local installs; it is no longer the only
place it exists.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 13:38:11 +00:00
970578f090 feat(system): notice when a machine is running a Fleet Runner we replaced (#388)
* fix(orchestration): narrow a claim I overshot — `undelivered` becomes `unconfirmed`

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 c350623c — one of the seven
files stranded by the broken release pipeline, shipped this morning as
v0.8.13. Same chain as #370, #374, #381 and #383.

Mutation-proven nine ways, each red then green.

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

* feat(system): notice when a machine is running a Fleet Runner we replaced

FleetCrown published desktop releases and had no idea whether any machine
ever installed one. Both halves mattered today: releases had not been cut at
all for twelve days (#370/#374), and even after v0.8.13 shipped, the laptop
kept reporting 0.8.12 while the box ran box-0.8.13.

That gap is what produced the last two days of work. 0.8.12 predates the
inject-hardening from 2026-08-23 (c350623c) — the change that retries a stuck
paste and then HARD-FAILS instead of acking ok:true — so that runner kept
accepting unverified injects and leaving the runs to be reaped an hour later.
29 runs died that way and were billed to the projects whose prompts went
unanswered, which climbed escalation ladders that could not clear.

Nothing was missing except the subtraction. FLEET_RUNNER_RELEASES is already
the SSOT for what shipped; every runner reports its version on every
heartbeat. runnerVersionStatus() compares them — no network, no new data —
and Fleet Doctor now fails when a runner is behind.

Four states, and two of them are the point:
  behind  — FAIL. Merged desktop work is inert on that machine.
  unknown — WARN. "We could not tell" is not "it is current"; a runner that
            has never reported a parsable version must never read as fine.
  ahead   — PASS. The box builds from main, so it legitimately runs ahead of
            the newest tag. Reporting that as a fault would cry wolf on every
            merge, and a check that cries wolf is one nobody reads.
  current — PASS.

`box-` is stripped before comparing: without that the fleet's MOST current
runner was the one that read as unparsable.

Mutation-proven seven ways, each red then green — including unknown read as
current, the helper left uncalled by Doctor, and the default release list
forked from the changelog SSOT.

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

---------

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 13:08:12 +00:00
6d9b0b955c refactor(ai): ai-ration is now ai-kit (#387)
Rename only — no behaviour change. `freeChain`, `checkCatalog`,
`classifyRateLimit` and `fairShare` are the same functions from the same
package, which was renamed because its old name described one of its five
modules and hid the other four.

fleetcrown is the reason the rename is worth doing rather than cosmetic. This
repo adopted the package and was the ONLY app in the fleet still serving AI on
2026-08-26, when Groq retired the llama-3.x family and took down botsmann, evig,
kivvi, orangecat and truthseeker together. All five hand-roll the layer this
package replaces. They skipped it partly because nobody could tell from the name
what it was for.

ai-kit also re-exports ai-forms now, so an app adding AI installs one thing
instead of making four separate decisions and, as AOZ did, making only one.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-26 12:55:34 +00:00
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 c350623c — one of the seven
files stranded by the broken release pipeline, shipped this morning as
v0.8.13. Same chain as #370, #374, #381 and #383.

Mutation-proven nine ways, each red then green.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 12:30:29 +00:00
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>
2026-08-26 11:43:34 +00:00
64c057ecbf fix(control): drop the reaper's prose from runs that did not fail (#382)
#379 moved new reaper explanations to payload.note and restyled the old
ones. Checking the live card afterwards, the sentence was still there:

  "Reaped as timeout, but the repo shows work during the run window —
   corrected to partial (see evidence)"

Restyling was the wrong fix. The complaint was never that the text was
red — it is that the text is reaper vocabulary addressed to nobody, on a
run that succeeded. Quieter jargon is still jargon.

payload.error now renders only when run.state is error. That is safe by
construction, not by assumption: every writer of that field sets
state = error alongside it — closeRunUndelivered, and the reaper's
timeout branch — so an error sitting on a non-failed run can only be the
pre-2026-08-26 correction prose. Checked all four payload writers in the
orchestration routes; none of them set an error without the state.

Rows already in the database keep their data. Nothing is migrated or
deleted; the card simply stops reading a field that, for those rows,
holds a sentence written for whoever maintains the janitor. A non-failed
run says what it has to say through `note`, which is human copy from
EXECUTOR_COPY and carries a real evidence link.

The test now asserts the absence of the restyle branch too, so the
half-fix cannot come back as a "tidier" version of itself.

npm run verify green.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 12:44:29 +02:00
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>
2026-08-26 10:44:22 +00:00
e751ecfe4f fix(runs): a run that did not fail must not explain itself as an error (#379)
/control showed this on a project card, in the red error box:

  "Reaped as timeout, but the repo shows work during the run window —
   corrected to partial (see evidence)"

The run's outcome was `partial`. That is a success. Two defects in one
line: the reaper wrote non-failure explanations into payload.error, which
the card renders with `ui-error`, and the sentence was written for
whoever maintains the reaper — "reaped", "corrected to partial", and a
"(see evidence)" pointing at nothing the reader can click.

Three call sites did it, not one:

  reap-evidence.ts   timeout corrected UP to partial on repo evidence
  orchestration-runs reaped run whose agent had written a handoff
  orchestration-runs a genuine timeout

Only the third is an error. The first two now write payload.note, and
the copy moves to EXECUTOR_COPY.honesty so both read from one place
instead of two SQL string literals: "This run ran out of time, but its
work reached the repo — so it counts as partial rather than failed."

The evidence was already stored structurally and thrown away by the API,
which is why the sentence had to say "(see evidence)" — nothing carried
the link. payload.evidence now reaches the card and renders as "See the
pull request" / "See the push".

Rows already in the database still hold the old sentences in
payload.error, so fixing the writers alone would have left them looking
like failures forever. The card now styles by `run.state === error` — the
run's own account of whether it failed — rather than by which field
happens to be set. Old rows go quiet without a data migration.

Also extracted src/lib/repo-evidence.ts. The evidence type and its
validator lived in github-evidence.ts, which fetches from GitHub; the
moment control-types imported the TYPE from there, check:desktop started
walking that chain and broke on `next: { revalidate }`, absent from its
DOM lib. Caught by verify, not by review. A shape both a client type and
a server fetcher need belongs below both.

Evidence is validated at the API boundary, not cast: an unknown `kind`
drops the whole block, because the card labels the link BY kind.

Both source-level assertions were checked by reintroducing the defect and
watching them fail.

npm run verify green.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 12:29:41 +02:00
9d936c9842 fix(dates): fold the fourth renderer into the ladder (#378)
#375 claimed one elapsed-time ladder. It was not: compactRelativeDate
counted days itself, with a weeks tier the ladder does not have, and
appended the word "ago" on its own — a fourth place that word was
written. Verified on the live page after #375 deployed: one row read
"Last run 2w ago" while a card beside it read "14d ago" about the same
instant.

It now keeps the two tiers that are genuinely its own — "today" and
"yesterday", which are what a person calls those days and which no
elapsed count says as well — and delegates everything older to timeAgo.
So "2w ago" becomes "14d ago", matching every other age on the page.

Also clamps future timestamps to "today". The old `diffDays === 0` test
let a clock-skewed future date fall through to "-1d ago".

A loop asserts compactRelativeDate IS timeAgo past yesterday, at eight
ages, rather than merely resembling it.

secondsAgo stays separate and is not folded in: it renders sub-minute
precision ("12s") for live timers, where the ladder's "now" tier would
destroy the only information the display carries.

npm run verify green.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 12:02:37 +02:00
e6aa407c1c fix(feedback): a run's raw error is a diagnostic, not advice to the user (#376)
/control printed this on a feedback card, verbatim, twice:

  "Corrected 2026-08-24: repo evidence in the run window belonged to a
   sibling run; this run was acked verified:false and never started"

That is an engineer's note to another engineer, addressed to whoever
filed the feedback. It tells that person nothing they can act on, and it
is the kind of text that makes a surface read as debug output someone
forgot to remove.

The cause is one line, not one bad string: deriveFeedbackWork set

  detail: run.error?.slice(0, 160) || "The run ended without a successful
                                       fix. Retry or Watch Terminal."

so whatever an executor happened to write went onto the card AS the
advice line, and the sentence actually written for a human was only the
fallback for when no error existed. Every other phase's detail is
curated copy; this one was a coin toss.

detail is now always the curated sentence. The raw error moves to
`diagnostic`, rendered behind a "Technical details" disclosure the reader
opens on purpose. Kept rather than deleted: when a run genuinely failed
for a legible reason, that reason is the most useful text on the row —
the fix is where it renders, not whether.

Note this is a rendering fix, not a data edit. The two rows that showed
the sentence still hold it in the DB; they now show "The run ended
without a successful fix. Retry or Watch Terminal." with the note one
click away. Nothing was deleted from anyone's records.

Deliberately does not touch FleetFeedbackStrip: #372 replaces it with
ControlInbox. Fixing this at the derivation layer means whatever renders
work.detail inherits the curated copy, including that new component,
without a conflicting edit to a file being deleted.

npm run verify green.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 11:48:59 +02:00
ddd4c90bfa refactor(dates): one elapsed-time ladder, two renderings (#375)
There were three: timeAgo (capped at hours), shortTimeAgo (kept scaling,
and said so in a comment sitting right beside the one that did not), and
agoLabel in lib/atlas/format.ts, which existed ONLY because
`${shortTimeAgo(t)} ago` printed the phrase "now ago" during the first
minute after a check — exactly the minute someone is looking.

Three ladders produced three bugs. "Next (agent, 288h ago)" on a project
card. "now ago", still live at three call sites in ProjectDossierSections
that appended the word by hand, which is the very thing agoLabel was
written to prevent. And a silent disagreement about when weeks begin.

Now elapsedSince() is the single ladder and returns {value, unit}.
timeAgo renders it as "12d ago", shortTimeAgo as "12d". agoLabel is gone
— once both read one ladder it was character-for-character timeAgo, so
its two callers use timeAgo directly and lib/atlas/format.ts is deleted.

Two deliberate behaviour changes:

- Floors at every tier instead of rounding. An elapsed label must never
  claim more time has passed than has: 90s is one minute, not two.
- Days run to 30 before months. Loki lists and the dossier go from "3w"
  to "21d", which is the change flagged in #371 as needing its own PR
  rather than riding along with a bug fix. For a stale handoff the day
  count is the actionable reading.

The "now ago" class is closed with a gate, not a comment — a comment had
already failed three times. Any line in src/ that calls shortTimeAgo and
says "ago" after it fails the suite.

The gate's FIRST version was itself a green check that proved nothing:
`shortTimeAgo\([^)]*\)\s*ago` cannot cross the parens in
`shortTimeAgo(new Date(x).getTime())} ago`, so it passed while the bug
was injected. Verified by injecting it: the current per-line version
fails, and passes on a clean tree.

npm run verify green.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 09:44:45 +00:00