Skip to content

feat(events): unverified + denied verification stages for crowdsourced listings - #624

Merged
Ardnived merged 6 commits into
mainfrom
feat/unverified-events
Aug 14, 2026
Merged

Ardnived merged 6 commits into
mainfrom
feat/unverified-events

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Summary

Part 1 of the crowdsourced-listings plan: Events can now exist without a manager in two new pre-adoption verification stages, so bulk-imported and (soon) user-submitted events have somewhere to live until a manager adopts them.

  • unverified — imported or accepted from a public submission; published so it appears on the map (badged client-side by the Atlas frontend), open to registrant confirm/deny voting (PR 3).
  • denied — community-rejected via the vote threshold; unpublished (_status: draft), voting closed.
  • Adoption is the only exit: assigning a manager and saving flips either stage to verified through the existing verify-on-save path. Grooming edits without a manager deliberately change nothing.

Changes

  • manager is conditionally required: every ladder stage implies one; unverified/denied/finished may be unmanaged (finished because the stale sweep below finishes run-out events that were never adopted, and a terminal stage sends no reminders).
  • New Events columns: confidenceScore (indexed Wilson lower bound — feeds will rank unverified listings by it), systemMeta (namespaced system-managed JSON, starting with communityFeedback vote tallies), submitter (→ users, record-keeping only) + submittedEvents join on Users.
  • ExpireEvents: two stage-independent sweeps — mark elapsed unverified/denied events finished (they carry nextCheckAt: null and are invisible to the due sweep), and trash finished events whose schedule ended 6+ months ago (retention measured from schedule end).
  • Atlas sidebar: managerless unverified/denied events in the manager's owned-region subtree now appear in the event list (the adoption surface); they bucket into Needs verification / Unpublished respectively.
  • Admin: EventVerificationNotice banners for both stages (with vote counts from systemMeta.communityFeedback), off-ladder steps in the stage tracker, a denied quality-check skip reason; quality checks run on published unverified events; events capped at 7 images.
  • Migration: ALTER TYPE ... ADD VALUE ×2 + new columns (validated with migration-validator; only the rollback path rebuilds the enum).

Tests

  • Unit: stage machine (no transitions for new stages), sidebar bucketing, timeline off-ladder steps.
  • Int: expire-events (finish sweep, 6-month cleanup, inactive exemption, due pre-adoption events never advance), verification lifecycle (grooming save inert, adoption flips both stages, managed-stage-without-manager refused), sidebar (subtree orphan surfaces), quality (unverified checked, denied skipped).

Follow-ups (separate PRs per the agreed plan): event-submissions collection + write-guard plugin + screening job; registrant confirm/deny voting + post-event follow-up emails.

🤖 Generated with Claude Code

…urced listings

Events can now exist without a manager in two pre-adoption stages:
'unverified' (imported or user-submitted, published and badged client-side)
and 'denied' (community-rejected via registrant votes, unpublished). Assigning
a manager and saving adopts the event into the normal verification cycle;
grooming edits without a manager change nothing (verifyOnSave skips).

- manager is now conditionally required: every ladder stage implies one;
  unverified/denied/finished may be unmanaged (the stale sweep finishes
  run-out events that were never adopted)
- new columns: confidenceScore (indexed Wilson lower bound for feed ranking)
  and systemMeta (namespaced JSON for system-managed metadata, starting with
  communityFeedback vote tallies); submitter relationship -> users
- ExpireEvents gains two stage-independent sweeps: finish elapsed
  unverified/denied events (they carry nextCheckAt: null and are invisible
  to the due sweep), and trash finished events 6+ months past schedule end
- Atlas sidebar surfaces managerless unverified/denied events from the
  manager's owned-region subtree so they can be found and adopted
- admin: verification notice banners + off-ladder stage tracker steps for
  both new stages; quality checks run on published unverified events and
  report a dedicated 'denied' skip reason; events capped at 7 images

Part 1 of the unverified-events plan (submissions collection and registrant
voting follow in separate PRs).

Co-Authored-By: Claude Fable 5 <[email protected]>
@railway-app

railway-app Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

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

Service Status Web Updated (UTC)
SahajCloud ✅ Success (View Logs) Web Aug 13, 2026 at 9:06 pm

…At watermark

The two standalone sweeps added for the pre-adoption stages both led with
`schedule.lastDate < now`, which matches every event that ever ended -
permanently, and with no composite index on verification_stage. That degrades
as the table grows, which country-batch imports will do quickly.

nextCheckAt doesn't have that shape: it's a watermark, so only genuinely
actionable rows ever sit in the past. Expressing the remaining transitions
there returns the job to a single, permanently cheap due-query.

- new resolveNextCheckAt() is the one place each stage's watermark is defined:
  schedule end for unverified/denied, min(stage deadline, schedule end) for the
  ladder, schedule end + 6 months for finished. Every writer routes through it
  (verify op, verifyOnSave, the job, the importer, the new hook)
- stageMachine becomes a discriminated union (remind | trash | await-schedule)
  inside an exhaustive Record<VerificationStage, StageRule>, so a new stage
  can't be added without deciding what the job does with it. No FSM library:
  the state is one enum column transitioned by a nightly batch, and the graph
  projections we rely on (daysUntilUnpublish, the admin timeline) aren't
  something a library would cover
- finished stops being a null-watermark dead end and becomes a dwell state
  with a retention deadline; finishesOnRunOut: false keeps a due finished
  event from re-finishing itself and deferring retention forever
- new syncUnmanagedCheckAt hook arms the watermark on write for pre-adoption
  events (deliberately ignoring skipVerifyHook - it's derived data, and both
  paths that create unverified events set that flag)
- a managed event whose schedule runs out is now finished the day after its
  last occurrence rather than up to a cadence later; the admin timeline gained
  a matching case so a capped watermark isn't mislabelled as a reminder date
- scripts/backfill-finished-retention.ts arms pre-existing finished rows
  (dry-run clean against dev: 68 rows, 0 failures)

Co-Authored-By: Claude Fable 5 <[email protected]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-624 August 12, 2026 19:07 Destroyed
… watermark module

Three review follow-ups on the watermark refactor, all structural:

- verifyOnSave + syncUnmanagedCheckAt collapse into syncVerificationOnSave.
  They were two branches of one question (what should this save do to the
  verification fields?), mutually exclusive by construction, and each carried
  its own copy of the schedule merge. The skipVerifyHook asymmetry between
  them — the verify branch honours it, the derived-watermark branch must not —
  is now a documented ordering inside one function rather than an invariant
  split across two files.
- StageRule/finishesOnRunOut is gone; MACHINE is Record<VerificationStage,
  StageAction>. The flag encoded a tautology — finishing is a transition
  *into* `finished`, so it cannot apply to an event already there — which
  reads better as a guard at the one call site than as a field repeated across
  eight rows. The invariant it protected is covered end-to-end by the
  retention case in the int spec.
- The watermark rule moves out of periods.ts into its own watermark.ts.
  periods.ts is cadence helpers; the watermark rule is the load-bearing
  contract behind the job's single query, and had turned its host into a grab
  bag.

Also fixes a pre-existing flake in the listing-progress tests (1 of 4 runs):
remindOnce took the first email sent to the manager address that every event
in the spec shares, so a second reminder landing in the same job run could be
asserted against by mistake. It now selects by event title — three
consecutive clean runs after the change.

src/lib/eventVerification stays in lib, deliberately: ten distinct owners
import from it (the Events and Registrations collections, the job, three
admin components, seeds, app routes, two lib folders), so co-locating it
under Events would force cross-owner imports into a collection's internals —
the arrangement .claude/rules/project-structure.md rule 4 prohibits.

Co-Authored-By: Claude Fable 5 <[email protected]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-624 August 13, 2026 02:18 Destroyed
Admin-panel layout only — no schema change (tabs and collapsibles carry no
`name`, so `migrate:create` generates nothing).

- confidenceScore: was hidden, now a labelled read-only field in the
  Verification tab, shown only while `unverified` — the one stage where votes
  are still being collected, so anywhere else the number is a stale artefact
- publicUrlFields now always wraps its fields in a collapsed 'Public Links'
  collapsible (Events, Regions, Pages), and takes hasAppUrl to omit appUrl
  entirely rather than emit a field that can only read null. Events opts out
  and moves the group into its Details tab
- legacyMigrationFields collapsible starts collapsed
- new collapsed 'System' collapsible gathers every machine-managed value that
  was previously hidden outright — nextCheckAt, registrationsFull,
  qualityOpenCount, qualityCheckVersion, systemMeta — so they're inspectable
  without a database query
- systemMeta is admin-only in the UI (adminOnlyCondition) and carries
  access.update: () => false. Visibility and writability are decided
  separately on purpose: Payload deletes an access-denied key from the
  incoming patch rather than nulling the column, and system writers pass
  overrideAccess, so hiding the field can never let a manager's save wipe it.
  Pinned by two tests

Co-Authored-By: Claude Fable 5 <[email protected]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-624 August 13, 2026 18:24 Destroyed
…icter contact rules

Consolidation. stages.ts and stageMachine.ts each held part of the lifecycle,
and some facts twice — an `unpublish` boolean on the transition AND a
PUBLISHED_STAGES list, an UNMANAGED_STAGES list AND an 'await-schedule' action.
Both files are now one exhaustive Record<VerificationStage, StageConfig> in
lib/eventVerification/stages.ts, declaring published/managed/onDue once per
stage; PUBLISHED_STAGES, UNMANAGED_STAGES, STAGE_DURATION_DAYS, LADDER and
whether a transition unpublishes are all derived from it. stageMachine.ts is
deleted (it had also outgrown the job folder — the collection, admin
components, sidebar and importer all read it).

Consolidating surfaced a real collision the tests caught: modelling `finished`
as managed: false made isUnmanagedStage() true for it, so the watermark took
the pre-adoption branch and skipped the retention window entirely. Those were
two different questions wearing one name — isUnmanagedStage (may have no
manager: unverified, denied, finished) is now distinct from isPreAdoptionStage
(no clock but the schedule: unverified, denied).

nextCheckAt stays nullable — null is the watermark's 'never', and inventing
deadlines to avoid it would reintroduce exactly the churn the watermark
removes. What was loose is now tight: `finished` falls back to retention-from-
now when there's no schedule end (the importer maps a dump status straight to
the stage, so dormant and open-ended rows could reach it with a null watermark
and never be trashed), leaving exactly one nullable case — a pre-adoption stage
with nothing scheduled. Pinned as an invariant over every stage.

Also: the importer wasn't threading its injected clock into the watermark.

Contact rules. A website no longer satisfies an inactive event's contact
requirement — it's metadata, not a route to a person (1 of 16 inactive events
in the dev DB relies on it and will need a real contact on next save).
contactEmail gains a bounded validator composed with `email` from
payload/shared (an email field takes no maxLength, and a custom validate
replaces the built-in format check); contactPhone likewise via `text`.
contactName now appears for a phone OR an email.

Reverted: appUrl is emitted on Events again and the hasAppUrl opt-out is gone.
Moved: submitter into the System collapsible.

Co-Authored-By: Claude Fable 5 <[email protected]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-624 August 13, 2026 20:38 Destroyed
… drop dead weight

Off-ladder is gone. The tracker had its own parallel vocabulary — OFF_LADDER,
OffLadderStage, JOURNEY, STEP_ORDER — restating what STAGES already knew, and
'off ladder' only ever meant 'this stage isn't in my hardcoded list'. It now
draws the journey the event is on: unverified -> denied -> verified for a
pre-adoption listing (with copy saying what adoption actually takes), verified
-> reminders -> expired once managed, finished as its own terminal. All six
steps use the full STEP_COPY structure; the only thing this file still knows
that the config doesn't is that three reminder stages collapse into one step.

systemMeta is now a reusable field factory (src/fields/systemMetaField.ts)
carrying a JSON Schema. That IS the built-in read helper: Payload generates the
exact type into payload-types (so systemMeta?.communityFeedback?.denials is
checked at compile time) and validates on write, so a malformed tally can't be
stored. readCommunityFeedback is deleted — a defensive runtime parser could
only report that bad data had already landed.

collectIds walked pages of a table it was concurrently mutating; it's one
pagination:false query, which is safe precisely because the watermark keeps the
due set bounded by the day's work rather than the table.

buildAtlasSidebarData is back to its original parallel shape. Pre-adoption
events come out of the subtree query that already runs for the region counts —
two extra fields in its select — instead of an OR branch that forced the
region reads to complete first.

Also: confidenceScore is visible for denied as well as unverified (on a denied
event the score is the reason it came down), and backfillFinishedRetention is
removed along with its script.

Co-Authored-By: Claude Fable 5 <[email protected]>

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-624 — 325d3f91 Deployed Aug 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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant