Commit Graph
49 Commits
Author SHA1 Message Date
Catoandcatomean 830fdf2d5a docs: site audit matrix + 2026-11-04 handoff (#1550)
* docs: living site audit (works/broken matrix)

* docs: handoff for 2026-11-04 site-fix sweep

* docs: handoff status after #1544/#1545/#1547 verified live

---------

Co-authored-by: catomean <catomean@users.noreply.github.com>
2026-11-04 13:16:17 +01:00
CatoandClaude fa09bc6a4f docs(agents): fold CLAUDE.md and .claude/CLAUDE.md into AGENTS.md (#1472)
Both CLAUDE.md files now only point at AGENTS.md, the fleet's one
agent-file shape (bitbaum/fleet scripts/ci/agent-rules.mjs). What was
still true moves into AGENTS.md: the principles and the entity test, the
shipping hand-offs (re-arm, post-main), the self-hosted Supabase read and
migration path, the design tiers and the one-orange rule, and the money
surface as the reference for one shape per kind. Every named path,
script, workflow key and component was checked against the tree.

Dropped as stale or copied:
- `.claude/CLAUDE.md` still listed the warm accent as `#ff5c00`; the root
  file and globals.css say it is gone (accent = Bitcoin orange).
- a machine-specific project path, the duplicated stack table and the
  `.claude/rules` restatements (those files remain).

Docs and comments that sent readers to CLAUDE.md for "Shipping" or the
principles now point at the AGENTS.md sections.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-29 10:57:51 +01:00
CatoandClaude Opus 5.5 24c3d140ae docs: archive point-in-time records, fix live docs against the tree (#1349)
* docs: archive point-in-time records, drop broken guide symlinks

Status reports, progress trackers, audits, session summaries, completed
migration plans and the 2025 roadmap move to docs/archive/ (same relative
path), with a README saying they describe the day they were written.
.ai-guides/ held only symlinks into a docs/guides/ai/ that no longer
exists, tests/unit/docs/ held a stray copy of an old getting-started page,
and docs/operations/PORT_MANAGEMENT_README.md duplicated port-management.md;
all three are deleted.

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

* docs: correct drifted paths, links and versions in current docs

Fix in place the reference docs agents use: point paths at where the code
lives now (src/stores/auth.ts, src/lib/supabase/*, scripts/dev/*,
docs/reference/api/CONVENTIONS.md, the squashed baseline migration),
rewrite the development, features, operations and API index pages to list
documents that exist, say plainly where something is gone (/api/metrics,
the CSP report route, .envrc in the repo, Loki's `migrate` script), and
correct the Next.js major. docs-truth findings: 468 -> 2 (both "Next 30/90
Days" headings in the legal overview, a checker false positive).

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-19 14:09:06 +02:00
CatoandClaude Opus 5.5 b774f06de7 docs: correct drift in agent instructions, README and ops docs (#1348)
* docs: correct drift in agent instructions, README and ops docs

- Auto-merge sweep lives in bitbaum/fleet, not bitbaum/dotfiles; cd.yml is
  dispatch-only (handed off by ci.yml post-main), not a workflow_run listener
- Design-system docs match globals.css / tailwind.config.ts: warm accent
  #ff5c00, bg-bitcoinOrange (no bitcoin-orange utility), tiffany/orange are
  legacy; display typography is shipped
- .claude rules: real paths (src/lib/validation/, entityCrudHandler.ts,
  standardResponse.ts, withZod/withRateLimit/withRequestId, services/actors),
  real Button/Alert APIs, real rate limits, search via @bitbaum/searchkit,
  real payment modules, PostgREST instead of the POSTGRES_URL tunnel,
  lint-staged pre-commit, eslint.config.mjs
- README/AGENTS/REVIEW: Next 16 / TS 6 / Tailwind 4, pnpm, messaging is not
  E2E-encrypted yet, beta not Live, CD deploys, migrations apply on deploy
- docs/: deploy process, CI/CD, migrations guide, moved docs/ paths, stale
  CLI-entity and edge-function docs flagged

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

* style(docs): prettier on the docs touched by the drift fix

lint-staged would have run this; the commit was made without hooks.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-19 12:07:09 +02:00
CatoandClaude f3d5d751b1 feat(auth): a second way back in — linked providers, a last-method guard, and "Can't get to your email?" (#1186)
Step D6 of ADR-0009. Every recovery path ran through the inbox: lose it and
the account was gone. Now:

- Settings → Security → "Ways to sign in": every identity at the auth
  server (email, and each linked provider) with when it was last used, a
  "Link Google / GitHub / …" button for each working provider not yet
  linked, and remove — refused BEFORE the click, with the reason, while it
  would leave no way in (email is kept while a passkey is the only other
  way, since a passkey cannot recover a lost device). One way in shows a
  warning that says what to do about it.
- /auth/cant-get-email, linked from "Forgot password?" and from the reset
  form: a linked provider, a passkey (when switched on), the inbox's own
  recovery, and support with what to say. Each is a real way in that exists
  today; the last one is a person.
- lib/auth/sign-in-methods.ts holds the rules, pure and tested; the
  identities service wraps getUserIdentities / linkIdentity /
  unlinkIdentity and returns to Settings through the same callback the
  sign-in flow uses.
- docs/operations/account-recovery.md: the one switch this needs on the box
  (GOTRUE_SECURITY_MANUAL_LINKING_ENABLED — until it is set, "Link" reports
  that it is not switched on yet), and why first-factor backup codes are
  deliberately not built.

Verified: verify green (4027 tests); the card rendered against a real
account at 1280 and 390 with no overflow; /auth/cant-get-email and the
forgot form at both widths.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-29 03:09:29 -07:00
CatoandClaude Fable 5.1 2077bfc207 feat(auth,docs): developer page for "Sign in with OrangeCat"; passkeys (#1185)
* feat(docs): developer page for "Sign in with OrangeCat" + round-trip script

Step D9 of ADR-0009. OrangeCat has been a real OpenID Connect provider
since June and five relying parties sign people in through it, but a site
that wanted the button had the standard and nothing else.

/docs/sign-in-with-orangecat: what you get (one identity keyed by sub,
passwords optional, people can disconnect you), self-service registration
with its rules, the Auth.js config Solon/Heidi/Loki run and the by-hand
authorize/token/userinfo/refresh calls, button wording (prompt=create,
login_hint), sessions and what invalid_grant means, and every scope with
its consent-screen wording. Every URL, scope and lifetime is derived from
the provider's own config (snippets.ts), and a unit test pins the snippets
to the discovery document, so the page cannot quote an endpoint the server
does not serve.

scripts/oauth/sign-in-roundtrip.mjs registers a client, opens the sign-in,
catches the code on loopback, exchanges it with PKCE, checks iss/aud/nonce,
reads userinfo, refreshes, and proves the spent token is refused — the
same steps any relying party takes, runnable before writing a line.

Linked from /docs. ADR-0009 status updated: D1–D4 shipped, relying parties
now honour revocation (solon#203, heidi#145).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* fix(docs): userinfo snippet uses a shell variable for the token

gitleaks (curl-auth-header) reads 'Bearer THE_ACCESS_TOKEN' as a leaked
token; $ACCESS_TOKEN is what a person would paste anyway.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* chore(security): allowlist the docs bearer-token placeholder for gitleaks

The developer page's userinfo example used 'Bearer THE_ACCESS_TOKEN', which
gitleaks' curl-auth-header rule reads as a leak. The tree now uses a shell
variable; the placeholder in history is allowlisted instead of rewriting it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* feat(auth): passkeys — add/list/remove in settings, sign in with a passkey

Step D5 of ADR-0009. The self-hosted auth server (GoTrue) supports WebAuthn
passkeys and the browser client already carries the ceremony; what was
missing was the UI, the wrapper, and the switch.

- Settings → Security → Passkeys: the person's passkeys with name, date and
  last use; "Add a passkey" (browser prompt, then named); remove.
- /auth: "Sign in with a passkey" beside the emailed code — nothing typed.
- Both are hidden until the auth server reports passkeys_enabled: true
  (lib/auth/passkeys-availability reads GoTrue's public settings, cached
  five minutes, fails closed). A button that cannot work is a dead end.
- docs/operations/passkeys.md is the switch: GOTRUE_PASSKEY_ENABLED and the
  relying-party id/origins, with why the id is orangecat.ch and not the
  API host. scripts/auth/passkeys-e2e.mjs drives add → sign in → remove
  with Chromium's virtual authenticator and exits 2 while the switch is off.

services/supabase/auth/passkeys.ts wraps registerPasskey / passkey.list /
update / delete / signInWithPasskey in the auth service's shape; a passkey
is named in a second call and a failed rename still returns a working key.
Unit tests cover the availability parser and the wrappers.

Also: the two CLI scripts under scripts/ carry the no-console pragma their
siblings use.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* fix(scripts): throwaway inbox password from crypto.randomBytes

CodeQL (js/insecure-randomness) flags Math.random() for a password, even
a disposable one; the real generator costs nothing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-29 02:45:52 -07:00
CatoandClaude 04a8b7ea1c feat(auth): connected apps page; sign out everywhere reaches every product (#1182)
One account for every door, steps D3 and D4 of ADR-0009.

D3 — Connected apps (Settings → Integrations): every app that signed in
with the person's OrangeCat account (Solon, Loki, Heidi, any self-registered
AI app), with what it may do, when it connected, when it was last used and
how many live sessions it holds — and a Disconnect button that forgets the
consent and revokes the app's refresh tokens. Until now a self-registered
app could keep a thirty-day session the person had no screen to find.

- src/services/auth/connectedApps.ts: list / revoke / revoke-all. Every
  query on the service-role-only oauth_* tables names the user; the unit
  tests pin that.
- GET /api/connected-apps, DELETE /api/connected-apps/[clientId]: session
  auth only, so an app can never enumerate or revoke the others.

D4 — Sign out everywhere now revokes the OAuth refresh tokens connected apps
hold before it revokes OrangeCat's own sessions; before, it signed the
person out of OrangeCat and left them signed in to everything that signs in
through it. Account deletion revokes and forgets them too (the oauth_* rows
do not cascade from auth.users). The OIDC key-rotation runbook writes down
the order of operations that keeps the JWKS overlap so a rotation signs
nobody out.

Docs: ADR-0009 (the identity design of record: one account held by
OrangeCat, every product and outside site a client of it, passwords
optional, recovery with more than one path, what a person allowed they can
see and take back — with the build order D1–D9 and every edge case's
landing place).

Verified: pnpm run verify green (3970 tests). Production E2E: emailed-code
sign-in on orangecat.ch from Solon's sign-in page completes the round trip
in five seconds with no consent screen for the trusted client; the
Connected apps list itself needs the service-role key, so it is checked on
production after deploy.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-29 01:20:31 -07:00
Cato 9d63579b78 fix(cat): preserve tool progress and recover before execution (#1113)
* fix(cat): preserve tool progress and recover before execution

* refactor(cat): keep tool turn reporting in its state
2026-09-23 02:22:43 -07:00
CatoandClaude Fable 5.1 9a352d3646 refactor: rename FleetCrown to Loki across the integration (#1016)
The sibling product was renamed on 2026-09-14. Every reference follows:
service and route paths (src/services/loki, /api/integrations/loki),
env keys (LOKI_*), the build-intent audience and timeline source ('loki'),
ecosystem config, docs, tests, and 13 file names.

Tool labels keep "Loki" capitalised: the old name had an internal capital
and passed the "looks like a name" shape test for free; a one-word name
needs listing, so softLower now carries a small PROPER_NOUNS set.

Box and data were moved ahead of this: LOKI_* keys sit beside the old ones
in the app env, the OAuth client is `loki` with the new callback host, and
timeline/metadata rows carrying the old name were rewritten.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 16:40:27 -07:00
CatoandClaude Fable 5 1ee64e9377 refactor(rate-limit): move the algorithm to limitkit; limits stay app semantics (#897)
Adopt limitkit@0.2.0 (fleet package) as the rate-limit engine, completing
ADR-0002's remaining work:

- src/lib/rate-limit.ts keeps its full export surface (138 importers
  untouched) but now only declares the LIMITS — every value preserved
  exactly — while limitkit supplies the sliding-window arithmetic, the
  bounded MemoryStore, and the standard headers. The five-fold
  upstash-limiter + fallback-limiter + function triple is gone.
- Delete the never-configured Upstash path and the @upstash/ratelimit +
  @upstash/redis dependencies; the live path was always the in-memory
  fallback on the single self-hosted instance, so runtime behaviour is
  unchanged. A second instance now means implementing limitkit's
  two-method Store over shared infrastructure, not a parallel code path.
- src/lib/client-ip.ts delegates X-Forwarded-For parsing to limitkit's
  clientIp() (same last-hop correction, trustedProxies: 1 for the one
  Caddy hop); the app keeps its 'anonymous' bucket naming and the
  clientIpOrUndefined address variant. check:client-ip gate unchanged.
- Headers now follow ADR-0002's spec exactly via limitkit toHeaders:
  X-RateLimit-Reset in epoch seconds (was ms), Retry-After on refusals
  only (was also emitted on success responses).
- health.ts drops the Upstash cache probe and its "Cache" service row —
  there is no cache dependency left to probe, and a hard-coded
  "operational" row would be a fake metric. uptime.yml only reads
  services.authentication, which is untouched.
- Drop _resetActionRateLimits (referenced by nothing).
- New __tests__/unit/rate-limit.test.ts pins every limit value — limits
  are app semantics, asserted locally, per limitkit's own contract.
- ADR-0002 gains a dated addendum; ops docs stop instructing operators
  to set UPSTASH_* env vars.


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

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-05 16:35:04 +00:00
c022bfdf46 docs: sync docs with actual stack (#890)
Truth-sweep of the living docs against repo ground truth (pnpm 11.25.0,
Node 24, Vitest, zod 4, TS 6, Next 16/React 19, self-hosted Supabase with
file-based migrations applied on deploy):

- npm/npx commands -> pnpm / pnpm exec / pnpm dlx; `run X -- --flag`
  loses the `--`; package-lock.json -> pnpm-lock.yaml
- jest -> Vitest (config names, vi.fn/vi.spyOn, reporter examples,
  debug commands, framework mentions)
- retired mcp_supabase_* examples -> current mechanisms: PostgREST
  reads, migrations as supabase/migrations/*.sql applied on deploy,
  box psql for DDL
- version claims: TypeScript 5.x -> 6.x, Node 20 -> 24, Next.js 15 ->
  16, React 18 -> 19; CI described as Node 24 + pnpm
- nonexistent scripts replaced with real ones (test:comprehensive:* ->
  test:*, diag:supabase -> scripts/diagnostics/*, db:migrate/test:
  migration -> deploy-applied migrations / migration-replay.yml)
- infrastructure.md deploy claim fixed: cd.yml deploys main after green
  CI (doc said pushes to main do NOT deploy)
- zod 4 API: z.record now takes key+value schemas


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

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-04 17:02:55 +00:00
30abac251b fix(cat): @cat has resolved to nobody for two days (#802)
* fix(cat): @cat has resolved to nobody for two days

The email-derived-handle retirement renamed the Cat. Its predicate —
`username = split_part(email, '@', 1)` — is exactly right for a person,
whose public crawlable handle then republishes their email local part.
It is exactly wrong for the Cat, because deriving the handle from the
address is HOW the Cat is created: cat-account.ts registers
`cat@orangecat.invalid` precisely so handle_new_user mints `cat`. So the
script matched, and at 2026-08-26 21:58:59Z the handle became
`user_0234d5e38e66`.

`@cat` is the platform's advertised interface and it resolves by
username, so every `@cat` in a message or under a post has since
resolved to nobody. No reply anywhere. Found by typing `@` in the
composer in production and seeing no Cat in the menu.

Nothing went red. The account still existed, /profiles/cat still 301'd
through profile_username_history, CI was green, health was 200. The only
symptom was silence from the feature whose job is to answer.

Three defects, three fixes:

POLICY — the retirement could not tell a leaked address from a system
identity. Now excluded by property, not by name: RFC 2606 reserves
`.invalid` for undeliverable addresses, so there is no mailbox, no
owner, and nothing personal in the local part. Hardcoding 'cat' in SQL
would have put a second definition of the handle where it could drift
from config/cat-identity.ts. Applied to the rename script and to
count_email_derived_usernames(), which would otherwise have gone from 0
to 1 and turned the nightly gate red for a profile that is fine.

CODE — ensureCatAccount looked the Cat up BY USERNAME, so its
self-healing walked straight past a rename: lookup missed, createUser
said "already registered", second lookup missed, returned null on every
tick. It now keys on the login address, which no policy has reason to
rewrite, and treats the handle as a field to assert rather than a key to
search by. A rename now repairs itself on the next tick.

GATE — nothing checked the product's own claim. checkCatHandle asserts
that the name we tell people to type reaches the Cat; a lookup by id
would have stayed green throughout. The literal it carries is pinned to
CAT_USERNAME by a test, so the duplicate cannot drift.

Proven by mutation: restoring the username lookup, removing the
re-assert, and drifting the gate's literal each turn the suite red.
The migration was rehearsed against production inside a transaction and
rolled back — UPDATE 1, DELETE 1, 28 real retired handles untouched,
gate still reads 0.

Also restores the github.com/catomean links lost when this worktree was
reset; the owner rename left them pointing at a redirect.

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

* fix(docs): point at bitbaum, the canonical owner

catomean is itself a redirect now — the repos live in the bitbaum org.

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

* fix(mentions): the @ menu was offering rows nobody can read

Production has 84 profiles and 74 of them have no display name — the
correct consequence of no longer minting names out of email local parts,
where NULL is honest. The menu did not account for that, so what it
actually showed on a bare `@` was two rows of `user_d58c7dccec41`,
printed twice each: once as the name, because the name falls back to the
handle, and once as the subtitle.

Three changes, all following from the data rather than from taste.

A nameless row now shows its handle ONCE, in the position the eye reads
first, instead of the same hex string on two lines.

A nameless profile is not offered at all on a bare `@`. You cannot be
searching for a name that does not exist, so those rows were pure noise
in the one position that matters most — the first thing anyone sees when
they discover the feature. Type any part of the handle and they come
straight back through the existing prefix rules.

At equal match quality, a named profile outranks a nameless one. `@u`
matches `ursula` and `user_d58c7dccec41` equally well by anything the
score can see, and only one of them is a row a human can act on. The
tiebreak sits after match quality, never before it, so an exact handle
match still wins — a demotion that overrode "this is plainly the row
being asked for" would be a worse bug than the one it fixed.

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

* chore: leave the CLAUDE.md owner line to #803

Both branches edit the same line; one owner avoids a conflict that would
stop CI running on whichever loses.

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

---------

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 07:03:52 +00:00
b9fb22114a chore(sites): remove hosted sites — OrangeCat is not the host (#785)
I built this on a wrong premise: that <name>.orangecat.ch means membership in
OrangeCat. It does not. It is an address on a domain George happens to own,
which is why petvity has a site and no profile, and why sinktattoo moved to its
own domain without moving a line of code.

Every site in this studio is its own repository from birth — aslan-tattoo,
kivvi, vitareba, petvity, botsmann, all of them. That is not an accident of
history, it is the property that makes a site handover-able, and a site that
lives inside this codebase can never be handed to anyone. Substrata was the only
violation, and it was mine.

Removed: the group_features 'site' feature, the profile-site renderer, the
positional host resolution and its reserved-subdomain list, the publish API, the
tls-check endpoint, the catch-all Caddy block, and Substrata's configs. Substrata
moves to its own repository, with its own design system — it currently renders in
OrangeCat's tokens and OrangeCat's orange, which is the visible form of the same
mistake.

The RLS policy needs its own DROP: deleting a migration file does not undo a
policy that already ran on production, and an anonymous SELECT grant is not
something to leave behind because nothing writes that row any more.

Kept, because they were never about hosted sites:
  - rateLimitDomainSearch — /api/v1/domains still fans one request out to 24
    registry lookups for an anonymous caller
  - the bounded RDAP result cache, keyed by caller input in a process that runs
    for weeks
  - clientIp(), collapsing the third copy of the x-forwarded-for read
  - the CodeQL fix for the URL substring test
  - type-check:scripts, which is why scripts/ is type-checked at all

verify green: 244 suites, 2406 tests.

Co-authored-by: Mao Nakamoto <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 12:13:30 +00:00
370ccce976 feat(sites): make publishing a website a row, not a deploy (#783)
* feat(groups): a trading company whose whole book is singularity materials

Substrate Materials is a company profile with exactly one focus: the
physical inputs a technological singularity actually consumes. Software
is not the constraint — purified tin, neon, polysilicon, ruthenium,
transformer steel and rare-earth metal are, and each has a chokepoint, a
lead time and a counterparty.

The profile is a `group` (label 'company', public so a counterparty can
read the book before sending an RFQ), its own actor_type 'group' actor,
and a 15-line catalogue of `user_products` owned by that actor. Follows
the Revive My Old Ride convention: copy defined once in config, a
separate owner-gated seed writes it to the live DB.

What makes "solely focused" a rule rather than a slogan is the inclusion
test. A material is listed only if it moves one of three curves —
compute per joule, joules delivered, or actuation. Everything else is
declined, and the test is enforced: every listing must sit on a desk,
every desk on a curve, and no desk may sit empty.

- src/config/singularity-materials.ts — SSOT: mandate, exclusion rule,
  five desks, the catalogue, compliance stance, group + product payloads
- scripts/seed-singularity-materials.ts — idempotent, owner-gated seed
  (group by slug, actor by group_id, listings by (actor_id, title))
- test gating the payloads against the live CHECK constraints, the label
  / feature / governance registries, and the mandate itself

Treasury is deliberately not enabled: GROUP_FEATURES.treasury requires a
bitcoin_address the company does not yet have. Prices are indicative
reference levels, and every listing says so — a budgeting number, not a
quote. Export-controlled lines carry the licence and end-use conditions.

The seed has not been run; it needs the box's service-role key.

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

* feat(groups): make the map the product — Substrate as an open research firm

Reframes the trading company into what it should have been from the start:
an open-source research firm covering the chokepoints between here and a
technological singularity, with a trading desk on the materials it knows
best. The asset is the map, not the book — trading a commodity and
researching a robotics company are the same work, so the map is the
product and the desk is one way to monetise it.

Two tests now gate the universe instead of one. A node must move a curve
(compute per joule, joules delivered, actuation) AND actually gate it, on
concentration, substitutability, lead time and demand inelasticity. The
unit of coverage is a chokepoint node, not an asset class — a node can be
a material, company, person, machine or process. That is what lets the
firm reach robotics, AI hardware and additive manufacturing without
becoming "everything": you arrive at them by tracing a chain you were
already mapping, so the graph grows by traversal rather than ambition.

Phase 1 is the producers of the fifteen: 92 producer leads across 85
distinct companies, for every material on the desk. Each row asserts a
name, a jurisdiction and a step in the chain, and nothing else. There is
no field for capacity, share, revenue or quality — those are the claims
that go stale in a quarter and move markets when wrong, and the research
phase is what adds them with a citation. Every row therefore starts at
source: null, which reads as an unverified lead; coverage is measured by
how many rows have a source, not by how many rows exist.

Disclosure is written now, before any position exists, because a firm
that publishes on what it trades and intends to own cannot install that
rule credibly afterwards.

- src/config/substrate.ts — firm: curves, chokepoint screen, node types,
  four phases, desks, catalogue, compliance, disclosure, group payload
- src/config/substrate-coverage.ts — Phase 1 universe + coverageProgress()
- tests: the schema gates, plus coverage follows the book both ways and
  no producer row can carry an unsourced claim it has no field for

Renamed from singularity-materials — the firm is no longer materials-only.

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

* feat(domains): a profile spins up a whole website on its own hostname

/domains has been selling this sentence — "a working site, hosted and
managed at yourname.orangecat.ch" — with no mechanism behind it. This is
the mechanism, proved end to end on Substrate.

A request arriving on a hosted site's host is rewritten onto
/sites/<slug> and answered by a standalone website built from that
profile's own structured data. Rewrite, not redirect: the visitor's URL
bar keeps saying substrate.orangecat.ch, which is the entire point of
what is being sold. The path form keeps working on any host, so a site
is previewable before its DNS exists.

The website is not separately authored. Substrate's mandate, desks,
catalogue and coverage universe already existed as config because the
profile needed them; the five pages are those same objects rendered for
a different audience. Change the profile and the site changes with it —
and the map page cannot quietly drop the "unverified lead" caveat,
because the only data it has is the data the tests hold to source: null.

Adding a site is an entry in HOSTED_SITES plus a builder returning
SitePage[]. Pages are data, sections come from one closed set of shapes,
and one renderer serves every hosted site — which is what stops fifty
customer sites becoming fifty stylesheets.

- src/config/sites.ts — host → profile, pure and DB-free (edge hot path)
- src/config/site-content.ts — page/section model + per-site dispatch
- src/config/site-substrate.ts — Substrate's five pages, from its config
- src/middleware.ts — the host rewrite
- routes.ts + AppShell — 'site' is a fourth surface, not a chrome
  override, so a hosted site can never grow OrangeCat's header on
  somebody else's domain
- metadata uses title.absolute, so the tab says "Substrate", not
  "Substrate | OrangeCat"
- formatChf so a ruthenium quote reads CHF 15’000, in the listing the
  seed writes and on the site alike

Verified against a running server: the host rewrite resolves for
substrate.orangecat.ch, www., and substrate.localhost; orangecat.ch
itself is untouched; an unknown path under a site host 404s.

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

* feat(domains): domain availability search, shared by OrangeCat and FleetCrown

Finding a name is the rung before the two services /domains already
sells — somebody with no domain cannot buy hosting for one. This adds
the check, as a public keyless v1 endpoint both products call rather
than a widget one of them owns.

THE RULE THIS IS BUILT AROUND

The obvious implementation asks a redirector for a domain and treats 404
as available. That implementation reports ORANGECAT.CH — this project's
own production domain — as free, because .ch operates no public RDAP
service and a redirector cannot distinguish "no such domain" from "no
such registry". The same false positive hits .io and .co.

So a TLD earns a definitive answer only by appearing in IANA's RDAP
bootstrap. Everything else — unsupported TLD, timeout, transport error,
odd status, bootstrap unreachable — is `unknown`, surfaced as "check
manually" with the reason. `unregistered` is reachable by exactly one
path: a bootstrapped registry that answered 404. Even then the copy says
premium pricing, registry reservations and trademark conflicts are not
visible here. A search tool that guesses is worse than one that admits
the gap, because the guess is what someone acts on.

- src/config/domain-search.ts — SSOT: bootstrap URL, TLDs, patterns,
  timeouts, and the status copy
- src/services/domains/availability.ts — bootstrap-gated RDAP lookup,
  cached, batched at a polite concurrency
- src/services/domains/suggest.ts — bare name across every TLD first,
  variants after; a caller may narrow the TLD list
- GET /api/v1/domains — registered in PUBLIC_API_INTEGRATION_ENDPOINTS
  beside search and demand, so FleetCrown gets it as a contract
- /domains grows a search box above the offer it feeds

19 tests, none touching the network, including one per no-RDAP TLD that
fails if the feature ever reports one of them as free.

Verified live: substrataintel.com and .ai unregistered; orangecat.ai and
orangecatlabs.com registered; orangecat.ch correctly unresolved rather
than free.

Note for deploy: the box needs outbound HTTPS to rdap.org and
data.iana.org, or every lookup degrades to "check manually".

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

* feat(sites): Substrata Intel at substrataintel.orangecat.ch, designed properly

Renames the firm to Substrata Intel (files and slug follow, so a reader
never finds substrate.ts exporting a company called something else) and
gives the hosted site a design rather than a stylesheet.

TWO CORRECTIONS TO THE BRIEF, BOTH CHECKED

No domain is bought. The site runs on the free subdomain the platform
already offers. And it is orangecat.CH, not .com: orangecat.com is
registered to someone and serves nothing, while every part of this
platform — CD, Caddy, the /domains copy, SITES_BASE_DOMAIN — is .ch.

THE DESIGN

Editorial, not marketing. Space Grotesk for display, IBM Plex Mono for
anything a reader compares down a column, Inter for prose at measure.
Monochrome surfaces; the warm accent appears exactly twice, on the
current nav item and the coverage bar; status colour only on status.

- Hero replaces the generic title block on the home page: eyebrow, one
  display statement, and a lead cut to two paragraphs. The two that were
  dropped are said better by the phase block and the desk page, and a
  lead nobody finishes is not a lead.
- Coverage meter. The single most important number on the site now has a
  picture, and at 0 of 92 that picture is an empty bar. Drawn from the
  same data as the map, so it cannot flatter the work.
- The map gets a jump index — fifteen tables without one is a scroll,
  not a document — and every anchor is tested to land on a real table.
- Tables are table-fixed with declared widths. Auto layout sized each of
  the fifteen to its own longest cell, so one long company name shifted
  every column out of line with the table above it.
- Status cells carry a dot. "Unverified lead" and "Sourced" are the two
  words on this site a reader must never skim past.
- Sections are numbered, headings sit on a hanging number, cards are
  top-ruled rather than boxed.
- Masthead is one row at every width; the nav scrolls sideways on a
  phone instead of wrapping, because a two-row sticky header ate a third
  of a 390px screen.

Renderer split into focused section components under components/sites/
sections/, dispatched from one place. Three new section kinds — hero,
meter, index — available to every future hosted site, not just this one.

Verified against a running server at 1280 and 390: the host rewrite
answers on substrataintel.orangecat.ch, the tab reads "Substrata Intel",
and orangecat.ch itself is untouched.

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

* refactor(sites): the firm is Substrata, at substrata.orangecat.ch

"Intel" was only ever a workaround for substrata.com being taken. On our
own subdomain there is no scarcity to work around, so the name is just
Substrata — config files, slug, subdomain and site all follow, and the
wordmark is one word again.

ORANGECAT.COM IS NOT OURS — DNS, not opinion:

  orangecat.ch   -> 167.233.22.31   (bitbaum, this platform)
  orangecat.com  -> 222.122.39.84   (KRNIC space, unrelated party)

So substrata.orangecat.com cannot be built: it would point a customer
site at somebody else's domain. The site is on .ch, where the CD, Caddy
and every line of the /domains copy already live. No multi-base-domain
plumbing was added for a .com we do not own — that is a constant to
change on the day it becomes true, not an abstraction to carry until then.

Also: the domain-search placeholder was one customer's name. It is
"yourname" now, matching the /domains copy.

Verified against a running server — substrata.orangecat.ch and
substrata.localhost both rewrite, the tab reads "Substrata", the retired
substrataintel host correctly no longer resolves as a site, and
orangecat.ch itself is untouched.

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

* feat(substrata): no trading desk, and chokepoints that are not materials

Two corrections, both of which the site was getting wrong.

THE DESK DOES NOT EXIST

Standing a regulated commodities book up is a long road through
licensing, and none of it has been walked. Until then, prices, units,
lot sizes and invitations to deal are advertising a capability the firm
does not have — which is the single biggest untruth a page can carry,
and the one everything else here was built to prevent.

So the desk page is gone, along with every price, every unit, and the
product listings the seed wrote. The fifteen materials remain as
research subjects, keeping the part that was always research — why each
gates a curve, and which grade actually ships — folded into the map
where it belongs. The group advertises no marketplace, because there is
nothing to sell. `SCOPE.today` says plainly: we publish research, we do
not trade, broker, quote or arrange movement, and nothing here is an
offer or advice.

Disclosure keeps its rules even though there is nothing to declare —
a disclosure policy is only credible before it is needed — and now
opens by saying so. A desk survives only as a phase marked not-started,
described as an intention rather than a service.

Two tests keep it that way: one asserts a material carries no price,
unit or lot-size field, and one greps the config and the site builder
for dealing language. A config that quietly regrows a price field is a
config that puts an offer in front of a reader nobody may sell to.

MATERIALS ARE NOT THE ONLY CHOKEPOINT

The node taxonomy admitted machines, processes, companies and people
from the start, and then the universe contained nothing but materials.
Fourteen non-material chokepoints now sit alongside them: EUV scanners
with one supplier, projection optics that are a chokepoint inside a
chokepoint, packaging capacity allocated years ahead, HBM stacking
yield, transformer slots, interconnection queues, turbine order books,
magnet sintering, precision drives — and process engineers, the
constraint nobody can buy.

They enter on the same two tests and carry the same claim limits: what
the node is and why it gates, nothing about capacity, share or price,
every row unverified until sourced. A test now fails if the universe
ever collapses back to one kind of node, so "a node can be anything"
stays a fact about the coverage rather than a line in the config.

Rendered as cards, not a table: a grid of names and country codes scans
nicely and says nothing, and the claim IS the reason it gates.

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

* feat(substrata): thesis, how to act on it, and the ledger to becoming the fund

Readers will want to do something with this research. Two new pages serve
that without crossing a line the firm has no licence to cross.

THE LINE, AND WHERE IT ACTUALLY IS

Publishing an impersonal, generally-circulated view is research.
Telling a particular person what to buy is advice, and advice is
licensed nearly everywhere. Less obviously: taking a fee for an
introduction is what converts "here is who the brokers are" into
regulated intermediation — introducing broker, tied agent, finder — in
Switzerland, the EU and the US alike. Being unpaid is not a detail of
that arrangement; it is the whole of what keeps it lawful.

So there is no referral list. `PARTNERS` is empty behind a flag, and the
gate is documented: a name appears only with an executed agreement AND
confirmation that the introduction itself needs no licence. The page
says so rather than leaving a blank space, because volunteering
somebody's name as an endorsement they never gave is the easier thing
to do and the wrong one.

WHAT THE PAGES DO INSTEAD

Six routes by which anyone acts in these markets, described as market
structure and not endorsement, each carrying what it does NOT give you
— the real failure mode here is misleading by omission, and a reader
who takes a commodity ETF as exposure to seven-nines tin has been
misled by what nobody said. One route is not financial at all:
for an industrial reader the highest-return action is usually
procurement, and the map is a supplier list as much as a research
product.

A thesis, six claims, each with a falsifier. A thesis without one is a
slogan, and a slogan cannot be scored — which also makes the track
record possible later.

A readiness ledger: nine requirements to manage money rather than only
publish, at 1 done and 2 in progress. Same discipline as the coverage
meter, and the licence line still reads not started, which is the whole
reason the other two pages are written the way they are.

Tests hold the line rather than good intentions: no partner may appear
while the gate is shut; every route must state its limitation; and the
whole site is grepped for directive language ("we recommend", "you
should buy", "guaranteed", "risk-free"). These erode quietly, one
helpful sentence at a time.

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

* feat(substrata): the participant directory, graded by scarcity

The ask was everyone in the singularity chain, seen through scarcity.
102 participants across ten layers, ore to buyer, each graded.

THE GRADE IS THE PRODUCT

A directory of everyone in a supply chain is a phone book. What makes
this research is the last column: chokepoint, concentrated, or
competitive. Grading participants "competitive" is not filler — it is
what makes "chokepoint" mean anything, and several well-known names are
in the list precisely because they are not constraints. A map where
every node is critical is a map nobody has read, so a test fails if all
three grades are not in use, and another fails if chokepoints ever
exceed half the list.

On the demand side the grade reads the other way: when a handful of
firms account for most of the world's orders, that concentration is a
scarcity fact about the chain too, pointing upstream instead of down.

Same claim limits as everywhere: name, layer, jurisdiction, role and a
scarcity judgement. Nothing about revenue, capacity or share, and every
row unsourced until an analyst attaches a source.

The page leads with the 24 that actually bind, as cards carrying the
reasoning, then the full directory as per-layer tables behind a jump
index.

ALSO

- Dropped the defensive framing from Acting. The limits are three
  plain lines now, and the "why there is no referral list" section is
  gone: a directory nobody paid to be in is the point, not a caveat.
- Domain aliases wired ahead of ownership. substrata.ch (intended home,
  appears free — .ch publishes no RDAP so a registrar has to confirm)
  and substrataintel.com (the .com fallback; substrata.com is taken).
  A host only reaches the check if DNS already points here, so listing
  them early costs nothing and means the site works the hour one is
  bought, with no deploy.
- The readiness ledger became definitions instead of a table. Three
  columns where one holds a paragraph is a table that scrolls sideways
  on a phone and is read by nobody.
- The nav is a client component for one reason: at eight sections the
  active item sat off-screen on a phone, so a visitor on a deep page saw
  no indication of where they were. It scrolls itself into view now.

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

* docs(seed): the seed header still described a firm that no longer exists

It said "Substrate", promised a trading desk, and claimed the script had
to run on the box. All three were stale: the firm is Substrata, there is
no desk, and the seed is PostgREST calls rather than psql — so it runs
from any machine that can reach supabase.orangecat.ch over HTTPS, no SSH
and no tunnel needed. That last one matters, because believing otherwise
is what makes a two-minute task look like it needs a maintenance window.

Also notes that the service-role key bypasses RLS, so the machine running
it is privileged.

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

* fix(sites): close the five defects the architecture audit found

CodeQL was red on this branch with six alerts, which is why the PR could not
merge. All six were real but shallow: five unused locals, and one substring
test on a URL (`url.includes('data.iana.org')`) that also matches
`data.iana.org.evil.example`. It sat in a test — the worst place for it, since
tests are what the next lookup gets copied from.

The other four are the ones that mattered:

**60 KB of dead payload on every page load.** `SiteNav` is a client component
and was taking `SitePage[]`. Every prop crossing that boundary is serialised
into the RSC payload, so all eight Substrata pages shipped the entire site —
92 producer rows, 102 participants — to render eight links. Measured: 60.1 KB
carried, 0.33 KB used. It now takes `SiteNavItem[]`, the narrowest shape that
answers its question.

**A public keyless amplifier with no rate limit.** One request to
`/api/v1/domains` fans out to as many as 24 outbound RDAP lookups, and varying
the query defeats the cache. The cost of abuse was never our CPU — it was this
box's IP being throttled by the registries we depend on. Now behind
`rateLimitDomainSearch` (10 per 5 min), modelled on the ask-cat limiter, which
exists for exactly this shape: an expensive downstream call for an anonymous
caller.

**An unbounded cache keyed by caller input.** `resultCache` grew for as long as
the process did, and on the box that is weeks. The TTL did not bound it —
expired entries are only noticed when the same key returns, which an
enumerating caller never does. Capped, with a TTL sweep before LRU eviction,
and a test that fails if the cap stops holding.

**A seed that would break on the box, not in CI.** `seed-substrata.ts` used an
untyped client and five `as string` casts, so a column rename would surface by
hand, months later. Bound to the generated `Database` type; the casts are gone
because they are no longer needed.

Also collapsed the third copy of the x-forwarded-for read in rate-limit.ts into
`clientIp()`. A per-IP limiter is only as correct as its notion of "IP".

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

* feat(sites): publishing a website stops being a code change

A hosted site was an entry in a hardcoded array plus a hand-written builder.
That means every customer costs a pull request, a CI run and a deploy before
their domain resolves — which is the opposite of what /domains sells. Three
changes make an ordinary site cost nothing:

**Host resolution is positional, not a list.** `siteSlugForHost` asks whether a
Host header is SHAPED like a hosted site — one non-reserved label on
orangecat.ch — and never touches the database, because it runs in edge
middleware on every request to the whole app. Whether a site EXISTS is decided
downstream by the page, which is allowed to query. An unclaimed slug rewrites
and 404s, which is the safe direction.

That trade needs a reserved list to be safe, so there is one, and it is
load-bearing twice over: `supabase`/`bridge`/`fleetcrown` already serve
something else on this box, and `security.orangecat.ch` under our own
certificate is a phish, not a website. RESERVED_SUBDOMAINS covers both, and the
tests assert every entry refuses.

**A site is a row in a table that already exists.** `group_features` has
group_id, enabled, an audit column and a `config` jsonb, and its own header
already says adding a feature needs no code. Publishing a website is a
capability a group switches on, exactly like treasury. A `hosted_sites` table
would have duplicated all four columns and created a second answer to "what has
this group turned on". The new migration adds one RLS policy so a published site
is world-readable — the database decides "published", not TypeScript, and
`enabled = false` unpublishes instantly. jsonb is `any` wearing a hat, so it is
validated at the boundary with a per-field `.catch`: one malformed alias host
costs that alias, never the customer's website.

**An ordinary site has no builder.** `site-profile.ts` renders any group from
the profile it already filled in. Nothing is authored twice and nothing is
invented — no Support block without an address, no nav on a one-page site. The
dispatch that was a `switch` is now a map holding only the exceptions, because
that is what a bespoke builder is: Substrata's research corpus is not
profile-shaped, and it stays in the repository so it renders statically without
a database at all.

Net: a new site is a row and zero lines of code. 216 config tests green.

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

* feat(sites): a certificate for any customer domain, with no ssh

Positional host resolution gets a site routed. It does not get it a TLS
certificate, and without one the site is unreachable — so this is the other half
of "spinning up a site costs no infrastructure work".

The alternative was a wildcard certificate: a DNS-01 challenge, an Infomaniak
API token living on the box, a Caddy DNS plugin — and it still would not cover a
customer's own domain. On-demand TLS needs none of it and inverts the
relationship correctly: Caddy asks OrangeCat whether a hostname is real before
ordering a certificate, and OrangeCat already knows, because a site is a row.

`/api/internal/tls-check` is that gate, and it is written as a gate. Every 200 is
an ACME order and Let's Encrypt rate-limits an account that fails them, so
anyone who points a hostname here and requests it is spending our issuance
budget. Reserved subdomains are refused before any query runs, and a lookup that
throws denies — a database blip must not become an open certificate mint. Six
tests hold exactly those cases, including the fail-closed one.

The Caddy block lives in `deployment/caddy/` rather than only on the box,
because configuration that exists only on a box is configuration nobody can
review. `install-hosted-sites-caddy.sh` refuses to run until the ask endpoint
answers 200, backs up the Caddyfile, validates before reloading, and re-checks
the neighbours afterwards — one bad Caddyfile takes down all twenty-odd apps.

**RESERVED_SUBDOMAINS was wrong, and now cannot be.** Written by hand, it held
seven labels. The box is serving twenty-two. Fourteen live hostnames —
kivvi, vitareba, solon, supabase among them — were claimable as site slugs the
moment resolution became positional. The list is now generated from Caddy into
`deployment/reserved-hosts.txt`, and `check:reserved-hosts` is in `verify`, so
the next app deployed on this box fails the build until it is reserved. The gate
was tested by deleting an entry and confirming it goes red.

Live Caddyfile deliberately untouched: the ask endpoint is not deployed yet, and
enabling on-demand TLS before it exists would deny every request. Install after
the deploy.

438 tests green.

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

* docs(sites): the runbook for turning a group into a website

Two audiences. Somebody publishing a site needs to know it is one row and no
deploy — and that the minute before it answers is a named constant, not a
mystery. Somebody deploying a new app on bitbaum needs to know why the build
suddenly fails on reserved hosts, because that failure is the whole point of
the gate and it will look like a bug the first time.

Both one-time infrastructure steps are written down with the reasoning kept,
including the one that cannot be automated from here: no Infomaniak API
credentials exist on a developer machine, so the wildcard A record is a human
action, once, forever.

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

* fix(verify): type-check the scripts, so the seed's types mean something

The previous commit said binding seed-substrata.ts to the generated `Database`
type 'moves that failure to npm run type-check'. That was not true as
configured: tsconfig.json excludes scripts/**/*.ts so Next does not compile
them, and the side effect was that verify never looked at them at all. The
binding was decoration.

A seed is exactly the wrong place for that gap. It runs by hand, on the box,
months after the migration that broke it — the one script whose schema drift
surfaces in front of a person rather than in CI.

scripts/ was already at zero errors, so this gate starts green. Verified it
bites by mistyping a column name and watching it go red.

Deliberately not extended to __tests__: 119 pre-existing type errors live there
and fixing them is real work that does not belong to whichever change happens to
notice. Recorded rather than silently skipped.

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

* feat(sites): publish a website with one call, not one INSERT

Everything underneath already worked off a single row, but the only way to
write that row was SQL. That is not "a few clicks" — it is a DBA. This is the
endpoint FleetCrown and the group settings UI call:

  GET    /api/groups/[slug]/site   status, address, eligibility
  PUT    /api/groups/[slug]/site   publish (upsert, so it also reconfigures)
  DELETE /api/groups/[slug]/site   unpublish, keeping the configuration

Three decisions worth naming:

**PUT is an upsert.** "Create a site" and "configure a site" would be two
states to reason about where the database has one row.

**GET answers `url` even when unpublished**, plus `eligible` and `reason`. It
costs nothing and it is the difference between a button that says "Publish" and
one that says "Publish at acme.orangecat.ch" — and between a group learning its
slug is reserved before it clicks or after.

**DELETE disables, it does not delete.** `enabled = false` is what both the RLS
policy and the resolver read, and keeping the row keeps the config, so taking a
site down for a week does not lose its custom domain.

The refusals are the tested part, because the worst failure here is a site that
exists in the database and never answers on the internet — the button said it
worked. A slug that is not a legal DNS label, a slug that already belongs to
infrastructure (`supabase`, `fleetcrown`) or invites a phish (`security`), and
a private group whose site RLS would hide from every visitor.

`check:sizes` refused the first version at 229 lines, which was the right
complaint: the route was doing domain work. Rules and writes now live in
services/sites/publish.ts, which imports nothing from `next/` — that one
`revalidateTag` import dragged Next's entire server runtime into any test that
touched these rules, and dropping a framework cache is the HTTP layer's job.

verify green: 250 suites, 2494 tests.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mao Nakamoto <georgy.butaev@revamp-it.ch>
2026-08-27 08:42:17 +00:00
0cfca45556 docs(ops): runbook for enabling/operating CD (auto-deploy) (#480)
cd.yml stays dormant until SELFHOST_SSH_KEY exists. Document the one-time
secret + deploy-key setup, the manual-deploy command, and rotation — so
"merge = shipped" is discoverable next to the workflow instead of tribal.

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-28 15:05:52 +02:00
255690d741 feat(auth): add LinkedIn OAuth + fix provider-union SSOT + config runbook (#477)
Social login is fully config-driven and SSOT-clean already: buttons come from
OAUTH_TO_SUPABASE, and /api/auth/oauth-providers probes each provider's real
/authorize so only working ones render. Two gaps:

- LinkedIn was missing. Added `linkedin: 'linkedin_oidc'` to the map (auto-flows
  through the probe route and the client hook) + a LinkedIn button in
  OAuthIcons, ordered google/github/x/linkedin/facebook.
- handleOAuthSignIn hardcoded a 'google'|'github'|'facebook'|'apple'|'twitter'
  union — a duplicate of the map that silently rots when a provider is added.
  Replaced with supabase-js's own `Provider` type (SSOT: adding to the map now
  extends it), and exported SupabaseOAuthProvider from the map for reuse.

Diagnosis captured in docs/operations/oauth-social-login.md: google + github
work today; x (twitter) is flagged enabled but its /authorize bounces to the
site root (broken/missing credentials) so it's correctly hidden; linkedin +
facebook need configuring. The runbook has the exact per-provider steps
(register app -> GoTrue redirect URI https://supabase.orangecat.ch/auth/v1/callback
-> GOTRUE_EXTERNAL_* env -> restart -> verify via the providers endpoint).

Code is tsc + lint clean; the providers endpoint returns cleanly with LinkedIn
added. Enabling each provider is now ops-only (no app deploy for the button).

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-28 14:17:44 +02:00
0ea2fafffe feat(credits): one-command activation handoff — full top-up round-trip verifier + runbook (#455)
Cat Credits is built + break-even-hardened and dormant behind one env var
(PLATFORM_NWC_URI). Provisioning a real receiving wallet is George's action
(it's a live financial credential); this makes the rest a single verified step.

- scripts/bitcoin/verify-credits-roundtrip.ts — proves the APPLICATION loop,
  not just the wallet: initiateTopUp issues a real invoice → you pay it → checkTopUp
  settles it and credits the ledger → asserts the balance increased. Complements
  the existing verify-platform-wallet.ts (mint-only, never paid) with the part
  that could actually have a bug (payment → ledger).
- docs/operations/credits-activation.md — the exact ordered runbook: set the
  URI → verify wallet → verify round-trip → flip NEXT_PUBLIC_CAT_CREDITS_LIVE.
  Flags the money-transmission/custody question to weigh first.

Verified: tsc 0. (The scripts move real money, so they're run by George on the
box against the live wallet — not in CI.)

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-27 18:54:31 +02:00
60359d8aa9 chore(infra): remove Vercel references — everything is self-hosted now (#430)
The 2026-06 migration already removed all live Vercel surface (no vercel.json,
no @vercel/* deps, no process.env.VERCEL_* reads, no *.vercel.app URLs, no
Vercel CI workflow). This trims the remaining gratuitous/misleading textual
mentions in the docs:

- ENVIRONMENT.md: drop the now-redundant "(not Vercel)" parenthetical — the
  Hetzner box is already named.
- preview-automation.md (archive): mark the doc OBSOLETE up top so nobody reads
  its present-tense Vercel preview/deploy workflow (`deploy.yml`,
  amondnet/vercel-action) as still active; body kept as historical record.

Deliberately kept: the "there is no Vercel" protective guidance, accurate
historical rationale in current infra/deploy docs, the `/vercel/next.js`
Context7 library id (Next.js genuinely lives under the vercel org), and the
dated historical snapshots under docs/archive/** and docs/reference/changelog/**.

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 21:35:56 +02:00
Georgy ButaevandClaude Opus 4.8 90fda19e32 docs(runbook): first-payment handoff is zero-friction (top-up auto-enables from env)
A3/A4 prep. Corrected the wallet runbook: the Settings->AI top-up button gates on
GET /api/cat/credits topupEnabled = platformReceiveEnabled() (server, PLATFORM_NWC_URI),
NOT on CAT_CREDITS_LIVE. So the founder can test the first payment the moment they set
the env + restart — no code change from me. CAT_CREDITS_LIVE is purely the pricing-card
badge (cosmetic), flipped after. The Settings->AI panel (balance + ledger) is the
'counter we can watch' for the first payment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 16:03:44 +02:00
Georgy ButaevandClaude Opus 4.8 f9b377ca55 docs: platform wallet runbook + one-week plan (first-payment sprint)
Runbook: founder-facing steps to provision PLATFORM_NWC_URI (Alby Hub NWC
connection → box env → live top-up test → flip CAT_CREDITS_LIVE), unblocking
Cat Credit top-ups + paid assistants — the single blocker to OrangeCat's first
payment. One-week plan: North Star = payments 0→>=1 + one real FleetCrown
economic action driven by the Cat; harden (S1/F2 done), Cat drives the loop,
prove with a real user. First concrete step onto the 10-year path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 09:18:25 +02:00
1669da5604 docs(ops): vendor app systemd unit + launch.sh, add resilience runbook (#391)
Box-side resilience prep from the DevOps audit (advisory + SSOT artifacts —
zero runtime change; the founder applies the runbook steps box-side):

- Vendor the OrangeCat systemd unit + launcher into the repo (they lived ONLY on
  the box), so a fresh-box rebuild is a scripted install, not archaeology:
  scripts/systemd/orangecat-app.service, scripts/systemd/launch.sh (verbatim
  from the box; no secrets — env is externalized to .env).
- docs/operations/RESILIENCE.md — actionable, copy-paste runbook for the four
  proactive gaps: (1) single-box SPOF → scripted OC bring-up + publish RTO +
  optional warm standby; (2) off-site backups are deletable → B2 Object-Lock +
  non-delete key + off-box retention + ≥2 RESTIC_PASSWORD copies; (3) root
  deploy credential → non-root oc-deploy user with scoped sudoers; (4) the
  fleetcrown-owned backup pipeline dependency + the container-dump must-hold.

Full box-wide IaC stays in fleetcrown's shared hetzner toolkit (noted), not
forked here.

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 09:11:49 +02:00
G 239a5b12c1 Merge pull request #382 from maonakamoto/ops/restore-drill
docs(ops): restore drill runbook — off-site backups proven, RTO ≈ 45 s data leg, 2 backup-pipeline gaps fixed
2026-07-03 20:02:25 +02:00
Georgy ButaevandClaude Fable 5 5ad101fb57 docs(ops): restore drill runbook — off-site backups proven, RTO measured, 2 pipeline gaps fixed
Full drill executed 2026-07-03 on bitbaum (never touching prod):
- restic restore latest from B2 (277 MiB): 6.1 s
- pg_restore of OrangeCat dump into throwaway supabase/postgres:15.8.1.085: 6.1 s
- data-restore RTO ≈ 45 s; verification = exact parity with prod
  (115/174 tables, 325 RLS policies, all spot row-counts, cat_credit_append, pgvector)

Gaps found and fixed in /opt/backups/pg-backup.sh on the box:
1. supabase-db container cluster globals (roles) were never dumped →
   21 pg_restore errors; now dumped as supabase-globals-$STAMP.sql.gz
2. orangecat systemd units + launch.sh missing from config snapshot →
   added to stage_cfg list
(pre-patch copy kept at pg-backup.sh.bak-20260703; sync fixes into the
fleetcrown Hetzner toolkit so a re-install does not revert them)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 19:56:09 +02:00
Georgy ButaevandClaude Fable 5 6cff710873 ops(migrations): extract auto-apply into scripts/apply-migrations.sh SSOT
The deploy path already applied pending supabase/migrations/*.sql inline in
deploy-selfhost.sh; this promotes that block to a standalone, hardened SSOT
script and documents the whole migration story.

scripts/apply-migrations.sh:
- ensures public.schema_migrations (filename PK, applied_at) exists
- --backfill bootstrap mode (record all current files as applied, run nothing)
  + a guard that refuses a full replay when the tracking table is empty but
  core app tables exist
- applies pending files in filename order, each in a single transaction
  (psql -1 -v ON_ERROR_STOP=1), records only after success, aborts non-zero
  on first failure with the failing filename
- --dry-run lists pending without changing anything
- integrity-checked tracked-list fetch (count vs rows in one psql call) +
  per-file DB recheck before executing — a truncated list over ssh once made
  an already-applied 2025 file look pending and re-execute against prod
  during live testing of this script (harmless: CREATE OR REPLACE only)
- all SQL travels via stdin, never -c, killing nested-quoting across
  shell→ssh→docker-exec

deploy-selfhost.sh delegates to it before the boot-test/swap; a migration
failure still aborts the deploy loudly with the live release untouched.
cd.yml already runs deploy-selfhost.sh --no-build, so merged migrations
auto-apply on every deploy — no workflow change needed.

Live-tested against the box: dry-run 0-pending after reconcile (162 tracked
== 162 files), no-op migration applied+recorded+cleaned, failing migration
aborted exit-1 without being recorded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 19:54:37 +02:00
Georgy ButaevandClaude Opus 4.8 a52836c793 chore: remove all Vercel — everything runs on Hetzner
Production is fully self-hosted on the Hetzner box (bitbaum, behind Caddy)
with self-hosted Supabase. This scrubs the remaining Vercel footprint:

Code (src/ now has zero Vercel references):
- security page: "Hosted on Vercel" → self-hosted infrastructure
- FleetCrown URL fleetcrown.vercel.app → fleetcrown.orangecat.ch (entity
  registry + external-publish allowlist; the dead vercel.app subdomain was
  also a re-registration risk in an allowlist)
- webhook-secret error + cron/env comments point at the box, not Vercel
- corrected stale "Vercel kills the function on response" comments (false
  on a persistent server) to accurate await-before-respond reasoning

Security/config:
- supabase/config.toml: dropped dead *.vercel.app auth redirect URLs
- @vercel/mcp-adapter dependency removed (unused)

Artifacts removed:
- scripts/auth/vercel-login.js, scripts/preview-url.sh,
  scripts/dev/merge-env.js, scripts/monitoring/deployment-monitor.js,
  scripts/db/setup-env.js, mcp-servers/vercel-openapi.json, .vercel/
- setup_vercel_secrets MCP tool in mcp-servers/github-server.js
- .gitignore Vercel section; env scripts stripped of vercel-login/token

Docs + .claude rules/commands rewritten to the self-host deploy flow
(scripts/deploy-selfhost.sh / .github/workflows/cd.yml; env at
/opt/orangecat/app/.env). Historical/archive records left intact.

Verified: tsc 0 errors, SELF_HOST=1 build green, cron unit tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 08:50:43 +02:00
Georgy ButaevandClaude Opus 4.8 994bdc0180 docs(storage): OC media migrated to R2 — deployed record + maintenance runbook
storage-api v1.60.4 backend flipped file→s3 (bucket orangecat-media), 35 objects
migrated verbatim, read+write verified. Documents the real key layout, R2 gotchas
(checksum disable, tus tags), rollback, and shared-token rotation coupling.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 03:35:53 +02:00
Georgy ButaevandClaude Opus 4.8 78814deb83 feat(observability): expose box disk/mem on /api/health + alert on disk pressure
The Hetzner box is the whole platform's single failure domain and was at ~68% disk
and climbing with zero visibility — a silent disk-full = hard outage. Since the app
runs as a standalone Node process directly on the box (not containerized), it can read
the real filesystem:
- src/lib/host-metrics.ts: statfs('/') + os mem → {disk_used_pct, mem_used_pct}
  (percentages only — nothing sensitive — safe on the public health endpoint).
- /api/health now returns a host{} block alongside service status.
- uptime.yml (free off-box monitor) reads disk_used_pct and opens/auto-closes a
  'disk-pressure' GitHub issue at ≥85% — early warning before the box fills.

Also recorded the 2026-06-19 DR restore drill result in the runbook (B2 pull →
pg_restore into a throwaway DB → real rows verified).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 03:35:08 +02:00
Georgy ButaevandClaude Opus 4.8 692a9e3ba4 docs(storage): runbook + script to move OC media to R2 (Supabase Storage backend swap)
Backend swap only — app keeps calling supabase.storage, public URLs unchanged,
no DB rewrite. Captures the rolled-shared-token box commands for the sibling apps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 03:12:18 +02:00
Georgy ButaevandClaude Opus 4.8 29cd7e5e19 docs(dr): config/secret backup gap CLOSED — off-site restore now self-sufficient
pg-backup.sh (on the box) now stages the Supabase .env, app .env, Caddyfile and
all docker-compose*.yml into /opt/backups/config (600 root) and restic pushes them
to B2 in the same encrypted snapshot as the DB dumps. Verified: latest B2 snapshot
contains both /opt/backups/pg and /opt/backups/config (12 config files). Runbook
updated: step 0 now pulls everything from restic, with the staged→real-path restore
mapping. Remaining open item: mirror the box pg-backup.sh edits (container-dump +
this config block) into fleetcrown's install-backups.sh so a reinstall can't revert them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 02:58:01 +02:00
Georgy Butaev fb251adf58 ops: free off-box uptime monitor + disaster-recovery runbook
- .github/workflows/uptime.yml: GitHub-hosted uptime check (every ~10 min) on
  /api/health + homepage; opens/closes a GitHub issue on down/recovery (off-box, so it
  survives the box dying; free, no signup). Optional Discord/Slack webhook secret.
- docs/operations/DISASTER_RECOVERY.md: restore-to-fresh-box runbook with the REAL
  topology (two Postgres — OrangeCat is in the supabase-db container, not box-system PG),
  exact paths, and the open backup gaps (off-site + config/secret backup).

Context: discovered + fixed today that OrangeCat had no working backup at all
(pg-backup.sh dumped an empty box-system stub, never the Supabase container). The daily
backup now captures the container DB; see the runbook for the remaining gaps.
2026-06-18 19:17:59 +02:00
Georgy ButaevandClaude Opus 4.8 ef740ba66b docs: correct stale Vercel deploy claims to self-hosted Hetzner reality
OrangeCat deploys self-hosted on Hetzner (bitbaum, behind Caddy); there
is no Vercel anymore. Brought present-tense docs/config in line:

- developer-guide.md: 'Deployment: Vercel' -> self-hosted; replaced the
  'git push -> Vercel' production block + Vercel env-var section
- scripts/health-check.js: setup hints no longer say 'vercel env pull';
  point at /opt/orangecat/app/.env on the box
- .env.example: dropped the dead VERCEL_* env block + 'vercel login' /
  'vercel env pull' instructions; replaced with self-host notes
- DEPLOYMENT_CHECKLIST.md: '6) Vercel Deployment' -> Self-Hosted (Hetzner)
- INTEGRATION_DEPLOY_CHECKLIST.md: customer (FleetCrown) is self-hosted
  too — 'set Vercel env vars / redeploy' -> edit .env + restart service
- removed dead vercel.json (no live reference; only past-tense comments)

Supabase references left untouched — self-hosted Supabase is the real,
current stack. Historical/archive docs (DECOMMISSION-CLOUD, archive/**)
preserved. LICENSE / legal / .mailmap real-name left for a separate
identity decision.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 20:10:11 +02:00
Georgy ButaevandClaude Opus 4.8 ae55dc1f80 docs: consolidate taxonomy from ~40 dirs into ~13 coherent areas
The docs tree had sprawled into ~40 overlapping/singleton/empty directories.
Consolidated (history preserved via git rename detection; links rewritten so
no previously-working link broke):

- architecture/ ← adr/, database/, + loose *_ARCHITECTURE / my-cat specs
- development/  ← standards, contributing, guides, examples, templates, components, ai
- operations/   ← devops (+runbooks), deployment, supabase
- design-system/← design, UX, ux-improvements, branding
- reference/    ← api, changelog, content, misc
- forward-looking/ ← planning, improvements, implementation
- archive/2026-h1/ ← point-in-time reports/plans that were loose at docs/ root
- removed empty docs/analysis/; rewrote docs/README.md as a current index

Verified: non-README relative-link health 81→83 OK (0 regressions, same 64
pre-existing-rot broken); all new README links resolve; external refs in
.claude/ + root repointed to moved targets.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 11:34:28 +02:00
Georgy ButaevandClaude Opus 4.8 d82805dd43 docs: bring docs up to date with self-host reality; archive dead cloud docs
Product/infra evolved (managed Supabase Cloud retired 2026-06; prod now
self-hosted on Hetzner). Reconciled the canonical/entry docs:

- README + CLAUDE.md: Deployment Vercel → self-hosted Hetzner; DB → self-host
- SETUP / ENVIRONMENT: drop 'cloud Supabase only' + Vercel prod setup; use
  supabase.orangecat.ch, env on the box, psql migrations
- implementation-guide / cleanup-summary: 'npx supabase db push' → psql apply
- CURRENCY_SYSTEM_EXPLAINED: amounts stored in BTC NUMERIC(18,8), sats are
  display-only (not stored in satoshis)
- SUPABASE_SCHEMA_GUIDE / functions-guide: dashboard + *.supabase.co → psql /
  supabase.orangecat.ch
- TECHNICAL: top note that it predates the self-host migration; Next.js 14→15
- troubleshooting / BEST_PRACTICES / environment-management: self-host notes

Archived to docs/archive/2026-h1/ (managed-cloud-only, now misleading):
SUPABASE_MIGRATION_WORKFLOW, MIGRATION_QUICK_REFERENCE,
MIGRATION_LESSONS_LEARNED, preview-automation (no Vercel workflow exists),
mcp-supabase (MCP targets retired cloud). Rewrote docs/workflows/README as a
concise accurate index.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 11:04:49 +02:00
Georgy ButaevandClaude Opus 4.8 054204e943 chore(infra): retire managed Supabase cloud; Hetzner self-host is SSOT
The managed Supabase Cloud project (ohkueislstxomdjavyhs) is retired; the
self-hosted instance at supabase.orangecat.ch on the Hetzner box is the single
source of truth. Repoint the image host + setup scripts, rewrite the agent/dev
guidance to use the self-host directly (not the Supabase MCP, which only reaches
the retired cloud), update active docs, exit retired cloud-Management-API
scripts behind a RETIRED guard, env-ify direct-connect scripts, gitignore
.env-backups, and add a founder-run DECOMMISSION-CLOUD runbook. No live code
path references the managed project anymore.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 09:26:58 +02:00
Georgy ButaevandClaude Fable 5 2e43593920 chore(cleanup): remove the Vercel-era deploy toolchain (post-migration orphan sweep)
Everything a developer could run or read that still targeted the exited
Vercel platform is gone or corrected:
- scripts/deployment/: 19 Vercel-era scripts deleted (one-button-deploy,
  vercel-monitor, auto-deploy-agent, …); browser-verify.js kept with a
  new README — it's the platform-agnostic post-deploy smoke test
- w + scripts/dev/w.bat + scripts/dev/sync-env.js deleted (auto-commit/
  Vercel-deploy/env-sync automation; w.bat triggered a deleted workflow)
- package.json: 14 dead scripts removed (ship, deploy*, deployment:*,
  env:pull/push, monitor:logs, mcp:vercel, w); deploy:rollback pointed
  at a file that didn't exist
- Makefile: dead 'ship' target removed
- docs: 1.3k lines of Vercel pipeline docs deleted (DEPLOYMENT_PROCESS,
  GITHUB_VERCEL_SETUP/STATUS, legacy-tools, action-plan.json) and
  replaced with short true versions; ci-cd.md rewritten; ghost links and
  stale instructions fixed in devops/README, ENVIRONMENT, debugging,
  workflows/README (DEPLOYMENT_WORKFLOW.md never existed)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 01:51:13 +02:00
Georgy ButaevandClaude Opus 4.7 c1126764b7 docs(deploy): update TL;DR to 9 steps after the WEBHOOK_SECRET_KEY add
cc76194f added step 9 (WEBHOOK_SECRET_KEY) to the body of the
checklist but the TL;DR header still read "8 steps" and the
introduction still pointed at "the 8-step deploy that shipped
across 211188a3 → 5f051a83". Also touched up the step-9 inline
description: now references secret_encrypted (the column that
exists post-6da6b8cd) instead of secret_plaintext (the column
that was just dropped).

Pointer to the latest commit in the lineage updated 5f051a83 → 6da6b8cd.

No code change. Doc consistency only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 04:11:51 +02:00
Georgy ButaevandClaude Opus 4.7 6da6b8cd0c feat(crypto): encrypt webhook secrets at rest (phase 2 of 2) — drop plaintext
cc76194f shipped the cipher util + dual-write. This commit closes the
encrypt-at-rest thread:

  1. Migration 20260604000004 (applied to remote, prod row count
     verified zero so backfill is a no-op):
       - DROP CONSTRAINT webhook_endpoints_secret_not_blank (targeted
         the column we're dropping)
       - ALTER COLUMN secret_encrypted SET NOT NULL (load-bearing now)
       - DROP COLUMN secret_plaintext
  2. createWebhookEndpoint: writes only secret_encrypted on mint
     (plaintext column no longer exists). The encrypt-throw-on-bad-env
     behaviour from phase 1 still fails the mint cleanly.
  3. getEndpointSigningContext: selects secret_encrypted, decodes the
     PostgREST `\x...hex...` bytea wire format (with a base64 fallback),
     decrypts via decryptWebhookSecret. Decrypt failure logs and returns
     null so the worker records a "[endpoint revoked]" outcome rather
     than signing with a wrong key — degraded but never forged.
  4. Deploy checklist step 9 verification updated: mint a row, check
     `secret_encrypted IS NOT NULL` and that secret_plaintext no longer
     exists, trigger a delivery, watch the X-OrangeCat-Signature header
     succeed. Rollback section rewritten with the honest "you cannot
     rotate this key in place" warning and the 3-step safe rotation.

decodeSupabaseBytea helper added inline — Supabase admin client returns
BYTEA as `\x<hex>` text by default; the fallback to base64 handles
environments where postgrest serialises differently. Never throws,
falls back cleanly.

The encrypt-at-rest thread is now complete: webhook signing secrets
are AES-256-GCM at rest, in-memory only during fire, key rotation
documented as a planned-incident operation.

Suite: 55 suites · 717 tests · 0 failures. tsc + eslint clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 04:11:02 +02:00
Georgy ButaevandClaude Opus 4.7 cc76194fd6 feat(crypto): encrypt webhook_endpoints secrets at rest (phase 1 of 2)
The PHASE-2 debt the user explicitly chose 30+ commits ago in
2755a8a5 ("plaintext for now, encrypt later"). Webhook signing secrets
are needed at fire time (the worker must sign each delivery), so they
have to live somewhere — but a DB compromise should NOT reveal them.

This commit lands the encryption infrastructure and starts dual-write.
Commit 2 of 2 will backfill secret_encrypted (no-op today: prod has
zero webhook_endpoints rows), flip getEndpointSigningContext to
decrypt, drop secret_plaintext.

Cipher (src/lib/crypto/webhookSecretCipher.ts):
  AES-256-GCM with WEBHOOK_SECRET_KEY env var (32-byte hex). Ciphertext
  layout: IV(12B) || GCM tag(16B) || ciphertext. Authenticated — a
  flipped byte anywhere in the blob throws on decrypt, so a DB
  compromise can't return a forged secret to the worker (only DoS by
  deleting rows). loadKey() validates the env var at first use and
  caches the parsed key; resetCachedKey() is test-only.

Schema (migration 20260604000003, applied to remote):
  ALTER webhook_endpoints ADD COLUMN secret_encrypted BYTEA.
  Service dual-writes; reads still come from secret_plaintext so the
  worker keeps signing deliveries unchanged.

Service (webhookEndpointsService.createWebhookEndpoint):
  Dual-writes secret_plaintext + secret_encrypted on mint. If
  encryptWebhookSecret throws (env var missing/malformed), the mint
  fails — we never store a row that phase 2 can't decrypt.

Deploy checklist: new step 9 (WEBHOOK_SECRET_KEY env var) with
generation command, verification (mint a webhook endpoint and watch
for 500), rollback warning (rotating the key requires re-encryption,
mention of incident-response posture).

Tests (16):
  loadKey: cache, missing env, empty env, non-hex, wrong length
  round-trip: exact equality, len-1, 4KB, unicode, IV-randomness,
    blob layout assertion (12+16+len(plaintext))
  tampering: flipped ciphertext / IV / tag byte, truncated blob,
    wrong key → all throw

Suite: 55 suites · 717 tests · 0 failures (+1 suite, +16 tests).
tsc + eslint clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 04:03:38 +02:00
Georgy ButaevandClaude Opus 4.7 9798ffedf2 docs(deploy): step-by-step checklist for the platform-API integration
Production deploy was queued for 20+ commits in the session state with
no discoverable artifact. This commit captures the 8 steps from the
211188a3 → 5f051a83 thread into one document an operator can pull up.

Companion to the existing docs/operations/DEPLOYMENT_CHECKLIST.md (which
covers general OrangeCat deployment); this file is specifically the
extra steps to onboard an integration-key + webhook customer (FleetCrown,
hirn.li, third-party).

Per step:
  - Exact command(s) and where to run them
  - Verification — how to know the step landed
  - Rollback — what to do if it doesn't

Plus a smoke test at the end that exercises the full path: SDK call
creates entity → webhook fires within 60s → deliveries drawer shows
green Delivered → customer's verifyWebhookSignature returns valid.

Documented operational surface at the bottom: backoff schedule, idempotency
TTL, rate-limit defaults, scope wildcard default, sandbox prefix. All
linkable to the commits that shipped them so the next operator can
verify behaviour against the test that locks it.

Suite: 54 suites · 701 tests · 0 failures. Repo state otherwise unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 03:12:18 +02:00
g-butandClaude Opus 4.5 2df79381f1 feat: streaming AI, canonical rate limiting, cleanup demo pages
Major changes:
- AI streaming: Add unified client for OpenRouter SSE and local (Ollama) providers
- Local AI detection: Auto-detect and configure local model providers
- Rate limiting: Canonical adapters with X-RateLimit-* headers across APIs
- SSE: Add lib/sse.ts for consistent event-stream parsing

Cleanup:
- Remove /demo, /donate, /fund-us, /funding, /fundraising pages
- Simplify ModelSelector component (288 → 80 lines)
- Consolidate timeline queries

New features:
- Voice input component and hook
- Query provider for React Query
- Model registry with status badges
- HTTP headers config

Tests & Docs:
- E2E tests for project creation wizard
- Unit tests for auth, streaming, components
- CHANGELOG.md for version tracking
- Deployment checklist and PR summary docs

Bug fixes:
- Timeline schema and functions migration fixes
- Messaging RLS recursion fix
- Auth callback improvements
- Bitcoin formatting precision
- Lint fixes for unused variables

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 16:02:26 +01:00
Your NameandClaude Opus 4.5 bcfb0aa8de security: remove all hardcoded secrets from scripts and docs
- Replaced 29 JWT tokens with environment variable references
- Deleted docs/operations/SUPABASE_API_GUIDE.md (contained real keys)
- Removed mcp-servers/node_modules from git tracking (716 files)
- Updated .gitignore to prevent future exposure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 13:11:53 +01:00
Your Name 1b2a2371e9 refactor: Complete codebase improvements per engineering principles
- Fix currency defaults (SATS → CHF) across forms, configs, and API routes
- Remove @ts-nocheck from socialService.ts and improve type safety
- Replace console.log statements with proper logger utility in production code
- Additional type safety improvements and code quality enhancements
- Documentation updates for improved maintainability

All changes follow DRY, SSOT, and separation of concerns principles.
2026-01-04 12:25:26 +01:00
Your Name 94bfe613b6 chore: deploy local snapshot
Commit current local state for production deploy.
2025-12-10 16:56:40 +01:00
Your Name 5cd7495b78 feat: Complete entity relationship system - 11 APIs connecting profiles, organizations, campaigns, projects
- Added intelligent onboarding with AI analysis and personalized recommendations
- Implemented organization creation with founder membership and role-based access
- Built 11 production APIs for full entity relationships:
  * Profile endpoints: campaigns, projects, organizations
  * Organization endpoints: campaigns, projects, member management
  * Project endpoints: campaigns, add/remove campaigns
  * Campaign endpoints: stats and enhanced detail
- Enhanced UX with guest-first campaign creation flow
- Fixed sidebar naming consistency (Campaigns vs Fundraising)
- Improved onboarding with interactive category cards and clean animations
- Added comprehensive documentation and integration guides
- Implemented proper JSX structure and TypeScript fixes
2025-10-18 09:44:02 +02:00
Your NameandClaude 2872828779 chore: version 0.1.1 deployment - fix configuration and dependencies
- Bump version to 0.1.1 for tracking
- Add webpack-bundle-optimizer script for Next.js config
- Simplify ESLint configuration to resolve missing dependencies
- Prepare for production deployment with proper version control

This deployment includes:
- Profile update fixes with banner_url support
- LN address validation
- Auth cookie fixes for profile updates
- Various documentation and testing improvements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-13 09:30:45 +02:00
cato 5a3baa8161 ci: automate preview Lighthouse audit and post PR comment\n\nAdds Lighthouse audit to deploy.yml with post-comment using sticky-pull-request-comment. Updates docs with preview-automation overview. 2025-06-11 01:26:34 +02:00
cato eb6449ab1b update all documentation and configuration to use correct production URL orangecat.ch 2025-06-10 10:57:17 +02:00
cato 17dbaa08e3 Update deployment documentation 2025-06-08 20:46:42 +02:00
cato 7bd344de18 � PRODUCTION READY: Complete deployment preparation - Security hardening (vulnerabilities 13→1), build fixes (TypeScript/auth), performance optimizations (SWC/caching), 83.3% test success rate, modular architecture - Ready for GitHub→Vercel deployment 2025-06-08 20:33:33 +02:00