Skip to content

feat(events): enforce one lifecycle table for events and submissions - #1135

Merged
sydevs-bot merged 19 commits into
mainfrom
claude/feat-1121-lifecycle-table
Nov 13, 2026
Merged

sydevs-bot merged 19 commits into
mainfrom
claude/feat-1121-lifecycle-table

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Declares each lifecycle once, as a table of the moves that exist and the states a row may open at, and refuses every other.
  • Builds Every class, submission and import follows clear rules for what happens next #1120's four behaviour changes on it, plus the two one-definition sweeps it asked for.
  • Joined: fixes scripts/preview-manager-emails.ts, which threw on main, so this PR has previews.
  • Joined: a review decision's skip flag named no row, so a bulk accept applied only the first.

Change outline

The stage column on events and the status column on user-submissions each walk a fixed set
of values, and before this each writer decided for itself what it was allowed to do.

Contract — one lifecycle, declared as its moves and its openings

A machine is declared once: the column it governs, its states, where a row may open, every
(from, to, by) that is legal, which writers may name themselves, and how a request's person
resolves. The column is built from it, default and guard included, so the options, the generated
union and the refusals cannot name different sets.

// src/lib/stateMachine/machine.ts
defineStateMachine({ name, field, states, opensAt, opens?, moves, declarable, person?, refusal? })
Move { from: State[] | '*', to: State, by: Actor[],
       name?,        // the decision it is — what an afterChange acts on
       when?,        // pure condition on the document → true | refusal
       refusal? }    // what a person outside `by` is told
Opening { at: State, by: Actor[], when?, refusal? }   # where a row may be CREATED
can(machine, from, to, by) -> boolean        # the table alone: buttons, pre-checks
judgeTransition({ machine, from, to, doc, req }) -> unchanged | allowed(move) | refused
judgeOpening({ machine, at, doc, req })      -> opened | refused   # a create has no `from`

// src/fields/stateMachineField.ts
stateMachineField(machine, { labels, enumName, … }) -> SelectField
  # options AND defaultValue from the machine, required, readOnly, guard as a FIELD beforeChange

Two tables use it, each beside its owner:

 src/lib/eventVerification/stages.ts        STAGES — what each stage MEANS
+src/lib/eventVerification/machine.ts       EVENT_MACHINE — who may move between them
+  opensAt           verified — the column's default, so every writer may open there
+  opens             unverified (proposal) · any stage (import)
+  job:expireEvents  the ladder (read off STAGES), and any stage → finished
+  hook:save         a manager's save re-opens the cycle; revives a finished class
+  adoption          unverified|denied → verified
+  community         unverified → denied
+  verify            → verified, from every stage BUT finished
+  import            the dump decides
+  proposal          creates only — an accepted submission, no move of its own

 src/collections/UserSubmissions/statuses.ts   the vocabulary
+src/collections/UserSubmissions/machine.ts    SUBMISSION_MACHINE
+  opensAt           pending — every intake, naming nobody
+  opens             any status (import)
+  review / admin    accept · reject · reopen · confirm-spam · resend, each a named row
+                    with its own condition (a proposal; a region for a new event)
+  screening, block  pending → spam
+  delivery          pending|failed → accepted|failed|pending
+  repeat-signup     accepted|pending|failed → pending
+  import            the fixture decides

Flow — how a state change is made now

Every writer names itself, and the guard reads that name off the write's own context.

 ExpireEvents.processEvent(event)                   src/jobs/ExpireEvents/ExpireEvents.ts
-  updateEventBookkeeping({ data: { verificationStage: next }, expect })
+  transition({ machine: EVENT_MACHINE, from: stage, to: next, by: 'job:expireEvents',
+               expect: { nextCheckAt: as read }, write: bookkeepingWrite })
+    can(EVENT_MACHINE, from, to, by)                # a move not in the table throws here
+    claim = { stage: { equals: from }, ...expect }   # ANDed into the write's own where
+    context['stageActor:verificationStage'] = by   # one key per machine
+      events.beforeChange (collection)              src/collections/Events/Events.ts
+        syncVerificationOnSave                      # derives the stage, declares its actor
+      verificationStage.beforeChange (field)        # stateMachineField's guard — runs after
+        judgeTransition(from, to, doc, req)         #   every collection hook, by Payload's order
+          no writer named      → refused + capture(warning)
+          no row holds it      → refused + capture(warning)
+          a row's `when` fails → refused (on its own field: not an incident)
 any create of either collection
+  verificationStage.beforeChange / status.beforeChange (field)
+    judgeOpening(at, doc, req)                     # no `from`, so no move to match
+      at is machine.opensAt   → opened             # what the column does on its own
+      at is unlisted or null  → opened             # `required` + the select validator answer
+      an `opens` row holds it → opened
+      else                    → refused + capture(warning)
 user-submissions  status.beforeChange (field) → judgeTransition(SUBMISSION_MACHINE, …)
+    a declared system writer wins, whoever's request carries it   # the seed runs as an admin
+    else SUBMISSION_MACHINE.person(req)                           # admin | review | no grant
+    → the matched row, its condition, or the refusal a person can act on
 user-submissions  afterChange
   applyReviewDecision → the same judgement → applyReview(move.name)

⚠ A write may only name a writer with no person behind it: review and admin are resolved
from the request, never from a claim, so naming one cannot skip the grant check in person.

Behaviour — what the table made it safe to change

 resolveNextCheckAt(stage, …)                       src/lib/eventVerification/watermark.ts
+  remindersSilenced({ stage, status }) → null       # a hidden class is nobody's to chase
   stage is expired → its own trash countdown        # the ladder unpublished it

 syncVerificationOnSave — managed branch            src/collections/Events/hooks/
   from a pre-adoption stage → verified
+    and _status: 'published'                        # adoption puts it back on the map

 applyVerification(eventId)                         src/collections/Events/lifecycle/verify.ts
+  stage is finished → APIError 409, public          # extend the schedule; that save verifies it

 SUBMISSION_MACHINE                                 src/collections/UserSubmissions/machine.ts
+  failed → pending, on a non-proposal, by an admin → 'resend'
+    applyReview queues deliverSubmission            # what releasing a refusal already did

 gateRegistration(data)                             src/collections/UserSubmissions/hooks/
+  no startingAt, after every coded refusal → 400    # or the follow-up never finds the row

 eventImport                                        src/plugins/eventImport/
+  importWriteContext()                              # ONE context: the create AND its dry
+                                                    # validation pass, which runs the same hooks

Contract — one definition per stage rule

Five facts had more than one spelling, each free to disagree with the others.

-NOTICES: Partial<Record<VerificationStage, …>>     # a stage added later gets no banner
+NOTICES: Record<VerificationStage, NoticeConfig | null>
-bucketForEvent: switch … default: 'verified'       # the shape that caused #624
+BUCKET_BY_STAGE: Record<VerificationStage, EventBucket>
-OVERDUE_QUERY_STAGES = ['escalated','urgent','expired']  # a literal beside a different literal
+LADDER_STEPS            — the `remind` narrowing, written once in stages.ts
+OVERDUE_QUERY_STAGES    — the steps whose reminder included the region
+OVERDUE_STATUS_STAGES   — every step's landing stage that is still published
-four copies of `stage === 'unverified' && _status === 'published'`
+isFeedbackOpen(event)                              src/lib/eventVerification/communityFeedback.ts
-INACTIVE_STATUSES = [rejected, spam, confirmed_spam, failed]
+ACTIVE_STATUSES = [accepted, pending]; the rest derived   # a new status holds no seat
-MERGEABLE_STATUSES = ['accepted','pending','failed']
+derived from the table's own repeat-signup moves
-stateMachineField(machine, { defaultValue, … })    # where a row OPENS, beside the table
+machine.opensAt                                    # the table, which the column reads

Files — what is new

src/lib/stateMachine/          machine.ts     defineStateMachine, the table and its lookup
                               transition.ts  the claim, and the actor it carries
                               guard.ts       resolve the writer / judge a move / judge a
                                              create / refuse / the field hook
                               actor.ts       how a writer names itself
src/fields/stateMachineField.ts               the column, built from its machine
src/lib/atlasOverview/         deliveryFailures.ts  the rows nobody could find
                               listPath.ts          lifted from its one-off spellings
tests/utils/lifecycleFixtures.ts   setLifecycleState — a state, never a move

Files — what is gone

-src/collections/Events/hooks/guardVerificationStage.ts         # the column's own guard now
-src/collections/UserSubmissions/hooks/guardStatusTransition.ts # likewise
-reviewMove / actionFor / spamActionFor  (lifecycle/review.ts)   # rows in SUBMISSION_MACHINE
-the "two tables agree" spec                                     # there is one table

Preview

  • Admin home — the open items list, now carrying a Delivery failed row
  • Undelivered submissions — open one as an admin for Send again
  • Classes — open an unverified one and assign a manager: it verifies and publishes

Data: CI fills every preview from seeds/preview-fixture, which carries a failed contact row.
Not verified from this session — PREVIEW_ACCESS_CLIENT_ID / PREVIEW_ACCESS_CLIENT_SECRET
are unset here, so the Cloudflare Access gate in front of the preview cannot be passed.

Email previews

Contract impact

src/payload-types.ts changes by one JSDoc line — the events.manager description now says
adoption publishes. The consumers that sync it (sydevs/WeMeditateWeb, sydevs/SahajAtlasWeb)
pick it up in the bot's contract-sync PR after this merges. No response shape changes.

⚠ One refusal is new on a client-facing create and deliberately carries no error code: a
registration naming no session answers 400 with a message alone, because
EventRegistrationErrorCode is a file three repos sync and the widget cannot produce this
refusal — it has always sent the session the visitor picked. Adding a code would be a consumer
sync for a case no consumer can reach.

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh — lint, format, typecheck, typecheck:tests, unit (119 s)
  • Unit lane: ✓ 269 files, 3610 tests. Integration lane: ✓ 108 files, 2017 tests, measured before
    the review pass; since then event-feedback, atlas-overview and digests (45) cover what moved
  • After the state-machine field: lean gate ✓ (lint, format, both typechecks; unit lane 3628/3630 —
    the two others are doc-citations, fixed by staging the new file, and ics-builder, which
    fails only in this machine's local timezone and passes under TZ=UTC); integration ✓
    user-submissions-review-lifecycle (42), event-verification (39), expire-events (26),
    block-user, screen-submissions, user-submissions-repeat-registration, atomic-writes,
    digests. pnpm generate:types writes no diff, so the schema is unchanged.
  • New: tests/unit/lifecycle-table.spec.ts (47 — every review decision, per person and intake,
    plus judgeOpening), plus cases in next-check-at,
    open-item-status, manager-invite, expire-events, event-verification, atlas-overview,
    digests, user-submissions-review-lifecycle, user-submissions-registration-gate
  • After main was merged, the actor key scoped and the skip flag keyed: lean gate ✓ (lint,
    format, both typechecks, unit lane 270 files / 3673 tests); integration ✓
    user-submissions-review-lifecycle, user-submissions-create, screen-submissions,
    event-verification, expire-events, atomic-writes, event-feedback, atlas-overview,
    digests, block-user, user-submissions-registration-gate, events, event-imports,
    user-submissions-repeat-registration, preview-fixture-import, seed-importer-preload
  • After openings were added (0d67d0c): lean gate ✓ (lint, format, both typechecks,
    unit lane 271 files / 3692 tests, 109 s). Full integration lane ✓ — 107 files, 1917 tests.
    The three new where a class may open cases go red with the create branch of the guard
    removed, and the refusal case is the one the reviewer named.
  • Build: N/A — Railway builds the preview
  • Migration: none. pnpm db:migrations:create … --skip-empty wrote nothing.

Manual verification

  1. As an admin, open a failed contact or registration row — Send again is offered, the row
    returns to pending, and its log reads "Queued for delivery again". As a non-admin reviewer
    the button is absent, and a hand-rolled PATCH is refused.
  2. Assign a manager to an unverified class saved as a draft — it is published and verified in the
    one save. An incomplete draft refuses with its own validation errors instead.
  3. Save a verified class as a draft — it leaves the reminder ladder. Republish it: the save
    re-verifies and the cycle restarts.
  4. Follow a verify link for a class whose schedule has run out — it refuses, and offers the edit.
  5. Create a class through the admin — it opens verified. A PATCH-style create naming
    expired is refused on verificationStage.

Notes for reviewer

  • Two moves forgo the claim, and each says why. transition() ANDs the state as read into
    the write's own where everywhere else, the community denial included.
    applyVerification and the repeat-signup fold take an id-addressed write through the same
    function instead: the first must keep Forbidden as a throw, and the where form narrows by
    access rather than throwing, so POST :id/verify would answer 200 to a manager it means to
    refuse; the second reads the row back, which a boolean cannot give it.
  • A version restore that moves the stage is now refused. Verified against Payload's own
    restoreVersion.js, which runs the field beforeChange pass as an update with originalDoc,
    so the column's guard sees it — the review pass claimed the opposite. It reads as correct (a restore should not silently rewind a lifecycle)
    but it is a behaviour change nobody asked for, so it is worth your eye.
  • The openings are option A of the guard.ts thread, and they turned up two live gaps.
    The class import's dry validation pass (fieldErrors) runs Payload's own field beforeChange
    pass over a built class, and the stage guard is one of those hooks — so a pass given a
    different context refuses a class the create would have written. importWriteContext() is now
    the one context both use. And the Atlas seed's registration upsert authors accepted while
    naming no writer, as did scripts/preview-event-emails; both are named now.
  • transition() is built on updateIfUnchanged (fix(jobs): stop jobs overwriting state that changed mid-run #1116), not payload.db.updateOne. The
    ticket's Notes describe a claim-then-update pair; fix(jobs): stop jobs overwriting state that changed mid-run #1116 shipped the guarded single write
    instead, for the reason its own docblock gives — both callers need the hooks the operation
    carries. One write, same guarantee.
  • The fixture helper is the shape of the cost, and a create pays it too. A guard that refuses
    a move naming no writer also refuses a test setting up a state, so ~12 integration fixtures
    write the column beneath the hooks (setLifecycleState) — and a create cannot do that, so a
    fixture authoring any state but the machine's opensAt names import on its own context.
    testData.createEvent and eight specs' own create helpers declare it once each. Every case
    that asserts a move still makes it through that writer's own path.
  • Security review ran (the diff touches collection hooks and an endpoint) and found nothing above
    its bar; its two hardening notes are taken — an explicit null target is judged rather than
    read as "no move", and the declarable-actor set excludes the humans. It ran again over the
    merged branch and found nothing above its bar: req.context is unreachable from a request body
    (createPayloadRequest hard-codes it), a field beforeChange cannot be skipped by
    overrideAccess or a narrow patch, a version restore is judged, and the admin-only resend is
    refused server-side for a reviewer. Its one finding was the bulk-accept skip above. The
    openings commit touches no path in securityReview.triggerPattern and only narrows what a
    create may write, so it was not re-run: proposal joins declarable with no move of its own
    and one opening strictly below the default.
  • reviewMove is now rows, not a second predicate. What it owned that a bare (from, to, by)
    row could not state — the action name, the reviewability gate, the grant check, the refusal
    wording — is now a row's name, when and refusal, plus the machine's person. A refusal a
    person can fix on another field (the region an accept needs) is reported there and not sent to
    Sentry; every other refusal still is.
  • The guard is a field hook, so there is no plugin. Payload runs collection beforeChange
    before the field pass (collections/operations/utilities/update.js), so a guard on the column
    always judges the patch every collection hook produced, and a column cannot be mounted without
    it.
  • Dismissed from the review pass, with reasons: dropping the import
    actor
    — a seed writes through the hooks on purpose, so a fixture bypass there would skip the
    screening queue and the fullness recompute it needs; un-deriving the overdue sets — the
    ticket asked for exactly that.
Detail

What the draft rule does not change. expired keeps its trash countdown, because being
unpublished is that stage's own doing. Only stages that send reminders go quiet.

Rows written before the rule existed. The watermark leaves a draft out of the due query from
its next save on, so ExpireEvents also clears the watermark of a draft it still finds — that is
what makes the criterion true without a backfill. It carries a shortcut: line naming when it
can go.

Why describeEvents is opt-in. summarizeGrants is also what the anonymous preview sign-in
picker calls, once per listed account, up to 25 of them in series — and it renders none of the
brief. The brief also composes its own three lines rather than calling buildEventEmailDetails,
whose one query counts registrations this email does not print.

Why a create's missing or unlisted value is left alone. The column is required and its
options are the machine's states, so Payload's own validator answers both, naming the field. A
refusal here would report a person's validation mistake as a writer the table was not told
about — and it would reach Sentry as an incident.

Closes #1121

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjVEDwt82zbosDvsneg

Which stage moves exist lived in a hook, a job, two endpoints and a
vote-counting hook, and only a manager's submission review was checked at
all. A move no reader could find was a move nobody could refuse: the stage
column is `admin.readOnly`, which is the admin UI alone, so any manager
holding `events: update` could PATCH it to any value and nothing applied
what the new stage implied.

`src/lib/stateMachine/` is the table, its lookup and its claim, and nothing
else — a machine that ever needs actions or timers wants XState instead.
Each writer now names itself, and one `beforeChange` guard per machine
refuses and reports the rest.

Two behaviour changes ride on it, both from #1120:

- a draft on a reminder stage gets no watermark, so a class its manager has
  hidden is not chased (decision 3);
- assigning a manager to an unverified or denied class publishes it as well
  as verifying it (decision 4).

And the verify link and endpoint now refuse a finished class, which is what
`syncVerificationOnSave` already decided for the save path: extending the
schedule is the move, and that save verifies it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWNkBmFdb8R9xG91MT
`reviewMove` answers for a manager's own write and returns `none` for a
request carrying no manager — which was the whole gate on screening,
delivery, the block endpoint and the repeat-signup fold. Each could write
any status from anywhere, and nothing said which moves they were for.

They now name themselves and go through `transition()`, and the table is
their gate. The review buttons are built from the same table, so a button
and the guard behind it cannot name different sets.

Adds the first move that was not there before: an admin may send a `failed`
contact, subscribe or registration row again, which re-queues the delivery
job the way releasing a refused row already does (#1120 decision 2).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWNkBmFdb8R9xG91MT
Five facts about a stage were spelled in more than one place, and each
extra spelling was free to disagree with the others:

- the admin banner's stage map was a `Partial`, so a stage added later gets
  no banner and nothing says so;
- the sidebar bucket was a `switch` with a `default:`, the shape that once
  labelled both pre-adoption stages "verified" (#624);
- the two overdue sets were two literal lists, one wider than the other for
  a real reason nothing enforced — both now derive from the ladder;
- "still collecting feedback" was written out at four surfaces;
- the registration status sets restated the vocabulary, inactive-first,
  which is the direction where a status added later silently holds a seat.

Also requires a registration create to name its session: a row without one
is invisible to the follow-up query for ever, so the registrant attends and
is never asked how it went (#1120 decision 5).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWNkBmFdb8R9xG91MT
A `failed` row is in no list anybody reads: it is not a refusal, so no spam
surface holds it, and it is not open for review, so no reviewer meets it.
The only way to find one was to query the collection by hand.

Admin home open items and the admin digest now carry them — Sahaj Atlas
rows only, since We Meditate gets its own home in #1119 — and an admin can
send one again from the row itself.

Also carries the class's own details into the adoption email: what it says,
how complete the listing is, and whether the community had flagged it. One
email, not a second one beside the first (#1120 decision 4).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWNkBmFdb8R9xG91MT
Four review lenses over the branch. What they found, and what changed:

- A write could name itself `review` or `admin` and skip `reviewMove`'s grant
  check entirely, because `resolveActor` accepted every actor in the table.
  Only a writer with no person behind it may be named now.
- The event brief now rides on an opt-in: `summarizeGrants` is also what the
  anonymous preview sign-in picker calls, once per account, and it renders
  none of it. The brief itself no longer calls `buildEventEmailDetails`,
  whose one query counts registrations this email does not print.
- `applyVerification` kept the document its own write returned, rather than
  re-reading the row it had just written.
- The ladder walk, the admin list path and the count-and-link note each had a
  second spelling; `LADDER_STEPS`, `listPath` and `countNote` are the one.
- `RESEND_FROM` was derived through three predicates to rediscover one state,
  and would have widened silently; it is named beside the move it belongs to.
- `targetsFor` and `originsFor` had no production caller between them, the
  guard's `actorFromRequest` seam had no non-trivial instance, and
  `judgeTransition`'s third verdict was never read apart from its second.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWNkBmFdb8R9xG91MT
Also two findings from the review pass that are worth their own lines: an
explicit `null` target is now judged like any other, rather than read as "the
write left the column alone"; and the invitation preview grew the scenario
that shows a class's brief, which is what makes the new state reviewable.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWNkBmFdb8R9xG91MT
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1135 November 12, 2026 19:04 Destroyed
@railway-app

railway-app Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

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

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

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

sydevs-bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 02:36Z address-review · attempt 1 · session · done
  • 02:36Z address-review · attempt 1 · session
  • 00:13Z address-review · attempt 1 · session · done
  • 00:13Z address-review · attempt 1 · session
  • 23:42Z resolve-conflicts · attempt 1 · session · done

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

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 12, 2026
Four doc conflicts, all from #1134 landing its own perf figures beside ours.

tests/PERF.md's session table is append-only, so both sides' rows are kept and
#1121's is renumbered to follow #1131's five. The counts every consumer states
are re-measured on the merged tree rather than picked from either side: 269
files and 3608 tests, which is neither branch's figure.

The code merged clean. The overlap worth proving was #1134's feed spec against
this branch's new stage guard — it drafts and republishes events, which the
guard now judges. It passes, as do event-verification and expire-events.

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

Copy link
Copy Markdown
Contributor Author

Merged main (#1134). All four conflicts were docs — the code merged clean.

tests/PERF.md's session table is append-only, so both sides' rows are kept; #1121's is renumbered to follow #1131's five.

The counts were the only real decision. Both sides moved them from 266 / 3555, so neither figure survives the merge. I re-measured on the merged tree — 269 files / 3608 tests — and wrote that into PERF.md and its three consumers, which perf-figures-pinned.spec.ts holds in agreement.

The overlap worth proving: #1134's feed spec drafts and republishes events, which this branch's new stage guard now judges. It passes (22), as do event-verification and expire-events (65). Lean gate green.

The PR body's "267 files, 3592 tests" is that session's figure, now superseded by the row above.

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


Generated by Claude Code

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

@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 large because the ticket is: all nine sections are asked for, the joined script fix is declared, and I found no refactor smuggled in beside them. countNote.ts is the one new piece the ticket did not ask for.

The table pays its rent. can is the only lookup, two guards are the only gate, and every set the PR claims to have derived reproduces the literal it replaced. It sits on updateIfUnchanged rather than a second atomic write — the right call, and not the one the ticket's Notes describe.

Two defects, both one line, both in the behaviour built on top rather than in the table.

Findings

  • should-fix — grantSummary.ts:406: flagged fires on one denial, so the email can tell a manager a listed class was taken off the map.
  • should-fix — eventFeedback.ts:193: the write callback drops expect, leaving the unverified → denied write unconditional.
  • consider — stateMachine/actor.ts:13: the docblock names a req.user fallback resolveActor does not have.
  • consider — atlasOverview/countNote.ts:12: two callers, six lines each, collection hard-coded — neither generic nor folded in.

What was checked

Read on the branch: both machines, all four stateMachine/ files, both guards and their order in Events.ts, every transition caller, watermark, stages, status.ts, openItems, grantSummary, lifecycle-table.spec.ts.

Re-derived by hand, each matching its old literal: OVERDUE_QUERY_STAGES → escalated/urgent/expired, OVERDUE_STATUS_STAGES → reminded/escalated/urgent, MERGEABLE_STATUSES → accepted/pending/failed.

One refusal I expected and could not reach: restoring a trashed denied event returns at the pre-adoption branch, ahead of the hook:save → unverified move RE_SAVE_FROM omits.

Previews not opened: the PREVIEW_ACCESS_* pair is unset.

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


Generated by Claude Code

Comment thread src/plugins/login/grantSummary.ts Resolved
Comment thread src/lib/stateMachine/actor.ts Resolved
Comment thread src/lib/atlasOverview/countNote.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 12, 2026
The invitation's flagged line tells a new manager attendees could not find
the class and it was taken off the map. It fired on `denials > 0`, while
what takes a listing down is `computeCommunityVerdict` — five denials and a
Wilson upper bound under 0.5. One dissenter among twenty confirmations
therefore produced an email about an unpublishing that never happened.

The predicate is the one that made the decision, so the sentence and the
stage it describes cannot disagree again.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZBZomK3wD6hYJGcEr
`transition` builds a claim naming the stage the caller read; this one's
`write` callback destructured it away, so the `unverified → denied` write was
unconditional.

The window is a manager adopting the class while its votes are counted. The
write then reaches `guardVerificationStage` with a stage no `community` move
starts from, and the refusal it throws rolls back the visitor's own vote
inside this unguarded hook — the failure #842 closed. Claimed, the row is
re-selected at write time and the write simply reports that it did not land.

Pinned in the unit lane rather than the integration one: the race is between
a read and a write, so the assertion is that the claim reaches `payload.update`
at all.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZBZomK3wD6hYJGcEr
`resolveActor` reads the declared actor and nothing else, so a write naming
none answers `null`. The docblock promised a `req.user` fallback behind it,
which sent a reader looking for a branch no module has — and made the two
collections' opposite handling of that case look like a single shared rule.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZBZomK3wD6hYJGcEr
Two callers, both in this directory, each saving six lines — and the
collection was hard-coded while the sentence was a callback, so it was
neither a general helper nor an abstraction either caller was shorter for.
The ticket asked for the failed-delivery row and its words, not a layer
beneath them.

What it did carry is the `null`-for-zero convention, which both callers now
state at their own return.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZBZomK3wD6hYJGcEr
Two cases joined the unit lane, so PERF.md's canonical count and the three
docs that quote it move together — `perf-figures-pinned.spec.ts` reddens on
any one of them lagging.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZBZomK3wD6hYJGcEr
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1135 November 12, 2026 19:51 Destroyed
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1135 November 12, 2026 23:37 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Three critic threads, main merged in, and one finding the security pass turned up.

  • actor.ts:17 — taken, c7ca29f. The context key carries the column now; import is declarable in both tables, so the shared key handed a submission's importer every event-stage move on that request.
  • machine.ts:17 — answered, 646f6f3. The docblock states the widening rather than a limit that had moved.
  • guard.ts:185 — open, and yours to settle. The create gap is real, and feat(events): enforce one lifecycle table for events and submissions #1121 §2 lists the proposal row this machine drops. A/B is in the thread.
  • Joined, dc0b340: a review decision's skip flag said true, not which row. A bulk accept runs every row on one request, so only the first got its event and log entry.

Gate ✓ lint, format, typecheck ×2, unit (270 / 3673), sixteen int specs. Security review ✓ nothing above its bar.

🤖 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 Nov 12, 2026
`main` (#1127) and this branch each appended measurement rows to
`tests/PERF.md` under their own ordinals, and the four #1131 rows reached
both sides at different indices.

Keeps `main`'s numbering, which already carries those four, and appends this
branch's three #1121 rows after it. No row is dropped or renumbered, and the
session's own measurement is recorded beside them.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWtuecC3drMgcCJUso
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1135 November 12, 2026 23:49 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main. One conflict: the unit-lane table in tests/PERF.md, where #1127 and this branch
each appended rows under the same ordinals.

Kept main's numbering — it already carries the four #1131 rows this branch had numbered
fifty-fourth to fifty-seventh — and appended this branch's three #1121 rows after it. Nothing is
dropped or renumbered.

Lean gate ✓ — lint, format, both typechecks, unit lane 271 files / 3685 tests (126 s).
Integration ✓ mailing-list-key, event-verification (56).

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


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 12, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 13, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 13, 2026
A create was never judged, so the table declared every later step of a
lifecycle and not where one begins: `stateMachineField`'s `defaultValue`
said where a row opened, and nothing refused a new row created straight
into a terminal state no writer may ever move it to. #1121 §2 lists a
`proposal` writer this machine dropped for the same reason — it only ever
creates a class, so a table of moves had no row for it.

A machine now declares `opensAt`, which the column takes as its
`defaultValue` and which stands for every writer, plus an `opens` row per
other state naming the writers that may author one. `judgeOpening` judges
a create against those rows, sharing the move judgement's own row pick so
the two cannot answer a writer differently. A missing or unlisted value is
left to the column: it is `required` and its options are the machine's
states, so refusing here would report a person's validation mistake as a
writer the table was not told about.

The openings that exist: a class opens `verified`, `unverified` to a
`proposal` (an accepted submission with no manager named), and any stage
to an `import`. A submission opens `pending`, and any status to an
`import`.

Two writers therefore name themselves where they did not. The class
import shares one write context with the dry validation pass it runs
first — `fieldErrors` runs Payload's own field `beforeChange` pass, and
the stage guard is one of those hooks, so a pass given a different
context refused a class the create would have written. The Atlas seed's
registration upsert authors `accepted`, and `scripts/preview-event-emails`
authors an escalated class and a settled sign-up; both named nobody and
would now be refused.

Reviewer's call on #1135: option A, build it here.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVEDwt82zbosDvsneg
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1135 November 13, 2026 00:59 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Answered the one open thread: a create is unjudged — you chose A, so it is built here in 0d67d0c.

A machine declares opensAt, which the column takes as its defaultValue and which every writer may open at, plus an opens row per other state naming its writers. judgeOpening judges a create against those rows, sharing the move judgement's own row pick. proposal joins the table with the opening #1121 §2 lists and no move of its own.

It turned up two live gaps in this PR's own guard. The class import's dry validation pass runs the same field hooks as its create, so a different context there refused a class the create would have written — one importWriteContext() now. And the Atlas seed's registration upsert authored accepted naming nobody, as did scripts/preview-event-emails.

Full integration lane ✓ — 107 files, 1917 tests. Lean gate ✓. The new where a class may open cases go red with the guard's create branch removed. Criterion added to #1121; PR body refreshed.

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


Generated by Claude Code

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

@Ardnived Ardnived left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to

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

Copy link
Copy Markdown
Contributor Author

Your approving review carries only its opening words — "Would it make sense to ". The rest did not post.

I built nothing on it rather than guess at the rest. Nothing else on this PR waits: all seven review threads are resolved, the branch is level with main, and 0d67d0c is green.

Finish the question and I will take it. Reply with @sydevs-bot address and the rest, and another run starts here.

⚠ Your approval stands and the merge gate is satisfied, so this may merge before you reply. Your point then needs its own ticket.

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


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 13, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 13, 2026
Merged via the queue into main with commit 38bb854 Nov 13, 2026
39 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-1121-lifecycle-table branch November 13, 2026 02:49
sydevs-bot added a commit to sydevs/WeMeditateWeb that referenced this pull request Nov 13, 2026
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 13, 2026

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1135 — 0d67d0c6 Deployed Nov 13, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

feat(events): enforce one lifecycle table for events and submissions

3 participants