Commit Graph
363 Commits
Author SHA1 Message Date
CatoandClaude Opus 5 71a7b44ee6 feat(ai): show what the day's tokens were spent on (#723)
* feat(ai): show what the day's tokens were spent on

"What are the current providers, with limits, what is spent and on what" could
not be answered. The limits were there; the spend was one number with no
breakdown, and fifteen features were not in it at all.

ROUTING WAS NEVER THE PROBLEM

Worth saying plainly because I got it wrong first: every caller already goes
through ai-kit's chain. callTextDetailed walks the same chainFrom() with the
same fallback as the tool loop. There is one router, exactly as this file's own
header claims.

The gap was METERING. callOneLink did the fetch, read the body, and threw the
response headers away — so every digest, brief and form-fill drew on the same
Groq pool the capacity page was reading, and the page never saw them.

ONE LINE COVERS FIFTEEN FEATURES

recordVendorQuota() in callOneLink. They all reach the vendor through there.
Refusals record too: a 429 is the most reliable reading there is, because it
corrects a counter that had drifted optimistic.

`feature` IS NOW REQUIRED, AND THAT IS THE DESIGN

No default. The compiler then named every caller that had not named itself —
19 call sites in 15 files — and each now declares a slug the page can show a
person: activity-digest, form-assist, calendar-extract, project-brief,
frontier-propose, frontier-judge (its own slug: the panel's value is being an
uncorrelated second lineage, so its cost is worth seeing separately), dod-gate,
hosted-runner-analyze, and the rest.

A default would have let the twentieth caller be invisible again. That is how
the first fifteen got there — not by anyone hiding them, but because the
cheapest thing to write was the unnamed thing.

A SECOND TABLE, NOT A WIDER ONE

ai_spend answers "what has THIS USER spent today" and is read by the admission
gate on every turn; it must stay a point read on one row per (user, day).
Putting provider/model/feature in its key would make the rationing path pay for
reporting. ai_usage answers the orthogonal question and is keyed
(day, provider, model, feature). The user dimension is deliberately absent —
recording the same fact twice is how two tables start disagreeing.

VISION AND WHISPER REPORT TOO

They have their own transports and I nearly left them out. They spend the same
vendor pools, so omitting them would have made the page complete-looking and
wrong — the failure this surface exists to end.

EMPTY IS NOT ZERO

The ledger starts empty each UTC day, so the page says "nothing recorded yet
today", never "nothing spent". Same three-state discipline the provider rows
already keep.

5 coverage checks defend the guard itself, including that nobody can quietly
restore `options: GroqOptions = {}` and reopen the hole. Verify green, 237.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nm2REqtdsVsvjukBU2maCz

* chore: re-trigger CI (previous run stalled 5s after start)

The prior CI run for this branch froze with updatedAt five seconds after
creation and sat in_progress for 45 minutes, while every other branch's CI
completed in 3-5 minutes in the same window. A stuck runner, not a slow test —
two candidate causes in the change itself were tested and both disproved:
a unit test writing to a reachable database still exits, and importing the db
module against a live connection does not hold the event loop.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nm2REqtdsVsvjukBU2maCz

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 03:08:59 -07:00
CatoandClaude Opus 5 3e736fb8d0 fix(contact): publish cato@orangecat.ch, an address that exists (#726)
mao@orangecat.ch was never a mailbox. The orangecat.ch mail service showed
0 of 1 addresses used — "You don't have an address yet on orangecat.ch" —
so every security report, licensing enquiry, privacy request and investor
mail sent to it bounced. Nothing reported that, because a dead address is
silent by construction.

cato@orangecat.ch now exists (created 2026-09-15, Infomaniak) and matches the
public name in the org register. Swapped in the eight files that publish a
contact: LICENSE, SECURITY.md, the privacy policy, the terms, the investor
contact, the seed fallback, and a test fixture.

NOT changed, deliberately: "Mao Nakamoto" as the named operator, data
controller and copyright holder in LICENSE, TERMS, PRIVACY and the IP
assignment memo. Replacing the party to a contract is a decision that may want
a legal name rather than another pseudonym. docs/AUDIT_REPORT.md keeps the old
address because it is a dated record of what was true then.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 02:37:31 -07:00
CatoandClaude Opus 5 b2b724289b test(e2e): the check reads the run's real status, and a rationed refusal is a skip (#725)
Two ways this check lied about a working product, both found by running it on
the box rather than by reading it.

It printed `still ?/- after 20 min` when a dispatch produced no outcome turn.
`GET /api/orchestration/runs/[id]` answers the DERIVED dispatch view
(status/label/terminal), not the raw row, so reading it as {state, outcome}
told nobody anything — exactly when the diagnosis mattered most. It now reads
`status` + `terminal`, so a closed run with no turn is named as a lost
notification and an open one as a stuck builder.

And it FAILED "knows the fleet" when Loki correctly answered "You've used your
share of today's free AI budget for now." The free tier is rationed by design;
on a six-hourly timer with Telegram on flip, that pages for a healthy product
until the alerts get muted. A test against a rationed dependency needs three
verdicts, so there is now SKIP-with-reason: it does not fail the run, it says
why, and it never retries a rationed refusal (which would only spend the next
window too).


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 02:32:06 -07:00
CatoandClaude Opus 5 ac6e118bb1 feat(fleet): publish what a project IS, not just where it runs (#724)
A project's problem, solution, mission, vision, roadmap and changelog already
lived in its profile — four attribute keys, the `goals` table, and
`user_projects.dev_log` — and were injected into every dispatch. None of them
were readable from outside the database, so a site that wanted to show them had
no choice but to type its own copy, and the copies rot: orangecat's public
changelog stopped at 2026-07-31 while its main branch ran on to PR #1039.

The map now carries all six. A page renders them instead of authoring them.

WHAT IS PUBLISHED, AND WHAT IS DELIBERATELY NOT

Each projection is an allow-list that drops a column sitting next to the one it
keeps, because every one of those columns is on a row we now serve publicly:

  identity   four attrs from PUBLIC_IDENTITY_ATTRS. The attribute table is OPEN
             (the UI lets anyone add a key) and already holds business_plan,
             competitors, partnerships and security_vulnerability. A deny-list,
             or "publish every attr", puts the next key someone types on the
             public internet by default. The allow-list is applied in the QUERY
             as well as the projection, so an excluded key is never read into
             the process at all.
  roadmap    goal title, status, progress, target day, milestone TITLES.
             NOT goal.description: read in production today, those are internal
             engineering notes carrying acceptance criteria — "Acceptance:
             pushing main runs DB migrations", "HMAC entitlement webhook
             verified". A public roadmap is what we are working on and how far
             along, not the conditions under which an engineer may call it done.
             Completed goals stay; a roadmap that hides what shipped reads as
             though nothing ever does.
  changelog  dev-log `done` and the day, newest first, capped at 20.
             NOT next/tests/todos/health — operator working notes, not entries.

Null means nobody has written it; an empty array means the surface exists and is
empty. A consumer must render those differently, so the shape keeps both.

AND THE BUG UNDER THE WHOLE THING

/api/fleet/register built its projection without a `description` key at all.
load-map.ts passed it; this route never did, and usefulDescription(undefined) is
null — so the register's ONLY prose field was null on all 35 rows, and the gap
presented exactly like a register nobody had written descriptions for. One line.

PROVEN BY MUTATION, NOT BY SHAPE

39 assertions, every one paired with the negative: the adjacent field is absent
from the output. A test that only checked the happy shape would pass just as
well with the filters deleted, so all three were broken on purpose and each
turned the suite red — changelog spreading the entry, identity iterating the
caller's keys instead of the allow-list, roadmap spreading the goal row.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 01:57:54 -07:00
CatoandClaude Opus 5 aa287aa2cf fix(hosted): a one-shot runner drains its work before it exits, so the thread hears (#721)
A hosted dispatch ran, Hermes did the task, the run closed `done/success`
with its summary — and the conversation that asked for it never heard a word.
Nothing errored. Nothing logged.

`updateOrchestrationRun` fires `void notifyRunClosed(...)` — its contract is
never to slow a close — and that call is what writes the outcome turn. The web
server outlives such a promise for free. `hosted-runner.ts --once` is a
45-second cron tick: it drained the command and called `process.exit(0)`
while the write was still in flight.

- settle-background-work.ts: a bounded drain window (5s,
  HOSTED_RUNNER_DRAIN_MS), paid only by a tick that actually drained
  something. A window rather than a promise registry, because the void-call is
  this codebase's convention at dozens of sites and threading bookkeeping
  through all of them to repair one process boundary is the larger change.
- loki-loop-e2e.ts now reads the run's state when no turn arrives, so the two
  halves can never be confused again: a CLOSED run with no turn is a lost
  notification (the work happened); an OPEN one is a stuck builder. That
  distinction cost an hour today.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 01:08:42 -07:00
CatoandClaude Opus 5 ee03f3daa1 fix(control): name the button Attention actually draws (#722)
/control used to render Retry beside every failure. For "no running agent" that
button was a lie — the target is identically absent on every attempt, so it
fails identically forever — and it was replaced with "Start session".
failure-remedy.ts still records why.

The BUTTON was fixed. Two sentences describing it were not:

  TerminalSurface  "open Control — Attention shows Retry when the prompt
                    never started."
  ControlInbox     "Queued for X. If Attention shows Retry, the agent never
                    started."

Both describe the never-started case, which IS the no-running-agent case, which
is exactly where Attention deliberately shows "Start session" and no Retry at
all. So the flow ended by sending the reader to Control to hunt for a control
that is not drawn — after a dispatch, at the moment they most need it to work.

Nothing was broken enough to notice: the button that is missing looks the same
as a button you have not scrolled to.

WHAT CHANGED

The button words join the remedy SSOT as REMEDY_LABEL, AttentionBar renders
from it, and both sentences now interpolate the label for the case they
describe instead of typing one. Prose and button can no longer disagree,
because there is only one copy of the word.

THE GUARD

scripts/test/remedy-copy-agreement.ts asserts the mapping, asserts every remedy
has a label, and greps src/ for prose that promises "Retry" for a never-started
situation. It also proves its own detector is not inert by running it against
the exact sentence that shipped and against the corrected one.

Reintroducing the old sentence on a copy turns it red:
  ✗ no copy promises Retry for the never-started case —
    found: src/components/terminal/TerminalSurface.tsx:544

tsc clean, eslint clean, prettier clean, unit suite green.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 01:08:10 -07:00
CatoandClaude Opus 5 a78b4b1e9a fix(runs): a fast task closes its run — delivery is stamped at injection, not at the ack (#720)
* fix(runs): a fast task closes its run — delivery is stamped when the prompt lands, not when the runner acks

The e2e health probe did everything right and its run never closed. The
agent was injected at 05:12:55, wrote `status: ready` at 05:13:06, and the
runner acked at 05:13:11 — because between injecting and acking it spends up
to eight seconds (plus retries) checking that the agent is actually
generating. `deliveredAt` was stamped at the ack, and closeRunFromSession
requires the handoff to POST-DATE delivery, so the run's own handoff read as
stale. It sat `waiting` until the hourly reaper called it a timeout.

Every task shorter than that check hits this, which is every health probe and
most one-line fixes — the runs most likely to be used as proof that the loop
works.

The runner now records the moment of `injectPty()` and reports it in the ack;
the server prefers it (`deliveryStampFor`) within bounds that keep the floor
honest: never before the run was created (60s of clock slack), never in the
future, otherwise the ack time as before. Tested on the verbatim timings above.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

* chore(desktop): ship the delivery-stamp fix as Fleet Runner 0.8.25

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-14 23:18:42 -07:00
CatoandClaude Opus 5 fadb7f4274 fix(terminal): a "Watch" link must open the thing it offered to show (#719)
Dispatch a prompt from Control and you get a "Queued — waiting for a builder"
banner with a Watch link. Clicking it opened a plain bash prompt showing a
week-old panic message. The agent was running the whole time; the page just
opened somewhere else.

WHY

Every watch link is `/terminal?project=<key>` with no source, and the terminal
resolved its source as `initialSource ?? mode.source` — where `mode.source` is
REMEMBERED IN LOCALSTORAGE. Anyone who had once picked Shell had every watch
link on Control silently redirected to a bash PTY, for that browser, forever.
Nothing errored. Nothing looked broken.

A shell cannot be the answer to a project link: it is a Loki-owned bash PTY
with no concept of project tabs — `stripTabs` is not even passed when the
source is "shell". So `?project=` plus a remembered "shell" is never what the
link meant.

THE RULE

A deep link that names a project resolves to an agent source. An EXPLICIT
`?source=shell` is still obeyed — that is the reader asking, rather than a
stale preference answering for them. Nothing else changes: opening /terminal
with no project still honours whatever you last chose.

The rule lives in src/lib/terminal-deep-link.ts so it can be asserted rather
than inferred from a component, and `fleetSurfaceHref` now takes an optional
source so callers that know where an agent runs can say so instead of leaving
it to be resolved.

PROVEN, NOT ASSUMED

- 8 assertions, both directions: the regression, the remembered-shell case with
  no project (still shell), explicit ?source=shell with a project (still
  shell), an agent source surviving a project link, a hosted plane with no
  shell at all, and shell-as-only-source returning something usable.
- Reverting the fix on a copy turns two of those red — the test catches the
  original bug rather than describing the new code.
- Driven in a real browser against a dev server, same URL, same browser, with
  `loki:terminal-mode` seeded to `shell`:
    before the fix -> the header reads "Shell"   (the dead end)
    after  the fix -> the header reads "Cloud"
  and the two negative cases re-checked live: no project -> "Shell",
  explicit ?source=shell -> "Shell".


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-14 22:48:39 -07:00
CatoandClaude Fable 5.1 f7c4e35fdc feat(builder): a project can pin its work to the hosted runner — no Claude credential needed (#718)
builder_pref gains a third value, 'hosted'. A project pinned to it never
touches a runner PTY: the dispatch goes straight to the hosted runner
(Hermes in its own clone on the box, on the providers the box already holds
keys for — Copilot, Gemini, Groq), and the hosted runner closes the tracked
run with the pull request as evidence, so the outcome reaches the thread
that asked, like any other run.

Why now: the box's Claude Code credential died silently and every
self-dispatch hung, while Hermes on the same box answered fine. The
unattended path should not depend on a person's Claude subscription at all.

- statuses.ts: HOSTED_BUILDER_PREF / BUILDER_PREFS (channels stay what they
  were — nothing claims 'hosted' from a queue); API enum widened.
- inject-core: hosted branch before the channel pin; run id travels in the
  hosted_dispatch payload.
- hosted-runner: closeHostedRun() through updateOrchestrationRun (outcome
  turn, ledger, escalation bookkeeping all fire); delivered stamp at claim.
- Control → project profile → Runs on: third choice with its explanation.
- docs/development/cloud-local-workflows.md: the tier in the SSOT table.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 22:43:29 -07:00
CatoandClaude Opus 5 a4529b94e3 fix(loki): the tool loop answers too, it does not narrate its plan (#717)
#709 stopped the Groq FALLBACK serving the model's plan as the answer. The same
guard was missing on the tool loop — the path that serves nearly every turn.

WHY GROUNDING CANNOT COVER THIS

A plan asserts nothing, cites nothing and invents no proper noun, so it passes
every rule in verifyAnswer while telling the operator nothing at all. That is
exactly how it reached production: retrieval was fine, the answer was
scratchpad, and every automatic check said the turn was clean.

WHY THE GAP IS REAL AND NOT THEORETICAL

openai/gpt-oss-20b — the model that demonstrably wrote "We need to answer: … We
must cite each claim … Let's go through each:" and spent its whole budget on it
— is link TWO of this chain. The only reason the leak has not been seen here is
that gpt-oss-120b usually answers first. That is luck, and a fallback chain
exists precisely for the times the first link cannot answer.

MEASURED BEFORE ADDING IT

Ran the detector over every assistant reply Loki has stored: 106 replies, fires
on exactly 2 — both the same question, both from before the fallback fix, both
genuine leaks. ZERO false positives on the other 104.

That was the deciding number rather than the hit rate. A guard that misfires
costs a second model call on a rate-limited free tier, which is the resource
this whole week of work has been about conserving.

THE CURE MUST NOT BE WORSE

Four properties pinned, three of them about restraint:

  - a plan is retried ONCE, with the instruction the first attempt showed it
    needed — never a loop
  - a second plan is not an improvement, so it is not retried again
  - an EMPTY retry never replaces a real reply: a plan at least shows the model
    read the question
  - a good answer is never re-asked, so the common path costs nothing

The retry carries no tools: the model already gathered what it needed, and the
failure was in writing the answer, not in finding it. A failed retry leaves the
first reply standing — losing the turn to protect its formatting is the worse
trade. The stream is reset so the plan does not sit on screen above the answer.

Proved by mutation: disabling the guard fails "the plan must not reach the
operator" and nothing else.

Verify green, 233 checks.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-14 22:40:09 -07:00
CatoandClaude Opus 5 b95ef434b9 feat(ai): a third vendor Loki does not share with anything — Gemini (#714)
Loki's free chain had two vendors and both are SHARED. Groq's daily token pool
is org-wide and OpenRouter's 50 requests a day are account-wide, and on bitbaum
the same OpenRouter key serves ten apps — so those two links do not just run out,
they run out TOGETHER, for everyone. A Google project is per-app.

That is the property being bought here, not the model. ai-kit 1.8.0 adds Google
to `freeChain()`, so this is a dependency bump and nothing else — the chain comes
out of the package already ordered:

    groq -> google -> openrouter

    google models: models/gemini-flash-latest,
                   models/gemini-flash-lite-latest,
                   models/gemma-4-31b-it
    google keyEnv: GEMINI_API_KEY
    day capacity (all keyed): 250000

OpenRouter stays LAST on purpose: its unpaid tier is the scarcest pool in the
chain, so every other pool is drained before one of those 50 requests is spent.

Every id was verified with a real key on 2026-09-15 — 200 on the catalogue, a
NATIVE tool_call from each of the three, and a non-empty completion with
finish=stop. The `models/` prefix is deliberate: the catalogue lists all 56 ids
prefixed with no bare form anywhere, while /chat/completions accepts both, so a
bare id would serve perfectly AND be reported missing by the rot check forever.

ONE TEST HAD TO CHANGE, and it is the interesting part.

`ai-budget-gate.ts` set exactly GROQ_API_KEY and OPENROUTER_API_KEY, then
asserted capacity equalled the sum over EVERY provider in CHAT_CHAIN. That is
the same statement only while the chain has exactly two vendors; with three it
went red at 200000 vs 250000. The assertion was about capacity but was WRITTEN
as an assumption about how many vendors exist.

It now derives its keys from the chain, so a fourth vendor cannot silently turn
"all keyed" back into "some keyed". And it gains the case that was impossible
before: an UNKEYED vendor contributes nothing to the total — with two vendors,
"all keyed" and "some keyed" were the same set, so the subset could not be
stated at all.

(The identical bug existed independently in ai-kit's own chain.test.js and was
fixed there in the same release. Two repos reached the same wrong shape from the
same true premise.)

GEMINI_API_KEY is already installed in /opt/loki/app/.env, and the unit reads
that file (EnvironmentFile=/opt/loki/app/.env), so this takes effect on deploy.

Worth stating for whoever weighs it later: Google's FREE tier says content is
used to improve its products; the paid tier says the opposite. This is the
second-to-last link, reached only once the pools above it are spent.

Verified: pnpm run verify clean, 171/171 unit test files.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-14 20:57:30 -07:00
CatoandClaude Fable 5.1 efeabdec64 test(e2e): does Loki work as intended — asked of the live site, on a clock (#712)
Three testable meanings, one script, no browser and no mocks
(scripts/test/loki-loop-e2e.ts, run as the signed-in operator through the
same API the /loki page uses):

1. knows the fleet — a fleet-shaped question is answered from the studio map
   (all three pillars named, fleet_map among the retrieved sources) and the
   reply is an answer, not the model's plan for one;
2. publishes the map — /api/fleet/map is public with the pillars live, and
   bitbaum's map.json is the same map, recently generated;
3. closes the loop (--dispatch) — a request typed into a thread comes back
   into that thread as an outcome turn. A run that never returns is aborted
   with a [loki-e2e] marker so no test leaves the operator's queue hanging.

Proven against production before commit: 3/3 without dispatch; with dispatch
and the builder unauthenticated, the loop failed honestly inside two minutes
with the runner's own diagnosis delivered into the thread.

Scheduled on the box every six hours (install-loki-e2e-watch.sh ->
loki-e2e-check.sh, alert on flip; the dispatch leg only when the builder-auth
probe last said ok). pnpm run test:e2e:loki runs it from a laptop.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 05:17:40 -07:00
CatoandClaude Fable 5.1 b8aea45988 fix(loki): the Groq fallback answers, it does not narrate its plan (#709)
Asked "what projects do we have, name the three pillars" with the fleet map
in context, the fallback (openai/gpt-oss-20b at low effort, 1024 tokens)
replied "We need to answer: … We must cite each claim … Let's go through
each:" and spent the whole budget describing how it would answer. No
<think> tags, so stripReasoning let it through; grounding passed, because a
plan makes no claims. Probed on Groq directly: gpt-oss keeps its reasoning in
a separate field — this was the FINAL channel, the model thinking out loud
because low effort gave it nowhere else to.

- effort "medium" with a 2048-token budget, raised together as groq.ts
  documents, so the thinking happens in the hidden channel.
- looksLikePlan() (pure, tested on the verbatim leak) catches a reply that
  addresses the model instead of the operator; one retry with an answer-only
  instruction, after a stream reset so the plan does not stay on screen.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 04:38:53 -07:00
CatoandClaude Fable 5.1 5136a3b387 feat(projects): say whether something is being built, and one big Make it happen (#707)
A project kicked off from OrangeCat was dispatched at 22:31, its agent went
silent after 113 bytes of output, and the reaper closed the run at 00:15. The
next morning the page said "No live agent" in a card halfway down, with a
text-xs "Run next step" beside it. Nothing answered "is anything being built?"
either way, and there was no obvious way to start it.

- lib/project-build-status: ONE derived answer (building / queued / stalled /
  idle + last attempt) from the runner's last observation, the run ledger and
  the commit list. A runner's `agentRunning` claim past the offline threshold
  is expired, not true; an open run past a grace window is stalled, not running.
- ProjectBuildStatus: the first card on Now. Building → "Watch it work";
  nothing running → "Last attempt timed out 1h ago after 1h 44m — nothing
  reached the repo" and a full-size Make it happen. Same label as the kickoff
  hero, because it is the same act; the strip yields to the hero when setup is
  still missing, so there is never a second CTA.
- project_states lookup falls back from project id to every key a runner files
  the row under (display name, checkout directory, repo slug). 92 of 104 rows
  on the box have no project id, so the id-only lookup was blind for almost
  every project.
- NowSection stops reporting "Agent process running" from an expired claim.
- "Run next step" (xs, inside the Next card) is gone; the strip owns dispatch.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 04:20:31 -07:00
Cato 15fb484a50 fix(feedback): Implement gets a real builder, Working means a PTY, Telegram when Needs you (#705)
Phone evidence: Heidi sat Queued / fake Working / Stalled with cloud builder
offline and no session on Cloud. Boss-mode:

- Implement prefers the cloud box-runner, falls back to hosted Hermes when
  offline, and refuses with one next action instead of queueing into the void.
- Working only when a runner heartbeat proves a real agent PTY; delivered
  with no output is Starting, then Not running — never fake Working.
- Feedback/Control stay short (badge + next action; dig-in for why);
  Telegram pings when stalled or Check live waits (check-feedback-needs-you).
2026-09-13 22:29:59 -07:00
CatoandClaude ab1fa88cb5 feat(loki): tell Loki what the neighbour can make, and what it cannot (#704)
OrangeCat shipped a Studio: it renders video, music, longform writing and
artwork, and revises them from plain-language notes. Loki knew nothing
about it, so an operator asking "can I make a trailer for this project?"
got a flat no — wrong, and the kind of wrong that sends someone looking
for another tool.

The tempting fix is to let Loki sound capable, which is precisely the
failure LOKI_CAPABILITIES exists to prevent (it began after Loki invented
a security sandbox and an Approve button that would book a calendar
event). So the facts and the boundary land together: ORANGECAT_CAPABILITIES
in config/ecosystem.ts states what OrangeCat can do, the preface
interpolates those lines rather than restating them, and the same preface
denies Loki every one of those abilities and hands over a real URL
instead.

scripts/test/loki-neighbour-boundary.ts pins both halves — that the
preface reads the SSOT (no verbatim copy that could drift) and that the
disclaimer still travels with it. The build handoff copy now says what
OrangeCat is actually for, which is no longer only funding.

Note: `pnpm run verify` could not run here — pnpm install fails in this
sandbox on the private bitbaum/listkit tarball (403, no credentials). The
changed files were checked against the repo's own Prettier 3.9.6 config
and the new test's assertions were dry-run against the real sources; CI
is the first place the full gate runs.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-13 18:58:54 -07:00
CatoandClaude Fable 5.1 f8f557a5ef feat(loki): a fleet-shaped question reads the studio map as one fact (#703)
"What projects do we have, which are live, name the three pillars" retrieved
an essay (similarity 0.72) and answered that the pillars were Blog, Roadmap
and Changelog. The map chunk existed in the index and lost the race: one long
overview embeds worse than a focused essay.

The shape of the studio is not something a similarity search should be
trusted to find. A fleet-shaped question (what do we have, which are live,
pillars, the studio, how many projects, what is loki for) now plans
fleet_map FIRST — ahead of knowledge, because "what is X for" is a map
question — and fleetMapFacts() hands the live map in as one 8k fact, the
same overview the nightly reindex embeds and /api/fleet/map publishes.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 18:49:24 -07:00
CatoandClaude Fable 5.1 366398d149 fix(fleet): a project with a live URL but no hosting row is live, and dev-log dates are days (#701)
loki and orangecat are served from the main Caddyfile, not apps.conf, so the
map filed both pillars under "not live" next to their own live URLs, and
bitbaum would have grouped them as Not live. liveUrl is the SSOT for served;
the register row only adds kind/owner/since. Dev-log dates are timestamps in
the DB and days on the map.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 18:35:10 -07:00
CatoandClaude Fable 5.1 c2f001a511 feat(fleet): publish the studio map — every project's purpose, layer, state and last movement (#698)
"What do we have, what is each thing for, where does it run, what is happening
on it" was answered by the register (facts) plus 24 hand-written briefs, a
showcase overrides file and an ecosystem config that all restate the register
in prose and drift within days. The assistant could not answer it at all: no
chunk in the knowledge index held the shape of the fleet, so "what projects do
we have" came back as "Not in your data".

- GET /api/fleet/map: the register join, plus per project the purpose line
  from its profile, a layer (the three pillars, product, client, demo, next),
  hosting state and owner, public doors (live, repo, OrangeCat, Solon), the
  dev log's declared next step, and what last moved (open runs, last run
  outcome, last log headline). Public and cached like the register; prices,
  paths and tokens stay out (api-route-auth names the reason).
- src/lib/register/map.ts is pure and unit-tested; load-map.ts is the I/O half,
  shared by the route and the nightly reindex so page and assistant read the
  same map.
- reindex-knowledge embeds one fleet_map overview chunk (owner-scoped): one
  line per project in a fixed order, so the fleet's shape is retrievable.

bitbaum renders this map (its own PR) and publishes it as map.json; Cat on
OrangeCat reads it into its context.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 18:04:18 -07:00
CatoandClaude Fable 5.1 81f4eeeb98 feat(loki): a dispatched run reports back into the thread that asked for it (#697)
A request typed into /loki ended at "Dispatch queued". The run closed hours
later into run_events, a push notification and Telegram — everywhere except
the conversation the person was typing in. Learning whether the work happened
meant leaving Loki for GitHub, which is the trip this product exists to make
unnecessary.

- Chat dispatches now carry the conversation id and opt into close
  notification. On close, notifyRunClosed also writes an assistant turn of
  kind "outcome" into that thread: what happened, the pull request found in
  the repo during the run (which merges on its own once green) or the honest
  absence of one, and the project's live URL (run-outcome-format.ts, pure and
  tested; run-outcome-post.ts does the lookups).
- While the newest turn in a thread is still a dispatch, the workspace
  re-reads the thread every 20s so the outcome appears without a reload.
- The dispatch closing and the box agent contract now ask for auto-merge on
  the PR the agent opens: CI is the reviewer, a green PR merges and deploys by
  itself, and the old "never merge from here" no longer leaves work stranded
  behind a button nobody presses.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 17:36:47 -07:00
CatoandClaude Fable 5.1 95c40a9cd8 refactor: rename the product from FleetCrown to Loki (#695)
The product, its assistant, the repo, the host and every unit on the box now
share one name. 638 files, ~3,000 mentions: UI copy, config, env keys
(FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs,
articles, the deploy workflow other repos reuse, and nine file names.

- Three article slugs carried the old name and had been shared; permanent
  redirects keep those links alive (next.config.ts).
- test-no-retired-name.sh now also forbids the old product name across the
  whole repo, so the rename cannot creep back through templates and examples.
- ASSISTANT_STACK collapses the product and the assistant into one entry,
  because they are now the same name.

Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki`
database and role, loki.orangecat.ch (old host 308s to it; /api, /widget,
/embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases.
The Resend sending domain stays fleetcrown.orangecat.ch until the new domain
is verified in DNS.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 16:13:10 -07:00
CatoandClaude Opus 5 d32f6c9968 fix(ai): "spent" must never sit beside a number that says otherwise (#691)
Rendered the capacity page from the LIVE production table and read it. Groq's
per-minute window came out like this:

  groq  openai/gpt-oss-120b   [spent]
     3,984 of 8,000 tokens this minute

Half a tank, labelled spent. The STATE is right — 3,984 tokens buys no whole
answer, so the turn genuinely cannot be served from that window — but the word
contradicts the figure printed next to it, and a label that argues with its own
number is exactly how a dashboard gets called made-up.

So a shortfall is now its own fact:

  groq  openai/gpt-oss-120b   [too low]
     3,984 of 8,000 tokens this minute — under one answer's worth · back now

An empty tank still says spent. The two are not the same and they do not even
recover on the same timescale: a minute window with 3,984 left refills in
seconds, while 0 of 50 requests a day is back tomorrow. The summary counts them
apart for the same reason.

THE SUBTITLE CARRIES MEASUREMENTS, AND ONLY MEASUREMENTS

The same render showed the "also metered" line repeating a skip notice under a
row that already said it, and a stale counter phrased as "not measured recently
— this counter refills every minute", which does not even name which counter it
is talking about. Neither is a measurement. Both are gone; nothing measured is
hidden, because an unmeasured counter was never measured.

Quota-view checks 27 -> 31. Verify green.

Found by looking at the page rather than at the tests — which is the only way
either of these was ever going to be caught.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 07:19:57 -07:00
CatoandClaude Opus 5 6b552296a6 fix(ai): show the limit that is actually stopping you (#690)
Groq meters three things. It publishes two.

At 13:26 today the capacity page had every reason to call Groq healthy:

  tokens / minute   header      2,672 of 8,000 left
  requests / day    header      999 of 1,000 left
  tokens / DAY      429 body    227 of 200,000 left

The third is why "what needs me right now" returned a 503 to the operator. It
is stated once, in prose, inside the body of the refusal enforcing it, and
nothing was reading it.

TWO CHANGES, ONE IDEA

1. Record the counter only the refusal admits to. ai-kit 1.6.0 adds
   readingFromRefusalBody; this wires it into the 429 path. A "size" 429 is
   deliberately excluded — that reports THIS PROMPT being too big, a fact about
   the prompt, not about remaining allowance.

2. One model, one row. Three bars per model is not more honest, it is less: it
   invites the reader to average limits that do not average. The answer to "can
   I use this right now" is the WORST counter. Counters are ranked by how hard
   they block — exhausted, then skipped, then tightest known, then unknown — and
   the leader is shown with the rest named underneath, so nothing measured is
   hidden.

A STALE COMPLAINT MUST NOT OUTRANK A LIVE MEASUREMENT

A skip row says "at 13:27 we did not call this", and nothing ever rewrites it —
only another skip replaces it. So once the budget fix lets Groq through, this
page would have gone on insisting Groq is never reached, indefinitely, while it
was quietly answering. A reading taken later than a skip now supersedes it. Both
directions are pinned: the fix must show as fixed, and a skip newer than every
reading still leads, because then it IS the current fact.

TWO BUGS FOUND ON THE WAY

Both would have read as more numbers that do not add up.

  - React was keying two rows identically. key={provider}:{model} already
    collided, because Groq reports two counters for one model TODAY.
  - summarise counted counters as providers, so a page with two vendors was
    announcing "of 5 configured".

Grouping fixes the arithmetic at its source rather than papering over either.

Verify green. Quota-view checks 19 -> 27. The ai-kit side was proved by
mutation: breaking the arithmetic fails 3 of its 4 new tests.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 07:07:18 -07:00
CatoandClaude Opus 5 f926f37811 perf(loki): stop skipping Groq on prompts it would have taken (#689)
Sizing a prompt and skipping a link look like the same question. They are not,
and answering them with one number was costing us the fastest provider we have.

WHAT THE PRODUCTION LOGS SAID

Yesterday's scoped catalogue got the feedback turn onto Groq for the first time:

  [loki] turn via=tool-loop model=loki/groq/openai/gpt-oss-120b ms=1378

1.4 seconds, where the OpenRouter path measured 19-25s. But four other question
shapes were still walking past it:

  skipped groq/openai/gpt-oss-120b (prompt ~5887 > 5400)   <- 487 tokens over
  skipped groq/openai/gpt-oss-120b (prompt ~6996 > 5400)
  skipped groq/openai/gpt-oss-120b (prompt ~7790 > 5400)
  skipped groq/openai/gpt-oss-120b (prompt ~8316 > 5400)

5,400 is not Groq's window. Groq's window is 8,000. The gate was built from
floor(8000 * 0.85) - 1400, stacking an estimator margin on top of a reply
reserve AND charging the margin against the reserve — a fixed allowance we
choose, which has no estimator error in it. The honest bound is 8000 - 1400.

THE TWO MISTAKES DO NOT COST THE SAME

  Skip a link that would have answered
    -> the turn goes to OpenRouter: 19-25 s, and one of only 50 free requests
       a day. Measured today: that pool hit zero mid-eval and the next question
       returned a 503 to the operator.

  Try a link that refuses
    -> Groq answers 429 in about a second and the chain moves on to that same
       OpenRouter call. A per-minute refusal is rejected before processing, so
       it costs nothing against the daily token pool either.

One second against twenty-five and a scarce request. A gate with that payoff
belongs at the hard limit. The 429 IS the safety net — which is exactly why the
estimator's 15% does not need to be charged twice.

SIZING KEEPS ITS MARGIN

Two functions now, because the asymmetry only runs one way. Sizing a prompt too
big is unrecoverable — it gets truncated, or the only link refuses it and there
is nothing to fall back to — so linkPromptBudgetTokens is unchanged and the loop
still sizes against it. Only the chain walker moves to the new ceiling. A
Groq-only deployment therefore still packs conservatively; it just stops
refusing to try.

Two tests pin the bounds apart, including that they only diverge for a
per-minute-metered vendor — elsewhere a second knob is a second thing to drift.

Effect: the 5,887-token turn now reaches Groq. Verify green, 11 budget checks.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 06:39:39 -07:00
CatoandClaude Opus 5 684883549f fix(terminal): give the phone back its screen, and say where the shell runs (#688)
Three complaints, measured on a 390x844 phone before touching anything.

TOO MUCH CHROME

The page spent 204px above the terminal and 64px below it — 268px of 844,
before a single line of shell. The terminal got 390px. An optional email
reminder was 74px of that: not required, dismissible, and sitting on the one
page where the viewport IS the product. It is now suppressed on /terminal
specifically, not removed — it still appears everywhere else, and dismissing it
there still silences it for good.

Chrome above the terminal: 204px -> 130px. The terminal: 390px -> 480px, +23%.

NO FEEDBACK

The pane printed the raw lifecycle enum into its header — "provisioning",
"starting". Those are our words for our state machine, not an answer to the
only question being asked, which is whether the thing is working. They now read
opening / starting / ready / idle / closed / failed, and a failure offers
"Try again" instead of a dead end.

WHERE IS THE WORK HAPPENING

The pane never said. It knew: /api/workspaces resolves the cwd and then threw
it away. The route now returns `cwd` and `home` alongside the handle, and the
pane header shows the directory, full path on hover. The existing stall overlay
gets it too, so "nothing came back" names the place nothing came back from.

WHAT I GOT WRONG ON THE WAY, BOTH CAUGHT BY LOOKING

A first pass truncated the path from the left with CSS `direction: rtl`. That
moves the leading separator to the far end: /home/g rendered on the page as
"home/g/". A shortened path is fine; a path that is a DIFFERENT path is not —
it is the one string on that row someone might act on. Shortening now happens
in code (src/lib/terminal-path.ts, 22 assertions), where the output is a real
string that can be asserted. It lives in lib rather than beside the component
because importing the component pulls xterm's stylesheet into the test runner.

The same pass added a stall detector to the pane. TerminalView already had one
— driven by ACTUAL OUTPUT rather than by lifecycle state — and mine fired a
banner reading "No output yet" over a terminal with output plainly on it, twice,
for two different states. Two detectors that can disagree is how a page starts
lying. Mine is deleted; the real one now gets the location it was missing.

pnpm verify green. Rendered and measured at 390px throughout.

NOT FIXED, AND WORTH KNOWING

The mobile key deck and composer only mount once a session is attached
(`activeTab`), so a session that never attaches leaves the phone with no way to
type and no way to retry from the keyboard. That is a real hole, but the fix is
a layout decision about what the dock should show with no session, and it is
not a change to make blind.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 06:16:26 -07:00
CatoandClaude Opus 5 83968bae23 perf(loki): show the tools the question needs, accept all of them (#687)
Groq's window is 8,000 tokens per minute. A measured feedback turn was 10,153,
so the preflight skips Groq on every single call and a whole free provider is
never used — which is the direct reason OpenRouter burns its 50 requests a day.

Cutting RECORDS to fit would recreate the failure this retrieval layer exists to
end. So I measured where the tokens actually are before touching anything:

  system prompt (tools on) : 1,869   of which the catalogue: 1,328
  native tool schema       : 1,141
  FIXED OVERHEAD           : 3,010 tokens, before a single record

That is 47% of a 6,442-token turn, spent on eighteen tool descriptions.

Scoping the catalogue to what the planner already routed saves 1,100–1,700
tokens per turn. The feedback question goes 6,442 -> ~4,780, inside Groq's
budget, without dropping one record.

THIS REMOVES NO CAPABILITY, AND THAT IS TESTED

Only what the model SEES narrows. The accepted-name set stays the whole registry
and every handler stays reachable, so a model that names an unadvertised tool
still runs it. A test advertises exactly one tool, has the model call a
different one, and asserts it executes.

Three more properties pinned: the tools for every planned source are always
advertised; the core four are always present (the pulse and project list answer
"what else", the knowledge index answers "why did we decide that", and
propose_action is the only lever Loki has on the world); and a question nobody
could route advertises EVERYTHING, because it might need anything.

MEASURED FIRST, ON PRODUCTION

Baseline across five real questions before changing anything: every answer
grounded ok, both objective checks passed (named "Heidi" for the latest
feedback, "34" for the project count) — and ZERO turns called a tool. The seed
answered all five. So this reclaims tokens from capability that no measured turn
was spending.

The same five re-run after deploy is what decides whether this stays.

164/164 unit test files; 38 planner checks (up from 33), 17 loop checks (15).


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 06:13:21 -07:00
CatoandClaude Opus 5 c9c65360c1 fix(ai): the capacity page was describing a subsystem as if it were the system (#684)
George's reaction to the page as shipped: "this looks bad and is not actionable
and the numbers look like bullshit". All three were fair, and the third was the
tell — the numbers looked wrong because the page was describing one of three
answer paths while presenting itself as the whole picture.

Three false claims, from the journal rather than from reading the code:

1. "groq — configured, but it has not served an answer yet. Will be measured on
   the next answer it serves."
   Both halves false. Groq HAD served (through callGroqText, a path with no
   meter on it), and it is being SKIPPED on every turn:

     skipped groq/openai/gpt-oss-120b (prompt ~10153 > 5400)
     skipped groq/openai/gpt-oss-20b  (prompt ~8312  > 5400)

   Four skips in six hours. It will never be measured, and the operator was
   told to wait for that. The actionable truth — prompts exceed the window, so
   this vendor is never reached, which is WHY the next one burns out — had
   nowhere to live, because a row could carry a number but not a reason.

2. "Every measured provider is spent." One of two had been measured. True, and
   it reads as evasion, because it quietly redefines "every" to mean "the one".

3. The gateway served most of today's answers and was not on the page at all.
   So the page could report everything spent while Loki plainly worked. The
   omission, not the arithmetic, is what made it read as untrue.

WHAT CHANGES

- A fourth state, `skipped`, distinct from `exhausted` — opposite problem,
  opposite fix. Its consequence names the fix ("shorten the prompt or raise its
  budget") because waiting changes nothing, and it is URGENT: a provider walked
  past on every turn is capacity held and never spent.
- `provider_quota.note` (0069) carries the reason. `source: "preflight"` marks
  a skip; `remaining` is 0 there only to satisfy a non-null column, so the
  presenter keys on source and never reads that 0 as empty.
- Counts are always out of the TOTAL: "1 spent, back in 4 hours · 1 never
  reached · (of 2 configured)".
- Rows are ordered by CHAIN POSITION, not recency. Recency put the last link
  above the link that precedes it, directly under the words "this is the last
  link".
- The gateway is listed as an unmetered path, because it answers.

19 presenter checks (up from 15), 164/164 unit test files.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 05:24:46 -07:00
CatoandClaude Opus 5 f637036f17 feat(feedback): say WHY the agent is quiet, not just that it is (#679)
* feat(feedback): say WHY the agent is quiet, not just that it is

George dispatched a fix at 15:45:29. The first output arrived at 15:58:43 —
thirteen minutes later, and only because he opened a terminal by hand and
found the agent sitting at a Claude sign-in. The row said "the agent never
reported any output". True, useless, and the reason was ten seconds away.

Silence has two meanings and the operator can only act on one. "Thinking" is
nobody's problem; "waiting for a human" is theirs, right now. The runner could
already tell them apart — detectAuthFailure reads the transcript for a 401 or a
/login notice — but it only ever asked ONCE, inside an 8-second window at
inject time. That run passed the check and then went quiet, and nothing looked
again.

The heartbeat is the thing that watches the terminal for the whole run, so it
is where the question belongs. After 90 seconds of no output the runner asks,
and the answer rides the next beat; the route stamps payload.blocked and emits
one `blocked` event per stretch; the row reads "Needs you to sign in" with
Watch opening the terminal where you answer it. 90 s is chosen so the reason is
ready BEFORE the ten-minute mark forces the row to say something.

One subtlety worth the test that pins it: a blocked agent prints nothing, so
the "no output, no beat" rule would have suppressed exactly the beat carrying
the reason. Silence WITH a reason is now the message — still one beat per
window.

detectAuthFailure moved to desktop/src/main/agent-auth.ts: the poller starts the
heartbeat, so importing it back would have been a cycle.

163/163 unit files, lint, check:desktop, prettier green.

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

* chore(desktop): 0.8.23 — the runner says why a quiet agent is quiet

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

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 10:53:41 -07:00
Cato 69b5926ff4 chore(register): delete the six experiment sites, and gate what let them linger (#678)
* chore(register): delete the six experiment sites, and gate what let them linger

Six sites from dogfood and site-factory runs on 10-11 September were still
live today, five with GitHub repositories behind them. Two of them read as
real Zurich businesses that do not exist — "Velokiosk — Bike Repair at
Zürich HB" and "Kaffeeklappe – Kaffee to go in Zürich Wiedikon" — on the
founder's own domain. Nobody decided to keep them. They were never removed
once the thing they proved was proved.

All six are gone from the box (service, vhost, /opt, checkout, port, row,
workflows, and this box's deploy key revoked from each repo first), and the
five repositories are deleted. This removes their rows here, which had
drifted from the box copy.

The gate is the point. check-no-experiment-litter.sh fails the build when a
generated throwaway name reaches the committed register — a dated suffix
(-sep11-0040) or a throwaway prefix (dogfood-, factory-, probe-, e2e-). No
grace period: spinning one up for an hour leaves no trace here, so
committing its row IS the moment a test becomes permanent.

It matches names, not kinds. A first version judged kind=demo and flagged
sbb-fundbuero and camille-boulangerie, which are real work that happens to
sit at demo status — exactly the false positive that gets a gate widened
until it catches nothing. No product is ever called factory-sep11-0040.

* docs(retire): delete the project first, or the box puts the site back

Deleting the six sites in the obvious order looked like it worked — units
stopped, vhosts gone, directories removed. Two minutes later:

  [box-prepare] cloning velokiosk-sep10 <- github.com/bitbaum/velokiosk-sep10

and three of the six checkouts were back. A FleetCrown project row that
still names a dirPath is a standing instruction to restore the site, and
it is invisible from the box, so the box cannot know the site was retired
on purpose. The order is now part of the documented cleanup.
2026-09-12 10:39:22 -07:00
27b7e403f8 feat(ai): what is left at each vendor, and what happens when it runs out (#677)
FleetCrown enforced a daily AI budget with no interface at all: a user was
refused and never learned why, or what their share had been. And nothing
anywhere knew how much was left at the VENDORS — the constraint that actually
decides whether the next answer happens.

Settings → AI now shows it, and the numbers come from the answers we already
paid for rather than from asking.

WHY OBSERVED AND NOT POLLED

The obvious design is a cron that asks each provider how much quota remains.
That design reports a FULL TANK DURING AN OUTAGE. Measured on one live key,
within the same second:

  GET  /api/v1/key        ->  limit_remaining: null,  usage_daily: 0
  POST /chat/completions  ->  429, x-ratelimit-remaining: 0 of 50,
                              "Rate limit exceeded: free-models-per-day"

Both are OpenRouter's answers about the same account, and the account was
locked out. Its usage endpoint tracks money, free models cost nothing, and the
limit that binds is a request count that endpoint never reports.

So the recorder hangs off the existing model call and reads the rate-limit
headers off every response, success and refusal alike. No extra request, and no
quota spent to discover how much quota is left.

A NUMBER WITHOUT AN ACTION IS DECORATION

No row shows a bare percentage. Each says what is left in ANSWERS, when it
returns, and which provider takes over — because "78%" tells you nothing you
can do and "about 40 answers, then it moves to OpenRouter" tells you whether to
care. Tokens are translated because nobody has an intuition for a token.

THREE STATES, NEVER TWO

known · unknown · exhausted. A vendor nobody has called today has no reading,
and it is drawn as UNKNOWN with the reason stated — listing only what has been
measured would let the page read as the whole fleet while omitting the provider
about to serve the next turn. A per-minute counter read six minutes ago also
reverts to unknown rather than reporting a number that expired.

DETAILS THAT ARE LOAD-BEARING

- `key_owner` is a non-null text column, not a nullable user_id. Postgres treats
  NULLs as DISTINCT in a unique index, so a nullable owner would let the
  platform accumulate one duplicate row per observation while the upsert never
  found its target — a rollup silently becoming an append-only log.
- The recorder is never awaited, cannot throw, and imports the db lazily. A
  telemetry write must not add latency to an answer someone is waiting for, nor
  fail it and demote a working vendor off the chain.
- A unique INDEX rather than a CONSTRAINT so the migration can carry
  IF NOT EXISTS, which the box's forward-only applier requires.
- 0067 is hand-written: drizzle-kit generate stops on an interactive prompt in
  this schema, and apply-schema.sh globs numbered .sql rather than reading the
  journal — as 0065 and 0066 already did.

FIVE DEFECTS CAUGHT ON THE WAY IN

Two by reading it back: a stale-write guard that was a tautology
(eq(observedAt, observedAt) is always true), and an unreachable sub-minute
branch (40 seconds rounds UP to 1). Three by the gates: prettier on the
workspace file, react-hooks on a synchronous setState in an effect (which also
exposed a real unmount race), and the dead-exports ratchet on a single-counter
read written for a router that does not exist yet — deleted rather than
baselined.

163/163 unit test files; 15 new checks on the presenter, which is pure.

Co-authored-by: Cato <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 10:37:38 -07:00
Cato ac8c25597c fix(teardown): stop offering a repo deletion no token can perform (#670)
* fix(teardown): stop offering a repo deletion no token can perform

Deleting a project with ?deprovision=delete-repo returned

    502 {"error":"GitHub delete failed (403)",
         "detail":"Must have admin rights to Repository."}

found by running the whole create-and-reverse path against production.
The cause is not a permissions mistake: GitHub requires the delete_repo
scope, and neither credential this product holds asks for it — the org
token has gist/read:org/repo/workflow, the user OAuth grant has
read:user/user:email/repo/workflow. So no FleetCrown token can ever
delete a repository, and the button offering it could only ever fail.

That is the right security posture, so keep it and make the product
honest about it instead:

- the teardown UI drops the delete option and links to the repository's
  own Settings page on GitHub, where the owner has rights we never borrow
- a delete attempted through the API reads GitHub's x-oauth-scopes header
  (sent on every response, errors included), and when delete_repo is
  genuinely absent says so, lists what the token does have, and gives the
  URL — rather than echoing a 403 nobody can act on. A token that DOES
  hold the scope and still gets 403 keeps the real message.
- retire-site.sh --repo delete refuses up front, before the service,
  vhost and files are gone, instead of failing at the last step

Verified against production: repo creation 200, archive 200, publish to
OrangeCat then take it down (public page 200 -> 404), project delete 200.
scripts/test/repo-delete-capability.ts pins both halves of the contract
and fails if either comes back.

* fix(retire): warn while it is a plan, refuse only when told to go

CI runs a GitHub token without delete_repo, so the new preflight aborted
the DRY RUN and took the whole retire-site suite with it. A plan that
cannot run is still worth reading: it now says the scope is missing, and
only --go refuses outright, before anything is torn down.

The test stubs both answers from gh rather than inheriting whichever
token the machine happens to hold — CI has no delete_repo, a laptop may.
2026-09-12 03:30:46 -07:00
CatoandClaude Opus 5 3a8f152cf4 fix(feedback): the auto-merge safety guard was decoration — an audit, and what it found (#669)
* fix(feedback): the safety guard was decoration, and four siblings of it

A first-principles audit of the loop, written as if the auto-merge had already
gone wrong. Five defects, none of them stylistic.

1. THE OWNERSHIP GUARD DID NOT EXIST. decideAutoShip takes fromOurDispatch and
   refuses when it is false; the single call site passed a hardcoded true. The
   pull request is resolved from PROSE the agent wrote, so a handoff that merely
   mentions a number ("same approach as PR #42") would have handed #42 to the
   merge call — and #42 can be a person's unrelated work. It is now established
   from GitHub's created_at: a run row exists before any agent touches the repo,
   so its pull request is always newer than the run. One minute of slack for
   clock skew; anything older belongs to a previous attempt or to someone else.

2. THE CACHE FOUGHT THE THING THAT FILLS IT. The refresher resolved the pull
   request preferring the reaper's evidence; the cache-validity check read only
   the handoff. A run whose evidence and handoff named different pull requests
   could never satisfy the check, so every inbox request re-fetched GitHub for
   that row, forever. resolveFixPrRef is now the one answer both ask for.

3. A PAUSE NOBODY COULD LIFT. One failed deploy pauses a project's automatic
   shipping. The scan counted resolved and archived rows, and a deploy_failed
   ledger is terminal — so the pause never ended and nothing in the product
   could end it. Only open rows count now: resolving IS the operator saying
   they handled it.

4. STARVATION DRESSED AS A RATE LIMIT. The inbox refreshes at most 8 ledgers
   per request and took them in list order — newest first. Everything past the
   eighth was never looked at again. Oldest-first makes the cap a rate limit;
   the count is logged rather than silently dropped.

5. THE SAME ROW BEHAVED DIFFERENTLY IN TWO PLACES. runnable was only on the
   cross-project inbox, so the project page offered Implement on a project with
   nowhere to work and answered with a 422 toast instead of "Connect a
   repository". Both lists carry it now.

And the gap the audit was really for: NOBODY WAS TOLD WHEN A FIX WENT LIVE, OR
WHEN A MERGED FIX FAILED TO DEPLOY. The loop announced a visitor filing and an
agent's run closing — and a run closes at a pull request, which is the exact
claim the ledger exists to stop making. That was survivable while a human
pressed merge. It is not survivable now that FleetCrown merges and deploys onto
a live site unattended: a failed deploy after an automatic merge is the worst
state this system can produce, and it was silent. notify-shipped.ts announces
both, on a ledger TRANSITION so each fix speaks once, naming whether FleetCrown
merged it.

Every rule that used to live in a loop is now a pure exported function with
tests — projectsPausedByBrokenDeploy, prOpenedByRun, fixCheckedAtMs,
resolveFixPrRef, shipAnnouncementFor — because today's lesson was that testing
the rule while the wiring goes untested is how a feature ships inert.

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

* docs(telegram): register the fix-shipped notifier

Every path that can reach the operator's phone owes a row saying what arrives,
when, and from where. The gate is right to refuse without it.

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

* fix(feedback): meet the alert gate where it looks, and stop two labels overstating

CI caught what I had not run: scripts/test/alert-registry.ts reads the alert
types a file raises by scanning it, and FAILS on a file it cannot read rather
than skipping one. A ternary at the call site made this file unreadable to it.
That is the right kind of gate — it refuses to pass vacuously — so the types
are literal `type:` fields now, and the branch reads better anyway because the
severity differs with the type.

Two labels also claimed more than they measured, the same class this whole
audit is about:

  "Report → fix" is stamped when the operator presses Confirm, so the number is
  dominated by how long they took to look, not by how fast the loop shipped. It
  says "Report → confirmed" now.

  FeedbackInbox's own docstring still described "Needs you / In progress /
  Shipped" grouped by DB status — the arrangement replaced precisely because
  status cannot answer the page's one question.

160/160 unit files, lint, prettier, tsc, design and both registry gates green.

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

* test(feedback): pin the ownership guard to the real merge and the real mistake

The best pin available for prOpenedByRun is production. On
dogfood-site-sep10-1201, run 1ff0be72 started 16:13:25 and its pull request #3
was opened at 16:15:37 — two minutes in, and it merged for real. The pull
request the parser wrongly named, #1, was opened at 10:21:48, six hours
earlier.

So the guard admits the merge that legitimately happened and rejects the exact
pull request that yesterday's bug resolved. It is a second, independent line of
defence against that failure: prose said #1, but #1 predates the run.

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

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 03:00:37 -07:00
CatoandClaude Opus 5 e5f8e8ea49 fix(loki): let it think, and fetch the thing you asked about (#668)
Asked "what do you think about heidi", Loki answered:

    ...`.

    Everything is clean and strictly compliant.
    </think>An opinion or assessment is: Not in your data.

…and then listed every record containing "Heidi", including two unrelated
people who happen to be named Heidi. Four defects, stacked.

## 1. A model's private reasoning was persisted as the answer

There is a literal `</think>` in the database. This repo already knew the
trick — TWICE, in `frontier/propose.ts` and `orchestration/dod-gate.ts` — and
both copies exist to make JSON parse. The one path a HUMAN reads had none.

`stripReasoning` now lives once, at the model seam next to
`stripToolCallLines`, and is applied at all four seams (tool loop, groq
buffered, groq streamed, gateway). The two old copies call it.

`lastIndexOf` rather than a regex is load-bearing: the leak had a CLOSING tag
and no opening one, because the head of the reasoning was lost upstream. A
`<think>[\s\S]*?</think>` pattern matches nothing there.

While streaming, nothing can know text is reasoning until the tag arrives — so
the gate now RETRACTS what it showed the moment the tag proves what it was.

## 2. It was forbidden to have a view

`buildContract` says every claim must cite a record (1) and anything without
one gets exactly "Not in your data." (3). An opinion is not a record, so the
model looked one up, failed, and refused. It was obeying the contract exactly.

ai-kit's OTHER builder, `buildAssistantRules`, already carries the equivalent
carve-out as its rule 5 ("general knowledge … is not covered by rules 1–2").
The typed-record builder never grew one — so the WEAKER contract is the usable
one and the stronger contract forbids reasoning.

Rules 7–10 are added as a NARROWING, inserted INSIDE the contract section:
the contract opens with "this overrides every formatting instruction below",
so a narrowing placed after the records would be outranked by the rule it
narrows. Both grounded paths share one assembly point, because the production
refusal came through the gateway while the loop carried the same defect.

The durable fix belongs upstream in `buildContract`; noted in the module.

## 3. Retrieval fetched the wrong subject

This was the one that made the answer useless, and it survived the prompt fix.

`peopleFacts(userId, message)` searches by the message. `documentFacts(userId,
message, limit)` searches by the message. `projectFacts(userId)` ignored it:
projects came back in table order and were then head-sliced. With ~30
registered projects that is a lottery, and the `Heidi` PROJECT lost it — while
the people search matched two contacts by name. Retrieval chose the subject of
the answer, and chose wrong. No prompt rule can recover a record that was
never fetched.

Projects the message NAMES are now ranked ahead of the slice. Pure, in its own
module because `sources.ts` imports `@/db`, which throws at load without a
connection string — and this repo's unit suite is env-independent.

## 4. A citation the verifier could not see

Found only by running it: nemotron cited `【F16】` in fullwidth brackets. Both
readers are ASCII-only, so the verifier's unknown-citation check silently had
nothing to check, and the renderer printed the handle verbatim as plumbing.
Normalised at the seam, before verification.

## Verified

Against REAL production records through the read-only tunnel, same question:

    Heidi is an active project — status active [F16]. Its recorded description
    is "Learn to understand and text in Zurich Swiss German.
    heidi.orangecat.ch" [F16]. The latest development log notes the creation of
    a /check page … and a PR #4 that has not yet been merged [F16].

No reasoning tags, no refusal, ASCII citations, 0 grounding violations.

Three new pure suites, each proven by MUTATION: removing the judgment clause
fails 7/10 checks; a no-op `stripReasoning` fails 3. The prose-gate test
replays the exact production bytes.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 02:28:36 -07:00
CatoandClaude Opus 5 4e29a12578 feat(loki): the chat shows its work — streaming, a stop button, one rail (#665)
Loki did more work than any other surface in the app and showed the least
of it. A turn is up to three model rounds with real retrieval in between —
it searches your people, reads your projects, queries the knowledge graph —
and all of it happened behind one static "Loki is thinking" line for as long
as it took. `runLokiTurn` has always returned `toolsUsed`, carrying the
comment "surfaced so the UI can show work". Nothing ever surfaced it.

## The turn streams, for real

Not a typewriter over a finished string. `agent/llm.ts` gained a genuine
`stream: true` path against the providers' OpenAI-compatible endpoint, with
`stream_options.include_usage` so a streamed turn is still BILLED — without
it the final chunk carries no usage and the day's ration would drain for
free on exactly the turns someone is watching.

Two rules keep the preview honest:

  - **Prose is released a whole line at a time.** A weak model narrates its
    tool calls as `TOOL:` / `ARGS:` lines, and the buffered path strips them
    before anyone sees them. A chunk ending in `TOO` could still become
    `TOOL:`, so nothing is shown until a newline proves the line finished.
    Extracted as `createProseGate` and covered by `test:loki-prose-gate`,
    including that it agrees with `stripToolCallLines` on the same text.
  - **`delta` is a preview; `message` is the record.** The loop REPLACES its
    answer every round (`text = turn.text`), and the grounding repair pass can
    delete unsupported claims from a finished one. So round boundaries and
    dead links emit `reset`, and the persisted turn replaces the preview when
    it lands. Appending instead would leave a fabrication on screen that the
    database does not contain.

The fallback path streams too. It is tempting to treat it as degraded and
therefore allowed to be silent — but it runs precisely when the free tiers
are drained and the tool loop cannot start, which is to say on the slowest
days. Leaving it unstreamed meant no visible streaming exactly when progress
most needed showing. One shared SSE frame reader, not two.

## What else changed

  - **A stop button.** There was none: a running turn could not be cancelled.
    It takes the same slot as send, and the abort reaches the provider call.
  - **The work trail** — each tool as it runs, with the records it actually
    returned. A failed tool reads as "unavailable", never as "nothing found".
  - **One rail instead of four navigations.** The global sidebar, a
    Chat/Control/Terminal strip, a pinned history rail AND a "Chats / New"
    toolbar all led to the same two actions. The rail owns them now.
  - **A model picker** that says what it does: a choice sets where the CHAIN
    starts, and the fallback below it survives — a hard pin on a free tier is
    a scheduled outage. Vendors without a key are listed, disabled, with the
    reason; never hidden, never fake-enabled.
  - Copy and try-again on an answer. Autoscroll that follows only while you
    are at the bottom, plus a way back down.

## Bugs found on the way

  - `bg-accent-primary` + `text-white` is invisible in dark mode, where
    `--accent-primary` is near-WHITE. The send arrow did not exist on a dark
    screen. Same bug in `.ui-assist-send`; both now `text-text-inverted`.
  - The composer was keyed on `activeId`, so creating the thread REMOUNTED it
    mid-send — silently resetting the model choice and dropping staged files.
  - That same transition looked like a thread SWITCH, so the transcript
    cleared, showed "Loading conversation" over the streaming turn, and
    refetched a thread the server had not finished writing. The question
    vanished and the answer arrived alone.
  - `.ui-loki-thread` was missing `flex flex-col`, making its `mt-auto` inert:
    a short conversation pinned to the top with dead space above the composer.
  - The rail's project filter could hide the thread you were reading, because
    scope follows the answer. A filter may narrow what else is offered; it may
    not hide where you are.

## Refactor

Three components deleted. The composer finally uses `useAttachments` — the
hook that was extracted FROM it and adopted by the Control and Terminal
composers, leaving the one surface it came from as the only one with a
private copy. Dispatch/approval/project-picker footers moved out verbatim,
because rewriting honest-status logic to move it is how the regressions its
comments warn about get reintroduced.

`check-loki-classes.mjs` (wired into `check:design`) asserts every
`ui-loki-*` class is both defined and used. A renamed class is invisible to
tsc, eslint and the build — it still renders, as unstyled markup. It found
six orphaned rules on its first run, and fails under mutation.

Verified live: page renders at 1440/390/320 with no horizontal overflow, a
real turn streams against real models and the local DB, and the stop button
cancels one.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 13:57:30 -07:00
CatoandClaude Opus 5 35a75292c6 fix(feedback): a cached ledger about the wrong PR is not a cache, it is a wrong answer (#663)
The parser fix in #660 could not reach a single row it had already poisoned.
A wrong resolution had landed those rows in PR_CLOSED — a terminal state —
and terminal meant never ask GitHub again. So the row kept saying "nothing
shipped" while the real pull request sat open and mergeable, and the only way
out was deleting payload.fix by hand on the box, which I did to prove the
merge path works at all.

The cache outlived its input. Re-parsing a handoff is pure and free; the
GitHub call is what costs. So the parse now runs on every request and a
cached answer about a DIFFERENT pull request is invalid whatever its state,
while terminality and the refresh window still ration the network.

fixNeedsRefresh takes an options object now. It already had a trailing
`now`, and slipping expectedPrUrl in front of it would let every existing
caller pass a timestamp where a URL is read — truthy, unequal to any URL,
refresh forced every time. That is the same silent-wrong-argument shape as
the bug being fixed, so the signature refuses it.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 13:36:53 -07:00
CatoandClaude Opus 5 d5c83e66b5 fix(ci): a merge on main stopped having a path to the box (#662)
Four merges reached main on 2026-09-11 and never left the repository.
Every check was green, no job was red, nothing anywhere was marked failed.
Each one needed a Deploy dispatched by hand, and the only way to notice was
to compare the box's build stamp against main's tip.

Two paths ship a commit, and exactly one fires per commit by design: a push
to main chains through workflow_run, and a dispatch runs ci.yml's own ship
job. Under a concurrency group keyed only by branch, auto-merge's re-armed
dispatch cancels the push run for the same commit — which is intended, and
the comment on the ship job says so.

What was never intended is the NEXT merge cancelling the surviving run of
the previous one. That kills both paths at once. For the stranded commit,
gh run list showed a cancelled push run AND a cancelled dispatch run, with
a clean success five minutes later belonging to a different commit.

So main is now keyed per commit. Same-commit cancellation is preserved, so
a commit still ships exactly once; cross-commit cancellation is gone, so it
ships at all. Branch behaviour is unchanged.

The gate that comes with it states the property narrowly — on main, one
commit's CI must never cancel another's — and also pins the five premises
that make it matter, because if the chain is ever rewired the gate must
fail loudly rather than guard a ghost.

Both were proved by mutation on a copy, six mutations, each asserted to
have actually applied. That assertion earned its keep immediately: the
first draft of this gate checked for `workflow_dispatch` with a plain
substring, which matched a comment and an `if:` elsewhere in the file, so
removing the actual trigger left it green. A mutation that silently no-ops
makes a gate look proven when nothing was tested.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 12:58:34 -07:00
CatoandClaude Opus 5 6310c3d330 fix(feedback): two ledger-accuracy defects the live row exposed (#660)
* fix(feedback): unknown mergeability is not a conflict

The live row said "GitHub cannot merge this pull request — it is a draft or
has conflicts" in a case where GitHub had simply not finished computing
mergeability. It answers null on a cold read, and the code folded null in with
false.

Unknown stays a hold — it is never permission — but it is now its OWN hold,
with its own sentence: GitHub has not finished checking, and it retries on its
own. Asserting a cause nobody verified is the same defect as the old "Check
live", scaled down to one sentence, and the test now refuses any wording for
this state that mentions drafts or conflicts.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

* fix(feedback): resolve the pull request the agent OPENED, not the first one it mentions

Caught on the live row. A retry's handoff reads: "...after prior PR #1
diverged and conflicted (closed #1, opened #3, test check green)". The parser
took the first match, so the row reported PR #1 as closed and said nothing
shipped — while PR #3 sat open and mergeable. With automatic shipping on it
would have been evaluating the wrong pull request entirely.

Now every reference in the handoff is collected, and the one the sentence
marks as OPENED wins; with no such cue the highest number wins, because a
later pull request supersedes an earlier one. A bare #number still resolves to
nothing: in prose that is far more often an issue, and naming the wrong thing
is worse than naming none.

Pinned with the real handoff text, not a paraphrase.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 12:53:51 -07:00
CatoandClaude Opus 5 f847ba8fb5 feat(retire): a site can be taken off the internet, password-protected, or removed (#657)
Creating a site makes about forty things. Deleting the project undid two of
them, plus the repository if you asked. Everything else survived — and the
part that survived is the part that is public.

After "Delete project" on a kicked-off project you still had: the live site at
<slug>.orangecat.ch, its Caddy vhost and TLS certificate, an enabled systemd
unit, /opt/<slug> with its secrets, the checkout, an apps.conf row holding a
port that could never be reclaimed, a monitoring target that keeps paging about
a site you deleted, the box's SSH deploy key sitting in the repository, and the
project's milestones orphaned onto /goals. The only way off the internet was a
human with SSH.

FOUR LEVELS, because "undo it" means four different things:

  offline   stops serving at once; code, files and port kept. Reversible.
  private   keeps working behind a password; repository made private.
  restore   undoes either of the above.
  delete    unit, vhost, /opt, checkout, apps.conf row (freeing the port),
            monitoring target and the leftover deploy key. The repository is
            ARCHIVED, never deleted, unless explicitly asked — that is the one
            step nobody can undo, so it is never a default.

NOTHING HAPPENS WITHOUT A SECOND ASK. The default prints exactly what it would
touch and performs no action, and that preview is produced by the same script
that does the work — a plan written separately is a description that drifts.
The route runs the plan through the runner and returns it inline, so the
confirmation is the real thing rather than a promise about it.

Refusals are refusals: thirteen infrastructure slugs (fleetcrown, orangecat,
the bridge…) cannot be retired at all, and a LIVE client engagement needs an
explicit second hand — money terms are not a thing a button decides.

Shape follows new-site.sh, deliberately: a closed set of parameters validated
against a fixed grammar, handed to the script as an ARGUMENT VECTOR via
execFile, armed by the same FLEETCROWN_SITE_FACTORY switch that arms creation.
A runner allowed to bring public hosts into being is the one allowed to take
them away, and no other.

Also fixed, found by the same inventory:
- GitHub visibility could only be set at creation. setGithubRepoVisibility
  makes a repository private (or public) afterwards — new-site.sh creates
  public repos, so "make this not public" had no answer for the code.
- Deleting a project now deletes the milestones the kickoff wrote FOR it,
  instead of leaving them unowned on /goals (ON DELETE SET NULL).
- "Danger zone" says what it does NOT do, and points at the site controls.

Verified: pnpm run verify green. 32 assertions on the script (a dry run never
edits the register; every artifact named in a delete plan; infrastructure
refused; no backticks), 41 on the validator (a plan never carries --go; no mode
defaults to deleting a repository).

DEPLOYMENT: set FLEETCROWN_RETIRE_SITE_SCRIPT in /opt/fleetcrown/runner/.env to
the retire-site.sh in the factory checkout, beside the FLEETCROWN_NEW_SITE_SCRIPT
already there, and update that checkout. Until then the command is rejected with
that exact reason rather than silently doing nothing.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 08:46:08 -07:00
CatoandClaude Opus 5 8cd138bd1a feat(feedback): ship fixes automatically, per project, opt in (#656)
An agent's job ends at a pull request, so until somebody merges it the
visitor's report is not fixed. This adds the switch that decides who presses
merge — per project, off by default, in the Feedback section beside the
widget's Pause.

NOT an auto-merge.yml in the customer's repo. That would be a commit in
someone else's repository, would need back-filling into repos FleetCrown
never provisioned (annushka's was made by hand), would need another commit to
turn off, and — the real objection — it merges ANY green pull request,
including one a person opened for something unrelated. FleetCrown already
watches the exact PR its own dispatch produced (the fix ledger), so it merges
that one and nothing else: the setting applies to PRs already open, and
leaves no trace in the repo when it goes back off.

auto_ship is nullable on purpose. NULL = never chosen, and the project shows
an invitation rather than a switch sitting in the off position looking like
somebody's decision. FALSE = chosen off; stop offering. Off is the effective
default either way, which is what keeps client sites safe: FleetCrown cannot
tell a client site from its own — that ledger lives in apps.conf on the box,
not in this database.

Conditions, pure and pinned in scripts/test/feedback-auto-ship.ts:
  - only a PR from FleetCrown's own dispatch;
  - never on an "unverified" ledger — that is the agent's claim, and it is
    the exact shape the org-restriction 403 produces;
  - not a draft, and GitHub must say mergeable (null means it is still
    computing, which is not permission);
  - every check passed, and NO CHECKS AT ALL IS A HOLD. The dogfood site's
    first agent PR had zero checks; absence of red is not evidence of green;
  - one failed deploy pauses the project, so a broken fix cannot have the
    next one land on top of it.

When it holds, the row says what it is waiting for — an operator who turned
the switch on should never have to wonder whether the feature works.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 08:35:34 -07:00
CatoandClaude Opus 5 c68b28377b fix(fleet): stop rendering links the register never checked (#655)
Measured on the live page: of 37 outbound links, three were dead.

Two were OrangeCat project pages. user_projects.orangecat_project_id
records a link made once; OrangeCat is a separate product with its own
deletions, so the id outlives the thing it points at. The chip said
OrangeCat, the reader clicked, and got a 404.

The third was every Solon chip. It pointed at /orgs/<slug> — a route
Solon does not have and never had. The register knows the organisation
exists because it asks GET /api/orgs/<slug>, and I turned that into a
page URL that was never real. Until Solon publishes a page to send
someone to, the fact is stated and not linked.

So OrangeCat ids are now probed before they are rendered, cached ten
minutes, the same shape as the Solon check next to it. The rule the new
tests pin is the one that is easy to get wrong: a 404 is an answer and
the link goes, but a timeout or a 502 is NOT an answer and must leave
the link alone. Reading an unreachable host as deletion would quietly
drop true facts from the page every time OrangeCat had a bad minute.

Not fixed here, and worth saying: a 200 is not a useful page. Nine of
the site links lead to day-zero scaffolds of 6-17KB — real HTTP, nothing
to read. The register already records that as status=prospect; the page
should set the reader's expectation from it rather than presenting a
placeholder as a product. That belongs with the redesign.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 08:19:45 -07:00
f0c1654c3e fix(loki): two defects the first live turn found (#654)
Shipped in #647, then asked the original failing question against production.
Loki answered it correctly — project, quoted report, exact time and relative
age, status, 44 facts, verification clean. The one-line turn log added in that
PR then reported two things worth fixing.

1. A CORRECT ANSWER WAS SENT TO A NEEDLESS REPAIR PASS.

     [loki] ungrounded claims, repairing: unknown-citation:[D5] (x5)

   The computed briefs render into the context as [D1]…[Dn] and the model duly
   cites them, but the GATEWAY path never passed those handles to the verifier
   — only the tool loop did. So every directive citation was flagged
   `unknown-citation`, triggering a repair on an answer that was already right.
   A repair is a deletion: it can only make a correct answer worse, and it
   costs a model round trip. Both verify calls on that path now admit them.

2. BACKGROUND CONTEXT CROWDED OUT THE SUBJECT.

     skipped groq/openai/gpt-oss-120b (prompt ~12912 > 5400)
     skipped groq/openai/gpt-oss-20b  (prompt ~12912 > 5400)
     tool loop failed: openrouter 429 daily quota exhausted

   A question about FEEDBACK pulled 38 project facts as background, and they
   were the bulk of a 12912-token prompt. That put the turn past every Groq
   window, so the preflight correctly skipped both Groq links and went to
   OpenRouter, whose free daily quota was spent — and the turn fell to the
   gateway. Right behaviour from every component, wrong prompt.

   Projects now get the whole fleet when they ARE the question (a count must
   never come from a sample) and ten when they are merely background.

   The preflight and the shared seed both did their jobs here: the fallback
   answered correctly because it now gets the same records the primary path
   does. That is the resilience this design was rebuilt for, working.

Both pinned: the plan test asserts projects lead-vs-background limits, citing
the measured numbers. 154/154 unit files, 33 planner checks.


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

Co-authored-by: Cato <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 07:42:24 -07:00
CatoandClaude Opus 5 5d1c1fdb33 fix(orangecat): the site door was behind the session middleware (#653)
* fix(orangecat): the site door was behind the session middleware

The door shipped live, reachable, and unusable. A correctly signed
request got 401 — not from the signature check, from the session
middleware, which answered first.

src/proxy.ts exempts the prefix `api/orangecat/` — the receivers that
verify their own HMAC — and exempts nothing else. I put the new route at
`api/integrations/orangecat/site` because it read as tidier, and that
one word took it outside the exemption.

The failure mode is worse than a 404. The endpoint resolves, the deploy
is green, and a 401 from the middleware is indistinguishable from a 401
for a wrong shared secret — so the obvious next move is to suspect the
credential, which is the one thing that was fine.

Caught by replaying a SIGNED request against production: the body came
back {"error":"Unauthorized"} instead of this route's own
{"error":"invalid signature"}, and the difference between those two
strings is the whole diagnosis. The unsigned probe that returned 401
earlier had "passed" and proved nothing — a guard that can never be
satisfied looks identical from outside to one that works.

So the route moves to /api/orangecat/site, beside entitlement and
events, where the other two self-authenticating OrangeCat receivers
already live. The path IS the auth decision; there was never a reason to
invent a second home for the third one.

Closing the class rather than the instance: the gate now reads the real
matcher out of src/proxy.ts and fails if the door's prefix is not exempt
from it. Proved by mutation — delete `api/orangecat/` from the matcher
and the gate refuses to go green, which is the regression that actually
happened, reproduced deliberately.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nayuDvAPd5BYkSfsVPHHA

* fix(orangecat): gate the exemption the move depends on

The move in the previous commit is only half the fix. Moving a file
changes where the route answers; it does not stop the next receiver
being put somewhere the session middleware answers first. This is the
half that does.

- The gate reads the real matcher out of src/proxy.ts and fails if the
  door's prefix is not exempt from it. Proved by mutation: delete
  `api/orangecat/` from the matcher and the gate refuses to go green,
  which is exactly the regression that reached production.
- The gate's own paths and the route's doc comment follow the file to
  /api/orangecat/site, and the comment now says WHY it lives there —
  the path is the auth decision, not a filing preference.

Why this is a separate commit rather than an amend: the previous one
went out with only the rename staged, because the `git add -A` that
should have preceded it was in a compound command that never ran. The
branch is already pushed with a PR open, so a second commit is cheaper
and safer than a force-push over it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nayuDvAPd5BYkSfsVPHHA

* fix(api-auth): gate that a self-authenticating route is reachable at all

Third occurrence of one bug class, so per the never-twice rule it gets a
derived check rather than another hand-maintained list.

  1. vitareba 2026-08-07 — the `/api` matcher blocked LOGIN itself.
  2. fleetcrown 2026-08-13 — `api/solon/` missing from the matcher; the
     Solon doorbell was unreachable from the day it shipped.
  3. fleetcrown 2026-09-11 — the OrangeCat site door shipped at
     `api/integrations/orangecat/site`, outside every exempt prefix.

There was already a pin for this, in solon-message.ts, and it passed all
three times — occurrence 3 included. It checks that a hardcoded list of
PREFIXES appears in the matcher, and `api/orangecat/` was indeed there.
What nothing checked was the other direction: that every route which
authenticates ITSELF actually LIVES under one of those prefixes. A
receiver put somewhere tidier deploys green and 401s every caller,
signed or not.

So this derives the receivers from the source instead. Any route calling
an HMAC or shared-secret verifier is self-authenticating wherever it
sits, and its path must fall inside the matcher's exemption. 22 such
routes today; the failure message names the route, the marker that
identified it, and the two ways to fix it.

Why a gate rather than vigilance: the middleware's 401 is
indistinguishable from the route's own 401 for a bad secret, so the
first instinct is to suspect the credential — the one thing that was
fine. Only a SIGNED replay tells them apart, and nobody signs a replay
for a route they believe they just shipped correctly.

Proved by mutation with a throwaway fixture at an unexempt path: the
gate names it and fails. The first attempt at that proof moved the real
route instead, mis-restored the directory, and the cleanup deleted a
different pre-existing route (`integrations/orangecat/build`, restored
from git). Never move real files to test a check when a fake one proves
the same thing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nayuDvAPd5BYkSfsVPHHA

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 07:13:24 -07:00
CatoandClaude Opus 5 1784cd121d fix(feedback): stop telling the agent its PR merges itself (#652)
* fix(feedback): stop telling the agent its PR merges itself

The dispatch prompt said: "Sites FleetCrown set up merge a green PR by
themselves (auto-merge.yml), so an opened PR with passing checks counts as
shipped." Site provisioning writes deploy.yml and nothing else
(src/lib/site-cd.ts) — there is no auto-merge.yml. Two green agent PRs sat
open on dogfood-site-sep10-1201 for a day while the feedback row called the
work finished.

The instruction's BEHAVIOUR was right and is unchanged: the agent ends at a
green PR and never merges its own work. Only the false justification is gone.
An open PR is now described as honest progress, because the fix ledger
follows it to merged and deployed and the row asks the operator to merge when
nothing else will.

Pinned: the prompt may not name auto-merge.yml or claim a PR counts as
shipped, and must still forbid self-merging.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

* fix(feedback): the ledger asks GitHub with a token the org will answer

The ledger read "PR #2 · open?" while that pull request had already merged
and deployed. Not a parsing bug: bitbaum has OAuth-app access restrictions,
so the person's own token — correct scope, valid, 4408 requests left — gets
403 "OAuth App access restrictions" on every org repo. The ledger degraded
honestly to the agent's claim, which is the right failure, but it is a
failure that never has to happen: getRepoWriteToken already prefers the
server's GITHUB_ORG_TOKEN and falls back to the person's, and its own
comment names this exact 403 from the day repo creation hit it.

Verified against the live row: the org token answers state=closed,
merged_at=2026-09-11T13:28:06Z, merge sha 30fb40bd.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 07:02:40 -07:00
CatoandClaude Opus 5 223a2f0915 fix(github): the org token is for accounts entitled to fleet infrastructure, not every session (#651)
The org write token added in #634 was handed to any signed-in account. It can
create, seed and DELETE repositories in the bitbaum organisation — a
server-held admin credential reachable by whoever holds a session is a
privilege escalation waiting for the first external user, and FleetCrown is
schema-ready for those today.

It is now offered only to accounts already entitled to fleet-owned
infrastructure — founder or explicit allowlist, the same boundary the shared
cloud builder draws (docs/architecture/multitenancy-execution-plan.md). Anyone
else writes with their own GitHub token exactly as before, and if their org
refuses it they get the honest 403 that names both remedies.

`isFleetInfrastructureAllowed` is separate from `getExecutionAccess` on
purpose: that one also reads runner presence, which a GitHub write has no use
for, and "may this account act as the fleet" deserves one name every caller
asks by rather than each re-deriving `isDefault || allowlist`.

Verified: tsc, eslint, scripts/test/github-org-token.ts (extended to pin that
an unentitled account falls back to its own token, never the org's).


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 06:43:21 -07:00
CatoandClaude Opus 5 83126a7265 feat(fleet): make the register legible to someone who is not its author (#650)
The page listed slugs. A slug tells the person who chose it everything and
everyone else nothing, so a visitor arriving from the Product menu met 38
rows of vocabulary and left. The line that says what a project IS was
already written — user_projects.description, the one a human fills in on
the project page — and the register simply was not carrying it.

Four things a reader could not do, and now can:

- Know what they are looking at. Descriptions ride the join. The site
  factory's own filler — Website at <url> — is treated as absent, because
  restating the column next to it is not a description, and an empty gap
  invites the real sentence where boilerplate does not.
- Link to one project. Every row carries id=slug, so /fleet#causius opens
  on that row and rings it.
- Trust the chips. /projects/<id> redirects a signed-out caller to a login
  wall, so that chip was a promise the page could not keep. Present-but-
  not-yours is now its own state: solid, because the fact is the same; no
  hover, because there is nothing to click.
- Know what the page does not know. Live is what the hosting register
  DECLARES, not a reading taken now — a host that fell over ten minutes
  ago still says live here. Uptime is watched elsewhere and does not feed
  this join. A stated limit beats a status light that lies.

The hero led with how the join is built. A visitor needs what this is
first and the provenance second, so they swapped places.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 06:39:57 -07:00
ebeeb8101d feat(loki): retrieve before answering — Loki could not see the fleet it is named for (#647)
George filed two reports through FleetCrown's own feedback widget, watched
nothing happen, and asked Loki "what was the most recent feedback sent".

  Not in your data.

Both rows were in site_feedback, filed minutes earlier. Four runs spawned from
them sat in `waiting`. Twenty-four runs had errored in three days. The answer
was nevertheless honest: Loki had been handed no records, so the sentence was
true of what it could see — which is worse than an error, because a truthful
negative reads as a checked one.

Three independent causes, each sufficient alone.

1. NO SOURCE READ THE TABLE. `grep -rn feedback src/lib/agent/` returned
   nothing. Nor did runs, agent sessions, alerts, or notes. Loki could see the
   "life" half of the product (people, projects, goals) and nothing of the
   fleet half the product is named after.

2. THE PROMPT BUDGET WAS ARITHMETICALLY IMPOSSIBLE. One module constant —
   Groq's 12000-token minute window x 0.8 / 3 rounds = 3200 — applied to every
   vendor. Groq has since cut the window to 8000, and the prompt's own fixed
   cost measures 2946 tokens (system prompt 1264 + native tool schema 977 +
   catalog), leaving ~254 tokens: one fact. With the operator's message it goes
   negative, the fit correctly returns zero, and production logged
   `[loki] round 1: 40 facts exceed the call budget — sending 0` on every turn
   and sent it anyway with an empty Records block.

3. THE RICHER SEED WAS ON THE FALLBACK PATH ONLY. buildGroundedTurn (approvals,
   knowledge, economy, cues) ran only inside askLokiViaGateway. The primary
   loop seeded people + projects. So the approval queue seeded in #262
   *specifically to survive losing the tool loop* was, on the path that
   normally ran, reachable only by the tool call the loop could not afford.

WHAT CHANGED

Retrieve first, then reason. A pure keyword planner (src/lib/agent/plan.ts)
reads the question and fetches the relevant sources in parallel BEFORE the
model is called; tools become depth, not basic retrieval. A tool loop needs a
healthy model and a fitting prompt before it can ask its first question, which
is exactly what is missing when this class fires. A regex is dumber than a
model and never rate-limited. This is how OrangeCat's Cat has always worked.

Eleven new fact adapters: feedback, runs, live agent sessions, alerts, notes,
plus a computed fleet pulse (runner state, runs waiting/errored, unread
feedback, pending approvals, today's AI budget) and a buildFleetBrief of
SQL-computed answers the model may only phrase. Six new tools over them.

Budgets follow the vendor: linkPromptBudgetTokens() sizes Groq from its minute
window and large-context vendors by usefulness; the prompt is sized against the
largest usable link and the walker SKIPS links it does not fit (a preflight,
not a refused round-trip). Env-tunable without a deploy. When overhead busts
every budget the loop now throws instead of sending an empty Records block.

Conversation history reaches the primary path, so continuity no longer appears
and disappears depending on which brain served the turn.

Provenance is rendered: model, what was read per source, tools used, elapsed
time, and the grounding verdict. The verdict was always computed and always
returned; the route dropped it on persist and the assistant never read it, so a
flagged answer looked exactly like a clean one — the failure the harness exists
to prevent, reintroduced at the last inch.

THE GATE (this is the third time this class has fired)

Every read tool's data must ALSO be reachable from the seed. Seed =
survivability, tool = depth, one adapter called by both.
scripts/test/loki-retrieval-plan.ts fails the build on a read tool with no seed
source, and on a seed source no question can reach. It caught a real orphan on
its first run: the OrangeCat economy feed, fetchable but unreachable.

Also fixed while here: propose_action reported a failed DB write as a
successfully queued draft; the repair pass accepted a repair that invented a
NEW unsupported claim if it had fewer total; assignee matching used a bare
substring (the dr-UZH-nikov pattern on the write side); pageContext over 2000
chars 400'd the whole request instead of being clamped; the native tool schema
repeated each full description, paying for the same prose twice.

Docs: docs/architecture/loki-answering.md.
Tests: 4 files, 63 checks, all env-independent.


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

Co-authored-by: Cato <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 06:31:48 -07:00
CatoandClaude Opus 5 10b6669f40 fix(feedback): the badge is a status, not a sentence (#648)
Two copy rules the row was breaking, now pinned by tests.

"Live (partial) · confirm" is three ideas in a chip, and "partial" is the
agent's word about its own session — it belongs in the line that tells a
person to look harder, not in the status they read at a glance.

And the deployed row printed "Merged and deployed. Open the live page,
confirm the visitor's point is fixed, then Confirm — or Not fixed to send it
back." directly above two buttons labelled Check live and Confirm. On four
deployed rows that is the same 18 words four times. A detail line has to
carry what the badge and buttons cannot; this one carried nothing.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 06:27:30 -07:00
CatoandClaude Opus 5 806cb885e5 feat(orangecat): open the site factory's front door (#646)
The site factory has been live on the box for weeks — it creates a repo,
a subdomain, a certificate and a deploy in about 35 seconds — and had no
HTTP entry point. Its only callers were a CLI and a test, so "OrangeCat
asks FleetCrown to build something" could not happen at all.
provision.ts anticipated this exact caller in its own header comment.

This is that door and deliberately nothing more. Every decision it could
have re-made already lives in requestNewSite: what a valid slug is,
which labels are reserved, whether a live client site may be created
from a queue. A second caller that assembles its own payload is how one
path grows a check the other lacks, so the route reaches the queue only
through the SSOT — and the gate fails if it ever stops doing so.

HMAC, not a bearer token. The ck_* agent rail would have been less code
and wrong: those tokens carry a PERSON's full operator authority, so
OrangeCat holding one would mean every site built for any user was
created by George, in George's account, with a credential that also
reaches the terminal-injection endpoints. The x-orangecat-signature rail
both products already run says the right thing instead — this is
OrangeCat, the service, acting for the named actor in the body.

Three narrowings, because this endpoint mints externally-visible,
rate-limited, un-unspendable resources on another service's say-so:

- A remote caller gets three of the register's six kinds. `client-app`
  and `infra` are claims about a customer relationship that a scaffold
  does not establish.
- Status is FORCED to `unverified`, never read from the body. The
  register's status column is a human claim about whether a site is
  real, wanted and correct; a machine that just ran a scaffold has
  established none of those.
- Three sites per account per day, counting REQUESTS rather than
  successes — ten requests that all fail validation have still done ten
  rounds of work against a repo host and a certificate authority.

An actor with no linked FleetCrown user is refused with a 409 naming the
next step, not quietly attributed to the studio's own account, which
would turn this into an unmetered domain-minting primitive reachable
from a public button.

The gate is proved by mutation, not by being green: forcing status=live,
adding a caller-supplied status, widening to every register kind,
bypassing requestNewSite, and failing open on a missing secret are all
caught. Runs with no database and no network.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 06:18:30 -07:00
CatoandClaude Opus 5 81d86a2869 feat(feedback): a fix ledger, and a page grouped by who is blocked (#639)
* feat(feedback): a fix ledger — where the change actually is, instead of a Check live that lies

"Check live" appeared the moment a run closed with success, and it opened
whatever URL the visitor had reported. Both halves were wrong.

The agent's job ends at a pull request (SHIP_INSTRUCTION says so). At close
the change is a PR nobody merged, on a site nobody redeployed — so "check
live" showed the unchanged page. And the reported URL is where the visitor
happened to be: a preview host, a stale domain, or in one of my own test
rows a .example fixture that resolves to nothing.

The fix ledger (src/lib/feedback/fix-shipping.ts) answers one question —
where is this change on its way to the live product? It reads the PR the
agent named in its handoff (or the reaper's evidence), asks GitHub with the
user's own token, and caches the answer on the run (payload.fix), refreshing
at most once a minute while the state can still change and never once it is
terminal. States: nothing shipped · pushed, no PR · PR #N open · closed ·
merged · deploying · deploy failed · Live.

The row now says which of those it is, shows the agent's own one-line
account, and offers the button that matches: Review PR while it is open,
Check live only once a deploy-like workflow succeeded on the merge commit,
Retry when nothing shipped. Check live opens the PROJECT's live URL plus the
reported path, never the visitor's host. Confirm resolves; the undo arrow
reopens it as "not fixed".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

* refactor(feedback): group by who is blocked, and open with the loop's numbers

The page asks one question — is anything waiting on me? — and answered it
with DB status, which cannot. `dispatched` covers an agent mid-run AND a fix
that merged and deployed an hour ago, so the row that needed a person sat
under "In progress" next to the one that didn't, and "Stalled" (a person's
problem, Retry) was filed as progress.

work.waitingOn is now the SSOT: you / machine / nobody, derived in ONE place
from the phase and the fix ledger, so a new phase cannot land in the wrong
column. Sections become Needs you / Under way ("moving on its own — nothing
to do") / Shipped, and the poll runs while anything is machine-side, which
now includes a PR waiting to auto-merge.

The page also opened with a blank column above three rows. It is the
ironing-out loop, so it now leads with the loop: reports, shipped, median
report→fix — the metrics the inbox route already computed and only ever
showed as a footnote on one section heading. Fifth caller of StatRow/StatCard;
no new CSS.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 05:00:30 -07:00
CatoandClaude Opus 5 9613cc9fb0 feat(fleet): the register answers the business question too (#638)
The page said what exists. It did not say which of it is a business. That
answer was already in apps.conf — owner|plan|price per site — and nobody
had ever added it up: four live client engagements, none priced above
zero, ten sites in the pipeline. The page now says so, in numbers it
computes rather than prose someone maintains.

Two deliberate boundaries:

- Terms are NOT joined onto RegisterRow. That row is served by a public
  endpoint, and what a client is charged is theirs. commerce() reads
  apps.conf directly; fleet-register.ts asserts the public payload's exact
  key set, so a field added 'just for the page' fails the suite instead of
  leaking.
- The band renders only for the studio owner. A prospect who reads 'every
  engagement is on favour terms' will expect a favour.

Per row, the register now says who a site is for and since when. The two
number bands are visually ranked: the commercial one carries the accent,
coverage stays neutral — six equally loud numbers is no hierarchy.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 04:48:48 -07:00