Repository navigation
ci(contracts): fail the gate when the generated types or the English mirror drift from SahajCloud - #310
ci(contracts): fail the gate when the generated types or the English mirror drift from SahajCloud#310sydevs-bot wants to merge 3 commits into
Conversation
A red `git diff --exit-code` on server/payload-types.ts or
lib/translations.en.json says only that the file moved. A reviewer needs to
know which contract moved: the translation key path, or the type member.
scripts/contract-drift.ts compares the file in the git index (what
`git diff` compares against) with what the generator just wrote, and puts
the result in the job summary: keys only in the committed file, only in the
generated one, with a different value, and (for the types) with only a
different doc comment. Types are read with the TypeScript compiler API and
keyed by declaration and member path (`TableOfContentsHeadings[].occurrence`),
folding a nested object to `{…}` so a change inside it is reported once, on
the member that changed. A file that differs only in layout is never called
a match. It only reports and always exits 0, so a crash in it cannot redden
a step whose files match; the diff stays the verdict.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Nothing compared server/payload-types.ts or lib/translations.en.json with their producer. Typecheck and every test read the committed copy, so `blocks.general.wisdom_sidetext`, hand-added to both ahead of sydevs/SahajCloud#1218, passed every check while the deployed /heart-chakra rendered the key path itself. The gate job now ends with two steps. One runs `pnpm types:cms` (SahajCloud main), the other `pnpm sync:translations` (production SahajCloud); each summarizes the drifted keys, then `git diff --exit-code` fails on any difference. They run last so that a SahajCloud change, which reddens every open PR at once, cannot also skip the Ladle build and the wrangler check, and the translations step runs even when the types step failed so one run names both drifts. Each fetch gets four tries and fails with a message saying it is not drift. The mirror step needs SAHAJCLOUD_API_KEY. GitHub withholds it from a fork's pull request and from Dependabot's, where that one step skips with a warning. Anywhere else an empty secret fails the step, since a deleted secret would otherwise switch the check off unnoticed. This is blocking on purpose: main itself fails it until SahajCloud#1218 merges, its English is published, and the re-sync lands. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Neither generator sets a timeout: `types:cms` is a bare `curl -fsSL` and sync-translations calls `fetch` with no signal, whose defaults allow 300 s for headers alone. A stalled transfer was never retried; it ran into the gate's 15-minute timeout instead of ending on the "not drift" message. Each try is now `timeout 60`, so four stalled tries end in about 4.5 minutes with that message (measured against a listener that never answers: 270 s, four connections, no orphaned curl). The summary script promises it never fails the job, but GitHub runs `run:` blocks with `bash -e`, so a load failure (tsx or typescript not resolving, a syntax error) ended the step red before `git diff --exit-code` ran, even on a file that matches. The call now falls through to a warning. Measured with the script moved aside and a matching file staged: exit 1 before, exit 0 after. The types step's failure message also names a curl 404 as a moved upstream path, which a re-run cannot fix. A spec pins the workflow to these shapes and to one `git diff --exit-code` per contract file. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | 15072f4 | Commit Preview URL Branch Preview URL |
Nov 19 2026, 10:53 PM |
|
Nothing to fix this pass. The red Every earlier step passed:
sydevs/SahajCloud#1218 is still open, so the blocker stands. Re-syncing either file drops the hand-typed Pushed nothing. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Superseded by #320 and sydevs/claude-workflow#283. Instead of comparing every PR with SahajCloud |
Summary
For a developer: the
Lint, Typecheck & Unitjob now ends with two blocking steps. One regeneratesserver/payload-types.tsfrom SahajCloudmain, the other regenerateslib/translations.en.jsonfrom production SahajCloud. Each step fails when the committed file differs. Before the diff runs, the job summary lists every drifted key by name: a translation key path, or a type member such asWmWebTranslationsBlocksGeneralStrings.wisdom_sidetext. Nothing changes for a visitor or an editor.Current drift, measured with the exact step scripts on this branch rebased onto
mainc4a7927 on 2026-11-19:server/payload-types.tsagainstpnpm types:cms(SahajCloudmain): 7 lines removed, nothing added.WmWebTranslationsBlocksGeneralStrings.wisdom_sidetext(wisdom_sidetext?: string;). It was typed by hand ahead of feat(translations): declare a key's English in the schema, reconciled on boot SahajCloud#1218, together with the// shortcut:comment above it.lib/translations.en.jsonagainstPUBLIC__SAHAJCLOUD_URL=https://cloud.sydevelopers.com pnpm sync:translations(API client 40, 162 strings): +6/−7 lines.blocks.general.wisdom_sidetext("Ancient Wisdom") andcommon.a11y.opens_in_new_tab("%{label} (opens in new tab)"). Nothing onmainreads the second one.common.a11y.menu("Menu").lecture.a11y.untitled_heading, "Untitled talk" → "Untitled Lecture".footer_navigation,primary_navigation,skip_to_main). The generator would re-indent them.What changed and why
F3b: nothing compared either generated file with its producer. On
main, typecheck and every test read the committed copy, andtests/guards/translation-keys.test.tsreads only the mirror. That is howwisdom_sidetext, hand-added to both files in 3a318d8 (fix(textbox): the OrnateTextBox header fails AA over the warm band #269), passed every check while the deployed/heart-chakrarendered the key path itself..github/workflows/ci.yml): runspnpm types:cms, then the summary, thengit diff --exit-code server/payload-types.ts.pnpm sync:translations.PUBLIC__SAHAJCLOUD_URL=https://cloud.sydevelopers.comandSAHAJCLOUD_API_KEY(a repository secret the smoke job already uses) are set in that step's env only. Itsif: !cancelled() && steps.contract-types.outcome != 'skipped'means it runs even when the types step failed, so one red run names both drifts.Summary script,
scripts/contract-drift.ts. It compares the git index (whatgit diffcompares against) with the regenerated working-tree file. It writes the per-key summary to$GITHUB_STEP_SUMMARYand adds an::error file=…annotation.{…}, so a change is reported once, on the member that changed. A change to a doc comment alone is listed separately. Children of an added or removed parent are not listed again. Lists stop at 40 entries.scripts/contract-drift.test.ts(18 tests). These include the real 2026-11-19 drift shapes, and an end-to-end case in a temporary git repo that checks the index against the working tree and the annotation present or absent. Mutation checks: droppingwithoutImpliedChildrenfails 1 test, removing the{…}folding fails 3, removing the doc separation fails 1.Decision: placement. The spec said "after
pnpm test:run". Both steps sit at the end ofgate, aftercheck:wrangler, which is still aftertest:run. One upstream change reddens every open PR at once. If these steps sat directly aftertest:run, that failure would also skipladle:buildandcheck:wrangleron every PR.Decision: secrets. GitHub withholds Actions secrets from a fork's PR and from Dependabot's. On those runs only the translations step skips, with a
::warning::and a line in the summary. The types step needs no secret and still runs. An empty secret on any other run fails the step, because a deleted secret must not switch the check off unnoticed (the spirit of ci(preview): move the Ladle site to Workers and fail on no preview #184: a skip must never look like a pass).Retries, each bounded (review nit, applied). Each generator gets 4 tries, 5, 10 and 15 s apart, and each try is now wrapped in
timeout 60. Neither generator sets a timeout of its own:types:cmsis a barecurl -fsSL, andsync-translationscallsfetchwith no signal. Without the bound, a stalled transfer ran into the job's 15-minute timeout instead of ending on the "not drift" message.::error, and no orphanedcurl.package.json, which several open PRs edit.Only
git diffdecides (review nit, applied). GitHub runsrun:blocks withbash -e, so a summary script that failed to load (tsx or typescript not resolving, a syntax error) ended the step red before the diff ran, even on a matching file. Each summary call now falls through to a::warning::. Measured with the script moved aside and a matching file staged: exit 1 before the change, exit 0 after. Three specs inscripts/contract-drift.test.tspin the workflow:CONTRACTSfile has its owngit diff --exit-codelinetimeout||Against the workflow as it was before this change, the last two fail.
Review finding, applied: the PR body uses current
main. The implementer measured on 5ee6ded. Since then chore(contracts): re-sync copied contracts from SahajCloud #292 and chore(contracts): re-sync copied contracts from SahajCloud #306 (both contract re-syncs), feat(preview): stream unsaved lecture edits into the preview panel #290 and feat(player): move VideoPlayer from Vidstack to Video.js 10 #285 have merged. The branch is rebased onto c4a7927, and the drift above was measured there. On 41079b2, before chore(contracts): re-sync copied contracts from SahajCloud #306 merged, the same step also reported the feat(events): tidy the event form, send signups to the manager only SahajCloud#1198Eventchanges, which shows that the gate catches an unsynced upstream merge.Docs.
docs/cloudflare-previews-ci.mdgets a new section, "The contract gate". It covers what fails, thewisdom_sidetextincident, and the one fix (land the producer first, then regenerate). It warns that one upstream change reddens every open PR and that each PR then needs Update branch, because a re-run reuses its original merge commit. It also covers retries and time bounds, the fork skip, and why the steps sit last.AGENTS.mdgets a 4-line pointer under "Commands package.json does not show".docs/rules/rest-api.mdand the header ofscripts/sync-translations.mjsno longer say the sync is "not run in CI".Not in this PR
.claude/workflow.jsongeneratedFiles. It lists onlyserver/payload-types.ts. Adding^lib/translations\.en\.json$would make the workflow skills treat the mirror the way CI now does..claude/is a protected path, so this is left for a person to edit.bash -n), then run locally asbash -ewith real network and the real key: the match path, the drift path, the fork-skip path, the missing-secret path, the stall path and the broken-summary path. This PR's CI run is their first run on GitHub.Reconciled with open PRs
git merge-treeof this branch (on c4a7927) against every open PR branch is clean. This PR does not touchpackage.json,server/payload-types.tsorlib/translations.en.json.fix(ci): smoke tests the head commit's preview, not the previous build #295 edits
.github/workflows/ci.yml(lines 18 and 109) anddocs/cloudflare-previews-ci.md(lines 32–37 and 67). The hunks are separate.feat(seo): share metadata and JSON-LD at parity with the old site #282 edits
docs/cloudflare-previews-ci.mdandAGENTS.mdin other regions.feat(server): legacy redirect map and lookup for the wemeditate.com cutover #276, feat(server): switch wemeditate.com over to the new site #288 and feat(components): a MeditationLibrary for the meditations index block #293 edit other regions of
AGENTS.md.fix(server): report a failed read once per cause, stop caching what it emptied, list the whole sitemap #305 edits
docs/rules/rest-api.mdlines 48–58. This PR edits lines 92–106.Open PRs that edit a contract file go red once this merges, until they match upstream exactly.
common.a11y.menu. Its types half is already onmainthrough chore(contracts): re-sync copied contracts from SahajCloud #292, and production already serves the string.mainnor production has yet.wisdom_sidetextby hand.All three carry
main'swisdom_sidetext, so they stay red until feat(translations): declare a key's English in the schema, reconciled on boot SahajCloud#1218 lands in any case.After any re-sync PR merges, every open PR needs Update branch: a re-run reuses its original merge commit. raw.githubusercontent.com can serve SahajCloud
mainup to about 5 minutes stale right after an upstream merge.Test results
.claude/skills/pr-prep/check.sh --fullon the rebased branch (c4a7927 + 3 commits):Lint: 0 errors, 1,087 warnings. The two new TypeScript files add none.
tsc --noEmit: passed.Vitest: 132 files, 1,293 / 1,293 tests passed, including 18 in
scripts/contract-drift.test.ts.pnpm build(client + server): passed.The other CI gate steps, run locally:
pnpm ladle:buildpassed,pnpm check:wrangler(offline dry run) passed, andnode scripts/a11y-summary.mjspassed.The new contract steps, run locally exactly as CI runs them:
::error file=server/payload-types.ts,title=SahajCloud contract drift::…, summary Only in the committed file (1):WmWebTranslationsBlocksGeneralStrings.wisdom_sidetext::error file=lib/translations.en.json,…, with the four keys and the layout note listed above.Both are red as intended.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw