Commit Graph
475 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 8b70d2a191 fix(widget-chat): what the first live answers got wrong
Seen on production right after #879:
- a reasoning model spent the 700-token budget and the Cat stopped mid-clause
  ('…which is running, in') — budget 1600, and trimToLastSentence drops a
  trailing half sentence rather than show it;
- the speaker label 'Loki:' counted as a mention, so a Loki chip led an answer
  recommending Heidi — labels are stripped before links are found;
- 'running, in beta' was copied verbatim — the stage word is now 'in beta';
- Loki described itself in the third person and sent a self-serve need to the
  closed studio waitlist — an agent that fits recommends itself in the first
  person, and a product that fits always beats the waitlist.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 23:47:04 +02:00
CatoandClaude Opus 5.5 6ee4cbb858 feat(widget): Chat mode — a chat the Cat and Loki both live in (#879)
The widget's Chat tab ships. A visitor on an embedding site asks; whichever of
the Cat (earning, getting paid) and Loki (getting things built) the question
belongs to answers as itself — both when both have something useful — from the
public fleet map, and is sent to the project that fits.

- POST /api/widget/chat: fcw_* token + origin allowlist + per-IP/per-token
  limits, charged to the token owner's fair share of the free AI pool. Links are
  attached from the map, never typed by the model. When the budget or every
  vendor refuses it still routes by keyword match (degraded: true).
- src/lib/widget-chat/concierge.ts: pure facts/prompt/links/fallback. Retired
  projects, throwaway names (same pattern as the litter gate, pinned equal) and
  unwritten not-running projects are not offered; stage words say beta/pilot,
  never live/client; facts are budgeted to survive free-tier limits.
- Chat is OPT-IN per embed (data-fc-modes="chat,report"); the default is now
  Report alone, because the same bundle runs on pilot sites. The first listed
  mode opens first. window.Loki.ask(question) lets a host page hand a question
  over (bitbaum's homepage does).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 13:58:52 -07:00
CatoandClaude Opus 5.5 5f1e283117 fix(scripts): grep -q is never the reader of a pipe under pipefail (#874)
`echo "$x" | grep -q PAT` under `set -o pipefail` can report "not found"
for text that IS there: grep -q exits on its first match and closes the
pipe, the writer takes SIGPIPE (141), and pipefail makes the pipeline
status 141. An `if` then takes the else branch on a successful match.

#587 found this in one file and noted it "only fires when the payload
exceeds the ~4KB pipe buffer". That is not so, and the belief is why
82 copies in 22 scripts survived. Measured today on retire-site's real
1,158-byte plan output with has()'s exact pattern, 3,000 calls each:

  'DRY RUN'        line 3 of 20    echo|grep -q   2/3000 false misses
  'apps.conf row'  line 11 of 20   echo|grep -q   2/3000 false misses
  last phrase      line 20 of 20   echo|grep -q   0/3000
  'DRY RUN'                        here-string    0/3000

Rare per call, but verify makes hundreds of these calls, and the
retire-site suite went red on those two exact phrases twice this week,
passing every rerun. It is worse in a NEGATIVE check - hasnt() read a
false miss as a PASS. And several copies are not tests: deploy-hetzner.sh
exits 1 on a false miss, and the sshd drift watch would raise a false
security alert.

All 82 rewritten to `grep -q PAT <<<"$x"` (a here-string is not a
pipeline, so there is no writer to signal) by a script that only touched
the simple quoted-variable form and reported anything else. Checked: all
22 files pass `bash -n`, every file is a 1:1 line swap (82 lines), and
the 20 line-continuation sites keep the here-string before the trailing
backslash (the first draft of the rewrite got those wrong; caught in a
dry-run diff before anything was written).

#587's comment is corrected so it stops teaching the wrong threshold.

Gate: scripts/test/no-grep-q-in-a-pipe.ts ratchets it repo-wide,
including forms the rewrite skipped (e.g. "$(cmd)" | grep -q), and
self-tests that its detector still fires. Proven by restoring the
original deploy-hetzner.sh line.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 02:57:19 -07:00
CatoandClaude Opus 5.5 bec2a9d67c perf(runs): fetch the latest run per path, not every run ever made (#873)
getLatestRunsByProjectPaths selected every run for every path and kept
the first per path in JS. Measured on production today for the busiest
user: 699 rows at ~1.26 KB each (~880 KB, mostly `summary` JSON) fetched
and parsed to keep 32. Control paid that on every poll; since #863 the
/today front door pays it on every load, and it grows with every run.

Postgres time was ~2 ms either way, so the cost was transfer and parsing.
DISTINCT ON (project_path) returns only the 32 rows the caller keeps.
The repo already uses selectDistinctOn on this table (register/load-map).

Equivalence checked against production data before changing it: the old
and new selection pick the same run for all 36 (user, path) pairs, with
0 mismatches; there are 0 ties on the latest started_at and 0 NULL
started_at values, so neither tie-breaking nor NULL ordering can differ.
The drizzle-generated SQL (via .toSQL()) was run read-only on prod and
returned 32 rows.

Gate: latest-run-is-one-row-per-path.ts pins both halves. The ORDER BY
must lead with the DISTINCT ON column or Postgres rejects the query at
runtime, which tsc cannot see and both callers would swallow into an
empty map, so run health would silently stop reporting. Proven by
mutation both ways.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 02:34:52 -07:00
CatoandClaude Opus 5.5 ef96be9b91 feat(projects): invite anyone into a project by email, account or not (#872)
Inviting a collaborator required them to already have a Loki account.
The members route answered "No Loki account uses that email. Ask them to
register first." — a dead end with no way to ask. The only other invite
path creates a LOCAL-PASSWORD account and adds it to the inviter's whole
org: broader than one project, and a second identity path beside
OrangeCat, which fleet STACK.md says our own products must not grow.

Now any email works:

- Has an account: added at once, as before.
- No account: a one-time invite is created, emailed when mail is
  configured, and ALWAYS returned as a link to copy — an email that was
  sent is not an email that was received. They open it, sign in with
  OrangeCat (creating that account on the way), and join exactly this
  project with exactly the role chosen. No Loki password anywhere.

The link is bound to the invited email. A token is a bearer secret that
gets forwarded; on its own it would let whoever holds the link in. The
wrong account is told which address it was for, masked (ge•••@gmail.com)
because the link may be in the wrong hands.

Only a sha-256 of the token is stored, so a leaked backup cannot be
replayed as working links. Acceptance spends the invite and grants the
membership in one transaction guarded on accepted_at/revoked_at IS NULL,
so a double click or two tabs grants once. Re-inviting the same email
revokes the old link rather than leaving two live ones.

"emailed" is only reported when mail is configured AND the send
succeeded: sendEmail returns quietly when mail is off, so trusting the
call alone would have claimed an email nobody sent.

The panel moved from a collapsed "Editors" disclosure inside the
Feedback tab to the top of the project's Settings tab — where every other
product keeps "people with access", and where George looked for it. It
now offers Editor or Viewer, lists pending invites, and lets the owner
withdraw one. Editors do not see pending invitees' emails.

The accept API lives under /api/invitations/project/ so it inherits the
existing public-route exclusion instead of widening the proxy allow-list.

Migration 0080 is hand-written, like 0073-0079: drizzle/meta's snapshot
stops at 0072, so `drizzle-kit generate` diffs against a stale picture —
it believes beacon_sessions still exists and calendar_busy does not, and
would have emitted a DROP and a duplicate CREATE alongside this table.

Tests: 14 checks on the acceptance rule, proved by mutation — removing
the email binding turns the suite red. tsc clean, lint 0 errors,
check:design ok, format ok, test:unit 260/260, test:home 130/130.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 02:34:14 -07:00
CatoandClaude Opus 5.5 9dfe6e6b11 fix(control): the hero says whose need it counts (#871)
Control's hero counted ONLY agent attention (session or last-run health)
but claimed the whole phrase: "1 project needs you - loki". /today's
verdict counts raised flags too, and named evig. Same three words, two
populations, one click apart.

/today is now the complete answer (#863). Control is the fleet page, so
it keeps its scope and says it: "1 project's agent needs you".

Gate: one-meaning-of-needs-you.ts gains a check; proven by restoring the
unqualified phrase.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 01:18:46 -07:00
Cato fcd38cb463 fix(loki): clarify terminal and retire stale guidance (#866) 2026-09-23 07:58:21 -07:00
Cato 4b9542c14e feat(loki): deepen investigations without repeating tool actions (#865) 2026-09-22 14:04:50 -07:00
CatoandClaude Opus 5 d2ac85ec21 fix(projects): a health signal has one name, and it is not "Broken" (#864)
Seen on production today, evig's health panel, three headings stacked:

  x Security risk   Email verification bypass: anyone can register...
  x Broken          Marketplace, Repairers, IT-Hilfe (API returns HTML)...
  x Deploy issue    CMS backend (Express port 3001) not deployed...

"Broken" is not a thing. It read as an unfinished string between two
real labels - and four inches away on the same page, the same signal
was writing itself out as "4 broken features".

The cause was two fields for one concept. Every signal carried BOTH a
`label` and a `cardLabel`, drifted in wording AND in casing:

  label             cardLabel
  "Security risk"   "Security Risk"
  "Broken"          "Broken Features"
  "Deploy issue"    "Deployment Issue"

Nothing distinguished them. No surface needed a different word - they
were written twice and maintained once, so the badge said one thing and
the raise-a-flag sheet another about the same flag, and the copy that
got left short is the one at the top of the panel.

One name per signal, sentence case, and `cardLabel` is gone. The one
surface that wanted it lowercase calls .toLowerCase() instead of
keeping its own copy. The "4 broken features" row is unaffected - that
label is a runtime count, not this field.

Also repoints an existing gate. a-flag-can-be-raised-and-cleared.ts
required a `cardLabel` specifically, which pinned the IMPLEMENTATION
(two label fields) rather than the rule (a signal the operator can
raise must have a name) - so collapsing the two fields failed a gate
even though it fixed the defect. It now asserts the rule.

Gate: scripts/test/one-name-per-signal.ts, 5 checks. Proven by mutation
- restoring the "Broken" stub, letting Title Case back in, and
reintroducing a second name field each fail on the matching check.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 13:16:30 -07:00
CatoandClaude Opus 5 ed49fd6e0e fix(today): "needs you" means one thing, and the front door knows all of it (#863)
Measured on production today, same login, minutes apart:

  /control hero    "1 project needs you - loki"
  /today verdict   "7 things need you", and the project it names is evig
  /projects chip   "Site issues 1" - evig

/projects and /today agree since #857. Control overlapped with NEITHER:
it counts projects whose agent SESSION or last RUN is unhealthy, the
other two count raised flags (security / broken features / deploy issue
/ site down). Same three words, three different populations.

So the front door said seven things needed me, and Control - one click
away - named a project that was in none of the seven. Trust /today and
you miss a blocked agent; trust /control and you miss an authentication
bypass. A front door that is incomplete teaches you to check everything
anyway, which is the whole thing it exists to stop.

ONE DEFINITION. The scoring moved out of control-presenter into
src/lib/project-attention.ts, taking two health strings and nothing
else - so a client component holding live SSE state and a server
component holding two DB reads can both ask it. Control is now a
four-line adapter. The scoring, including the `score <` guards that
stop one trouble seen in two places counting twice, is preserved
exactly, and the reason strings are unchanged so both surfaces name the
same trouble with the same words.

THE FRONT DOOR ASKS IT. /today derives blocked projects server-side
from the same two sources Control reads (project_states.session_health,
orchestration_runs.summary.health), joined on the same keys Control
joins on (normalized tab name, dirPath), and merges them with the
flagged list - deduped, with the flag winning, because a flag says what
is wrong in the operator's own words where a health word does not.

NO ROW LINKS TO A 404. /projects/[id] resolves by ENTITY id, and a
catalog project need not have an entity row. Those are still NAMED and
simply are not links; dropping them would make the verdict quietly
incomplete again.

Gate: scripts/test/one-meaning-of-needs-you.ts, 8 checks. Proven by
mutation - deleting the /today call, double-counting one trouble,
treating missing health data as a problem, and restoring Control's own
scoring each fail on the matching check.

Two of those mutations initially passed. `src.includes("symbol")`
survives a rename (the original stays a substring) AND survives
deleting the call (the import still matches). The gate now asserts the
symbol is CALLED, with import lines stripped first.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 13:03:16 -07:00
CatoandClaude Opus 5 0c126182c5 fix(projects): a 404 is only "gone" if the token could see private repos (#862)
Caught before this shipped, not after it paged someone.

Without the `repo` scope, GitHub answers 404 for a PRIVATE repository —
byte for byte the same response as a deleted one. The checker would have
read that as "your repo is gone" and raised an alert for every private
project of any user whose GitHub link is sign-in-only. An alarm that
fires on healthy projects is worse than no alarm: it teaches the operator
to dismiss the surface, and the real 404 goes with it.

So ask once per user what the token is actually allowed to see —
`x-oauth-scopes`, which GitHub sets on every API response — and let that
decide what a 404 is permitted to mean. No scope, no verdict: it
downgrades to `unchecked`, which already exists and is already excluded
from auto-resolve.

Absence of the header, or a failed call, counts as "cannot see private" —
the pessimistic read is the only safe one here, because the cost of
guessing wrong is a false alarm about a repo that is fine.

Proven by mutation: trust the 404 regardless of scope → the test fails
with expected 'unchecked'.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 12:57:29 -07:00
CatoandClaude Opus 5 f12b60931a fix(projects): a project page leads with what is wrong, not what the machine is doing (#861)
Measured on production today, evig's Now tab, top of the viewport:

  BUILD
  * Nothing is being built right now          [ Make it happen ]
  Last attempt finished partially 24d ago after 16m
  --------------------------------------------------------------
  Security risk  Email verification bypass: anyone can register
                 @revamp-it.ch and get Staff role with admin
                 access to 14 areas                      [Fix]
  4 broken features  ...
  Deploy issue       ...

The page's largest type and its only orange button went to "nothing
is happening". A live authentication bypass was plain grey text
underneath it.

That is the same fault /today had and #855 fixed: the surface reported
the MACHINE'S STATUS where the reader was asking what needs them. Idle
is not news; a security hole is.

So the flags lead WHEN THERE ARE FLAGS, and the build status leads when
there are none - at which point "nothing is being built right now" is
genuinely the most useful thing the tab can say. Need above status, but
only when there is need. The block carries one warning rule and no tint
(principles 2 and 3), and the heading names the count in words rather
than showing a bare number.

Raising, editing and clearing still live in ProjectFlags further down,
which is always rendered.

Gate: scripts/test/project-leads-with-need.ts, 5 checks, picked up by
the test-unit glob. Proven by mutation - restoring build-above-flags,
rendering the alarm unconditionally, and tinting it instead of ruling
it each fail, on the matching check.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 12:38:37 -07:00
CatoandClaude Opus 5 264101889b feat(projects): notice when a repo moves, and fix it without asking (#860)
`git_url` was written once, when a project was registered, and trusted
forever. Nothing ever asked GitHub whether it was still true.

Measured against production on 2026-09-22: eight of thirty-three stored
repos were wrong. Four point at repositories that no longer exist (three
are abandoned factory experiments), two at a retired personal account
that has since been renamed, two at deleted scratch repos.

That is not cosmetic. git_url is the address every agent dispatch, clone
and CI lookup starts from, so a stale one surfaces as a confusing build
error inside a run the operator already paid for, rather than as "this
project points at nothing".

THE DISTINCTION THIS IS BUILT ON

GitHub already knows the difference between a repo that MOVED and one
that is GONE, and Loki was throwing it away. A rename answers with a
redirect and the new full_name — so Loki can simply fix it, which is the
automatic repair that being connected to GitHub is supposed to buy. A 404
cannot be repaired by a machine: deleted, or made private, or renamed
away without a redirect, and the only honest response is to say so once.

  moved     → healed silently, logged
  gone      → one alert, refreshed not duplicated
  unchecked → neither, and explicitly NOT counted as healthy

That third state is load-bearing. A dead token or a network blip must
never read as "all repos fine" — the auto-resolve is gated on it, so a
tick that could not look can never clear a real alert.

- src/lib/github-repo-ref.ts — parsing and one lookup, kept apart from
  the route so both are testable with no network and no database
- src/app/api/crons/check-project-repos/route.ts — daily 06:20 UTC
- project_repo_missing registered in config/alert-types.ts, whose own
  gate checks the producer file really raises it

scripts/test/github-repo-ref.ts covers 15 stored URL forms (ssh remotes,
trailing .git, deep links, a dot in the repo name, non-GitHub hosts) and
pins all three verdicts across 9 responses. Case alone is not a move —
GitHub is case-insensitive here, and healing on case would rewrite rows
forever without changing anything.

Proven by mutation: treat 401/403 as healthy → "HTTP 401 must be
unchecked, got ok"; stop detecting renames → the moved assertion fails.

tsc caught a real bug pre-commit: the summary's `ok` count would have
overwritten the response's boolean `ok`, so every caller checking it
would have read a number. Renamed to `healthy`.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 12:32:06 -07:00
CatoandClaude Opus 5 923f0bf4ef fix(feedback): one declaration of the summary shape, and a legible assertion (#859)
Two follow-ons found by the gate from the previous commit.

1. The summary SHAPE was declared three times. NotificationPanel and
   NotificationsPill each carried a structural copy of
   ProjectFeedbackSummary. A second declaration never breaks at runtime,
   which is why it survives - it just quietly stops seeing any field the
   real type gains. Both now import it, and the gate has an eighth check
   that refuses a re-declaration. I only spotted the panel by hand; the
   gate found the pill.

2. scripts/hetzner/test-retire-site.sh failed once inside a full verify
   ("expected output to mention 'DRY RUN'") and then passed 25/25
   standalone. The cause is still unknown - it only misses under
   concurrent load - and it was undiagnosable after the fact because the
   assertion prints what it WANTED and never what it GOT. has() now dumps
   the first 400 chars of the actual output on a miss, in the three
   hetzner suites that share the idiom. Proven by mutating an assertion to
   look for a string that is not there.

Not claiming the flake is fixed. Claiming the next occurrence will say
what happened instead of costing an hour of guessing.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 12:21:35 -07:00
CatoandClaude Opus 5 ce7ecd3e91 chore(account): deleting an account cannot silently stop working (#858)
`deleteUserAccount` hand-clears every table whose user FK is not
onDelete:"cascade", because the users row cannot go while such a row
points at it. That was seventeen `tx.delete(...)` calls in a fixed order
with a comment asking the next person to remember, and nothing checked it.

So adding a table with a plain `references(() => users.id)` broke account
deletion silently. tsc is happy — the new table is simply not mentioned.
Every test is happy — nothing exercised the path, in either direction:
`deleteUserAccount` had exactly two references in the repo, its route and
itself. The failure surfaces only when a real person opens Settings →
Danger zone, types their email to confirm, and gets a 500 on the one
action they cannot retry their way out of.

Measured against production first: seventeen tables need clearing and all
seventeen were already handled, so this goes in green. It is here to keep
that true, not to fix a present break. (The FK violation seen earlier in
this session came from a raw SQL DELETE that bypassed this function —
the app's own path was already correct.)

- the list moves to src/db/queries/user-purge-tables.ts and becomes data
  the function iterates, so the code and the declaration cannot disagree
- it lives apart from users.ts because users.ts imports `@/db`, which
  opens a client at module load; the gate has to run in CI, where there
  is no database (same reasoning as the deferred import in lib/email.ts)
- scripts/test/account-deletion-covers-every-table.ts derives the truth
  from drizzle's own table metadata, never by parsing source — a regex
  over `.references(` would be a second, weaker description of the same
  fact. It checks BOTH directions, so an entry left behind after a table
  gains onDelete:"cascade" is reported too, rather than sitting there as
  a no-op that reads like protection.

Proven by mutation, three ways: drop a table from the list → names
goals.user_id as blocking; give a listed table onDelete:"cascade" → names
it as a stale entry; add a new table with a plain user FK → names
gate_probe.user_id. scripts/test-unit.ts globs the directory, so the gate
is wired into `verify` by existing, and it ran green there.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 12:11:11 -07:00
CatoandClaude Opus 5 15977ee864 fix(feedback): one derivation of "N needs you", and it counts the right things (#857)
Measured on production today, on a single screen: the sidebar badged
Feedback 4 while /today's front-door verdict — shipped an hour earlier to
end exactly this — said "5 feedback reports to triage" four inches away.

Four derivations of one number existed, in three spellings:

  use-control-inbox    sum of (s.newCount || s.openCount)
  NotificationsPill    sum of (s.newCount || s.openCount)   hand copy
  ControlInbox         s.newCount > 0 ? s.newCount : s.openCount
  FeedbackNavCount     sum of s.newCount

The majority formula is not merely duplicated, it is backwards. openCount is
new + dispatched, so a project with 1 new and 4 dispatched contributes 1,
and one with 0 new and 4 dispatched contributes 4: the further along a
project gets, the MORE it inflates a number captioned "to triage".
Dispatched means an agent already has it - the opposite of waiting on you.

The fallback was added so a project chip would not vanish mid-watch when its
last NEW row flipped to dispatched. It never did that job:
listFeedbackSummary already filters status IN (NEW, DISPATCHED), so every row
it returns has openCount > 0 and the chip stays listed on its own. The
fallback only ever leaked in-progress work into a count of pending judgement.

So: triage is the count, presence is the list, and they are different
questions - asked by name in src/lib/feedback/queue-counts.ts. Removing the
fallback re-created the mid-watch bug for real (the group was gated on the
count), so the group is now gated on presence and counted on pressure, and a
project with nothing new says "in progress" instead of showing a number that
reads as work you owe.

Gate: scripts/test/one-number-for-feedback.ts, 8 checks, picked up by the
test-unit glob. Proven by mutation - restoring the fallback, re-deriving the
count in the sidebar, counting openCount in the owner, and re-gating the
group on the count each fail, on the matching check.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 11:48:48 -07:00
CatoandClaude Opus 5 8c9faf2a44 fix(crons): the backfill starved every project past the first few (#856)
The tick walked the projects in order and stopped at its budget, from the top,
every time. So a project far enough down the list was never reached — not
"eventually", never.

Measured on prod while catching up the five-day outage: three consecutive
ticks each reported `posted: 30, capped: true`, and across all three Heidi's
wall went 0 → 0 → 0 correct links while the head of the list was re-sent its
same thirty moments. The janitor looked busy and was starving its own tail,
and the counters could not tell the difference: thirty posts is thirty posts
whether they are thirty projects moving forward or one project repeating.

Round-robin makes the budget a SHARE rather than a race — every project's
queue is built first, then one moment is taken from each in turn. Every wall
moves every tick, a project with a large backlog cannot hold the others
hostage, and an empty queue simply stops being asked, so unused turns are
reclaimed rather than reserved.

verify: tsc, lint (0 errors), test:unit 252/252.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 11:10:56 -07:00
CatoandClaude Opus 5 230000cb4d feat(today): the front door says what needs you (#855)
Measured on production with /today fully expanded: the page mentioned
"feedback" ZERO times, "failed" ZERO times and flagged projects ZERO times.
What it showed was a greeting, the weather, an empty sticky note, and "92 runs
this week" — while the sidebar three inches to the left badged "Feedback 4".

So the front door reported VOLUME. The one question it exists to answer —
"what needs me?" — was answered three clicks away on Control, and answered
DIFFERENTLY again on Activity (Control's 7 was 5 feedback + 2 widget;
Activity's 7 was attention events).

The verdict now renders first, above the weather and the note.

ONE OWNER, NOT A THIRD COUNT. It reads `useControlInbox` — the same hook
Control's own inbox uses — so the two surfaces cannot disagree about the
number. A third derivation of "needs you" is precisely how there came to be two
different sevens. Flagged projects come through `hasProjectAttention`, the same
predicate the projects list sorts by, and honour `valid_until` the same way, so
a project cannot be flagged on one page and calm on another.

A FAILED FETCH IS NOT "NOTHING". On a page whose whole job is to be trusted
when it says you are free, a request that errored must never render as the
confident answer "no" — it says "could not check", disclaims itself, and offers
a retry. The hook already modelled this; nothing had been reading it.

An empty queue is SAID, not left blank: a page that shows nothing when nothing
is wrong teaches you to distrust its silence.

Flags are NAMED with their own words ("evig — Email verification bypass…"), not
counted. A count is a number to go and decode; the sentence is already in the
database.

Styling follows the principles added in #848: no box and no colour in the calm
state, a single warning rule in the alarm state, and nothing tinted but the
alarm.

Guarded by scripts/test/today-answers-the-question.ts (7 checks), which pins
the two honesty rules — one owner, and a failed fetch is never an all-clear —
as hard as the ordering.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 11:05:52 -07:00
CatoandClaude Opus 5 d90d180a07 fix(crons): the backfill spent a third of every tick being refused (#854)
OrangeCat allows 30 writes per minute per user (rateLimitWriteAsync, sliding
60s window). This janitor fired its whole tick as fast as the event loop
allowed, so the first tick after the five-day publishing outage reported
exactly what the arithmetic predicts:

    {"projects":9,"attempted":50,"posted":30,"skipped":0,"failed":20}

The first thirty landed, the bucket emptied, and the remaining twenty came
back 429 and were counted as failures. Not a flake to retry past — ANY backlog
over thirty burned the rest of its budget on refusals, every tick, and the
deterministic external ids meant the next day re-sent the same doomed twenty.

Paced at the neighbour's published limit with headroom (60000/30 = 2000ms →
2100ms), nothing is refused and nothing is wasted. The number comes from their
limiter, not from tuning until the errors stopped.

With a pace comes a clock, so the tick now also stops at 90s — under the
systemd timer's `curl -m 120`. A tick killed mid-flight reports nothing at
all: no counts, no debug_logs row, just a dead curl. Ending early and saying
`capped` keeps its account of itself intact, and the rest is picked up next
tick.

verify: tsc, lint (0 errors), test:unit 252/252 — the new test derives its
floor from the neighbour's documented limit rather than restating a constant.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 11:00:08 -07:00
CatoandClaude Opus 5 91eeb2cddc fix(design): the health value stops being the only boxed thing on the row (#852)
Looked at the rebuilt list on production. The rail lines up — one row height
(64px, was 71/79/81) and the run column dead level at 0px spread — but the
health value still sat in a bordered pill, and it was the ONLY boxed thing
there. Two of the principles I had just written, broken by my own change:

  · Principle 3, space separates and boxes are a last resort.
  · Principle 2, emphasis belongs to alarms — that pill pulled the eye harder
    than the flag count beside it, which is the one thing on the row that is
    actually an alarm.

It also kept 8px of column jitter, because a pill's width follows its text
("7/10" vs "10/10"). Plain tabular text, full cell width, right-aligned: the
column edge is exact and the number is as quiet as the date beside it. Still a
button, still opens the breakdown.

THE GATE WAS STRICTER THAN THE SPEC, which is its own kind of wrong.

CLAUDE.md's four-layer architecture already rules on arbitrary values: colour
and typography never, one-off LAYOUT constraints explicitly permitted. My gate
treated both alike, so it would have blocked work the documented policy allows
— and a gate that contradicts the spec it claims to enforce is one people
learn to route around. Split in two: colour/typography is zero-tolerance,
layout is ratcheted at 16.

That split immediately found a real pre-existing violation the blanket version
had buried: `drop-shadow-[0_0_4px_var(--surface-page)]` in scroll-affordance,
which the spec names explicitly as forbidden. Named as
`.ui-scroll-affordance-glyph` rather than excused — a visual decision belongs
in globals.css even when its value is already a token.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 10:38:06 -07:00
CatoandClaude Opus 5 0f62687a9d fix(settings): the account page said things that were not true (#850)
Reported from the live page: pressing Reconnect on OrangeCat does nothing.

It is worse than nothing. The round-trip SUCCEEDS — measured on prod:
/api/auth/callback/orangecat returned 200 and redirected back to /settings —
and the row still read "Needs reconnecting" afterwards, forever.

Auth.js writes the OAuth token set through the adapter's linkAccount(), and
linkAccount only runs when the link is NEW. Sign in again on an account that is
already linked and the fresh tokens are discarded. The stored row kept
refresh_token NULL and expires_at 2026-09-17 — five days stale — so
getOrangeCatLink() still returned null. The button could not repair the thing
it was named after, and the only way out was Disconnect-then-Connect, which
nobody would guess.

Now the signIn event upserts the fresh tokens onto the existing row. Upsert
rather than unlink-then-relink: deleting first would leave the account unlinked
if the round-trip failed halfway. refresh_token is only overwritten when the
provider actually sent one, so a response that omits it cannot blank a good one.

WHILE LOOKING, THREE MORE CLAIMS ON THE SAME PAGE TURNED OUT FALSE

"The others are sign-in only — nothing here can be broken in a way this page
could detect or a reconnect would fix." That was the stated reason the health
check covered OrangeCat alone, and it is false. The GitHub link carries `repo`
scope — full read/write on private repositories — and Loki acts through it in
six places: /api/github/repos, projects/[id]/enrich, bulk-from-github,
project-dossier, github-org-token, reap-evidence. A revoked GitHub token breaks
all six silently while the row shows "Connected" in green, which is precisely
the five-silent-days failure the OrangeCat check was written to end. GitHub is
now health-checked against /user.

Google IS sign-in only — but it must not claim "Connected" either. Measured
2026-09-22: its stored token expired 2026-06-29, three months earlier, and the
row was green. Sign-in-only links now say so.

The Reconnect button was hardwired to signIn("orangecat"), so the moment GitHub
became reconnectable it would have signed the operator into the wrong provider.
It takes the provider now.

THE EMAIL FIELD SAID "READ-ONLY" AND NOTHING ELSE

True, and useless: a dead end wearing a status badge. Nothing in the codebase
writes users.email — the only write to that table is emailVerified — so the
constraint is real and permanent. It now says where the address came from and
that a new account is the only alternative, instead of leaving the operator
hunting for a button that does not exist.

AND THE TAB HASH WORKED IN ONE DIRECTION ONLY

resolveInitialTab ran in a useState lazy initializer: read once, at first
render. So /settings#agent opened the Agent tab when arriving from /control and
did NOTHING when the hash changed while already on /settings — including
browser Back. Every in-app link to a settings section was a coin flip depending
on where the operator happened to be standing.

The reverse was missing too: clicking a tab moved React state only, so the URL
never changed and could not be shared, bookmarked or reloaded onto the section
being looked at. Added a hashchange listener and replaceState on click —
replaceState so switching tabs does not stack history entries.

GATE

scripts/test/orangecat-link-recovery.ts pinned the exact source line and
correctly failed when this change extended it. It was not loosened: it now
asserts the BEHAVIOUR it names, and covers the two new cases — GitHub must be
health-checked, and a sign-in-only link must not read "Connected". Proven by
mutation: delete the GitHub check and it fails by name.

RESPONSIVE

/settings verified clean at 320, 390, 768 and 1440 against production via
scripts/test/responsive-audit.mjs — no overflow, no clipped text, no touch
target under 44px. Worth recording for whoever runs it next: the audit reports
"landed on /sign-in" when its session is not accepted, and still prints a tick
for the page it did load. Three earlier runs here were unauthenticated because
AUTH_SECRET was read with `cut -d= -f2-`, which keeps the quotes from the .env
line — 46 chars where the process uses 44. Check for that note before trusting
a pass.

verify: exit 0.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 10:13:08 -07:00
CatoandClaude Opus 5 a4ac97c3d3 fix(auth): signing in again never repaired the link it was the remedy for (#849)
`DrizzleAdapter.linkAccount` writes an account's token set exactly once — on
the first connect. Every sign-in after that authenticates the person and leaves
the stored tokens untouched. So "sign in with OrangeCat again", which is the
remedy every broken-link message points at and the thing the Reconnect button
triggers, could complete perfectly and change nothing.

Measured on prod today, minutes after the owner pressed Reconnect: OrangeCat
had issued FIVE fresh token sets that day, none revoked, while Loki's accounts
row still held a null refresh token and an access token five days expired. Both
halves worked. The join between them did not exist.

That is also why the outage could not heal itself. A stranded link had no way
back AT ALL — not through refresh (its token was revoked at rotation) and not
through re-consent (the answer was discarded). The alert I added last week told
the owner to press a button that could not work, which is worse than no button.

Every provider, not only the one that broke: Loki stores these tokens to act as
the user, a re-authorization is the user handing over fresh ones, and there is
no provider for which keeping the older set is the better answer. Scopes cannot
narrow underneath us — each provider's are fixed in its config here.

The alarm goes down with the fault: a repaired OrangeCat link dismisses the
`orangecat_link_broken` alert, so it cannot outlive its own repair and say
"publishing is paused" while publishing works.

verify: tsc, lint (0 errors), test:unit 250/250. The predicate lives in a
db-free module so the DB-free suite can exercise it.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 10:07:06 -07:00
CatoandClaude Opus 5 a8c0f8158b refactor(design): give the design system a grammar, and rebuild the project row on it (#848)
George: "I thought our design was centralized and all pages would be elonesque,
including principles."

The tokens WERE centralized — sixteen arbitrary values across the whole
component tree, which is disciplined for a product this size. What was missing
was any rule about how to COMPOSE them. So every page invented its own density,
its own use of colour, its own row shape, and the product stopped looking like
one product. Tokens without a grammar are a palette, not a design system.

globals.css now states the grammar, as eight load-bearing principles: type does
the work; colour is for alarms; space separates; one row one height; columns
fixed and numbers tabular; no decoration on a control that already reads as
one; every value from a token; nothing claims more than it knows.

THE PROJECT ROW IS REBUILT ON THEM, not patched again.

Gone, and why:
  · A BADGE PER FACT — stage, up to three flags with ages, Needs path, Team.
    A row was two to seven coloured chips, so every row was a different shape
    and the page read as chip soup. Colour is now spent ONLY on flags, which
    are the one thing here that is actually an alarm; stage is quiet text and
    flags collapse to a count whose tooltip carries every note.
  · THE SEGMENTED BAR. Shape of a meter, content of a checklist. The score
    says it in four characters; HealthScoreBar gains a `compact` mode and the
    full readout stays on the project's own page, where there is one of it.
  · THE CHEVRON, on a row that is entirely a link already.
  · THE ARROW before the description, on all 25 rows.
  · CONTENT-SIZED COLUMNS. Measured on prod: 37px of horizontal jitter in the
    right-hand column and three row heights (71/79/81px), so nothing lined up
    in either axis. The rail's four cells are fixed-width and tabular now.

scripts/test/design-principles.ts enforces what can be enforced: the
principles must survive in globals.css, the rail must stay fixed-width and
tabular, the row must keep one height, the row must spend no colour but the
alarm, and arbitrary values RATCHET — they may fall or hold, never rise. The
baseline is 16, corrected from a "9" I had quoted from a narrower pattern; the
number given to a human should be the one the gate measures.

Also fixed: mobile-shows-what-the-list-sorts-by pinned `sm:hidden` INSIDE the
component, so it failed the moment the classes moved to globals.css as
principle 7 requires. That is the second gate today to encode an
implementation instead of a rule. It now reads both files and asserts the
intent.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 09:59:38 -07:00
CatoandClaude Opus 5 cc85390123 feat(projects): a flag can now be raised, edited and cleared (#847)
The third of the three "hard-coded demo" findings, and the worst of them.

A flag — security_vulnerability, broken_features, deployment_issue — is the
loudest signal in the product: it sorts a project to the top of /projects,
colours its row, and costs a health point. The complete set of ways to RAISE
one was: an agent writing the attr through the API.

There was NO UI. And the one surface that lets a person type an arbitrary attr,
"Additional context", excludes exactly these three keys on the grounds that "a
dedicated UI owns them" — a dedicated UI that did not exist. So the exclusion
only meant there was nowhere at all.

The result is what George saw: a red badge on evig, no way to tell what put it
there, no way to raise the same flag on a project that deserved one, and a
clear path buried inside a health disclosure. He called it "magic, or some
other non-scalable, stupid solution". It was the second one — three free-text
fields with no author and no door.

<ProjectFlags> is the door. All three signals always listed (a control that
appears only once the thing has happened cannot answer "how do I flag this?"),
each showing its note, when it was written and by what, with Raise / Edit /
Clear. On the Context tab, beside the other things a person writes about a
project.

NOTHING HERE DETECTS ANYTHING, and the copy says so in the first sentence: "A
flag is a note someone wrote — an agent or you. Nothing here scans the
project." Dressing three text fields up as monitoring would be the same lie in
better clothes. The panel also states the COST up front — top of the list, one
health point — so that is known before writing one rather than discovered
after.

getProjectDetail now loads attribute provenance (same single query), so the
project page can say "noted 6mo ago by loki-ui" instead of showing an
anonymous sentence.

Guarded by scripts/test/a-flag-can-be-raised-and-cleared.ts (9 checks), which
pins the HONESTY rule as hard as the mechanics: the copy must never contain
"detected", "monitoring" or "scans the project for", and must say what a flag
costs.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 09:19:53 -07:00
CatoandClaude Opus 5 ab6fb13ffa fix(orangecat): the link answer missed the project that needed it most (#846)
`/api/orangecat/project-link` asked `orangecat_entity_links` and nothing else.
Two tables record "this OrangeCat project is built here" — that one, and the
legacy `user_projects.orangecat_project_id` column that predates it and is
still written by every publish for the funding read path.

They normally agree. Measured on prod the hour the route shipped, one of nine
published projects had the column and no link row — and it was Loki's own. So
the route answered "not linked" for a project that has been building in public
for months, which is the exact wrong answer it exists to stop giving, on the
one page most likely to be looked at as an example of the thing working.

Both are asked now, consent is required from whichever answers, and the test
pins that it is BOTH rather than whichever happened to be enough that day.

verify: tsc, test:unit 248/248. Live against prod before the change:
Heidi → linked, Loki → NOT linked; both have public profiles at /fleet.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 08:37:29 -07:00
CatoandClaude Opus 5 5dc7e89d51 test(gate): a number written in prose must match what it counts (#845)
Someone writes "all 11 sections" beside an array of 11 things. The array grows
to 12. The sentence does not, because nothing is watching it — not tsc, not
eslint, not any test. The prose is now wrong and stays wrong, and it reads as
authoritative precisely because it sits next to the code.

Every claim this gate covers was ALREADY stale when it was written, and it
found all three before being told any answers:

  SettingsTabs.tsx      says 11 settings sections, but there are 12
  terminal-keys.ts      says 23 terminal keycaps, but there are 24
  telemetry-paths.ts    says 3 hourly cron timers, but there are 5

Fixed, and now gated.

WHY A GATE AND NOT THREE EDITS

This is the fourth stale number corrected by hand in a single sweep — the
Whisper model sizes, the /download artifact sizes, the 0.8.19 pin in
desktop/README, and "the 1845-line globals.css" (6073). A number that has gone
stale once will go stale again the moment the structure moves, and the person
who moves it has no reason to grep prose for arithmetic.

TWO THINGS THAT MAKE IT A GATE RATHER THAN DECORATION

A pattern pinned to a sentence silently stops matching when someone rewords
that sentence, and then reports success forever — which is the exact defect
found in scripts/smoke.sh this week, where the auth middleware answered 401
before routing so every probe passed whether the route existed or not. So a
non-matching pattern here is an assertion FAILURE that names the file and says
to fix the pattern in the same commit.

And it deliberately covers only what this repo can derive. The box being a
CX33, an artifact's size in MB, a model's download size — no source here
settles those, so they cannot be gated and should not be written down. The
sweep deleted several rather than restate them; the file says so, because the
next person will be tempted to add one.

Proven by mutation: adding a 13th tab to SettingsTabs makes it exit 1 naming
both numbers; restoring makes it exit 0. The mutation itself is asserted before
the result is trusted — a mutation that silently fails to apply produces a
"passing" gate that was never actually tested.

verify: exit 0.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 08:24:59 -07:00
CatoandClaude Opus 5 bcf140a9e6 fix(projects): stage becomes a real vocabulary, and "active" stops lying (#843)
Two of the three things George identified as "hard-coded demo bullshit". Both
are missing CONTRACTS, not missing features.

STAGE WAS FREE TEXT WEARING AN ENUM'S CLOTHES.

`status` is an arbitrary string. The badge coloured it from a 13-key map and
`shortProjectStatus` returned null for anything else — so a project whose stage
read "Early Stage" or "MVP" showed NO BADGE AT ALL, indistinguishable from one
that had never set a stage. Nothing constrained the value, so two projects
could mean different things by "Development" and no code would notice. And
there was no list anywhere of what the stages ARE, so "what counts as
pre-launch?" lived in nobody's head.

Every other vocabulary in this product is declared in lib/constants/statuses.ts
— goals, sessions, actions, events, feedback, human tasks. Stage never joined
them. PROJECT_STAGE does now: seven stages in LIFE order (the order is the
meaning), each with a written definition shown in the tooltip, plus an explicit
legacy map for values already in the data.

An unresolvable value is now SHOWN and marked — dashed border, a "?", and a
tooltip naming the real stages — because "this project's stage is a word nobody
defined" is a fact worth seeing. Swallowing it was the actual bug.

"ACTIVE" MEANT SOMETHING ELSE.

The row said "active 10h ago". That is the newest AGENT DISPATCH from
prompt_history. George had not touched printcraft in months; a 06:00 autopilot
run made it "active". Worse, #830 ORDERED the whole page by it under a subtitle
promising "most recently active" — so the list ranked his projects by when a
robot last ran, in a word that means he did.

Now "last run 10h ago" / "never run", with the subtitle and both sort hints
saying agent run. The Recent hint says outright: "not when you last worked on
it".

Guarded by scripts/test/stage-is-a-real-vocabulary.ts (8 checks), which pins
the RULE and not just the values: an unknown stage must never be swallowed, the
legacy map must stay explicit rather than fuzzy, and the row must not filter
stages through a hardcoded list again.

Still open, deliberately: the three flag attrs (security_vulnerability,
broken_features, deployment_issue) have no writer and no way to set one from
the UI. That is the third of George's three and it needs its own change.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 08:12:23 -07:00
CatoandClaude Opus 5 814632e739 fix(orangecat): "Connected" meant a row existed, not that the link worked (#842)
Two halves of the same mistake — a stored value read as a state of the world.

SETTINGS ASKED THE COLUMN, NOT ORANGECAT. #841 reported a link as broken when
its refresh-token column was empty, which sounds like a health check and is
not one: the column is only emptied once a refresh has actually been attempted
and refused. Measured on prod the day it shipped — the link had been dead five
days, the revoked token was still in the column, and the page said "Connected"
in green. It now resolves the link the way every publish does; when OrangeCat
refuses, that same call retires the credential and raises the alert on its way
out. (Being signed INTO Loki with OrangeCat never repaired this: the session
cookie and the stored OAuth token set are different things, which is how a
person can be looking at a Loki they logged into through OrangeCat while Loki
cannot speak to OrangeCat at all.)

ORANGECAT OFFERED TO BUILD WHAT IT ALREADY HAD. Its project page shows "Build
it with Loki — one click: creates the project and puts an AI agent on it" to
owners of projects that have been building here for months, because nothing on
that page could tell the difference. The click was always safe — the handoff
screen flags an already-linked project rather than creating a second one — but
the card was addressing a stranger. `GET /api/orangecat/project-link` answers
it, and answers the more valuable question too: a funder on a public project
page had no way to reach the build record.

Public without a signature, by construction rather than by intention:
`linked: true` requires the Loki project to carry listed_publicly, so every
field returned is already served at /fleet and /fleet/<slug>, and a project
without that consent answers byte-identically to an id nobody has heard of.
The consequence is stated rather than hidden: for an unlisted project
OrangeCat keeps saying "Build it with Loki" — a worse label, not a broken
path.

verify: tsc, lint (0 errors), test:unit 246/246 — including api-route-auth,
which refused the new route until its public stance was written down.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 08:06:23 -07:00
CatoandClaude Opus 5 a94458870d fix(settings): a broken OrangeCat link read "Connected" and offered no way back (#841)
The link this account publishes through has been refused by OrangeCat since
2026-09-17 — every project publish, dev-log entry and closed run silently
skipped. Settings listed OrangeCat as Connected, in green, with Disconnect as
the only button: the page could not tell a LINKED account from a WORKING one,
and the single action that repairs it was the one action it did not offer.

The alert raised when the token is refused points here, so this is the screen
that has to show the way forward — CLAUDE.md's rule that a gate records but
never blocks, applied to the place a person actually lands.

`needsReconnect` is scoped to OrangeCat on purpose: getOrangeCatLink clears the
refresh token exactly when OrangeCat has refused it, so an empty column there
MEANS broken. A GitHub OAuth app never issues one, and the same test would call
a healthy link broken.

verify: tsc, lint (0 errors), test:unit 245/245.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 07:23:40 -07:00
CatoandClaude Opus 5 d8ce9e03af feat(projects): the order is a control, not just a claim (#840)
#830 made the sort legible by stating it in the subtitle. Stating an order
makes it understandable; only a control makes it arguable — and there are two
real questions this page's default cannot answer at once:

  "what moved?"           — a project flagged in March should not sit on top
  "where is X?"           — neither recency nor attention helps you find it

Priority / Recent / A-Z. The same three Control's project rail has carried for
a while, on a second, smaller copy of this same list — this is the half of that
duplication worth keeping, and the type and labels now live in one place rather
than being retyped per page.

THE EXPLICIT ORDERS ARE FLAT. No tiers at all: someone who picks "Recent" is
asking one question, and hoisting a flagged project above this morning's work
is the page overruling them. Tiering is what "Priority" MEANS, not a property
of the list every mode inherits.

Persisted in the URL beside q and filter, and only when it differs from the
default — so the common URL stays clean and a shared link carries the order the
sender was actually looking at. An unrecognised value falls back to Priority
rather than silently reordering the page; there is a test for that, because a
sort read from a query string is user input.

A radiogroup rather than three buttons: one choice, one answer, arrow keys.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 07:06:02 -07:00
CatoandClaude Opus 5 0464358605 fix(orangecat): the wall went silent, and every link on it pointed at a login (#839)
* fix(orangecat): the wall went silent, and every link on it pointed at a login

Three failures on one seam, each invisible from inside Loki because the
symptom is on somebody else's page.

THE WALL STOPPED. OrangeCat rotated this account's refresh token at
2026-09-17 07:42:44 and issued a replacement that is still valid and was
never used; Loki kept presenting the one that rotation REVOKED at that
instant. Every refresh since answered 400, getOrangeCatLink returned null,
and every promote was skipped as "feature unavailable" — across every
project, for four days. The last entry to reach any OrangeCat wall was
posted eight minutes before that access token expired. The only trace was
66 console.warn lines on the box.

Verified by hashing the stored token and finding its row in OrangeCat's
oauth_refresh_tokens: revoked_at = 2026-09-17 07:42:44.

Three rules follow, none of them a repair: one refresh at a time per
account (the backfill cron fires up to 50 promotes at once, so a burst was
guaranteed to look like a broken link); a spent refresh token is never
written back (`?? account.refresh_token` reads as defensive and stores a
credential that can only ever fail); and a dead link raises an alert,
because re-linking needs a human click and nobody clicks what nobody sees.

EVERY LINK POINTED AT A LOGIN. Wall entries carried a hardcoded
`${LOKI_PUBLIC_ORIGIN}/projects` — the private dashboard. A stranger
following "via Loki" from Heidi's OrangeCat page got a sign-in form; the
owner got all 36 projects instead of the one the entry was about. Twelve
such links on that page alone. The right page has existed the whole time:
/fleet/<slug>, now derived exactly as the register derives it.

THAT PAGE WAS UNREADABLE ON A PHONE. Measured at 390px: 737px of roadmap
content in a 390px column, clipped by .ui-public-surface's own
overflow-x:hidden — 47% of every milestone line unreachable, no scrollbar,
no ellipsis. Cause: unbreakable GitHub URLs in prose. Fixed on the
ui-public-* prose tokens in globals.css, so it holds for every public page.
Also on that page: three of six "changelog" entries were internal dispatch
bookkeeping (two announcing a FAILED dispatch, stored truncated mid-word),
a `Source: <url>` provenance pointer rendered as an untickable milestone,
"0% recorded progress" under every item, and a raw ISO timestamp.

NO GATE COULD HAVE CAUGHT IT. audit-covers-every-page skipped every route
containing "[", so /fleet/[slug] — the template behind all 36 public
profiles — had never been measured at any width. Dynamic routes now take
the same decision as static ones: a concrete sample (/fleet/heidi,
/u/cato, one essay) or a line in NOT_MEASURED saying what it would take.
The overflow detector could not have seen it either — it reads
documentElement.scrollWidth, which the clip holds at the viewport width —
so there is a new one asking the reader's question: can I get to the rest
of this sentence? A listed route that 404s now fails, because a rotted
sample looks exactly like a covered route.

Two gates lied and are fixed with it: the audit's list parser ended an
array at the first "]" in a comment, and alert-registry read
`grant_type: "refresh_token"` as an unregistered alert type.

AND THE FEED IS NOW A CHOICE. Publishing did two things under one press:
it created the public page and enrolled the project in a live feed of
everything its agents did, with no switch — "stop telling everyone what my
agents are doing" cost you the funding page. user_projects.orangecat_autopost
separates them, three-state like auto_ship (null = nobody has chosen, and
an unanswered question is not consent). Reversible either way, without
touching the page. Already-published projects are backfilled to true:
introducing consent must not silently stop a feed someone relies on.

Left on, it is the strongest thing a public project page can carry —
dated evidence of work, which is the half of a transparency claim that
better copy cannot manufacture.

/fleet/[slug] also now reads CONSENT rather than ownership (it resolved any
slug in the owner's map, which the catalogue beside it has never done), and
a slug with no public profile gets an invitation instead of a dead end.

verify: tsc, lint (0 errors, 2 pre-existing warnings), test:unit 231/231.
The page itself is measured against prod after deploy — it cannot be
measured before.

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

* fix(smoke): the pre-push gate blocked a push over another app's dev server

`/api/health` answering with a `"commit"` field was the whole identity test,
and every app in the fleet serves that route from the same template. On
2026-09-22 a Heidi dev server held :3000 first; Loki's 48-route auth smoke ran
against it, reported 23 routes returning 404, and failed the push — a verdict
about somebody else's app, delivered as a verdict about this one.

A name cannot be mistaken for another name: health now says which app answered,
and the hook asks for "loki" instead of for a shape. Additive to the payload,
so the deploy assertion, the uptime sweep and check-deploy-ref are unaffected.

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

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 07:04:07 -07:00
CatoandClaude Opus 5 8afc84bf08 fix(pre-push): skip the smoke against a server that has no database (#838)
"Is this Loki?" was answered by the presence of a `commit` field in
/api/health. A Loki process started without DATABASE_URL satisfies that
perfectly: it answers health and 404s every database-backed route. So the hook
smoked it and failed 23 of 48 routes — on changes that could not possibly have
caused it (CSS, one copy string, a sort comparator).

Seen twice on 2026-09-22 against a dev server left running without a database.
Both pushes went out --no-verify and CI passed the identical bundle each time.

That is the worst shape a gate can take: it blocks correct work, names the
wrong cause, and teaches you to bypass it — after which it protects nothing.
The payload already reports `schema.state`, so the hook had the fact it needed
and never looked.

It now skips, rather than fails: the state of a server on someone's laptop is
not the pusher's problem, and failing here is exactly what makes --no-verify
reflexive. The message names the cause and the cure (pnpm run db:push).

Deliberately narrow — a healthy server is still smoked, and the "not running"
and "not Loki" branches are untouched. The test pins all of that, so this
cannot quietly widen into "never smoke anything".

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 06:37:19 -07:00
CatoandClaude Opus 5 6beb7be241 fix(projects): the panel shows the problem it was opened to show (#837)
Two faults, both found by opening the disclosure on production and READING it.

1. THE EVIDENCE WAS CUT AT 80 CHARACTERS. Every check's detail went through the
   same truncate(), which is right for a field preview (a repo URL, a stage)
   and wrong for the three signal checks, whose detail is a report a person or
   an agent wrote. evig's security note rendered as

       "Email verification bypass: anyone can register @revamp-it.ch domain
        and get Sta…"

   cut mid-word, in the one place you go to read it. EVIDENCE_MAX (400) applies
   to those three only; field previews stay at 80. Still bounded, so a
   pathological note cannot push the actions off the bottom of the panel — the
   panel already scrolls.

2. THE HEADING CONTRADICTED ITS OWN BODY. A failing row was titled with the
   check's GOAL state:

       No security risks open
       Email verification bypass: anyone can register…

   `label` is correct in the tooltip's "missing: …" list — the missing thing
   really IS that state — and wrong as a headline printed above the risk
   itself. Failing rows now use `failLabel` (the problem's name); passing rows
   still name the goal, and the tooltip is untouched.

Detail text also moves from text-muted to text-secondary: it is the content of
the panel, not a caption on it.

Guarded by scripts/test/health-panel-shows-the-evidence.ts (7 checks), using
evig's actual note as the fixture — including that field previews did NOT grow
and that the bound still holds at 5000 characters.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 06:13:52 -07:00
CatoandClaude Opus 5 6588207273 fix(projects): the health panel was unreadable, and I shipped it that way (#836)
Opened the disclosure on production and looked at it. It is unusable: other
rows' text bleeds straight through the open panel, and its sentences are cut
off at the right edge of the screen. Three faults, two of them mine from #832.

1. THE PANEL WAS TRAPPED IN ITS OWN ROW. `.ui-projects-row-actions` carried
   `z-[1]`, which makes every row a STACKING CONTEXT. The panel asks for z-40,
   but z-40 then only ranks it against its own row's children — so every row
   further down the list paints over the open panel. `relative` alone is both
   sufficient and correct: it and the stretched link's ::after are positioned
   with z-index auto, so they paint in DOM order and the actions come second.

   The test from #832 asserted `z-[1]` as a REQUIREMENT. It pinned a broken
   implementation instead of the intent, so it went green on the bug and then
   failed on the fix. Rewritten to demand "positioned, and no stacking
   context", with the reversal explained.

2. THE PANEL OPENED OFF-SCREEN. It hung `left-0` from a chip that sits at the
   RIGHT edge of the row, so a 24rem panel ran past the viewport and truncated
   its own content mid-word ("anyone can register @revamp-it.ch domain and get
   Sta…"). Anchored right, so it opens back across the row it belongs to.

3. "Passes while no broken is recorded on this project." The noun is missing.
   The comment three lines above that string says this exact bug was fixed by
   writing the wording per signal rather than deriving it — and `clearLabel`
   was fixed while `rule` was left deriving from `label`, which is the bare
   word "Broken". The repair stopped one line short of the defect. Rules are
   now written per signal too.

Also in here, and the reason I opened the panel at all: the health track
rendered its segments in CHECK ORDER, so a 7/10 came out as ●●●●●○○●● —
filled, filled, gap, filled. A progress-bar shape carrying checklist content.
Sorted earned-first; position carries no information to anyone, since the
track is aria-hidden and no segment is labelled or addressable, and the test
pins that trade so it fails loudly if a segment ever becomes identifiable.

Every one of these passed a DOM probe. The elements were present, the classes
were right, the gates were green. Looking at the page is what found them.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 05:08:39 -07:00
CatoandClaude Opus 5 1fa8b4a230 fix(projects): a flag's age is terse on the badge, spelled out in the tooltip (#834)
Shipped "Security risk · 6mo ago" in #833, then looked at it on production:
evig carries three flags, each gained ~10 characters, and the third wrapped
onto a second line — pushing the next-step text down with it. The densest row
on the page got taller to say something it could say in four characters.

"ago" does no work beside a label that is plainly a timestamp. The badge is
scanned, so it reads "· 6mo"; the tooltip is read, so it keeps the full "Noted
6mo ago by loki-ui · 30/03/2026" alongside the note itself.

Found by taking a screenshot rather than probing the DOM — the elements were
all present and correct, and the layout was still worse.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 04:23:51 -07:00
CatoandClaude Opus 5 cd67d92439 feat(projects): flags say how old they are, and an expiry finally means something (#833)
"Security risk", "4 broken features" and "Deploy issue" are the TEXT of project
attributes someone — a person or an agent — typed. They reached the list
undated and unattributed, so a note written this morning and one typed in June
looked identical, and both hoisted their project above everything else equally.

THE DATA WAS NEVER MISSING. fetchAttributesByEntityIds does `select()` — it
pulls updatedAt, source and valid_until on every row — and then dropped all
three in its grouping loop, keeping only key → value. Showing them costs no
extra query; the meta variant returns the value too, so getProjects makes the
same single call it always did.

Badges now read "Security risk · 23d", with the exact date and what wrote it in
the tooltip alongside the note itself. Terse where it is scanned, spelled out
where it is read.

VALID_UNTIL IS THE SHARPER ONE. That column has existed on the attributes table
the whole time and NOTHING read it — an author writing "this expires on the
14th" was writing into a field with no consumer. It is honoured now.

That is deliberately NOT auto-decay, which stays George's call: a flag with no
valid_until still stands forever, however old. Inventing a deadline for someone
else's security note would be worse than showing a stale one. And a malformed
valid_until never clears a flag — a typo must not silently resolve a security
issue.

One predicate, three surfaces: the badge, the attention sort and the "Site
issues" chip all call signalHasExpired. It lives in lib/, not beside the badge,
because two of those callers are not React — and because a flag hidden on the
row while still counted by the sort would hoist a project to the top of the
page with nothing on it explaining why.

Guarded by scripts/test/flags-carry-their-age.ts (8 checks), which pins the
policy line as hard as the behaviour: "no expiry means it stands forever" is a
test, so a future change cannot quietly introduce decay. Mutation-tested:
ignoring valid_until fails 2.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 03:27:33 -07:00
CatoandClaude Opus 5 0dfdbd059f feat(projects): the row can hold controls, so health becomes a real one (#832)
The row WAS a single <Link> wrapping everything, with aria-label="Open {name}".
HTML forbids interactive content inside an anchor, so the row had ZERO
interactive children BY CONSTRUCTION — which is the actual reason every number
on it led to the same generic destination, and the reason the health chip could
only ever be a dead <span> explained by a hover `title`: invisible on touch, a
bare "7/10" to a screen reader.

THE CAPABILITY WAS NEVER MISSING. HealthScoreBar has always had an
`interactive` mode — a real button, aria-expanded, a panel naming each missing
point with an inline edit that writes it, and a draft-from-the-brief action.
The list could not use one line of it. Ten named checks, each with its rule and
the exact field that earns it, sat behind a structural prohibition.

Stretched link instead: the project NAME is the anchor and its ::after covers
the row, so the whole row remains one click target while the row itself is no
longer an <a>. Two things improve at once — a screen reader now announces a
link whose text is the project's name rather than an aria-label bolted to a
wrapper, and anything needing its own click sits above the overlay via
.ui-projects-row-actions.

Both classes live in globals.css, per the rule that styling has one home; the
test asserts they are DEFINED there, because a class the CSS does not define
would leave the row unclickable everywhere except the name — a silent, large
usability regression that nothing else would catch.

Caught by the repo's own lint while writing this: `brief` must be the CLEANED
description, never the raw column, or the gap-fill would draft a mission from
the bulk-import placeholder ("Local repository imported from loki-ui"). Good
rule; it fired exactly where it should.

Guarded by scripts/test/project-row-can-hold-controls.ts (6 checks). This is a
STRUCTURAL invariant, not a style preference: collapsing the row back to a
wrapping anchor would silently re-delete every control inside it — the page
would still render, nothing would fail to compile, and the disclosure would
just quietly stop existing again. Mutation-tested: dropping `interactive` fails
the payoff check.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 02:53:50 -07:00
CatoandClaude Opus 5 c934ea5b95 fix(projects): a phone can now see what the list is sorted by (#831)
#830 made /projects order by recency and put that promise in the subtitle:
"flagged first, then most recently active". The row keeps health, "active …
ago" and the open-feedback count in a right-hand column marked `sm:flex` — so
on a phone none of them render. The page asked you to trust a sequence whose
evidence it had hidden on the viewport where it matters most.

Adds a stacked `sm:hidden` meta line rather than reusing the desktop column: at
390px a right rail steals the width the project name needs, and the name is
what you came to read. The health score is spelled out (`health 7/10`) because
a bare "7/10" sitting next to a date is exactly the magic number that module
exists to stop it being.

ALSO: `Needs path` was `hidden sm:inline-flex`. It means Loki cannot dispatch
an agent for that project AT ALL — the most actionable badge on the row — and
it was hidden on the narrowest viewport. Now always shown.

The desktop column is untouched; this complements it rather than replacing it,
and the test pins that too so a later "simplification" cannot quietly collapse
the two into one cramped layout.

Guarded by scripts/test/mobile-shows-what-the-list-sorts-by.ts. It reads the
source, so it proves the classes are right, not the pixels — real rendering at
320/390/768/1440 is `audit:responsive`, which needs a running server and cannot
live in the env-independent unit suite. The gate earns its place because the
regression is a ONE-WORD edit (`sm:hidden` → `hidden`) that no type or lint
error would ever surface. Mutation-tested both ways: restoring the badge's
`hidden` fails 1 check, removing the mobile line fails 4.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 02:17:59 -07:00
CatoandClaude Opus 5 440b016c6a fix(projects): the list now orders by the number it prints (#830)
Every row renders "active 23d ago" and the list ignored it. After the flagged
and freshly-created tiers, the real tiebreaker was `name.localeCompare` — and
with 22 of 36 projects holding a next step, the ALPHABET decided most of the
page.

Measured on production before this change:

  - 9 inversions across 21 adjacent pairs
  - loki, active seven minutes earlier, sat ELEVENTH, below BiasLens and
    HamsterCheek, both untouched for a month
  - the three projects whose runs had failed at 06:00 that morning
    (surf-your-life, printcraft, sbb-lost-found) sat at positions 15, 18 and 20
  - the page rendered as two alphabetical blocks, a–v then A–c

Recency now decides, read from the SAME map the row labels itself from, so the
order and the label cannot disagree.

TWO TIERS REMOVED, both undocumented in the original:

  - has-a-next-step-first. Backwards on its face — a project that knows its
    next step is the one that needs you least — and it was the tier drawing
    that line through the middle of the list.
  - own-before-team. A team project touched yesterday outranks a personal one
    untouched for a month; recency says that better.

Kept: flagged-first, and the freshly-created tier, which carries a dated
comment explaining why it exists (2026-09-11, a new project lost in an
alphabetical fold of 25).

THE SUBTITLE WAS ALSO UNTRUE. "Decide what needs your attention now" promised
triage this page never did. It now says what the order IS — "Every project you
run — flagged first, then most recently active" — because the order is this
page's only real product: everything about ONE project is better on that
project's page, and ranking across projects is the thing only a list can do. A
page that names its sort can be trusted or argued with; one that hides it just
feels arbitrary.

Guarded by scripts/test/projects-list-is-ordered-by-recency.ts (9 checks),
which pins the two kept tiers as well as the new ordering, so a future change
cannot quietly restore either removed tier. Mutation-tested: disabling the
recency comparison fails 6 of the 9.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 01:30:15 -07:00
CatoandClaude Opus 5 689358197a feat(projects): fields the operator adds now reach the agent (#826)
AddAttrInline has always let anyone type any key/value onto a project, and
humanizeAttrKey renders it back under "Additional context" — inside an editor
headed **Agent context**. It reached no agent. renderProjectDossierForAgent
built its profile from hardcoded property reads, so a key nobody had
anticipated was stored, shown back to the human, and dropped silently on the
way to the model.

That is the worst shape of defect: the feature looks like it works. Someone
fills in "Suppliers" or "SWOT", sees it on the page, and reasonably concludes
their agents know about it.

Only UNREGISTERED keys qualify. A registered field already declares whether it
reaches agents, and two of those answers are deliberately "no" — the market
lens is for the human operator (it costs tokens on every dispatch), and
UI-owned attrs like `business_plan` have their own surface. Consulting the
registry is what stops this path from quietly undoing those decisions; the
tests exist mostly to keep it that way.

DEVIATION, stated plainly: the plan said custom fields would default to
human-only with a per-field "send to agents" toggle. They default to ON here,
with no toggle. A toggle needs new per-field storage and a migration, and adds
a step to reach a result the user already asked for by typing into a box
labelled Agent context. The boundary that actually carries risk — publishing —
is untouched and remains an explicit four-key allowlist. If the default turns
out wrong it is one predicate to change.

Capped at 12 fields per project so one profile cannot crowd out goals, runtime
and the last handoff. Values are never clipped: anything past the cap is
listed BY NAME, which is honest about what was withheld and lets the agent ask
for it.

Lives in lib/project-custom-context.ts rather than beside the dossier
renderer, which opens a database connection at import time — that is what had
put the text of every dispatch beyond the env-independent unit suite.

Mutation-tested: dropping the registry check trips three gates, including the
one that would have sent a 5,000-character business plan into every prompt.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 00:17:21 -07:00
CatoandClaude Opus 5 7d892ec91f refactor(projects): one registry describes a project field, not five lists (#825)
Five separate lists decided what a project field is and does: the context
editor's groups, the agent dossier's Profile block, the fallback
DRIVING_FIELDS, the AI profile-apply keys, and the public allowlist. Adding
one field meant editing five places, and nothing checked they agreed — so
they had already drifted:

  - the dossier carried `status`; DRIVING_FIELDS did not
  - the dossier said "Next owner step"; DRIVING_FIELDS said
    "Next step (owner's highest-priority action right now)"
  - the editor said "People served"; both agent paths said "Customers"

PROJECT_FIELDS in config/project-attrs.ts now describes each field once, and
the lists derive from it. The divergences above are carried as explicit
`inAgentDossier` / `inDrivingFields` flags rather than quietly reconciled:
changing what agents read is a product decision, not a refactor.

renderProjectDossierForAgent built its profile from hardcoded property reads
(`attrs.mission`, …), which is why a field added through the UI — AddAttrInline
has always allowed any key — reached no agent at all. It now iterates the
registry. Only the two rows the registry does not own stay bespoke: Health is
computed, and Operator notes live on user_projects.

One deliberate behaviour change: "Next step" moves later in the FALLBACK
dispatch prompt, because one registry cannot hold two orders and the dossier —
the path nearly every dispatch takes — is the one preserved exactly. The two
paths agreeing is the point of the change.

DRIVING_FIELDS moves to config and is re-exported under its old name: it is
pure config, and living in a queries module put it behind a database
connection, so the text every fallback prompt carries had no test.

The public allowlist stays an explicit four rather than becoming a per-field
boolean. Publishing is a security boundary, and four lines a reviewer can read
beat a flag scattered across 33 entries.

scripts/test/one-registry-describes-a-field.ts pins every derived value,
because they are prompt text — and fails if a PROJECT_ATTR key is added
without being registered.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 23:21:32 -07:00
CatoandClaude Opus 5 6c999cb13e fix(ui): the primary button's label was grey on orange — 1.38:1 (#824)
Found by measuring which page most needed work. /system carries 128 numbers
and, before this, not one you could click; the biggest thing on it is a queue
of pending proposals whose primary action is "Accept → goal".

In light mode that button rendered muted grey on the orange accent:

  colour  lab(67.52)  rgb(164,165,165)   = --text-muted
  field   rgb(245,85,0)                  = --accent-warm
  ratio   1.38 : 1                        against a 4.5 floor

Twenty-four of them on one screen. The primary action of the only surface
that asks the operator to DECIDE something was effectively invisible.

CAUSE — a size modifier repainting a variant:

  .ui-btn-primary   line 3548   bg-accent-warm + text-on-accent
  .ui-btn-xs        line 3607   text-text-muted

Same specificity, both in @layer components, so CSS source order decides and
the size class wins. Writing `ui-btn-primary ui-btn-xs` in the other order at
the call site does nothing — which is what makes this a class of bug rather
than one mistake: it is invisible at the place a person would look for it, and
six files compose these two.

Two classes beat one, so one composed rule restores the variant's own label
colour everywhere. Verified on the live page: 1.38 → 5.51, passes AA. The 19
standalone `ui-btn-xs` uses are untouched.

WHAT THE RATCHET DOES NOT BAN, and why. `ui-btn-xs` is also composed with
ghost (14 files) and secondary (3). Neither paints a base background, so their
labels sit on the ordinary page surface — the ground `text-text-muted` is
designed for. Losing tertiary to muted there is a shade preference, not a
readability failure. The rule is therefore "a variant that paints its own
FIELD must keep the label it chose for that field", which is the line between
a bug and a taste call — and if ghost ever gains a background it moves into
the rule automatically.

The test also asserts its own premise: it fails if `ui-btn-xs` stops being the
later rule, or stops setting a colour, because either would make the composed
rules dead weight and every other check pass vacuously.

Mutation: removing the composed rule fails it, naming all six files.

verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings),
check:design (11), check:desktop, test:home. test:unit 232/234 —
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>
2026-09-21 15:50:45 -07:00
CatoandClaude Opus 5 8b04216b8d fix(control): a CTA that skipped the filter, and a card that said it twice (#823)
Two from reading the rail.

"REVIEW FAILURES" DID NOT REVIEW THE FAILURES

  The hero counts them — "the latest run on 4 projects failed" — and the
  button under it went to /activity?window=week: a full week of every
  dispatch, success and failure alike, leaving the operator to find the four
  the sentence had just counted.

  It was the one activity link in the app written by hand instead of through
  `activityHref`, which is why it was also the one carrying no filter. It now
  passes `filter: "attention"` — precisely error, timeout, hang, partial and
  unconfirmed — so the button lands on what it names.

THE CARD SAID THE SAME THING TWICE

  Status badge: "Tab open". Subtitle directly beneath: "Workspace tab open".

  The subtitle exists to name what was OBSERVED — "Live agent process
  detected", "Agent signaled ready on connected computer", "Last run
  completed". For this state it restated the badge in different words, on
  every card in that state.

  A guard for exactly this already existed:

    {evidenceLabel && (evidenceLabel !== stateLabel || …) && …}

  Exact equality catches only the one phrasing nobody was going to write
  twice. `restatesLabel` compares the WORDS — case, order and punctuation
  ignored — so "Workspace tab open" no longer slips past "Tab open", while
  "Last run completed" is untouched. The tab-open branch now adds nothing when
  it has nothing to add, and keeps the dispatch suffix when it does.

A NOTE ON THE TEST: its last case originally asserted that no two states share
a label, and reported `ready` / `orchestration_ready` — both "Ready for next
step" — as a defect. They share it on purpose; the distinction is internal and
the operator's next move is identical. The check now pins that known pair and
fails only on a NEW clash. A test does not get to overrule a decision.

Mutation: reverting the guard to exact equality fails 2 of the 6 cases.

verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings),
check:design (11), check:desktop, test:home 130/130. test:unit 228/230 —
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>
2026-09-21 15:21:40 -07:00
CatoandClaude Opus 5 e6b499468e fix(control): the sort called "Priority" ranked nothing at all (#822)
George, looking at the rail: "priority ordering has no logic and idk why it is
like that."

There was none. The comparator for that mode, in full:

  return sourceSnapshots.indexOf(a) - sourceSnapshots.indexOf(b);

— the order the API happened to return. It is the DEFAULT sort, it is labelled
Priority, and it sorted by nothing. That is why the rail opened with idle
projects while the three holding an open workspace tab sat two thirds of the
way down, and why the order looked arbitrary: it was.

A control labelled Priority that applies none is worse than an unsorted list.
An unsorted list makes no claim; this one tells the operator that the top of
the list means something.

Nothing new is invented in the fix. control-states.ts is already the SSOT for
what each state MEANS — `problem` is non-null exactly when "this needs your
attention", `counterCategory` is the bucket the summary chips count — so the
rail now reads the same two fields the chips read, and the row order can no
longer tell a different story from "0 working · 0 awaiting input · 23 idle"
printed directly above it.

The order is Control's one question answered top to bottom:

  0  something is wrong and it is yours to fix   (any state with a `problem`)
  1  awaiting input — your move is to type       (waiting)
  2  working — running, watchable                (working)
  3  offline — we cannot see it                  (offline)
  4  idle                                        (idle)

then most-recent-activity first inside each bucket, so two idle projects still
land newest-first rather than in API order.

The test pins the ordering against the SSOT rather than against a list of
state names, so a new state inherits the rule instead of quietly landing at
the bottom. Its last case is the one that matters: if every state got a
DISTINCT rank the ranking would be list order again, so it fails when the
ranks stop bucketing.

Mutation: flattening every rank to 0 fails 2 of the 5 cases.

verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings),
check:design (11), check:desktop, test:home. test:unit 228/230 —
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>
2026-09-21 04:09:15 -07:00
CatoandClaude Opus 5 c32ceb1342 fix(public): the pages still sold the product Loki stopped being (#821)
Four things the public surface said that the codebase no longer does.

THE IDENTITY, RETIRED YESTERDAY AND STILL ON SALE

  /philosophy: "Loki is infrastructure for builders running many agents at
  once across multiple projects — not a friendly chat assistant."

  That is the framing #801 removed on 2026-09-20. Its own gate records why:
  the narrow label "named Loki's deepest capability and not the product —
  Today, People, Crew, Money, Goals and Habits ship here too", and under it
  those surfaces read as scope creep, twice prompting "move the life-ops half
  to the Cat". There is nowhere to move it to.

  That rename pinned "the three places it actually lives" — the fleet map, the
  agent's role sentence, the two assistant prompts. All three are things a
  MACHINE reads. The page a stranger reads was not among them, and the public
  copy mentions Crew, Money, Habits and commitments exactly zero times. The
  correction reached the agents and not the humans, which is the wrong way
  round. execution-plane.ts now covers the public copy too.

A CAPABILITY THAT DOES NOT EXIST

  /philosophy: "Open and local models compete equally for your attention and
  your work." The chat chain is freeChain("LOKI") — Groq, OpenRouter, Gemini,
  all hosted — and every agent adapter is a hosted-model CLI. There is no
  Ollama, llama.cpp or LM Studio path anywhere in src. The open-WEIGHT half is
  real (llama, qwen and gpt-oss drive the loop today), so the claim keeps the
  half it earns and states the other as the direction it is.

A WHITEPAPER THAT DISAGREED WITH plans.ts

  v0.3, published 2026-08-12, never recomputed:

    "Pro — for power builders running 10+ active projects"
       PLAN_LIMITS.projects.pro is Infinity; /pricing says "Unlimited".
    "Team — for small groups (up to 10 people)"
       no seat limit exists anywhere in the codebase.

  A reader comparing the two pages got different answers about the same tier,
  and an unenforced limit is a promise to somebody. It also said Loki "is
  offered" as four subscription levels while three of them have no price and
  cannot be bought — it now says which one is purchasable today.

  whitepaper-matches-plans.ts pins the checkable half against PLAN_LIMITS: a
  finite ceiling must be quoted exactly, an unlimited tier must not quote a
  number at all, and no tier may claim a seat limit. Prose about who a tier is
  FOR stays prose.

A LINK THAT ASKED FOR THE WRONG THING

  The footer's "Support Loki", under a heading already reading SUPPORT, asks a
  reader to fund the project. It opens the help desk, whose own H1 is "Get
  help" — so it misled in both directions. It is "Get help" now.

CHECKED AND LEFT ALONE: the ecosystem references. Loki's public copy names
Solon once ("Solon — Governance") and OrangeCat as "Economy"; both match the
PILLARS roles, both sites answer 200, and their own titles are "Solon —
Bitcoin-Native Governance" and "OrangeCat — Your AI economic agent". Nothing
overclaims Solon's maturity.

Mutation: restoring the retired framing fails execution-plane.ts; restoring
either the "10+" ceiling or the seat limit fails whitepaper-matches-plans.ts.
Both ratchets strip comments first, or the note recording what was retired
would fail on itself.

verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings),
check:design (11), check:desktop, test:home 130/130. test:unit 228/230 —
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>
2026-09-21 04:06:18 -07:00
CatoandClaude Opus 5 d71ddd446e fix(runs): the fleet stopped executing and nothing said so (#820)
`closeRunUndelivered` stamped `error`, emitted a run event and called
`notifyRunClosed` — but never `advanceEscalation`. It was the ONLY
failing-close path feeding the ladder nothing: the funnel
(updateOrchestrationRun) advances, the reaper advances, this did not. A
dispatch that died before an agent ever saw it therefore could not build
a streak no matter how often it repeated, so the `human` rung — the one
that raises the alert — was unreachable from this path.

Notification did not cover the gap and could not: formatRunCloseMessage
self-gates on payload.notifyOnClose, which only human-initiated
dispatches carry ("autopilot churn stays quiet"). For an autopilot or
cron dispatch the notify call returns null, so the close said nothing to
anyone at all.

Measured on prod today: six dispatches failed across FOUR projects
(loki, kivvi, solon, reparaturbonus-zh) within twelve hours on an
exhausted Claude quota — every one through this path — while the newest
row in `alerts` was six days old.

Derived, not assumed, via the same ladderEffectForClose predicate the
other two call sites use, so there is one rule for what a close does to a
ladder. The ladder's own `lastOutcome` keeps it honest downstream: it
already distinguishes a streak built from undelivered dispatches from one
built from an agent's failing work.

Attaches the missing signal only — it does not change the outcome, the
notification policy, or what a streak means.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 04:02:57 -07:00
CatoandClaude Opus 5 5386267149 fix(public): "46 agents running" was two agents and forty-four stale flags (#819)
/investors and the homepage hero read a raw boolean that nothing expires.
Measured against prod on 2026-09-20:

  rows flagged agent_running = true ....... 46
  updated in the last 30 minutes .......... 2
  oldest flagged row last touched ......... 2026-08-13 — 910 hours earlier

So the page showed "46 agents running" while Control, on the same database,
showed "0 working". Both numbers came from the same fleet; only one of them
was bounded.

It sits directly under this sentence, which is why it matters more than an
off-by-something: "the homepage hero and this page render the same live
snapshot of that fleet — real data, never fabricated numbers." The numbers
were not fabricated. They were stale, offered to an investor as proof of
activity. And this file's own header promises "honest by construction —
isLive is true only when an agent is really running, so the hero never claims
LIVE falsely". isLive is `totals.running > 0`, so it had been true for weeks
on the strength of flags nobody cleared.

The app already had the answer. Control bounds the same question by
OPEN_TURN_TTL_MS — thirty minutes, a constant whose comment records that
without it "a dead Codex tab showed working 61h", and which is deliberately
matched to STALE_PROMPT_S so two definitions cannot disagree on screen. The
public query simply never applied it. It does now, through one predicate used
by BOTH the headline count and the per-project dots: bounding only the count
would have left a project's dot lit for an agent that died in August.

Reused rather than re-picked on purpose. A second freshness number would
eventually disagree with Control's, and then a reader is right to trust
neither.

The other two figures were already honest and are untouched: "projects" counts
active rows, and "runs this week" was time-bounded from the start.

Proved by mutation: restoring the unbounded check fails 2 of the 6 cases.

verify: format:check, tsc, lint (0 errors, 2 pre-existing warnings),
check:design (11), check:desktop, test:home 130/130. test:unit 227/229 —
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>
2026-09-20 15:08:45 -07:00
CatoandClaude Opus 5 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>
2026-09-20 14:09:32 -07:00
CatoandClaude Opus 5 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>
2026-09-20 13:13:57 -07:00
CatoandClaude Opus 5 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>
2026-09-20 12:06:05 -07:00