Skip to content

feat(translations): declare a key's English in the schema, reconciled on boot - #1218

Merged
sydevs-bot merged 7 commits into
mainfrom
claude/feat-translations-wisdom-sidetext
Nov 22, 2026
Merged

sydevs-bot merged 7 commits into
mainfrom
claude/feat-translations-wisdom-sidetext

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Change outline

A new key's English used to reach production through a hand-written data-only
migration — three near-identical ones in 48 hours, differing only in a table
pair, a key and a value. The declaration moves beside the key, and one generic
pass puts it where the per-key migrations used to.

Contract — the key declares its own English

 wm-web-translations · blocks · general         src/globals/WeMeditateWebTranslations/translationsSchema.json
   wisdom_sidetext:
     type: string
     maxLength: 24                              # advisory: it stands on its side in one line
+    default: Ancient Wisdom                    # the English, declared once

default is a standard JSON Schema keyword and is still kept out of the
emitted schema: Ajv writes a declared default into the data it validates under
useDefaults, so emitting it would make a save store copy nobody typed.
stringsSchema builds its properties explicitly, so there is nothing to strip.

Flow — two readers, one declaration

 a fresh database
   pnpm seed translations                       seeds/translations/import.ts
-    data.en.json carries the key
+    withEnglishDefaults(seed, schema)          # the corpus, plus what the schema declares
+                                               # English only; blank counts as absent here,
+                                               # because a seed run is a deliberate act

 a database that already exists (production, and any preview forked from it)
-  20261119_040000_wm_web_wisdom_sidetext       one migration per key
+  reconcileEnglishDefaults(payload, targets)   src/lib/translations/englishDefaults.ts
+    onInit, after prodMigrations               src/payload.config.ts
+    <global>_locales                           # _locale = 'en'
+    _<global>_v_locales                        # latest: true rows only — a global's update
+                                               # loads the document it changes from that row
   clientEnglishFallback fills a blank key for a client read FROM English,
   so English holding it is what makes every other locale answer

Both statements are one UPDATE per leaf-group column:

SET "blocks_general" = $1::jsonb || coalesce("blocks_general", '{}'::jsonb)
WHERE "_locale" = 'en'
  AND jsonb_typeof(...) = 'object'
  AND NOT coalesce(...) ?& ARRAY(SELECT jsonb_object_keys($1::jsonb))
  • defaults || stored — the right operand wins, so a word somebody chose
    survives and only an absent key takes the default.
  • The ?& test keeps the write off a row with nothing to gain. A no-op
    UPDATE still writes a row version, and this runs on every boot.
  • jsonb_typeof keeps a scalar column out, where the concatenation would
    build an array and void the whole group.
  • Only the table and column names are interpolated, and both come from
    committed source; the values are bound parameters.

Scope — what this does not change

A default lands only where nothing is stored, so retiring a key and
rewording stored copy are both still migrations. The 400-odd keys already in
data.en.json stay there: the corpus is unchanged, and a key declaring a
default is kept out of it so the two cannot disagree.

Preview

The diff touches none of fixture.surfacePaths, so it adds no fixture record. The admin view it changes is already a fixture link target (src/fixture/views.ts:350-351, TranslationsRow → globalDoc('wm-web-translations')).

  • WeMeditate Web translations → Blocks → General — a Wisdom Sidetext row exists under General, carrying its description and a 24-character counter. Its input is empty there: a preview's database is fresh, so there is no stored global for the boot reconciliation to fill and no seed runs at boot. The row's presence is what this link shows.

Contract impact

src/payload-types.ts gains wisdom_sidetext?: string, unchanged by this revision — default never reaches the emitted JSON Schema, so it generates no type. sydevs/WeMeditateWeb is the consumer; its pnpm types:cms reads this repo's main, so the dispatcher's contract sync re-derives it once this merges. sydevs/WeMeditateWeb#269 merged with the entry hand-typed and says so in its own body. No consumer issue is owed.

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh — lint, format, typecheck, typecheck:tests, 3863 unit tests (143s), on the branch merged with current main
  • Targeted specs: ✓ 48 passing across tests/int/translations-english-defaults.int.spec.ts (new), tests/int/translations-globals.int.spec.ts and tests/int/wm-web-translations-seed.int.spec.ts, on the same merge. Unit: tests/unit/translations-english-defaults.spec.ts (10, new), tests/unit/wm-web-translations-seed.spec.ts, tests/unit/translations-seed-meta.spec.ts
  • Build: N/A — Railway builds it on the preview.

Manual verification

  1. On the preview admin, open the link above, go to the Blocks tab, and confirm a Wisdom Sidetext row renders under General with its description and its 24-character limit.
  2. After deploy, confirm production's English blocks.general.wisdom_sidetext reads Ancient Wisdom. The boot reconciliation is what puts it there, and the deploy log carries nothing for it — it is a plain UPDATE, not a migration.

Notes for reviewer

  • This is the generic mechanism you chose (thread), built here as option A. The per-key migration this PR opened with is deleted, and the three already merged are untouched: a migration is frozen history.
  • The deleted migration already deployed to this PR's preview. That database keeps a payload_migrations row naming a file that no longer exists. Payload walks the files and ignores such a row — boot, migrate and migrate:status all do (src/migrations/AGENTS.md), so the preview needs no reset.
  • Two guards were watched failing before they were trusted. Removing the version-table write makes survives the next ordinary save of the global fail with undefined; reversing the merge to stored || defaults makes fills the absent key of a column whose other key is stored return Declared Hours over the stored Hours. Both are in the new integration spec, and the second builds its own two-key target because the shipped schema declares one default per column.
  • The SQL ran against a real database this time. The previous revision said its migration's statements had not; these are exercised by tests/int/translations-english-defaults.int.spec.ts against Postgres, including the version row. CI runs it.
  • Security review: no findings. src/payload.config.ts matches securityReview.triggerPattern. The sweep read englishDefaults.ts, the src/ and seeds/ diff, quotedDbSchema, stringsSchema and drizzle's sql builder, and settled that every sql.raw input is committed source and the declared copy is a bound parameter.
  • maxLength: 24 is advisory and derived, not measured in a browser. The label is [writing-mode:vertical-rl] whitespace-nowrap at text-2xl with tracking-[0.12em], in a block at least 80vh tall, so roughly 22 characters fit at an 800px viewport height. It is a warning in the admin, not a refusal — no strict: true — because an over-long translation makes the decoration ugly rather than breaking the layout.
  • Every PR that shared this schema file has landed, and their conflicts are resolved here. feat(translations): add common.a11y.menu for WeMeditate Web #1216 (common.a11y.menu), chore(translations): drop WeMeditate Web's unused video tab #1217 (the video tab dropped) and refactor(translations): no global declares a screen-reader-only string #1246 (the ten a11y sub-groups dropped) are on main, so _meta.schema_version in seeds/wm-web-translations/data.en.json now reads post-#1218 (13 tabs, 13 leaf groups, 98 declared keys) — main's 13/13/97 plus this PR's one key. tests/unit/translations-seed-meta.spec.ts derives all three numbers from the merged schema and passes. The schema file itself merged without a conflict every time: each of those changes and this PR's new key touch different objects.
  • feat(translations): add common.a11y.menu for WeMeditate Web #1216's per-key copy migration is on main (20261118_233000_wm_web_menu_key), the third of its kind. This PR's would have been the fourth, and is deleted. The three already applied are frozen history; this convention retires the next one.
Detail

Why onInit rather than a job or a generic migration. A migration runs once ever, so one written generically would still miss every key added after it. A job needs a queue tick and would reach production minutes late, after the first client read of the new key. onInit runs after prodMigrations on every boot, which is exactly the moment the schema declaring the key and the database that lacks it first meet. It is also where seedPreviewAdmin already reconciles, for the same reason.

Why it never throws. The call is wrapped and logged: a database missing a word is a better outcome than a CMS that will not boot. The log line is English translation defaults not reconciled.

Why blank is not a gap for the boot pass. It runs on every restart, so filling a blank English value would overwrite an operator who deliberately emptied one, again and again. The seed importer does treat blank as absent, because pnpm seed translations is a deliberate act somebody ran.

Why the registry sits in src/globals/index.ts. Nothing but the master barrel may import from a global's folder (src/globals/AGENTS.md), and both readers — the boot pass and the seed — need all three globals at once.

Not done here. EMAIL_STRING_DEFAULTS (src/lib/translations/emailStrings.ts) is the same idea for one Atlas group, hand-maintained beside the schema, and could now derive from it. That is a separate change to a group holding live production data, and this PR does not touch it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjVWFbaN8WP9sHe8iQp

…te Web

`OrnateTextBox` defaults its decorative side label to `'Ancient Wisdom'` from a
default parameter, and the block converter passes none, so all 123 ornate
blocks render that English word on every locale
(sydevs/WeMeditateWeb#262). WeMeditateWeb's `no-restricted-syntax` guard
selects `JSXText` and copy props, so a default parameter reaching the markup is
invisible to it.

The label is `aria-hidden` and rotated onto one vertical line, so it carries a
24-character advisory limit and a description telling a translator it is
decoration rather than copy to render faithfully.

The data migration ships the English string, which the seed reaches only on a
fresh database.

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

railway-app Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

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

Service Status Web Updated
SahajCloud 😴 Sleeping (View Logs) Web Nov 22, 2026 at 6:51 pm UTC
1 service not affected by this PR
  • mailpit

@sydevs-bot

sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 18:21Z resolve-conflicts · attempt 1 · session · done
  • 18:21Z resolve-conflicts · attempt 1 · session
  • 22:18Z address-review · attempt 1 · session · done
  • 22:18Z address-review · attempt 1 · session
  • 16:41Z resolve-conflicts · attempt 3 · session · timed out

Written by the sydevs dispatcher. Sessions never edit this comment.

`_meta.schema_version` carried the derived shape with no `post-#<n>` prefix,
because the number is this PR's own and the branch is pushed before it exists.
Eleven of the twelve translations seeds spell it `post-#<n>` against a
SahajCloud number, so an unnumbered one leaves a later reader no commit to read.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXXxqsPdZ6LuTSTsiY
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1218 November 19, 2026 03:47 Destroyed
sydevs-bot pushed a commit to sydevs/WeMeditateWeb that referenced this pull request Nov 19, 2026
`sidetext` defaulted to `'Ancient Wisdom'` in a default parameter, and the
block converter passes none, so all 123 ornate blocks rendered that English
word on every locale. `no-restricted-syntax` selects `JSXText` and copy props,
so a default parameter reaching the markup was invisible to it.

The label now reads `blocks.general.wisdom_sidetext`. `??` rather than `||`, so
an explicit empty string still suppresses the decoration rather than falling
through to the translation.

The two generated files carry the key by hand, because neither generator can
see a key that is not on SahajCloud's `main` yet: sydevs/SahajCloud#1218 adds
it, and the contract sync re-derives `server/payload-types.ts` when that
merges.

Answers the sidetext question thread on #269 — option B (Ardnived).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXXxqsPdZ6LuTSTsiY
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 19, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

Every claim in this body checks out, and the change is as small as one key can be. What I would push back on is not in the diff — it is that the diff exists. This is the third verbatim per-key copy migration in 48 hours, and the next key implies a fourth. The generic English default #1216 proposed belongs here, not in a fourth PR.

One thing went stale after you opened this. WeMeditateWeb#269 merged at 04:01Z, 15 minutes after this PR opened, so "Merge this before sydevs/WeMeditateWeb#269" now reads backwards. Nothing breaks — the consumer falls through to its committed English mirror, the pre-existing behaviour — but that bullet is the first thing a reviewer reads.

Findings

  • should-fix — the per-key copy migration is the wrong unit; build the generic default instead (src/migrations/20261119_040000_wm_web_wisdom_sidetext.ts:25).

What was checked

  • 20261119_040000…json is byte-identical to 20261118_231500…json, as claimed.
  • maxLength is advisory: stringsSchema emits it only for strict === true (src/fields/translationsField.ts:238).
  • 14 tabs / 25 leaf groups / 197 keys on the branch, matching _meta.schema_version.
  • Consumer: OrnateTextBox.tsx:113 on WeMeditateWeb main reads t('blocks.general.wisdom_sidetext'), with sidetext? as a per-block override. A translations key is the right mechanism here, not a block field.
  • Preview link answers ON_HOST; no fixture.surfacePaths touched; src/fixture/views.ts:350-351 is the TranslationsRow → globalDoc('wm-web-translations') link it claims.
  • BLOCKS_GENERAL and addKey's value parameter are single-use indirection, held to match the two siblings. Weighed, not flagged.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

No code changed. One thread answered, one false note in the body corrected, nothing pushed.

Asked, left open — the per-key copy migration. The generic English default is the right unit. This one-key PR is the wrong place to build it. Your call: B, its own ticket, recommended, or A, built here. The thread holds the merge. #1216 raised it in a body note, which asks nobody — that is why it got no answer.

Corrected — the body told you to merge this before sydevs/WeMeditateWeb#269. That PR merged at 04:03:51Z, 17 minutes after this one opened, with both generated entries hand-typed. Nothing broke. Until this deploys, that site reads its committed English mirror and every locale still shows Ancient Wisdom, exactly as before. What this PR unblocks is the translated label and the contract sync.

Nothing pushed. The branch is level with main, and no ask was adopted.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 19, 2026 04:19
@sydevs-bot
sydevs-bot requested a review from Ardnived November 19, 2026 04:19
@sydevs-bot
sydevs-bot enabled auto-merge November 19, 2026 04:19
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 19, 2026
…ons-wisdom-sidetext

#1246 retired this global's ten a11y sub-groups, so the seed's `_meta` prose
and its quoted shape both moved under this branch. The conflict is `_meta`
alone: main's wording is the true one — no a11y key is declared here any more —
and the shape it quotes gains this branch's one key, 13 tabs, 13 leaf groups,
98 declared keys.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYqULZrbvhm9F3pwHY
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1218 November 22, 2026 18:27 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main in. One conflict, in _meta of seeds/wm-web-translations/data.en.json.

#1246 dropped this global's ten a11y sub-groups while this branch was open, so both sides rewrote the same two lines. I took main's source prose whole: this branch's copy still named common.a11y.menu and four other keys the schema no longer declares. The quoted shape is main's 13 tabs, 13 leaf groups, 97 keys plus this branch's one key — post-#1218 (13 tabs, 13 leaf groups, 98 declared keys).

Nothing else conflicted, and nothing semantic did: SUBGROUP_PRESENTATION is gone from main and this branch never used it, and the new default keyword lands in a group #1246 left alone.

Lean gate green, 3863 unit tests. 48 integration cases green across the three translations specs.

The body's shape bullet and unit-test count are updated to match.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 22, 2026
sydevs-bot pushed a commit to sydevs/WeMeditateWeb that referenced this pull request Nov 22, 2026
main's #329 re-ran `pnpm types:cms` against SahajCloud main (#1246), which
dropped the ten a11y interfaces and the video tab. This branch's hand copy
of the contract still carried them, so every one of those groups conflicted.

Resolved to main's generated output plus only the shapes this branch's code
needs from the unmerged sydevs/SahajCloud#1232: `blocks.live_session`,
`blocks.general.days`, `SplashBlock.event` and `ClassDirectoryBlock`. The
a11y groups stay dropped — #328 moved those strings into lib/i18n/a11y/,
so nothing here reads them from the CMS. `wisdom_sidetext` is re-typed
because its own `shortcut:` marker says a contract sync drops it until
sydevs/SahajCloud#1218 lands.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeQVCd9NZbNZ37XVL
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 22, 2026
Merged via the queue into main with commit af9d7b8 Nov 22, 2026
24 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-translations-wisdom-sidetext branch November 22, 2026 22:31
sydevs-bot added a commit to sydevs/WeMeditateWeb that referenced this pull request Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 22, 2026
sydevs-bot added a commit to sydevs/SahajAtlasWeb that referenced this pull request Nov 22, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
One conflict, in `seeds/wm-web-translations/data.en.json`'s `_meta`: both sides
re-stamped `schema_version`, and this branch also extended `source`.

Kept this branch's `source` sentence — it names the four mood-finder keys, which
main has no reason to mention — and derived the counts from the merged schema:
main's `post-#1218 (13/13/98)` plus these four keys is `post-#1223 (13/13/102)`.
`tests/unit/translations-seed-meta.spec.ts` derives all three, and passes.

#1218 landed on main while this branch waited, so a new key's English is now
declared as `default` in `translationsSchema.json` and reconciled on boot. These
four keys declare none and stay in the corpus file plus this branch's migration,
which is what `tests/unit/wm-web-translations-seed.spec.ts` requires of a key
with no default. Whether to convert them is asked on the PR.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZPhoz9ErHoiLegKGi
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
…tdown-directory

main's #1218 added `blocks.general.wisdom_sidetext` and the `default` keyword
that declares a key's English in the schema. Both sides only added, so all
three conflicts keep both.

- `blocks.general` carries this branch's `days` and main's `wisdom_sidetext`,
  the countdown labels still together. `blocks.live_session` stays, and the tab
  description is main's, which names the Ancient Wisdom text box.
- `_meta.schema_version` is re-derived rather than merged: 13 tabs, 14 leaf
  groups, 105 declared keys, as `translations-seed-meta.spec.ts` counts them.
- `src/payload-types.ts` is `pnpm generate:types` on the merged tree.

The seven new keys declare no `default`, and that is the convention rather than
an omission: #1218 refuses a key that sits in both the schema and the corpus
file, and these ship their English in `seeds/wm-web-translations/data.en.json`.
So `20261119_231000_wm_web_live_session_copy` is still what reaches a database
that already holds the global.

No snapshot heal this time. main has added no migration since the last merge,
so `migrate:create --skip-empty` on the merged tree wrote nothing.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVZBi3r2prvzbsmPpM
sydevs-bot added a commit to sydevs/SahajAtlasWeb that referenced this pull request Nov 22, 2026
sydevs-bot added a commit to sydevs/WeMeditateWeb that referenced this pull request Nov 22, 2026

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1218 — ae94dcac Deployed Nov 22, 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

Development

Successfully merging this pull request may close these issues.

3 participants