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>
drizzle/0000_pretty_cammi.sql was in the journal but never committed, and
the objects between it and 0001 (adoption, seller profiles, signal history,
16 indexes) were reconciled with db:push, so the chain could not build an
empty database. The baseline is generated from 0001's snapshot minus what
0001 itself adds, and 0000_snapshot.json now records that state, so every
step's snapshot diff matches its SQL.
Every baseline statement is guarded (CREATE TABLE/INDEX IF NOT EXISTS,
CREATE TYPE and foreign keys in a block that ignores duplicate_object), so
loki apply-schema.sh, which will see 0000_pretty_cammi as pending on prod,
applies it as a no-op there. Checked against a tip-state database with
0001..0007 in its ledger: no error and an identical shape afterwards.
browser-smoke now replays the migrations the way the deploy batches them
(scripts/ci/migrations-replay.sh) and fails when the result differs from
drizzle-kit push.
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
Co-authored-by: Claude <noreply@anthropic.com>
"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>
* 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>
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>
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>
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>
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>
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>
* 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>
- Add ## Mission section to CLAUDE.md (who the user is, what success looks like)
- Fix docs bug: createPetSlug() → createPetHandle() in lib/domain section
- Add "Find a vet near you" secondary CTA to petHealthAlert email — the
alert told owners their pet needs attention but gave no path to act;
now it links directly to /portal/find to close the monitor→understand→act loop
- Commit drizzle/ migration metadata (was untracked)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>