Repository navigation
feat(ci): add Cloudflare PR previews with cloned prod data + smoke tests - #435
Merged
Merged
Conversation
Defines a sahajcloud-preview Worker with its own D1 + R2 bindings, keeping production data physically isolated from preview. Cloudflare Workers Builds will publish a deploy on every non-main branch push. OPERATOR placeholders document the one-time provisioning steps (D1 create, R2 bucket + public URL, lifecycle rule, secrets). Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Strips INSERTs for managers, clients, sessions, preferences, locks, form submissions, and job-system tables from a prod D1 SQL dump. Preserves schema (CREATE TABLE) and all other content INSERTs. Tracks string-literal state so semicolons / newlines inside string values don't fool the statement splitter. Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- seed-preview-admin.mjs: POSTs to Payload's first-register endpoint after a reclone (avoids hardcoding a pbkdf2 hash that could drift if Payload's algorithm changes). - compute-preview-url.mjs: derives the deterministic CF Workers Builds branch-alias URL from GITHUB_HEAD_REF + CF_WORKER_SUBDOMAIN. - wait-for-200.sh: poll-until-200 helper for the smoke job to wait for CF to publish the preview before running specs against it. Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sundays at 04:00 UTC + workflow_dispatch. Exports prod D1, runs the sanitizer, drops preview tables dynamically (no static schema file), imports the sanitized dump, and seeds the preview admin via Payload's first-register endpoint. Requires repo secrets CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID, and PREVIEW_BASE_URL — operator-runbook step in DEPLOYMENT.md. Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Strips the unused local-E2E machinery (dev-server boot, file-based
SQLite, global-setup seeding) from playwright.config.ts and points
baseURL at PREVIEW_URL with a localhost:3000 fallback for ad-hoc
dev-server runs.
Deletes tests/setup/playwright.global-{setup,teardown}.ts and the
sqliteCleanup helper they pulled in — all three were orphaned after
the config change. The vitest globalSetup at tests/setup/globalSetup.ts
is untouched.
Refs #431
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Four .e2e.spec.ts files driven via Payload REST against the deployed preview Worker (PREVIEW_URL): - auth: login + /me round-trip - meditations: create with audio upload, update, delete cycle - songs: same cycle for Songs (admin-hidden, REST-only) - lectures: clip variant referencing a cloned full lecture (skips full-variant create to avoid the Nirmala Vidya API) Helpers in tests/e2e/_helpers/ centralize login + a per-run record-name prefix so concurrent PR smoke runs don't collide on the shared preview DB. Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
CF Workers Builds now owns the build step end-to-end for every PR push, so the local dry-run wrangler deploy job in CI is redundant. The new smoke-preview job computes the per-PR preview alias from GITHUB_HEAD_REF, waits up to 180s for CF to publish, and runs the Playwright smoke specs against the live preview. Renames the dead-placeholder test:e2e script to test:smoke and drops the conditional skip — smoke specs now land in this PR. Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
DEPLOYMENT.md gains a "Preview Environment" section: architecture diagram, file-protection invariant, one-time operator runbook, reclone schedule + sanitization summary, verification checklist. .claude/rules/storage.md notes that CLOUDFLARE_R2_DELIVERY_URL is per-env (prod = custom domain, preview = pub-*.r2.dev, dev = empty) with a back-pointer to DEPLOYMENT.md for the file-protection details. Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…dlock `wrangler secret put --env=preview` fails because the sahajcloud-preview Worker doesn't exist until first deploy, and the first deploy fails its build-time Zod env validation if PAYLOAD_SECRET / SAHAJCLOUD_PREVIEW_SECRET aren't already present — classic chicken-and-egg. Resolve by inlining the four preview env values directly in wrangler.toml [env.preview.vars], matching the existing dev-env precedent (SAHAJCLOUD_PREVIEW_SECRET inlined in [env.dev.vars]). Acceptable for non-prod: preview data is sanitized and JWTs signed by the preview secret only validate against preview. PAYLOAD_SECRET + SAHAJCLOUD_PREVIEW_SECRET ship pre-generated; the operator pastes real values for SENTRY_DSN + RESEND_API_KEY (or deletes those lines to disable). Operator runbook in DEPLOYMENT.md updated to drop `wrangler secret put × 4` and add the Build-variables step in CF Workers Builds dashboard for build-time process.env coverage. Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
sahajcloud | 1fe8d84 | Commit Preview URL Branch Preview URL |
Jun 01 2026, 04:45 AM |
…ll wait The check_run-triggered smoke workflow wasn't firing — needs further investigation of CF's check_run integration before we revisit. For now, go back to the previously-working pattern: smoke-preview runs as part of the main CI workflow on pull_request, polling for the preview URL via scripts/wait-for-200.sh with a 120s grace period before the first poll. Trades ~2 min of billable runner time per PR for reliable triggering. Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
These two files diverged when the direct-SQL seed approach was pushed to main (56479c4) but the corresponding branch edits never got committed — so the reclone workflow on this branch still called the old HTTP-based seed script with an undefined PREVIEW_BASE_URL. Bring main's versions onto the branch so the reclone seed step completes end-to-end. Refs #431 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
3 tasks
Ardnived
added a commit
that referenced
this pull request
Jun 1, 2026
…ent (#440) * feat(hooks): add unit-test PostToolUse hook for sub-5s feedback Closes #434 (P1) Runs `pnpm test:unit` after every Edit/Write to `src/**/*.ts(x)` or `tests/unit/**/*.spec.ts`. Skips `src/payload-types.ts` and `src/migrations/**`. Silent on success; prints a 30-line failure tail otherwise. Local timing: ~1.85s for 331 cases, well under the 5s target. This closes the feedback gap between editing and the pre-PR lean gate — Tier 1 of the three-tier speed contract. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore(tests): remove 5 Payload-internal integration specs Refs #434 (P2) Audited all 40 tests/int/*.int.spec.ts files and removed the 5 that only exercise Payload-CMS built-ins, with reachability already covered by collections-smoke.int.spec.ts: - api-explorer.int.spec.ts — built-in OpenAPI plugin endpoints / Scalar UI; tests the plugin, not our code. - app-cards.int.spec.ts — schema-only CRUD across app-cards fields (audiences/weight/targetSections/textColor/...); custom audience logic lives in app-cards-for-audience.int.spec.ts. - frameFiltering.int.spec.ts — built-in where-clause filtering and depth:1 relationship populate; no custom hook. - tableOfContents.int.spec.ts — Lexical block round-trip storage for null/empty/populated headings arrays; pure Payload field serialization. - subtle-system-nodes.int.spec.ts — built-in unique-slug constraint + reverse-join exposure; smoke covers reachability. The remaining 35 files all exercise at least one of: custom hooks, access control, virtual fields, custom endpoints, scheduled jobs, or business-critical workflows. Full classification ships next as tests/COVERAGE.md (P3). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(tests): add COVERAGE.md mapping collections to int test coverage Refs #434 (P3) Source-of-truth map of custom behavior to the integration test that covers it. Spans collections, globals, custom endpoints, scheduled jobs, and cross-cutting helpers (storage, RBAC, schema introspection). Notes one explicit gap (`/api/frames/by-narrator/:narratorId`, recommended follow-up) and one borderline keep (`seeds-lectures`). Documents the 5 files removed in P2 as a record of what was dropped and why. Per `.claude/rules/tests.md`, Payload-CMS built-ins are not tracked here; `collections-smoke.int.spec.ts` is the reachability canary. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore(tests): remove access-performance.int.spec.ts Refs #434 (P4) The file has three problems: 1. It is mis-located. It never calls createTestEnvironment() — every case operates on plain testData.dummyUser() objects and the permission functions. It belongs in tests/unit/ by the lane rules, not tests/int/. 2. The wall-clock thresholds (50ms / 100ms / 150ms / 200ms over 10k iterations) are inherently flaky on shared CI runners. The 200ms bound on the admin-checks case already exists "to account for CPU variance during full test suite" — a sign that the test is testing the runner, not the code. 3. Functional correctness of hasPermission / hasAnyPermission / bypassPermissions / customResourceAccess is already covered by role-based-access.int.spec.ts. Nothing here asserts a behavior the functional suite doesn't. A real perf-regression detector belongs in a dedicated benchmark lane with stable hardware — out of scope for #434. Falling back to option (c) from the issue: remove. Re-introduce a structural micro-benchmark later if the access path is ever a measured bottleneck. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(tests): record P5 dedup analysis in COVERAGE.md Refs #434 (P5) Smoke specs (auth/meditations/songs/lectures clip) target Cloudflare PR preview env via REST. Three int tests touch the same REST paths but each exercises custom logic that smoke does not assert: - content-index-block: builds /api/meditations URLs via the computeApiEndpoint virtual field — not REST CRUD. - meditation-lectures: hits /api/meditations/lectures custom endpoint (weight ranking, audience validation), not the bare /api/meditations CRUD path that smoke covers. - storage-utils: URL field factories reference /api/songs/... — tests the factory, not the REST flow. No int test removed by P5. Recording the table + analysis so future PRs can answer "is smoke already covering this?" without re-running the audit. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(testing): document three-tier speed contract Closes #434 (P6) Adds the explicit Tier 1 / Tier 2 / Tier 3 table to .claude/rules/testing-reqs.md and surfaces the same table from AGENTS.md (CLAUDE.md is a symlink). Each tier names its command, target runtime, and trigger so Claude and humans both know which lane to use when. Also corrects the AGENTS.md CI section, which still described the pre-#435 "two parallel jobs: Lint & Test, Cloudflare Build" layout. The real workflow is one job, "Lint, Test & Smoke", that runs lint, the Vitest suite, and the Playwright smoke specs against a CF PR preview environment. The Cloudflare build itself is performed by Cloudflare Workers Builds on the push, not by GitHub Actions — CI just waits for the preview URL. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(pr-prep): name the three tiers in SKILL.md + check.sh Closes #434 (P7) Aligns the pr-prep skill with the explicit Tier 1 / Tier 2 / Tier 3 contract documented in .claude/rules/testing-reqs.md. The skill now identifies its default mode as Tier 2 and --full as "Tier 3 locally, minus smoke", which is the truthful framing now that smoke runs against a Cloudflare PR preview (not locally). - SKILL.md: adds the tier table at the top; clarifies that --full cannot run smoke locally because Playwright targets a deployed CF preview built by Cloudflare Workers Builds. - check.sh: relabels the section headers as "Tier 2 (lean gate)" and "Tier 3 (local)"; prints a note that smoke runs in CI only. No behavior change in what the gate runs; only naming + framing. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(int): close framesByNarrator gap; drop seeds-lectures spec Refs #434 Two follow-ups to the audit: 1. New tests/int/frames-by-narrator.int.spec.ts covers the one gap that COVERAGE.md called out — /api/frames/by-narrator/:narratorId. Five cases: empty narratorId → 400, missing narrator → 404, imageSet filtered by narrator.gender, image/* sorted before video/*, and depth:1 hydration of subtleSystemNode. 2. tests/int/seeds-lectures.int.spec.ts removed. Covered the WeMeditate seed importer (importLectures), not a collection hook or any built-in custom logic the integration lane is responsible for. Aligns with the audit's "remove what doesn't belong in the integration lane" stance — seed-script coverage belongs in a dedicated lane or as part of the seed runner itself, not here. COVERAGE.md updated: gap row resolved, seeds-lectures moved from the borderline-keeps section into the "Removed by the audit" list. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Ardnived
added a commit
that referenced
this pull request
Aug 3, 2026
…re import (#605) * feat(atlas): groom legacy event listings before import The 511 Atlas events were typed by ~200 volunteer managers over four years with no validation, so the free-text fields carried information the listing already renders structurally, copy-paste junk, spelling mistakes, and dates now 2-4 years stale. 219 of 511 events needed at least one edit. Grooming (events.json, managers' wording kept verbatim): - Removed what `address` / `room` / `schedule` / `contactInfo` / `onlineUrl` / `registrationUrl` / `website` already render. Where prose and schedule disagreed the schedule won — its weekday always matches startDate's day-of-week, the prose did not (#128, #149, #235, #389, #443). - Dropped stale dates (25 events named a year, 48 a specific date) and 18 expired notices ("On Christmas break", "Sommerpause", "CLOSED during August 2024"). - Fixed capitalization (the Italian `SAHAJA YOGA -` prefix, the Australian `HORNSBY Thursdays 6.30pm` pattern, German title-case, missing accents) and ~25 confirmed spelling errors across 8 languages. - Stripped 480 U+2800 braille blanks used as VK padding, 31 zero-width spaces, tabs, CRLF, `</br>`, and styled Mathematical-Alphanumeric letters. - Rewrote titles that were a bare place name, a venue name, an address, or a day and time. A weekday stays in a title where it is the only thing separating sibling events at one venue, and in a description where `schedule` cannot express the real cadence — both noted in AGENTS.md. Supporting changes: - Add `Events.contactEmail`. Atlas has no such column: 16 addresses came out of descriptions and 12 from the `contactInfo.email_address` the importer never read. Deliberately outside the contactPhone -> contactName required gate, since some events publish an email and no phone. - Promote 10 `contactInfo.meetup`/`facebook` values to `website`, own domain beating the aggregator per the #584 rule. - Derive a missing `schedule.weekday` from `startDate` in `parseSchedule`. 49 rows use a YAML dialect with no `on` key; weekly ones were already covered by scheduleMapper's fallback, but `monthly_1st` was not — 2 events recurred on "day 3 of the month" instead of "first Sunday". - Emit optional event fields as `null`, not `undefined`. Payload omits `undefined` from an update, so the 36 descriptions this pass cleared survived the first `--update` reseed unchanged. - Skip the leftover test records #494/#575, warning with the document id when an earlier import already created them (#575 landed published). - Move recurrence parsing to `helpers/recurrence.ts` so it is unit-testable (extract.ts runs `main()` at module load). tests/unit/atlas-events-data.spec.ts guards the grooming invariants so a re-extraction — which drops every curated value — fails the unit lane instead of quietly shipping. 13 of its 15 cases fail against the pre-grooming file. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * feat(events): time-of-day auto-titles, and prefer them over generic names A blank event title is better than a hand-written generic one: the auto-fill localizes, and improving one string improves every event, where 60 copies of "Free Meditation Classes in <Place>" cannot be. This makes the auto-fill worth preferring, then retires the generic names in favour of it. Auto-title: - Add `event.title` to the Atlas translations global — `morning` / `afternoon` / `evening` / `default`. Each is a complete sentence with a `%{place}` placeholder, not a shared prefix plus a time-of-day word: a locale that puts the time of day after the place, or inflects it with the preposition, cannot be served by concatenation. - Pick the slot from the event's *local* start hour via `schedule.firstDate_tz`. 19:00 in Auckland is 07:00 UTC, so reading the UTC hour would label it a morning class. `default` covers a 22:00-04:59 start and the 19 events with no schedule at all. - Slots fall back to English individually — Payload's locale fallback is per-field, not per-key, so a partly translated locale would otherwise yield `undefined` for the slots a translator skipped. The hook previously read `event.titlePrefix`, which was never declared in `translationsSchema.json`: the lookup always missed and every title used the hardcoded English. `event` holds nested groups and the builder cannot mix leaf keys with groups at one level, which is likely why it was never added — hence a `title` group rather than a bare key. Titles (69 blanked, 11 kept or restored): - Blanked the standardised "Free Meditation Classes in <Place>" names an earlier pass introduced, three indistinguishable "Online Meditation" listings, five casing/"Weekly" variants, eight that collided at one venue, and five carrying an English generic on a DE/FR event. - Restored 10 titles that name the **venue** — the auto-fill only has the street, so `Regina Public Library, Glen Elm branch` carries what `1601 Dewdney Ave E` cannot. Kept #293/#294/#371, whose streets are `Zentrum`, `Innenstadt` and `B26`; fixed #294 `Tyrol` -> `Tirol`. - The importer now sends `title: ''` for a blank `customName`. The hook keeps `originalDoc.title` for a nullish value, so clearing a title in events.json would otherwise never reach an already-imported row. Because the auto-fill takes the first comma-segment of `street`, three venue records were producing "Meditation at 9" / "at solihull" / "at old bar"; fixed in venues.json, which improves the rendered address too. The four Swiss `Introduction & Meditation Course` events are not a translation gap — they are the `course` half of duplicate pairs (same venue, weekday, language, and time in 5 of 7). Translating them would mint a duplicate title per venue, so they are blanked and the pairs documented for a manager to reconcile. Verified: lint, typecheck, 897 unit tests, and 60 integration tests across the events/atlas/translations specs. The full integration lane is flaky on this machine — the clean tree at 4f7ca64 fails 12 files / 13 tests the same way (timeouts in media- and meditation-heavy suites), so this branch sits inside the existing noise band rather than adding to it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * feat(atlas): merge 12 confirmed duplicate events Atlas let one real class be entered twice. 12 pairs were confirmed by sharing a venue *and* an identical frequency/interval/weekday/weekNumber/startTime, then differing only in title, description, lifecycle status or language. Atlas's own `status` decided the survivor: 0 = verified/live, 6 = finished, so a 6/0 pair means Atlas had already retired one side. 15 rows removed from events.json (511 -> 496): - #195 -> #603 same Zoom room + slot, same manager and region; title blanked - #752 -> #753 one bilingual Ixelles session listed twice, EN and FR - #360 -> #684, #392 -> #698 Helsinki, retired half dropped - #458/#461/#464/#468/#469 -> #560/#565/#562/#570/#571 one Swiss manager's `course` rows, retired and re-entered as `dropin` at the same venue/weekday/time/language - #82 + #496, #497 + #534, #355 + #535 both sides already retired A merge is not a delete: values the removed row held and the survivor lacked were carried over first — #684 gained #360's meetup `website` and contact, #698 gained #392's contact. - Add a curated `languageCodes` override. Atlas stored one code per row but Payload's `languages` is hasMany, so the merged bilingual #753 carries ['EN','FR']; `mapEventLanguages` prefers it over `languageCode`. - Generalise the skip guard into `EXCLUDED_EVENT_LEGACY_IDS`, a reason-per-id map covering the 2 test records and all 15 removals, so a re-extraction (which rebuilds the file from `select * from events`) cannot undo the merge. It warns with the document id when an excluded row already exists from an earlier import — all 15 do. - `expectedCounts.events` 509 -> 494. Removing rows also drops 3 venues from multi-use to single-use (132, 317, 562), so the import now creates 3 fewer region centers; regions still clear their expected minimum. Deliberately not merged: #115/#116 (same Zoom link but different `areaId` — one room advertised to two regions on purpose), five pairs owned by two *different* managers, and #400/#404 + #435/#437, which only look co-located because a venue record's coordinates disagree with its own stated address. Verified with captured exit codes: lint, typecheck, 899 unit tests, and 33 integration tests across the atlas/events/translations specs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * refactor(atlas): blank 78 titles that only say "meditation" A custom title has to earn its place: the auto-fill localizes and improves centrally, so a generic name is strictly worse than none. 78 titles said nothing the auto-title doesn't — often the identical string repeated verbatim across a dozen cities, so they never distinguished anything either. Blanked, among others: 10x Taller de meditación (5 Spanish cities) 7x Viikoittainen meditaatio (4 Finnish cities) 6x Corso di Meditazione (6 Italian cities) 5x Meditatie Cursus (5 Belgian towns) 5x Sahaja Yoga Präsentation und Meditationsübung 3x Méditation (#753/#754/#755) plus one-offs — `Aula aberta`, `Meditation Course`, `Learn to meditate`, `Meditate for inner peace`, `Медитация`, `Meditação Presencial` ("in person" is `eventType`), `Weekly meditation`, `Daily online meditation`. Kept, because they name something the auto-fill cannot: - a venue — Regina Public Library, University of Guelph, Button Factory - an audience — Kids' Meditations, Aula de Aprofundamento, Meditation für Fortgeschrittene - a language — Viikoittainen meditaatio suomeksi, Meditationskurs auf Deutsch, Sahaja Yoga in English - a format — Music and Meditation, Live Online WhatsApp Video Meditation, Taller de musicoterapia - a named event — Corso Leopold, Puja a Shri Ganesha, Vaasan Taiteiden Yö Blanking can collide: two events at one venue in the same time-of-day slot auto-fill to the same title. #463 and #569 were therefore left named, each sharing a street with an already-blank sibling. The 7 remaining collisions are all pre-existing pairs already on the unmerged-duplicates list — #263-#266 were four identical `Taller de meditación` titles before this change, so they are no less distinguishable than they were. Two guards added to tests/unit/atlas-events-data.spec.ts: a regex rejecting bare "meditation/class/course" titles in 9 languages, and a check that every blank title can still produce one (online, or a venue with a street). The first was mutation-checked by re-introducing `Méditation` on #753 — it fails. 221 custom titles remain, 273 events auto-fill. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(atlas): group events that meet at one address into a shared venue A venue used by more than one event becomes a Regions node those events point at; a single-use venue's address is inlined and the record dropped. That already worked — but grouping keys on `venueId`, and Atlas holds the same place under several venue rows, so two events at one address each looked single-use and neither grouped. Ten pairs added to VENUE_MERGES, each verified by hand. **36 -> 44 shared venues**, 346 inlined. Coordinates alone are not evidence in either direction: two Civitavecchia venues sit 177 m apart but are different places, while Athens 386/432 are 230 m apart yet share a name, street, city and postcode. Two candidates were rejected on inspection — Móstoles 155/158 (404 km apart, different names; one row's `street` is simply wrong) and Воронеж/Тольятти 483/511 (700 km apart). Both had surfaced from a normaliser that stripped non-Latin text to an empty string, so every Cyrillic and Greek address matched every other one. The kept side is whichever holds better data, not the lower id — 191 -> 215 because 215 is named `Wensum Sports Centre`, which event #315's own description names; 50 -> 514 because 50's postcode `1017ZP` is Amsterdam's on a Den Haag venue. VENUE_FIELD_OVERRIDES repairs a field where the *deleted* row was better (514 keeps its correct postcode but takes 50's real name, `Atelier`), in code so a re-extraction reproduces it. Two bugs this fixes: - Venues 11 and 104 sit 1 m apart and were *both* shared, so the import created two nodes for one Amsterdam building. - Merges apply in a single pass, so a chain strands events on a deleted row. The pre-existing `342 -> 104` had to become `342 -> 11` once 104 merged into 11. `venueMergeChains()` + a unit test now reject any chain. Also: warn on orphaned nodes. The import only upserts, so a venue dropping below the >1-event bar leaves a stale region behind with its public URL. It reports the document id rather than deleting — a manager may have hung content off it. Three postcode conflicts are left as they stand, flagged in AGENTS.md, because the data cannot settle them: Eindhoven 5641EC/5641PC, Tampere 33541/33540, Derby DE73 5SA/5UA. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * feat(events): keep the venue name, and let the auto-title use it `venueToEventAddress` discarded a venue's own name when folding a single-use venue into an event's address, leaving nothing but a street — so a blank title auto-filled to "Meditation at 9 St Peter's Park Rd" rather than naming the meeting house a seeker is looking for. - Add `address.venueName` (text, max 100) behind a `hasVenueName` option on the shared addressFields factory; only Events opts in. Distinct from `room`, which says where *inside* the building to go. - `addressPlaceName` prefers it over the street, so `composeEventTitle` now takes the address rather than the street alone. - The importer sets it for 232 offline events. 166 names are deliberately dropped, because they add nothing over the address: - **the street rewritten** — Atlas names many venues after their own address with the house number on the other end ("22 Manenburgstraat" for "Manenburgstraat 22"). Compared as a sorted token bag, so word order and punctuation don't matter. - **the city** — venue 483 is named "Воронеж", in Воронеж. Using that as the place would be worse than the street, not better. Trailing separators are stripped: "Browns Bay Community Centre," and "Waimarie: Hamilton East Community House," both carried one, and would otherwise have ended a title with a comma. Resulting titles: "#4 Evening Meditation at Main Sahaja Centre in New Zealand", "#11 Afternoon Meditation at Upper Riccarton Community and School Library". The generated migration also picks up `event_title` on the translations locales tables — that group was added in 023fc39 without one. Dev runs `push: true` so it went unnoticed; production would have been missing the column. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * refactor(regions): rename the `center` level to `venue` Most of these are public libraries and community halls that host more than one class, not Sahaja Yoga centres — "SY Center" claimed more than the data supports. The level is what it actually is: a venue shared by several events. Renamed the stored enum value, not just the label, so the API says the same thing the admin does: `level: 'center'` -> `'venue'`, "SY Center" -> "Venue", the Centers tab -> Venues, `childrenCenters` -> `childrenVenues`, and the importer's `center:<venueId>` map keys -> `venue:<venueId>`. *** BREAKING FOR AtlasReact *** — the widget reads `level` off the region API and must be updated in step. Nothing else consumes the value: it appears only in Regions.ts, Events.ts's City/Venue filter, geocoder.ts's radius default, the importer, and generated types. `src/lib/atlasSidebar/sidebarModel.ts` declares its own `RegionLevel` union (deliberately, to keep the client tree free of the server collection), so typecheck could NOT catch it — the stale `center` key surfaced only when the unit lane ran. Worth remembering the next time a level value changes. *** THE MIGRATION NEEDS A HAND-EDIT BEFORE MERGE *** `20260730_172342_rename_region_level_center_to_venue.ts` is committed exactly as generated, and as generated it will FAIL on deploy: it casts the column to text, drops and recreates the type, then casts back with `USING "level"::"enum_regions_level"` — which throws on every existing row holding 'center' (44 of them), aborting the in-process boot migration. The hook blocks me from editing files under src/migrations. Replace both bodies with an in-place rename, which carries the rows and needs no backfill: up: ALTER TYPE "public"."enum_regions_level" RENAME VALUE 'center' TO 'venue'; down: ALTER TYPE "public"."enum_regions_level" RENAME VALUE 'venue' TO 'center'; Verified with captured exit codes: lint, typecheck, 919 unit tests, 29 integration tests across atlas-collections / regions / events / atlas-sidebar. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * refactor: re-export RegionLevel instead of redeclaring it `sidebarModel.ts` declared its own copy of the `RegionLevel` union, so the `center` -> `venue` rename typechecked cleanly while leaving two stale `center` keys behind — the failure surfaced only when the unit lane ran. A type-only re-export from the canonical union makes tsc catch it. Type-only, so it's erased at compile time: none of geocoder.ts's server-side Mapbox code reaches the client bundle this module feeds ('use client' components under src/components/admin/AtlasNav/). Mutation-checked — renaming the canonical value now produces `sidebarModel.ts(147,3): Type '"venue"' is not assignable to type 'RegionLevel | null'` where it previously compiled silently. `REGION_LEVEL_LABEL` stays duplicated on purpose, now with the reason recorded: `REGION_LEVEL_OPTIONS` is a runtime value inside a server collection config, so importing it would drag that config, its hooks and `serverEnv` into the client bundle. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(seeds): correct the expected Atlas region count to 518 `expectedCounts.atlas.regions` was 482 with a comment claiming "482 source geo nodes (29 + 100 + 353)". Both halves were wrong: regions.json holds 474 rows (29 country + 99 region + 346 area, post-dedupe), and the importer adds one shared-venue node per venue used by more than one surviving event — 44 of them. The real figure is 518. This mattered because verification is `actual >= expected`, so an understated constant is not a conservative choice — it degrades into no check at all. At 482 the import could have silently lost 36 regions and still reported a pass. Adds a unit test deriving the number from the data (regions.json row count + shared-venue count computed off events.json, excluding the two test records the importer skips) and asserting EXPECTED_COUNTS matches. Mutation-checked: with the constant back at 482 the case fails with "expected 482 to be 518". Also corrects the `eventTitle` no-place comment, which claimed an empty title would fall through to `useAsTitle`/the document id. It doesn't — `title` is `required`, and field `beforeChange` hooks run *before* validation (payload/dist/fields/hooks/beforeChange/promise.js:16-19), so the field is refused rather than saved blank. The behaviour was already correct and already covered by "leaves no event unable to produce a title at all"; only the comment was misleading. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * docs(atlas): sync the region-level rename and the groomed/region counts The branch renamed the Regions `center` level to `venue` and moved several counts; the docs still described the old shape. - MIGRATION_PLAN.md: three "Regions `center`" references → `venue` node. - atlas/AGENTS.md: the grooming pass covers 446 of the 511 extracted events, not 219 (the figure predates the second and third passes); contactEmail is on 27 events; the venue-topology note points at the test that now guards the count. - seeds/AGENTS.md: atlas events 511 → 494, regions 482 → 518 in the collection metadata table, and the same 446 correction. - Records why an understated `expectedCounts` value is not a safe default. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(migrations): rename the region level enum value in place The generated migration cast `regions.level` to text, dropped the enum type, recreated it without 'center', then cast back with `USING "level"::"enum_regions_level"` — which throws `22P02 invalid input value for enum enum_regions_level: "center"` on every existing 'center' row. Prod has 44, and Railway PR previews boot against cloned prod data, so as generated this aborted the in-process boot migration. `ALTER TYPE ... RENAME VALUE` renames the label in place, so no row is rewritten. Verified in a scratch schema seeded with center rows: the generated form fails with 22P02, RENAME VALUE succeeds, the column default survives as 'country'::enum_regions_level, and `down` reverses cleanly. Augmentation case 1 in .claude/rules/migrations.md — the migration fails without the edit. The .json snapshot already records the post-rename values, so the chain stays intact for the next migrate:create. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(tests): finish the center → venue rename in the access specs `role-based-access.int.spec.ts` still created regions with `level: 'center'` in four places, so the whole "recursive inheritance via breadcrumbs" block failed CI with "Details > Type: This field has an invalid selection" (plus a cascading slug collision as the fixture chain unwound). The reason it reached CI: `tsconfig.json` excludes `tests`, so `pnpm typecheck` never reads the int specs — the type-only RegionLevel re-export added earlier guards `src/` but cannot guard here. Compounding it, both `createRegion` helpers took `Record<string, unknown>`, so `level` was unconstrained even in-editor. Narrows both helpers to a `RegionFixture` type keyed on the canonical `RegionLevel`, and renames the leftover center/Center identifiers and test names in both region specs to match the level they now create. Including `tests` in the tsconfig program would be the real fix — it surfaces 189 pre-existing errors across ~20 spec files, so it needs its own ticket rather than riding along here. Verified: role-based-access + regions + atlas-collections int specs pass (79 tests), and the lean gate is green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds per-PR Cloudflare preview deploys on a dedicated
[env.preview]Worker (sahajcloud-preview) with its own D1 + R2, populated by a weekly sanitized clone of prod. Newsmoke-previewCI job runs Playwright specs (auth + Meditations / Songs / Lectures CRUD) against the per-PR preview URL.Closes #431. The follow-up Cloudflare Images/Stream isolation work stays in #432.
What landed
wrangler.toml— new[env.preview]block mirroring[env.dev], withOPERATOR:markers for the values that need post-merge provisioning..github/workflows/preview-reclone.yml— Sunday-04:00-UTC cron +workflow_dispatch. Exports prod D1, runs the sanitizer, drops preview tables dynamically (no static schema file to drift), imports, seeds the admin via Payload'sfirst-register.scripts/sanitize-preview-dump.ts— string-literal-aware SQL parser that strips INSERTs formanagers*,clients*,payload_preferences*,payload_locked_documents*,form_submissions*,payload_jobs*. Covered by 9 unit tests.scripts/{compute-preview-url.mjs,wait-for-200.sh,seed-preview-admin.mjs}— small CI helpers.playwright.config.ts— repurposed for smoke-against-remote (the prior local-E2E machinery was unused). Orphanedtests/setup/playwright.global-{setup,teardown}.ts+sqliteCleanup.tsdeleted.tests/e2e/auth|meditations|songs|lectures.e2e.spec.ts+_helpers/{preview,runId}.ts— REST-driven smoke specs. Lectures spec uses the clip variant only, skipping the full-lecture create path so we don't hit the Nirmala Vidya API in CI..github/workflows/ci.yml— deletes thebuildjob (CF Workers Builds runs an equivalent build per push, so the dry-run was duplicate work) and addssmoke-previewin its place.package.json— renames the dead-placeholdertest:e2escript totest:smoke.DEPLOYMENT.md— new "Preview Environment" section with the architecture diagram, file-protection invariant, operator runbook, and verification checklist..claude/rules/storage.md— short note thatCLOUDFLARE_R2_DELIVERY_URLis per-env.File-protection invariant
Preview's Worker has no binding to the prod R2 bucket. Cloned DB rows still reference
assets.sydevelopers.com/...URLs (so the preview admin UI renders), but any delete in preview admin callsR2.delete(key)against the preview bucket — a no-op for files that live in prod. The next reclone restores the row.Operator runbook (after merging)
This PR ships code; the preview env itself needs one-time provisioning. See DEPLOYMENT.md → Preview Environment for the full step-by-step, but the short version:
wrangler d1 create sahajcloud-preview --location=weur→ paste UUID intowrangler.toml.wrangler r2 bucket create sahajcloud-preview --jurisdiction=eu→ enable the defaultpub-<hash>.r2.devpublic URL in the dashboard → paste intowrangler.toml→ add 8-day object-lifecycle rule.wrangler secret put× 4 (PAYLOAD_SECRET,RESEND_API_KEY,SENTRY_DSN,SAHAJCLOUD_PREVIEW_SECRET) with--env=preview.mainbranches.CLOUDFLARE_API_TOKEN,CLOUDFLARE_ACCOUNT_ID,PREVIEW_BASE_URL. Repo variable:CF_WORKER_SUBDOMAIN.preview-recloneonce.Test plan
Verified locally:
pnpm lint— cleanpnpm test:unit— 326 pass (including 9 new forsanitizeDump)node scripts/compute-preview-url.mjs— slugifies branch names + truncates correctlypnpm exec wrangler deploy --dry-run --env=preview—[env.preview]block parses (the build itself errors on missingPAYLOAD_SECRET, same way the existing--env=""dry-run does without the dummy CI env)Cannot validate without the operator runbook (track in DEPLOYMENT.md checklist):
smoke-previewjob runs the four specs green against a real preview URLSMOKE_RUN_ID-prefixed records🤖 Generated with Claude Code