Skip to content

feat(api)!: unified intake, phase 1 — the user-submissions schema - #754

Merged
Ardnived merged 28 commits into
mainfrom
claude/feat-723-user-submissions-schema
Sep 15, 2026
Merged

Ardnived merged 28 commits into
mainfrom
claude/feat-723-user-submissions-schema

Conversation

@sydevs-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • Adds user-submissions — the one intake for contact, subscribe, registration and proposal — beside the three collections it will replace in Phase 3. Nothing is deleted here.
  • Locks the new table down: restricted, create-only for clients, and a manager's read narrowed per row to the contact messages addressed to them plus proposals.
  • Forms gain actionType with save-time validation, and lose the plugin's emails field — the pre-screening sendEmail path is now structurally unreachable.

Changes

  • src/plugins/formBuilder/ — the plugin's one configuration, shared with the test harness. It also does three things the plugin options cannot: clears the plugin's own access block, removes its sendEmail hook, and reuses validateProposal as the gate on proposed. Each is explained where it happens.
  • src/collections/UserSubmissions/ — the field list, the per-type beforeValidate, the submissionData bound, and the two JSON columns, declared with jsonField and Zod (refactor(fields): declare a JSON column with one jsonField helper #756). Two files: fields.ts and submissionData.ts, plus the hook.
  • src/collections/Users/ — gains the submissions join. It does not lose registrations or submittedEvents: nothing writes user-submissions until Phase 2, so all three sit side by side and the two legacy ones go in Phase 3.
  • src/plugins/access/ — RESTRICTED_COLLECTIONS, the role changes, and the per-row manager scope. The registrations: ['update'] grant, its uuid-scoped branch and restrictClientRegistrationUpdate are removed.
  • src/fields/logField.ts — the activity-log column now goes through jsonField too, with its shape in Zod.
  • src/migrations/20260914_172100_user_submissions.* and src/migrations/20260914_175014.* plus patches/[email protected] — the migration, the snapshot resync, and the patch that made generating them possible. src/migrations/AGENTS.md records all three.
  • package.json — the whole Payload family pins 3.86.0, for the patch-key reason below.

Preview

Migration

Two files, both included. src/migrations/20260914_172100_user_submissions.{ts,json} (the schema change) and src/migrations/20260914_175014.{ts,json} (a snapshot resync, no DDL), both generated attended by @Ardnived in 2d51e48 and fe3fbba.

20260914_172100_user_submissions renames rather than rebuilds, so existing form_submissions rows survive: form_submissions → user_submissions, its submission_data child table, and payload_locked_documents_rels.form_submissions_id. Then the intake columns, forms.action_type/recipient_id/client_id, and the drop of forms_emails + forms_emails_locales. user_submissions.form_id loses NOT NULL, as this body asked for. Validator: 4 pass, 0 fail.

Generating it first needed patches/[email protected] (b001669): applyPgSnapshotsDiff hands preparePgAlterColumns the raw pre-rename snapshot, so a renamed table with altered columns — every collection rename — is looked up under its new name and crashes. Unfixed upstream through 0.31.10, and @payloadcms/db-postgres pins 0.31.7 exactly, so the Payload family drops its carets to keep the patch matching. All ten packages, not two (1a0a690): Payload does not support a mixed-version family, so pinning payload alone left one pnpm update able to put @payloadcms/[email protected] beside it. No version moves — only the nine specifier: lines change in the lockfile, and pnpm install --frozen-lockfile accepts it.

The snapshot chain is healed. 20260914_175014.json was generated on the merged tree, so it carries both user_submissions and main's 20260909–20260913 schema, and it is the highest-timestamp snapshot. pnpm db:migrations:create <probe> --skip-empty now writes no files, which is the proof that snapshot and config agree exactly. Re-run after the latest main merge, and again after the round-2 review: still no files.

⚠ Its .ts half had to be emptied (d4cafc5). It was generated against the stale predecessor, so all 142 of its statements re-emitted DDL that nine earlier migrations already apply — every statement checked against the rest of the chain, none of them new. Replaying it aborts the boot migration on its first statement (CREATE TYPE "enum_wm_app_config_available_locales" already exists), and the DROP COLUMNs below it would take the translation columns with them. That is #566, the out-of-order snapshot trap. Nothing rolls back: the migration fails on statement one, so it commits no schema and leaves no payload_migrations row. The snapshot is kept, the DDL is gone, and the file's docblock names the nine migrations that already ship it.

No translation reseed is needed. The drops that prompted that concern lived in the emptied up(), and each was a re-emission of a drop main had already made. No live column loses data.

⚠ CI cannot see this class of defect. push: !isProduction in src/payload.config.ts means dev and every test lane sync the schema with Drizzle push and never replay the migration chain. Only a Railway boot runs prodMigrations, so the preview deploy is the check that matters for this folder.

Test results

  • Lean gate at fd278c3: ✓ lint, tsc over src/, tsc over tests/, unit lane (2045 tests, 143 files)
  • Targeted specs at fd278c3: user-submissions-access, user-submissions-create, forms-action-type — 3 files / 44 tests, all green. Earlier rounds also ran event-verification, atlas-seo, role-based-access, event-submissions, event-registration
  • pnpm generate:types leaves src/payload-types.ts byte-identical at fd278c3, which is the evidence this round moved no shape
  • Snapshot probe: db:migrations:create --skip-empty exits 0 and writes no files — before and after the latest main merge, and after the round-2 review. Not re-run this round: no field's shape changed
  • Build: N/A (Railway builds the preview; CI does not build)

Manual verification

  1. Watch the preview boot. It is the only environment that replays the migration chain. A clean boot is what confirms 20260914_175014 no longer aborts it.
  2. In /admin: author a contact form with a recipient and a subscribe form with a client. Confirm a subscribe form with no email field refuses to save, and that the Forms edit view shows no emails feature.
  3. curl -X POST $URL/api/user-submissions as an atlas client for each of the four types, with and without x-turnstile-token, and from a disallowed Origin.
  4. Load an existing page whose rich text embeds a form — the relationship node must still resolve.
  5. Open and re-save an existing production form. Every pre-existing row back-fills to actionType: 'contact', and the save-time rule then applies to it. It is deliberately scoped to saves that change the field list, the action or the client, so a rename should pass even on a legacy form that lacks a message field — that scoping is what stops such a row becoming unsaveable, and it is worth confirming against real data.
  6. Save an existing Event and an existing Registration that already carry an activityLog. logField now declares a schema, so that column is validated on every save of those documents. The schema is deliberately all-optional for this reason, but production rows are the one thing no test here reads.
  7. Open a Registrant in /admin. Three joins now show: Submissions (empty until Phase 2), Registrations, and Submitted Events.

Notes for reviewer

Four judgement calls worth checking, each a deviation from #695's written plan or a decision it did not cover:

  • The plugin's sendEmail hook is removed, not merely starved. feat(api)!: unify public intakes on the form-submissions pipeline #695 said stripping emails would make it take its "nothing to send" branch. It does not get that far: it spreads data.submissionData and loads data.form, both optional here, so it threw and logged an error on every registration and proposal. Nothing is swallowed — no email can be authored, so there is provably none to send.
  • The plugin's access block is cleared for user-submissions. accessPlugin composes { ...rbac, ...collection.access }, so the plugin's own block outranked the role table, the manager scope and RESTRICTED_COLLECTIONS together — including an anonymous, captcha-free create. This was pre-existing on form-submissions and would have carried over silently.
  • validateProposal is reused rather than re-derived, which means user-submissions imports from EventSubmissions/. It moves to a shared home in Phase 3 when that collection is deleted; duplicating the gate now would leave two definitions to reconcile.
  • seeds/lib/tagManager.ts needed a cast. Adding a required actionType to forms broke it: payload.create with a CollectionSlug-typed variable demands the required fields of every collection at once, and forms was the union member that { title } happened to satisfy. The helper has no callers.

Two scope limits stated rather than hidden: the submissionData bounds are create-time only (no client holds update; a manager editing a row is trusted, not checked), and proposed values are unbounded beyond a 60-key cap — the same shape event-submissions has today.

What Ardnived's review changed (round 4)

One thread, one commit. Nothing behavioural — the collection's runtime is untouched.

  • types.ts is gone (fd278c3). Round 3 left this open because folding the module would make the pure submissionData.ts import fields.ts. The review's answer removed that objection rather than arguing with it: adapt each consumer to name the generated union itself, instead of routing it through a module that only forwards it. submissionData.ts writes UserSubmission['type'] twice, fields.ts once, prepareUserSubmission.ts three times, and each imports @/payload-types, which is types only — so no zod or logField reaches the unit lane.
  • That is the rule src/types/AGENTS.md already states: a derived alias stays local and is never re-exported. SubmissionType and SubmissionStatus were exported aliases for UserSubmission['type'] and ['status'], which is the re-export chain the rule names — deleted, not repointed.
  • The runtime halves move to fields.ts, beside the selects they build — the same fold proposal.ts (b4c2d8f) and screening.ts (3b17fca) got. SUBMISSION_STATUSES and STATUS_LABELS stop being exported at all: statusField is their only reader.

pnpm generate:types leaves src/payload-types.ts byte-identical, which is the evidence no shape moved.

What Ardnived's review changed (round 3)

Three threads, one commit. Nothing behavioural — the collection's runtime is untouched.

  • screening.ts is folded away (3b17fca), the way proposal.ts went in b4c2d8f. It held one const with one consumer and an alias with none. SUBMISSION_VERDICTS now sits in fields.ts beside screeningResultField, which builds the schema's enum from it, and the module's one substantive paragraph — why the machine verdict lives in that column and never in status — moves onto the field. SubmissionVerdict is deleted, not re-derived: the list already generates SubmissionScreeningResult['verdict'], so an exported alias is the second definition src/types/AGENTS.md says to delete rather than repoint. A Phase 2 reader takes the generated type directly.
  • types.ts stays, and that thread is left open. ⚠ Superseded in round 4 above — the file is gone. What this round left standing was the objection that folding it would make the pure submissionData.ts import fields.ts; the review answered it by pointing each consumer at @/payload-types directly.
  • submissionData.ts's checks stay hand-written, and that thread is left open. Measured rather than argued this time: on zod 4.3.5, z.array(T).max(3) parses all 50,000 elements before the length check refuses, so a naive port loses the deliberate short-circuit at submissionData.ts:121 — the one that stops a 100k-entry array being walked on a public endpoint. A faithful port keeps today's loop inside a superRefine, because the allowed keys come from the live forms document per request, the cap is per key, and each message names the offending key as contract.

There is no UserSubmissions.ts to move anything into: formsPlugin assembles the collection from userSubmissionFields, so fields.ts is that file here.

What Ardnived's review changed (round 2)

Six threads, five commits. One behavioural change; the rest are how a shape is declared.

  • The subscribe reach check is gone (94bd58f), as asked. Any client role may now subscribe a person to any client's list. The subscribe_target_forbidden 403, the UNRESTRICTED_SUBSCRIBE_ROLES exemption, its integration case and the row in docs/rules/api-clients.md go with it. The type/actionType reconciliation stays: it kept this check reachable, but every per-type rule keys on type independently.
  • Both JSON columns are declared with jsonField and Zod (4dec4cc), the pattern refactor(fields): declare a JSON column with one jsonField helper #756 established after this branch was cut. screeningResult is a z.strictObject, proposed a bounded z.looseObject, both inline at their fields. screening.ts kept SUBMISSION_VERDICTS and carried no schema. ⚠ That file is gone as of round 3 above, and the "a leaf an admin component may import" reasoning went with it — it had no such importer.
  • logField does the same (c75de38). It was building its own { uri, fileMatch, schema } wrapper and exporting an ACTIVITY_LOG_SCHEMA_URI — exactly the constant refactor(fields): declare a JSON column with one jsonField helper #756 deleted everywhere else. Nothing imported it. The shape is unchanged: every key optional, the entry open, cap 500, because Payload validates this column on every save of the document.
  • SubmissionType and SubmissionStatus derive from @/payload-types (9ec9ac3) instead of (typeof ARRAY)[number]. The const arrays stay — fields.ts builds the selects from them — so deriving the types back closes the loop, and a new option without a label is now a compile error. ⚠ Round 4 finished this: the two aliases are deleted, and each consumer names the generated union itself.
  • blockTypes is inlined (a64d2f8) at its one call site. That thread is resolved.
  • prepareUserSubmission's checks stay hand-written, and that thread is resolved. The columns moved to Zod; what remains is not shape validation — see the measurement in round 3 above.

pnpm generate:types regenerates src/payload-types.ts byte-identically across all three schema conversions, which is the evidence that no shape moved.

What the adversarial review changed

Five findings, five commits. Nothing behavioural beyond the first.

  • Users kept its two legacy joins (9d57d11). The new submissions join replaced registrations and submittedEvents, but nothing writes user-submissions this phase — registerForEvent still creates registrations, event-submissions still takes proposals. So the replacement showed nothing while the two it replaced were the admin's only window onto a registrant's history, against a ticket saying this phase changes no old behaviour. All three now sit side by side.
  • The whole Payload family pins 3.86.0 (1a0a690) — see the Migration section above.
  • One home for the sendEmail story (0a744e7). It was told three times and one telling was wrong: Forms/fields.ts and the first formBuilder docblock both said stripping emails disables the hook. It does not — the hook throws before it reads emails. The detailed docblock also sat on formBuilder while describing formsPlugin. It moves onto formsPlugin and is now the one statement; the other two point at it.
  • subject's docblock says what it is composed from (b4f2130). It claimed "not client-writable: it is derived". The column is denied to clients, but composeSubject joins the sender's own subject pair into it, so unreviewed text does reach the admin list title. Bounded (URL-scanned, capped, truncated to 300) rather than trusted — wording, not a hole.
  • proposal.ts folded into fields.ts (b4c2d8f): 38 lines for one constant with one consumer. ⚠ The reply on that thread said UserMessages imports screening.ts's schema; it does not — UserMessages/screening.ts is its own file. UserSubmissions/screening.ts turned out to have one consumer too, and folded in round 3.
What the merge with main resolved

Three conflicts in the first merge, all additive on both sides:

  • pnpm-workspace.yaml — main's undici: '^7.29.1' override and this branch's patchedDependencies block both kept.
  • src/migrations/index.ts — main's seven migrations (20260909–20260913) kept ahead of this branch's 20260914_172100_user_submissions, which stays last by timestamp.
  • src/payload-types.ts — generated, so both sides' interfaces were kept and the file was then regenerated with pnpm generate:types.

The second merge (#781, #784 — atlas translations) was clean and added no migration. So was the third (#785, #786).

What the earlier reviews changed

An adversarial security pass and a code-quality pass both ran over the branch. Nine findings held up and were fixed; each has a test.

Would have shipped a defect:

  • An unrecognised type string crashed the public POST with a 500 — the hook runs before Payload validates the select's options, so the cast reached TYPE_SUBMISSION_KEYS[type] and spread undefined. Now a 400 naming the value.
  • type was never reconciled with the form's actionType, so a row could be judged by the rules of a type its form does not accept. Closed now. (It also kept the since-removed subscribe reach check reachable — see round 2 above.)
  • activityLog was client-writable. logField's docblock claimed it was "never writable through the API" and said so nowhere the server reads. The admin renders it as system-written history, so a forged delivery record would have read as fact. Now denied to clients — deliberately not a flat update: () => false, because the admin verify action writes that log with overrideAccess: false on purpose, and a blanket deny silently dropped the record of who verified a listing. That regression is what the narrower rule is for; event-verification.int.spec.ts caught it.
  • validateFormAction merged with ??, which reads an explicitly cleared relationship as the old value — so clearing a subscribe form's client passed the one rule the hook exists for.
  • The subject line echoed the title of any event id a client named, drafts and trashed rows included, routing around the published-only narrowing a client's own reads get.

Test quality:

  • Three cases could not fail for their own rule (a form fixture that also broke a second rule; a ?? [] join assertion that could not tell "filtered to nothing" from "never populated"; an "admins read everything" case that read with overrideAccess: true). All three now assert the property they name.

Bounds and accuracy: the entry cap now short-circuits instead of emitting one message per row; activityLog gained maxItems; a .catch(() => null) that turned a transient database error into a 400 blaming the integrator is gone; the dead urlScanFields: ['subject'] entry is removed with a note saying why; and the docs' claim that both new refusals are 400 is corrected. (subscribe_target_forbidden was 403, and is since removed — see round 2 above.)

Reported and deliberately not changed: proposed's unbounded values (parity with event-submissions, noted above); URL_EXEMPT_KEYS being wider than the crash-report case strictly needs (pinned as a constraint on Phase 2's templates in a comment, since nothing renders those pairs today).

Detail

Why submissionData is not in the write-guard's urlScanFields. A path there is walked by stringLeaves, which flattens the whole [{field, value}] array — and that array now carries the crash-report context (error, hostUrl, path) that user-messages exempted on purpose, because a bug report names the page it happened on. Listing it would refuse every issue report the Atlas widget sends. The pairs are scanned by prepareUserSubmission instead, which can tell one key from another, and raises the same urls_not_allowed failure.

Why the allowed-key check is a hook and not a jsonSchema. submissionData is the plugin's array field, not a JSON column, so Ajv never sees it. It also has to be per-type: a contact row's legitimate keys are whatever its form's author named, read from the live forms document.

Why the refusal is an APIError. A ValidationError's top-level message is composed from field paths ("The following field is invalid: submissionData") and the per-error text is buried, so the offending key — the thing the acceptance criterion asks for — never reaches the body an integrator reads. Forms keeps ValidationError, because there the admin UI surfaces the per-field message.

Why client is not required on a subscribe form. The rule is per-action, and required: true is a column-level NOT NULL that would demand one of every contact form too, on a table that already has rows. It lives in validateFormAction.

Every rule added here was re-run with itself disabled, and each went red: the access matrix (3 cases), the form-action rules (2 + the ?? merge), the submission-data matrix (2).

Closes #723

🤖 Generated with Claude Code

https://claude.ai/code/session_01XpWhgSLpDEgsryNu4btTJt

…phase 1)

Phase 1 of #695, per #723: the form-builder plugin's submissions collection
is renamed `user-submissions` and given the typed columns every public write
needs, beside the three collections it will eventually replace. Nothing is
deleted here — `registrations`, `user-messages` and `event-submissions` keep
working until Phase 3.

- `formSubmissionOverrides.slug` + a `fields` override adds `type`, `uuid`,
  `status`, `senderEmail`, `user`, `client`, `subject`, `screeningResult`,
  `activityLog`, `event`, `startingAt`, `unsubscribedAt`, `eventFeedback`,
  `followUpSentAt` and `proposed`. `submissionData` keeps only the flat
  free-form remainder, since it is client-writable as one blob and nothing
  queryable, unique, relational or system-gated can be protected inside it.
- `prepareUserSubmission` (beforeValidate) enforces per-type allowed keys and
  lengths on that blob, issues the `uuid`, composes `subject`, upserts the
  sender into `users`, and stamps provenance from the authenticated key.
- The plugin's unconditional `form` requirement becomes per-type: required for
  `contact` and `subscribe`, refused for the two that name an `event`. The
  plugin's own existence check is composed with, not replaced.
- Forms gain `actionType` with conditional `recipient` / `client`, save-time
  validation of the authored field list, and lose `emails` — a structural
  disable of the plugin's pre-screening `sendEmail`, not a suppression.
- Every `type: 'json'` column declares a `jsonSchema`, `logField`'s included.
  Its entries stay open (`additionalProperties: true`) because machine data is
  each writer's own; `LogDisplayCells` declares the matching index signature.
- `user-submissions` joins RESTRICTED_COLLECTIONS and leaves the wemeditate-web
  project. Clients get create-only; a manager's read is narrowed per row to
  contact rows addressed to them plus proposals.
- The `registrations: ['update']` client grant, its uuid-scoped access branch
  and `restrictClientRegistrationUpdate` are removed. The vote's only writer is
  the CMS-hosted feedback page, which writes with `overrideAccess` — that grant
  was an open write path nothing used.
- `Users` shows one `submissions` join in place of `registrations` and
  `submittedEvents`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QYXZbMFo1WvADtgEwSxHXP
…form actions

Four spec files, plus the two the change re-points.

Each caught a defect while being written, which is the reason for the shape
they take:

- `user-submissions-access.int.spec.ts` reads rows back through
  `overrideAccess: false` rather than asserting grants, and found that the
  form-builder plugin's own `access` block outranks the whole RBAC layer
  (`accessPlugin` composes `{ ...rbac, ...collection.access }`). Its
  `read: !!user` would have granted every API client read of every stranger's
  message, with `RESTRICTED_COLLECTIONS` looking like it applied. The plugin's
  `access` is now cleared for this collection.
- `user-submissions-create.int.spec.ts` found the Turnstile stub succeeding for
  any argument, so the "no token" case passed for the wrong reason; found the
  offending key missing from a `ValidationError`'s message, which is the one
  thing the acceptance criterion asks for; and found the plugin's `sendEmail`
  throwing once per form-less submission.
- `forms-action-type.int.spec.ts` pins the save-time rules and that `emails` is
  absent from the sanitized config.
- `submission-data.spec.ts` holds the per-type key matrix in the unit lane, and
  the URL-scan exemption that keeps a crash report from reading as spam.

The access, form-action and submission-data specs were each re-run with the
rule they cover disabled, and each went red.

`event-feedback.int.spec.ts` is re-pointed at the real writer: the feedback
page's server action, which votes with `overrideAccess`. Its client-vote block
becomes the assertion that no client write path exists.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QYXZbMFo1WvADtgEwSxHXP
Two corrections found reviewing the branch against `src/collections/AGENTS.md`.

`proposed` reaches `user-submissions` from a public POST and is a patch of real
Events fields, so Phase 3's accept path would apply it to an Event with a
manager's authority behind it — a submitter setting `verificationStage` mints a
verified listing, and `registrationNotificationEmail` forwards registrants'
answers to an inbox of their choosing. `validateProposal` is `event-submissions`'
own gate and derives its allowlist from the live Events config, so it is reused
rather than re-derived. It moves to a shared home in Phase 3, when that
collection is deleted.

`activityLog`'s schema now declares no `required` keys. Payload runs a JSON
validator on every save of the document, including one that never touches the
column — and this column predates the `logField` factory: it was Registrations'
`reminderLog`, whose entries were reminders with no `cells`. A `required` list
would have made any row holding one permanently unsaveable, which no test here
could see because no test holds a pre-#626 row. Type checks on the properties
that are present still apply.

The verification spec's hand-built log fixture is rebuilt with the real entry
builders either way: the entries it spelled out omitted `type` and `cells`,
which nothing that writes the column omits, so the crash it simulates was a
state the app cannot reach.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QYXZbMFo1WvADtgEwSxHXP
…ules

The new refusal codes, the URL-scan exemption, and the create-only grant are
things an integrator observes, so they belong beside the Turnstile contract
rather than only in the code that raises them. Also corrects a cross-reference
in EventSubmissions to the Users join that replaced `submittedEvents`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QYXZbMFo1WvADtgEwSxHXP
Nine findings from a security pass and a code-quality pass over the branch.
Five would have shipped a defect; each now has a test that fails without the
fix.

- **An unrecognised `type` crashed the public POST with a 500.** This hook runs
  before Payload validates the select's options, so the cast reached
  `TYPE_SUBMISSION_KEYS[type]` and spread `undefined`. Checked now, with the
  same 400 the neighbouring refusals use.
- **`type` was never reconciled with the form's `actionType`**, and
  `enforceSubscribeReach` keys on `type` — so a restricted client could post
  against another client's subscribe form while calling the row a `contact`,
  and the reach check never ran. The form is the authority; a disagreement is
  refused rather than silently corrected.
- **`activityLog` was client-writable.** `logField`'s docblock promised it was
  never writable through the API and stated that nowhere the server reads, which
  did not matter while the column sat on collections no client could write. The
  admin renders it as system-written history. Denied to clients — deliberately
  not a flat `update: () => false`, because the admin verify action writes that
  log with `overrideAccess: false` so the manager's own permissions gate it, and
  a blanket deny silently dropped the record of who verified a listing.
- **`validateFormAction` merged with `??`.** Payload normalises a cleared
  relationship to `null` and hands the hook data already merged with the stored
  document, so clearing a subscribe form's client read as the old client and
  passed the one rule the hook exists for. It now reads the merged value, and
  judges a save only when it changes the field list, the action or the client —
  which is also what stops a legacy form, back-filled to `contact` and lacking a
  message field, becoming unsaveable on an unrelated edit.
- **`subject` echoed the title of any event id a client named**, drafts and
  trashed rows included, routing around the published-only narrowing a client's
  own reads get.

Three test cases could not fail for their own rule: a form fixture that also
broke a second rule, a `?? []` join assertion that could not tell "filtered to
nothing" from "never populated", and an "admins read everything" case reading
with `overrideAccess: true`. All three assert the property they name now.

Also: the entry cap short-circuits instead of emitting one message per row;
`activityLog` gained `maxItems`; a `.catch(() => null)` that turned a transient
database error into a 400 blaming the integrator is gone; the dead
`urlScanFields: ['subject']` entry is removed with a note saying why field
access had already emptied it; and the docs' claim that both new refusals are
400 is corrected — `subscribe_target_forbidden` is 403.

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

railway-app Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

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

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

@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-754 September 9, 2026 16:54 Destroyed
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 9, 2026
@sydevs-bot

sydevs-bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
CI fix 3

recent dispatches
  • 15:49Z address-review · attempt 1 · session · done
  • 15:49Z address-review · attempt 1 · session
  • 15:29Z address-review · attempt 1 · session · done
  • 15:29Z address-review · attempt 1 · session
  • 15:19Z address-review · attempt 1 · session

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

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

CI is red on one smoke spec. POST /api/images returns 500 against the Railway preview (tests/e2e/images.e2e.spec.ts). I could not fix it in this pass.

Ruled out. No changed file touches Images, the upload path, the storage adapter or sharp. Lint, typecheck, unit and integration all passed in the same run. Of the eight e2e specs the image upload is the only write, and the rest passed or skipped. The absent migration is not it either: the preview boots, and an images write reads no drifted table.

What remains. Reproducing needs the deployed preview and its Cloudflare Images credentials, which a routine lacks. Two candidates:

Read the Railway deploy log for the stack. debug is off in production since #692, so the 500 body says nothing.

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


Generated by Claude Code

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

Copy link
Copy Markdown
Contributor Author

Correcting the comment above: the missing migration is the cause. It was ruled out wrongly.

Sentry caught the stack from the smoke run — environment SahajCloud-pr-754, release cebb548, POST /api/images, three events for the three retries:

column ..._rels.user_submissions_id does not exist
Failed query: select distinct ... from "payload_locked_documents"
  left join "payload_locked_documents_rels" ...

Payload checks document locks on every authenticated write, and that join carries one column per collection. formSubmissionOverrides.slug renames form-submissions to user-submissions, so the preview database lacks the column. Every write to the preview fails, not only images. #741, sharp and Cloudflare Images are not involved.

The PR body's "this fails on deploy, not on CI" is the same mistake. The smoke lane runs against the preview, which migrates on boot.

No fix-ci pass can turn this green. The next step is the attended one you already wrote:

timeout 300 pnpm db:migrations:create user_submissions_schema --skip-empty

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


Generated by Claude Code

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 9, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

CI is still red after 3 fix attempts (failing: Lint, Test & Smoke). I have stopped retrying. A comment or a push from you starts me again.

🤖 sydevs dispatcher

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

This draft has had no CI activity for hours and no session holds it. Comment or push to wake me.

🤖 sydevs dispatcher

@Ardnived

Copy link
Copy Markdown
Contributor

@sydevs-bot CI is failing and needs to be fixed

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Sep 10, 2026
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-754 September 10, 2026 05:20 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

CI is red for one reason: this PR still has no migration.

The Railway preview runs this branch's code against a database that never got its schema. GET /api/forms on the preview returns 500 — forms.action_type does not exist — while every other collection returns a normal 403. The smoke lane runs against that preview, which is why images.e2e fails.

Pushed e2f7c8d: main merged in, clean. Lint, both typechecks, the unit lane (1692) and role-based-access.int.spec.ts (65) all pass.

I need one attended run from you:

pnpm db:migrations:create user_submissions_schema --skip-empty

It stops on Is user_submissions_submission_data table created or renamed from another table?, now offering five choices. create drops the existing rows, rename keeps them. Read SELECT count(*) FROM form_submissions on production before you pick.

I did not answer it blind: src/migrations/AGENTS.md says hand it off, and the answer becomes DDL that auto-applies on boot.

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


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 10, 2026
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. awaiting labels Sep 15, 2026
`screening.ts` held one const with one consumer and an alias with none, so
it goes the way `proposal.ts` went in b4c2d8f. `SUBMISSION_VERDICTS` now sits
beside `screeningResultField` in `fields.ts`, which builds the schema's enum
from it, and the module's one substantive paragraph — why the machine verdict
lives in this column and never in `status` — moves onto that field.

`SubmissionVerdict` is deleted rather than re-derived. Nothing imported it, and
the list already generates `SubmissionScreeningResult['verdict']`; an exported
alias would be the second definition `src/types/AGENTS.md` says to delete, not
to point somewhere else. A Phase 2 consumer reads the generated type directly.

`pnpm generate:types` leaves `payload-types.ts` byte-identical, which is the
evidence no shape moved.

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

Copy link
Copy Markdown
Contributor Author

Three threads answered. One commit, pushed to 3b17fca.

Adopted and resolved

  • screening.ts folded away — SUBMISSION_VERDICTS sits beside screeningResultField; SubmissionVerdict is deleted, since the list already generates SubmissionScreeningResult['verdict']

Open, for you

  • Zod in submissionData.ts — measured: z.array(T).max(3) parses all 50,000 elements before refusing, so a port loses the short-circuit that stops a 100k-entry array being walked
  • types.ts inline — three consumers, not one; folding it pulls zod into a pure module

There is no UserSubmissions.ts: formsPlugin builds the collection from userSubmissionFields.

Lean gate green (2045 tests), three integration specs green (44). payload-types.ts regenerates byte-identically.

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


Generated by Claude Code

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 15, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

One thread answered. Nothing pushed — the branch stands at 3b17fca.

Open, for you

  • Zod in submissionData.ts — you asked whether it is simpler to maintain. Measured: 44 code lines today, 40 in Zod, the same loop inside superRefine. It costs the short-circuit at line 121. Your call.
  • types.ts inline — unchanged from the last round: three consumers, and folding it pulls zod into a pure module.

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


Generated by Claude Code

@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. awaiting labels Sep 15, 2026
`UserSubmissions/types.ts` is gone. Its two exported aliases were the
re-export chain `src/types/AGENTS.md` prohibits: `SubmissionType` and
`SubmissionStatus` already spelled `UserSubmission['type']` and
`['status']`, and exporting them gave each shape a second home for every
consumer to reach through.

Each consumer now names the generated union at its own call site —
`submissionData.ts` twice, `fields.ts` once, `prepareUserSubmission.ts`
three times — so no file imports a type from another module that is only
forwarding one. With `submissionData.ts` off the module entirely, the
pure-module objection that kept `types.ts` alive last round is gone: it
takes `@/payload-types`, which is types only, and pulls no `zod` or
`logField` into the unit lane.

The runtime halves move to `fields.ts`, beside the selects they build —
the same fold `proposal.ts` and `screening.ts` got. `SUBMISSION_STATUSES`
and `STATUS_LABELS` stop being exported: only `statusField` reads them.

No shape moves. `pnpm generate:types` leaves `src/payload-types.ts`
byte-identical.

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

Copy link
Copy Markdown
Contributor Author

One thread answered. One commit, pushed to fd278c3.

Adopted and resolved

  • types.ts inline — the file is gone. Each consumer now names UserSubmission['type'] itself, which is what removed my objection: the pure submissionData.ts imports @/payload-types, types only, so no zod reaches the unit lane. The runtime const arrays move to fields.ts, beside the selects.

SubmissionType and SubmissionStatus are deleted rather than repointed — exported aliases for a generated union are the re-export chain src/types/AGENTS.md prohibits.

Still open, for you

  • Zod in submissionData.ts — unchanged: 44 code lines today, 40 in Zod, and it costs the short-circuit at line 121. Your call.

Lean gate green (2045 tests), three integration specs green (44). payload-types.ts regenerates byte-identically.

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


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 15, 2026

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-754 — fd278c31 Deployed Sep 15, 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(api)!: unified intake, phase 1 — the user-submissions schema

3 participants