mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-05 13:17:37 +01:00
cdff69e3c2167fcdb48cecf48d389b2bb84cebcb
835
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
cdff69e3c2 |
test(audit): make the page list earn it, instead of asking it to (#818)
responsive-audit.mjs opens with the argument this enforces — "a rule enforced
on the pages that happened to be reachable is a rule with holes exactly where
nobody looked, so the list has to earn it". It could not earn it alone,
because nothing ever compared the list to the app. Twenty-four static page
routes were in neither list.
Comparing them found four that matter:
/my-feedback the REPORTER's view — the one feedback surface whose reader
may be a stranger on someone else's site, and one AGENTS.md
already records as having been forgotten ("the three-line
clamp shipped to the operator inbox never reached it").
/license public, 200, and already missed once: the MIT relicense fixed
LICENSE, README and Terms and left this page telling readers
they "may not" host or repackage (loki#802).
/privacy the other two pages a stranger is entitled to read, neither
/terms of them ever measured.
Plus /unlock, /releases, /setup and the two /docs guides. All twenty new
checks pass, so the gap was not hiding broken layouts here — but it was
hiding /feedback's, which clipped its own stats mid-word on a phone until
#813, and it would hide the next one.
The rest are excluded BY NAME WITH A REASON in NOT_MEASURED: retired redirect
stubs that render nothing (/agents, /atlas, /duet, /digests, /decisions,
/history, /blog), an action rather than a page (/sign-out), and flows that
need state a headless run cannot mint — a claim token, a verification token,
a connected Fleet Runner.
scripts/test/audit-covers-every-page.ts then fails when a page.tsx is in
neither, so adding a page becomes a decision about whether it is measured
rather than a silent omission. It also fails on an exclusion whose page no
longer exists — a stale reason is one nobody re-examines — and refuses a route
listed in both.
It asserts its own parse first. If the regex that reads those lists ever stops
matching, every other check would pass vacuously, which is precisely the
failure this file exists to prevent.
Mutation, both ways: removing /my-feedback from the audit fails it, and
excluding a route with no page fails it.
verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings),
check:design (11), check:desktop, test:home 130/130. test:unit 226/228 —
activity-time-zone-stable and telegram-allowlist need a live local server and
fail identically on pristine origin/main.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
1f7966ef4a |
fix(runs): a reaped "partial" recorded a verdict with nothing behind it (#816)
The reaper stamps `partial` on exactly one basis — `wroteAfterStart`, an
EXISTS over project_states proving the agent DID save a handoff inside the
run window. It then writes payload.note ("the agent had already saved a
handoff…") and stops. The handoff it just proved exists is never copied
onto the run, so `summary` stays NULL.
reapStaleRuns already names that state as the one to avoid — "reaped with
a partial verdict and a NULL summary, recording a failure whose reason
nobody could read". Aligning the freshness floor removed one CAUSE of it;
nothing ever filled the summary, so the ordinary path still reached it.
Measured on prod today: 8 of the last 12 closed runs on `loki` were reaped
partials with an entirely empty summary, every ~6 hours for three days.
That silence compounds, because the run summary is what briefs the NEXT
run — `done`/`next` are what the dossier re-serves under "Recent run
outcomes", so each dispatch was briefed with less than the previous run
actually knew.
A post-reap pass gives the handoff back, alongside the evidence corrector
it mirrors. Deliberately narrow: it attaches evidence, it does not
re-judge. Only rows whose summary is still NULL (never clobbers another
close path, re-running is a no-op); the run keeps its `partial` outcome,
because re-deriving the verdict would move the escalation ladders and the
failure brake that read it; and the same freshness floor the reaper used
is re-applied, so a handoff belonging to a different run can never be
pinned onto this one in the gap between the sweep and the pass.
The mapper is pure and lives beside the other two "summary from X"
builders, so it is testable with no database.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
013646e678 |
fix(pricing): "Most popular" was a claim about customers who do not exist (#815)
The pricing page badged Pro "Most popular". Checked against the database today: Loki has 7 users and 0 on any paid plan. Every paid tier reads "Price to be announced". So nothing has ever been bought, and no tier can be the popular one. It is the seller's emphasis, and it now says so: "Recommended". An opinion someone owns is honest; a fact about other people's choices, invented, is not. The card keeps its border and its filled CTA, so the hierarchy is unchanged. That page already held this standard in its own header — "a paid CTA only appears when a rail can actually take the money, never a dead Buy button" — and a permanently-unreachable Stripe branch was deleted for breaking it. The badge sat two screens below and slipped past. This is the second time the class has shipped in the fleet. George, on Substrata: "dont ever lie. ever." The remedy there was a banned-phrase ratchet, so this adds that ratchet for the public surface: scripts/test/no-invented-social-proof.ts fails on copy under src/app, src/config and src/components/public that asserts what other customers did — "most popular", "trusted by N", "join N users" and friends. Two things the ratchet gets right on purpose: - It bans claims about OTHER PEOPLE'S behaviour, not enthusiasm. "Recommended" and "Our pick" pass, because someone is accountable for them. - It strips comments before scanning. Otherwise this file, and the one it fixes, would both fail on their own explanations of the phrase they ban. Each pattern is only a lie while the number behind it is zero — which is why deleting an entry has to be a deliberate edit by a human who checked, not a check that quietly passes once the copy is reworded. Proved by mutation: restoring "Most popular" fails the suite. verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings), check:design (11), check:desktop, test:home. test:unit 224/226 — activity-time-zone-stable and telegram-allowlist need a live local server and fail identically on pristine origin/main. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
1f40a7c0d5 |
fix(ui): five scroll strips that hid their own scrollbar and never said so (#813)
Started from a real report: the buttons on /feedback look thrown together on a
phone. They do, and the page had never been measured — /feedback and /robots
were reachable from the sidebar and audited by NEITHER list in
responsive-audit.mjs. The paragraph above that list argues exactly this: "a
rule enforced on the pages that happened to be reachable is a rule with holes
exactly where nobody looked — so the list has to earn it." Both are in it now.
WHAT THE PHONE ACTUALLY SHOWED
/feedback at 390px ended mid-word — "32 Shipped 18 in…" — with the third
stat entirely off-screen. `.ui-stat-row` below sm is a flex strip with
`overflow-x-auto` AND `[scrollbar-width:none]`: no scrollbar, no fade, and
nothing whatever to say the row continues. A clipped word does not read as
"swipe me", it reads as a broken layout.
The repo already had the answer — `ui-scroll-fade-right`, which masks the
right edge below sm and nulls itself at sm. Four more strips were missing it:
ui-stat-row Feedback, Goals, Memory, Money, Habits
ui-filter-chip-row EventsGrid — the other FOUR call sites already had it
ui-inbox-projects Control's inbox
ui-activity-tabs the Activity tab row
ui-term-key-lane the phone key deck
ui-filter-chip-row settles the question of whether this was a decision: the
same class carries the fade at four of its five call sites.
A COMMENT THAT DESCRIBED A LAYOUT THAT DOES NOT EXIST
StatRow's doc said the row is "two columns below sm" and that the odd card
spans via `:last-child:nth-child(odd)`. No such rule has ever existed in
globals.css — the layout was replaced by the scroll strip and the
description was left behind. That is worse than no comment: it sends the
next reader hunting for a rule to adjust that is not there. Rewritten to
describe what the CSS does.
THE RATCHET
scripts/test/scroll-strips-have-an-affordance.ts fails on any strip that
scrolls horizontally AND hides its scrollbar AND offers no fade — reading
both the JSX and the ui-* class bodies, since .ui-stat-row hides its
scrollbar inside globals.css and its className reads innocent.
Its first cut reported the file it had just fixed, because it matched the
class name in the explanatory PROSE above the component. It reads className
attributes only now. A detector that cannot tell code from commentary
invents work.
Mutation: removing any one fade fails the suite.
verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings),
check:design (11), check:desktop, test:home 130/130. test:unit 223/225 —
activity-time-zone-stable and telegram-allowlist need a live local server and
fail identically on pristine origin/main.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
2e7c9bab61 |
fix(activity): the biggest number on the page was the one you could not open (#812)
Prod, 2026-09-20. The KPI row read: 9 Needs you · 1 Shipped · 0 Running · 49 Queued Four of those are links that filter the list below. "Queued" was a <span>. So the largest figure on the page — and the one that most obviously wants investigating, 49 waiting while nothing at all was running — was the one thing you could not click. Its only explanation was a `title` tooltip, which a touch device never shows at all. CLAUDE.md states the rule this breaks: "A gate records; it never blocks. Anything that pauses a person shows the way forward on the same screen." Queued is now a filter like the rest: a tab, a tally, and a list. The part worth care is that the rule lives in ONE place. `eventIsQueued` is exported and used by the hero's count, the tab's tally and the filtered list alike. Two copies would be worse than none — a count and a list that disagree teach people to trust neither, which is the failure this repo keeps finding in other forms. The predicate also carries the precedence the summary already used: attention outranks queued, so a dispatch that never reached an agent is reported as needing you rather than as patiently waiting. Proved by mutation: letting the filter drift from the count by one clause (including local chats) fails 2 of the 6 cases, one of them the explicit count == tally == list invariant. Typed into place, not guessed: `FILTER_LABEL` is a `Record<ActivityFilter, string>`, so adding the filter made the compiler demand the label. verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings), check:design (11), check:desktop, test:home 130/130. test:unit 222/224 — activity-time-zone-stable and telegram-allowlist need a live local server; both fail identically on a detached worktree of pristine origin/main, checked again here because this diff touches activity files. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
af98b036a5 |
fix(ui): numbers that did not add up, and a gate with no way out (#811)
Two things found by reading the screens as a user rather than as their author. SEVEN REPORTS WITH NO NAME The Feedback header read "68 reports · 29 still open" beside "32 shipped". 29 + 32 is 61. A reader who checks the arithmetic concludes one of the three numbers is wrong; every one of them was right. The remainder is `archived` — filed away rather than fixed — a state no card admitted existed. Confirmed against the database: resolved 32, dispatched 25, archived 7, new 4 = 68, where "open" is new + dispatched. The metrics query never counted archived rows, so the page could not have named them. It does now, and `reportsSubLine` is pure and exported so the arithmetic is pinned without rendering — three numbers that fail to reconcile look exactly like three numbers that do. Mutation: dropping the archived clause fails 3 of the 5 cases. A PIN SCREEN THAT BLOCKED ABSOLUTELY AGENTS.md and CLAUDE.md now state the rule: "A gate records; it never blocks. Anything that pauses a person shows the way forward on the same screen." The private-zone gate did the opposite. Forget the PIN and there is no route anywhere: changing it requires the current PIN, removing it requires the current PIN — both deliberately, so a hijacked session cannot swap it — and no reset flow exists. The screen offered an input, "Incorrect PIN", and nothing else, while the zone behind it holds 2,750 contacts and a 2,797-entity knowledge graph. The fix is NOT to weaken the gate. It is to stop implying a door that is not there: both surfaces — the /unlock page and the inline PrivatePinGate — now state the consequence and link to /support, whose address is on the apex domain and has a live MX (checked). Not changed: the PIN recovery policy itself. Adding a reset path is a security decision with a real trade-off, and it is George's. verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings), check:design (11), check:desktop, test:home 130/130. test:unit 221/223 — activity-time-zone-stable and telegram-allowlist need a live local server and fail identically on pristine origin/main; this diff touches neither. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
276b412a14 |
fix(audit): the contrast gate only ever looked at the dark theme (#810)
A fresh browser context has no `loki-theme` in localStorage, so ThemeProvider
falls back to defaultTheme="dark". This audit never set one — so every contrast
number it has ever reported was a dark-theme number, and light mode has never
been measured by anything. CLAUDE.md is explicit that light "is a real state
your styling must survive".
It was hiding real work. Measured on prod against /today and /control, 132
interactive labels across both themes: DARK has zero below the AA floor, LIGHT
has TWENTY, including the ones you press —
2.09:1 "Send" the dispatch button on Control
2.09:1 "More"
2.23:1 "Recent" / "A-Z" the project sort controls
2.29:1 "Unlock private"
3.83:1 "Open terminal"
4.13:1 the command palette ("Search prompts, pages, dispatch…")
4.29:1 the Profile / Chat / Terminal workspace tabs
Two changes, both about the gate rather than the palette:
- Each theme gets its own context, seeded with the key ThemeProvider persists,
and the run ASSERTS `data-theme` actually applied. Without that assertion a
light pass that silently rendered dark would report clean — which is the
exact shape of failure this file was written to catch.
- The settle loop now wants three identical counts and at least four reads.
Two was enough when one warm context served every route; each theme now gets
a COLD one, and cold /control served 2 labels twice running while it
hydrated, then latched and reported 2 of the 54 it has. That is a clean tick
for a page the audit never looked at.
Deliberately NOT done: raising the light `--text-muted` / `--text-tertiary`
tokens. The file already states the position — the tertiary token is below AA
on dark too, has ~429 usages, and widening scope waits on that token being
raised. That is a palette decision with a visible blast radius, and it is
George's, not a side effect of fixing the instrument. This change only makes
the cost visible.
Not wired into `verify` or CI (it needs a session, network and a browser), so
reporting more cannot redden the build.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
3ba22707cc |
fix(activity): the feed spent its whole preview on a note to the agent (#808)
Three consecutive "Needs you" rows on prod, 2026-09-20 — three different runs
— each showing the same sentence, cut at the same word:
Partial with no recorded reason — asked: Work on the project at
/home/g/dev/loki. [autopilot · loop=next_best — this prompt was auto-injected
by the local dispatch loop, NOT typed by a human. Treat it as a
regularly-scheduled review task; if the conversation seems off, suspect th…
That header is written in config/prompt-library.ts and addressed to the AGENT.
It is ~230 characters; PREVIEW_MAX is 240. So the preview was the header and
nothing else, the three rows were indistinguishable, and the reader never
reached a word of what was actually asked.
Two things wrong, both fixed:
- The header is stripped from the PREVIEW, so the row shows the ask.
- "asked:" is a claim about who asked, and for these rows nobody did — the
prompt's own first sentence says it was not typed by a human. An autopilot
row now names its loop instead of implying the operator wrote it.
This is what `activity-status.ts` already exists to do: stripHarnessScaffolding
and extractOperatorTask are there so a feed shows "exactly the human ask". The
autopilot header was simply a gap in that set.
THE DISTINCTION THAT MATTERS: stripped from `preview` only. `task` is what a
re-dispatch sends and `full` is what the agent received — removing the header
there would re-run the loop's work without the instruction telling the agent a
loop sent it ("suspect the loop, not the human"). The test pins that both ways,
and mutation proves it: stripping `task` too fails the suite, and not stripping
the preview fails it.
verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings),
check:design (11), check:desktop, test:home. test:unit 216/218 —
activity-time-zone-stable and telegram-allowlist need a live local server and
fail identically on pristine origin/main; this diff touches neither.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
6eff359fd3 |
fix(ui): two pages that knew more than they showed (#807)
Found by walking the pages on prod, 2026-09-18.
TODAY — four half-empty rows
`CardRow` is authored as a pair ("a single column on a phone, two from md
up"), but the cards inside it render nothing when they have nothing to say:
an empty calendar, a quiet alerts card, anything behind the locked private
zone. React drops a null child from the DOM, so a fixed two-track grid kept
both tracks and drew the survivor at half width beside an equally wide void.
Measured with the private zone locked: FOUR rows, each a 408px card next to
408px of nothing — most of what the page looked like. Now a lone survivor
spans the row. Nothing changes when both cards render, so the deliberate
pairings the page comments defend ("the two cards that are only true right
now") are untouched, and at grid-cols-1 the rule is a no-op.
PROMPTS — two cards nobody could tell apart
Two cards titled "Next Best Step" sat side by side: same title, same clamped
summary, same four tags, under a header reading "2 saved · most-recent
first". Nothing said which was which — and `updatedAt`, the field that
ordering rests on, was carried into the component and never rendered. So was
`runCount`.
Underneath, the API returned EIGHT rows, all named "Next Best Step", in two
groups of four byte-identical bodies. The render-time dedupe is RIGHT to fold
them (it was added after a smoke session forked a default seven times) and
right to keep both survivors — they genuinely differ, past the two-line
clamp. But folding silently made delete look broken: a card stands for a
whole group, so deleting it draws the next identical row in its place and the
prompt appears to come back.
The card now says when it was saved, whether it has ever run, and how many
identical rows it stands for.
`collapseDuplicates` is pure and exported so the rule is pinned without React.
Proved by mutation: dropping the count fails 3 of 7 cases, keying identity on
name alone fails 3.
NOT done here, because it is a decision rather than a defect: making delete
remove the whole group it represents, and clearing the 8 duplicate rows. Both
touch stored data.
verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings),
check:design (11 checks), check:desktop, test:home, and every check:*/gate
member green. test:unit 216/218 — activity-time-zone-stable and
telegram-allowlist need a live local server and fail identically on pristine
origin/main with no changes at all; this diff touches neither.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
4735397aa0 |
fix(feedback): the reporter page was the counter-example to its own top report (#806)
* fix(feedback): the reporter page was the counter-example to its own top report /my-feedback rendered a report asking for a three-line clamp at full eight lines, under a chip reading "Being implemented". The clamp WAS implemented — FeedbackReportText, #783, written in answer to that very report — but only in FeedbackItemRow, the operator's inbox. The reporter page kept its own row markup, so the fix never reached the person who asked for it. The missing import is the symptom. The defect is that a third feedback surface existed with its own renderer and nobody knew, so this fixes the page and closes the gap that let it drift. The page now: - renders bodies through the shared FeedbackReportText, so one dictated report stops owning the list; - derives status instead of dictionary-mapping the DB word. `dispatched` meant queued, running, crashed days ago, or shipped-but-unconfirmed, and all four read "Being implemented"; work-phase.ts opens by saying DB status cannot answer that question, and this page was the last one still asking it; - gives the reporter a next action — "Check the live page" once a fix is actually deployed, never while its pull request is open; - colours the chip. Every state used .ui-badge, the same neutral pill as a duplicate count, so the one thing a reporter comes here to learn carried the weight of a footnote; - formats dates in the READER's locale and time zone. toLocaleString() ran in a server component, so a Swiss reporter was shown a US date on the box's clock. The operator row never had this; it is already a client component; - labels the project name, which sat unlabelled exactly where a person's name would and read as one. What a reporter may see is decided in one place. reporter-view.ts writes every reporter-facing sentence rather than forwarding FeedbackWorkView's, because that view is written for whoever owns the machine: `detail` carries builder asks, `diagnostic` the agent's raw error, `stepSummary` run-hop narration, plus run and command ids. A pass-through would have been shorter and would have put an engineer's note on a stranger's screen. attachReporterView is likewise a narrow read, never attachFeedbackWork — that one refreshes GitHub ledgers, sends the owner's notifications and scopes to the owner, none of which belongs on a reporter's page load. Reporter run lookup is deliberately not owner-scoped, and authorization comes from the report instead: the caller has proved reporter_user_id, and passes only the dispatched_run_id values off those rows. Guards, so the next clamp-class fix cannot land on one surface only: - feedback-reporter-view.ts pins that the page renders through the shared clamp, formats no date server-side, maps every phase, and leaks no operator-only string for any phase; - CLAUDE.md names /my-feedback in Views — it listed /feedback and ControlInbox and not this one; - /feedback and /my-feedback join audit:responsive, which would have caught an eight-line row at 390px. Dropped the subtitle's "Tracking a report never grants permission to edit its project." It answered a question no reporter asked and spent the line that now says what the page is for; the boundary it described is enforced in code and pinned by tests, not by that sentence. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FuaeWPc8gT5sbS7G8BjnrK * fix(feedback): read the reader's clock without setState in an effect `react-hooks/set-state-in-effect` rejected the first cut, and correctly: a useEffect that immediately setStates is a cascading render, and the rule does not care that the second render is the point. The constraint that produced it is real, though. Only the browser knows the reader's time zone, so the localized string cannot exist during SSR — and server and client must still emit identical markup or React throws the tree away. useSyncExternalStore with a server snapshot answers both, and is the shape this repo already reaches for: BrandVersion says "client-only, with a null server snapshot so SSR/hydration match (no setState-in-effect)" in as many words, and NotificationsPill uses the same mounted gate after a React #418 on every authenticated page. Also drops the now-redundant `title`: after hydration the visible text IS the full localized string, and `dateTime` carries the exact instant for machines at every stage. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FuaeWPc8gT5sbS7G8BjnrK --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
fa5e277329 |
fix(dossier): a run's stderr is not the project's next step (#805)
The dossier every dispatch carries opens with "## Latest handoff → Done /
Next / Health", read from the newest `user_projects.dev_log` entry. For a
hosted (Hermes) run that entry was built like this:
done: label.slice(0, 100) // label = `Hosted dispatch (Hermes) — ${task.slice(0, 70)}`
next: text.slice(0, 2_000) // text = the run's OUTPUT, or its ERROR
health: "good" // on every entry, FAILED ones included
Three separate lies, all reported in #584 on 2026-09-10 and all still
reproducing on 2026-09-20 — the first of them in the dispatch that opened
this session:
- Done: Hosted dispatch (Hermes) — # Loki operator dispatch
Everything in this message is assembled by Lo
`task` for an autopilot run IS the assembled envelope, so slicing its
first 70 characters yields preamble. "What did the last run do?" came
back as a truncated system prompt, and then every subsequent dispatch for
that project re-served it for hours.
`extractOperatorTask` already exists for exactly this — the Activity feed
uses it so a row shows what was ASKED rather than the scaffolding. The
hosted runner had its own slice() sitting beside it. It now uses the
helper, so the line names the actual instruction.
`next` held the run's output. On failure that is the raw error, stack
frames and all, filed under the heading that tells the next agent what to
do. It is now empty — and the dossier omits a blank line entirely, which
is the honest rendering, because a hosted run genuinely does not know the
project's next step. Nothing is lost: the full output and the full error
already live on the orchestration run's payload via closeHostedRun and in
the task_completed/task_failed event beside it. The dev log is the
summary, not the archive.
`done` now states the outcome — the PR url, the pushed branch, "no file
changes", or FAILED plus the error's first line. First line, not the
error flattened: "Error: spawn pnpm ENOENT" plus three stack frames comes
to 158 characters, under any sane clamp, so flattening would have carried
`node:internal/child_process:285:19` into a line agents read. The test
pins that case; it caught it.
And a failed run no longer reports health "good", which it did
unconditionally — so the Health line agreed with itself no matter what
had happened.
The decision moves to src/lib/hosted-run-log.ts where it can be tested,
rather than living as four slice() calls at four call sites. What the
dossier shows to every future agent is a product decision, not a
formatting detail.
verify: 216/216 unit tests, tsc clean, lint 0 errors (2 pre-existing
warnings).
Refs #584
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
93a6e3e1f2 |
refactor(beacon): delete the popup, and gate the class of bug that hid it (#804)
The beacon popup was retired on 2026-06-11 ( |
||
|
|
d42dbfed4d |
fix(ci): a test that never exits is a failure, not a 56-minute wait (#809)
groq-chain-fallback finished its assertions in two seconds, printed its check
mark, and then held every CI run open for FIFTY-SIX MINUTES. It read as "CI is
slow" rather than "a test is broken", so nobody looked.
Its refusal cases drive the vendor-error path, which fire-and-forgets a quota
write: recordRefusal -> persist -> lazy import of @/db -> postgres(url,{max:5}).
Nothing closes that pool, so its sockets hold the event loop open. The file now
ends with process.exit(0), as the other database-touching tests already do
(rag-retrieval, telegram-allowlist). Exiting is safe precisely because the
pending write is worthless: the readings come from a stubbed vendor answering a
fake key, so persisting them would put fiction in the quota table.
Reproduced both directions against a real database: without the exit the
process is still alive when killed at 45s; with it, 1s.
This was invisible locally, which is why it survived -- with no DATABASE_URL the
lazy import rejects and the process exits in two seconds. The hang exists only
where a database does, so test-unit.ts's own header claim that these tests
"behave identically on a laptop and in CI" was quietly false, in timing rather
than in pass/fail.
The runner is the real fix: it spawned every file with no timeout, so one wedged
test set the runtime of the whole suite. It now enforces a per-file deadline
(UNIT_TEST_TIMEOUT_MS, default 120s) and reports a timeout as a named failure
pointing at the likely cause. Proven by mutation: a planted file that wedges the
event loop goes red in 20s instead of running forever.
Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
33395d2c91 |
refactor(ecosystem): Loki is the execution layer, not the engineering one (#801)
"Engineering" named Loki's deepest capability, not the product. Today, People, Crew, Money, Goals and Habits ship here too, and OrangeCat — whose dashboard is economic entities — has no surface to receive them. Under the narrow label those two thirds read as scope creep, and the conclusion drawn from it, twice in one session, was "move the life-ops half to the Cat". There is nowhere to move it to. What actually separates the three products is AUDIENCE, not subject matter: OrangeCat is public by design, Loki private by default, Solon shared with its members. Work crosses a boundary when it needs to be seen, paid or decided — which is the seam Crew already implements, keeping an assignment private here and mirroring it to OrangeCat as a service only once it is paid. - fleet map: the `capability` layer becomes `execution`, and Loki's role sentence names the people, commitments and spending alongside the agents - both assistant prompts (chat + tool loop) introduce Loki as the operator's execution layer rather than a captain over projects alone - AGENTS.md / CLAUDE.md state the plane, and why the old word was wrong - new gate scripts/test/execution-plane.ts pins all three, so the rename cannot roll back quietly; picked up automatically by test:unit Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
a02d31d996 |
Every public claim matches the code, and two gates can now fail (#802)
* fix(truth): every public claim now matches what the code and the licence say The /license page forbade what LICENSE grants. #791 relicensed the repo to MIT and fixed LICENSE, the README and the Terms — but missed the page, which still said "source-available", listed hosting and repackaging under "you may not", and promised a replacement licence that had already shipped. On a public repo, that revoked rights we had granted. Same shape, five more places: - Three live /thoughts pages and four front-matters carried "Mao Nakamoto", the retired identity, into the rendered byline and the OG social card. - legal/ named that identity as operator, data controller and IP assignor, and assigned the work to bitbaum AG / orangecat GmbH / loki GmbH — none of which were ever incorporated. Rewritten as a record of authorship and the MIT grant, which is what is actually true. - The desktop About dialog and the installer copyright metadata shipped "© 2026 Mao Nakamoto" in every build. No audit pass had looked there. - /pricing and the feedback-widget docs said the report loop "closes itself" months after close-loop.ts deliberately removed auto-resolve for being untrue; resolve is an operator act and has zero call sites. - /roadmap claimed signed installers under "Shipping now"; no signing secret exists and /download says the opposite two pages away. - /releases claimed "every shipped version" while missing nine, and listed a 0.8.25 that was never tagged — its "Binaries →" link 404'd. Removed per the file's own rule: one entry per tag pushed to loki-releases. - desktop/README pointed all five install commands at bitbaum/loki, which 404s; releases publish to loki-releases. Version pin replaced with a glob so it cannot rot again. - DEFAULT_USER_NAME greeted nameless OAuth users as "Mao". And the two that lied to agents rather than users: CLAUDE.md claimed pre-push runs the full verify bundle so "green locally means green in CI", and AGENTS.md claimed pre-commit runs tsc. The hook's own header documents why it stopped doing both — a docs-only push runs nothing. An agent trusting either line would skip the verification it needed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(gates): close the two gaps that let deleted things keep passing Two gates could not fail, and one migration ledger had silently drifted. MIGRATION JOURNAL — 13 files missing, next db:generate breaks the deploy. drizzle/ held 78 .sql files; meta/_journal.json had 65 entries. Production was fine and always had been: apply-schema.sh globs the directory and keeps its own _deploy_schema_history, so it never reads the journal. But drizzle-kit does, and its newest snapshot was 0072 — so the next generate would re-emit 0073-0077, including CREATE TABLE "calendar_busy" with no IF NOT EXISTS. apply-schema.sh rewrites ADD COLUMN only, and the batch is one transaction, so the deploy would abort on a change unrelated to it. Reconciled to 78 via bootstrap-migration-ledger.ts --write-journal, and added scripts/test/migration-journal-coverage.ts so it cannot drift again: files vs journal in both directions, plus idx contiguity. Proven by mutation — drop one entry and it exits 1; restore it and it exits 0. SMOKE — every authenticated probe passed whether or not the route existed. The auth middleware answers 401 before routing, and check_route accepted 401 for everything in AUTH_API_ROUTES. Measured: /api/definitely-not-a-real-route returns 401 exactly like /api/orgs. So the list proved nothing, and /api/checkout/personal sat in it for 15 days after the Stripe rail was removed. A 401 now only passes if a route file actually resolves on disk (dynamic and catch-all segments included); the dead entry is gone, and all remaining probes resolve. Also: bumping desktop/package.json to 0.8.29, because the retired-identity fix in the previous commit touched desktop/src/main/index.ts and desktop-release- drift.ts correctly refused to let a shipped file change without a release to carry it. That gate was right and is the model for the two above. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
451ac5ded7 |
fix(dispatch): a deadline four months gone is not a near-term commitment (#800)
Every dispatch this fleet sends opens with the operator's goals and
deadlines, under the instruction "align your priorities" — and on
2026-09-20 the two it listed were:
The operator's near-term commitments/deadlines (be mindful of these):
- Get a $50 signup bonus when you spend $100 within 30 days of getting
a new Coinbase One Card — due 2026-05-03
- You can unpause your project from the dashboard within 90 days. After
this period, the project cannot be restore — due 2026-07-03
Four and a half months and eleven weeks gone, handed to every agent on
every project as something to aim at. Filed as #584 on 2026-09-10 after
the same block reached Heidi; it has shipped in every dispatch since,
including the one that produced this commit.
Two separate defects, and the interesting one is not the label.
listUpcomingCommitments takes everything active due before now+14d with
no floor, which is deliberate and documented — "overdue included, those
are the most urgent" — but it then ordered by due_date ASC and capped at
8. Ascending order over a set that reaches backwards means the OLDEST
rows sort first and take the whole cap, so the least recoverable items
crowd out the ones still worth doing. "Soonest first" and "most urgent
first" read as the same sentence and are opposites here. Distance from
today is what urgent actually means, so that is what the ORDER BY says
now; verified against the live table, where it flips the two rows into
the right order.
The label is the half that changes today's prompt. Overdue rows still
belong in this block — a commitment someone missed is exactly what an
agent should know — they just have to arrive marked as missed:
- ... — was due 2026-07-03 (OVERDUE)
- Reduce Monthly Burn (40%) — target 2026-06-30 (PAST, not met)
and the heading no longer calls the list "near-term" while carrying rows
that are not.
isOverdue lands in lib/dates.ts as the one definition, deliberately not
`isPast`: that is instant-granular and would call a 09:00 deadline missed
by lunchtime. It compares PRINTED dates — the same toLocalDateStr the
block renders with — so the word and the date beside it cannot disagree,
which an instant boundary computed in a different timezone from the
formatter can and does.
The same predicate goes into the daily brief, whose entire premise is
handing the model settled answers instead of rows to filter. It asked
"commitments due inside 3 days" and described its own SQL as
`due_date <= now()+3d`, both true of the code and neither true of the
rows: overdue ones were in the answer, unlabelled. Its dateLabel also
printed a UTC day next to a word now decided on the local one, so both
now go through toLocalDateStr.
The format test moves out of the source file into scripts/test/, where
test-unit.ts actually globs it — as an inline `--self-test` nothing ever
ran it. Extended to pin the boundaries, built from local calendar parts
rather than UTC instants (green under UTC, Zurich, Kolkata, New York,
Kiritimati and Midway).
Not touched: getGoalsDueSoon and getEventsDueSoon share the missing
floor, but /today's GoalsDueCard and EventsDueCard render them and are
meant to show overdue items to the human. Their `method` strings now
state that honestly instead of being made to lie less.
verify: 214/214 unit tests, tsc clean, lint 0 errors (2 pre-existing
warnings).
Refs #584
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
49e668d418 |
feat(projects): interview the owner before building from one sentence (#799)
* feat(projects): interview the owner before building from one sentence "Build it with Loki" created a project and immediately ran the kickoff — profile extraction, milestones, repository, agent — on whatever the OrangeCat page happened to say. For a service listing that is a title, a price and one line of public description. Everything the kickoff produces is a function of that text, so a thin brief produced a thin everything: `isThinBrief` already named the failure and had nothing to do about it, and the extractor wrote "Unknown" into the fields it could not infer. The one person who knows the answers is right there, so ask them. A new project from a handoff now lands on five short questions — who it is for, what they do today, what this does for them, what the build must use, what makes the first version worth shipping — and reaches the kickoff a few sentences later with a profile worth building from. - lib/project-interview.ts is the SSOT for which gaps are worth asking about. Pure: the same plan drives the route, the card and the tests, so a question can never be asked about a field already answered. Only the three essential gaps decide whether to interrupt; a missing stack preference rides along but never starts an interview. - Answers are stored verbatim — as the attribute each one answers, and appended to the description, which is what the profile extractor, the roadmap step, the dispatch prompt and RAG actually read. No model sits between the owner's words and what gets stored; extraction happens after, from a brief that now says something. - lib/project-interview-ai.ts only REWORDS the questions for this project. It cannot change which are asked, and every failure path returns the bank unchanged: generic wording beats no interview. - `hasAnswer` guards both ends. "Unknown" is a gap worth asking about, and a typed "n/a" is a skip — a stored one is truthy, satisfies every "is this filled?" check downstream, and briefs an agent with nothing. - Skipping is always available and never punished. Skip everything and you land exactly where this flow landed before. A project that was merely LINKED to an existing Loki project still gets neither flag — linking is not consent to start work on it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RU7EqR1TPicrJGv46cLDaH * fix(interview): an error is never a wall, and a slow model costs wording, not waiting Two places the interview could leave someone standing still: - If the questions failed to load, the card showed the error and nothing else. The questions are an improvement to the build, not a condition of it, so the build is now one tap away from the error: "Skip to the build" lands exactly where the old one-click path landed. - Tailoring the questions to the project could take 20s, all of it spent on "Reading your page…". The plain questions are already good. 8s now: a slow model degrades the wording, never the wait. And the rule both follow, written into CLAUDE.md where the next agent reads it: a gate records; it never blocks. Anything that pauses a person shows the way forward on the same screen. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RU7EqR1TPicrJGv46cLDaH --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
04cedba195 |
Loki's public face belongs to the tenants who agreed to be on it (#798)
* fix(setup): the documented local setup produced a broken app Followed README.md and .env.example exactly on a clean checkout and got an app that renders but cannot read a session. Three separate gaps, each on the documented path: - AUTH_TRUST_HOST was undocumented. src/auth.ts gates trustHost on it, and scripts/hetzner/gen-env.sh writes it on the box — but .env.example, the README's "minimum local .env.local", docker-compose.yml and loki-app.sh all omitted it. Unset, Auth.js answers EVERY /api/auth/session with 500 UntrustedHost. Verified: 500 before, 200 after, nothing else changed. The auth.ts comment claimed the local production server set it; it did not. - The compose db image has no pgvector. knowledge-embeddings.ts declares vector(384), so `drizzle-kit push` dies on the first table with `type "vector" does not exist` and leaves an EMPTY database — which reads like a broken checkout rather than a missing extension. Switched to pgvector/pgvector:pg17 and added an initdb script that creates it before the migrate service runs. - drizzle.config.ts never loaded .env.local, though a dozen scripts under scripts/db and scripts/test do. `pnpm run db:push` therefore threw "DATABASE_URL is required" at someone who had just set DATABASE_URL where the README told them to. An exported variable still wins, so CI and the box are unaffected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(projects): the empty state named a button that does not exist A new account with no projects is told to "Register your first project with 'New project' above". There is no "New project" control on the page — the button reads "Add", and the dialog it opens is titled "Add Project". The component file is called NewProjectButton.tsx, which is most likely where the copy came from. Found by signing up as a new user and following the onboarding instruction literally: the first thing the product asks you to do names a control you cannot find. Now says "Add", matching what is rendered. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * feat(fleet): a project reaches Loki's public catalogue only by consent /fleet is unauthenticated and speaks for the PRODUCT, not for a user. It resolved a single account — getSelfImprovementTarget(), "whoever owns the oldest entity named loki" — and published every project that account had. Two things were wrong with that in a multi-tenant product: 1. No decision was ever recorded. A project was on a public page because it existed. Every other public surface here already goes through getPublicProjects (the landing hero, /u/[username]); /fleet was the only one reading the unfiltered query. 2. WHICH account got published was a side effect of the self-improvement loop's notion of "which product am I improving". Reseed that entity and the next-oldest match's whole project list becomes Loki's front page. So consent is now a stored property of the project: - user_projects.listed_publicly, DEFAULT FALSE. The default is the point — signing up must never enrol a tenant in the product's shop window. - getPubliclyListedProjects() reads consent instead of ownership, across all accounts, which is also what makes the page meaningful with more than one user. /fleet no longer selects by owner at all. - A per-project toggle on the project workspace, beside the existing "Publish to OrangeCat" opt-in and reversible from the same control. - 0075 backfills the account publishing the catalogue today, so the live page is unchanged for it while everyone else starts at false. Also: FleetRegisterNote told EVERY account "19 sites are hosted on the box with no project here" — apps.conf describes one box and is a file in this repo, so a brand-new user was being told about sites they do not own. It now renders only for the account that operates that box. A user's own profile (/u/[username]) is deliberately untouched: that page is the user speaking about themselves, and it was already scoped. scripts/test/public-catalogue-consent.ts pins all of it — swapping the query back is a one-word change, and a comment cannot hold that line. Verified against a real database: consent false -> absent from /fleet, true -> present, toggled both ways through the UI. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * feat(public): what a signed-out visitor sees is a decision, not an accident Answers "whose projects does a stranger see on Loki?" — with three tiers instead of three different hardcoded owner lookups. THE PROBLEM. Loki is multi-tenant and the founder is tenant #1, but every public surface resolved an owner and published whatever that account held: - the landing hero → getHeroFleetSnapshot(getDefaultUser()) - /fleet → getSelfImprovementTarget() (fixed in the last commit) - the /projects note→ nothing at all Three answers to one question is three chances to be wrong, and the landing was the worst of them: it never consulted consent at all. Verified locally — a project with listed_publicly = false was rendering in the hero console. It also ordered by a hardcoded FLAGSHIPS = ["loki", "orangecat"], the ad-hoc version of "featured", which could only ever name the founder's own projects. The same list sat in /u/[username], where it reordered EVERY tenant's profile by two names they will never have. THE MODEL. src/db/queries/public-visibility.ts is now the one place that says what a signed-out visitor may see: 1. AGGREGATE — fleet-wide counts. Identify nobody, need no consent, and grow honestly as Loki gains users. 2. CATALOGUE — /fleet: projects whose OWNER opted in (listed_publicly). 3. SHOWCASE — landing hero: the catalogue narrowed to what the OPERATOR featured (featured_at). Curated space cannot be first-come. Two gates because they answer to different people: consent is the tenant's and may be withdrawn; featuring is the operator's editorial act. The showcase predicate is BUILT ON the catalogue predicate, so revoking consent drops a project off the homepage immediately even while it is still featured — verified all three ways against a real database. This is the doctrine site_feedback.featured_at already had ("raw visitor text NEVER auto-publishes"). Projects now work the way feedback already did. Featuring is authorized by isSiteOperator (users.is_default — the account made at /setup, so it means "runs this instance" for self-hosters too) and lives on its own query rather than riding patchProject, because it is the one project field a tenant must not set for themselves. It also refuses to feature a project whose owner has not consented. UI: two separate controls on the project workspace, deliberately not merged — "List publicly" (owner) and "Feature" (operator, shown only to them, and explaining itself when consent is missing). ALSO, from auditing the public pages at 320/390/768/1440: - /fleet had 19 sub-44px tap targets — every one the site address that is the whole point of the row, and the only sub-44px targets left on any public route. .ui-public-fleet-site was missing from the touch floor AND was an inline box, where min-height does nothing. Both fixed; now zero. - The responsive auditor EXCLUDED public routes, deferring to `smoke` "which already covers them" — smoke asserts HTTP status, which says nothing about a layout. So the pages a stranger sees first were the only ones with no responsive coverage. They are in the auditor now and need no session, so a session is required only when authenticated pages are requested. No horizontal overflow at any width, before or after. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(fleet): a phone spent a screenful on filters before the catalogue Measured at 390x844: the first project row sat at y=1020px. Four facet rows (Where / Kind / For / Missing) took 366px of that, so you scrolled past more than a screen of controls before seeing any of the thing they control — on a page whose entire job is to show a catalogue. The rows now live in a <details> that is collapsed below md and forced open from md up, so desktop is unchanged and the phone leads with content: first row y=1020 -> 699. The summary carries a count of active facets, because a filter you cannot see is one you forget you set — and then an empty result reads as a broken page rather than a narrowed one. <details> rather than state, because this page deliberately ships no JavaScript ("the address bar is the state") and a filter panel that needed a bundle to open would be the one thing on it that did. One trap worth recording: hiding the closed panel has to be EXPLICIT. The UA sheet hides a closed <details>'s children with display:none, but author styles outrank the UA sheet and .ui-fleet-facet-row is `@apply flex` — so the first version rendered a toggle that changed nothing, with the element correctly reporting open=false while all four rows stayed visible. Verified both states at both widths after the fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * feat(public): credit the builder, ask before publishing, stop renting the box Four things, all following from the same rule: Loki is multi-tenant, so its public face belongs to the tenants who agreed to be on it. 1. ATTRIBUTION. A showcased project now carries a byline — @handle linked to /u/[handle], display name when there is no handle, and NOTHING when there is neither, because a stand-in label is a name we would be inventing for somebody. Showing a tenant's work unattributed reads as "our projects", which is untrue and is the opposite of why a showcase exists; being credited and linked is also most of what a tenant gets back for consenting. Joined in the query rather than fetched per row. 2. LOKI ASKS. Consent was reachable only from a toggle nobody knew about, and a control nobody finds collects exactly one answer. The empty catalogue that follows is what gets "fixed" by widening the query again — the bug 0075 removed. So the project workspace now invites the owner once, and listing_prompt_dismissed_at takes no for an answer: per project (declining for a client build says nothing about the open-source one beside it) and in the database (a refusal that resets on a new device is a product that nags). The rule lives in src/lib/listing-invitation.ts, pure and unit-tested. The bar is repo + active, deliberately NOT a live URL: /fleet's own facets list "Being built" beside "Live", so requiring a deployment would ask only the projects that least need the exposure. 3. THE BOX IS NOT THE FLEET. apps.conf describes ONE box and is a file in this repo, and unmatched entries MINTED rows — so a Loki with one consented project still published 19 sites belonging to someone the viewer has never heard of. buildFleetRegister now takes includeUnlinkedSites, true only for the operator, for whom those rows are the entire point (the register read sideways is a to-do list). A hosted app still ENRICHES a project that exists, so a consented project keeps its real address either way; only row creation is gated, because only row creation publishes something nobody asked to publish. Verified: operator sees 20 projects / 19 sites, the public sees 1 / 0. 4. THE COPY. "This is the studio's whole catalogue" was true when one account was the whole fleet. It now says what the page is: projects their owners chose to show. Also, from re-auditing: .ui-public-fleet-name (the row's PRIMARY link) measured 21px tall on a phone. It had been invisible to every previous audit because while the page listed hosted sites alone, nothing in a row was a link at all — the fix in 3 is what made a real project row render and the gap appear. Same cause as .ui-public-fleet-site last time: the coarse-pointer floor sets min-height, which does nothing to an inline box. Every public page: zero horizontal overflow and zero sub-44px targets at 320/390/768/1440. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(home): the hero console had an empty third column Making the hero tenant-agnostic dropped "runs this week", because the old one counted getRecentOrchestrationRuns(userId) — one account's week, which is not a number a visitor should be shown. But the console's metric row is grid-cols-3, so removing it left a visibly empty third of the panel. Caught by looking at the rendered page rather than the diff. Restored fleet-wide, counted the same way as the other two: it is the metric that answers "is anything actually happening here", and an aggregate across every tenant identifies nobody, so it needs no consent and grows with the product instead of describing one account. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(footer): the studio's sites were labelled as Loki's fleet Every public page's footer lists 14 sites generated from apps.conf under "Part of the fleet — 14 more sites". apps.conf describes ONE box, the studio's, and several of those sites belong to clients — so on a multi-tenant Loki the label told every visitor that one account's client work was what Loki is. Same error as the /fleet lede, and the same fix: say whose they are. "Built by the studio" now, and the link beside it points at the tenants' catalogue by its real name rather than calling it "the whole register". Deliberately a COPY change and nothing more. The links themselves stay, all 14 of them: they are real work, several had no inbound link from anywhere before this block existed, and the cross-linking is the entire reason it is here. Removing them would trade a genuine asset to fix a sentence. Only the claim was wrong. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(home): the hero console looked broken with nothing featured 0076 deliberately does not backfill a feature stamp — featuring is an editorial act nobody has performed yet — so the live hero will really render with zero project rows until someone features something. I had asserted that was fine without looking at it. It was not. The bar carries mb-4 + border-b and the metrics carry mt-4 + border-t, so with no rows between them the panel drew TWO horizontal lines with 32px of nothing in between: the shape of content that failed to load, on the first screen of the product. The metrics now sit flush under the bar's own border in that state, which is a panel with nothing to list rather than a panel that broke. Verified in both states: with rows the divider is back and the flush class is absent. Not fixed by falling back to showing consented-but-unfeatured projects, which was the tempting option: the invitation asks permission for the public fleet page specifically, so putting those projects in the hero would take more than the owner agreed to. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A * fix(fleet): an empty catalogue told visitors to clear filters they never set With nothing listed, /fleet rendered "Nothing matches that. Clear the filters →" — to a visitor who had set no filters, offering a link that changes nothing. That is the FIRST thing a freshly self-hosted Loki ever says on that page, and it reads as a fault rather than an empty shelf. Two states now, told apart by `rows` (the whole catalogue, before the query) rather than `result.rows` (after it): nothing listed at all → says so, and says why: owners choose which of their projects appear, and nothing is published without them saying so. Links to what Loki does. filtered away → unchanged: "Nothing matches that" + clear the filters. Found by putting the local database into the state a new install starts in, rather than only the state mine happened to be in. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJkpuZ2F3GWrB6TLycwy4A --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
602a581c46 |
Organise navigation around the operator loop, give the header an identity, and stop Control contradicting itself (#797)
* refactor(shell): organise navigation around the operator loop, and give the header an account menu The sidebar carried 27 destinations in four sections, one of which was named "More" and held Approvals, Terminal, Prompts, Activity, System, Thoughts and the PUBLIC /fleet register — seven pages whose only shared property was that nobody had decided where they went. Alongside them sat a "Site" section: Mission, Philosophy, Roadmap, Whitepaper and Investors, in the signed-in app navigation. Loki is an operator console. Its surface answers three questions, so the sidebar now has exactly three sections and each one states its question: Now — what needs me? Today, Approvals, Feedback Fleet — what is my fleet doing? Control, Projects, Activity, System Command — how do I act on it? Loki, Terminal, Prompts Private stays PIN-gated below them. The marketing pages left the signed-in shell and stay reachable through Cmd-K, which now indexes NAV directly rather than whatever happens to be in the sidebar — curating the sidebar must never make a page unfindable. Alongside that, identity: - There was no way to sign out from the header, and nothing anywhere in the top bar said who was signed in. A grep of components/shell/ for "avatar", "UserMenu" or "ProfileMenu" returned nothing. Sign out, Settings and the private-zone lock lived in the sidebar footer, which is `hidden md:flex`, and were duplicated in the mobile Menu sheet's footer: two account menus, neither called one, and none where users look first. - AccountMenu now owns all of it, in the top bar, on every viewport. - The theme toggle moved inside it. It was the only control in the top bar drawn with a border and a fill (ui-theme-cycle-btn) while every signal beside it was a bare ghost circle (ui-topbar-btn) — a preference outweighing every piece of live state on the page. - SidebarFooter is deleted. Its collapse button was marked `md:hidden` inside a panel marked `hidden md:flex`, so it could never render on any viewport; SidebarBrand has always owned the working toggle. Two retired NAV entries are deleted rather than hidden: `agents` → /control and `atlas` → /projects pointed at the pages that replaced them, and since NAV_ITEMS is what AppTopBar and PageTitle scan for "which page am I on?", the first match won — /control would have been titled "Agents". Their redirect pages reference the targets, so the redirects stay honest. scripts/test/navigation.ts is rewritten to defend the new structure: every section must state its question, "more"/"misc"/"tools"/"site" are rejected by name, account items may not appear in the sidebar, marketing items may not, no two items may share an href, and the bottom bar must carry one entry point per loop section. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159PhgGrn6ccwfwVTJoTuYx * fix(control): stop the hero claiming "Idle" over a queue of six things Observed on prod: the Control hero read "Idle — nothing queued" while a panel titled "Needs you", badged 6, sat roughly a screen and a half below it, under a 23-project list. One page, one question — is anything waiting on me? — and two answers, with the confident wrong one on top. Two distinct faults, fixed together because either alone leaves the page contradicting itself. 1. The hero could not see the queue. deriveFleetPulse read agents, run outcomes and projects awaiting input, and nothing else, so the one queue on the page that literally counts things waiting on the operator was invisible to the headline that summarises them. It now takes `inbox` and ranks it last among the states that say something is up — a stall, a failure, a half-finished run and a blocked project all still outrank chores — but comfortably above "Idle". `unknown` is a separate state from `count: 0` on purpose. A queue we failed to read is not a queue we know to be empty; ControlInbox already refused to render silence as the answer "no", and the hero now refuses too. The count could not be lifted while it lived inside the panel rendering it, so the fetches moved to `useControlInbox`, called once in ControlPanel and passed down. One read, two consumers, one truth. It also removes a third copy of the /api/feedback/summary request from the page. 2. The panel was filed in the wrong tier. ControlPanel's own ordering rule says tiers 1-2 are about a human being blocked and "reporting never renders above blocking" — and a queue titled "Needs you" with a count badge is the definition of tier 2. It sat in tier 4. It now sits with AttentionBar and AgentEscalations, which it can afford because of how it was built: one line per group until opened, nothing auto-expanding, and nothing at all rendered when the queue is empty. Two rows above the fleet, not the ~1,400px of unbounded strips it replaced. The `inbox` state takes the warning dot rather than neutral grey, for the reason the `partial` state already does: grey beside the words "Waiting on you" is the page agreeing with itself in tone while disagreeing in substance. `unknown` stays neutral — that one really is "no idea". Four tests pin it: a non-empty queue is never Idle, an empty one still is, an unreadable one is not a claim of emptiness, and real trouble still outranks chores. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159PhgGrn6ccwfwVTJoTuYx * fix(design): un-invert the dark text ramp, and make token drift a build failure @bitbaum/design-tokens calls itself "the design single source of truth for OrangeCat, Loki and Solon". Solon proves it — its globals.css is 19 lines and imports the package. Loki's is ~5,800 and declares its own ramp, with the package present only as a devDependency used to generate the widget theme. A comment here said the quiet part out loud: "Loki still declares its ramp locally, so the value is kept in step by hand." Nothing was keeping it in step. Measured: Loki and the package disagree on 32 of the 36 tokens they both define, and the disagreement has a shape — someone transcribed the DIGITS between colour spaces without converting them. `--text-secondary` is `oklch(0.4 0 0)` here and `0 0% 40%` there; those are 30 of 255 apart. light: surfaces agree within 5/255; the TEXT ramp is 20-30 apart dark: text agrees within 7/255; the SURFACE ramp is 17-30 apart (Loki's ground is #010101, the fleet's is #121212) Comparing them exposed a real bug, which this commit fixes. Loki's documented ramp is primary → secondary → tertiary → muted, each quieter than the last. The light block follows it (0.1 → 0.4 → 0.58 → 0.72). The DARK block was written in the order primary/secondary/muted/tertiary with values descending in THAT order — so `--text-muted` sat at 0.65 while `--text-tertiary` sat at 0.59, and text marked muted rendered BRIGHTER than text marked tertiary. The two quietest tiers in the system, inverted, on the theme that is the default. The two values are swapped rather than retuned, so no new colour enters the system and the contrast range is unchanged. The rest is a gate, not a migration. Some of the divergence is deliberate: Loki is an operator console that sits beside a terminal, its near-black ground is a product decision, its borders are translucent overlays rather than opaque greys, and its typeface is Geist where the fleet's is Inter + Instrument Serif. Adopting the package wholesale would restyle every surface and every glyph of a running product in one unreviewable step. So scripts/test/token-drift.ts requires every difference to be DECLARED. A divergence listed in DIVERGENCES is a decision somebody signed; one that is not listed fails the build. Tokens that currently agree are pinned, so agreement cannot quietly lapse. It also asserts the text ramp descends in both themes, and complains if a token listed as divergent has since converged — which is how the list shrinks, one reviewable token at a time. It is picked up automatically by scripts/test-unit.ts (which globs scripts/test/*.ts), so it runs in `verify` and in CI without further wiring. Verified to bite: re-introducing the ramp inversion and silently retuning a pinned token each exit 1. Docs corrected to match the shell as it now is: CLAUDE.md claimed ThemeToggle ships in 8 places and described a "Today/Control/Projects + Loki + More" mobile nav; responsive-design.md described sidebar sections "Work / Private / Site" with account actions in two different footers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159PhgGrn6ccwfwVTJoTuYx * refactor(shell): stop two navigation surfaces answering a question already answered Loki ran six navigation surfaces at once — sidebar, top bar, the Profile/Chat/Control/Terminal strip, the mobile bottom bar, the Menu sheet and the command palette. On a phone at /control, four were on screen together and three were answering "where am I?". Two of them now stand down where they add nothing. FleetSurfaceGuide renders only with an active project. Its whole claim is that the four tabs are views of ONE project and that moving between them preserves it — but `fleetSurfaceHref(surface, null)` falls back to /projects, /loki, /control and /terminal, which are four sidebar entries. So with no project it was rendering the sidebar a second time, above every Control, Terminal and Projects page, preserving nothing. A navigation surface that carries no information the others lack is not a shortcut; it is a fifth nav system charging rent. AppTopBar drops its mobile page label on pages the bottom bar already names. Below md the bar shows Today / Loki / Control as labelled, highlighted tabs, so on those three the top bar's title was the third simultaneous answer after the bottom tab and the page's own heading. It still speaks on all 15 other destinations, where the bottom bar can only show "Menu" and genuinely cannot say. scripts/test/nav-surfaces.ts pins both, and pins them against the config rather than against a screenshot: it derives the projectless hrefs from fleetSurfaceHref and asserts each is a real sidebar destination (the premise the first fix rests on), checks every tab carries the project when there is one, and checks the label suppression uses the same isCurrentPath the bottom bar does — otherwise it would silently never fire. It also holds the Menu sheet to having no account footer, now that AccountMenu owns those actions. Verified to bite: reverting the strip gate fails the suite. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159PhgGrn6ccwfwVTJoTuYx * fix(ci): pre-push ran the wrong suite for scripts/test/ The hook classifies changed paths into three arms and runs the gates each one can break. `scripts/test/` was in the `_ops` arm, and that was backwards in both directions at once: • test:ops runs `scripts/hetzner/test-*.sh` and nothing else — verified: all 18 scripts it invokes are under scripts/hetzner/. No file under scripts/test/ can affect its result, so editing a unit test ran eighteen Hetzner shell suites for nothing. • scripts/test/ holds the 218 .ts files that ARE the unit suite (scripts/test-unit.ts globs the directory). The unit suite runs in the `_app` arm, which scripts/test/ did not trigger. So a broken unit test added under scripts/test/ passed pre-push: the hook never ran the suite that file is a member of. Now: `scripts/test/*.ts` → `_app` (tsc, lint, design, desktop, test:unit, test:home). `scripts/test/*gate.sh` → `_register`, the arm that actually runs the deploy-ref / not-behind / client-ledger / deploy-ready gates; they had no arm that ran them before either. `_ops` keeps hetzner and site-template. scripts/test/pre-push-routing.ts pins it by deriving both sides rather than restating them: it parses the hook's own `touches '<regex>' && _arm=1` lines, reads the scripts test:ops actually invokes out of package.json, and asserts each path reaches the arm that covers it. The failure mode this guards is invisible — a gate running the wrong suite still prints a wall of green. Disclosure, because it matters for how this commit is read: this also unblocks pushing this branch. test:ops fails 4 of 92 checks in a container running as root (the .env-repair cases assert file ownership against a systemd unit's User=), and that is not caused by this branch — confirmed by running it on a clean worktree of origin/main, where it fails identically, 88 passed / 4 failed. The routing above is a defect on its own merits and the fix is the same one either way; the side effect is stated rather than left to be noticed. Those 4 ops failures remain, unaddressed by this branch, on main. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159PhgGrn6ccwfwVTJoTuYx * chore(design): ratchet the dead ui-* rules in globals.css check-loki-classes.mjs holds `ui-loki-*` to zero in both directions — a class used but undefined, and a class defined but unused. The other ~1,000 `ui-*` rules had never been checked at all, and 35 of them are referenced by nothing. That matters more here than in most codebases. This repo's Layer 3 contract is that every recurring visual pattern gets a named class, so the class IS the decision. Someone looking for "how do we draw a metric card" finds .ui-control-metric-card, -value, -label and .ui-control-metrics-grid sitting in globals.css and reasonably concludes that is the house style. Nothing has used them in months. Dead CSS in a system built on that premise does not read as dead; it reads as load-bearing, and the next person builds to match it. It is a ratchet, not a hard zero, for the reason the dead-exports ratchet already is one: 35 rules is real work to remove safely, and a check that fails on day one is a check that gets switched off on day two. The number may not rise, and each deletion lowers it for good — the script fails in BOTH directions, so cleaning up without lowering the baseline is also an error and the gained ground cannot be given back. Dynamic class names are honoured: `ui-dot-${kind}` appears in source as the literal `ui-dot-`, so a token ending in a hyphen marks every matching rule used. Without that the check reports ~77 false orphans, which is how a lint earns being ignored. Eight such prefixes are in play. Also deletes .ui-mobile-nav-sheet-footer, which the previous commit orphaned when the Menu sheet's account footer moved into AccountMenu. Verified in both directions: adding an unreferenced rule fails with "rose to 36", and deleting a genuinely dead one fails with "fell to 34 — lower the baseline". The first attempt at that second test was itself wrong and is worth recording: deleting `.ui-btn-pill {` changed nothing, because the class is also targeted by a compound selector 2,500 lines further down. The checker was right and the test was wrong — which is exactly the sort of thing a rule counted by hand gets wrong. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159PhgGrn6ccwfwVTJoTuYx --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
d14796ca4a |
fix(widget): the mode chips were unstyled on every customer site (#796)
#734 pasted the .modes / .mode rules into the middle of the .dot rule's declaration block, and left .dot's `background` unterminated. CSS error recovery swallows everything from that declaration to the matching brace, so two things were broken on every site embedding /widget.js: - .dot lost its own `flex: none` and `box-shadow` halo, - .modes, .mode, .mode.on, .mode:disabled and .mode-hint never applied at all, so Report / Chat / Watch rendered as naked 16px text instead of chips. Neither is catchable by tsc — the CSS is a template string. The same rules also carried literal hex fallbacks (#333, #aaa, #f60, #fff, #888) behind var() lookups. The widget's Shadow DOM sets `all: initial` and defines no custom properties, so those var()s could only ever resolve to their fallback: a hardcoded colour wearing a token's clothes. Every colour now interpolates from the boot theme, which is generated from @bitbaum/design-tokens, like the rest of the file. Ratchet, so this class ends here: widget-theme-from-tokens now parses both emitted stylesheets and fails on a nested block inside a plain rule, an unterminated declaration, any var(), and any hex that is not a colour the generated theme supplied. All three faults were proven by mutation. Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
ae92bde49e |
test(access): pin the project permission boundary, which nothing tested (#795)
Priority 5 of the 2026-09-17 review asks for the journey to be proved
with an editor and a reporter account. The live two-account walk still
needs two real sign-ins and is NOT what this does — see below. This is
the half that needs no accounts, and it turned out to be missing
entirely.
`getProjectAccess` is the one authorization decision every project
surface reads, and the rule inside it —
canEdit: member.role === "editor",
canManageMembers: false,
— lived in a function that cannot be imported without a DATABASE_URL. So
it had no test. The only way to find out that a viewer could edit, or
that an editor could add members, was to sign in as one and look. A
boundary whose only proof is a manual walk regains a hole the first time
someone adds a role.
The rule is now its own pure module and the query reads it. Behaviour is
unchanged — same two expressions, one place — and it is a Record over
ProjectRole, so adding a role without deciding its capabilities is a
type error rather than a silent `false` or, worse, a copy of another
role's answer.
Six checks, including two that hold for EVERY declared role rather than
the two that exist today: nobody but the owner can manage members, and
no collaborator role is silently as powerful as the owner. That is the
part a future role would break.
Proved by mutation: granting `viewer` canEdit fails with "a reporter
must not be able to dispatch work" — a viewer is the role a reporter
gets on the project they filed against, so that assertion is the
tenancy boundary itself.
WHAT THIS DOES NOT DO: it does not prove the end-to-end journey with two
real accounts. That needs credentials I do not have, and creating
accounts is not something to do unasked. Priority 5 stays open for the
live walk; this makes the rule it would be checking impossible to break
silently in the meantime.
tsc clean, lint 0 errors, test:unit 205/205.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
54ee73791f |
feat(control): say what a dispatch will do before it is dispatched (#794)
Priority 4 of the 2026-09-17 review: "Show agent, model, machine, and known cost/quota information before dispatch." All three were already settable on the project profile — agent, "Runs on", Model — as three separate controls, stacked, and nothing stated the combination. So the operator chose a builder in one row, a model two rows down, pressed a prompt button, and the first statement of what actually ran arrived afterwards, on the run record. Now, directly above the prompt buttons that dispatch: Dispatch runs Claude Code · opus · This computer [last run $0.42] COST IS THE LAST RUN'S, AND SAYS SO. What this dispatch will cost cannot be known before it runs, and a predicted number beside a button reads as a quote. What the previous run on this project cost is measured, and it is the best available answer to "what am I about to spend" — labelled as the past, in the tag and in its title text, never as an estimate. A real sub-cent run renders "<$0.01", not "$0.00". Rounding a run that cost something down to free is exactly the move that turns a measurement back into a claim, and it is pinned by a test. QUOTA IS EVIDENCE, NOT A BLOCK. The one piece available without asking anything: the previous run here died with capacity language (looksLikeAgentCapacityIssue, the same predicate the provider chooser uses). Quota refills, so the caution says "may still be spent" and leaves the decision with the operator. An ordinary crash is not evidence about quota, which is also pinned. Nothing is invented: a project that has pinned no builder gets no machine in the sentence, and an agent with no model choice gets no empty slot. On the standing model instruction — Opus preserved, Fable excluded: there is nothing to exclude. `fable` does not appear anywhere in this repo (the two grep hits are the word "undiffable"), and this change adds no model list of its own; it renders whatever the agent registry already offers. Tests: 7 cases, proved by mutation — dropping the sub-cent branch fails with actual '$0.00'. tsc clean, lint 0 errors, check:design ok, test:unit 205/205. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
46ea5d57a5 |
fix(loki): a severed answer looked exactly like a finished one (#793)
Found by using the chat. Asked Loki a question on prod; it answered in 10.8s and the reply ended mid-word: - The active Claude sessions reported right now are running on `research- An unclosed backtick, a dangling hyphen, and nothing anywhere saying the answer was incomplete. The stored row is 243 chars and genuinely ends there, so this was severed at generation, not at render. `grep -rn finish_reason src/ home/` returned ZERO. The field rides the same frames this code already parses for `usage` — the one field that separates a finished answer from a severed one — and both readers dropped it: readBufferedBody destructures only `message`, readStreamedBody only `delta` and `usage`. So there was no way for anything to know, and a fragment was stored, billed, and rendered exactly like a complete reply. This is not new. `frontier/propose.ts` carries a comment about an answer "cut in half. Observed in prod at maxTokens 3000", worked around by raising a number rather than by noticing the condition. And sse-stream.ts opens by warning that "a stream that drops frames does not fail — it silently truncates an answer", then never reads the vendor's own statement about it. What this does NOT do is guess. It reads the reason, classifies it, and says so. `cutOff` is carried on the turn but nothing renders it yet: what a severed answer should LOOK like is a product decision, and the grounding `Violation` channel that would be its natural home is owned by @bitbaum/ai-kit, so widening that is a change to make there, deliberately. Three rules worth keeping, each pinned: - ORDERING. The frame carrying `finish_reason` routinely carries an empty delta, so the stop reason must be read BEFORE the `if (!delta) return` guard. Read after it, the field is dropped and the answer looks whole forever — the original bug, reintroduced. - SILENCE IS A THIRD STATE. A vendor that omits the field has told us nothing. Reporting that as a problem would fire on every quiet provider, and a warning that always fires is one nobody reads. - AN UNKNOWN REASON IS SUSPICIOUS, NOT FINE. Vendors add stop reasons; a new one meaning "cut off" must not read as healthy merely because the switch predates it. Unrecognised values are surfaced verbatim, named. Measured before writing any of it: 1 of 183 stored assistant replies is truncated — this one. Rare, which is exactly why it needs a machine to notice rather than a reader. (My first detector claimed 28; it was wrong — 11 of 12 samples simply ended with a URL. The honest count came from reading them.) Proved by MUTATION, both ways: moving the read below the delta guard fails 2 of 9 cases; defaulting an unknown reason to "fine" fails 1. verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings), check:design (10), check:desktop, test:home 140/140. test:unit 203/205 — activity-time-zone-stable and telegram-allowlist fail with "probe failed:" and an empty reason; both need a live server and this diff touches neither them nor anything they import. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
2d80b507ef |
fix(feedback): ask where a run ACTUALLY went, not where a new one would go (#792)
Risk 3 of the 2026-09-17 review: "Feedback attach-work falls back from closed pending command to current project routing preference. A current setting cannot prove where a historical attempt ran." Exactly right. The channel resolution was: pending row (open) ?? pickDispatchChannel(project) The open row is gone for most of a run's life — the runner stamps executedAt on its inject-ack, within ~8s of injecting — so in practice the second half decided almost every finished run. And that half is a LIVE PREFERENCE. Flip a project from This computer to Cloud and every finished local run starts claiming it ran on the box, with its offline verdict computed against a machine it never touched. The fix needed no new state, because the record already existed. The executed pending_commands row carries the channel it was handed to, in its payload, and getInjectAcksByRunIds was already reading exactly those rows for the same runs — it just never selected the field. So the immutable execution identity of the attempt was one property away the whole time. Now the order is an order of EVIDENCE: 1. the open pending row — this attempt, right now 2. the executed command — this attempt, recorded when it was handed 3. the project's setting — where a NEW dispatch would go today Only the first two are about the attempt being described. The third stays as the last resort because a run that never reached a builder has no recorded channel at all, and there the dispatcher's own rule is the best available guess. The channel lives in the jsonb payload rather than a column, so it is validated the same way the open-row reader already validates it: an unrecognised value is not a channel. Tests: two cases — a project now set to Cloud whose attempt ran local (the recorded fact wins, and the offline verdict follows it), and an attempt with no recorded channel (falls back). Proved by mutation: restoring the old expression fails "the recorded attempt outranks the project's current preference". tsc clean, lint 0 errors, test:unit 204/204. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
7cbdbf0db5 |
fix(providers): scope the installed list to the builder that would run it (#790)
Risk 2 of the 2026-09-17 review: /api/providers read
getRuntimeSnapshot(userId) — no channel.
That function's own doc says what the channel-less form returns:
"whichever channel pushed last". Both builders push their own row every
~5 minutes, so which machine's capability report the chooser saw was
decided by a race between two heartbeats. A cloud push could make a
laptop-only agent read "not installed"; a laptop push did the same to
the box. The chooser DISABLES rows on that evidence, so this was a
confident claim about a different computer.
The project already knows where it would dispatch —
pickDispatchChannel() is the SSOT for that decision — so now we ask that
channel. Without a project there is no "the" builder, so the honest
input is the union across this user's builders: an agent installed on
ANY of them is launchable somewhere, and only an agent no builder
reports is genuinely absent.
Unknown stays unknown. No row for a channel means null, not [] — the
three-state rule this module is already built on. Rendering silence as
"none installed" would disable every alternative, which is the one
control the operator came to that row for.
And the claim is now stamped. `evidence: { channel, observedAt }` rides
along, and the chooser says "Installed list as observed on This computer
(Fleet Runner), 4m ago" — or, when nothing has reported, that
availability here is unknown rather than empty. A capability claim with
no machine and no time reads as "true now, everywhere"; it is neither.
Lint caught a real defect mid-change: describeProviderEvidence took a
`now` it never used, because the phrasing comes from timeAgo(), which
reads the clock itself. A parameter the function ignores is worse than
none — it makes a test look deterministic when it isn't — so it is gone
rather than papered over with an underscore.
Tests: three cases, proved by mutation — disabling the unknown branch
fails "The input did not match /unknown, not empty/". tsc clean, lint 0
errors, test:unit 204/204.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
14967a376d |
fix(feedback): a run that streamed and then went quiet is on an offline machine too (#789)
#769 removed "Open Terminal" from runs whose builder is offline, on the grounds that it points the operator at a PTY on a switched-off laptop. It guarded on `!lastProgressAt`, so it only ever reached runs that never streamed a byte. A run that DID stream and then went silent kept the old sentence — and the machine is just as off. The row read: Needs you · Open Terminal — or Retry Worked 32 min, silent 15 min Every word true except the instruction, which is the only part that asks the operator to do something. Freshness has already expired by the time this branch is reached, so the silence is not the agent thinking; when `builderOffline` is also true, the machine carrying it is gone. Now it names that, and asks for the thing that would actually help: Needs you · Open Fleet Runner on This computer — or use cloud builder, then Retry Worked 32 min, then the This computer (Fleet Runner) builder went offline — silent 15 min. The diagnostic is observation only. Whether the work survived on that machine is not something this can see, so it does not say — it reports what the run achieved before the builder vanished and how long ago. The ask is identical for both offline readings (only the history differs), so it now lives once in `builderOfflineAsk` rather than being typed twice and drifting. An online builder is untouched: the existing "Open Terminal — or Retry" reading still fires, and its test still asserts `watchable: true`. Tests: two cases, local and cloud, proved by mutation — disabling the new branch fails with "must not send the operator to a terminal on an offline machine: Open Terminal — or Retry". tsc clean, lint 0 errors, test:unit 204/204. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
507a8d9066 |
fix(terminal): the empty terminal offered to start an agent in the wrong project (#788)
Found by using the page. The Terminal was scoped to `loki` — the breadcrumb said `loki`, and the Profile/Chat/Control/Terminal strip linked to `/control?focus=loki` and `/loki?project=loki`. Two inches below, in the same render: "Open on Control" -> /control (scope dropped) "Ask Loki" -> /loki (scope dropped) the launch form -> "Bitbaum" (first project in the list) So the one obvious button on an empty terminal would have started Claude in the wrong repository, and nothing on screen said so. The cause is that this screen had its own idea of "the current project": the ATTACHED tab, which is null exactly here — nothing is running, that is why the empty state renders at all. Everything derived from it quietly lost the scope the page was still displaying. The page already had the right answer. `fleet-context` is the SSOT the tab strip reads, and TerminalSurface already WROTE to it (rememberFleetProject) without ever reading it back. So this is mostly deletion: the reader is extracted from FleetSurfaceGuide into useFleetProject() and used in both places, rather than copied into a second one. Two details worth keeping: - The launcher DERIVES its selection instead of seeding useState. The scope is null on the first render (it comes from a store the server cannot read) and real a tick later, so an initialiser would capture the null and go back to picking the first project — the bug, reintroduced by the fix. Same shape the agent select already used: the operator's own pick wins, and until they make one the scope answers. - A project in scope but not launchable is still not pre-selected. `launchable` is filtered to projects with a linked directory; offering one without would draw a button that fails every time. preferredLaunchProject is pure and exported so the rule is pinned without React — the defect is invisible to any test that renders nothing, and reads as a styling choice on screen. Proved by mutation: restoring the old rule fails 2 of the 5 cases with "expected loki, got Bitbaum". verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings), check:design (10), check:desktop, test:home 140/140, and every check:*/gate member green. test:unit 200/202 — activity-time-zone-stable and telegram-allowlist fail with "probe failed:" and an empty reason; both need a live server and this diff touches neither them nor anything they import. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
1cc39fb361 |
feat(events): a weekly scout for what is worth going to (#787)
The operator asked to hear about events worth attending instead of finding them by accident after they had happened. Finding events is the easy half; sending a message that is still worth opening in week six is the hard one. So the shape is borrowed from what already works in this repo rather than invented: ONE MESSAGE, NOT ONE PER EVENT. The 2026-08-05 disk-alert storm (40 pings in three hours) is the standing lesson about per-item notification. EVERY LINE IS ACTIONABLE. Each suggestion is a real draft in the approval queue with its own one-tap Approve link, so "that looks good" is a tap and it is in the calendar — not a link to a listings page and a note to self. The queue, the signed links and the booking drain all already existed and are already proven; the scout's whole delivery story is "write a draft". A CLASH IS NAMED. Each suggestion is checked against the calendar mirror, so a Thursday gig that collides with an existing meeting says so before it is accepted rather than after. FOUR DECISIONS WORTH THE REVIEW: 1. SEARCH COMES FROM ai-kit/web. fleet/SHARED.md owns this and says plainly: do not hand-roll fetch-and-summarise. That package already has the backend chain (self-hosted searxng → brave → tavily), an SSRF-safe reader for urls the MODEL chose, and a three-valued answer. `could_not_look` is not `nothing`: a dead backend must never be reported as "there are no events in Zurich this week". Writing a second client here would have reinvented that bug — and memory already records the specific shape (a stock searxng answers JSON with 403, which reads as "no results"). 2. ONE MODEL CALL PER RUN, NOT ONE PER RESULT. Extraction has to be a model — snippets carry dates as prose, in two languages — but the AI budget is rationed and shared across ten apps, so per-result extraction would spend a day's allowance on one digest. Every snippet goes into a single batched call. 3. THE MODEL IS NOT TRUSTED ABOUT TIME. It is told today's date and told that omitting is always correct; whatever comes back is screened AGAIN in pure code, which drops undated, past and out-of-horizon entries regardless of what it claimed. This is not hypothetical: the first search run while building this returned a Zurich meetup dated September 2025 as its top hit. 4. THE CAP IS THE PRODUCT. The operator selected all four purposes, so ranking cannot lean on exclusion — six per week is what stops a curated handful becoming a feed. Better to miss a good event than to send the message that teaches him to swipe past the next one. Rejections are the memory: a suggestion turned down is never proposed again, however it is spelled, so the operator says no once rather than every week. Tests: 21 cases on what reaches the digest, written from the side that hurts — the guessed date, the duplicate, the rejected thing returning — with the real 2025 listing as a fixture. The cron installer gains a weekly OnCalendar form (existing daily/hourly entries expand exactly as before) and the scout is added to the one list that both writes AND enables timers, because listing a job twice is how one gets a timer and never runs. Deliberately NOT built: a separate same-day reminder. Approved events go into Google Calendar, which already reminds; a second notifier would be the second one of something that works. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
c90638c311 |
fix(feedback): a dispatch waiting its turn is named, not blamed (#786)
Loki runs one agent per project: while a run is open, the queue deliberately
withholds the next command for that project (fifoEligibilitySql). Correct
behaviour. But nothing downstream knew that was the reason a command sat
unclaimed, so both surfaces guessed, and both guessed wrong — in opposite
directions, on the same row:
row: "Retry — or Open Terminal for why it never started"
panel: "Waiting for This computer to claim. If this stays put, confirm
Fleet Runner is polling"
Nothing had failed. The project had a healthy run in flight, both builders
were connected and claiming everything else, and Retry could only have
enqueued a second command the same gate would withhold for the same reason.
Found by pressing Implement on the live site and then reading the queue
(2026-09-17, command 98c6a42a: created 16:01, claimed 16:48 the moment the
run ahead of it closed).
The gate's rule is now one SQL fragment — olderOpenRunSql — composed by both
the claim query that enforces it and a new findQueueBlockers that answers
"what is ahead of this run". The decision the queue makes and the sentence a
person reads come from the same predicate, so they cannot drift.
The row now says which run holds the lane and that the wait ends by itself;
the panel says the same thing instead of sending the reader to inspect a
builder that is doing nothing wrong. Both keep their old copy when no blocker
exists, because "nobody is claiming this" is still a real and different fault.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
036e4e3810 |
fix(loki): the assistant composer was deleting your newlines (#781)
* fix(loki): the assistant composer was deleting your newlines Found by using Loki to develop Loki. 'Brief Loki' on /today prefills the assistant with a multi-line prompt SummaryBar builds - heading, the day's counts, then the question, joined with newlines. The field it lands in was an <input>, and an <input> cannot hold a newline, so the browser stripped every one. Measured live on 2026-09-18: the value was 'Daily brief - Friday, 18 SeptemberWhat should I focus on today?' with a newline count of ZERO. The product generated a structured prompt and its own field destroyed the structure - no error, nothing to notice, and the result still reads as roughly sensible prose, which is why it survived. It is also the composer for the thing this product is FOR. A brief is several sentences by nature; a single-line box that scrolls horizontally shows about forty characters, so you cannot read back what you are about to dispatch. It is now a textarea that grows to a ceiling, with Enter to send and Shift+Enter for a line break - the convention the full-page composer already uses, whose auto-grow this mirrors rather than reinventing. SECOND BUG, same prompt: .filter(Boolean) deleted the paragraph breaks. The array carries two deliberate empty-string separators, and an empty string is falsy, so the filter meant to drop absent counts dropped those too. Even in a textarea the three parts would have run together. The builder moves to lib/today-brief.ts because it could not be tested where it was - an inline array inside an async server component. Six cases now pin it, including the exact 'SeptemberWhat' shape. Proven by mutation: restoring .filter(Boolean) fails two of them. 202/202 unit test files pass; the new test is picked up automatically by scripts/test-unit.ts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * chore(format): prettier the today-brief test CI's verify runs prettier --check on the whole tree; I had formatted the files I edited but written this one afterwards, so the check caught it and nothing else did. Exactly what that gate is for. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
a5e95e40da |
fix(control): say where a run's change got to, not just how the run ended (#785)
"The feedback run delivered #757, but its record ended as partial. Shipping and outcome reporting still disagree." They were not disagreeing. They were answering different questions, and Control only ever asked one of them. A run's `outcome` grades the AGENT'S ATTEMPT and is stamped once, at close — necessarily before the pull request is merged and the box redeployed. The fix ledger (`payload.fix`) grades the CHANGE, and keeps moving after the run is closed: pr_open -> merged -> deploying -> deployed. Both records were right. Control rendered the first and never read the second, so a run that closed `partial` and then merged and deployed read on the card as unfinished work — while the Feedback row, two surfaces away, already said "PR #757 · merged". The ledger was already there and already correct: `runFinishedWell` includes `partial`, so partial runs have been tracked through merge and deploy all along. Nothing needed reconciling; the control plane just never carried the field. `serializeLatestRun` now passes it, validated the same way `evidence.kind` is — an unknown state drops the block rather than printing a raw enum at the operator. One consequence worth calling out: the card's "no commit" warning is read off the run's own handoff, and a merged, deployed pull request outranks it. Before this, a run whose handoff forgot the SHA showed "no commit" directly beside "merged and deployed". NOT a closure-policy change, deliberately. Promoting `partial` to `success` after the fact would be the obvious move and it is wrong: a merged pull request does not prove the run's definition-of-done bar was met, and `partial` is non-failing, so an undeserved upgrade silently cancels the escalation ladder. The verdict stands; the card now also reports where the change is. The long-form copy for these states stays in feedback/work-phase.ts — that is the Feedback row's voice. This is the short form for a card with one line to spend, reading the same FIX_SHIP_STATE constants so a new state cannot appear in one and not the other. Tests: 8 cases, proved by mutation — returning null for DEPLOYED (the old silence) fails "a run that shipped says so, whatever its outcome was". tsc clean, lint 0 errors, test:unit 202/202. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
98e775a8f1 |
fix(feedback): a pull request the run never opened is not proof the fix shipped (#784)
The feedback ledger resolves its pull request from PROSE the agent wrote, so a
handoff that merely mentions a number ("same approach as PR #42") hands the
ledger someone else's work. If that pull request happens to be merged and
deployed, the row rendered "Live · confirm".
That is the worst sentence this surface can produce. The queue exists to answer
one question — is anything waiting on me — and a false Live is not a cosmetic
error, it removes the row from that answer. A report nobody has acted on stops
asking.
Loki already knew better. `prOpenedByRun` has guarded the MERGE since the
retry case that first exposed this, holding at NOT_OURS on exactly this
evidence. But `deriveShippingFromPr` ran unconditionally a few lines earlier,
so the same pull request the machine refused to touch was still good enough to
tell the operator their report had shipped. Refusing to act on evidence while
publishing a conclusion from it was never coherent. One rule, both decisions.
`prPredatesRun` is deliberately not the negation of `prOpenedByRun`. Merging
asks "may I act?", where unknown means no; reporting asks "may I claim this
shipped?", where unknown means leave the ledger alone — demoting a real fix to
"nothing shipped" because GitHub omitted a created_at would break every honest
row to catch a dishonest one. Both return false on missing or unparseable
timestamps, so only a PROVEN ordering moves anything.
The discounted pull request stays on the ledger and the row names it. "No pull
request was found" would be false and would send the reader hunting a parser
bug instead of the number they can check in one click.
Pinned against the real timestamps from dogfood-site-sep10-1201 (2026-09-11),
where the wrongly-named PR #1 predates its run by six hours and the real PR #3
lands two minutes in. Also moved this suite's success log to the last line: it
sat two thirds up, so the new failure printed underneath "✓ passed".
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
343a1c8491 |
fix(dispatch): say how long it has been, so a busy builder differs from a dead one (#782)
Observed 2026-09-18 while dispatching real work: the run sat on 'Delivered to agent - waiting for a completion handoff' for five minutes. No elapsed time, no heartbeat, no log tail. One second in and twenty minutes in read identically, so the only way to learn whether anything had happened was to open another window and read git log. Every non-terminal state now carries its elapsed time: picked-up counts from claimedAt, delivered and running from executedAt. Terminal states do NOT - a finished run says what happened, not how long it has been happening. 'waiting for a completion handoff' is the internal name for the mechanism. What a person needs is that the agent has the work and has not reported back, so that is what it says now. Deliberately NOT a judgement. There is no measured baseline for how long a run should take, so this reports how long it HAS taken and leaves the conclusion to the human. 'Taking longer than usual' would be a claim nothing here can back. elapsedLabel returns null rather than '0s' for a missing or future timestamp: a confident zero is worse than silence. Proven by mutation - restoring the old silent line fails with 'waiting detail must carry elapsed time'. Note: activity-time-zone-stable and telegram-allowlist fail in this suite and are PRE-EXISTING - they fail identically in a worktree that touches neither file, and both are probe tests needing a live server. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
7523a25b47 |
fix(control): a half-finished run is not evidence that things are working (#780)
Found by using Loki to develop Loki on 2026-09-18. The loki project card read '5 of last 5 partial' while the hero above it said only 'Building', with no hint that nothing had landed in days.
deriveFleetPulse counted partial as succeeded: const succeeded = recent.filter(r => r.outcome === 'success' || r.outcome === 'partial'). So a fleet whose every recent run came back partial always had a non-zero succeeded, and the failing branch (failed >= 2 && succeeded === 0) could never fire. Two feet away on the same screen, OutcomeStreak renders the same outcome with ui-tag-warning. One fact, graded two ways in one view - and the forgiving reading drove the headline.
partial is correctly excluded from FAILING_OUTCOMES: a run that delivered something is not a hard failure and must not trip the dispatch brake. But 'not a failure' and 'proof things are working' are different claims, and only the first is true. succeeded now counts success alone.
Three consequences, each its own fix. A fleet that only half-delivers gets its own verdict ('Half-finished') instead of falling through to 'Idle - nothing queued', which reads as a clean desk when it is a pile of unfinished work. 'Building' keeps its headline but stops being silent: it now names a partial streak instead of returning detail: null. And the hero renderer no longer discards that sentence - it overwrote sub with 'N agents working' unconditionally, so the warning would have been dead code.
OutcomeStreak says 'stopped part-way' instead of 'partial'. The summary already earned its place by replacing bare glyphs with a sentence; saying 'partial' only moved the cipher from a symbol to a term.
Proven by mutation: restoring the old succeeded line fails the new test with 'partials must not vouch for a failing fleet'. 57/57 pass with the fix in place.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
eadad2711f |
feat(calendar): warn on the card when a proposal clashes (#777)
* feat(approvals): standing approvals + one-tap decisions from Telegram
Asking Loki in Telegram to put an appointment in the calendar did not put an
appointment in the calendar. It sent you to a website.
Three separate causes, all fixed here:
1. THE CHAT HAD NO ROAD TO THE CALENDAR AT ALL. `gog calendar create` is
blocked on the box by the safety shim, and the fleetcrown skill could only
decide drafts that already existed — it had no way to create one. So the
agent hit the shim, read "route it through the approval queue", and passed
that on as advice. Adds `fc.sh book`, which proposes a structured event
through /api/actions/propose, and rewrites the shim's refusal to name it.
The shim still blocks every external Google write; unattended agents have
gained nothing.
2. THE GATE WAS ON THE WRONG SIDE OF THE REVERSIBILITY LINE. The queue enforced
"nothing runs that the operator did not TAP", which is stricter than the rule
it stands for ("nothing runs that the operator did not APPROVE"). For an
event in your own calendar — private, self-only, undone by deleting it — the
difference was pure latency (2026-08-04: proposed 14:15, booked 21:02).
Standing approvals let that yes be given once, in advance, with three rails
in code rather than in a docblock: eligibility is hard-coded (calendar events
and commitments only — never anything that reaches another person), the
payload is re-checked at decision time (guests mean invitations, so those go
back to the queue), and unknown is never yes (no resolvable time, or a slot
already past, queues). Default on for calendar events; toggle at /approvals.
3. THE NOTIFICATION HANDED BACK A CHORE. "2 actions are waiting… <url>" states
a problem and leaves the answer behind a login. Decisions now arrive as a
card carrying what/when/where plus one-tap Approve / Reject / Edit buttons,
backed by HMAC links scoped to one action and one verb — so a decision needs
no session and works when the gateway is down. Still two messages and only
two: one when a decision is owed, one when the effect really happened.
Also fixes a real data bug: propose_action had no event date fields, so the WHEN
of an appointment had nowhere to go and arrived as prose in `body`, which a Groq
pass then had to guess back — a model re-deriving a value the model one step
earlier knew exactly.
Behaviour that did NOT change: emails, messages, dispatches, and person-book
writes still require a per-item yes, and always will — they are ineligible in
code, and a preference row naming one authorises nothing. Every auto-approval is
audited with `via: standing-rule` and announced, so nothing is done in the
operator's name silently.
Tests pin the parts that must not be trusted: 37 cases on the standing-approval
rails (asserted from the side that hurts — a false `auto: true`), 21 on token
forgery and tampering.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(chat-skill): the chat's whole Loki skill was dead, and unversioned
Found while testing the previous commit end-to-end, and it is the largest of
the reasons appointments never got added.
On 2026-09-14 the product was renamed to Loki and `calendar-drain.env`'s keys
were renamed with it. The chat agent's skill script, which reads that file, was
not — because it lived only on the box, where no gate in this repo could see
it. Since then every command it offers has aborted on its first line:
line 14: <OLD>_AGENT_TOKEN: <OLD>_AGENT_TOKEN missing in calendar-drain.env
Verified live on bitbaum just now. So from Telegram the operator could not list
the approval queue, could not approve or reject anything, and could not
dispatch — silently, because a skill that errors just makes the agent talk
about something else instead. The only surviving route to a decision was the
website. That is the complaint, and it had a cause older than the UX.
Fixes:
- Renames the skill to `loki` (the retired product name is forbidden in this
repo by scripts/hetzner/test-no-retired-name.sh — which caught this commit,
correctly, when the box files were first imported verbatim) and reads the
env keys the file actually has.
- The installer REMOVES the superseded skill directory rather than leaving it.
Two skills claiming the same job, one of which cannot run, is how the agent
kept choosing the broken one.
- The installer now runs `loki.sh pending` as the openclaw user and fails if it
cannot authenticate. That is the check which would have caught the rename on
the day it happened: run the thing, as the user who runs it, and require real
output. Every other verification in that script only asserted that files
exist, and files existing is exactly what was true throughout the outage.
Also closes a gap in the previous commit: an auto-approved COMMITMENT executed
without telling anyone, while the comments claimed every auto-approval is
announced. Calendar events are announced from where gog succeeds (asynchronous,
on the box); everything else finishes inside enqueueAction, so that is the only
place that knows it finished at all. A standing approval nobody is told about
is not a standing rule, it is a silent one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(install): keep the gog shim parseable, and prove the block still fires
The replacement text I substituted into the shim carried double quotes. It
lands inside `block(){ echo "…" >&2; }` — a double-quoted bash string — so a
quote in the middle of it closes that string early and leaves the shim a
syntax error. Every gog call on the box would then fail, reads included, and
the calendar drain's real bookings with them: an install step meant to improve
an error message would have taken out the calendar entirely.
Caught by tracing the sed against the shim's actual text rather than running
it. Two checks added so the next one is caught by the machine:
- `bash -n` on the shim after the edit — it is a shell script we just modified
in place, so prove it still parses before trusting anything else about it.
- Actually attempt a calendar write as the openclaw user and require it to be
REFUSED. The old check grepped for the rule's text, and a rule you can read
in a file is not a rule you have seen refuse anything.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(ui): use tokens this design system actually defines
The new approvals control and decision page reached for `text-brand`,
`accent-brand`, `bg-surface-hover` and `rounded-card`. None of those exist in
globals.css — the real names are `accent-text`, `surface-raised` and the
`radius-*` scale. Tailwind emits nothing for an unknown utility and reports no
error, so the checkbox would have rendered browser-default blue and the hover
state simply would not have happened, on a page whose entire job is to be
tapped once and trusted.
The design check passes either way: it forbids arbitrary values (`bg-[#fff]`),
which is a different failure from naming a token that was never defined. Caught
by grepping whether any other component uses these names — none did, which is
the tell.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(notify,install): two silent no-ops found by running the thing
Both found by exercising the deployed feature end to end rather than reading
it, and both are the same failure: a step that could not succeed, reporting
nothing.
1. A REFUSED TELEGRAM SEND WAS INVISIBLE. sendTelegramMessage reports a bad
token, a blocked chat or an API error as `{ok:false}` — an ordinary return
value, not an exception — so the try/catch around it caught the case that
never happens and ignored the case that does. That matters more here than
in a normal notification: the confirmation message IS the review mechanism
for actions a standing rule took without asking. If it stops arriving, the
operator does not notice Loki went quiet; they notice Loki apparently
stopped doing things, which is the opposite of what is true. Both senders
now log a refusal.
2. THE INSTALLER'S CLEANUP STEP CLEANED NOTHING. It globbed the skills
directory as the ssh user, who cannot traverse the openclaw home: the glob
matched nothing, the loop ran zero times, and the script printed its success
banner. The superseded skill was still installed afterwards — the exact
"two skills claiming one job, one of them broken" state the step exists to
prevent, left in place by the step that prevents it.
Fixed by running the loop under sudo, and then ASSERTING no other skill
ships the old entrypoint. Trusting the loop's own silence is what let the
first version pass; verified on the box that it now removes the directory
and that the assertion sees an empty result afterwards.
Verified live on bitbaum after deploying the parent change: booking from the
chat skill returns auto-approved, the drain books it, the row reaches executed,
and the event is really in Google Calendar at the right time. Test event
deleted.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(auth): the one-tap approval link redirected to sign-in
The feature whose entire purpose is "decide from your phone without logging in"
sent you to a login page. Found by tapping it against production, not by
reading it:
GET /a/<token> → 302 /sign-in?callbackUrl=/a/<token>
Route auth here is one negative-lookahead regex in src/proxy.ts listing the
prefixes served without a session, and `a/` was not among them. Every unit test
on the token passed throughout — 21 of them — because they tested the TOKEN.
Nothing tested whether the route could be reached, which is the part that was
broken. A signature that verifies perfectly behind a login is worth nothing.
Adds `a/` with the same justification the file already records for `share/task/`:
the minted token IS the credential, the holder has no account by design, and the
link decides exactly one action with one verb (lib/actions/action-link.ts).
THE TRAILING SLASH IS LOAD-BEARING, and that is why this commit also adds a
gate. The list holds bare prefixes, so `a` instead of `a/` would have made
/approvals, /api/*, /agent — every path starting with that letter — publicly
readable, and nothing would have looked broken: the app would have worked
better, with nobody asked to log in. That is the one direction a reviewer will
not notice.
scripts/test/public-matcher.ts reads the real regex out of the real file and
asserts BOTH directions: what must be reachable without a session, and what must
not. Proven by mutation before committing — with `a` in place of `a/`, eight
assertions fail loudly (/approvals, /api/actions/pending, /api/me/preferences
among them). A test that only checked the public list would have passed just as
happily on a regex that made the whole app public.
Verified: pnpm verify green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feat(calendar): warn on the card when a proposal clashes
An approval card asks "shall I book Thursday 14:30?" and could not answer the
one question most likely to change the answer: is Thursday 14:30 already taken?
On 2026-09-17 a test booking for 14:30–15:30 was approved on top of an existing
15:00 meeting and the card said nothing at all.
It could not know. The calendar lives behind `gog`, authenticated on the
operator's machine only; the cloud control plane — where proposals are made and
cards are sent — gets `runtimeOnly: true` and an empty list.
So the box mirrors what is OCCUPIED, one way, and the card reads it:
home/calendar-drain.ts → POST /api/calendar/busy → calendar_busy
The drain already held both halves this needs (gog, and the ck_* token), so it
gains a second, slower clock rather than a second process. Start, end and title
only — no attendees, no descriptions, no locations leave that machine. Google
stays authoritative; nothing here is ever written back.
FOUR DECISIONS WORTH THE REVIEW:
1. REPLACE THE WINDOW, DO NOT MERGE. An event cancelled in Google stops
appearing in what the box sends; a merge would keep it forever and produce a
phantom clash on a slot that is free. A warning that cries wolf is worse than
no warning, because it is read exactly once.
2. BACK-TO-BACK IS NOT A CLASH. Overlap is half-open, so 14:00–15:00 against
15:00–16:00 stays silent. Inclusive ends would flag every adjacent pair in a
real diary and train the operator out of reading the line within a week.
3. STALE NEVER READS AS FREE. `conflictsFor` answers clear / conflict / UNKNOWN,
and unknown speaks: "your calendar hasn't synced recently, so I couldn't
check". An offline laptop leaves the mirror stale, and a stale empty window
is indistinguishable from an empty afternoon — collapsing the two would have
the card implying you are free on the app's behalf. Same failure this
codebase keeps meeting: absence of evidence rendered as evidence of absence.
4. CLEAR SAYS NOTHING. A card that announces the absence of a problem every
time is noise, and noise is what stops warnings being read.
Tests: 20 cases on the conflict rules, asserted from BOTH dangerous directions
(the false positive that kills trust, the false negative that hides a clash),
including the exact 2026-09-17 collision as a fixture; 10 new cases in the
drain's self-test on normalising gog events, where the null paths get as much
attention as the happy one — inventing a busy block is how you invent a clash.
The mirror is also the prerequisite for suggesting events that do not collide
with what is already booked.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
254e451565 |
fix(ai): the tool loop spent tokens the ledger never saw (#776)
"One door" was wrong, and I said it confidently yesterday. groq.ts was metered — 19 callers, rows landing, verified. But Loki's CHAT turns do not go through groq.ts. They go through llm.ts, the tool loop, which records vendor quota, refusals and preflight skips and never recorded SPEND. Two days were spent working inside that file without checking it. THE LEDGER SAID SO PLAINLY 2026-09-17 groq 15 calls 13,806 tokens 2026-09-16 groq 11 calls 14,586 tokens 2026-09-15 groq 4 calls 1,926 tokens Three days, groq only, never once google — not because Gemini was idle, but because Gemini serves CHAT and chat was not being recorded at all. Every row on the capacity page's "spent today" was a background feature; the biggest consumer was missing entirely. IT ALSO MADE YESTERDAY'S FIX DEAD CODE The google row reads ai_usage to prove a vendor served despite publishing no limits. For the one vendor it was written for, that table could never contain a row. Correct, and structurally unable to fire. THE FIX `feature` is required on ModelCallInput, exactly as on GroqOptions, so the compiler names any caller that has not declared itself. The tool loop charges its spend on the success path, beside the health signal, fire-and-forget and caught like every other write there. A turn's three calls — round, plan retry, grounding repair — share one label, "loki-chat". They are one question being answered; three lines on the capacity page would read as three features. Two checks aimed at how the hole opened: BOTH doors must call recordUsage, and the label must be REQUIRED rather than optional. An optional field is what let sixteen callers go unnamed the first time. Gate green: tsc, lint, format, design, unit 194/194, home, desktop, ops. Claude-Session: https://claude.ai/code/session_01Nm2REqtdsVsvjukBU2maCz Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
083cda1089 |
fix(control): name the signal that says a project is working (#775)
* fix(control): render verified runs as working
* fix(control): name the signal that says a project is working
Control rendered "Working · Live agent process detected" for a project
whose own /api/control reported agentRunning=false and activeAgents=[].
The badge was right — a hook-reported turn was open — but the reason
under it was invented, and an operator reading it goes looking for a
process that was never there.
isRunning had three causes and the evidence line asserted one of them
for all three. None of the three is a /proc scan:
promptRunning a dispatch sentinel exists (the code comment right
below it even says the process "may not yet appear
in /proc on the current tick")
liveTurnRunning the agent's own hook report of an open turn
verifiedRunActive fresh PTY output on an unfinished run
`agentRunning` cannot stand in for the process either: the control route
ORs verifiedRunActive into it, so a verified run alone sets it. Where a
process and a run could both explain the state we report the run —
under-claiming, which is the safe direction.
One derivation now produces both the boolean and the reason, so the
badge and the line beneath it cannot drift apart:
const runningEvidence = ... ;
const isRunning = runningEvidence !== null;
RUNNING_EVIDENCE_LABEL is keyed by that union, so a fourth running
signal cannot be added without stating what it observed.
Also carries 6c30b29a forward: verified run output makes a project
Working rather than session-open. Before it, a verified run only moved
agentRunning in the API, which the presenter reads as "a process is
open" — so a real cloud run showed as idle.
Tests: three cases pinning the labels, each proved by mutation —
restoring the old single string fails "a live agent turn is reported as
a turn, not as a detected process" with the exact text Control showed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
5f4797ea0a |
fix(notify,install): two silent no-ops found by running the thing (#765)
* feat(approvals): standing approvals + one-tap decisions from Telegram
Asking Loki in Telegram to put an appointment in the calendar did not put an
appointment in the calendar. It sent you to a website.
Three separate causes, all fixed here:
1. THE CHAT HAD NO ROAD TO THE CALENDAR AT ALL. `gog calendar create` is
blocked on the box by the safety shim, and the fleetcrown skill could only
decide drafts that already existed — it had no way to create one. So the
agent hit the shim, read "route it through the approval queue", and passed
that on as advice. Adds `fc.sh book`, which proposes a structured event
through /api/actions/propose, and rewrites the shim's refusal to name it.
The shim still blocks every external Google write; unattended agents have
gained nothing.
2. THE GATE WAS ON THE WRONG SIDE OF THE REVERSIBILITY LINE. The queue enforced
"nothing runs that the operator did not TAP", which is stricter than the rule
it stands for ("nothing runs that the operator did not APPROVE"). For an
event in your own calendar — private, self-only, undone by deleting it — the
difference was pure latency (2026-08-04: proposed 14:15, booked 21:02).
Standing approvals let that yes be given once, in advance, with three rails
in code rather than in a docblock: eligibility is hard-coded (calendar events
and commitments only — never anything that reaches another person), the
payload is re-checked at decision time (guests mean invitations, so those go
back to the queue), and unknown is never yes (no resolvable time, or a slot
already past, queues). Default on for calendar events; toggle at /approvals.
3. THE NOTIFICATION HANDED BACK A CHORE. "2 actions are waiting… <url>" states
a problem and leaves the answer behind a login. Decisions now arrive as a
card carrying what/when/where plus one-tap Approve / Reject / Edit buttons,
backed by HMAC links scoped to one action and one verb — so a decision needs
no session and works when the gateway is down. Still two messages and only
two: one when a decision is owed, one when the effect really happened.
Also fixes a real data bug: propose_action had no event date fields, so the WHEN
of an appointment had nowhere to go and arrived as prose in `body`, which a Groq
pass then had to guess back — a model re-deriving a value the model one step
earlier knew exactly.
Behaviour that did NOT change: emails, messages, dispatches, and person-book
writes still require a per-item yes, and always will — they are ineligible in
code, and a preference row naming one authorises nothing. Every auto-approval is
audited with `via: standing-rule` and announced, so nothing is done in the
operator's name silently.
Tests pin the parts that must not be trusted: 37 cases on the standing-approval
rails (asserted from the side that hurts — a false `auto: true`), 21 on token
forgery and tampering.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(chat-skill): the chat's whole Loki skill was dead, and unversioned
Found while testing the previous commit end-to-end, and it is the largest of
the reasons appointments never got added.
On 2026-09-14 the product was renamed to Loki and `calendar-drain.env`'s keys
were renamed with it. The chat agent's skill script, which reads that file, was
not — because it lived only on the box, where no gate in this repo could see
it. Since then every command it offers has aborted on its first line:
line 14: <OLD>_AGENT_TOKEN: <OLD>_AGENT_TOKEN missing in calendar-drain.env
Verified live on bitbaum just now. So from Telegram the operator could not list
the approval queue, could not approve or reject anything, and could not
dispatch — silently, because a skill that errors just makes the agent talk
about something else instead. The only surviving route to a decision was the
website. That is the complaint, and it had a cause older than the UX.
Fixes:
- Renames the skill to `loki` (the retired product name is forbidden in this
repo by scripts/hetzner/test-no-retired-name.sh — which caught this commit,
correctly, when the box files were first imported verbatim) and reads the
env keys the file actually has.
- The installer REMOVES the superseded skill directory rather than leaving it.
Two skills claiming the same job, one of which cannot run, is how the agent
kept choosing the broken one.
- The installer now runs `loki.sh pending` as the openclaw user and fails if it
cannot authenticate. That is the check which would have caught the rename on
the day it happened: run the thing, as the user who runs it, and require real
output. Every other verification in that script only asserted that files
exist, and files existing is exactly what was true throughout the outage.
Also closes a gap in the previous commit: an auto-approved COMMITMENT executed
without telling anyone, while the comments claimed every auto-approval is
announced. Calendar events are announced from where gog succeeds (asynchronous,
on the box); everything else finishes inside enqueueAction, so that is the only
place that knows it finished at all. A standing approval nobody is told about
is not a standing rule, it is a silent one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(install): keep the gog shim parseable, and prove the block still fires
The replacement text I substituted into the shim carried double quotes. It
lands inside `block(){ echo "…" >&2; }` — a double-quoted bash string — so a
quote in the middle of it closes that string early and leaves the shim a
syntax error. Every gog call on the box would then fail, reads included, and
the calendar drain's real bookings with them: an install step meant to improve
an error message would have taken out the calendar entirely.
Caught by tracing the sed against the shim's actual text rather than running
it. Two checks added so the next one is caught by the machine:
- `bash -n` on the shim after the edit — it is a shell script we just modified
in place, so prove it still parses before trusting anything else about it.
- Actually attempt a calendar write as the openclaw user and require it to be
REFUSED. The old check grepped for the rule's text, and a rule you can read
in a file is not a rule you have seen refuse anything.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(ui): use tokens this design system actually defines
The new approvals control and decision page reached for `text-brand`,
`accent-brand`, `bg-surface-hover` and `rounded-card`. None of those exist in
globals.css — the real names are `accent-text`, `surface-raised` and the
`radius-*` scale. Tailwind emits nothing for an unknown utility and reports no
error, so the checkbox would have rendered browser-default blue and the hover
state simply would not have happened, on a page whose entire job is to be
tapped once and trusted.
The design check passes either way: it forbids arbitrary values (`bg-[#fff]`),
which is a different failure from naming a token that was never defined. Caught
by grepping whether any other component uses these names — none did, which is
the tell.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(notify,install): two silent no-ops found by running the thing
Both found by exercising the deployed feature end to end rather than reading
it, and both are the same failure: a step that could not succeed, reporting
nothing.
1. A REFUSED TELEGRAM SEND WAS INVISIBLE. sendTelegramMessage reports a bad
token, a blocked chat or an API error as `{ok:false}` — an ordinary return
value, not an exception — so the try/catch around it caught the case that
never happens and ignored the case that does. That matters more here than
in a normal notification: the confirmation message IS the review mechanism
for actions a standing rule took without asking. If it stops arriving, the
operator does not notice Loki went quiet; they notice Loki apparently
stopped doing things, which is the opposite of what is true. Both senders
now log a refusal.
2. THE INSTALLER'S CLEANUP STEP CLEANED NOTHING. It globbed the skills
directory as the ssh user, who cannot traverse the openclaw home: the glob
matched nothing, the loop ran zero times, and the script printed its success
banner. The superseded skill was still installed afterwards — the exact
"two skills claiming one job, one of them broken" state the step exists to
prevent, left in place by the step that prevents it.
Fixed by running the loop under sudo, and then ASSERTING no other skill
ships the old entrypoint. Trusting the loop's own silence is what let the
first version pass; verified on the box that it now removes the directory
and that the assertion sees an empty result afterwards.
Verified live on bitbaum after deploying the parent change: booking from the
chat skill returns auto-approved, the drain books it, the row reaches executed,
and the event is really in Google Calendar at the right time. Test event
deleted.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(auth): the one-tap approval link redirected to sign-in
The feature whose entire purpose is "decide from your phone without logging in"
sent you to a login page. Found by tapping it against production, not by
reading it:
GET /a/<token> → 302 /sign-in?callbackUrl=/a/<token>
Route auth here is one negative-lookahead regex in src/proxy.ts listing the
prefixes served without a session, and `a/` was not among them. Every unit test
on the token passed throughout — 21 of them — because they tested the TOKEN.
Nothing tested whether the route could be reached, which is the part that was
broken. A signature that verifies perfectly behind a login is worth nothing.
Adds `a/` with the same justification the file already records for `share/task/`:
the minted token IS the credential, the holder has no account by design, and the
link decides exactly one action with one verb (lib/actions/action-link.ts).
THE TRAILING SLASH IS LOAD-BEARING, and that is why this commit also adds a
gate. The list holds bare prefixes, so `a` instead of `a/` would have made
/approvals, /api/*, /agent — every path starting with that letter — publicly
readable, and nothing would have looked broken: the app would have worked
better, with nobody asked to log in. That is the one direction a reviewer will
not notice.
scripts/test/public-matcher.ts reads the real regex out of the real file and
asserts BOTH directions: what must be reachable without a session, and what must
not. Proven by mutation before committing — with `a` in place of `a/`, eight
assertions fail loudly (/approvals, /api/actions/pending, /api/me/preferences
among them). A test that only checked the public list would have passed just as
happily on a regex that made the whole app public.
Verified: pnpm verify green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
5d9a942cd7 |
refactor: split the five unreadable functions, then lint against the next one (#733)
* refactor(orchestration): split the 733-line dispatch POST into named steps The POST handler in /api/orchestration/run carried every dispatch path inline: registry resolution, the cloud queue branch, the prompt-queue pop, run tracking, the queued-behind and parallel branches, and the claude / codex+gemini / openclaw executors. Reading it meant holding all of them at once. Each step is now its own named function, and POST reads as the sequence it always was. No behaviour change: same responses, same status codes, same sentinel writes in the same order, same log lines. Two genuine duplicates folded while passing: the project-state description block (claude and codex/gemini derived it identically) and the lifecycle sentinel writes. POST 733 -> 164 lines. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor(inject): split injectPrompt into named dispatch steps injectPrompt was one 627-line function carrying the whole dispatch: target resolution, local and remote prompt assembly, run opening, /tmp side effects, the hosted-builder route, the executor call, and the failure and success ledgers. Each is now a named function and injectPrompt reads as the sequence. This path is autopilot-critical, so nothing moved across a boundary: same statuses, same response bodies, same event/audit rows in the same order, same log strings. injectPrompt 627 -> 163 lines (executeAndReport, the post-executor half, is 122). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor(control): split the 492-line control GET into named steps The /api/control GET built the whole panel inline: project collection and dedupe, the agent-availability override, ten parallel DB slices, a 256-line per-project map callback, and the response. The card builder alone carried session persistence, run closing, runtime resolution and run serialization. Each is now named: collectControlProjects, resolveRunnerAvailability, loadControlSlices, buildProjectState (with persistSessionHandoff, maybeCloseRunFromHandoff, resolveAgentRuntime, serializeLatestRun) and resolveRunnerLastPushedAt. Same payload, same headers, same log lines, same write ordering. GET 492 -> 128 lines; the per-project builder 256 -> 133. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor(widget): split the 1,329-line embed into modules widget/main.ts was one file with a 776-line mount() closure and no exports — the launcher, the element picker, the screenshot strip, the voice control, the stylesheets and the DOM helpers all lived inside it. This is the only surface strangers on other people's sites load, and it earns the same care as src/. It stays a self-contained esbuild bundle (nothing imports from src/), split into siblings: dom, theme, visitor-placement, launcher, picker, attachments, voice-control. main.ts now owns the panel, submit and boot. Same DOM, same order of construction, same copy, same listeners — verified by diffing the string literals of the old and new unbundled builds. Two pins added while the code was moving: - scripts/test/widget-self-contained.ts — every widget module imports only its siblings, every sibling import resolves, and the only document-level CSS is the fcw-* pick highlight. Proven by mutation (an "@/config/brand" import makes it fail). - widget-server-caps-mirror now reads every widget module, not just main.ts, so moving a clamp cannot silently defeat the check. main.ts 1,329 -> 528 lines; mount 776 -> 386. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor(control): thin the 665-line ControlPanel into named pieces ControlPanel held the deep-link effect, the runner-presence derivation, the empty state, the Workspaces panel, the launch defaults, four modals and the toast — all inline, between the four-tier comments that explain the page's ordering. Extracted, behaviour unchanged (same DOM, same copy, same props): - useControlDeepLink — /control?focus=&switchTo= navigation handling - deriveRunnerPresence — offline / never-seen / stale, now in the presenter - latestRunSignals — the fleet-pulse outcome pairing - ControlEmptyState, WorkspacesSection, LaunchDefaultsSection, ControlNotices - ControlPanelModals — every overlay in one sibling deriveRunnerPresence is the one piece with real logic in it (the ADDITIVE rollout rule where connected===false is not yet authoritative on its own), so it is now pinned by five cases in the presenter suite — it had none. ControlPanel 665 -> 520 lines; the component function 665 -> 396 (most of which is JSX and the ordering comments that explain it). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor(control): split the 412-line useControlData hook The hook did four jobs in one function: snapshot fetching + refresh triggers, the SSE patch fold, the /api/control/stream EventSource, and the five dispatch actions. - applyProjectPatches (lib/control-project-patch.ts) — the fold, now pure - useControlProjectStream — the EventSource and its reconnect - buildControlActions — inject / launch / runWithBrain / runCustomPrompt / saveAgent applyProjectPatches carries three rules a later edit could silently break (match by live tab, leave omitted fields alone, maintain liveTabs case-insensitively) and was untestable inside a useCallback. It now has six cases pinning exactly those. useControlData 412 -> 290 lines; the hook function 412 -> 180. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor(shell,system): split the palette and Fleet Doctor CommandPalette (442-line component): the entry list and the filter were two useMemos nobody could test, and the NL composer's two fetch hops were inline. Both moved out — palette-entries.ts (pure) and useCommandComposer — with eight cases pinning the decisions that look arbitrary and get tidied away: projects outrank navigation, recents lead and are not repeated, free text offers Run FIRST, a pending command turns the list into a project picker, and a project with no checkout offers no agent switch. /api/system/doctor GET (328 lines): a flat run of independent probes appending to one array. Each is now a named probe returning its own checks, and GET is the list of them plus summarize(). Same checks, same order, same ids and copy. CommandPalette 442 -> 245; doctor GET 328 -> 33. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor(loki): split the 450-line conversation POST into named turns The Loki chat route answered a turn with eight deterministic fast paths and a classifier path, all inline inside the SSE job — a 450-line closure whose control flow was a column of early `return send(...)`. Each fast path is now a named TurnHandler over one TurnContext, returning a message or null to pass. The classifier half splits into dispatchResolvedCommand / needsProjectReply / chatReply. The chain and its ordering are now a list you can read, and the two "add this project to the thread" patterns collapse into linkProject/linkProjects. Same replies, same meta `source` tags, same ordering, same SSE frames. POST 450 -> 63 lines; the longest piece is chatReply at 84. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * chore(lint): hold the line on function length Nothing was watching functions grow. Today's rule is a ratchet set just above the worst case that survives the split work above, so the next 700-line handler is an error on the author's machine instead of a surprise in review. Two thresholds, because the halves fail differently. Logic — routes, lib, queries, home/ — is where length hides branching, so 300. A component's length is mostly JSX depth: real, far less dangerous, so 510. Error, not warn: a warning on a repo this size is a number nobody reads. Blank lines and comments are skipped — this codebase comments heavily on purpose and a rule that punished that would push the WHY out of the code. Proven by mutation: a 324-line function under src/lib fails the rule. Also removes fnlen-all.mjs, a measurement scratch file that rode along in the previous commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
4c3237c3d1 |
fix(feedback): give every surface one answer about the builder (#773)
|
||
|
|
e3d9024887 |
fix(orchestration): a closed run tells the thread what the agent actually did (#772)
Both close notifications — the outcome turn in /loki and the push/Telegram message — read only `payload.resultText`. The hosted runner and openclaw set it. The local PTY path, which is the one a person watches after typing into /loki, does not: it closes from the agent's session handoff, and the agent's own words land in `summary`. So the main path reported "🟡 **loki** — partly done." and nothing else. The agent had written `done: e2e ok — no changes`, the judge had written exactly what it found missing, and none of it reached the thread — which is the trip out of the product this message exists to prevent. One shared `runReportText` now answers "what did the agent say", preferring a runner's own result text and falling back to the handoff: `done`, plus `next` when it holds something, because on anything short of success `next` carries the definition-of-done gap and the gap is what the operator must act on. And the live check stops asserting what its own prompt forbids. The probe says do NOT change a file, commit, or open a pull request; the judge then correctly grades the run partial for having no committed change; the check demanded a ✅ and so failed on a perfect run (2026-09-17, run 69cdbdb7: injected 11:56:11, handoff "e2e ok — no changes" thirty-two seconds later, every leg working). It now asserts the thing that actually proves the loop — the agent's own handoff summary coming back into the thread — and still fails on ❌ or on a turn that carries somebody else's words. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
dd8a877944 |
fix(ai): the capacity page said a busy vendor had never served (#770)
* fix(ai): the capacity page said a busy vendor had never served Opened the page on production and read it. Three things were wrong, and the first is the SAME false sentence that started this work. THE GOOGLE ROW WAS THE ORIGINAL COMPLAINT, AGAIN google — not measured "configured, but it has not served an answer yet" "will be measured on the next answer it serves" Gemini answers most of the traffic. It also publishes no rate-limit headers at all, so it can never appear in provider_quota — which means BOTH lines were false, and the second promised a measurement that would never arrive however long anyone waited. The identical wording about Groq is what got this page called made-up in the first place; I fixed it there and shipped it here. Fixable now only because of the ledger added yesterday. Spend is a SECOND WITNESS: headers answer "how much is left" and go silent for a vendor that discloses nothing, while spend answers "did this actually run" and never goes silent, because it is recorded on our side of the call. With two witnesses the row can say the true and useful thing — "served 14 calls today (9,532 tokens) — this vendor publishes no limits, so there is nothing left to measure", and a consequence that admits the headroom is unknowable until it refuses. Every false claim this page has made has been the same mistake: reporting ABSENCE OF MEASUREMENT as ABSENCE OF ACTIVITY. Groq "hasn't served" while being skipped. A minute window "spent" while holding 3,984 tokens. Now this. TWO SMALLER LIES whisper-large-v3-turbo — "~1,999 answers". It serves TRANSCRIPTIONS. A wrong unit is how a reader starts distrusting the number beside it. Five OpenRouter models each printed "this is the last link — after it, answers wait for the reset". The fact is per-PROVIDER; repeating it per model does not make it truer, it just buries the rows that say something different. Said once per run now, and a consequence that returns after a different one speaks again — dedupeConsequences is pure and tested rather than inline in the route. Quota-view checks 31 -> 37, both directions of each: a vendor nobody has called still says exactly that, and a chat model keeps "answers". Full gate green, run in pieces because the box is at 26/31 GB: tsc, lint, format, design, unit 194/194, home 130, desktop, ops 7/7. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nm2REqtdsVsvjukBU2maCz * chore: re-trigger CI Both prior runs for this branch stalled seconds after starting, during a window when the box was at 26/31 GB and local verify was being OOM-killed too. Branches that started after the crunch are progressing normally, so this is a fresh run against a healthier machine rather than a change to the code. 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> |
||
|
|
c116518216 |
fix(feedback): tell the truth when the builder goes offline after delivery (#769)
A dispatch whose builder goes down mid-run read "Starting", then "Needs you · Open Terminal — or Restart Fleet Runner" — pointing the operator at a terminal on a machine that is switched off. Loki already knew better: the snapshot carries builderChannel and per-channel presence. Two things kept that knowledge off the row. The phase guard was `!run.deliveredAt && run.builderOffline`. The runner stamps executedAt on its inject-ack, seconds after the prompt lands, so a claimed command counts as delivered for nearly the whole run and the honest branch could only ever fire in the opening moments. Gate it on PROGRESS instead: no bytes have arrived and the builder is down NOW is the whole diagnosis, delivered or not. A run that is actually streaming keeps its own reading, so a lapsed heartbeat cannot mute a live agent. builderChannel came only from an OPEN pending_commands row, and that row closes on the same early ack. With the channel unknown the offline test fell through to "any builder will do", which reported a local run healthy because the cloud box was up — the channel-aware code added for exactly this case was unreachable in practice. Fall back to the project's stored routing decision (locus lock → builder_pref → cloud floor), the same answer the dispatcher itself used. The diagnostic now separates claimed-then-silent from never-claimed: if the prompt already reached that machine, the honest ask is to bring it back, not to re-dispatch blind. Pinned in scripts/test/feedback-work-phase.ts — nothing covered builderOffline before, which is how the guard drifted into dead code. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
918f3c0e90 |
fix(newsletter): two gaps the live endpoint showed that the tests could not (#768)
Both found by probing the deployed route rather than re-reading the code. Vary reached nobody. The preflight answered the correct per-origin Access-Control-Allow-Origin with NO `Vary: Origin` beside it: Next attaches its own Vary list (rsc, next-router-*) to every response, and a Vary passed in a `headers:` init lost to it. ACAO that varies by origin, served without Vary, is the exact header a shared cache can hand to the wrong origin. The headers are now applied to the response object, appending Vary instead of setting it. The unit test could not have caught that, because it asserts what the helper RETURNS, not what the framework puts on the wire — verifying the wrong thing, one layer too early. It now also reads the route source (comments stripped, so the prose cannot satisfy the rule) and fails if Vary is set rather than appended, or if the headers go back into a response init. Mutation-proven: restoring `set` fails exactly that assertion. A dead channel was silent. sendTelegramMessage REPORTS failure, it does not throw, so ignoring its result swallowed an undelivered signup — in a function whose entire reason to exist is that a signup must reach a person. Asked "did anyone hear about that signup?", the only honest answer has to come from a log line, not from the absence of one. A failed send now logs a warn with the reason. Verified end to end before writing this: a real submission from the live /hire/ page returned 200, wrote one row with source bitbaum-hire, and the probe row was deleted afterwards. Claude-Session: https://claude.ai/code/session_01DzY8KuwgUM7u95GVTpRL2m Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
c8ebc5708d |
test(e2e): widen the dispatch window past a measured cold start (#766)
The window was twenty minutes and guessed. On 2026-09-15 a cold-start agent on the box — fresh PTY, boot, trust prompt, then the task — wrote its handoff at 13:44 for a dispatch injected at 13:23: twenty-one minutes to answer `git status`. The check aborted at 13:43 and reported a broken loop that was one minute from succeeding, which is the worst thing a health check can do. Thirty minutes in the script, thirty-five on the box timer (the timer runs six-hourly, so the extra slack costs nothing and the check must outlast the slowest healthy path it exercises). Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
28de8ac62e |
feat(newsletter): let the studio site join the list, and say so out loud (#762)
The studio site's /hire/ page stops publishing rates and offers a waitlist instead. It is a static page on another origin, so a JSON POST to /api/newsletter triggers a preflight this route did not answer, and a row landed in a table with no sending pipeline — capture-only by design, which is fine for a newsletter nobody has sent and wrong for a page that promises a human writes back when capacity opens. CORS, but an allowlist. The feedback widget can afford `Access-Control-Allow-Origin: *` because its fcw_* token is the real gate. This route has no token and writes a row per call, so it echoes one allowlisted origin at a time (src/lib/api/public-cors.ts) and varies on Origin, and an unknown origin gets no ACAO at all. The 429 carries the headers too: a cross-origin refusal the browser cannot read is a refusal the visitor cannot be told about. A new row now announces itself on Telegram, through the channel's existing contract — fire at the insert choke point, never throw, never slow the response, and stay silent when the operator must not act. subscribeToNewsletter returns whether it actually inserted, so a repeat signup is still a silent no-op; the visitor is told the same thing either way. Registered in docs/telegram-notifications.md, as the gate requires. Proven by mutation, not by a green run: setting ACAO to "*" fails the new test with "an allowlisted origin must be echoed back verbatim", and the allowlist test also refuses a prefix match (bitbaum.orangecat.ch.evil.test), a scheme downgrade, a null origin and a missing one. 191/191 unit files pass. Claude-Session: https://claude.ai/code/session_01DzY8KuwgUM7u95GVTpRL2m Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
fe9b396e4d |
feat(uptime): watch the studio site, the one public host nothing watched (#763)
bitbaum.orangecat.ch was in neither register. It is static files Caddy serves straight from /opt/bitbaum/app, so it has no port, no unit and no repo path, and it can no more hold an apps.conf row than annushka can — which is exactly the case EXTRA_TARGETS exists for. Its own header says why: still public, still on the one box, still unwatched reproduces the blind spot the sweep was written to close. It mattered little while nothing linked to the site. It matters now: all nine package READMEs point at it, the org and personal profiles point at it, and as of today /hire/ takes waitlist signups through it. An outage there is silent lost work, and the first person to notice would be someone who had already decided to get in touch. Its health route is `/` — a static site's homepage IS its health — declared in HEALTH_PATHS rather than left to the /api/health default, so it reads UP instead of joining the LIMITED "no health route" list. Verified against the live fleet, not just the table: the sweep now probes 16 targets and bitbaum answers health:200. 65/65 test-uptime-sweep.sh pass. Claude-Session: https://claude.ai/code/session_01DzY8KuwgUM7u95GVTpRL2m Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
e6b8a17970 |
feat(approvals): standing approvals + one-tap decisions from Telegram (#761)
* feat(approvals): standing approvals + one-tap decisions from Telegram
Asking Loki in Telegram to put an appointment in the calendar did not put an
appointment in the calendar. It sent you to a website.
Three separate causes, all fixed here:
1. THE CHAT HAD NO ROAD TO THE CALENDAR AT ALL. `gog calendar create` is
blocked on the box by the safety shim, and the fleetcrown skill could only
decide drafts that already existed — it had no way to create one. So the
agent hit the shim, read "route it through the approval queue", and passed
that on as advice. Adds `fc.sh book`, which proposes a structured event
through /api/actions/propose, and rewrites the shim's refusal to name it.
The shim still blocks every external Google write; unattended agents have
gained nothing.
2. THE GATE WAS ON THE WRONG SIDE OF THE REVERSIBILITY LINE. The queue enforced
"nothing runs that the operator did not TAP", which is stricter than the rule
it stands for ("nothing runs that the operator did not APPROVE"). For an
event in your own calendar — private, self-only, undone by deleting it — the
difference was pure latency (2026-08-04: proposed 14:15, booked 21:02).
Standing approvals let that yes be given once, in advance, with three rails
in code rather than in a docblock: eligibility is hard-coded (calendar events
and commitments only — never anything that reaches another person), the
payload is re-checked at decision time (guests mean invitations, so those go
back to the queue), and unknown is never yes (no resolvable time, or a slot
already past, queues). Default on for calendar events; toggle at /approvals.
3. THE NOTIFICATION HANDED BACK A CHORE. "2 actions are waiting… <url>" states
a problem and leaves the answer behind a login. Decisions now arrive as a
card carrying what/when/where plus one-tap Approve / Reject / Edit buttons,
backed by HMAC links scoped to one action and one verb — so a decision needs
no session and works when the gateway is down. Still two messages and only
two: one when a decision is owed, one when the effect really happened.
Also fixes a real data bug: propose_action had no event date fields, so the WHEN
of an appointment had nowhere to go and arrived as prose in `body`, which a Groq
pass then had to guess back — a model re-deriving a value the model one step
earlier knew exactly.
Behaviour that did NOT change: emails, messages, dispatches, and person-book
writes still require a per-item yes, and always will — they are ineligible in
code, and a preference row naming one authorises nothing. Every auto-approval is
audited with `via: standing-rule` and announced, so nothing is done in the
operator's name silently.
Tests pin the parts that must not be trusted: 37 cases on the standing-approval
rails (asserted from the side that hurts — a false `auto: true`), 21 on token
forgery and tampering.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(chat-skill): the chat's whole Loki skill was dead, and unversioned
Found while testing the previous commit end-to-end, and it is the largest of
the reasons appointments never got added.
On 2026-09-14 the product was renamed to Loki and `calendar-drain.env`'s keys
were renamed with it. The chat agent's skill script, which reads that file, was
not — because it lived only on the box, where no gate in this repo could see
it. Since then every command it offers has aborted on its first line:
line 14: <OLD>_AGENT_TOKEN: <OLD>_AGENT_TOKEN missing in calendar-drain.env
Verified live on bitbaum just now. So from Telegram the operator could not list
the approval queue, could not approve or reject anything, and could not
dispatch — silently, because a skill that errors just makes the agent talk
about something else instead. The only surviving route to a decision was the
website. That is the complaint, and it had a cause older than the UX.
Fixes:
- Renames the skill to `loki` (the retired product name is forbidden in this
repo by scripts/hetzner/test-no-retired-name.sh — which caught this commit,
correctly, when the box files were first imported verbatim) and reads the
env keys the file actually has.
- The installer REMOVES the superseded skill directory rather than leaving it.
Two skills claiming the same job, one of which cannot run, is how the agent
kept choosing the broken one.
- The installer now runs `loki.sh pending` as the openclaw user and fails if it
cannot authenticate. That is the check which would have caught the rename on
the day it happened: run the thing, as the user who runs it, and require real
output. Every other verification in that script only asserted that files
exist, and files existing is exactly what was true throughout the outage.
Also closes a gap in the previous commit: an auto-approved COMMITMENT executed
without telling anyone, while the comments claimed every auto-approval is
announced. Calendar events are announced from where gog succeeds (asynchronous,
on the box); everything else finishes inside enqueueAction, so that is the only
place that knows it finished at all. A standing approval nobody is told about
is not a standing rule, it is a silent one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(install): keep the gog shim parseable, and prove the block still fires
The replacement text I substituted into the shim carried double quotes. It
lands inside `block(){ echo "…" >&2; }` — a double-quoted bash string — so a
quote in the middle of it closes that string early and leaves the shim a
syntax error. Every gog call on the box would then fail, reads included, and
the calendar drain's real bookings with them: an install step meant to improve
an error message would have taken out the calendar entirely.
Caught by tracing the sed against the shim's actual text rather than running
it. Two checks added so the next one is caught by the machine:
- `bash -n` on the shim after the edit — it is a shell script we just modified
in place, so prove it still parses before trusting anything else about it.
- Actually attempt a calendar write as the openclaw user and require it to be
REFUSED. The old check grepped for the rule's text, and a rule you can read
in a file is not a rule you have seen refuse anything.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(ui): use tokens this design system actually defines
The new approvals control and decision page reached for `text-brand`,
`accent-brand`, `bg-surface-hover` and `rounded-card`. None of those exist in
globals.css — the real names are `accent-text`, `surface-raised` and the
`radius-*` scale. Tailwind emits nothing for an unknown utility and reports no
error, so the checkbox would have rendered browser-default blue and the hover
state simply would not have happened, on a page whose entire job is to be
tapped once and trusted.
The design check passes either way: it forbids arbitrary values (`bg-[#fff]`),
which is a different failure from naming a token that was never defined. Caught
by grepping whether any other component uses these names — none did, which is
the tell.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
b9a28bff0b |
fix(providers): let the operator's ranking govern every fallback (#760)
|
||
|
|
2a8aa17d6f |
feat(solon): found an organization from a project, and attribute it by consent (#759)
Solon can now create organizations (bitbaum/solon#166). This is Loki's half: the handoff that starts it, and the register join that records the result. A HANDOFF, NOT A PUBLISH Publishing to OrangeCat works because Loki holds the user's OIDC token and acts as them. That does not transfer: founding a Solon organization needs a signature from the founder's own Bitcoin wallet, and Solon's key custody is "never Solon — SELF is a human's own wallet". So Loki cannot do this for anyone. It mints a link, pre-filled with the project, and the owner signs on Solon. ATTRIBUTION BY GRANT, NOT BY NAME Founding is permissionless, so a register that paired a project with the organization of the same name would let whoever founds `loki` appear to govern Loki. The register now joins on Solon's `claimedProject`, and Solon sets that only from a grant this signs for the founder's own OrangeCat identity, checked against their session. Squatting a name costs a vanity slug, never attribution. The grant is HMAC-SHA256 over a domain-separated line, 30-minute TTL, signed with SOLON_WEBHOOK_SECRET — which both deployments already hold, and which cannot collide with a webhook body because that is JSON. Both ports are pinned to ONE shared vector; drift turns both repos' suites red rather than silently refusing every founding link with "issued to a different identity". AND A PROBE THAT COULD ONLY EVER FIND WHAT IT KNEW solonOrgSlugs() asked `GET /api/orgs/<slug>` per candidate slug — and all three callers passed no candidates, so it only ever probed `orangecat`. An organization for any other project could have existed and the register would never have seen it. It reads Solon's new list endpoint once instead. A fetch that fails is still UNCHECKED, never "no organisation". The button renders nothing when Solon is unreachable: the project may already have an organization we could not see, and offering to found a second one is the wrong guess. The grant is minted on click, not on page load, so a tab left open past the TTL does not hand Solon an expired link. Checked: tsc, eslint, design-system, 191/191 unit test files — including the shared-vector test and a register test pinning that an organization which merely shares a project's name attributes nothing. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |