Skip to content

feat(api): atlas submission intake — proposal location, opt-in list owners, submission copy - #1027

Merged
Ardnived merged 12 commits into
mainfrom
claude/feat-1021-1022-1023-atlas-intake
Oct 24, 2026
Merged

Ardnived merged 12 commits into
mainfrom
claude/feat-1021-1022-1023-atlas-intake

Conversation

@Ardnived

@Ardnived Ardnived commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Change outline

Contract — user-submissions and events

A client gains one write and one read; region/regionHint stay system fields.

 user-submissions                                   src/collections/UserSubmissions/fields.ts
+  location?: { placeId?, regionId?, countryId? }   # client-writable layers above the address; an online class's city is placeId
   region                                           # system — now written at intake
-  regionHint: open object
+  regionHint: { country?, state?, anchorRegion? }  # region ids, closed — intake is the only writer
 events                                             src/collections/Events/Events.ts
+  offersMailingList: boolean (virtual)             # single-event reads only; null in a list
 sy-atlas-translations
+  submit.{chrome,where,when,contact,about,more,review,done,errors}   # 61 keys
+  registration.form.subscribe

Flow — placing a new-event proposal (#1021)

 POST /api/user-submissions  type: proposal, no event
   beforeValidate: validateProposal, gateRegistration, prepareUserSubmission
+  resolveProposalRegion                            hooks/resolveProposalRegion.ts
+    regions where mapboxId in [proposed.address.mapboxId, location ids] (manual- ids skipped)
+    venue ?? city → region + regionHint.anchorRegion
+    region-level / country matches → regionHint.state / .country
+    nothing matched → leave data alone
 deliverProposal                                    src/jobs/DeliverSubmissions/deliverProposal.ts
   target event → its manager, else up its region chain
-  no target → system contact
+  no target → managerUpChain(submissionRoutingRegionId(row))   # city, else state, else country
+              → system contact only when placed nowhere

Flow — which list an opt-in joins (#1022)

+mailingListClientFor(req, regionId)                src/lib/atlas/mailingListOwners.ts
+  loadRegionClaims(req, LIST_ELIGIBLE, row => row.id)   # regionOwners.ts, shared with canonical
+  nearest claim up the chain (resolveOwnersByRegion, now generic)
+  miss → sy-atlas-config.canonicalFallbackClient, if its list is complete   # read lazily
+  else null
 Events.offersMailingList  → mailingListClientFor(event.region) != null
 deliverSubscribe.resolveMailingList                src/jobs/DeliverSubmissions/deliverSubscribe.ts
   form's client
-  ?? provenance client
+  ?? (row names an event ? mailingListClientFor(event.region) : provenance client)
+     hard-deleted event → none, never the fallback

Files

-src/collections/Events/hooks/ensureWebPathDeps.ts
+src/collections/Events/hooks/ensureVirtualFieldDeps.ts   # table: computed field → inputs it reads
+src/lib/atlas/regionOwners.ts: loadRegionClaims, getCanonicalFallbackClientId   # shared by both ownerships, read without req

Preview

⚠ Railway did not deploy this PR: the author's account is not in the Railway workspace (its comment above). These links resolve once a preview exists.

Contract impact

Generated Payload types change (location, closed regionHint, offersMailingList, the submit translations). Consumer: sydevs/SahajAtlasWeb — #147 runs pnpm types:cms and pnpm sync:translations after this merges, sends location on a proposal, and reads offersMailingList on its single-event read. No widget change is needed for this to ship.

Migration

  • New migration: src/migrations/20261024_005319_submission_location.ts
  • Impact: adds user_submissions.location (jsonb) and nine submit_* jsonb columns on sy_atlas_translations_locales and its versions table. Additive only.
  • Reversible: yes — down drops the added columns.

Test results

  • Lean gate: ✓ lint, format, typecheck, typecheck:tests, 2886 unit tests
  • Targeted specs: new atlas-submission-routing 14 passed; atlas-sitemap 23, atlas-seo 53; user-submissions-create 41, user-submissions-review-lifecycle 37, translations-globals 36, events 11, event-verification 36, region-canonical-url 24 — all passed
  • Each new behaviour was driven red by reverting it (region hook, opt-in routing, proposal routing)
  • Build: N/A (Railway builds the preview)

Manual verification

  1. On the preview, set a client's Config → Region and an enabled mailing list; open an event in that region's subtree and confirm offersMailingList is ticked, and unticked for an event elsewhere (with no fallback list).
  2. Set sy-atlas-config → canonical fallback client to one with a list; confirm the unticked event now reads true.
  3. Create a proposal via the API with location.placeId = a city region's mapboxId (or proposed.address.mapboxId = a venue's); confirm Region is filled and the review email goes to that city's (or the nearest parent's) manager.

Notes for reviewer

  • One PR for three tickets, by request — each feature is its own commit (8e17dc8, 9769b48, ce624f4).
  • Opt-in routing changes who receives existing opt-ins: a registration-spawned row used to go to the relaying client's list, and now goes to the class owner's (decided on feat(api): send atlas opt-ins to the class owner's mailing list #1022). A row whose class has no list anywhere fails delivery visibly, as before.
  • regionHint is now closed. Nothing in production writes it today, so no stored row holds other keys.
Detail

Review passes: /simplify (4 lenses) and /code-review high, both triaged and fixed; /security-review found nothing at confidence ≥ 8. pr-review-toolkit is not installed here.

Dismissed findings:

  • A public key can name any event on a subscribe row and reach that region's list. The intended registration-plus-opt-in flow already does exactly this; Turnstile, screening and provider opt-in still gate it (security review: 2/10).
  • location should be an open schema for forward compatibility. Closed on purpose: it is client-written, and strictness is what keeps free text (and links) out of a reviewer's view. The producer-first ship order means a new widget key lands after the CMS accepts it.
  • Refuse the spawn when no list resolves. Kept the visible failed row instead — the consent stays on record for an admin.
  • Write the anchor only once. regionHint.anchorRegion records what the location matched after a reviewer changes region.
  • Event-routed delivery loads the region tree. A job path, memoized per request.

Fixture pre-mortem: createRegionNode stores mapboxId as <prefix>-<slug>, checked against MAPBOX_FEATURE_ID (src/collections/UserSubmissions/fields.ts); list ownership fields checked in src/collections/Clients/Clients.ts; the save-time provider probe (validateMailingList) is mocked at @/lib/mailingList/providers.

Closes #1021
Closes #1022
Closes #1023

🤖 Generated with Claude Code

Ardnived and others added 9 commits October 23, 2026 17:55
A `submit` tab for the add-a-class and suggest-a-correction panel (entry
points, the five steps, the review bar, the confirmation and its refusals),
and `registration.form.subscribe` for the mailing-list opt-in.

Closes #1023

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A registration opt-in now joins the list of the client that owns the class's
region, else the nearest owner above it, else the canonical fallback client's
(We Meditate). The Events `offersMailingList` virtual field answers from the
same resolver, so the widget shows the box only where a list exists.

Closes #1022

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A client may now send `location` (the Mapbox ids of the address or city the
visitor picked). Intake matches them against `regions.mapboxId` into `region`
and `regionHint`, and delivery emails the nearest manager above that region
instead of the system contact.

Closes #1021

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Share one memoized read of the fallback client between canonical ownership
  and the mailing-list fallback, and ask the fallback only on a miss.
- Require a complete list (provider, list id, key) to count as one.
- `offersMailingList` resolves on single-event reads only, like
  `qualityReport`; the select-deps hook is now a table (`ensureVirtualFieldDeps`).
- `regionHint` is closed now that intake is its only writer; routing reads it
  through `submissionRoutingRegionId` beside `submissionRegionId`.
- Skip `manual-` ids when matching a location; trim comments to their why.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- An authored form's client still wins over the event's region owner.
- A hard-deleted event refuses the opt-in rather than falling back.
- A non-string location id is left to the schema's 400, and a location
  matching nothing leaves a trusted writer's regionHint alone.
- A blank list id or key no longer counts as a list.
- Region and needsForm docs describe intake resolution, not screening.

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

railway-app Bot commented Oct 24, 2026

Copy link
Copy Markdown

This PR was not deployed automatically as @Ardnived does not have access to the Railway project.

In order to get automatic PR deploys, please add @Ardnived to your workspace on Railway.

@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 Oct 24, 2026
@sydevs-bot

sydevs-bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 15:14Z review-pr · attempt 1 · session · done
  • 15:14Z review-pr · attempt 1 · session

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

@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

Three tickets, three commits, and the diff tracks them: 61 translation keys (#1023), a region match at intake (#1021), list ownership resolved from the class's region (#1022). Nothing here is scope the tickets did not ask for, and the migration is additive and reversible.

Two shape questions, both about layers that already exist. src/lib/atlas/mailingListOwners.ts copies regionOwners.ts's loader, memo and eligibility structure rather than parameterising it, after this PR generified the pure half. And location.mapboxId arrives beside proposed.address.mapboxId, which the same POST already carries.

⚠ The three Preview links will not open — Railway refused to deploy this PR (its own comment above), so Manual verification 1-3 are unperformed.

Findings

  • should-fix mailingListOwners.ts:48 — the loader triplet is cloned, not shared.
  • should-fix fields.ts:663 — location.mapboxId duplicates proposed.address.mapboxId; #1021's online-city key is unanswered.
  • consider regionOwners.ts:208 — req forwarded from a nested global read a virtual afterRead reaches.

What was checked

#1021, #1022, #1023 against the diff. Read whole: fields.ts, resolveProposalRegion.ts, mailingListOwners.ts, regionOwners.ts, deliverProposal.ts, deliverSubscribe.ts, Events.ts, ensureVirtualFieldDeps.ts, validateProposal.ts. regions.level is country/region/city/venue, so the venue-then-city anchor order is right. Events.region is required, so the null-region fallback is unreachable. Search Box mapbox_id is base64url, so MAPBOX_FEATURE_ID refuses no real id. skipVerifyHook matches qualityReport's own guard. Consumer side: SahajAtlasWeb#147 sends location and reads offersMailingList, so no widget change gates this merge. Preview not reachable.

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


Generated by Claude Code

Comment thread src/lib/atlas/mailingListOwners.ts Resolved
Comment thread src/lib/atlas/regionOwners.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 24, 2026
Ardnived and others added 3 commits October 24, 2026 08:23
`location` now carries only the layers the address group cannot: the city,
state and country ids. An online class names its city as `location.placeId`.

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

Copy link
Copy Markdown
Contributor Author

Review addressed — all three adversarial findings adopted, lean gate green, pushed.

PR body refreshed for the new location shape. The Railway preview still needs deploying before Manual verification can run.

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

@Ardnived
Ardnived marked this pull request as ready for review October 24, 2026 15:55
@Ardnived
Ardnived merged commit 2e53a1b into main Oct 24, 2026
45 of 50 checks passed
@Ardnived
Ardnived deleted the claude/feat-1021-1022-1023-atlas-intake branch October 24, 2026 16:08
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Oct 24, 2026
sydevs-bot added a commit to sydevs/WeMeditateWeb that referenced this pull request Oct 24, 2026
sydevs-bot pushed a commit that referenced this pull request Oct 24, 2026
#1027 landed `20261024_005319_submission_location` on `main`, which
conflicted with this branch's two migrations in `src/migrations/index.ts`.
Both sides are additive, so all three are registered in timestamp order.

That merge re-armed the out-of-order snapshot trap. #1027's snapshot is now
newest by timestamp but was generated on `main`, where `task_slug` still
names `cleanupJobs`, `purgeSubmissions` and `sweepEventImports` — so
`migrate:create` re-emitted both enum rebuilds that
`20261021_152406_retention_registry` already ships. The re-emission omits
that migration's `DELETE` of the rows naming the dropped slugs, so replaying
it would abort the boot migration on the first legacy row. Healed the
documented way: `20261024_161437_merge_1027_main_snapshot` keeps its `.json`,
generated on the merged tree, with empty `up` and `down`.

`src/plugins/formBuilder/index.ts` merged cleanly and carries both sides —
this branch's `custom.retention` and #1027's `resolveProposalRegion` hook.
#1027 adds no submission type, so `DURABLE_TYPES` is unchanged, and the purge
windows select on `type`, `status` and `createdAt`, none of which it touches.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SPqGrb2pbaKRL5f1PFAyT8
sydevs-bot pushed a commit that referenced this pull request Oct 25, 2026
Clean merge, no conflicts — the first on this branch that needed no
numbers argument. Main's three commits since the last merge (#959, #1027,
#1028) touch the atlas SEO resolver, the submission intake and
escapeRegExp's home, none of which this branch reads.

src/plugins/access is untouched on main this time, so there was no
semantic call to make. tests/PERF.md's counts stand: main added one int
spec and edited two unit specs without adding a unit file, and
perf-figures-pinned counts files, not cases.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Tj9vmW1FyGMJBwBFWybcWq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

2 participants