Skip to content

feat(atlas): groom legacy event listings and group shared venues before import - #605

Merged
Ardnived merged 13 commits into
mainfrom
feat/atlas-event-grooming
Aug 3, 2026
Merged

Ardnived merged 13 commits into
mainfrom
feat/atlas-event-grooming

Conversation

@Ardnived

@Ardnived Ardnived commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Grooms the 511 legacy Sahaj Atlas events before import, and closes the gaps in the
code that the groomed data exposed. Four years of unvalidated free text from ~200
volunteer managers meant a large share of listings would have imported reading as
abandoned — stale dates, repeated addresses, dead links, shouty titles.

446 of the 511 extracted events are touched; 15 confirmed duplicates are merged
away, leaving 496 rows and 494 imported.
The managers' own wording is kept
verbatim throughout — this deletes redundancy and fixes errors, it does not rewrite
copy.

What changed

The data (seeds/atlas/data/)

  • Redundancy removed — address, room, weekday, time, phone, email and URLs all
    have their own fields; repeating them in prose is noise, and where prose and
    schedule disagreed the schedule won (the prose was simply stale).
  • Stale content removed — 25 events named a year, 48 named a specific date, 18
    carried an expired notice ("On Christmas break until the 8th Jan"). All in the past.
  • Links relocated — 30 URLs duplicated onlineUrl/registrationUrl/website;
    one was promoted to onlineUrl (its only join link), one repaired. Descriptions
    convert to plain Lexical paragraphs, so a URL left in prose renders unclickable.
  • 27 contact emails lifted out of descriptions and the legacy
    contactInfo.email_address the importer never read, into a new contactEmail.
  • Invisible junk stripped — 480 braille-blank padding characters, 31 zero-width
    spaces, tabs, \r\n, </br></br>, 122 untrimmed values.
  • 78 titles blanked — a title that only says "Meditation" is strictly worse than
    the auto-title, which localizes and improves for every event at once.
  • 15 duplicates merged — online classes sharing a Zoom room and slot, in-person
    pairs differing only in language (now one bilingual event), and retired pairs.
  • 10 venues merged, 3 street/city casing fixes (the auto-title reads the first
    comma-segment of street).

The code

  • Time-of-day auto-titles — "Morning/Afternoon/Evening Meditation at «Place»"
    plus the existing fallback for late or indeterminate times, as 4 distinct
    translation strings
    (not compounded fragments), editable per locale in
    sy-atlas-translations. The hook previously read event.titlePrefix, which was
    never in the schema — this localization had never worked.
  • venueName on the inline address — Atlas has a building name on most venues
    and it was being discarded, so a blank title auto-filled to "Meditation at 9 St
    Peter's Park Rd" instead of naming the meeting house. 232 names recovered; dropped
    when it merely repeats the street or the city.
  • Shared venues — events meeting at one address now group under a Regions
    venue node (renamed from center; most are libraries and community halls, not
    Sahaja Yoga centres). 36 → 44 nodes. Single-event venues stay inline on the event.
  • Cleared fields now actually clear — Payload omits undefined from an update,
    so a description the grooming pass emptied would have survived every --update
    reseed. Optional fields emit null; title emits '' to re-trigger the auto-fill.

Review findings fixed in this PR

  • expectedCounts.atlas.regions was 482; the real figure is 518 (474 source geo
    nodes + 44 shared venues). Verification is actual >= expected, so understating it
    isn't conservative — the import could have lost 36 regions and still passed. Now
    derived from the data by a test.
  • RegionLevel was declared three times, which is why tsc stayed silent
    through the center → venue rename while two stale values survived. Now a
    type-only re-export from the canonical union.
  • The enum-rename migration was destructive as generated — see below.
  • Four level: 'center' literals survived in role-based-access.int.spec.ts,
    found by CI. The type-only re-export guards src/, but tsconfig.json excludes
    tests, so pnpm typecheck never reads the int specs — and both createRegion
    helpers took Record<string, unknown>, leaving level unconstrained even
    in-editor. Both are now keyed on the canonical RegionLevel.

Dismissed: an O(n²) includes in mapEventLanguages (the array holds at most 2
entries, and the efficiency reviewer independently called it micro-optimization); a
request to unit-test mapEventLanguages's all-unmappable branch (it's private, and
the real risk — a bad hand-edited code — is pinned at the data layer by the test
asserting #753 → ['EN','FR']); deriving REGION_LEVEL_LABEL from
REGION_LEVEL_OPTIONS (a runtime value in a server collection config; importing it
would pull serverEnv and the config's hooks into the client bundle).

Migration

20260730_172342_rename_region_level_center_to_venue is hand-edited away from the
generated form
, which cast the column to text, dropped the enum, recreated it
without center, and cast back with USING "level"::"enum_regions_level" — throwing
22P02 invalid input value for enum enum_regions_level: "center" on all 44 existing
rows. Since Railway PR previews boot against cloned prod data and run
prodMigrations in-process, that aborted the boot.

ALTER TYPE ... RENAME VALUE renames in place, rewriting no rows. Verified in a
scratch schema seeded with center rows: the generated form fails with 22P02,
RENAME VALUE succeeds, the column default survives, and down reverses cleanly.

Follow-up worth a ticket

tsconfig.json excludes tests, so no test file is typechecked — which is how
the stale level literals above reached CI. Including tests in the program
surfaces 189 pre-existing errors across ~20 spec files, too large to fold in
here, but it means the int lane is currently the only thing standing between a
renamed union and a red CI run.

Testing

  • pnpm lint, pnpm typecheck, 920 unit tests — green.
  • CI green after one fix round (the level: 'center' literals above); the Railway
    preview deploys clean, which is the real proof the migration edit works — it
    boots against cloned prod data and applies prodMigrations in-process.
  • role-based-access + regions + atlas-collections int specs — green (79 tests).
  • New: atlas-events-data.spec.ts (21 data-invariant cases), atlas-dedupe.spec.ts
    (8), atlas-recurrence.spec.ts. The data specs exist so a re-extraction — which
    regenerates the file from the SQL dump and drops every curated value — fails the
    unit lane instead of quietly undoing the pass.
  • Mutation-checked, per the project practice: reverting regions to 482 fails
    with expected 482 to be 518; renaming the canonical RegionLevel value now
    errors in sidebarModel.ts, where it previously compiled clean.

Verify manually

The end-to-end seed has not been run — the local dev server can't boot in this
environment (Payload times out reaching ethereal.email for its mock mail account).
Worth checking against the preview after deploy:

🤖 Generated with Claude Code

Ardnived and others added 11 commits July 29, 2026 16:08
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]>
…ames

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]>
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]>
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]>
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]>
`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]>
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]>
`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]>
`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]>
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]>
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]>
@railway-app

railway-app Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-605 environment in sahajcloud

Service Status Web Updated (UTC)
SahajCloud ✅ Success (View Logs) Web Aug 3, 2026 at 9:54 pm

@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-605 July 31, 2026 00:48 Destroyed
`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]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-605 August 3, 2026 21:52 Destroyed
@Ardnived
Ardnived merged commit c327cde into main Aug 3, 2026
2 checks passed
@Ardnived
Ardnived deleted the feat/atlas-event-grooming branch August 3, 2026 22:47
Ardnived added a commit that referenced this pull request Aug 4, 2026
The highest-timestamp snapshot on main
(20260803_221051_registrations_full_flag.json) was stale: it merged in via
PR #601, whose registrations_full migration was generated before #605/#608's
schema landed (region level `venue`, events contact_email / address_venue_name,
translations event_title). Those migrations are timestamped earlier than 0803
but merged later — the out-of-order snapshot trap in .claude/rules/migrations.md.

The next migrate:create would have diffed against that stale snapshot and
re-emitted the already-applied DDL. This lands a no-op migration whose
regenerated .json reflects the full current schema, so the chain is healed:
migrate:create now detects no changes (verified). The .ts does nothing — every
column already ships in an earlier migration.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 6, 2026
…s seed fixes (#615)

* refactor(events): move pure title helpers into src/lib/eventTitle

The listing-quality checks need composeEventTitle / EVENT_TITLE_DEFAULTS /
addressPlaceName to recognise an auto-filled title, and they live in
src/lib/eventQuality. src/lib/ imports nothing from src/collections/ (rule 4
in .claude/rules/project-structure.md), so the pure half of the title hook
moves to src/lib/eventTitle/compose.ts. The request-scoped half —
resolveTitleTemplates + eventTitleBeforeChange — stays with the collection.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(events): add the listing-quality check registry

A registry of named checks flagging an event listing as incomplete or
low-quality, with a pure report builder over it. Advisory only — nothing here
blocks publishing, hides an event, or gates verification.

Three decisions the design rests on:

- An auto-filled title is never judged. The auto-title is built from the
  address, and #605 blanked 78 generic titles precisely so they'd fall back to
  it, so a naive "title restates the address" rule would fail the majority of
  listings. Detection is by recomposition (autoTitle.ts), across every slot and
  against the locale's own templates as well as the English defaults.
- Checks split into document scope (description, images, website, contacts —
  none localized) and per-locale (title quality, translation coverage), so the
  report can answer "which of my languages is missing a title".
- Locale scope is the default locale plus the event's own `languages`, not all
  19 — which would show 18 failing checks on nearly every listing.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(atlas): import the shared heuristics instead of copying them

The URL / email / generic-title regexes and the stale-date rule were defined
inline in the data spec. They now come from @/lib/eventQuality, so the
grooming pass's definition of "a URL in the description" and the runtime
check's cannot drift. The 1970 exemption moves into findStaleDates with it.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(events): wire the quality report onto the collection + admin panel

- `qualityReport` — virtual JSON field, not localized, computed on afterRead.
  It opts out of list reads via the hook's `findMany` flag, so a 25-row list
  view issues no per-event queries; `defaultPopulate` keeps it out of
  relationship hydration too. Its two reads (all-locale titles, all-locale
  auto-title templates) are promise-memoized on req.context, and the titles
  read carries a narrow `select` so it can't recurse back into this hook.
- `qualityOpenCount` / `qualityCheckVersion` — stamped by a collection-level
  beforeChange from `{ ...originalDoc, ...data }`. Collection-level because a
  field hook computing off sibling data NULLs the column on every unrelated
  write (the computeLastDate trap in .claude/rules/collections.md).
- EventQualityPanel replaces the raw JSON rendering: findings grouped by tier,
  per-locale ones tagged with their language, passing ones behind a
  Collapsible, and the skip reason rendered as its own explanation. Reuses
  StatusIcon / ProgressBar / summaryTone from ReadinessField and Banner /
  Pill / Collapsible from @payloadcms/ui. No refresh button — the report is
  computed on read, so a control to recompute it would write on read.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* chore(migrations): add the event listing-quality columns + backfill

Adds quality_open_count (indexed) and quality_check_version to events and
_events_v.

The generated migration was trimmed: its diff base is the newest-by-filename
snapshot, which was authored on a branch predating schedule_last_date, so it
re-emitted that column's DDL for app_cards/events and both version tables.
Replaying it would fail on ADD COLUMN and abort the in-process boot migration.
The .json snapshot is left as generated — it holds the full current schema and
heals the chain for the next migrate:create.

scripts/backfill-event-quality.ts restamps rows written before the columns
shipped (NULL sorts as "no open items", burying the worst listings) and rows an
older check definition wrote. Dry run by default, re-runnable, and it passes
skipVerifyHook so a backfill can't reset every event's verification cycle.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(events): cover the listing-quality wiring

Everything the pure unit lane can't reach: the skip states as they arrive from
real hooks, the all-locale title read, the stored columns after a partial
write, and the read cost.

The two cost assertions were mutation-checked — removing `defaultPopulate` and
the `findMany` guard each makes its test fail, so neither passes vacuously.

Two fixture notes worth keeping:
- verifyOnSave resets verificationStage on every save, so a terminal stage
  passed to create never survives; the skip cases set it with skipVerifyHook.
- The all-locale test localizes while the event is still a draft, then
  publishes. A locale-scoped title update on an already-published event
  silently doesn't persist — reproducible on main with none of this feature's
  hooks attached, and not the case for a published Page. Pre-existing and
  Events-specific; flagged in the PR, not fixed here.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* refactor: simplify per /simplify pass

- Compute the description plain text and the address phrases once per report
  and pass them on the check context. Eight checks read them, and each read
  walked the whole Lexical tree / re-parsed the address group.
- Replace the `check.tier !== 'title'` filter with a `requiresHandWrittenTitle`
  property on the check itself. Grouping metadata was carrying evaluation
  logic, so a check couldn't state its own precondition.
- Extract the request-scoped promise memoization both Events hooks now need
  into @/lib/utilities/requestMemo; eventTitle.ts had the only copy.
- Drop three exports nothing imports (EVENT_QUALITY_CHECKS_BY_KEY,
  containsWeekday, CheckContext).

Skipped: consolidating the three lexical plain-text extractors (mine
deliberately emits block newlines; retrofitting the other two would change
unrelated behaviour — worth its own ticket), lazy WEEKDAY_NAMES (a few ms once
per boot), and parallelising the backfill's writes (the sibling
backfill-schedule-last-date is sequential for the same connection-pool reason).

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(events): prove the backfill's empty-patch update actually persists

Code review flagged that backfillEventQuality relies on
`payload.update({ data: {} })` running stampEventQuality — untested, and a
no-op there would have the script report success while every column stayed
NULL.

It does persist. The test corrupts a row through the adapter (the only way to
get a stale value, since the hook stamps every write), then asserts the dry run
leaves it alone and the applied run restores the computed count and version. A
second pass is a no-op.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(rules): record the findMany list-read guard and the new lib folders

`defaultPopulate` only covers relationship hydration — a list read is a plain
find, so an expensive afterRead still runs per row. The `findMany` flag is the
guard, and it wasn't written down anywhere. Adds it beside the defaultPopulate
section, with the paired "cheap stored column for what the list sorts on"
pattern, and lists eventTitle/ + eventQuality/ among src/lib's domain folders.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* chore(migrations): regenerate the quality columns against the merged chain

Merging main brought in 20260803_221051_registrations_full_flag, whose snapshot
is now the newest by filename. The previous migration's own snapshot predated
it, so the next migrate:create would have re-emitted registrations_full — the
same out-of-order trap this branch had already worked around once, just handed
to the next author.

Regenerated so the committed .json is the full merged schema; a follow-up
migrate:create now finds nothing, so the chain is healed rather than deferred.

The generated .ts needed the same trim, and a wider one: main's snapshot
predates four merged changes, so the diff re-emitted contact_email,
address_venue_name, sy_atlas_translations.event_title and a destructive
drop/recreate of enum_regions_level. Only this branch's two columns are kept —
the file comment names each one and the migration that already ships it.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(events): stop the quality report's all-locale read hijacking the request

The report's afterRead runs during a published update, and its two nested
reads were handed the caller's own `req`. Payload's createLocalReq assigns
straight onto that object (`req.locale = localeCandidate`, plus
`fallbackLocale`), so `locale: 'all'` didn't scope to the nested read — it
repointed the whole in-flight request. Every later step of that write then ran
under `all`, and a locale-scoped title write was silently dropped: saving a
German title on a published event reported success and persisted nothing.

Both nested reads now get a shallow copy (@/lib/utilities/localeIsolatedReq).
`context`, `transactionID`, `user` and `payload` still carry over by reference,
so memoization, the transaction and access control are unchanged — only
locale/fallbackLocale become the copy's own.

I previously mis-diagnosed this as a pre-existing Events bug: the earlier
bisection disabled both new hooks but never the new *field*, so the afterRead
still ran. Running main's Events.ts against the same probe is what settled it.

The int spec's draft-then-publish workaround is gone — it now writes the
localized title directly on a published event, plus a dedicated regression
test. Both fail if the copy is removed.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* refactor: simplify per /simplify pass

- The afterRead's cheap-exit called buildEventQualityReport just to read its
  skip flag, walking the description tree and running every document check
  before throwing the result away. It calls shouldSkipQualityChecks directly.
- Trim the two localeIsolatedReq call-site comments; the helper's own doc
  comment is authoritative and repeating it invites drift.
- Document the locale-isolation constraint in .claude/rules/collections.md so
  the next nested cross-locale read doesn't reintroduce the bug.

Skipped: refactoring src/collections/Pages/appConfigCache.ts to use the new
memoizeOnRequest — a real duplication, but in a file this branch doesn't
otherwise touch.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(rules): list the two new src/lib/utilities helpers

project-structure.md enumerates that folder's contents, so requestMemo and
localeIsolatedReq have to appear there or the list reads as complete while
being wrong.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(scripts): load .env.local ahead of .env in the quality backfill

#617 made the shell environment win over .env files and pinned the convention
with tests/unit/env-file-precedence.spec.ts. This script was written against
the older two-call form (`.env` then `.env.local` with override: true), which
the new spec rejects — it turned CI red on the merge commit.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* refactor(events): drop the quality backfill; the Atlas seed stamps its own rows

Production has no events yet and is seeded from the Atlas import, so there are
no pre-existing rows to repair — the backfill had nothing to do. Every event
reaches the database through `upsert`, which goes through the Local API, so
`stampEventQuality` writes both columns on the way in.

Removes scripts/backfill-event-quality.ts and src/lib/eventQuality/backfill.ts,
and puts the guarantee where the rows are made: the batch that finishes the
events collection calls verifyEventQualityStamps() and warns if any row lacks a
stamp. Scoped past the excluded duplicates and trashed rows — this import
refuses to touch those by design, so it can never stamp them and their absence
says nothing about the hook.

Verified against the local database: 509 events, all stamped NULL beforehand,
490 stamped after `pnpm seed atlas --update`. The 19 left are exactly the 17
excluded duplicates plus 2 trashed rows. The check's own query returns 0 now and
490 before, so it isn't silent by construction. Values are a real distribution
(99 events clean, 170 with three open items), not a column of zeros.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(events): make the recommendations readable at a glance

Six changes from review of the panel in use:

- Show a percentage, not a ratio. "79%" reads as progress; "11/14" made a
  manager do arithmetic to find out how they were doing.
- Give every check a separate passing wording. A tick beside "The description
  repeats the address" read as an endorsement of repeating it — the opposite of
  the point. Checks now carry `label` (the imperative recommendation) and
  `passedLabel` (the state already reached), and a test refuses a check where
  the two are the same string.
- Print the one-sentence reason under each open recommendation instead of
  hiding it in a hover title. A manager shouldn't have to discover why they're
  being asked for something. Passing rows stay one line, folded away by default.
- Rewrite "Say a little more" as "Say more about what to expect", and say what
  to write: who comes, what happens, whether it suits a beginner, what to bring.
- Fold the language into the sentence in bold ("Add a title in **German**")
  rather than a pill that never said what it qualified — and only when the event
  is judged in more than one language, which is the rare case. Phrased "in
  %{language}" so vowel-initial names don't render "a English title"; a test
  guards the article.
- Drop `website.missing`. A website is optional and a listing that says
  everything in place is better than one that sends a seeker elsewhere. A
  website still counts toward `contact.none`.

QUALITY_CHECK_VERSION → 2, since the document-scope set changed and stored
counts from v1 aren't comparable. Existing rows restamp on their next save.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(events): fold the recommendations into six, and cap the title

Thirteen checks meant a thin listing showed six near-identical rows about its
description. Six checks that *name* what they found say more in less space:

- description presence and length are one finding, `description.insufficient`,
  whose detail distinguishes "nothing here yet" from "too short to tell a
  seeker much";
- everything redundant in the description is one finding,
  `description.redundant`, naming what it found — "Take out the address, which
  appears above with a map, and the day and time, which the schedule keeps
  right on its own";
- everything wrong with a hand-written title is one finding, `title.unhelpful`,
  and the recommendation is to clear the field: an empty title fills in from
  the venue and translates itself, which is better than any of the wordings it
  was flagging.

Checks can now carry a `detail(ctx)` alongside `evaluate`, called only on
failure; the panel shows it in place of the static blurb.

**Fixes the translation check**, which was wrong: a blank title is composed per
locale from that locale's own template, so it is never untranslated. It now
fires only when the default locale carries a title a manager typed — which is
the only way another language ends up showing English.

Adds `maxLength: 100` to the title, matching the address fields. The longest
Atlas title is 94 characters and none exceed 100, so it binds new writing
without locking anyone out of a listing they already have. It's Payload
validation, not a column width — verified that migrate:create emits nothing.

Also restores two things a careless earlier edit to Events.ts dropped without
any check noticing: `required: true` on the title, and `contactName`'s place in
the contact row. An int test now pins that shape.

QUALITY_CHECK_VERSION → 3.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(events): rewrite the recommendations to the five specified checks

Replaces the previous set with exactly five, in the wording given:

1. description.missing     — absent or under 60 characters
2. description.quality     — repeats the address, day/time, contact, a link or
                             a past date; the subtext names which
3. title.quality           — same, for a title a manager wrote; skipped when
                             the field is blank, since there is nothing of
                             theirs to judge
4. images.insufficient     — fewer than three photos
5. translations.missing    — the event runs in several languages and the title
                             exists in some but not all; the subtext names them

Drops the contact check, which wasn't in the specified set.

Two design points the tests forced out, both worth keeping:

- `translations.missing` is document-scope (one finding naming every language)
  but reads localized data, which a write hook cannot see. It's therefore
  excluded from the stored `qualityOpenCount` via `dependsOnLocales` — counting
  it would make the column disagree with the report on every multilingual
  event.
- It also has to ignore a language ticked in the save currently in flight, or
  choosing German reports a missing German translation in the same breath.

Panel: the tier headings are gone — five checks don't warrant them — so the
model returns one flat ordered list instead of groups.

Title: rejects a link, composed with Payload's own text validator rather than
replacing it (`sanitize.js` installs the default only when a field has none, so
a hand-rolled validator would have silently dropped `maxLength: 100`).

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(events): de-localize the title, and put all check copy in one file

The Atlas widget translates client-side, so a per-locale title column bought
nothing and cost a great deal: the report needed an all-locale read per event,
a pending-locale handshake between the write hook and the read hook, and a
translation check whose semantics we got wrong twice. `title` is now one plain
column and all of that machinery is gone — the report is a flat list of checks
with no locale dimension at all.

- The translation check is removed, as is `perLocale` from the report, the
  language-bolding in the panel, and the all-locale `findByID` the afterRead
  used to make. The auto-fill now composes from the default locale rather than
  `req.locale`, so the one stored value doesn't depend on which locale the
  manager happened to be editing in.
- `description.quality` is skipped outright while `description.missing` fails,
  via a `skipWhenFailed` precondition. Two rows about one empty field is one
  too many, and a skipped check is not a passing one — it doesn't pad the tally.
- Passing checks now sit in the same list below the open ones, faded with a
  green tick, instead of behind a collapsible.
- All wording moves to `src/lib/eventQuality/copy.ts`, which is the only file
  to edit to change what a manager reads. `checks.ts` keeps the logic and
  spreads the copy in.

The migration is NOT in this commit — the repo blocks hand-editing generated
migrations, and the generated one is lossy (it drops events_locales before
adding events.title, so every title would vanish). Handed to the user with the
corrected statement order.

QUALITY_CHECK_VERSION → 5.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(events): follow the de-localization through the seed and the schema

Sweeping for what the title's de-localization made untrue:

- The Atlas importer's own comment promised a "localized auto-fill". Its code
  needed no change — it already writes `title` with no locale, so the value
  lands in the single column — but the comment did.
- seeds/atlas/AGENTS.md said the auto-fill "translates per locale". It doesn't;
  the widget translates the composed title client-side.
- The `sy-atlas-translations` `event.title` description promised the templates
  localize. Only the default locale's set is read now; the description says so.
  Confirmed with migrate:create that a description-only edit needs no migration.
- The Events live-preview comment said `locale` was there so the localized
  title previews.

Also replaces a vacuous test of my own. `expect(field.localized).toBeFalsy()`
proves nothing — Payload strips `localized` during sanitization, so it passes
either way. It now writes the title in Czech and reads it back in English with
the fallback off, which only holds for a single shared column (same approach as
the `website` case in events.int.spec.ts).

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(atlas): adopt the real question set and stop erroring on unimportable rows

326 errors on every `atlas --update` run, 320 of them two bugs:

**The question contract was invented, not observed.** EVENT_REGISTRATION_QUESTIONS
held five placeholder questions nobody had ever collected an answer to, and its
`additionalProperties: false` schema rejected every real answer in the dump —
310 of 886 registrations, which stored answers under `questions`, `experience`,
`aspirations` and `referral`. It is now those four, named with the dump's own
keys so the importer needs no translation layer. The `experience` and
`referral` labels carry over unchanged; the other two are the questions Atlas
actually asked.

That also fixes a quieter loss: `mapRegistrationQuestions` only knew how to map
two of the four flags and *warned away* the rest, silently dropping the
`questions` toggle on 435 events and `aspirations` on 78. It is now a
pass-through, and warns only on a flag the contract doesn't define.

**29 users held junk where an email should be** — "jbk", "dfsjdhflskdhf",
someone typing into a form. Unimportable by definition, so they're skipped by
name instead of erroring.

The remaining 6: an inactive event whose only contact is a Meetup page now
passes, because the rule demanding a *phone* has been relaxed to demand a
contact — any of phone, email, website or online URL, which is what its own
comment always claimed it meant. `contactName` is required only alongside a
phone now, since an event reachable by email has no one to name.

Also names the failing row in seed errors. `Upsert registrations: invalid` × 291
told an operator nothing about which rows to look at; it now carries the
identifier the reporter already had in hand.

The dead placeholder questions are removed from the Atlas translations schema
(they live in a JSON blob, so no migration).

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* chore(migrations): replace the registration-question columns

Drops the five placeholder question toggles and adds the four Atlas ones.
Generated in the drop/add form rather than as renames — signed off as
acceptable: production has no events yet, so there are no toggles to carry
across. On a database that does hold them, `prior_experience` → `experience`
and `referral_source` → `referral` would need to be renames instead.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(atlas): clear the last of the importable seed errors

With the rows now named in the report, the stragglers were diagnosable:

- **Two archived events failed on every run** with `Not Found`. Payload appends
  `deletedAt exists: false` to every read on a trash-enabled collection, so the
  importer's find-then-update couldn't see a trashed row — the trap in
  .claude/rules/collections.md, which `preloadCollection` was already fixed for
  but `upsert` was not. Both now pass `trash: true` (a no-op where trash is off).
- **A dormant event lost its only phone number.** The importer paired name and
  number — `!!name && !!phone` — so a number with no name against it was thrown
  away, leaving the listing with no contact route and failing validation.
  `contactName` is no longer `required` either: it's a nicety, and refusing a
  real number for want of one helps nobody.
- **The admin account collided with Atlas manager #45.** Same email, no
  `legacyId`, so upserting on `legacyId` tried to create a second manager and
  hit the unique constraint. Upserting on email instead would have overwritten
  the account — resetting its password and `type` from the dump. It now adopts
  the existing row: events owned by that manager still resolve, and the account
  is left alone.

`atlas --update` now reports 4 errors, down from 326, and all four are the same
external flake: Mapbox failing to geocode a region (Alberta, Saskatchewan,
Basilicata, East), which leaves it on manual location where coordinates are
required. The count moved between runs on identical data — 1, then 4 — so it's
rate-limiting, not the dump.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(seeds): correct the Atlas user and registration expected counts

The last two verification failures weren't missing data — the constants were
unreachable. `users: 755` counted the 29 rows holding typed-in junk instead of
an email as importable; they never could be, so every run failed on a target
that could not be hit. The real ceiling is 717 unique addresses, which is
exactly what the database holds. `registrations: 886` likewise counted the 27
rows belonging to those registrants; 859 is the importable figure, and again
exactly what is there.

Both now carry the derivation, and a unit test recomputes them from the dump —
the same guard the region count already had, and for the same reason: a
constant that drifts above what can be imported fails every run, and one that
drifts below quietly stops checking anything.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(seeds): pass trash:true on the preloaded update path too

The previous commit patched only the fallback find-then-update. `upsert` takes
the preload path whenever the collection was preloaded, which is the normal
case — and `preloadCollection` deliberately includes trashed rows, so the id it
hands back can be one. The update then refused it with `Not Found`, which is
why the two archived Atlas events survived the first fix.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(events): pin the trashed-row update the importer depends on

Asserts both halves: an update targeting a trashed event throws without
`trash: true` and succeeds with it. That asymmetry is the whole bug behind the
two archived Atlas events failing every seed run, and nothing in the suite
covered it.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* refactor: simplify per /simplify pass

- Close the remaining `trash: true` gaps in BaseImporter. The two archived
  events exposed the bug on `upsert`'s two paths; the same latent one sat in
  the slug-collision recovery finds (a trashed row still occupies its slug),
  in `findByNaturalKey` (an existence check blind to trashed rows reports
  "absent", and the caller creates a duplicate on the key the trashed row
  holds), and in the per-locale translation update. All no-ops where trash is
  disabled.
- Batch the manager adoption lookup. It was one `find` per manager — 327 round
  trips for what is one small read of the accounts Atlas didn't create.
- Drop four heuristics helpers from the eventQuality barrel that nothing
  outside the module imports.

Skipped: memoizing `redundantParts` between `evaluate` and `detail`. It's two
extra regex passes over one description, only for a check that already failed,
and only on an edit-view read — the review justified it by a 25-row list view,
but list reads skip the report entirely via the `findMany` guard.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(events): correct the title hook's comment after de-localization

It still said `title` is localized and "computes per save-locale". The code was
already right — it composes in the default locale — but the comment described
the behaviour this branch removed.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(rules): record the trashed-row *write* trap, and where the panel copy lives

The trash rule covered the existence-check form of the bug — a find that misses
a trashed row and creates a duplicate. It didn't cover the write form, which is
what cost this branch two seed runs to find: an update addressing a trashed row
by id throws `Not Found` without the flag, even when the id came from a query
that passed it. Fixing the read is not enough.

Also points `src/lib/eventQuality/` at `copy.ts` as the single file to edit for
what a manager reads.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(events): let the admin save a blank title, as the field tells you to

The field's description says "Leave blank to fill in from the venue", and the
server does exactly that — `eventTitleBeforeChange` composes the title and
Payload validates afterwards (hooks at line 58 of
`fields/hooks/beforeChange/promise.js`, `validate` at 86). But **no hook runs in
the browser**, so the admin's own validation refused the blank `required` field
before the request was ever sent. The workflow was only reachable through the
API.

`eventTitleValidate` now permits a blank title when there is an address to
compose one from, and keeps demanding one when there isn't — an online event has
no venue to name it, so the guarantee that every event carries a title still
holds. `required: true` is untouched.

Moves the validator next to the hook it is paired with: the two are one
behaviour (the hook fills, the validator permits blank *because* the hook will
fill), and splitting them across files is what let them drift apart.

Covered both ways: a unit spec drives the validator directly, which is the
browser's path, and the integration spec pins that a blank title with an address
saves as "Evening Meditation at Sunrise Hall" while one without an address is
still refused.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(events): name an online event after its region

An online event has no address, so `addressPlaceName` returned nothing and
both halves of the title behaviour bailed: the hook handed the blank value
back, and the validator refused it. The importer papered over this with a
hardcoded "Online Sahaj Yoga Meditation" for every online listing in the
dump.

`region` is required on every event, so there is always a place to name a
listing after. `resolveTitlePlace` prefers the venue (or street) and falls
back to the region's name — "Evening Meditation at Dublin". The read is
memoized per request like the templates, and passes a narrow select because
it forwards the caller's request through the client-query gate.

The validator mirrors it, permitting a blank title when a region is
selected; the browser only holds the region's id, so it trusts the name to
resolve — `name` is required on every region.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(events): recognise a region-derived auto-title as auto-filled

`isAutoFilledTitle` detects the auto-fill by rebuilding it from the event's
address, so an online event — auto-titled from its region — looked
hand-written and `title.quality` judged it. Benign on today's data ("Evening
Meditation at Dublin" passes), but it credits a manager for a title we wrote,
and a region whose name carries a weekday would draw the self-contradictory
"leave it blank and one will be written for you".

Fall back to matching the template's shape around `%{place}` when, and only
when, there is no address to recompose from. An event with a venue keeps the
exact comparison, so prose in the auto-fill's shape is still judged as prose.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(events): enforce the title guarantee in the hook, not in `required`

`eventTitleValidate` has to permit a blank title — the browser runs no hooks,
so `required` would refuse the "leave it blank" workflow before the request
was ever sent. But supplying `validate` replaces the default that enforces
`required`, so permitting the blank also disarmed it server-side: if the
region read failed (a trashed region, a DB blip) the hook handed back the
blank value and nothing stopped it being saved.

Move the guarantee to the one place that knows whether the auto-fill had
anything to work from — the hook now throws a ValidationError against `title`
when it comes up empty. The validator keeps only the cheap question it can
actually answer in the browser: is a place plausible.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(rules): record when a validate may permit what `required` forbids

The conditional-validation rule says never return true for an empty value.
The Events title field has to, and the compensating design (the hook throws,
the validator only gates the round trip) is the part worth writing down —
along with the two Payload facts behind it: no field hook runs in the browser,
and a custom validate replaces the default that enforces `required`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(events): let a draft keep an empty title

The hook's new throw stood in for `required`, but not the way `required`
actually behaves: Payload skips it entirely for a draft, so an incomplete
draft is legal by design. Throwing unconditionally broke that — caught by
atlas-collections.int.spec.ts, which drafts an online event with no address.

Skip the throw on a draft save. The guarantee is that every *published*
event carries a title, which is the one that was ever enforced.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 8, 2026
…tings (#621)

* feat(atlas): refresh seed data from the 2026-08 dump and re-groom listings

Re-extracts seeds/atlas/data/ from the August 2026 Atlas dump (the previous
data ended October 2024), ports the #605 curation forward wherever the raw
source is unchanged, and re-grooms the delta under the same rules: 230 new
events groomed from scratch, ~100 upstream-edited events re-groomed three-way.

Data: 653 event rows (673 extracted, less 11 re-dropped #605 duplicates and 9
newly confirmed ones), 53 shared venues (6 new venue merges), 5 new countries,
curated schedule.weekday for 7 events whose own text names a different day.

Code: parseSchedule maps monthly_2nd/monthly_last to weekNumber 2/-1; the
importer reports events whose Atlas source row was deleted upstream (64 in
this refresh) for hand-trashing; extract.ts normalizes venue text fields.

Counts and invariants recomputed: expectedCounts (managers 495, regions 653,
users 1864, events 652, registrations 2007, clients 31) and the
atlas-events-data invariant suite.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(atlas): resolve import collisions surfaced by the local end-to-end seed

The full local reseed exposed three gaps: Atlas holds five city rows twice
(new AREA_MERGES for Nottingham, Colombier, Compiègne, Martinique, and
Province Québec onto the Québec node) and a second row for the München
Am Lilienberg building (VENUE_MERGES 5063 → 458); event #762's groomed room
exceeded the field's maxLength of 100; and Atlas *renumbers* geo nodes
(Paris moved area 438 → 1208), so a stale doc under the old id blocks the
renumbered node's create on the unique slug/mapboxId —
reportUpstreamDeletedRegions now enumerates those docs for hand-trashing,
mirroring the events-side report.

Region counts follow: 595 source geo nodes + 52 shared venues = 647.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(atlas): set verification floors to the proven-reachable counts

The clean-DB end-to-end reseed (stale docs removed, three converged runs)
leaves exactly two permanently-unimportable rows: region:East (#42, invalid
source coordinates) and event #4958 (no Atlas area, so no resolvable region).
regions 647 → 646 and events 652 → 651 so verification measures what the
import can actually reach; the invariant spec derives the regions floor with
the same -1.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(atlas): re-attach merged duplicates' registrations to their survivors

The wiped-DB fresh seed surfaced two registration losses the update-mode runs
had masked: 54 registrations pointed at merged-away duplicate events and were
silently skipped (a merge is not a delete — #195's 39 registrants belong to
#603's class), and the paginated id-map rebuild couldn't see the 2 events that
import straight into the trash, dropping their registration too.

MERGED_EVENT_TARGETS now routes a removed row's registrations to its merge
survivor, the rebuild passes trash: true, and the verification floors are set
to fresh-state-proven values: events 649 (2 archived rows land in trash,
uncounted), registrations 2005 (only the 2 rows with neither event nor
survivor drop). The invariant spec derives the registrations floor with the
same rules.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(atlas): skip the registration on a trashed event instead of phantom-creating it

Isolated with a bare REST create: Payload returns 201 with a doc id for a
registration whose event relationship targets a trashed doc, then silently
rolls the insert back — the row never lands (the sequence advances, the
count doesn't). The trash-aware id-map rebuild therefore made #252 (on the
archived-to-trash Floriade event #199) log "created" on every run while
never persisting.

Trashed events now stay out of the registration id-map, turning that row
into a visible, counted skip. The registrations floor is 2004 (2034 source
rows, less 27 junk-email registrants, 2 events with neither row nor merge
survivor, and this one), derived identically by the invariant spec, which
also pins the archived-on-import set to #75/#199. The stale per-collection
totalItems metadata (886-era counts) is updated to the 2026-08 dump.

Full wiped-DB reseed now verifies green on all six collections with exactly
the two permanent source-data errors (region:East invalid coordinates,
event #4958 with no Atlas area).

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Ardnived added a commit that referenced this pull request Nov 5, 2026
A registry of named checks flagging an event listing as incomplete or
low-quality, with a pure report builder over it. Advisory only — nothing here
blocks publishing, hides an event, or gates verification.

Three decisions the design rests on:

- An auto-filled title is never judged. The auto-title is built from the
  address, and #605 blanked 78 generic titles precisely so they'd fall back to
  it, so a naive "title restates the address" rule would fail the majority of
  listings. Detection is by recomposition (autoTitle.ts), across every slot and
  against the locale's own templates as well as the English defaults.
- Checks split into document scope (description, images, website, contacts —
  none localized) and per-locale (title quality, translation coverage), so the
  report can answer "which of my languages is missing a title".
- Locale scope is the default locale plus the event's own `languages`, not all
  19 — which would show 18 failing checks on nearly every listing.

Refs #609

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Nov 16, 2026
* fix(regions): show the Events tab at every region level

#1145 hid a region's Events tab above a city, because `events.region`
admits only a city or a venue and the join is direct. That took the tab
away from every country and region. The tab now shows on every saved
region again, whatever its level.

`EVENT_REGION_LEVELS` existed so the tab condition and the `events.region`
picker could not narrow differently. With the condition gone, the picker
is its only consumer, which `lib-boundary.spec.ts` refuses for a
`src/lib` module, so the levels go back inline in `filterOptions`.

The "Import classes" edit-menu item stays: it offers the link from every
tab, not only the Events tab's heading.

No schema delta: admin conditions only, so no migration and no type
regeneration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(events): keep the level rename check on the picker

Deleting `EVENT_REGION_LEVELS` left `['city', 'venue']` as plain strings:
Payload's `Where` does not type `in`, so renaming a level would no longer
fail typecheck here. `center` → `venue` (#605) is a rename this repo has
already made once.

`satisfies Region['level'][]` restores that check at the cost of one type
import, and leaves the picker's behaviour unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWhhTBryJRfAQLESKH

* test(regions): pin the Import classes edit-menu item

The assertion went with the level-gate cases, leaving the edit-menu
registration untested. It is still the only "Import classes" surface a
tab other than Events renders, since the Events tab's heading renders
only while that tab is open.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWhhTBryJRfAQLESKH

* fix(regions): list the subtree's classes on the Events tab

A join resolves one reverse lookup, and `events.region` admits a city or
a venue, so `on: 'region'` leaves the tab empty on a country and on a
region — the emptiness #1145 answered by hiding the tab there. The child
tabs reach their descendants through `breadcrumbs.doc`; events carry no
breadcrumbs, so a join cannot carry the subtree.

`RegionEvents` renders Payload's own `RelationshipTable` — the element
`JoinField` itself renders — with `region: { in: descendantRegionIds(…) }`
in place of the join's `on`. The table re-queries through `getTableState`
under the reader's own access, so the predicate asks for rows rather than
granting them, and the columns, pagination and document drawers are the
join table's. The stored join still answers `on: 'region'` for every API
reader; the widening is the admin table's alone.

Replacing the `Field` replaces the heading, so the component renders
`ImportClassesLabel` itself. `allowCreate` follows the stored level, not
the form's: only a city or a venue can hold a class directly, so only
there does seeding `region` give the picker's own `filterOptions` a
document it accepts. The read that supplies that level is the access
gate a server field component owes (#1126).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZ5G3bpSAJbneXiqrA

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: sydevs-bot <[email protected]>

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-605 — a0945159 Deployed Aug 3, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant