Skip to content

feat(api)!: unified intake, phase 3 — cutover, and delete the three old collections - #801

Merged
sydevs-bot merged 19 commits into
mainfrom
claude/feat-725-unified-intake-cutover
Sep 16, 2026
Merged

sydevs-bot merged 19 commits into
mainfrom
claude/feat-725-unified-intake-cutover

Conversation

@sydevs-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • One public intake. registrations, user-messages and event-submissions are gone, with their jobs, their tables and POST /api/events/{id}/register; every caller reads user-submissions.
  • The proposal review path, the registration gates and fullness, the feedback page, the reminder and follow-up sweeps and the manager digest all moved first, so nothing is deleted while something still reads it.
  • The Atlas seed importer writes type: registration rows, so a seeded database has the shape a live one now has.

This is all five children of #725 in one PR, in dependency order: #796 → #797 → #798 → #799 → #800, one commit per behaviour.

Changes

  • src/collections/UserSubmissions/{lifecycle,endpoints,hooks}/ — the review path, the registration gate, and the vote hooks, moved and re-pointed.
  • src/lib/registrations/fullness.ts — one countActiveRegistrations, now a single count over user-submissions.
  • src/jobs/RegistrationNotifications/ — all three jobs read the row's own columns and submissionData pairs.
  • seeds/atlas/import.ts — importRegistrations creates user-submissions rows keyed on the dump's uuid.
  • src/migrations/20260916_144804_drop_legacy_intake_collections.ts — the three tables, five enums and three payload_locked_documents_rels columns.
  • DEPLOYMENT.md, permissions.ts, payload.config.ts, formBuilder/index.ts, deliverProposal.ts, SubmissionActions.tsx — the deleted collections' names, off live code and docs (01c22e1).
  • src/collections/UserSubmissions/fields.ts — proposalPreviewTargetField opens the Live Preview panel on a proposal row and on no other intake (415e004).

Preview

  • User Submissions list — one table, four intakes; filter type: registration
  • A proposal row — the diff panel, Accept/Reject, and the live preview, which now opens on arrival
  • Events list — open one: its Registrations tab lists registration rows only
  • A user — one Submissions join where there were two

Email previews

None generated. The src/emails/ changes are a type import and a rename. UserMessageEmail now declares the UserMessageContext it renders, instead of importing it from a deleted collection's generated type. EventSubmissionReviewEmail is now SubmissionReviewEmail: it serves the proposal review job, not a collection that no longer exists. No template output changes.

Contract impact

Breaking, and it ships with sydevs/WeMeditateWeb#78 and sydevs/SahajAtlasWeb#195 — pnpm types:cms reads main, so both consumers sync after this merges. Registration, UserMessage and EventSubmission leave src/payload-types.ts, and POST /api/events/{id}/register returns 404.

src/collections/Events/endpoints/responseTypes.ts stays at its path — SahajAtlasWeb's types:cms curls that exact raw URL with curl -fsSL, so a move takes the whole chain down. It keeps EventRegistrationErrorCode, which the create gate still emits; EventRegistrationResponse is gone with the endpoint that returned it. EventRegistrationError now describes Payload's envelope, where the code sits at errors[].data.code — sydevs/SahajAtlasWeb#171 reads both positions.

Event['registrations'].docs retypes from Registration[] to UserSubmission[], so the types:cms sync is a breaking type change rather than an additive one. Neither consumer reads that field, so nothing downstream has to move.

Migration

  • New migration: src/migrations/20260916_144804_drop_legacy_intake_collections.ts
  • Impact: drops registrations, user_messages, event_submissions, their five enums, and the three payload_locked_documents_rels columns with their FKs and indexes. It also deletes payload_jobs / payload_jobs_log rows naming the three removed task slugs.
  • Reversible: the schema, yes — down recreates every object. The deleted job rows and the three tables' contents are not restored, which is the intended hard cutover: there are no live deployments and no production data in them.

Test results

  • Lean gate: ✓ pnpm lint && pnpm typecheck && pnpm typecheck:tests && pnpm test:unit — 2119 unit tests pass, re-run on 415e004
  • Targeted specs: ✓ the full integration lane on 01c22e1, 1311 tests across 80 files — this phase deletes collections, so a stale reference anywhere surfaces there. On 415e004, the three user-submissions int specs (create, access, review lifecycle), 58 tests
  • Generated files: ✓ generate:types and generate:importmap both produce no diff on 415e004 — a ui field adds no column, and PreviewTarget was already registered by Meditations
  • Migration: ✓ applied to a fresh database carrying the whole chain, with a payload_jobs row seeded for each removed slug. It succeeds, the unrelated screenSubmission row survives, and none of the dropped objects remain
  • Build: N/A — Railway builds the preview

Manual verification

  1. Register through the Atlas widget against a full event: the widget shows its "Full" message, from a 409 whose code is at errors[].data.code.
  2. Walk the post-event feedback flow end to end: follow-up email → feedback page with the vote preselected → vote recorded on the user-submissions row → event tallies updated → redirect with the post-vote param.
  3. curl -X POST $URL/api/events/1/register returns 404, and /api/docs shows no path for any of the three deleted collections.
  4. pnpm seed atlas, then filter /admin/collections/user-submissions by type: registration: rows carry an event, a startingAt, a linked user and the question pairs. Re-run it and the count is unchanged. Mailpit shows no new mail.
  5. Open /admin/collections/users: one Submissions join, no join error on boot.
  6. Open a proposal row: the Live Preview panel is already open. Open a contact, subscribe or registration row: it is not, and nothing shows the not-reviewable page unless you open the panel yourself.

Notes for reviewer

The Live Preview panel now opens itself on a proposal (415e004, review thread). admin.openByDefault is collection-wide and takes a value rather than a function, so on a table holding four intakes it would greet the other three with the not-reviewable page — which is why it was absent. A field branches where the option cannot: proposalPreviewTargetField is a previewTargetField({ autoOpen: true }) carrying admin.condition on type === 'proposal', and a false condition returns in addFieldStatePromise before Payload attaches the custom component to form state, so PreviewTarget never mounts elsewhere. It declares autoOpen alone, so composeTargetUrl returns null and the panel keeps the URL livePreview.url already resolved per type.

Two placement questions, answered rather than moved. src/lib/registrations/fullness.ts has two owners — Events' syncFullness and UserSubmissions' syncFullness plus gateRegistration — so src/AGENTS.md rule 4 keeps it in src/lib, and colocating it would force the cross-owner internal import that rule prohibits. feedbackLinks.ts is not imported by UserSubmissions at all: its consumers are SendPostEventFollowUps and the two /registrations/feedback route files. The buildWebPath pattern is colocated because the collection itself consumes it (Events.ts reads buildEventWebPath for both publicUrlFields and livePreview.url), which is the part that does not hold here. Both threads are left open for you to settle.

What still carries a deleted collection's name, after 01c22e1. Two things, both deliberate. src/migrations/20260812_032435_add_event_submissions and its index.ts entry: an applied migration is immutable, and renaming one breaks every database that recorded it. And past-tense comments that say why the surviving code is shaped as it is — statuses.ts on the open set event-submissions had no equivalent for, localizedRoles.ts on the ?locale=all over-grant, writeGuard/policies.ts on how proposed was scanned. Those are the reason a reader does not re-derive a decision. Everything else that named one of the three is gone.

Two leftovers this PR does not take, both behaviour rather than naming. Say if you want either in here.

  • deliverProposal still routes a brand-new-event proposal to the system contact. That was forced — Phase 1's user-submissions had no region column. It is not any more: the row carries region and regionHint, and screening resolves the first from the second, so findManagerForRegion is reachable. The docblock records the constraint as closed with a TODO rather than a limit that no longer applies. It changes who receives an email, so it wants its own spec.
  • proposalDetails renders proposed keys raw in the review email. The reason it did not use labelForPath was a cross-collection import into code this branch deletes; labelForPath is now a normal import away. It changes email copy, so it is the same kind of decision.

Four open questions the tickets left, and what I chose. Each is a data decision, not a code one, so say if you want a different answer.

One contract loss, stated rather than hidden. The four registration refusal codes were documented on the register endpoint's OpenAPI path. The create that replaces it is the auto-generated POST /api/user-submissions, which is x-internal because the collection is in no project, so the codes are no longer in /api/docs. They stay in responseTypes.ts, which is the channel the widget actually syncs. Publishing them would mean putting user-submissions in a project, which also opens reads.

Five src/lib/ modules lost their second consumer when the old jobs went, so lib-boundary.spec.ts now lists them under KNOWN_SINGLE_CONSUMER: antiSpam/mxRecords, eventTitle/autoTitle, mapbox/geocoder, notifications/sendSubmissionReview, users/upsertUserByEmail. Each is general-purpose rather than one owner's private helper, so where each belongs now is a move worth deciding on its own, not a justification to write into this PR.

The security review found nothing, and raised one data question. The migration drops the three tables with no backfill, so on a database that holds live rows this is irreversible on the next boot — down() restores the tables empty. #725 states the premise it rests on: no live deployments and no production data in these tables. Worth confirming before merge, since it is the one thing this PR cannot undo.

Two sessions worked this branch at once. Four commits (30e578d..8ecbfc1) arrived on the remote while #799 and #800 were being written here, and this branch is rebased onto them. The one overlap is the gate escape above, where both reached the same answer; nothing else was touched twice.

Process: /simplify and the six-lens pr-review-toolkit pass did not run — the toolkit is not installed in this session, and the branch is deletion-heavy. comment-lint reports one finding on src/fields/jsonField.ts:35, which predates this review round and reads as a false positive on field-shape prose. The security review did run, and is the note above.

Detail

Two hand edits to the generated migration, both required.

  • The payload_jobs cleanup. Postgres cannot drop an enum value, so drizzle sets task_slug to text, recreates the type without the three removed slugs, and casts back — and that cast fails on any row still holding one. Reproduced on a seeded database before adding the DELETEs.
  • The generated DROP CONSTRAINT for each payload_locked_documents_rels foreign key is removed. DROP TABLE ... CASCADE above has already taken them, so the statement errors as missing — the first apply failed on exactly that. The columns are still dropped, which is the part CASCADE does not do.

The seed importer's natural key moves from legacyId to uuid, because user-submissions has no legacyId column and the dump already carries a uuid per row. The preload, the pagination plan and the seed route's count verification move with it. That count is taken under activeRegistrationWhere rather than whole-collection: contact, subscribe and proposal rows share the table, and an unfiltered count would pass on those alone.

Seeding at accepted is what keeps a seed run silent. enqueueSubmissionScreening returns early for a row that is not pending, and DeliverSubmissions refuses one, so neither queue is entered. spawnSubscribeFromRegistration keys on the subscribe opt-in pair, which the importer never writes.

tests/unit/atlas-registrations-data.spec.ts is new, and pins the 2034-row dump against the contract the collection now enforces: every mapped row inside checkSubmissionData's key allow-list and length bounds, the name pair present, no subscribe pair, and blanks dropped. Proven to fail: emitting one disallowed key turns three of its four cases red.

tests/unit/submission-preview-target.spec.ts is new, and pins the auto-open branch: the target is declared once, it carries autoOpen with neither path nor params, and its condition is true for proposal and false for the other three and for a row with no type yet. Proven to fail both ways — dropping the condition turns 5 of its 7 cases red, and adding a path turns the repoint case red.

RESTRICTED_COLLECTIONS shrinks to users and user-submissions — the other two entries named collections that no longer exist. No surviving collection changes tier: user-submissions is still restricted, still in no project, and clients still hold create and nothing else on it.

tests/unit/openapi-custom-endpoints.spec.ts is edited, not cut. It pins the register path and both its schemas as absent now, so a spec that re-advertised a 404 would fail, and it keeps the "ALLOW_POST_FOR is necessary but not sufficient" case on user-submissions.

Closes #796
Closes #797
Closes #798
Closes #799
Closes #800
Closes #725

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

🤖 Generated with Claude Code

https://claude.ai/code/session_015xYUfQYxhoN3Y8YadtBHcc

sydevs-bot and others added 9 commits September 16, 2026 13:42
Phase 3 deletes `event-submissions`, and the Accept/Reject buttons, the
diff UI and the merge-into-Events lifecycle had never moved with it — so
deleting the collection would have deleted proposal review along with it.

The lifecycle, the two virtual projections, `validateProposal` and the
`/review` endpoint all move to `src/collections/UserSubmissions/`. The
endpoint registers in the `formsPlugin` wrapper, because the collection is
plugin-generated and that wrapper is the one merge this repo owns; it stays
out of `CUSTOM_ENDPOINT_PATHS`, which is what would publish a manager-only
action in the OpenAPI spec.

Three things the port had to decide rather than copy:

- `user-submissions` carries one five-state vocabulary, so the six-state
  one collapses: accept → `accepted`, reject → `rejected`, reopen →
  `pending`. Created-vs-updated is an `activityLog` entry and a `outcome`
  field on the response, not a sixth status. `reviewedBy`/`reviewedAt` are
  dropped for the same log — two fewer columns for the same record.
- The open set is `pending` **and** `failed`. `failed` means the decision
  path was fine and the review email did not send, so a manager who reaches
  the row anyway must still be able to act; porting the old set verbatim
  would have refused them.
- Every entry point gates on `type === 'proposal'`. One table holds four
  intakes now, so without it a registration row would reach
  `newEventDefaults` with no `proposed` and mint an empty listing.

Refs #796

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbAa7XEfgnkNdNgWSnej9n
`POST /api/user-submissions` with `type: registration` was accepted
unconditionally: the eligibility gates, the capacity count and the
confirm/deny vote hooks all still hung off the `registrations` collection.
They move here, so the unified create enforces what
`POST /api/events/{id}/register` does and the Atlas widget keeps its
machine-readable refusals at `errors[].data.code`.

`gateRegistration` is a **`beforeValidate`**, not a `beforeChange`. Payload
runs every `beforeValidate` ahead of every `beforeChange`, and
`prepareUserSubmission` is one — so a `beforeChange` gate could not run
ahead of it. It gates **client-originated creates only**: a manager
recording a registration on a full event by hand is a deliberate act, and
`req.context.skipRegistrationGate` is the server-side escape a historical
import needs (#799).

One `countActiveRegistrations` helper replaces the `where` re-derived at
four sites, so a `spam`, `rejected` or `failed` row frees its seat
everywhere at once.

Two decisions the ticket left open:

- **It sums the old collection too.** `POST /api/events/{id}/register`
  still writes `registrations` rows until #800, and the widget still posts
  there until sydevs/SahajAtlasWeb#195. Counting only the new table would
  make `registrationsFull` read 0 for every event registered through the
  live path — a limit silently ceasing to be enforced. The legacy count,
  and the two thin bridge hooks that keep the flag in step with it, are
  marked for deletion with the collection.
- **`Events.registrations` gains `where: { type: { equals: 'registration' } }`.**
  One table holds four intakes and three can name an event, so without it
  the tab would list the event's proposals and spawned subscribe rows. The
  bare type, not `activeRegistrationWhere` — a manager needs to see the row
  they flagged `spam`.

Refs #797

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbAa7XEfgnkNdNgWSnej9n
Generated, not hand-written. Three nullable columns plus their FKs and
indexes — `manager_id`, `region_id`, `region_hint` — which is exactly what
the ported review path reads (#796). The re-pointed `Events.registrations`
join produces no DDL: a join field is virtual.

Refs #796

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbAa7XEfgnkNdNgWSnej9n
The three `describe` blocks that exercised the review path — the two
virtual projections, reopen, and `applyReview` — move with the code they
cover, plus the one `proposed patch validation` case that also called
`applyReview`. What stays in the event-submissions spec is the old intake:
the write guard, screening, proposal validation, titles and access.

Three assertions changed meaning rather than target, because the semantics
did:

- An accept asserts `status: 'accepted'` **and** `outcome`, since one status
  now serves four intakes and created-vs-updated lives in `outcome`.
- "Attributed to the reviewer" is the last `activityLog` entry of
  `type: 'review'` carrying `managerId` — `reviewedBy`/`reviewedAt` are gone.
- Reopen no longer "clears the review stamp": an append-only log has nothing
  to clear, so the case asserts the row is genuinely open again and that the
  reopening is recorded as its own entry. The idempotence case then asserts
  the log still holds exactly one review entry, so "already decided" is
  provably a no-op rather than vacuously green.

Adds the case the port itself did not owe: a `failed` row is still
actionable. That status has no `event-submissions` equivalent, so nothing
would have caught the open set being ported verbatim.

Refs #796

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbAa7XEfgnkNdNgWSnej9n
Both hooks now run on all four intakes, and the vote check is not enough to
stand alone: on a **create** `previousDoc` is undefined, so
`null === undefined` is false and a row that never carried a vote passes it.
On the old single-purpose collection that only ever meant a registration.
Here it would fire on every proposal and every spawned subscribe row naming
an event, paying for two counts and an Events write per create.

Refs #797

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

Everything that reads a registration *after* it is created still read the
`registrations` collection: the feedback and unsubscribe pages, the session
reminder sweep, the post-event follow-up sweep, and the manager digest.
All six call-site groups now read `user-submissions where type =
registration`.

**Both signed-token kinds are bumped, not just their claim renamed.** Each
carried a bare `registrations` row id, and the same integer addresses an
unrelated row in the new table. `verifyFeedbackToken` casts without checking
the claim, so a rename alone would have sent `undefined` into `findByID`
rather than refusing; a new kind refuses at the signature. The unsubscribe
token has no expiry at all, so nothing about the old shape ages out on its
own.

**⚠ `dueWhere` in the follow-up sweep gains `activeRegistrationWhere`, and
that is correctness, not tuning.** Nothing else in that `where` is a type
filter — `startingAt` is registration-shaped by an admin `condition`, never
by the column — so pointed at the unified table unchanged it would have
swept contact, subscribe and proposal rows and mailed their senders a
feedback ask.

Name, address, language and answers come off the row's own columns and
`submissionData` pairs, as `deliverRegistration` already does. The `users`
join was the derived copy: `prepareUserSubmission` seeds that row *from*
these. `loadUsers.ts` goes with its last caller. The missing-address guard
stays — `senderEmail` is deliberately optional, so an anonymous submission
is skipped and warned, never mailed.

Refs #798

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbAa7XEfgnkNdNgWSnej9n
Every fixture that stood in for a registration was a `registrations` row
with a `users` join, a `locale` column and a `questions` blob. It is now a
`user-submissions` row whose address is `senderEmail` and whose name,
language and answers are `submissionData` pairs — the shape the jobs now
read, and the one `prepareUserSubmission` seeds the `users` row *from*.

Three cases the criteria asked for and nothing covered:

- **The follow-up sweep skips a non-registration row with a past
  `startingAt`.** The fixture is a `subscribe` row carrying an `event` and
  no form — the one shape `needsForm` exempts — with a registration on the
  same event as the control proving the sweep ran at all. Verified by
  removing `activeRegistrationWhere` from `dueWhere` and watching it go red:
  `scanned: 2, sent: 2`, the subscriber's address in the recipients.
  Restored: `scanned: 2, sent: 1`.
- **The reminder sweep skips a `spam`-flagged row**, again against an active
  sibling on the same event.
- **The unsubscribe page action**, which had no spec at all: it stamps
  `unsubscribedAt` on the row, and the sweep then skips it. It lives in the
  reminders suite because that suite owns the sweep the assertion depends
  on, and `createTestEnvironment()` may be called only once per file.

Refs #798

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

**A published client key could read any Event out of a create response.**
`previewEvent` and `proposedChanges` are `virtual` fields with an `afterRead`
hook, and Payload runs field `afterRead` hooks on the response of a
**create** with no `findMany` argument — so their own list-read guard never
fired there, and `admin.hidden` is not `hidden`, so nothing stripped the
value either. `loadTargetEvent` reads the named event with
`overrideAccess: true, draft: true, trash: true`, and `mergeProposal`
returns the whole document. `eventField` has no `filterOptions` and
Payload's relationship validator checks the id's shape only, so a POST of
`{ type: 'proposal', event: <any id> }` read that event straight back —
past the published-only access filter, which applies on `read` alone, past
the trash filter, past project visibility, and past the client `select`
requirement.

The mechanism is not new; `event-submissions` carried identical fields. The
blast radius is: they now sit on the collection `wemeditate-web-client` also
holds `create` on, and the hooks fire for all four types. `read` is denied
to clients rather than the hooks being gated on `type`, because one rule
then closes every intake at once.

Second fix, same file family: `countVotes` filtered on the bare `type`
predicate while every other consumer of that row set uses
`activeRegistrationWhere`. A registration flagged `spam` after its follow-up
token was minted freed its seat but kept its vote — and five denials past
the Wilson bound unpublish the listing.

Three existing create cases moved to a published event: since #797 a client
registration naming an event it cannot read is refused 404, and those
fixtures had always used Payload's default draft. The subject-echo case
moves to a `proposal` for the same reason — a registration no longer reaches
`titleOf` at all, and a case that cannot reach the code it names is not
covering it.

Refs #796, #797

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbAa7XEfgnkNdNgWSnej9n
- `docs/rules/access.md` — the locale-bearing admin fetch is now
  `SubmissionReview/urls.ts` → `/api/user-submissions/:id/review`.
- `docs/rules/admin-ui.md` — the live-preview-by-postMessage example is
  `UserSubmissions.previewEvent`, and clients hold create-only on
  `user-submissions`.
- `docs/architecture.md` — the registration gate runs on the unified intake
  too, and `registrationsFull` counts both tables until the register
  endpoint goes.
- `src/collections/AGENTS.md` — the `formsPlugin` wrapper now also registers
  the review surface, and every collection-wide admin slot there serves four
  intakes, so each owes a `type` branch.
- `tests/COVERAGE.md` — the three new suites.

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

railway-app Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

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

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

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

sydevs-bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 17:57Z address-review · attempt 1 · session · done
  • 17:57Z address-review · attempt 1 · session
  • 15:54Z address-review · attempt 1 · session · done
  • 15:54Z address-review · attempt 1 · session
  • 14:55Z address-review · attempt 1 · session · done

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

#796 → #797 → #798 are sequentially dependent and the intermediate state is coherent, so three tickets in one PR holds. Each open question is answered with the option its ticket recommended. The PR's own rule — one table, four intakes, so every moved hook branches on type — reaches four hooks; both should-fix findings are where it does not.

Findings

  • should-fix — both review projections run on all four intakes · UserSubmissions/fields.ts:432
  • should-fix — a live-preview panel opens on every contact, subscribe and registration row · formBuilder/index.ts:177
  • consider — skipRegistrationGate is unreachable · hooks/gateRegistration.ts:39
  • consider — Event['registrations'].docs retypes to UserSubmission[] · Events/Events.ts:520

What was checked

All three tickets, then the diff file by file bar the migration snapshot. Clean: down drops what up adds, and registerForEvent writes only registrations, so seats cannot double-count. Neither consumer reads Event['registrations'].

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


Generated by Claude Code

Comment thread src/plugins/formBuilder/index.ts Resolved
Comment thread src/collections/Events/Events.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 16, 2026
`computePreviewEvent` and `computeProposedChanges` guarded only on
`findMany`, so every single-document read of a contact, subscribe or
registration row paid for both: an `events` findByID whenever the row
named one, plus a diff over the whole Events `flattenedFields` against an
empty proposal. `SendPostEventFollowUps` reads each due row singly and
the feedback page reads twice per vote, so this was on a hot path rather
than an admin one.

`admin.condition` hides the fields; it does not stop the hooks. Every
other hook moved onto the unified table already opens with a `type`
guard — these two were the exception.

The new case fails against the unguarded hooks with
`expected [] to be null`: the diff had run and returned nothing.

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

`livePreviewUrl` never returns a falsy URL — Payload would persist that as
the editor's "live preview off" preference for the whole collection — so
`path: null` lands on the explanation page rather than closing the panel.
The comment here claimed the other three intakes got no panel at all, and
`openByDefault: true` then opened one on arrival showing `no-path`, whose
copy tells the reader to go and fill in a slug.

A `not-reviewable` reason says what is actually true. `openByDefault` goes
rather than gains a branch: the option is collection-wide and takes no
function, so the only way to keep it for the reviewer is to greet every
contact, subscribe and registration row with that page.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013wu7znVUBgKHudEYxkdVit
`skipRegistrationGate` sat one line below the check that already returns
for every caller that is not an API client, and a Local API import — the
case its docblock named — never carries `req.user.collection === 'clients'`.
The only caller was the spec, which built a synthetic req impersonating a
client to reach it. #799 is unwritten, so this was a knob for a caller
that does not exist.

The spec case now creates the row the way an importer will, so it covers
the exemption that is really there.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013wu7znVUBgKHudEYxkdVit
The slot warning covered the components and the preview URL. Two things it
did not: a field hook behind a conditional field still runs on all four
types, and an admin option taking a value rather than a function cannot
branch at all.

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

Copy link
Copy Markdown
Contributor Author

Adopted all four adversarial findings — three in code, one in the body.

Five new integration cases, each watched failing against the defect first. Lean gate green, and both touched integration specs 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 Sep 16, 2026
@Ardnived

Copy link
Copy Markdown
Contributor

@sydevs-bot Why is this ticket still a draft?

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 16, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Still a draft because CI has not finished. The dispatcher owns the draft flag, and it reaches that step only after CI is green.

The order it works through, on head 8ecbfc1:

  1. Open threads — all four adversarial findings are answered and resolved.
  2. CI — Lint, Test & Smoke started 14:50Z and is still running. This is where it stops right now.
  3. Adversarial review — submitted 14:41Z, so that gate is already passed.
  4. Then it marks ready, requests you as reviewer, labels awaiting, and arms auto-merge.

A session never touches the draft flag itself. Flip it by hand if you want it ready sooner — the dispatcher carries on from there.

🤖 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 16, 2026
@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 16, 2026
`openByDefault` was dropped in 61c5a78 because it is collection-wide and
takes a value rather than a function: on a table holding four intakes it
would greet a contact, subscribe or registration row with the
`not-reviewable` page. That left the reviewer opening the panel by hand on
the one row where the preview is real.

A field branches where the option cannot. `previewTargetField` already
carries `autoOpen`, and a false `admin.condition` returns in
`addFieldStatePromise` before Payload attaches the custom component to form
state, so `PreviewTarget` never mounts for the other three types.

The target declares `autoOpen` alone. With neither `path` nor `params`,
`composeTargetUrl` returns null and the panel keeps the URL
`livePreview.url` already resolved per type — the two cannot disagree about
where a proposal previews.

No column and no import-map entry: a `ui` field stores nothing, and
`PreviewTarget` was already registered by Meditations.

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

Copy link
Copy Markdown
Contributor Author

Three threads answered on 415e004. Lean gate green — 2119 unit tests, plus the three user-submissions int specs.

Adopted — PreviewTarget auto-opens the panel. A conditioned previewTargetField opens Live Preview on a proposal and on nothing else, which openByDefault could not do. Resolved.

Rebutted, left open for you — fullness.ts has two owners, Events and UserSubmissions, so src/AGENTS.md rule 4 keeps it in src/lib. feedbackLinks.ts is not imported by UserSubmissions at all — a job and an app route read it, and buildWebPath is colocated only because its own collection consumes it.

Nothing asked. Say the word on either placement and I will move it.

🤖 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 16, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Sep 16, 2026
Merged via the queue into main with commit 0e83f6a Sep 16, 2026
29 of 32 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-725-unified-intake-cutover branch September 16, 2026 18:35
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Sep 16, 2026
sydevs-bot pushed a commit that referenced this pull request Sep 17, 2026
"kept only because #809 was comment-only" reads only to someone who saw that
diff, which `docs/rules/code-comments.md` bans. "Unwired since #801" and "#811
decides whether this goes" carry the substance to a fresh reader.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011JrquZ3M6mxws5KZXJkBbq
github-merge-queue Bot pushed a commit that referenced this pull request Sep 18, 2026
)

* fix(docs): resolve the conflict block in the access rule

`docs/rules/access.md` carried a raw, unresolved conflict block from #787.
Markdown is the one place a marker is silent: the same lines in a `.ts` file
are a syntax error both `pnpm lint` and `pnpm typecheck` reject, and in
`.json`, `.mts` or `.yml` they break a parser. Here they rendered as ordinary
text, and no lint covers `docs/`, so the block survived four merges. #801 and
#803 each edited prose inside it without seeing it.

The file is a `docs/rules/` rule, so it loads into every agent session that
reads `src/plugins/access/` — both halves at once, contradicting each other.

Neither half was wholly current, so the resolution is a mix.

The client-grant paragraph takes the `origin/main` text: both
`wemeditate-web` and `sahaj-atlas` may create `user-submissions`, create only.
`config/roles.ts:95,122` grants exactly that and nothing else. The `HEAD` text
named `wemeditate-web` alone and cited form submissions, a collection #801
deleted.

The warning paragraph takes the `HEAD` text, which differs from its twin only
in the final clause. "with no live-preview credential at all" is correct;
"with no preview secret" names the shared secret #788 deleted. A legitimate
draft read now carries a minted Ed25519 token, and `previewSecret.ts` says so
in the file: the header name outlived the value it used to carry.

Refs #810

Co-authored-by: Claude Opus 5 <[email protected]>

* test(docs): fail when a conflict marker lands anywhere tracked

Nothing in the repo grepped for conflict markers, which is why the block in
`docs/rules/access.md` survived four merges. A unit spec closes that, and runs
in both places that matter: `pnpm test:unit` is the lean gate's fast lane, and
`pnpm test` runs it in CI.

It is a unit spec rather than a line in `.claude/skills/pr-prep/check.sh`
deliberately. `.claude/` is a Claude Code Protected Path, so an unattended run
cannot write there — the write is prompted rather than refused, and the session
stalls until its lease expires.

The scan shells to `git grep`, for scope and for cost. Tracked files are what
can land on `main`, and git scans them in ~40ms where reading 76MB of tracked
bytes into JS would cost more than the rest of the lane.

Two traps are handled in the spec. The patterns are built by concatenation, so
the file cannot match itself. And a second test greps a scratch block through
the same pattern and the same command, because a pattern typo, a `git grep`
that cannot see the tree, and an exit code read the wrong way all produce the
same green as a clean tree does.

Proven by reintroducing a marker in a tracked file and watching the lane go
red.

Refs #810

Co-authored-by: Claude Opus 5 <[email protected]>

* refactor(tests): simplify the conflict-marker guard per /simplify pass

The three marker tokens are now named constants the pattern and the fixture
both build from, so the second test visibly shares the definition it is there
to prove. `grep` closed over the one pattern it was ever called with, its
two-valued argv fragment became a `noIndex` flag, and the `maxBuffer` knob went
— nothing it guarded was reachable.

The temp directory the non-vacuity test writes is now removed in
`onTestFinished`. Every lane run had been leaving one behind.

Cut the docstring roughly in half. One claim in it was also false: reading the
tracked tree into JS measures ~130ms against a 27s lane, not "more than the
rest of the unit lane". A checkable number that is wrong by two orders of
magnitude costs more than it buys, so the comparison is gone rather than
restated.

Refs #810

Co-authored-by: Claude Opus 5 <[email protected]>

* fix(tests): close two ways the conflict guard could go quiet

Both found by an adversarial review pass and reproduced before fixing.

`-I` skipped whatever git calls binary, and that includes a plain text file
marked `-diff` in `.gitattributes`. A scratch repo with `*.lock -diff` and a
real conflict block in `deps.lock` exited 1 with no output, so the guard went
green with the block committed. Without `-I` the same tree reports
`Binary file deps.lock matches`, which is a non-empty row and fails the
assertion. A guard should name a media file loudly rather than miss a real
block quietly, and the tree has no binary match today.

The fixture also proved only the pattern, not the scan. `--no-index` bypasses
index enumeration, the pathspec and `.gitattributes` — every structural way the
tracked scan can come back empty — so a sparse checkout, or the `-diff` case
above, left both tests green. It is now a real repository with the file really
tracked, which exercises the same path the tree test takes and lets the
`noIndex` branch go.

`grep.column` is pinned off. A contributor who sets it globally got
`sample.md:1:1:…` and failed the exact-array assertion on a clean tree.

A spawn that never ran reported "exited null". It now says git may not be on
PATH.

Refs #810

Co-authored-by: Claude Opus 5 <[email protected]>

* fix(tests): cut the guard docstring narration

The header retold #787 in six lines that the ticket, the PR body and the
commit already carry. What a reader cannot re-derive is the concatenation
rule and the tracked-files scope, so those stay and the story goes.

The #787/#810 breadcrumb stays too — docs/rules/code-comments.md keeps
those whatever else is cut.

Refs #810

Co-authored-by: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-801 — 415e0047 Deployed Sep 16, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment