Repository navigation
feat(translations): rewrite the Sahaj Atlas schema by widget view, seed all ten locales, and gate availableLocales on them - #750
Conversation
Replace the 2-year-stale 2-namespace schema with one derived from the widget's live catalogue, grouped by the view that owns each key. - 11 tabs (Common, Countries, Search, Filters, Online, Event, Calendar, Registration, Share, Compact, Emails), 33 leaf groups, 193 widget-facing keys. 23 keys dead in the widget are dropped (Appendix C of #706). - `event.display.sessions_count` becomes `plural: true`; the six copy budgets from the widget's own i18n-budgets.test.ts become `maxLength` + `strict: true`, so an over-length string cannot be saved. - `emails` and `event.title` are copied verbatim — both hold live production data and keep their columns, keys, values and limits. Seeds carry the widget's shipped translations for all ten locales, so a translator starts from what is on screen today rather than from English placeholders derived from key names. A key a locale has no translation for is omitted, never blank: the client-read English merge (#705) serves English for it. Refs #706 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B6BLLCtacuxznLkwvu13vf
…r locale `pnpm seed translations` wrote English placeholders derived from key names into one locale and never published. It now loads one file per widget locale and publishes each locale on its own, which is what makes the ten selectable in `sy-atlas-config.availableLocales` (#705's validator rejects a locale whose translations are not published). `publishAllLocales` cannot be used here: it scopes itself through `filterAvailableLocales`, which answers `['en']` for a request with no user — every seed request. `publishSpecificLocale` takes Payload's single-locale branch instead. `emails` and `event.title` hold live production data. No seed file carries them, and English alone fills a key that is blank today — the whole merged group is written back, because a JSON column is replaced wholesale and sending only the blanks would delete the translations beside them. Refs #706 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B6BLLCtacuxznLkwvu13vf
…rite Refs #706 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B6BLLCtacuxznLkwvu13vf
Drops the five columns whose groups no longer exist (`common`, `region_locations`, `region_venues`, `event_details`, `event_timing`) and adds the twenty-six new ones, on both the live and the versions table. `emails` and `event_title` hold live production data and are untouched in both directions. One hand-edit, documented in the file: `up` also nulls `event_recurrence`, `registration_form` and `share`. All three keep their column but get a new key set, and since #705 each JSON column validates against its own schema on every save of the global — so a locale still holding an old-shape blob would be unsaveable from the admin, on a save that never touched translations. The three hold seed placeholders only. Generated with the answer `create` for every rename-vs-create prompt, then validated with `migration-validator` and applied on a database that ran the old schema. Refs #706 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B6BLLCtacuxznLkwvu13vf
…ish step
Three suites, each covering something the others cannot:
- `tests/unit/atlas-translations-schema.spec.ts` pins the three groups that
mirror code rather than copy (`registration.questions` ≡
EVENT_REGISTRATION_QUESTIONS in order, `event.title` ≡ EVENT_TITLE_SLOTS,
`emails` ≡ EMAIL_STRING_DEFAULTS), every seed against the declared keys,
and the rule that a translation may not invent a `%{x}` English lacks.
It also states the schema's size, so no other assertion in it can pass by
walking an empty tree.
- `tests/int/translations-globals.int.spec.ts` moves to the new tab set and
the full ordered 33-name JSON field list — `chrome` appears three times,
so an unordered subset would let a dropped sub-group through. It also now
asserts a strict key over its `maxLength` is refused on write.
- `seeds/tests/atlas-translations-import.test.ts` runs the importer against
a real database: ten locales published, a pre-seeded `fr` emails value and
a tuned `en` auto-title both surviving, blank English email chrome filled
from the defaults, `cs` carrying its `few` form, `fr` carrying no
`registration.form.title`, and all of it stable across a re-run.
That last suite caught a real defect first: `publishSpecificLocale` selects
the single-locale branch but does not decide the status, so every locale
was written and left `draft` — the one state `availableLocales` refuses.
The write now carries `_status: 'published'`.
Refs #706
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B6BLLCtacuxznLkwvu13vf
…d coverage - `src/globals/AGENTS.md`: the eleven view tabs, why there is no Region tab, and a box on the two Atlas groups that hold live production data. - `seeds/AGENTS.md`: the `translations` script was missing from the table entirely. Adds it, plus the three properties the Atlas path must keep — `_status: 'published'` in the data, why `publishAllLocales` cannot be used, and the two groups a seed never writes. - `tests/COVERAGE.md`: the new schema, seed and importer rows. `available-locales.int.spec.ts` moves off `common.loading`, a key the rewrite removed, onto `countries.title`. Refs #706 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B6BLLCtacuxznLkwvu13vf
…ad fails
Two findings from the review pass, both about the same distinction: a read
that failed is not a read that came back empty.
- `readAtlasGlobal` returned `null` for both, so a database error made
`fillBlanks` treat every key as blank and write English defaults over
`emails` and `event.title` wholesale — the one thing this seed exists to
avoid. It now returns `{ ok }`, and a failed read omits both groups
exactly as every other locale does. A new case in the seed spec drives a
throwing `findGlobal` and was watched failing against the old code.
- The migration's `down` restored the old columns but left
`event_recurrence`, `registration_form` and `share` holding the NEW key
sets, which the old schema rejects just as flatly — so a rollback left
every seeded locale unsaveable. It now nulls them, mirroring `up`.
Verified by rolling the chain down and back up.
Refs #706
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B6BLLCtacuxznLkwvu13vf
|
🚅 Deployed to the SahajCloud-pr-750 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff tracks #706 closely and its riskiest claims hold: emails and event.title are deep-equal to the old schema, and the columns the migration nulls are exactly the kept ones whose key sets changed. The claim I cannot check here is the migration's own — it destroys three columns of real copy, asserting they hold placeholders only.
Findings
should-fix—upnulls three kept columns,downagain → migration:91consider—pickSlotsrestates a type the constant carries → import.ts:118consider—publishOptionsmirrors thelocalebeside it → import.ts:336consider— nothing pins the catalogue to the widget → spec:192
Checked
Both schemas parsed: 33 leaf groups, 193 widget keys, kept subtrees deep-equal, only those three columns' keys changed. Ten seeds: 0 undeclared, 0 blank, 0 over maxLength. Against SahajAtlasWeb@4380e18, data.en.json matched by value to the 219-key en bundle: 0 orphan seed values, 19 orphans, all Appendix C and unreferenced.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
|
||
| // Every other assertion here filters a list. This one states its size, so | ||
| // none of them can pass by walking an empty schema. | ||
| it('declares 193 widget-facing keys across 33 leaf groups', () => { |
There was a problem hiding this comment.
This pins the schema against SahajCloud's own constants and the seeds, the half this repo owns. The other half is unpinned: once sydevs/SahajAtlasWeb#198 deletes public/locales/, this schema is the widget's only key source, and a key added or renamed there fails nothing here — it renders blank at a visitor.
This repo already has the pattern: atlas-url-contract.json, pinned by atlas-canonical-url.spec.ts and diffed cross-repo. A follow-up ticket?
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
There was a problem hiding this comment.
Agreed, and the gap is real: once sydevs/SahajAtlasWeb#198 deletes public/locales/, a key renamed there fails nothing here.
I did not file the ticket. AGENTS.md says to ask before creating an issue, and this run has no one to ask. Ask for it and the next run opens it, shaped like atlas-url-contract.json — a committed catalogue file plus a spec, diffed cross-repo.
Leaving this thread open for that call.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The three kept columns were nulled wholesale in both directions, so any copy a manager had translated in the admin was destroyed with no recovery — and "seed placeholders only" was an assertion, not something the migration could rely on. Each UPDATE now keeps every key the direction it moves toward still declares, and drops only the rest. 10 of registration_form's 14 keys and 8 of event_recurrence's 11 are shared between the old and new key sets, so their values survive up() and come back through down(). What is still lost is exactly the copy under a key #706 deletes from the catalogue: share.action, registration.form.{cancel, mailing_list_consent, register_now, thank_you}, event.recurrence.{weekly, monthly, no_recurrence}. jsonb_object_agg over no surviving key yields NULL, which is the emptied state the old statement wrote. The jsonb_typeof guard is load-bearing: without it jsonb_each raises "cannot call jsonb_each on a non-object" on a column holding a scalar or an array and aborts the migration — verified by running the unguarded form against Postgres 16 on such a row. Both directions were run end to end on a real cluster over rows holding old-shape copy, new-shape copy, NULL, {}, [] and a scalar. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QDHYfUsBKxPFvARPPQUcTJ
EVENT_TITLE_DEFAULTS is declared Record<EventTitleSlot, string>, so its keys already are EVENT_TITLE_SLOTS. pickSlots rebuilt the same object and needed an `as string` to do it. Its one call site now passes the constant straight to fillBlanks. The drift it might have caught is already pinned: atlas-translations-schema.spec.ts asserts event.title against the slots. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QDHYfUsBKxPFvARPPQUcTJ
publishOptions.publishSpecificLocale was the `locale` argument beside it at every call site, so the object carried nothing the parameter did not. writeGlobal now takes `publish = false` and passes `locale` through. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QDHYfUsBKxPFvARPPQUcTJ
|
Addressed the adversarial round. Head is 2bdaa0a. Adopted — 3
Open — 1
A routine has no production database credential, so I could not run the query the first thread asked for. The migration changed instead, and the body now names what it still destroys. Lean gate green. The seed spec (9) re-ran against a real Payload and Postgres. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
I could not mark ready here — the dispatch token is not allowed to. Everything else on this item is done, so this is the one step left for you. 🤖 sydevs dispatcher |
|
This draft has had no CI activity for hours and no session holds it. Comment or push to wake me. 🤖 sydevs dispatcher |
One conflict, in `tests/COVERAGE.md`: both sides appended a row to the same coverage table. Kept both — #744's two Sentry rows and this branch's Atlas seed row. `src/payload-types.ts` and `src/globals/AGENTS.md` auto-merged and were verified rather than trusted: `pnpm generate:types` reproduces the merged types byte for byte, and both sides' AGENTS.md paragraphs survive (#705's `stringsSchema` rename beside #706's Atlas tab list). No semantic conflict. `main` brought #756's `jsonField` helper, which rewrites `src/fields/translationsField.ts` — a file this branch never touched — and added no migration, so the branch's migration stays last in `src/migrations/index.ts`. Gate: lint, typecheck, typecheck:tests, 1757 unit tests in 132 files. Targeted: translations-globals, available-locales and the Atlas seed spec, 43 tests, against a real Payload and Postgres. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DEd12ZA8W99LeMM2ukWup1
`main` moved five commits past this branch's base and `tests/COVERAGE.md` conflicted: both sides appended a row to the same table. Kept both — the `#743` guard row stays with the two Sentry rows above it, and #750's translations-seed row follows. Everything else merged clean. The overlap worth checking was `src/lib/env/deploymentEnvironment.ts`, which `credentialRejection.ts` imports: #763 only added `clientDeploymentEnvironment` beside it, so the server-side read is untouched. `main` changed nothing under `src/plugins/sentry/` or `src/lib/endpoints/`. Lean gate green after the merge: lint, typecheck, typecheck:tests, and 1786 unit tests across 135 files. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WMc58cJat8rdZnpNWc4Fnp
Resolves the only conflict, `src/migrations/index.ts`: both branches appended a migration. Kept both, in timestamp order — main's 20260909_161353_atlas_translations_by_view (#750) before this branch's 20260911_235823_pages_app_cards_localize_status. Their DDL is independent: one rewrites the Sahaj Atlas translations schema, the other moves `_status` into the pages / app_cards locale tables. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PBHRDEQqp6sryryeHTMXN4
Resolves the conflicts #750 (the Sahaj Atlas schema rewrite, #706) created. Both branches rewrote a translations global, so the overlap is the one importer, the migration index, and the specs that read both schemas. Four conflicts, each resolved to keep both behaviours: - `src/migrations/index.ts` — all three migrations, in timestamp order: #750's atlas reshape first, then this branch's drop and add. - `seeds/translations/import.ts` — `seedWmWeb` (real English copy, published) beside `seedAtlas` (ten locales, each published). `writeGlobal` takes main's `locale` parameter, so wm-web passes `DEFAULT_LOCALE` explicitly. - `tests/int/translations-globals.int.spec.ts` — main's atlas field set, this branch's wm-web set, one merged docblock. - `seeds/AGENTS.md` — one section covering both globals' real copy and both publishes. `generateExampleData` is deleted, not merged. Each side replaced one of its two callers with real copy, and this branch's own comment said to delete it once #706 took the last one. The plural-expansion fix this branch made to that generator goes with it — `pnpm seed translations` no longer generates data for any global, so the break it repaired cannot recur here. Also repairs the out-of-order snapshot trap (`src/migrations/AGENTS.md`). The two migration snapshots on this branch were generated before #750 merged, so the newest-by-timestamp snapshot described the pre-#750 atlas columns. The next `migrate:create` would have re-emitted #750's DDL and crash-looped the boot migration (#566). Both snapshots now carry #750's atlas tables, and `pnpm db:migrations:create --skip-empty` emits nothing. Verified: lean gate green (lint, typecheck, typecheck:tests, 1778 unit tests); `translations-globals` (23), `wm-web-translations-seed` (7) and `translations-field` (22) integration specs green; `pnpm generate:types` leaves `src/payload-types.ts` byte-identical, so the merged types already match the merged config. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T8bW17CGRLHDEzMz9pTk4m
…-seo-root #750 rewrote the atlas translations schema by widget view while this branch added a `seo` group to the same global. Four files conflicted; two more needed adapting because main renamed a key this branch reads. - `src/migrations/index.ts` — both migrations kept, in timestamp order, so `20260909_..._atlas_translations_by_view` runs before `20260912_..._atlas_translations_seo_group`. The `seo` column name collides with nothing #750 adds or drops, so the DDL is unchanged. - `20260912_..._atlas_translations_seo_group.json` — rebased onto #750's snapshot plus the two `seo` columns. It is the highest-timestamp snapshot, so left describing the pre-#750 schema it would have made the next `migrate:create` re-emit all of #750's DDL and crash-loop the boot migration (#566, `src/migrations/AGENTS.md`). Regenerating it under a new timestamp is unsafe — this branch has already deployed to its preview — and `migrate:create` cannot answer its own rename-vs-create prompt unattended. Verified: `migrate:create` now finds no schema change and no longer prompts, where against the stale snapshot it prompted on `common_chrome`. - `common.free_meditation_classes` became `common.chrome.widget_label` in #750 — same string in all ten locales. The root title's in-locale fallback now reads the new path, and the select descends into `common` rather than taking all seven of its columns. - `src/globals/AGENTS.md`, `tests/int/translations-globals.int.spec.ts`, `tests/unit/atlas-translations-schema.spec.ts` — `Seo` joins `Emails` as the second group no widget view reads, so #750's "one tab per widget view" rule and its three key counts now name both exceptions. - `src/payload-types.ts` — regenerated; carries both `SyAtlasTranslationsSeoStrings` and `SyAtlasTranslationsCommonChromeStrings`. Gate: lint, `tsc` over src and tests, 1804 unit tests. Targeted specs `atlas-seo` + `translations-globals` — 72 passed. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MoEHvcg8TondFU4WSguGcK
Summary
pnpm seed translationswrites the widget's own shipped copy for all ten locales and publishes each locale individually, which is what lets an operator select the ten insy-atlas-config.availableLocales.emailsandevent.titleare untouched: byte-identical in the schema, unwritten by every seed file, and left alone by the migration in both directions.Changes
src/globals/SahajAtlasTranslations/translationsSchema.json— rewritten. Six budgets from the widget's owni18n-budgets.test.tsbecomemaxLength+strict: true;event.display.sessions_countbecomesplural: true.seeds/sy-atlas-translations/data.{cs,de,en,es,fr,hu,nl,pt-BR,ru,uk}.json— new, generated from the widget'spublic/locales/<lng>/{common,events}.jsonthrough Appendix A.seeds/translations/import.ts— the atlas path seeds ten locales, publishes per locale, and preserves the two live-data groups.src/migrations/20260909_161353_atlas_translations_by_view.{ts,json}— new.Preview
scripts/get-railway-preview-url.tscould not discover the alias. The preview builds from this push.Contract impact
public/locales/and reads this global.src/payload-types.tsregenerated: 33 namedSyAtlasTranslations…Stringsinterfaces replace the old union.Migration
src/migrations/20260909_161353_atlas_translations_by_view.tssy_atlas_translations_localesand_sy_atlas_translations_v_locales, drops 5 columns whose groups no longer exist and adds 26.emails/event_titleare untouched.event_recurrence,registration_formandsharekeep their column but get a new key set, and since feat(translations): typed JSON groups, per-locale publish status, and an availableLocales field gated on published translations #705 each JSON column validates against its own schema on every save — so an old-shape blob would make that locale unsaveable from the admin.UPDATEkeeps every key the direction it moves toward still declares, so a value a manager translated survives wherever its key survives: 10 ofregistration_form's 14 and 8 ofevent_recurrence's 11. The first draft nulled the three columns wholesale, which destroyed those 18 too.share.action,registration.form.{cancel, mailing_list_consent, register_now, thank_you},event.recurrence.{weekly, monthly, no_recurrence}. Eight key names, with no home in the new schema by design.jsonb_object_aggover no surviving key yields NULL, which is the emptied state the old statement wrote. Thejsonb_typeofguard is load-bearing: without itjsonb_eachraisescannot call jsonb_each on a non-objecton a column holding a scalar or an array, aborting the migration. Verified by running the unguarded form against such a row.downmirrors the DDL and filters to the OLD key set, so a value that passed throughupunder a shared key comes back. Rolled the whole chain down and back up on a database built by the earlier migrations.NULL,{},[]and a scalar.Test results
pnpm lint && pnpm typecheck && pnpm typecheck:tests && pnpm test:unit(1718 unit tests, 129 files)translations-globals(19),translations-field,available-locales(15),atlas-seo,seeds/tests/atlas-translations-import.test.ts(9)seeds/tests/atlas-translations-import.test.ts(9), against a real Payload and Postgrestests/unit/atlas-translations-schema.spec.ts(49)Manual verification
ADMIN_EMAIL=… ADMIN_PASSWORD=… pnpm seed:prod translations(idempotent), then/admin→sy-atlas-translations: each of the ten locales shows Published./admin→sy-atlas-config→availableLocales: select the ten (enrequired). The validator refuses an unpublished locale.GET /api/globals/sy-atlas-translations?locale=fr&depth=0with a client key returns French, with English inregistration.form.titleandshare.title.GET /api/atlas/seohreflang lists ten again.frin the admin and save — no "unknown key" validation error.Interim: from this deploy until step 2,
hreflangisenonly, and the widget keeps its shipped ten. That is the safe direction.Notes for reviewer
tests/unit/atlas-translations-schema.spec.tsis what holds the two together from here.AGENTS.mdasks before an issue is created, and a routine has no one to ask.seeds/tests/atlas-translations-import.test.ts, not.int.spec.ts. The int project includesseeds/**/*.test.ts; the ticket's filename would never have run.publishSpecificLocalealone did not publish anything — it selects Payload's single-locale branch but the incoming_statusdecides the status. The write carries_status: 'published'. The seed spec caught this; it is not in the ticket.Detail
Key arithmetic. 219 catalogue keys − 23 dead = 196 live. Minus the plural merge (
sessions_count_one/_other→ one declared key) and Appendix B's two consolidations (chip_started+started_on;registration.cancel+report.cancel) = 193. The unit spec asserts that number and the 33 leaf groups outright, so no other assertion in it can pass by walking an empty tree.The consolidations, resolved against the data rather than by rule.
started_onwins overchip_startedbecause onlynldistinguishes them ("Gestart op %{date}"). The report form'scancelwins because onlydeandhudistinguish them ("Abbrechen", "Mégse").Why no seed carries a blank. A key a locale has no translation for is omitted.
registration.form.titleandshare.titleare absent from all nine non-English bundles, so the client-read English merge (#705) serves English for them. A stored blank would defeat that merge, which is why the spec asserts non-blank for every key present.Placeholder safety. A
%{x}a translation invents renders literally in front of a visitor, since substitution works from a fixed set per key. The unit spec compares each locale's placeholder set against English's, falling back to the_otherform for a plural category English does not use.The plural family per locale.
cs,ruandukcarry_few/_many; the rest carry_one/_other. English is asserted not to carry_few— a value there would have been invented.Migration generation.
pnpm db:migrations:createhits drizzle's rename-vs-create prompt (5 drops beside 26 adds) and exits at EOF on non-TTY stdin, assrc/migrations/AGENTS.mdpredicts. Generated through thepayload-cliskill's PTY driver instead, answering create for all 62 prompts, then validated withmigration-validator(4 pass, 1 warn — the expected DROP COLUMN notice).One tool defect hit on the way, filed separately.
.claude/skills/payload-cli/interactive.py's prompt regex isIs (\w+) column in (\w+) table…, but chalk colours those two names on a PTY, so the escape codes break the match and the driver stalls on the first prompt with no diagnostic. A patched copy (stripping ANSI before matching) was run from the scratchpad — the file itself was left alone, because a write under.claude/trips the Protected Paths guard and stalls an unattended run.Not reproduced locally: applying the migration to a dev database still carrying the old schema via
push: true. What was done instead is stronger for the SQL and weaker for the drift case: the whole migration chain was applied on a fresh database, then rolled all the way down and re-applied.Closes #706
🤖 Generated with Claude Code
https://claude.ai/code/session_01B6BLLCtacuxznLkwvu13vf
Generated by Claude Code