Skip to content

feat(atlas): prepare the final Atlas cutover - #1137

Merged
Ardnived merged 24 commits into
mainfrom
feat/atlas-cutover-prep
Nov 13, 2026
Merged

Ardnived merged 24 commits into
mainfrom
feat/atlas-cutover-prep

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Prep for the final legacy Atlas → SahajCloud sync and the atlas.sydevelopers.com/cms cutover.

Changes

  • Digests are paused by unscheduling them. SendDigests has schedule: [] and a shortcut: comment, so no imported manager gets a digest before the migration email. A follow-up PR puts back [{ cron: '0 7 * * *', queue: 'nightly' }] about a week after the cutover. The job and its tests are otherwise unchanged.
  • Importer: no follow-up for past sessions. Registrations whose session has already started are imported with followUpSentAt set (importedFollowUpSentAt), so SendPostEventFollowUps never asks about a legacy class, even after a reset wipes an earlier run's stamps.
  • Importer: two Atlas services stay as SahajCloud has them. These are ADOPTED_CLIENT_LEGACY_IDS (sync/merges.ts): Sahaja Yoga Canada (Ticket #1: Sentry Integration and Production Environment Setup #1) and syuk.org (feat: implement Narrator collection (Issue #2) #12). Their sites serve live users. A re-sync only re-links their region, which atlas-reset nulls, and keeps the label, managers, contact, roles, language and colour SahajCloud gave them. The re-link runs ahead of the manager lookup it reads nothing from, so a service whose Atlas manager the prune took still gets its region back.
  • public/atlas-moving.html. The holding page /cms* redirects to during the freeze. Plain language, with the new map's headline features and a link to it. Deleted after the cutover.
  • Migration email (scripts/send-atlas-migration-email.ts + src/emails/AtlasMigrationEmail.tsx), the one-off "Welcome to the new Sahaj Atlas".
    • Recipients: Atlas managers named on a live event, a region or an enabled service. Admins are excluded.
    • Content: it lists everything the manager looks after, through ResponsibilityRows — now in EmailLayout.tsx, shared with InviteEmail so both describe a manager the same way. The "what's new" lines depend on the manager's role (cmsHighlights), followed by the map's highlights. It ends on two buttons, one to the admin and one to the map. The admin host is spelled once, in signInUrl, and the support address comes from CONTACT_EMAIL.
    • Safety: it sends nothing without --preview <addr> or --send --force, and refuses a bulk send unless the transport is Resend. A local ledger makes a re-run send only the rest. It writes nothing to the database. Deleted after it goes out.
  • scripts/lib/payloadBoot.ts: every script you may point at production boots without a schema change (fix(scripts): an operator script pointed at production migrates it #1138). A plain getPayload under NODE_ENV=production applies every pending migration, so break-glass run from a feature branch would migrate production on the way to a link. signin-link.ts, create-manager.ts, audit-region-slugs.ts, audit-challenge-parents.ts and the email script all use the shared boot: no push, no prodMigrations, no onInit. preview-event-emails.ts and preview-registration-emails.ts keep a plain boot on purpose. They only run locally, and the dev push keeps that database current; each says so in its docblock and in scripts/AGENTS.md.
  • src/AGENTS.md. The featureFlag.ts paragraph goes: with digests paused by schedule: [], ExpireEvents/ holds the only flag module in the tree, and its reason now sits in that file.
  • atlas:sync fetch fix. It now reads the captured backup id from the Heroku CLI's stderr as well as stdout. The CLI prints the id on stderr, so the fresh-capture path always threw.

Testing

  • Unit: atlas-migration-recipients (selection and role-tailored highlights), atlas-registrations-data (importedFollowUpSentAt), atlas-sync (adopted clients), job-schedules, doc-citations.
  • Lint, format, typecheck, typecheck:tests: all green.
  • Email: previewed through Mailpit for the class-manager, region-manager and website-manager variants.
  • fix(scripts): an operator script pointed at production migrates it #1138, against a local database: create-manager.ts created a manager, signin-link.ts printed its link, and audit-region-slugs.ts reported. Then, under NODE_ENV=production with all 132 migrations pending, signin-link.ts and audit-region-slugs.ts booted and payload_migrations stayed unchanged. create-manager.ts stopped at its usage check before booting, but it shares the same boot. grep -n "getPayload({" scripts/*.ts lists only the two preview scripts.
  • Known unrelated failure: ics-builder's LAST-MODIFIED case fails on main locally too (machine timezone).

Closes #1138

🤖 Generated with Claude Code

- DIGESTS_ENABLED pauses SendDigests, off by default, so no imported
  manager gets a digest before the migration email. Temporary.
- The Atlas importer stamps followUpSentAt on registrations whose session
  has started, so no feedback email asks about a legacy class.
- public/atlas-moving.html, the page /cms redirects to during the freeze.
- scripts/send-atlas-migration-email.ts and AtlasMigrationEmail: the
  one-off announcement to active Atlas managers, with a local ledger.
- scripts/lib/payloadBoot.ts: the schema-safe boot the audit and the new
  script share.

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

railway-app Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

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

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Nov 13, 2026 at 3:04 am UTC
1 service not affected by this PR
  • mailpit

@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1137 November 12, 2026 23:28 Destroyed
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot

sydevs-bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 02:49Z address-review · attempt 1 · session · done
  • 02:49Z address-review · attempt 1 · session
  • 02:43Z review-pr · attempt 1 · session · done
  • 02:43Z review-pr · attempt 1 · session
  • 01:16Z address-review · attempt 1 · session · done

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

@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 12, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧐 Adversarial review

Judged against its own body. All five pieces are named there and joined by one operation, and three carry a shortcut: naming their deletion trigger. Nothing is larger than the cutover it serves, and no contract surface moves.

The one piece that outlives the cutover is the boot extraction, and it is the one to settle: scripts/AGENTS.md now claims a production-safety property for "an operator script" while four of them, the break-glass one included, still boot unsafely. The other gap is the body: it says nothing about the second commit.

Findings

  • should-fix scripts/lib/payloadBoot.ts:20 — the new shared boot leaves four operator scripts outside it.
  • should-fix seeds/atlas/sync/cli.ts:93 — the Heroku stderr fix is in the diff, not in ## Changes.
  • consider seeds/atlas/sync/cli.ts:98 — a failure to spawn reports null, not the ENOENT.
  • consider src/jobs/Digests/featureFlag.ts:4 — the second identical one-line flag module.

What was checked

Read whole on the branch: both new scripts, payloadBoot.ts, AtlasMigrationEmail.tsx, atlas-moving.html, plus SendDigests.ts, SendPostEventFollowUps.ts, middleware.ts and payload.config.ts.

Ladder, named answers found: not_equals: 'finished' is the repo's own spelling (atlasOverview/openItems.ts:367); the hand-rolled plural matches EventImportSummaryEmail.tsx:19; the transport guard holds, since the adapter is name: 'resend' (resendAdapter.ts:104); the stamp lands where the job reads it (SendPostEventFollowUps.ts:49), and an explicit null is absent to exists: false, so a session still ahead keeps its follow-up.

middleware.ts:118 matches /atlas-moving.html, but previewGate returns null off a Railway preview, so production serves it. The body publishes no preview link, so none was opened.

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


Generated by Claude Code

Comment thread scripts/lib/payloadBoot.ts Resolved
Comment thread seeds/atlas/sync/cli.ts Resolved
Comment thread seeds/atlas/sync/cli.ts Resolved
Comment thread src/jobs/Digests/featureFlag.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 12, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 12, 2026
Ardnived and others added 5 commits November 12, 2026 16:55
- Unschedule SendDigests instead of the DIGESTS_ENABLED flag: one line to
  restore about a week after the cutover.
- Rewrite the migration email for volunteers: it lists what each manager
  looks after the way an invitation does (ResponsibilityRows, now shared
  with InviteEmail), says what is new, and ends on a button to the admin
  and one to the new map.
- Rewrite the holding page the same way, with the new map's features and
  a link to it.
- ADOPTED_CLIENT_LEGACY_IDS: a re-sync only re-links the region of Sahaja
  Yoga Canada and syuk.org, whose sites serve live users, and keeps what
  SahajCloud gave them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`spawnSync` sets `status`, `stdout` and `stderr` to null when the CLI never
ran, so a missing `heroku` binary reported `failed:\nnull\nnull` and buried
the reason in `error`. Prefer `error.message` when it is set.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW4FCn952dMT17i5h3
`lib/payloadBoot.ts` makes its two callers safe to point at production, not
every operator script. The other five still boot through `getPayload({ config
})`, where `prodMigrations` applies pending migrations — `signin-link.ts`, run
in a production shell by design, among them.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW4FCn952dMT17i5h3
Two jobs now carry a byte-identical one-line flag module, which reads as
duplication. It is the deliberate shape: `vi.mock` is keyed by path and
`src/jobs/index.ts` loads every job, so one shared module would make each
job's integration spec restate every other job's flag.

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

Copy link
Copy Markdown
Contributor

Addressed all four review findings. origin/main merged in cleanly, no conflicts.

Adopted

Rebutted

  • featureFlag.ts:4 — one module per job is deliberate, and ec8ec22 states it in src/AGENTS.md. vi.mock is path-keyed and src/jobs/index.ts loads every job, so a shared one would make each job's int spec restate every other flag.

Lean gate and digests.int.spec.ts green on the merged branch.

🤖 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 13, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 13, 2026
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1137 November 13, 2026 00:08 Destroyed
@sydevs-bot
sydevs-bot enabled auto-merge November 13, 2026 00:27
…s once

The prose link hardcoded `cloud.sydevelopers.com` while the buttons came
off `signInUrl`, so the email would name one host and link another as
soon as either moved. The link now reads the host out of `signInUrl`.

The `mailto:` had the same shape and takes `CONTACT_EMAIL`, which
`docs/rules/email.md` names as the one address shown to a human.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW1mNU41VgYcGTZFh7
`import/order` refuses a blank line inside an import group, and the gate
runs eslint at `--max-warnings 0`.

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

Copy link
Copy Markdown
Contributor

Addressed all four findings from the second review. No merge: already level with origin/main.

Adopted

Lean gate and manager-invite.int.spec.ts green. Nothing exercises importClients, so that reorder carries no test.

🤖 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 13, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 13, 2026
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1137 November 13, 2026 01:31 Destroyed
…change

signin-link.ts, create-manager.ts and audit-region-slugs.ts booted with a
plain getPayload, which under NODE_ENV=production applies every pending
migration: break-glass run from a feature branch migrated production on
the way to a link. All three now use loadPayloadWithoutSchemaChanges. The
two preview-email scripts keep the dev push on purpose, and say so.

Closes #1138

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1137 November 13, 2026 02:42 Destroyed
@Ardnived

Copy link
Copy Markdown
Contributor Author

@sydevs-bot review

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

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧐 Adversarial review

Third look, on 63bcfbd, asked for by hand. Judged against its own body, which names all eight pieces.

New since the last review is #1138 folded in: signin-link.ts, create-manager.ts and audit-region-slugs.ts now share loadPayloadWithoutSchemaChanges. Right call — break-glass was the script that most needed it, and scripts/AGENTS.md no longer claims a production-safety property four scripts lacked. Nothing here is larger than the cutover it serves, and no contract surface moves.

Three findings, all consider: a comment or a type promising more than the code delivers. Ladder: no named answer for anything new.

Findings

  • consider seeds/atlas/sync/merges.ts:128 — a Map whose values nothing reads; a Set plus the note says the same.
  • consider seeds/atlas/helpers/registrations.ts:44 — followUpSentAt gains a second writer; the sweep's docblock still says it has one.
  • consider scripts/send-atlas-migration-email.ts:145 — the role highlights and the listed rows count a manager's events differently.

What was checked

Read whole on the branch: payloadBoot.ts, send-atlas-migration-email.ts, atlas-migration-recipients.ts, merges.ts, registrations.ts, import.ts's clients loop, plus grantSummary.ts, SendPostEventFollowUps.ts, logField.ts and UserSubmissions/fields.ts.

Verified: no script outside the two preview ones still boots plainly (git grep getPayload scripts/), so the AGENTS.md claim now holds; 9c6aa71's reorder reads nothing from the manager it now precedes; summarizeGrants does cover clients, so a service manager's email is not empty (grantSummary.ts:209); an imported stamp misleads nobody, since the field is admin: { hidden: true }.

The body publishes no ## Preview link, so none was opened; Railway's own was still building.

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


Generated by Claude Code

Comment thread seeds/atlas/sync/merges.ts Resolved
Comment thread seeds/atlas/helpers/registrations.ts Resolved
Comment thread scripts/send-atlas-migration-email.ts Resolved
@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 13, 2026
#1135's lifecycle work and #1121's class brief both landed while this
branch moved ResponsibilityRows out of InviteEmail.tsx.

Two conflicts, both kept whole:

- src/emails/InviteEmail.tsx — main grew an EventBrief under each class
  item of the rows this branch moved to EmailLayout.tsx. The component,
  its two styles and the item.event call site move with the rows, so the
  invitation still carries the brief and the shared rows still live in
  the layout. Nothing else renders one: only invite.ts asks
  summarizeGrants for describeEvents.
- docs/rules/email.md — both sides rewrote the template table. Took
  main's rows and put ResponsibilityRows back among EmailLayout's
  exports.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVJuj3U8ZvhK2zChe8
A Map<number, string> claimed the labels were data a reader could use.
Nothing read a value: the importer calls .has(), the spec iterated keys.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVJuj3U8ZvhK2zChe8
The sweep's docblock claimed the stamp was written only after a
successful send. The Atlas import writes it too, so a reader debugging
an unsent follow-up would never look at the importer.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVJuj3U8ZvhK2zChe8
compose()'s docblock claimed the listed rows and the role highlights
could not describe one manager differently. They can: holds counts only
unfinished events, summarizeGrants walks the join and counts the rest.

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

Copy link
Copy Markdown
Contributor

All three findings adopted. Merged origin/main, which conflicted.

Adopted

Merge (20c3362), two conflicts:

Lean gate and manager-invite.int.spec.ts green.

🤖 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 13, 2026
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1137 November 13, 2026 03:01 Destroyed
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 13, 2026
@sydevs-bot sydevs-bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 13, 2026
@Ardnived
Ardnived disabled auto-merge November 13, 2026 03:39
@Ardnived
Ardnived merged commit 7d01d37 into main Nov 13, 2026
9 checks passed
@Ardnived
Ardnived deleted the feat/atlas-cutover-prep branch November 13, 2026 03:39
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 13, 2026

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1137 — 3b4c28d4 Deployed Nov 13, 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.

fix(scripts): an operator script pointed at production migrates it

3 participants