Commit Graph
152 Commits
Author SHA1 Message Date
CatoandClaude 2d3609c13e feat(auth): stage AccountKit beside Auth.js, switch off (#156)
Petvity moves from Auth.js to @bitbaum/accountkit one reversible step at a
time, as evig and kivvi do. Nothing changes while AUTH_RUNTIME is unset.

- Migration 0008: AccountKit's tables under an `auth_` prefix, plus the
  users <-> auth_users mirror functions, inert until attached.
- scripts/db/accountkit-import.sql: accounts under their own ids, bcrypt
  hashes byte for byte, verification kept, orangecat_sub as an `orangecat`
  account row; refuses collisions, drift or a live shared runtime, then
  attaches the triggers. The rehearsal CLI always rolls back.
- lib/auth/shared/: the runtime (ids: 'uuid', legacy bcrypt, AccountKit
  0.16.0), a session reader re-read from `users` on every request, a bridge
  that answers next-auth/react including "Sign in with OrangeCat", and a
  Petvity row for a person AccountKit creates itself. AccountKit's own
  credential endpoints stay closed; Petvity's writers stay the only ones.
- lib/auth/claims.ts: the ADMIN_EMAILS promotion rule, written once.
- The proxy has one routing function and two session sources.
- browser-smoke.yml runs the account journey once per runtime; the
  AccountKit leg first runs the rehearsal and the real-database journeys.

docs/ACCOUNTKIT-MIGRATION.md records what is left before switching.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-01 08:31:55 +01:00
CatoandClaude f0d9e01cb3 ci(browser-smoke): account journey in Chromium, and sign-out that sticks (#144)
* fix(auth): the proxy no longer re-issues the session cookie

Auth.js's auth() proxy wrapper appends a fresh session cookie to every
response it handles, Link prefetches included. A prefetch that left the
browser before Sign out came back after it and set the old, still-valid
JWT again, so the person stayed signed in. The new browser journey hit
this in about one sign-out in three.

The proxy now drops only the session-token Set-Cookie it would add; the
session still rolls through /api/auth/*, which SessionProvider calls on
every page load.

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

* ci(browser-smoke): register, sign out, sign in and no stray Google button

browser-smoke.yml runs scripts/ci/account-journey.mjs in Chromium against
the production build and a throwaway Postgres 17: register through
/register, see the portal, sign out from the sidebar, a wrong password
refused, the right one accepted, no sideways scroll on /login and
/register at 390px. With no GOOGLE_* pair it checks that no Google
provider is mounted and no Google button is drawn, the guard for the
invalid_client sign-in of 2026-10-30.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-30 11:13:15 +01:00
CatoandClaude 2eaccb0498 fix(auth): mount Google only when its client pair is set (#142)
Google was always mounted, so with no GOOGLE_CLIENT_ID on the box a request
to it reached Google as client_id=undefined and failed with invalid_client.
No button shows it, but a provider that cannot sign anyone in should not be
mounted at all. It now mounts only with both keys, like OrangeCat beside it.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-30 08:46:25 +01:00
CatoandClaude 4a40a03d44 feat(charts): health trends and twin meters on @bitbaum/chartkit 0.7 (#141)
ChartKit 0.7.0 closes both gaps recorded in package-plan.json (#140):
LineChart now labels days on a 30-day span, and Meter takes a tone and
showValue={false}.

- HealthTrendChart renders ChartKit's LineChart on the server: one line
  per metric, the species' normal range as a reference band, the portal
  locale for dates and numbers. A day without a reading is left out of
  that line. The trend charts sit one per row: in the portal's 4xl
  column, three across left each plot about 190px and the day ticks ran
  into each other.
- The twin score and per-metric bars (DigitalTwinCard, public pet page,
  portal dashboard) are ChartKit Meters coloured by the twin state's
  tone, with the figure printed once by the page.
- The twin score block wraps under the state name on a narrow card; at
  390px in German it was clipped ("41 / 1") before this change.
- recharts is removed, with the chart colour config and the tooltip
  shadow that only it used. Both exceptions leave package-plan.json; the
  bindings are recorded instead.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-29 20:02:23 +01:00
CatoandClaude Opus 5.5 5ea4dab4fa fix(copy): every public claim matches the code — contact, legal, pricing, pros, 9 locales (#106)
* fix(copy): contact mail goes to a mailbox that exists

hello@ and support@petvity.com sat on the footer, every legal page, the
structured data and every email template. petvity.com is not ours (it is a
Netlify site with Zoho MX; lib/config/email.ts already lists it as "not
ours"), so privacy and support mail went to a stranger. APP.email is now
cato@orangecat.ch, the one address on the receiving apex, and supportEmail
is folded into it. lib/config/app.test.ts fails if it leaves the apex.

The pet-edit form also showed "petvity.com/pets/" as the share prefix; it
now derives the host from APP_URL.

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

* fix(copy): privacy and cookie policies describe the running system

Privacy: Neon was decommissioned in 2026-06 (the database is PostgreSQL on
the same Hetzner box, listening on 127.0.0.1 only), Google sign-in is not
configured in production while OrangeCat sign-in is, groomers and guest
checkout were missing, and "database connections use TLS" did not hold for
a localhost connection.

Cookies: Auth.js v5 sets authjs.* cookies, not next-auth.*, plus PKCE/state
cookies during OrangeCat sign-in; NEXT_LOCALE is a session cookie set on any
locale page, not a one-year cookie set only by the switcher.

Effective dates moved to October 2, 2026.

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

* fix(copy): marketing pages say only what the product does, in all 9 languages

- pricing: Pro and Clinic cards cut. Their buttons were href="#", neither
  plan is on ROADMAP.md, yet the FAQ called them "next".
- pros: cut vets reading clients' health history and sitters logging health
  during stays (records are owner-scoped; "Vet-facing records" is 0% on the
  roadmap), the unmeasured "growing community" card, and a sitter card that
  repeated its heading. Reviews tie to completed bookings, not confirmed ones.
- features: no refill tracking exists; charts span 30 days, not months; the
  twin is not built from 30 days on the dashboard (7); unverified pros are
  listed; cross-border adoption and "any language" were not true; handle host
  is the live one; groomers added.
- about: the "Behind the project" section was empty in 4 locales and claimed
  "a team of software engineers" in 5; cut.
- ar/ja/ko/tr/zh: the features, pricing, pros and about pages carried an
  older, differently ordered copy (stats swapped, "data export coming soon",
  "VitaReba"); retranslated from the current English.
- CHANGELOG: removed "health metrics that matter per species" (the
  observations config is not wired into any screen) and the Stripe claim;
  added 2026-10-02. ROADMAP: OrangeCat sign-in shipped, Google item dropped.

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

* fix(copy): close the gaps the verifier found, in all 9 languages

- Cookie policy names both ways NEXT_LOCALE is set: a session cookie per
  page, one year when picked with the language switcher.
- Privacy policy lists the Loki feedback widget as a service provider.
- /pros no longer says owners share pet records or Digital Twin data with
  vets and sitters (a booking shows them only the pet's name): rewrote
  metaDesc, heroDesc, vet/sitter hero copy; cut vb1 ("months of structured
  health history"); dropped 72 unrendered pros keys that still shipped the
  same claims in every page's message payload.
- Cut unmeasured timings: home heroSub ("30-second check-in"),
  benefitTrackDesc ("in 30 seconds"), "set up in minutes", "a few minutes".
- Species guide CTA: a record to show your vet, not one shared with them.
- ROADMAP/CHANGELOG: email+password sign-up still works for new users;
  changelog line lists what was cut instead of claiming all copy is true.

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

* fix(copy): privacy names what an OrangeCat sign-in stores; drop a dead features key

- Privacy, "Data we collect": an OrangeCat sign-in also stores the name and
  profile picture from the OrangeCat account (accountkit's orangecatProfile
  maps name and picture onto users.name and users.image), not only the id.
- features.heroSubtitle is rendered nowhere but still shipped in every page's
  message payload, carrying "cross-border adoption" and "in any language" —
  both cut elsewhere in this PR. Removed from all nine locales.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 17:45:53 +01:00
Cato b9c4899ee7 feat(auth): one password rule from accountkit (non-empty, up to 128); no local minimum or hint text (#123) 2026-10-28 03:53:21 +01:00
Cato 6a3044927b feat(auth): password recovery uses the shared accountkit form (#122)
Forgot/reset pages render PasswordRecoveryForm from @bitbaum/accountkit 0.8.1
through a small adapter over Petvity's own routes, so users, bcrypt passwords,
roles and Auth.js sessions are untouched. The hand-written pages could stay
stuck after a network error; the shared form leaves its busy state and says so.
The reset route now answers an invalid link with code INVALID_TOKEN.
2026-10-28 01:29:57 +01:00
CatoandClaude f1e98e2ae6 fix(layout): one <html>, so the fonts and the language survive navigation (#114)
The owner walked the site with Loki on 2026-10-18 and said the design was
inconsistent between the home page and the portal. It was, and not by
design: app/[locale]/layout.tsx rendered a second <html> inside the root
one. React keeps one document element and, when that nested <html>
unmounted on a client navigation from the marketing site into /login or
/portal, cleared what it had set on it — lang, dir and the font classes.
Measured on the live site, /de → /login without a reload: lang null,
class "", body font Roboto instead of Plus Jakarta Sans, headings out of
Jost. Loki's checks also kept reporting "the page does not declare its
language", which was true after every such navigation. German pages
were also served as lang="en" (the browser kept the first <html>'s).

- The root layout renders the only <html>, with the request's locale and
  direction (next-intl getLocale: the URL's on the localized site, the
  default elsewhere).
- Each route group keeps document lang/dir right across client
  navigations with a small client component (DocumentLanguage):
  [locale] with the URL's locale, the portal with the user's, auth and
  admin in English.
- lib/i18n/one-html.test.ts: only the root layout renders <html>, and
  every route group says its language.

Checked on a production build: /de, /login and /ar serve one <html> each
with lang de / en / ar and dir rtl for Arabic; /de → /login → /de/features
by client navigation keeps the font classes and the right lang at every
step.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-18 08:17:21 +02:00
CatoandClaude Opus 5.5 3209d7d74b refactor(auth): OrangeCat sign-in through @bitbaum/accountkit; no reset link for an OrangeCat-created account (#108)
lib/auth/orangecat.ts (provider, profile without email, placeholder email,
the sub-keyed adapter wrapper) moves to @bitbaum/accountkit/orangecat v0.2.1,
which took it as one of its sources; its tests went with it. The
ADMIN_EMAILS guard is accountkit's emailEarnsPromotion.

Fixes a gap: forgot-password emailed a reset link to an account OrangeCat
had created. That address came from OrangeCat unverified, so the link would
have given whoever owns it a password on the OrangeCat person's account.
It now gets the same generic answer (mayReceivePasswordReset); a person
with a password of their own can still reset it. Two route tests.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 05:19:24 -07:00
CatoandClaude Opus 5.5 2b7a71cb4f feat(auth): sign in with OrangeCat (#104)
"Sign in with OrangeCat" (OIDC) is now the primary action on /login and
/register; email + password stays behind a disclosure so existing accounts
are not locked out. OrangeCat's own page carries Google, GitHub, email and
open registration.

- Provider: client_secret_post + PKCE + state, scope "openid profile email",
  issuer https://orangecat.ch (ORANGECAT_OAUTH_ISSUER overrides). Absent,
  not broken, until ORANGECAT_OAUTH_CLIENT_ID/SECRET are set.
- Users are keyed ONLY on the new users.orangecat_sub (additive migration
  0007). The provider profile carries no email, so Auth.js never looks a
  user up by email; a new sub always creates a new user. A taken email gets
  an undeliverable @users.invalid placeholder.
- An OrangeCat login never earns ADMIN_EMAILS promotion (email unverified).
- Identity only: no OrangeCat token refresh, tokens not stored.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 05:01:17 -07:00
CatoandClaude cf6912e957 feat(records): public roadmap and changelog, from the repo through the fleet map (#103)
The fleet's building-in-public contract puts each product's record in its
own repository as two markdown files and renders it through Loki's fleet map
via bip-kit. Petvity had neither the files nor the pages.

- ROADMAP.md: Now / Next / Later / Shipped, derived from the phases in
  AGENTS.md and the merged history. Planned work is written as plans.
- CHANGELOG.md: Keep-a-Changelog dialect, user-facing, newest first, from
  merged PRs; today's homepage rewrite is the top entry.
- /[locale]/roadmap and /[locale]/changelog render bip-kit's DevelopmentPage
  inside the marketing nav/footer; the records are English by contract, the
  chrome and metadata stay localized (keys in all 9 locales, footer links).
- lib/config/development.ts is the SSOT for the map URL, slug and profile;
  lib/development/records.ts fetches with revalidate 300 and an 8s ceiling.
- The --bp-* theme scope already mapped for the blog (.pv-longform) covers
  the records; the page title and record name take the editorial faces.
- Vitest covers the data path with a fleet-map fixture, no network.
- Sitemap lists both pages.

Verified at 390px in de/en/ar: no horizontal overflow.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-28 04:09:11 -07:00
CatoandClaude Fable 5.1 18776a4251 refactor: one definition per concern — shared forms, one directory handler, limitkit, zero lint noise (#95)
* fix(lint): anchor the ignore patterns so eslint stops linting build output

`eslint` reported 18 unparseable files and 2 `no-explicit-any` errors that
exist in no source file. They came from `.claude/worktrees/*/.next/**` —
generated, minified code inside the repo. The default ignores of
eslint-config-next are unanchored (`.next/**`), which only matches at the
config root, so nested build output was walked.

Every pattern is now `**/`-prefixed, and `.claude/**` is ignored outright:
a worktree's files are linted on its own branch, never as a copy of this one.

Before: 2 errors, 36 warnings. After: 0 errors, 16 warnings — and the same
result whether you run it from the checkout or from a worktree.

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

* refactor(pets): one set of pet fields for both add and edit

"Add a pet" and "edit a pet" rendered the same ~120 lines twice — name,
species, breed, birth date, sex, bio, public toggle — so a new field or a
fixed label had to be applied in two places, and the two only stayed
identical by luck.

The fields now live in `components/portal/PetFormFields.tsx`. Each takes the
whole form plus a patch callback rather than a value and a setter, because
the pages hold one `useState` object (the edit page's also carries `handle`)
and a patch is what they can actually apply. The pages keep what genuinely
differs: one creates and can send you on to the first health log, the other
uploads an avatar, owns a handle and a delete zone.

Two primitives came out with it: `ToggleSwitch` (the peer-checkbox switch is
easy to get subtly wrong in a copy — the knob detaches from the track and
nobody sees it until they toggle) and `UploadedImage` (the plain `<img>` for
user-uploaded files, with the reason `next/image` is wrong for them written
down once instead of thirteen bare `eslint-disable` lines).

Render output is unchanged.

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

* refactor(api): one handler behind /api/vets, /api/sitters and /api/groomers

The three directory routes differed in a role string, a table and a list of
columns — and agreed, character for character, on everything that decides
what a caller sees: the session guard, the completeness rule, the city
filter, the 50-row page, the review aggregate and the response envelope.
Three copies of a paging rule is three chances for one directory to quietly
start answering a different question from its siblings.

`createProfessionalDirectoryRoute` in `lib/api/professional-directory.ts`
now owns that shared half. Each route file declares only what it publishes:
its role, its table, the extra columns a profile must have filled to be
listed at all, and its SELECT list — because that list IS the contract the
directory offers (a sitter has a day rate, a vet has a clinic).

Responses are byte-identical: 106 + 103 + 106 lines became three ~35-line
declarations over one handler.

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

* refactor(products): the add/edit-a-product state machine, once

`/admin/products` and `/portal/my-products` look nothing alike — a table with
an inline panel versus a grid with a modal, and only one of them is
translated — but underneath they ran the same 55 lines: the same form shape,
the same "blank stock means unlimited", the same dollars-to-cents rounding,
the same POST-or-PATCH decision, the same optimistic list update.

The arithmetic is the part worth having in one place. `parseFloat * 100` is
where a product silently goes on sale for the wrong money, and it was
written twice.

`useProductEditor` takes the create URL (the admin page appends
`?platform=true` — the one behavioural difference), the two messages it may
need to show, and a callback for the saved row. The pages keep their markup,
their copy, and ownership of their list.

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

* refactor(portal): one labelled input and one contact block for the profile forms

`ProfessionalProfileForm` carried the same four-field grid twice — once for a
vet's practice, once for a sitter's or groomer's services — which jscpd
reported as a 40-line clone of the file against itself. Two copies inside ONE
file is the worst kind: a reviewer reads the first, recognises it, and skims
the second, which is exactly where "city" kept its label and lost its
placeholder.

`ProfileTextField` is that labelled input; `ContactFields` is the
city/country/phone trio as a fragment, so the caller still owns the grid the
cells sit in. `country` is passed through as typed — the route takes the
first two characters and upper-cases them on submit, and normalising here
would be a second opinion about the same value. `SellerProfileForm` uses
both, and its on/off row is now the shared `ToggleSwitch`.

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

* fix(security): key the guest rate limits on the hop Caddy wrote, via limitkit

The hand-rolled limiter in `lib/utils/rate-limit.ts` keyed on the FIRST entry
of `X-Forwarded-For`, with a comment asserting that was the original client
and a test pinning it. Both were wrong in the same direction: a reverse proxy
APPENDS to that header, so the first entry is a string the caller typed. Any
client could send a different `X-Forwarded-For` with each request, mint a
fresh bucket every time and never trip the limit at all — the guest checkout,
which reserves stock without a session, was effectively unlimited. A limiter
that cannot be tripped is not a limiter.

The same bug was found in three sibling repos during this migration, and in
limitkit itself before v0.2.0 (bitbaum/orangecat#563, finding 2). It is
exactly the kind of thing one shared implementation exists to fix once.

So the mechanism is now `limitkit` (fleet/SHARED.md; it replaces 12 copies of
this across 9 repos) and the local copy is deleted: window arithmetic, the
bounded store, the refusal shape and the client-IP dance all come from the
package. What stays local is what is genuinely ours — the limit VALUES, still
declared at each route next to the reason for them, and the proxy depth,
stated once in `rate-limit.ts` because it is a fact about our deployment
(Caddy on the box is the single proxy, so `trustedProxies: 1`).

Behaviour otherwise unchanged: same 429s, same copy, same `Retry-After`, same
per-key allowances. `slidingWindow` (not `fixedWindow`) because the local
implementation started its window at the first hit, which is what sliding
means — the old test expecting 45s of wait after 15s still describes it.

The window-arithmetic tests moved with the code they tested; what this repo
keeps is a test of the part that was broken, including one that a caller
cannot split its bucket by varying the hops it sends.

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

* fix(portal): give the page loaders a stable identity instead of muting the rule

Eight portal pages declared a `loadX()` that fetches the page's list, then ran
it from a `useEffect` with an empty dependency array and an
`eslint-disable-next-line react-hooks/exhaustive-deps` above the `useEffect(`
line. The directive did nothing: the rule reports on the dependency array two
lines down, so every one of these files produced BOTH an "unused
eslint-disable" warning and the exhaustive-deps warning it was meant to
silence. Sixteen warnings from eight disables that never applied.

The cause is that `loadX` was redefined on every render, so listing it as a
dependency would have refetched forever. `useCallback` fixes that at the
source: each loader is now stable over the translation function (plus the
route param where there is one), the effect depends on the loader like the
rule asks, and the disables are gone. The retry buttons already called these
same loaders and keep working.

Lint: 16 warnings → 0. `pnpm run lint` now passes with nothing to say, so the
next real warning will be visible instead of arriving in a crowd.

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

* refactor(ui): one uploaded-image component, and a no-console rule so it stays that way

Thirteen components carried their own `<img>` for user-uploaded files, each
with its own `// eslint-disable-next-line @next/next/no-img-element` above it
and none with the reason written down. Thirteen places for that reasoning to
rot and thirteen exemptions a reviewer has to re-audit independently.

They now all render `<UploadedImage>`, which holds the exemption once and
explains it: these URLs are written by the upload routes at request time
(`/uploads/…` on the box, or an `object:` URL while a preview is in flight),
so `next/image` would need the path known at build time or matched by a
configured pattern — and a missing pattern fails the whole render, not just
the picture. The optimizer has nothing to add either; the upload route already
resized the file.

The last `any` went with them: `TSignal` in `lib/i18n/signal-reason.ts` now
says `Record<string, string | number>`, which is what a reason actually
interpolates — counts, days, formatted measurements, nested translations. The
loose shape is still structural rather than next-intl's own type, because the
key is composed at runtime (`metric_${id}`) and the real literal-keyed type
rejects that by design; that reason is now in the file.

eslint-disable directives: 25 → 1 (the one inside `UploadedImage`).

And `no-console` is on, allowing `warn` and `error`. There were no stray
`console.log`s to remove — `error` is how these routes report a failure they
swallowed, and it is what `journalctl -u petvity-app` shows at 2am — so this
is the ratchet rather than a cleanup: a forgotten debug line on a server
writes a stranger's data into the journal forever. `scripts/**` is exempt,
where stdout IS the output. Verified by mutation: a planted `console.log`
fails the lint.

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

* style: wrap the two UploadedImage calls prettier wanted on four lines

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

* fix(deps): install limitkit from npm, not from git

CI refused the git-hosted form: a package fetched from a tarball has no
`dist/`, so pnpm must run its `prepare` build, and pnpm 11 will not run a
git dependency's build scripts unless the exact resolved URL is listed in
`allowBuilds`. The local install had it cached from before that rule, which is
why this was green on the laptop and red the moment CI installed from scratch.

limitkit has been published to npm since, so the fix is the npm form rather
than an allowlist entry pinned to a commit sha that has to be re-edited every
time the version moves. fleet/SHARED.md still shows the github install line;
the published tarball ships `dist/` and needs no build here.

Same version, same resolution: 0.2.0.

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

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-15 02:09:23 -07:00
CatoandClaude Fable 5 daa029e81f refactor(blog): replace the homegrown three-block parser with bip-kit (#79)
The DB blog rendered through lib/domain/blog-markup.ts — a deliberately tiny
p|h2|ul parser whose no-raw-HTML security rationale is exactly bip-kit's
typed-block model, making this a pure upgrade: parse + ArticleBody from
bip-kit v0.2.1 now render the public post page and the admin editor's live
preview (parse + readingTime), and authors instantly gain the full long-form
vocabulary (h3/h4, ol, quotes, callouts, images, tables, code, math,
footnotes, charts, embeds).

- app/longform.css maps the editorial-luxury tokens onto the --bp-* theming
  contract, class-scoped (.pv-longform dark public reader, .pv-preview light
  admin) so nothing leaks into the rest of the app
- parseLongform() degrades malformed chart/stats fences to code blocks —
  bodies are DB-authored, so a half-typed fence must never 500 a page or
  crash the editor (bip-kit's throw-on-parse targets committed content)
- JSON-LD, i18n alternates and reading time preserved; blog-markup.ts and
  its test deleted, the legacy-subset assertions ported to longform.test.ts
- word-level parity verified old-vs-new across all published post bodies


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

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-07 12:14:50 +00:00
5236175232 refactor(email): migrate transport to @bitbaum/mail-kit (#78)
Replace the bespoke Resend-SDK transport in lib/email/index.ts with the
fleet's shared @bitbaum/mail-kit. Contract preserved: {sent:false} when
mail is unconfigured or the recipient is an undeliverable fixture, throw
on provider API errors so the cron can mark queue rows failed. The
unconfigured gate is now mail-kit's isMailConfigured, which also rejects
placeholder keys and sandbox senders in production. Module-load FROM
replaced by call-time RESEND_FROM with the fleet-conventional fallback.
Transport tests now mock global fetch. Removes the resend dependency.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-05 10:45:21 +00:00
4133ee1dcd refactor(nav): portal paths were written down 38 times; now once (#72)
`/portal/dashboard` and `/portal/find` were each hand-typed six times in
SidebarNav.tsx alone — 38 occurrences of thirteen paths across the portal
components, plus `/portal/pets/${petId}/health/log` templated in two files.
Renaming a route meant finding every copy, and a missed one did not fail to
compile: it became a dead link only a visitor would discover.

lib/config/routes.ts is now the one place. Static paths as a const object,
and functions for the two that need an id — a template literal in a component
is a copy like any other.

The guard is the point. routes.test.ts scans components/portal for a quoted
/portal/ literal and fails on one, so this cannot quietly come back. It is
stricter than the first pass of the fix was: it caught QuickActions.tsx and
both dynamic paths that a file-by-file sweep had missed, which is exactly the
job. Recorded in CLAUDE.md's SSOT table and Red Flags list so the rule is
findable without reading this commit.

No behaviour change: every path resolves to the same string it did before.
Typecheck clean, lint clean, 904 tests pass.

Found by a fleet-wide navigation audit across 20 repos, where petvity had the
highest concentration of hand-typed destinations in a single file.


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

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 07:56:52 +00:00
GandClaude Opus 5 c65ac4b7d7 chore: add a formatter (#71)
* chore: add a formatter, matching the style this repo already writes

singleQuote=false was chosen by counting this repo's own
imports, not by fleet decree. The fleet is genuinely split and the two repos
that already had a .prettierrc disagreed with each other, so there was no
standard to restore. Quote style does not cross repo boundaries; having a
gate does.

Markdown is ignored for now — prettier rewraps prose, which would bury the
real diff.

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

* style: format with prettier (252 files)

Mechanical. No behaviour change. This SHA is listed in
.git-blame-ignore-revs so `git blame` skips it.

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

* chore: teach git blame to skip the reformat

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

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-29 10:05:01 +00:00
GandClaude Opus 5 3d6ac9bed3 fix: prices were 100x wrong for zero-decimal currencies (#58)
Two real defects in the repo I can actually reach, found by auditing my own
work rather than someone else's.

formatPrice divided by 100 unconditionally. That assumes every currency has two
decimals, and several have none: with NEXT_PUBLIC_APP_CURRENCY=JPY a 2999-unit
product rendered as ¥30 instead of ¥2,999 — a hundredfold error, silently, on
every price in the shop. KRW, VND and ISK behave the same way, and KWD errs in
the other direction with three decimals. APP_CURRENCY is an environment
variable, so this was one deployment away from being real.

It now delegates to commercekit's money module, which takes the exponent from
the currency. That also removes a second money formatter from a repo that had
just adopted the first — exactly the duplication this whole exercise is about,
introduced by me.

TEMPLATE_MAP typed its payload as `any`, so the cron dispatching welcome emails
could hand a template the wrong shape and the compiler would agree — on mail
that goes to real users, built from a jsonb column nothing else validates. All
four templates take the same WelcomePayload, so the `any` bought nothing.

Typing it immediately produced an error, which turned out to be a typing gap
rather than a live bug: the cron spread `item.payload as object`, erasing the
shape, while enqueueWelcomeSequence does write { name, email }. So the emails
were correct and the types were lying about why. The cast now narrows to
WelcomePayload and the compiler can see it.

Verification: lint, tsc, css-vars, 901 tests / 87 files (8 new, including the
JPY case that would have caught the price bug).

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 16:07:54 +00:00
GandClaude Opus 5 b59101b0e2 fix(security): a missing CRON_SECRET must deny, not accept "Bearer undefined" (#57)
Found while inventorying what repeats across the fleet. Cron auth appears in 43
files across 9 repos, and the copies have diverged into two behaviours:

  petvity      if (auth !== `Bearer ${process.env.CRON_SECRET}`)          OPEN
  evig         if (authHeader !== `Bearer ${cronSecret}`)                 OPEN
  kivvi        if (!cronSecret) { ... }                                   guarded
  aoz-housing  if (!cronSecret || authHeader !== `Bearer ${cronSecret}`)  guarded

With CRON_SECRET unset, the template literal evaluates to the string
"Bearer undefined", so a request carrying exactly that header is authorised.
All 8 cron routes here had the open version.

Behind that gate: /api/cron/reset-demo wipes and reseeds the demo account, and
weekly-digest, health-alerts, vaccination-reminders, medication-reminders and
booking-reminders each email every opted-in owner. So the blast radius of a
missing environment variable was a stranger mass-mailing the userbase and
destroying demo data.

Not exploitable today — CRON_SECRET is set in production. It is a gate that
fails open on an absent secret, which is a normal thing to happen on a new
environment or a typo, and the failure is silent.

requireCronAuth() denies everything when the secret is absent or blank, logs why
so a broken deployment is loud rather than quiet, requires the Bearer scheme,
and compares with timingSafeEqual. The timing part is close to unexploitable
over TLS and is not the point; a helper that is obviously correct removes the
need for anyone to reason about whether it matters.

Two test files, and the second is the one that matters. cron.test.ts pins the
helper's behaviour, including that "Bearer undefined" is refused when
unconfigured. cron-routes.test.ts asserts against the directory that every cron
route calls requireCronAuth and no route mentions process.env.CRON_SECRET —
because fixing eight routes fixes eight routes, while checking the directory
fixes the ninth one nobody has written yet.

Also adds docs/repeatable-across-projects.md: the full measured inventory of
what repeats across 25 repos, and a first-principles rule for what to do with
each. The short version is that copy count is the wrong question — it measures
typing, which is free. The right question is what divergence costs, which sorts
duplication into four classes with four different correct answers, of which
"leave it alone" is one.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 15:03:03 +00:00
GandClaude Opus 5 02d847a016 feat(commerce): extract commercekit, and adopt it here (#53)
* feat(health): track what actually matters, per species

The seven metrics in health-metrics.ts are applied uniformly to all ten
species. That is tidy and, for several of them, wrong in ways that matter.

Body temperature is not a property a fish or a reptile has in the sense the
field implies. They are ectotherms: a fish's body temperature IS the water
temperature, and a reptile's depends on where it is sitting in a thermal
gradient. Heart rate is not measurable at home for a bird, a fish or a hamster.
Asking for either produces an empty field, and empty fields teach owners to
skip — a habit that generalises to the field that mattered.

Worse, none of the seven capture what actually kills these animals. A rabbit
that has not eaten and produced no droppings for twelve hours is a medical
emergency; gut stasis is the leading cause of death in pet rabbits. A male cat
straining without producing urine is fatal in 24-48 hours. A horse whose manure
output drops is the earliest practical warning of colic. A UVB bulb keeps
emitting visible light long after its UVB output has decayed, so the enclosure
looks fine while the animal develops metabolic bone disease.

lib/config/observations.ts is the SSOT for what is worth observing and for
which species. Each observation declares its species, cadence, whether an owner
can actually produce the answer, why it earns a tap, and what answer means
"call a vet" — with the reason, because an alert nobody believes is an alert
everybody dismisses. Records (microchip, parasite schedule, diet, farrier,
water changes) are modelled separately, since they are durable facts rather
than things that changed today.

The daily set is capped at five and the cap is a test that FAILS rather than a
slice that truncates. Printing the sets caught three real design faults that
the first round of tests passed: fish had an empty daily check-in because water
temperature is device-sourced and I was filtering device readings out; dogs and
cats had seven candidates silently cut to five by array order; and reptiles were
being asked about mood while the enclosure gradient that actually kills them was
excluded. Priority is now explicit and cadence can be overridden per species —
a snake fed weekly should not be asked daily whether it ate.

Clinical values are typical published ranges compiled for product design, NOT
clinically reviewed. REVIEW_STATUS records that, so it cannot quietly be
presented to an owner as authority.

Also adds docs/pet-health-science.md (the reasoning, species by species),
docs/digital-twin-and-legacy.md (twin staging, memorialisation, gamification
and revenue, including an explicit list of what not to build), and a first blog
draft. Nothing is published — that is a deliberate decision, not a side effect.

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

* feat(commerce): extract commercekit, and adopt it here

Three shops in the fleet: evig, petvity and fitfoot. Before proposing anything
shared I checked what is actually duplicated rather than assuming — revampit
turned out to be a second clone of evig, so it is three codebases, not four,
which is exactly the rule of three.

They have three incompatible foundations, so a single shared "webshop" adopted
by all of them would be a rewrite of two. What IS shared is narrower and is the
part every shop rewrites and gets subtly wrong. That is what this extracts.

packages/commercekit — zero runtime dependencies, framework-free core, React
bindings behind a separate entry point.

  money      Integer minor units. `12.55 * 100` is 1254.9999999999998, so
             fromDecimal works on digits. The currency carries its own exponent,
             so JPY has no decimals and KWD has three without a special case.
             allocate() is largest-remainder: splitting 100 three ways gives
             [34,33,33] and never loses or invents a unit — asserted across 200
             amounts x 5 weight patterns. percent() takes an explicit rounding
             mode, because a marketplace computing its own commission should
             round down rather than over-charge a seller.

  cart       A line is an id and a quantity. Never a price — a cart open for a
             week would otherwise show one number and charge another. Cross-tab
             sync, clamping, and corrupt storage yielding an empty cart rather
             than a crashed shop. Stable snapshot reference, which is what
             useSyncExternalStore needs to avoid an infinite render loop.

  inventory  Conditional decrement, all-or-nothing, with compensation on partial
             failure and sorted lock order so opposite carts cannot deadlock.
             Duplicate lines are merged, or the availability check for the
             second is made against stock the first already took. The test
             suite demonstrates the bug it prevents: a read-then-write adapter
             tells 50 buyers "yes" against 10 units while recorded stock falls
             by one.

  buyer      Account XOR guest as a discriminated union rather than two nullable
             columns, so an order belonging to nobody cannot be represented. A
             type is a claim, so the matching Postgres CHECK ships beside it.
             Receipt tokens use the platform CSPRNG and refuse to run without
             one.

  address    ISO-3166 codes with names from Intl.DisplayNames — every locale the
             runtime supports, no translation files, no way for the German list
             to drift from the English one.

Petvity adopts all of it, which is the proof: lib/shop/cart.ts and
lib/config/countries.ts become thin bindings, and placeOrder's hand-rolled
reservation is replaced by reserveAll over a Drizzle adapter that is the only
Petvity-specific part. Cancellation goes through releaseAll, so there is now one
implementation of giving stock back instead of two.

One behaviour change worth naming: the old code skipped the UPDATE entirely for
unlimited-stock products, so the shared db mock's default empty return was never
exercised on that path. The new adapter always issues the conditional update
(`stock IS NULL OR stock >= n`, and NULL - n stays NULL), which is correct
against a real database but made the mock read as "sold out". The mock was
modelling an UPDATE that matches nothing; two tests now say what a matching
UPDATE returns.

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

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 13:24:41 +00:00
GandClaude Opus 5 1e82028f27 feat(health): track what actually matters, per species (#52)
The seven metrics in health-metrics.ts are applied uniformly to all ten
species. That is tidy and, for several of them, wrong in ways that matter.

Body temperature is not a property a fish or a reptile has in the sense the
field implies. They are ectotherms: a fish's body temperature IS the water
temperature, and a reptile's depends on where it is sitting in a thermal
gradient. Heart rate is not measurable at home for a bird, a fish or a hamster.
Asking for either produces an empty field, and empty fields teach owners to
skip — a habit that generalises to the field that mattered.

Worse, none of the seven capture what actually kills these animals. A rabbit
that has not eaten and produced no droppings for twelve hours is a medical
emergency; gut stasis is the leading cause of death in pet rabbits. A male cat
straining without producing urine is fatal in 24-48 hours. A horse whose manure
output drops is the earliest practical warning of colic. A UVB bulb keeps
emitting visible light long after its UVB output has decayed, so the enclosure
looks fine while the animal develops metabolic bone disease.

lib/config/observations.ts is the SSOT for what is worth observing and for
which species. Each observation declares its species, cadence, whether an owner
can actually produce the answer, why it earns a tap, and what answer means
"call a vet" — with the reason, because an alert nobody believes is an alert
everybody dismisses. Records (microchip, parasite schedule, diet, farrier,
water changes) are modelled separately, since they are durable facts rather
than things that changed today.

The daily set is capped at five and the cap is a test that FAILS rather than a
slice that truncates. Printing the sets caught three real design faults that
the first round of tests passed: fish had an empty daily check-in because water
temperature is device-sourced and I was filtering device readings out; dogs and
cats had seven candidates silently cut to five by array order; and reptiles were
being asked about mood while the enclosure gradient that actually kills them was
excluded. Priority is now explicit and cadence can be overridden per species —
a snake fed weekly should not be asked daily whether it ate.

Clinical values are typical published ranges compiled for product design, NOT
clinically reviewed. REVIEW_STATUS records that, so it cannot quietly be
presented to an owner as authority.

Also adds docs/pet-health-science.md (the reasoning, species by species),
docs/digital-twin-and-legacy.md (twin staging, memorialisation, gamification
and revenue, including an explicit list of what not to build), and a first blog
draft. Nothing is published — that is a deliberate decision, not a side effect.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 11:29:14 +00:00
GandClaude Opus 5 37b1f59ed7 feat(shop): sell to visitors who don't have an account (#50)
The public storefront was a brochure. It shipped a Product/Offer JSON-LD so
search engines treat it as purchasable, then the only buy path was
"Sign up to buy" -> /register?returnTo=/portal/shop, which both forced
registration before a first purchase and dropped the product the visitor came
for. Cold traffic could not buy anything.

A visitor can now add to cart on the catalogue and the product page, check out
in one page with an email and an address, and read their order back from a
receipt link. No account anywhere in that path.

orders.userId becomes nullable, alongside guestEmail and an unguessable
publicToken. A CHECK constraint enforces exactly one of userId / guestEmail,
because an order with no reachable buyer cannot be repaired after the fact.
The token is the guest's only handle on their order: it is emailed, never
listed, and authorises resuming payment and cancelling while pending.

Order placement moves to placeOrder() in lib/domain/orders.ts so the authed
cart and the guest checkout share one implementation -- the stock reservation
and its compensation must not exist twice. setOrderStatus() joins it for the
same reason: a cancellation that forgot to restore stock destroys inventory,
and that happens when one route remembers and another does not.

Two joins were fixed before any UI existed. app/api/orders/seller and
app/api/admin/orders inner-joined users on orders.userId; with a nullable
column that drops every guest order from the views of the people who have to
ship them -- real revenue, invisible, nothing appearing broken. Both are now
leftJoin + COALESCE onto the address the buyer typed.

Also fixed while reviewing:
- toLocale() used `value in LOCALE_CONFIG`, true for inherited keys like
  "constructor", and the result goes straight into a URL path.
- orderShippingSchema accepted any two letters as a country, so "XX" could be
  stored and printed on an undeliverable label. Checked against a new ISO-3166
  SSOT whose names come from Intl.DisplayNames, so all nine locales are
  translated with no message files to maintain.
- Guest input (shippingName, notes) reaches a seller's inbox unauthenticated;
  email templates now escape it.

Guards, not just fixes: locale parity across all nine message files is now a
test rather than a convention, and the prod walkthrough places a real guest
order and asserts the seller can see the buyer's email -- the check that goes
red if anyone reintroduces an inner join there.

The public endpoints are deliberately outside PRIVATE_API_PREFIXES; a session
guard there would silently delete the feature. They are rate limited per
client, and the payment and cancel routes require the order token.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 08:56:48 +00:00
GandClaude Opus 5 c2b5f392c1 fix(blog): a taken URL is a 409 the author can fix, not a 500 (#49)
Caught by exercising the live endpoint as an admin rather than trusting the
unit test: creating a second post with an existing slug answered 500.

Drizzle wraps driver errors, so the pg error carrying `code: 23505` is the
`cause` of what the route catches, not the error itself. Reading only the
top-level `code` looks correct in a test — where the error is hand-built with
the code right on it — and is wrong against a real database. The test passed
and production returned 500 for a mistake the author can fix in two seconds.

isUniqueViolation now walks the cause chain, bounded, with a guard against a
self-referencing chain hanging the request.

Both tests now use the wrapped shape production actually throws, which is the
point: the old test asserted the shape I assumed, not the shape reality
produces.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 13:13:11 +00:00
GandClaude Opus 5 cd591aef27 feat(blog): publish posts from the admin instead of editing code (#48)
Publishing meant editing a TypeScript array in lib/content/blog.ts, opening a
PR, and waiting for a deploy. That is not a blog anyone will actually write in —
and it made every post a developer task. There was exactly one post.

Posts now live in the database, written and published at /admin/blog. A post
goes live the moment it is published; nothing is rebuilt or redeployed.

Authoring markup is a deliberately tiny subset of Markdown:

    ## Subheading
    - bullet
    anything else is a paragraph

No Markdown dependency. A full parser would buy inline HTML we would then have
to sanitise — an XSS surface in exchange for syntax nobody asked for. Parsing
to the closed block set the post page already styles means untrusted text can
never become markup, which a test pins with a <script> tag rendering as literal
text. The editor previews the parsed blocks live, so a mistyped bullet is
visible before publishing rather than after.

Body is stored as written and parsed at render, so the author's source stays
the single truth and the renderer can improve without a data migration.

Publish dates are stamped once, on the first publish, and preserved after that.
Unpublishing to fix a typo and publishing again must not silently re-date the
post and reshuffle the index — tested in both directions.

Drafts 404 publicly rather than merely being unlisted, so guessing a slug does
not reveal unpublished writing.

The migration carries the existing post across. Its URL
(/[locale]/blog/a-platform-for-both-sides-of-pet-care) is already public, so
losing the row would 404 an indexed page; the insert is dollar-quoted for the
apostrophes and ON CONFLICT DO NOTHING so it is safe to re-run.

Deleting is a two-step inline confirm rather than a confirm() dialog: deleting a
published post breaks its URL, and a browser dialog is both easy to click
through and impossible to drive from a test.

Both public pages are force-dynamic — content that an editor changes must not be
frozen into the build.

The walkthrough now fetches a real post and asserts its prose, which exercises
the table, the content migration and the renderer together. It fetches the body
itself rather than reading $LAST_BODY, which page() never sets — asserting on it
would have grepped whatever the previous request happened to leave behind.

27 new tests; pnpm verify green (678 tests / 75 files).

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 14:59:57 +02:00
GandClaude Opus 5 c63436c995 feat(shop): search and sort the catalogue, on both storefronts (#47)
Browsing offered one control — a category pill. Any shopper who knew what they
wanted had to eyeball the grid for it, and there was no way to see the cheapest
option first. That is fine for six products and useless at sixty.

Public storefront (/[locale]/shop) does it server-side, as a plain GET form with
sort as links. Results are therefore a shareable, indexable URL and work with
JavaScript disabled — a storefront that only works with JS is a storefront
Google browses badly. Search matches name OR description, so someone searching
"harness" finds one whose name is a brand they don't know.

Portal shop filters in memory: the whole catalogue is already loaded there, so
round-tripping to the API to filter it would be slower and no more correct.
Results narrow as you type.

Filters compose rather than clobber. Searching and then picking a category
keeps the search — each control rewrites only its own parameter, so no
combination silently discards another. A search that finds nothing offers a way
back to the full catalogue instead of the sign-up prompt, which is the wrong
answer to "no results".

Sort ids are SSOT in lib/config/products.ts. They appear in the URL, so they
are part of the page's public contract — shared links and search engines keep
them; add ids, don't rename them. `?sort=` is attacker-controlled and indexes
an ORDER BY map, so it is narrowed to a known value before use, covered by
tests including __proto__ and constructor.

`newest` is the default and is omitted from the URL, so the canonical
/en/shop stays a clean URL rather than gaining a redundant query string.

13 tests on the config; pnpm verify green (638 tests / 72 files).

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 12:35:17 +00:00
GandClaude Opus 5 abb693b7f3 fix(uploads): store images with an extension so they are served with a type (#46)
Found by probing the live endpoint rather than trusting the green deploy: the
upload succeeded, the file came back at HTTP 200 with the right byte count —
and an empty Content-Type.

Caddy serves the uploads directory with `file_server`, which derives
Content-Type from the file extension. Both uploaders stored a bare UUID, so
there was nothing to derive from. Chrome sniffs the bytes and renders the image
anyway, which is exactly why this would have shipped unnoticed; sniffing is a
browser courtesy, not a guarantee, and it defeats correct caching.

Both routes now append the extension for the (already validated) image type.
The mapping is SSOT in lib/config/uploads.ts next to the type allowlist it
mirrors — the two must agree, so they live together.

Pinned with a test per accepted type, since the symptom is invisible from
inside the app: every assertion about the response passes while the header the
browser needs is missing.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 12:13:27 +00:00
GandClaude Opus 5 12438d36e3 feat(shop): list a product with a photo from your phone, not a URL (#45)
Listing a product required pasting an image URL, which quietly assumed the
seller already hosted the picture somewhere. Everyone who sells has photos on
their phone; nobody has a CDN. That single field is why a real listing could
not be created without leaving the product first — and prod currently has zero
products.

Both product forms (seller's /portal/my-products and /admin/products) now take
a file: pick, preview, replace, remove.

The upload endpoint is deliberately not scoped to a product id. The seller
chooses the photo while filling in the "new product" form, before a row exists;
scoping it would force create-then-upload and leave a product visibly imageless
whenever the second call failed. It returns a URL the form submits as imageUrl,
so create and edit take the identical path.

Files land in UPLOADS_DIR (/opt/petvity/uploads on the box, outside the app
directory so they survive deploys) and Caddy serves them from /uploads/*.

Also fixes a drift this would have made worse: the upload limits lived inline
in the avatar route, and its file picker offered JPEG/PNG/WebP while the API
also accepted GIF — so a GIF was rejectable by the UI and acceptable to the
API. Limits are now SSOT in lib/config/uploads.ts, used by both routes, both
pickers and the hint text, so they cannot disagree again.

/api/uploads is added to PRIVATE_API_PREFIXES — it writes files to disk and
must never be reachable without a session.

8 tests cover the endpoint: stores and returns the URL, keys uploads by
uploader, refuses anonymous callers, no file, over-cap, exactly-at-cap,
non-image type, and a storage failure reported instead of a fake success. The
size gate needed real bytes — FormData rebuilds the File from its content, so a
patched `size` property is discarded in transit and the gate would never fire.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 14:03:18 +02:00
GandClaude Opus 5 fd5ea90729 fix(build): vendor the fonts so the build stops depending on Google (#44)
next/font/google downloaded the faces from fonts.gstatic.com **at build time**,
which put a third party on the critical path of every CI run and every deploy.
It failed twice in one week — module-not-found on the generated @font-face for
Jost — blocking a merge each time, both on changes that had nothing to do with
typography. A build that only succeeds when Google is reachable cannot be
trusted to ship an urgent fix, and re-running until it passes is not a fix.

The four .woff2 files are now vendored in lib/font-files/ and declared with
next/font/local. 82 KB total, which also removes a render-blocking third-party
connection for every visitor.

Only the `latin` subset is vendored, matching the previous `subsets: ["latin"]`
exactly — ja/zh/ko/ar and the Turkish latin-ext glyphs fell back to system
faces before and still do. Plus Jakarta Sans (400–800) and Jost (200–400) are
variable fonts, so each is a single file; IBM Plex Mono ships no variable axis
and keeps its two static weights.

scripts/fetch-fonts.mjs regenerates the files and documents where they came
from. It is deliberately NOT wired into the build — doing so would reintroduce
the exact network dependency this removes.

Verified rendering is unchanged, not merely similar: measured actual glyph
advance widths with a Range over the live hero text on prod (Google-hosted) and
on the local build (self-hosted). Identical to three decimals — h1 669.688px,
eyebrow 222.641px — and the screenshots are pixel-identical. The emitted
@font-face URLs are now local ../media/*.woff2 with no gstatic reference in the
build output.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 11:24:27 +00:00
GandClaude Opus 5 9c9df97e88 fix(email): stop sending real mail to test accounts that can never receive it (#42)
79 of the last 100 sends hard-bounced — an 80% bounce rate against an SES
suspension threshold near 5%, on a Resend key shared with the rest of the
fleet. The reputation that carries real owners' password resets was being
spent on fixtures.

The e2e walkthrough and the smoke timer create ~20 accounts per run at
petvity.orangecat.ch. Those are real rows in the real database, so the app
correctly sends them real welcome, booking, order, adoption and reset mail —
to a domain that serves HTTP and has no MX. Every one bounces. The damage had
already crossed over: a real tester mailbox (proton.me) sits on the
suppression list receiving nothing, which is exactly the silent-lockout
failure mode — reset says "check your email", no email ever arrives.

sendEmail() now drops recipients that provably cannot receive mail, before
anything reaches the wire. Suppression is safe precisely because these domains
have no mailbox: nothing that would otherwise be delivered is lost. It returns
{ sent: false } rather than throwing, so callers behave exactly as they do when
RESEND_API_KEY is unset — a path already covered by tests — and queued items
are not retried forever.

The list is SSOT in lib/config/email.ts: two exact domains that resolve without
a mailbox, plus the RFC 2606 reserved TLDs so any future fixture using
.invalid/.test is suppressed without editing the list.

Verified the guard fails without the fix (6 of 9 tests red), passes with it.

Also refreshes CLAUDE.md, which was stale in three places and would have taught
the next session wrong: all six cron routes are in fact wired to systemd timers
and returning HTTP 200 (it claimed they were unwired); RESEND_API_KEY,
RESEND_FROM and ADMIN_EMAILS are set in production (listed as missing); and
prod env lives in /opt/petvity/shared/.env, not .env.selfhost.local.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 11:51:38 +02:00
GandClaude Opus 5 c2f86a0377 fix(demo): the shared demo keeps its identity across the reset (#38)
The demo account is the no-account way into the product. Its reset deletes
the user row so the FK graph cascades away whatever a visitor touched, then
inserts it again — but the insert let the id be generated, so every run minted
a NEW identity.

Sessions last 30 days. The reset runs every 2 hours. So within at most two
hours of signing in, a demo visitor was holding a session for a user that no
longer existed: every owner-scoped query returned nothing and the demo read as
an empty product, while writes failed the owner FK outright. Observed live —
two consecutive resets produced 8ffb17c5... then dab16518..., and a session
minted one minute before a reset was already dead.

Pinning the id keeps the cascade (still a real wipe) while letting the identity
survive it, so any session ever issued stays valid.

The demo had no test coverage at all, which is how this went unnoticed:
- a route test asserts the reseed carries the pinned id (it fails if the id
  goes back to being generated - verified by reverting the fix)
- the prod walkthrough gains a demo section: the session id is the pinned one
  (the mechanism), and the demo actually has its seeded pet (the symptom).
  The symptom check alone is timing-dependent - it passes right after a reset
  either way - so both are needed.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 16:43:30 +02:00
GandClaude Opus 5 dadbe7e4a5 fix(readiness): a full profile is live even while not accepting clients (#35)
The readiness checklist required `isAcceptingClients` before calling a profile
live, but the directory queries treat it as an optional filter — a professional
who was temporarily full appeared in search results while their own dashboard
told them they were invisible. The directory behaviour is the correct one: a
full pro is worth showing, badged as not accepting, so owners can find them and
come back. The checklist now matches, and the dead `readyStep_accepting` string
is removed from all nine locales.

The production walkthrough caught this: it created professionals with partial
profiles and asserted they were browsable, which the gate correctly refused.
It now completes each profile before expecting a listing, and — more usefully —
asserts the negative first: an incomplete vet must NOT appear in browse. That
turns the readiness gate itself into a permanent regression check rather than
something only asserted in unit tests.

135/135 checks pass against production.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 12:24:46 +02:00
GandClaude Opus 5 b8595fd86e feat(portal): the dashboard covers the whole platform, and every page says what it is for (#34)
The dashboard answered one question — how are my pets? — and left everything
else the platform does undiscovered behind the sidebar. It now also shows what
is already in motion (the next three appointments, the three most recent
orders) and a role-aware "what would you like to do?" grid: find care, shop,
adopt, and either offer your services or manage your bookings, either set up a
store or manage the one you have.

The greeting was computed from new Date().getHours() during a server render,
which is the box's UTC rather than the reader's clock — an evening visitor in
Zurich could be wished good afternoon. It is now clock-free, and the space it
occupied says what the page is for instead.

Page purpose lines, all nine locales. The worst of them was Find a Pro:
"Connect with verified veterinarians and trusted pet sitters" claimed a
verification most professionals do not have, and omitted groomers entirely
even though grooming has been a first-class vertical since #27. Six others
described what the page contained rather than what you could do on it.

PageHeader replaces the hand-rolled title/subtitle/action markup on bookings,
find, settings, shop and orders — one header instead of five near-copies.
Status badges now resolve to the semantic badge-* tones from globals.css
through a `badge` field on the status config, rather than a parallel set of
arbitrary-value Tailwind strings that happened to render the same colours.

Documented that the liveness probe is /api/healthz: /api/health is the private
prefix for health metrics and records, so it always redirects to /login and can
never report healthy — the runbook pointed at a path that could not work.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 01:49:49 +00:00
GandClaude Opus 5 42bcc47ff4 feat(marketplace): real onboarding replaces fake profiles; orders become shippable (#33)
Three things made the marketplace a demo rather than a business.

1. Orders had no delivery address. A seller could receive an order and have
   nowhere to send it. Orders now carry a required address (migration 0004,
   additive); the API rejects an order without one, and both the seller and
   admin order views expose it so fulfilment is actually possible.

2. The directory was populated by five invented businesses. Dr. Brunner,
   Sam Keller, Nadia Roth, Pfoten & Co. and Tierheim Sonnenhof do not exist —
   a customer in Zurich searching for a groomer would have found a fiction.
   They are removed from lib/config/resident-pet.ts, and ensureCommunity is
   gone from the resident-checkin cron so nothing recreates them.

3. Nothing replaced them. lib/domain/profile-readiness.ts is now the single
   rule for when a professional or seller is real enough to be listed:
   identity, services, price, location, a 40-character intro, contact, and
   the pro's own "accepting clients" switch. The same predicate drives the
   ProfileReadiness checklist the pro sees and the SQL conditions the public
   directory queries use — so the listing is earned, never hand-curated.

Selling was already open to any account (products.sellerId = userId) but was
undiscoverable; /portal/become-a-pro now says so and links to the store setup,
which shows the seller's own readiness checklist including "list your first
product".

Also: deleting a pet was reachable only by guessing it lived inside the edit
form — the pet profile now links straight to the danger zone. Professionals
could not accept a booking from /portal/bookings, and groomers were missing
from the booking role union entirely.

E2E gains two checks: an order without an address must be rejected, and the
seller must be able to see where to ship.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 01:10:42 +00:00
GandClaude Fable 5 4883c8eae2 feat(platform): public directory, blog, 6-item sidebar, portal design vocabulary (#32)
The two-sided answer. 'How do I find a groomer in Zürich?' had no
logged-out answer — the directory lived behind auth. Now /find is a
public, SEO-indexed directory (vets/sitters/groomers tabs, city filter,
ItemList schema, review aggregates, links to public profiles) with a
provider CTA; the megamenu pros pillar and footer point at it.

'If I'm a groomer, how do I find customers?' — your profile IS your
storefront, and the new blog post documents the whole two-sided
proposition honestly (/blog, content SSOT in lib/content/blog.ts,
BlogPosting schema; no invented claims, resident accounts disclosed).

Portal navigation: six entries, no section labels needed — Care, Shop,
and Adopt are hubs whose sibling pages became segmented tabs (HubTabs;
same URLs). Seller/pro upsells moved out of daily nav into a Grow card
in Settings; active sellers get one 'My Store' entry.

Portal design vocabulary (the missing discipline): .page-title/.page-sub,
.badge + tones, .icon-tile(-lg), .modal-overlay/.modal-panel, .hub-tabs —
71 hand-built repetitions of these patterns replaced across portal+admin.

verify + build green; /find (incl. groomers/Zürich), blog, and post pages
render-verified locally.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 21:37:58 +00:00
GandClaude Fable 5 2a46bced71 fix(orders): cancelled orders restore stock; sellers can delete their account (#29)
Found by an exhaustive 129-check production walkthrough of every user path:

1. Cancelling an order never released the stock it reserved at creation —
   every cancellation permanently destroyed inventory. Cancellation (user
   or admin) now restores stock for finite-stock items, guarded against
   double-restore.

2. A seller who had ever sold anything could not delete their account
   (GDPR erasure 500'd): order_items.product_id was ON DELETE RESTRICT.
   Order items now snapshot the product NAME at purchase time (they
   already snapshot price), product_id is nullable ON DELETE SET NULL,
   and all order reads use the snapshot — the buyer's order history
   survives the seller's erasure intact. Migration backfills existing
   rows from the products table.

verify + build green.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 17:37:14 +00:00
GandClaude Fable 5 8a4b4fe58b fix(honesty): remove every fabricated trust signal — nothing on the site lies (#28)
- Homepage: the invented testimonials ('Sarah M.', 'James T.', 'Amara O.'
  with fake 5-star rows) are gone, replaced by a section that is TRUE and
  verifiable in one click: Milo and Rosie's live public profiles, tracked
  daily in the open
- Seller CTA no longer claims 'thousands of pet owners'
- Resident professionals (Dr. Brunner, Sam Keller, Nadia Roth) keep their
  seeded profiles (per policy: profiles OK for testing) but lose the
  unearned Verified badges and ALL fabricated bookings + 5-star reviews;
  the cron no longer seeds reviews at all — ratings now only ever come
  from real completed bookings
- Prod data surgery accompanies this deploy (fake reviews/bookings deleted,
  residents de-verified)

verify + build green; homepage section browser-verified.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 16:17:34 +00:00
GandClaude Fable 5 300fe1cdc2 feat(groomers): grooming as a first-class professional vertical (#27)
Groomer joins vet and sitter everywhere a professional exists:
- user_role enum + groomer_profiles (salon, services, from-price) + migration
- /api/groomers browse + /api/groomers/me CRUD; role plumbed through
  registration (?role=groomer), become-a-pro, availability, bookings,
  conflict guard, admin verification, dashboards, sidebar
- Find a Pro gains a Groomers tab; booking modal books grooming as a
  one-hour session with the salon's from-price in the header
- Public pro profile renders groomers (salon, services, starting price)
- Resident groomer Nadia Roth / Salon Pfotenschick seeds via the daily
  cron with a completed booking + 5-star review, so the tab ships alive
- 6 grooming services in the professionals SSOT; role badge tokens in
  globals.css; ~25 strings x 9 locales

Verified end-to-end locally: register groomer -> profile -> visible in
browse -> booked 201 -> overlap 409. verify + build green.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 15:36:56 +00:00
GandClaude Fable 5 763d55daea feat(ux): humane booking flow, self-serve pro upgrade, role-aware dashboard (#26)
* chore: nudge CI (pull_request event was never delivered)

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

* feat(ux): humane booking flow, self-serve pro upgrade, role-aware dashboard

Booking modal rebuilt around how people actually book:
- Sitter: drop-off/pick-up dates (no datetime-local minute-picking), live
  'N nights × rate = total' before any commitment
- Vet: one date + tap-a-time-slot chips (1h appointments)
- Availability surfaced BEFORE submit: busy ranges fetched from the new
  /api/bookings/busy (privacy-safe date ranges), clashing dates disable the
  button with a plain-words warning instead of a post-submit 409
- One pet -> stated, not asked; request-not-final explainer under the CTA

True multi-tenancy path: existing owners can now become professionals —
/portal/become-a-pro (sidebar 'Offer your services') POSTs the new
/api/account/role (pet_owner -> vet/sitter only, trust-first like
registration), session refreshes in place via the update trigger.

Dashboard attention strip now spans every role: pending booking requests
(pros) and open orders (sellers) join adoption applications and vaccines.

24 new strings x 9 locales. verify green (1212 tests), build green,
modal + clash state + sidebar verified in the browser.

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 14:49:13 +00:00
GandClaude Fable 5 bb5615c0fa feat(bookings,shop): calendar conflict blocking + Stripe payment integration (#25)
* feat(bookings,shop): calendar conflict blocking + Stripe payment integration

Tier-1 scheduling: the booking API now rejects (409) any request that
overlaps a professional's active bookings or their self-declared blocked
dates; vets/sitters manage blocked ranges at /portal/professional-profile
(new professional_blocked_dates table + /api/availability CRUD).

Payments: full Stripe Checkout flow, env-gated like Resend — without
STRIPE_SECRET_KEY nothing changes; with it, checkout redirects to Stripe,
the signed webhook (/api/payments/webhook) marks orders paid, and unpaid
orders stay payable from /portal/orders (Pay now + paid/awaiting badges).
orders gains paid_at + checkout_session_id.

Critical bug found by the smoke test: the login JWT callback wrote
resolveRole(email) back to the DB, silently DEMOTING every vet/sitter to
pet_owner at their next sign-in (residents were safe only because they
never log in). ADMIN_EMAILS now only promotes; professional roles survive.

Verified end-to-end locally: sitter registers → blocks dates → owner
booking overlap 409, blocked-dates 409, disjoint 201; checkout w/o keys
falls back to recorded orders. verify green (1209 tests incl. 12 new).

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

* chore: nudge CI (pull_request event was never delivered)

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 13:49:47 +00:00
GandClaude Fable 5 9beac50989 fix(ui): kill dead ps-* overrides on form inputs; deterministic price/date formatting (#23)
* fix(ui): form-input-icon semantic class ends dead ps-* overrides; deterministic en formatting defaults

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

* docs(agents): utilities cannot override unlayered semantic classes — use modifier classes

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

* chore: drop stray audit screenshots

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 11:58:14 +00:00
GandClaude Fable 5 68991544ed fix(auth): config-driven auth surface, dead-token repair, css-var CI gate (#22)
PR #20 removed the editorial tokens (--gold*, --cream*, .section-warm-dark,
.section-cream) but only reskinned the marketing pages — all 6 (auth) pages
and 4 (public) pages still referenced them and rendered with unresolved
var() styling. Repaired and hardened:

- (auth) layout: brand panel re-expressed on the obsidian/champagne surface
  (the same language visitors arrive from), form panel on the light product
  surface; all 6 auth pages now use only live tokens
- (public) shop/adopt/pets/pros pages swept to live tokens
- New verify gate scripts/ci/check-css-vars.mjs: any var(--x) referenced in
  app/, components/, lib/ that globals.css doesn't define fails the build —
  this class of regression can't ship again (2nd occurrence; never-twice)
- DRY/SSOT: .form-label replaces 86 identical label-class repeats across 19
  files; .link-accent replaces repeated link styling; register role labels
  derive from USER_ROLE_CONFIG; password hint derives from
  PASSWORD_MIN_LENGTH; POST_LOGIN_PATH centralized in lib/config/auth.ts
  (login, demo, proxy, email templates); Terms/Privacy now link to the
  actual legal pages
- Settings: display-name field no longer renders empty when the session
  loads after mount (profile editing bug found in browser testing)
- Root layout <html> now carries dir="ltr" — fixes the hydration attribute
  mismatch with the [locale] layout's dir
- .gitignore no longer hides scripts/ (verify depends on scripts/ci/)

Browser-verified on desktop (1280px) and mobile (390px): login (credentials
+ demo), registration end-to-end, forgot/reset password, profile edit save,
sign-out, marketing nav megamenu + mobile drawer, footer, portal sidebar +
bottom tabs. verify green: lint + typecheck + css-gate + 1181 tests; build
green.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 13:01:04 +02:00
GandClaude Fable 5 acabbdf4f4 feat(resident): full resident ecosystem — every user type represented with living data (#21)
Rosie the Beagle joins Milo as a second daily-tracked resident pet (28-day
deterministic backfill on bootstrap so charts start alive), and the same
cron now idempotently seeds one of every user type: a verified vet and
sitter (Find-a-Pro), a seller with a stocked 7-product shop, a rescue with
an adoption listing, and completed bookings with 5-star reviews so ratings
render on pro profiles. Check-in generation is parametrized per pet
(CheckinProfile) with Milo's series continuing unchanged (salt 0).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-11 16:38:06 +00:00
GandClaude Fable 5 0cdd565cd3 feat(design): obsidian luxury marketing surface — platinum/champagne on near-black (#20)
Reskin the entire marketing surface (homepage, features, about, pricing,
pros, species guides, nav, footer, OG image) in a luxury-futurist dark
design language: obsidian ground, onyx cards with hairline borders,
warm platinum text, champagne-gold accent, Jost 200 display face and
IBM Plex Mono instrument labels.

- globals.css: new obsidian token layer + .lux-* / .ed-* / .btn-editorial*
  semantic classes (aurora hero, staggered reduced-motion-safe entrance)
- lib/fonts.ts: new fonts SSOT (Plus Jakarta Sans / Jost / IBM Plex Mono)
  applied to BOTH html-rendering layouts — also fixes the pre-existing
  hydration className mismatch on /[locale] pages
- MarketingNav: always-solid obsidian bar (works over dark marketing and
  light legal pages); LocaleSwitcher gains a tone="dark" variant
- design-tokens.ts synced; OG image redrawn on the obsidian palette
- Portal/admin product UI intentionally untouched (light teal/terracotta);
  AGENTS.md documents the two-surface rule

verify green: lint + typecheck + 1174 tests; build green; visually
verified via headless screenshots (desktop/mobile, home/pricing/legal).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-11 16:26:43 +00:00
GandClaude Fable 5 226a775196 feat(resident): Milo — a real pet tracked for real, one day at a time (#19)
The demo account is wiped and reseeded daily, so nothing on it ever
truly ages. Milo is the opposite: a persistent resident cat whose
morning check-in is logged by a daily cron exactly the way a real
owner would — one row per day, accumulating genuine history. Charts
lengthen, trends emerge, vaccination due-dates actually approach,
and roughly every eleventh day is an anxious one (vacuum day), so
the wellness signal earns the occasional honest 'watch'.

Values are date-seeded and deterministic (re-running a day yields the
same row; the year-long series stays inside cat normal ranges — tested
across 365 generated days). The route bootstraps the account (no
password: machine-only), pet, vaccinations, and first vet record on
first run, then is a one-row-per-day idempotent logger.

Publicly watchable at /pets/milo.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 22:31:50 +00:00
GandClaude Fable 5 9ed916af14 feat(system): healthz, one-click /demo funnel, public demo profile, new-pet grace, score labeling (#17)
- /api/healthz: public DB-pinging healthcheck. /api/health is the auth-gated
  pet-data API, so deploys and uptime monitors had nothing honest to probe.
- /demo: signs a visitor into the shared demo account in one click; linked
  from the marketing hero ('Try the live demo') and nav across all locales.
  Also fixes two hardcoded English strings in HeroCTA.
- Demo seed claims the public handle /pets/luna (when free), so the
  public-influencer-profile feature has a live showcase.
- New-pet grace: a profile younger than the 7-day alert window with no data
  and nothing overdue reads healthy/'new profile' instead of an alarming
  Watch badge seconds after creation. Overdue vaccinations still escalate.
- Digital-twin score is labeled 'Emotional wellness' (9 locales) so it stops
  reading as a contradiction of the all-metric wellness % on the health page.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 21:00:07 +00:00
GandClaude Fable 5 e9b48a84a9 feat(auth): no-account demo access + honest password-reset failures (#16)
A real user (Manuel) got locked out: wrong password 3×, and the
forgot-password flow answered 'success' while prod had no
RESEND_API_KEY — the reset email silently never sent. Two fixes:

1. Forgot-password now returns 503 with a support address for EVERY
   request when email is unconfigured (uniform before any user lookup,
   so it stays enumeration-safe). No more silent lockouts.

2. 'Explore the demo — no account needed' on the login page signs
   visitors into a shared, seeded demo account (Luna the Golden
   Retriever: 30 days of check-ins, vaccinations, medication, records —
   charts and digital twin look alive). The account can't be locked
   out: password changes and resets are refused for it, and the
   CRON_SECRET-gated /api/cron/reset-demo wipes and reseeds it daily
   (user-row delete cascades every drive-by edit).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 20:28:29 +00:00
GandClaude Fable 5 53350e722c fix: user-walkthrough bug sweep + editorial design for marketing subpages (#15)
* fix(api): accept the form wire format on medical-history create routes

The portal forms serialize every empty optional input as null
(buildBody: `form.notes.trim() || null`), but the create schemas for
vaccinations, medications, and health records modeled optionals as
.optional() alone — which rejects null. Every save from the UI failed
with 400 'Invalid input', making the entire medical-history feature
set unusable in production. Unit tests stayed green because they
omitted the keys instead of sending null.

Schemas now use .nullish() for optional fields (the update routes were
already nullable-aware), and a new test posts the exact UI payload —
nulls included — against all three routes.

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

* fix(marketing): species guide pages no longer 500 in production

/[locale]/species/[id] was the only page declaring generateStaticParams,
but the locale layout's getMessages() needs request context — the static
prerender attempt threw DYNAMIC_SERVER_USAGE at runtime (500 in prod,
invisible in dev, where everything renders dynamically). Render it
dynamically like every other marketing page.

Also reskins the page to the editorial design system (cream/gold/serif),
matching the landing page.

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

* fix(i18n): resolve 7 missing message keys and end the class with an audit test

The public adopt page rendered raw keys ('public.adoptFilterAll',
'public.adoptSearch', …) to users: its filter-bar labels live in the
portal namespace, and four more keys (adoptNoResults, adoptClearFilters,
adoptFree, portal.loading) existed in no locale at all. The page now
reads the shared filter labels from the portal namespace, and the four
genuinely missing keys are added to all 9 locales.

New test statically extracts every literal t("key") per translator
namespace and asserts it resolves in messages/en.json — tsc and eslint
are both blind to this class; this test is not (it found 4 of the 7).

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

* fix(i18n): substitute {app} once at message-load time

47 message keys reference {app}; requiring each t() call site to pass
{ app: APP.name } shipped literal '{app}' into rendered copy on the
features page (heroDesc, ccDesc). next-intl v4 removed
defaultTranslationValues, so the request config now deep-replaces the
placeholder when messages load (memoized per locale). Call sites that
still pass the value are harmless; APP.name stays the SSOT.

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

* fix(proxy): null-safe role access in the auth redirect

session?.user.role crashes the middleware — and with it every route,
turned into a 500 — whenever NextAuth yields a session without a user
(observed locally with auth misconfiguration). One optional chain makes
the failure mode 'treated as logged out' instead of 'site down'.

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

* design(marketing): extend the editorial system to all marketing subpages

/features, /about, /pricing, and /pros still wore the old teal-SaaS
look (teal gradient heroes, multicolor icon chips, teal CTA bands) while
the landing page had moved to the petvity.com editorial brand. All four
now use the same language: cream sections, gold ed-icon chips, Cormorant
ed-title headlines, pill btn-editorial CTAs, warm-dark closing bands.
Presentation classes only — copy, translation keys, and structure are
untouched. (The species guide moved in the previous commit.)

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 22:07:31 +02:00
GandClaude Opus 4.8 f79ae9772d chore(infra): remove Vercel references — self-hosted now (#8)
Vercel is decommissioned; petvity runs self-hosted on the Hetzner box
behind Caddy at petvity.orangecat.ch. Repoint every current-setup Vercel
reference to that reality:

- Remove vercel.json (Vercel Cron is gone; CLAUDE.md cron table is the
  schedule SSOT, driven by host cron/systemd timers).
- Privacy page: Vercel hosting -> Hetzner; drop "Vercel Blob" vendor
  (avatars now on local disk, not a third party).
- Cookies page: drop the Vercel Analytics claim (no analytics package is
  installed) -> state no third-party analytics.
- FAQ (de/en/es/fr): "Vercel's global edge infrastructure" -> self-hosted
  European infrastructure.
- schema.ts / avatar route / forgot-password: comments no longer say
  "Vercel Blob"/"Vercel logs".
- .gitignore: drop the .vercel ignore.

Kept: lib/storage.ts "replaces @vercel/blob" narrative and the CLAUDE.md
"there is no Vercel Cron" guardrail. Lockfile transitive deps untouched.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 21:51:16 +02:00
Mao NakamotoandClaude Opus 4.8 3365b503eb docs+config: correct stale Vercel/Neon refs to self-hosted Hetzner
petvity migrated off Vercel/Neon on 2026-06-12 (commit 9488221).
- CLAUDE.md: Vercel/Neon → self-hosted Hetzner (petvity.orangecat.ch,
  service petvity-app, self-hosted PG17, local-disk storage, deploy.sh);
  flagged that vercel.json crons no longer fire on the box (need a host
  timer) — left vercel.json intact rather than break the schedule
- README.md: replaced create-next-app boilerplate with a real README
- lib/config/app.ts: APP_URL fallback vercel.app → petvity.orangecat.ch
- removed default public/vercel.svg boilerplate asset
- .mailmap: collapse legacy g-but identity into Mao Nakamoto

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 21:26:21 +02:00
Mao NakamotoandClaude Fable 5 94882211f2 feat(selfhost): migrate to self-hosted Hetzner (Vercel/Neon/Supabase exit 2026-06-12)
Standalone output, portable Postgres driver, proxy-aware fixes as needed.
Runbook: fleetcrown/docs/infrastructure/hetzner-migration.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 19:48:13 +02:00
g-butandClaude Sonnet 4.6 def789d04b refactor(design): eliminate last hardcoded colors in homepage — 5 new CSS vars + TOKENS entries
Add --warm-text, --green-border, --warn-border, --danger-border, --star to globals.css
and matching entries to design-tokens.ts; replace all remaining Tailwind named color classes
and hex literals in app/[locale]/page.tsx (testimonial avatars, signal card borders, star
rating, step-icon shadow, final-CTA shadow). Zero arbitrary hex colors now remain outside
globals.css and design-tokens.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 12:56:50 +02:00