Skip to content

feat(sy-atlas-config): name the atlas report-issue form on the config global - #823

Merged
sydevs-bot merged 8 commits into
mainfrom
claude/feat-813-atlas-config-form
Sep 18, 2026
Merged

sydevs-bot merged 8 commits into
mainfrom
claude/feat-813-atlas-config-form

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • sy-atlas-config gains reportIssueForm, a nullable forms relationship filtered to actionType: 'contact' — the widget's report-issue path now has an authored form behind it.
  • forms joins the sahaj-atlas project, which puts it in the atlas OpenAPI spec and the admin nav.
  • Forms.recipient and Forms.client are both locked with managersOnlyFieldAccess. Without them, opening forms to the atlas hands a manager's name and email, and a whole clients document, to a browser.
  • Nothing under src/collections/UserSubmissions/ changes. needsForm and perTypeForm were already right.

Changes

  • src/globals/SahajAtlasConfig/SahajAtlasConfig.ts — the new relationship
  • src/plugins/access/config/projects.ts — forms added to sahaj-atlas
  • src/collections/Forms/fields.ts — the recipient and client field locks
  • src/jobs/DeliverSubmissions/deliverContact.ts, src/lib/notifications/sendUserMessage.ts — three comments stated the rejected premise (that the widget posts a contact row with no form); corrected
  • docs/rules/access.md — the field-access section names all three fields carrying the lock

Preview

  • Sahaj Atlas configuration — the new "Report an Issue Form" picker. It should offer contact forms only.
  • Forms list — author a contact form here first, so the picker has something to offer.

Contract impact

sydevs/SahajAtlasWeb — the widget must now read the form id off sy-atlas-config, fetch the form, render its authored fields, and post a contact row naming it. sydevs/SahajAtlasWeb#213 and sydevs/SahajAtlasWeb#195 both need revising against this contract before either is implemented: #213 re-points the call onto POST /api/user-submissions, and on this contract it would be refused for naming no form.

src/payload-types.ts is regenerated, so consumers running types:cms pick up reportIssueForm.

Migration

  • New migration: src/migrations/20260918_172634_atlas_config_report_issue_form.ts
  • Impact: adds a nullable report_issue_form_id column to sy_atlas_config, an FK to forms with ON DELETE set null, and a btree index. No data transformed.
  • Reversible: yes — down drops the constraint, index and column.

Nullable is deliberate, and not only because unset is a live state the widget renders: a required relationship makes the column NOT NULL, and that migration aborts the boot migration on any environment carrying cloned production data.

Test results

  • Lean gate: ✓ pnpm lint, pnpm typecheck, pnpm typecheck:tests, pnpm test:unit (2135 passed)
  • Targeted specs: 127 passed across atlas-report-issue-form, forms-action-type, role-based-access, user-submissions-create, user-submissions-access
  • Re-run after the client lock: atlas-report-issue-form (8), forms-action-type + user-submissions-access (18) — all green
  • Build: N/A — Railway builds the preview

Every new assertion was proven by reintroducing the real defect and watching that case go red, per tests/AGENTS.md. The four are listed in the test commit. The one worth naming here: flipping recipientFor to overrideAccess: false sends every report to CONTACT_EMAIL instead of the named manager. A field lock that also broke delivery would have satisfied every other case in the file and failed silently in production.

The client lock's case was proven the same way: dropping its access block turns the new case red at depth 0, where the bare id comes back.

Manual verification

  1. Author a contact form with a recipient, and name it on sy-atlas-config.
  2. Confirm the picker refuses a subscribe form.
  3. Submit the widget's report-issue form against feat(api): migrate widget intakes to unified form-submissions SahajAtlasWeb#213's branch preview, and confirm the row is created and the message reaches the form's recipient.

Step 3 needs the atlas side, so it cannot be done from this PR alone.

Notes for reviewer

Two pre-existing security defects surfaced during review, both reproduced against a booted Payload and filed. Neither is caused by this branch and neither is fixed here:

The two field locks in this PR each close one instance of those mechanisms — recipient for #821, client for #822. Both docblocks say so explicitly, with a ⚠ pointing at the ticket, so the next person adding a relationTo: 'managers' or relationTo: 'clients' field does not read either lock as evidence the class is handled.

One ticket open question is answered, and it changes what a test means. "Is the forms read already open, making the project entry half a no-op?" — yes. The form-builder plugin ships forms with read: () => true and accessPlugin spreads ...collection.access last, so the read was open to anonymous callers already. The project entry therefore buys OpenAPI visibility and admin nav, not the widget's read. Proven by dropping the entry: the hasPermission case went false while both read cases stayed green. That is why the grant is pinned in role-based-access.int.spec.ts — nothing else in the suite would notice forms leaving the list.

Dismissed review findings: a shared testData.createForm factory (six specs hand-roll one; outside this diff, and one lens called it the repo's convention); exporting the {read, create, update} access triple (second occurrence, both sites carry a ⚠); dropping the forms project entry as inert (its OpenAPI visibility is the point, and the ticket asked for it).

Detail

Fixture pre-mortem. The spec's fixtures assume: sahaj-atlas-client is a client role scoped to the sahaj-atlas project granting user-submissions: ['create'] and nothing else (checked in src/plugins/access/config/roles.ts); forms is in both the sahaj-atlas and wemeditate-web lists and managers in none (src/plugins/access/config/projects.ts); an API client read must send select (src/plugins/usage/hooks.ts); every partial write to sy-atlas-config must carry availableLocales, and ['en'] alone needs no relaxation (src/fields/availableLocalesField.ts).

That last one is also why the #822 probe is worth describing: its first version left the other client's apiKey unset, got null back, and read exactly like "the field is protected". The exposure only appears once the fixture stores a key. The ticket carries that warning.

The lock costs nothing at read time and saves a query. managersOnlyFieldAccess is a synchronous property check, and field access runs before relationshipPopulationPromise is queued — so a non-manager read of a form at depth >= 1 now skips a dataloader fetch against managers per row, and one against clients.

filterOptions costs one indexed PK lookup per form-state build and per save, guarded on the value being set, and never runs on the read path. Both internal sy-atlas-config readers pass depth: 0 (src/lib/atlas/regionOwners.ts, src/endpoints/atlas/seo/atlasLocales.ts), so the new relationship adds nothing to webUrl resolution — the one place a new relationship on this global could have hurt.

deliverContact had no test coverage at all before this branch; nothing under tests/ named it.

Closes #813

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

🤖 Generated with Claude Code

https://claude.ai/code/session_011T2g9wJShY6zF1oRZDoTb8

… global

The widget's report-issue path had no authored `forms` document behind it, so
every message it sent arrived with no field list, no `actionType` agreement and
no operator-visible record of what the widget offers. `user-submissions` already
refuses a `contact` row naming no form, so the widget's path was refused
outright rather than merely undocumented.

`reportIssueForm` is the relationship that closes that: an operator authors an
ordinary contact form and names it here, exactly as WeMeditate Web does.

Nullable on purpose. Unset is a live state the widget has to render — hiding
report-issue — rather than an error, so a `required` relationship would also
make the column NOT NULL on a table carrying a production row.

`filterOptions` pins it to `actionType: 'contact'` so the refusal lands on the
operator at authoring time. Without it `prepareUserSubmission` refuses the
mismatch with a 400 at send time, one visitor at a time, with nobody who can
fix it present.

Refs #813

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011T2g9wJShY6zF1oRZDoTb8
`Forms.recipient` is a relationship to `managers` carrying no field access, and
`forms` ships the form-builder plugin's own `read: () => true`, which
`accessPlugin` spreads last. `managers` sits in no project, and
`isCollectionVisibleInProject` reads that as shared rather than restrictive —
so a read of `forms` at `depth >= 1` populated the manager and handed a name and
an email address to whoever asked, browser included.

`managersOnlyFieldAccess` is the same lock `Clients.mailingList` carries, for
the same reason. Delivery is unaffected: `recipientFor` resolves the recipient
server-side with `overrideAccess: true`.

Also corrects the three comments stating the rejected premise behind #813 — that
the widget posts a `contact` row with no form at all. It does not, and
`user-submissions` never allowed it. The `CONTACT_EMAIL` fallback stays
load-bearing for the real reason: `recipient` is nullable, so a contact form
whose author named nobody still has to deliver somewhere.

Refs #813

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011T2g9wJShY6zF1oRZDoTb8
The atlas's report-issue form is authored in the CMS and read by the widget, so
`forms` belongs to the atlas as much as to WeMeditate Web.

It buys two of the three things a project's `collections` list drives. OpenAPI
visibility (`specFilter.ts`) is the load-bearing one: without it the widget's
own contract for the form it must render is absent from the atlas spec. Admin
nav is the second, and it reaches admin managers only — `createHidden` needs a
write grant, and `atlas-manager` holds none on `forms`, so form authoring stays
an admin task.

The third, implicit read, is a no-op here: the form-builder plugin's
`read: () => true` already outranks RBAC on this collection. The grant is still
wanted — it makes the atlas client's read an intended rule rather than an
accident of plugin defaults, which is what the new `hasPermission` case pins.

Refs #813

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011T2g9wJShY6zF1oRZDoTb8
Each one fails in a way the others cannot see, and each assertion was proven
by reintroducing the real defect and watching that case go red:

- Dropping `filterOptions` from `reportIssueForm` let a `subscribe` form be
  named on the global, which every report would then be refused against.
- Dropping `recipient`'s field access returned the manager to the atlas client
  at depth 0 already — `select` names `recipient` and the fixture form has one,
  so neither half of the assertion can pass vacuously.
- Dropping `forms` from the atlas project turned the `hasPermission` case
  false while both read cases stayed green. That is the useful half of the
  answer to the ticket's first open question: the form-builder plugin's
  `read: () => true` does reach these rows without the grant, so nothing else
  in the suite would notice the collection leaving the list.
- Flipping `recipientFor` to `overrideAccess: false` sent every report to
  `CONTACT_EMAIL` instead of the named recipient. A field lock that also broke
  delivery would satisfy every other case here and fail silently in production.

The delivery cases mock `sendUserMessage` and assert the address it is handed.
`deliverContact` had no coverage at all — nothing under `tests/` named it.

Refs #813

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011T2g9wJShY6zF1oRZDoTb8
Three passages this change falsifies:

`access.md` named `Clients.mailingList` as the only `managersOnlyFieldAccess`
consumer. `Forms.recipient` is the second, and its reason is worth stating
separately — the collection keeps a plugin `read: () => true`, so the lock is
the only thing between a manager's address and a browser.

`src/globals/AGENTS.md` enumerates `sy-atlas-config`'s fields, and the
enumeration is what a reader checks against.

`admin-ui.md`'s project table showed `forms` for We Meditate Web alone. The
atlas column carries the caveat rather than a bare tick, because `createHidden`
needs a write grant and `atlas-manager` holds none.

Refs #813

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011T2g9wJShY6zF1oRZDoTb8
…ck does not close

Review findings, applied:

`filterOptions` takes the plain-object form — the callback read none of its
arguments, and `UserChoices` already spells a static filter this way.

Four comments restated the nullable-`recipient` fallback. Before this branch
each carried a real fact (the widget posted no form at all); the branch deletes
that fact, leaving three that narrate the type. The statement stays once, at
the field.

The spec's duplicate `hasPermission` case is gone — `role-based-access` pins
the same rule for all three client roles, which is strictly stronger, and it
does so without paying a Payload bootstrap. The depth loop drops 2: a one-hop
`relationTo: 'managers'` has only id and populated to distinguish.

One finding is a fix, not a cleanup. The `recipient` docblock diagnosed a
root cause — `managers` is in no project, so implicit read treats it as
shared — and then locked one field, which reads as though the class were
handled. It is not: a published client key reads `managers` directly, and
`Events.manager` and `Regions.managers` carry no lock at all. Both reproduced
against a booted Payload and filed as #821. The comment now says so.

Rejected: a shared `testData.createForm` factory (six specs, outside this
diff); exporting the `{read, create, update}` access triple (second occurrence,
both sites carry a ⚠); dropping the `forms` project entry as inert (its
OpenAPI visibility is the point, and it was asked for on the ticket).

Refs #813

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

railway-app Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

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

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Sep 18, 2026 at 6:20 pm UTC
1 service not affected by this PR
  • mailpit

@sydevs-bot

sydevs-bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 18:10Z address-review · attempt 1 · session · done
  • 18:10Z address-review · attempt 1 · session
  • 18:01Z adversarial-review · attempt 1 · session · done
  • 18:01Z adversarial-review · 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 Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

The diff is the ticket's size and shape. Four source files, one migration, two specs, no smuggled refactor. The cross-repo contract holds: SahajAtlasWeb reads sy-atlas-config with select: { availableLocales: true } at depth 0 (src/config/api/fetch.ts:720), so reportIssueForm is inert until #213 opts in. The forms project entry does buy only the OpenAPI row, as the body claims.

Findings

  • should-fix — Forms.client has no lock beside the new recipient one, and the ⚠ note omits it. src/collections/Forms/fields.ts:70.

What was checked

  • managersOnlyFieldAccess is req.user?.collection === 'managers', so it denies anonymous callers too.
  • isCollectionVisibleInProject has four callers, none in relationship population.
  • recipientFor reads with overrideAccess: true, so the lock cannot starve delivery.
  • WeMeditateWeb reads no forms.recipient under server/, lib/, pages/, components/.
  • testData.createClient returns collection: 'clients', so the new spec reads as a real client.

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


Generated by Claude Code

Comment thread src/collections/Forms/fields.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 Sep 18, 2026
`Forms.recipient` got the lock; `Forms.client`, two definitions below it in
the same file, did not. Both sit on a collection that keeps the form-builder
plugin's `read: () => true`, and this branch is what puts that collection in
the atlas project — so a `sahaj-atlas-client` read at `depth >= 1` populated a
whole `clients` document, plaintext `apiKey` included (#822). That payload is
worse than the manager name and address the `recipient` lock closes.

`Clients.mailingList` is the precedent for the same collection reached the
other way round. `deliverSubscribe` resolves this field with
`overrideAccess: true`, so the lock cannot starve a subscription — the same
argument that makes `recipientFor` safe.

The spec case was proven by dropping the `access` block and watching it go
red at depth 0, where the bare id comes back.

Refs #813

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0154yFhSVDXv7XCxYkksAGzk
`Forms.client` now carries `managersOnlyFieldAccess`, and the count in the
field-access section was two.

Refs #813

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

Copy link
Copy Markdown
Contributor Author

Adopted the one review finding. Pushed f97378d.

docs/rules/access.md now names all three fields carrying the lock. Lean gate green, and the three touched integration specs re-ran green.

Nothing rebutted, nothing asked.

🤖 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 Sep 18, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 18, 2026 18:29
@sydevs-bot
sydevs-bot requested a review from Ardnived September 18, 2026 18:29
Merged via the queue into main with commit 3c627d2 Sep 18, 2026
23 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-813-atlas-config-form branch September 18, 2026 19:15
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Sep 18, 2026

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-823 — f97378da Deployed Sep 18, 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.

feat(sy-atlas-config): name the atlas report-issue form on the config global, and open forms to the atlas scope

3 participants