Skip to content

feat(atlas): open-items homes, per-role digests, simpler preferences - #1083

Merged
sydevs-bot merged 43 commits into
mainfrom
claude/feat-1070-atlas-digest-homes
Nov 7, 2026
Merged

sydevs-bot merged 43 commits into
mainfrom
claude/feat-1070-atlas-digest-homes

Conversation

@sydevs-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • Every Atlas manager now gets one home and one email per role, both built from the same open-items list, in place of five unrelated emails and two dashboards — one of which showed a region manager their whole subtree as "Your programs".
  • Adds the daily count snapshot the statistics compare against, a sixth submission status an admin settles, and seven role-filtered notification rows in place of four.

Change outline

Files — where an open item's meaning now lives

One folder answers "what is open, for whom", and four surfaces read it instead of each deciding for themselves. No barrel: every module is imported by its own path, so a client view cannot pull the server graph in behind one.

 src/lib/
+├── atlasOverview/
+│   ├── status.ts        # STATUS_TABLE — every word a reader sees: pill, line, rank, filter, whether it counts
+│   ├── filters.ts       # the client-safe leaf: the filter tabs, the pill names, WINDOW_DAYS, changeLabel
+│   ├── scope.ts         # whose list this is: OverviewScope, and the ?region= refusal
+│   ├── openItems.ts     # the rows one role sees, ordered, and withRecommendations for one page
+│   ├── regions.ts       # both overviews' rows (Healthy %, Overdue, Unverified, sign-ups)
+│   ├── statistics.ts    # the tiles, a tile's 30-day change, and the snapshot key both ends spell
+│   └── refusals.ts      # sign-ups the spam check filed, and the sentence that says so
+├── jobs/
+│   └── runClock.ts      # the four task handlers' one req.context.now override
 └── notifications/
+    └── managerRoles.ts  # which hats a manager wears, off the same joins virtualRoles reads

The region tree stays @/lib/atlas/regionTree. getRegionTree now also selects level and managers, so scope.ts and regions.ts read the memoized tree rather than loading one of their own.

 src/components/admin/
 ├── Dashboard/
+│   ├── shared/           # StatTiles, OpenItemsList, RegionOverviewTable, SectionTabs, HomeHeader, IconTip, rows.ts
 │   ├── AtlasManager/     # reworked: opens on the list, not on a page of programs
+│   ├── AtlasRegion/      # new — a region manager had no home at all
 │   └── AtlasAdmin/       # reworked: only what fell through everyone else's hands
+└── helpers/
+    └── listControls.tsx  # the pager and filter tabs a home and a list view both render

 src/emails/
+├── DigestEmail.tsx       # one template; which sections it draws follows the role
-└── RegistrationDigestEmail.tsx

 src/jobs/
+├── AtlasSnapshot/RecordAtlasSnapshot.ts
+├── Digests/{SendDigests,buildDigest,registrations}.ts
-└── RegistrationNotifications/{SendRegistrationDigests,sendRegistrationDigest}.ts

Contract — what a consumer or an operator can observe

No collection is added. A snapshot is a payload.kv row and a refused sign-up is a spam submission already stored, so the migration creates no table.

 user-submissions.status
   pending | accepted | rejected | spam | failed
+  confirmed_spam                          # an admin agreeing with the machine; counts a spam strike

 managers.notificationPreferences          # seven role-filtered rows, replacing four
-  invitation | event_verification | event_registration | regional_summary
+  invitation | event_verification | event_registration | new_proposals
+  open_items | refused_signups | statistics
-  'Daily Summary' | 'Weekly Summary'      # renamed by the migration, not re-defaulted
+  'Daily' | 'Weekly'
+  NotificationKey                         # derived from NOTIFICATION_TYPES; every reader takes it

+managers.digestWatermarks                 # jsonField, schemaTitle 'DigestWatermarks', access.update: () => false
-managers.lastRegistrationDigestSentAt     # dropped

+payload.kv  atlas-snapshot:<YYYY-MM-DD>   # one row per UTC day, replaced not appended, pruned at 38 days
 user-submissions                          # a refusal is type=registration + status=spam inside 7 days

 payload_jobs.task_slug
-  sendRegistrationDigests
+  sendDigests | recordAtlasSnapshot

Flow — one run, one email per manager per role

 sendDigests  (07:00 UTC, nightly queue)           src/jobs/Digests/SendDigests.ts
   for each active manager (paginated)
     managerRoles(manager)                         # program | region | admin, off the joins
     for each role
+      buildDigest(manager, role, runStart)        src/jobs/Digests/buildDigest.ts
+        PACES[frequency].due(runStart)            # one schedule, three paces, off one 07:00 run
+        windowStart(mark, frequency, runStart)    # the watermark, trusted inside two periods
+        section('statistics' | 'open items' | 'registrations')   # each counted, skipped on failure
+        nothing due → no email at all
+      sendDigest(…)                               # false → continue, so nothing counts as delivered
+      payload.db.updateOne({ digestWatermarks })  # bookkeeping on someone else's row, hooks skipped
+      manager.digestWatermarks = next             # kept in step on the loaded document

The watermark assignment is load-bearing: the loop sends a manager's roles against one loaded document, so a second role that merged into the stale column overwrote the first role's marks and would have re-sent its whole window.

PACES is keyed by SummaryFrequency and buildDigest names its keys as NotificationKey, so a fourth cadence or a misspelled row is a tsc failure rather than a manager nobody mails.

recordAtlasSnapshot rides the same hourly tick an hour earlier, so the statistics an email quotes are the ones the home shows.

Behaviour — who sees which open item

 openItem(row, now)                               src/lib/atlasOverview/status.ts
+  STATUS_TABLE                                   # one row per status: pill, rank, filter, counts
   every status a row has; the lowest rank places it
   urgent → Overdue rank 0, reminded/escalated → rank 2, expired → rank 6
   qualityOpenCount > 0 → N recommendations, counts: false     # advice, never progress
   none of the above → Up to date (a tick, not a pill)
+  isProgramStage(stage)                          # not finished: what both surfaces count

 loadOpenItems({ scope, req, overrideAccess })     src/lib/atlasOverview/openItems.ts
   program  → events whose manager is the user
   region   → their own, plus escalated-or-worse and unadopted listings in the subtree,
              plus the proposals routed to them
   admin    → only what reaches no region manager, plus sign-ups filed as spam
+  ⚠ owned sets come from a query, never a join's docs, which caps at its own limit

Components — the admin button declaration

A slot serving four intakes and two kinds of viewer decided over (kind, viewer, stage) through two maps and a gate, with the precedence rule living only in a comment.

 WorkflowButtonsProps                            src/components/admin/WorkflowButtons/stages.ts
-  onlyWhen: { field, equals }                    # render the fallback unless this field matches
-  stages: Record<stage, buttons>
-  ungatedStages: Record<stage, buttons>          # consulted first, whatever onlyWhen says
+  rules: { when?: { field?, equals?, userType? }, stages }[]   # first match wins
   fallback: 'publish' | 'save' | 'saveDraft' | null

Preview

  • A manager's home — opens on Open items, with the tiles, meter and filter row; which of the three homes you get follows your own roles
  • One region, scoped — ?region= with SetStepNav breadcrumbs; outside your own subtree it refuses before it reads anything
  • Countries / Regions overview — one component serves both overviews
  • The refused sign-ups — "Confirm spam" / "Not spam", offered to an admin only
  • Jobs — queue recordAtlasSnapshot and sendDigests by hand

Sign in with PREVIEW_ADMIN_EMAIL at /admin/login. Data: not seeded yet — a Railway preview forks configuration, not volume data, so the homes open empty until the atlas seed runs. Step 1 of Manual verification is that seed; no later run is promised to do it, so this line stays as a disclosure.

Email previews

⚠ These four predate the email rewrite and are no longer what a run produces. 7fd282d generated the plain-text part and split out the shared itinerary and answer components, c7893e0 realigned registrations and localized a registrant's schedule, 5aa84d0 put open items back in two columns, and 7013079 reheaded them "Need your attention". Read them for the shape of a digest, not for its wording. They expire 2026-11-12.

Contract impact

user-submissions.status gains confirmed_spam, and managers gains the generated DigestWatermarks type, so src/payload-types.ts changes. After this merges, sydevs/WeMeditateWeb and sydevs/SahajAtlasWeb re-sync with pnpm types:cms. No endpoint, response shape or embed contract changes, and the widget's own write path (POST /api/user-submissions with type: registration) is untouched.

Migration

  • New migration: src/migrations/20261105_201411_atlas_digests_and_homes.ts
  • Impact: no table is created or dropped. Adds confirmed_spam to the submission-status enum; rebuilds both task_slug enums to drop sendRegistrationDigests and add sendDigests / recordAtlasSnapshot; rewrites managers.notification_preferences in place; adds managers.digest_watermarks; drops managers.last_registration_digest_sent_at.
  • Reversible: yes. down returns confirmed_spam rows to spam and the renamed paces to their old spellings before it shrinks either enum, and deletes job rows naming the slugs it removes — a surviving row makes the rebuild's final cast throw, which on a deploy is a boot crash-loop rather than a failed statement. regional_summary carries into statistics and back out again, so the round trip is lossless rather than approximately so (e1249a6).

Hand-edited in four places, each documented in the file's own docblock. Verified up → down → up against a throwaway Postgres with a row of every affected kind already present, the migration applied as its own batch; the bare enum cast was reproduced failing first, so the guard is measured rather than argued.

Test results

  • Last recorded local gate: 5ec6920, the main sync — .claude/skills/pr-prep/check.sh (lint, format:check, typecheck, typecheck:tests, test:unit), plus atlas-manager, atlas-overview, digests and atlas-report-issue-form: 52 passed.
  • 22 commits have landed since, all the reviewer's. Nothing local was re-run for them; CI runs the full lane and the build on 3a31e39.
  • This round changed the body and the review threads only — no code.

Manual verification

The homes read live data, and a fresh preview has none — so seed first:

  1. pnpm tsx scripts/redeem-signin-link.ts '<link>' --seed atlas against the preview, with a link requested as PREVIEW_ADMIN_EMAIL.
  2. As a program manager: /admin opens on Open items. Verify, Review and Continue editing each open an edit view that already exists — confirm none 404s and none acts on open.
  3. As a region manager: the list and the Regions overview both render; opening a sub-region shows its home under breadcrumbs; ?region=<id> for a region outside your subtree shows the refusal.
  4. As an admin: Verification health tiles show; the list holds the spam sign-ups and the items reaching no region manager; the Countries overview drills into a country. Setting confirmed_spam, or releasing one to pending, removes it from the list.
  5. In Jobs: queue recordAtlasSnapshot, then sendDigests. Mailpit should show one email per role, summary line first, each ending in "Open your dashboard".
  6. A stage tile's change line needs a snapshot. A preview has none from 30 days ago, so the five Verification health tiles and Total events should show no change line at all — not "+0". Registrations is the exception: its change is two windows of dated sign-up rows, so it always draws a line, "+0 in 30 days" on an empty preview.
  7. Total events and the Programs column must agree. Finish a listing in the scope you are looking at: both numbers drop by one, and the Registrations total does not.

Notes for reviewer

The reviewer has pushed 22 commits onto this branch (f9fdc38…3a31e39), reshaping it twice over. Four of them build what the earlier rounds had dismissed, so those dismissals are gone from this body rather than restated:

  • f9fdc38 gave digestWatermarks a jsonField schema, so DigestWatermarks is generated rather than hand-written. That settles the "worth a second opinion" this body used to carry.
  • d304220 collapsed the ten status literals into STATUS_TABLE.
  • 86ce445 gave the four task handlers one runClock.
  • adabf6a made an implicit read follow project membership, so a project-less collection fails closed — tests/unit/implicit-read-fails-closed.spec.ts pins it.

The region-tree ruling is superseded by the reviewer's own commit. 0f6d7d4 built rollUpRegionTree and the thread approved it; 19cb9a9 then deleted it, put the sidebar back on main's loop and inlined the overview roll-up. Two walks remain, not three — rollUpRegionManagers is gone and getRegionManagers serves managers — and the two differ in input: rollUpRegionCounts is pure over pre-shaped SidebarCountEventInput, while regions.ts reads event documents against tree.chainById and the scope set for six counters plus the dated sign-up pair.

Deliberate deviations from the ticket:

  • The shared email components went into src/emails/EmailLayout.tsx as specified, beside SectionHeading and BrandButton — not into a new module.
  • buildRegionTree stays sidebar-only, by the reviewer's decision: both overviews render flat rows, not a nested tree.

Still dismissed, with reasons:

  • Drop the tautological event in (every id) from the admin scope's sign-up query. Not behaviour-preserving: find excludes trashed events, so the id list is not every event, and dropping the term would newly count sign-ups on trashed ones.
  • Merge the status table's Overdue set with the two query-side ones. They differ, and the difference is the point: the status also carries reminded, while a reminded listing is still healthy and still not a region manager's to join. OVERDUE_QUERY_STAGES covers the two that do match, and says so.
  • Share the snapshot date key with EventVerificationNotice.tsx. They are not the same function: that one is a nullable display formatter with a NaN guard, and it sits in a 'use client' component that must not reach atlasOverview at all. The key lives in statistics.ts, which reads it back.

A /security-review over the branch found nothing exploitable. It traced every overrideAccess: true read in atlasOverview to a bound the reader cannot influence, confirmed ?region= cannot widen past resolveOwnedRegionIds, and confirmed there is no path to confirmed_spam except from spam by an admin. One thing it raised turned out to be a false positive: it read Users/endpoints/block.ts's pending → spam sweep as something guardStatusTransition would now refuse — block-user.int.spec.ts passes and the rows do move. That review predates adabf6a, which is the one commit since to touch a securityReview.triggerPattern path.

Detail

The migration's four hand edits, in up and down both: job rows naming a removed slug are deleted above each task_slug rebuild; confirmed_spam rows go back to spam above the status rebuild; preferences are rewritten rather than re-defaulted, because a column DEFAULT reaches new rows only; and the two DROP CONSTRAINT statements the generator emits for foreign keys its own DROP TABLE … CASCADE has already taken are removed, as 20261019_182311_import_plugin.ts removed them.

The preference rewrite round-trips, and did not. up subtracted regional_summary outright, so a rollback left the key missing and a manager who had muted regional summaries came back on the default. Both rows offer the same ['Monthly', 'Never'] pair, so the value carries into statistics — the row #1070 gave that content to — and down puts it back. Re-measuring the cycle against a throwaway Postgres also caught down writing "event_registration": null on every manager without that row, and planting regional_summary on one who never had it: jsonb_build_object on an absent key writes a literal null. Both branches are conditional now, under the jsonb_strip_nulls that already wrapped up.

Why snapshots are payload.kv and not a collection. 5f425c9 moved them. payload_kv is already in 20260606_050852_initial_schema, so the store owed no schema change; one row per UTC day is set, never appended, so a retry after a crash cannot leave a day half counted; and RecordAtlasSnapshot prunes past SNAPSHOT_RETENTION_DAYS (38 — the 30-day comparison, plus SNAPSHOT_TOLERANCE_DAYS, plus a day of slack) with a string comparison, because the keys sort as their dates do. The same commit dropped the registration-refusals collection: a refused sign-up is already a user-submissions row at status: spam, so refusals.ts counts those instead of storing a second copy.

Nothing is left from the closed PR #1052 (claude/feat-259-refused-signup-digest). The branch took its registration-refusals collection and recordRefusedRegistration wholesale; 5f425c9 deleted both, because a refused sign-up is already a spam submission. ⚠ That checkout silently reverted two later changes — ScreenSubmissions.ts lost #1060's blocked-sender check and projects.ts lost #1068's role rename, because #1052 predates both. Existing integration specs caught each; both are restored in 302c9c9.

Why the homes read with overrideAccess: false and the job with true. A page shows exactly what the reader's own access admits, so a scoping bug surfaces as a missing row rather than as a leak. The job has an explicit scope and no user at all, so there is no access to defer to — scopeRegionIds is what bounds it, and loadRegionOverview takes no overrideAccess precisely because it cannot honour one: a row's counts are a roll-up over a subtree, where a reader's own grants would undercount a region rather than refuse it.

Performance, measured against the shape rather than a stopwatch. Every loader in atlasOverview was its own entry point, so a region home opened with four full scans of a table holding a node per country, region, area, city and venue, each with a breadcrumbs join; the digest paid two per manager per role. The region tree and the open-proposals read are memoized per request, the regions overview's event and sign-up reads are narrowed to the scope, and the refusal count is a count, not a find.

One acceptance criterion was silently unmet until the review pass. SectionTabs refused to render fewer than two tabs, so the program home's Open-items tab — and with it the count, or the tick that stands in for zero — was never drawn. A lone tab renders now.

Closes #1070

claude added 12 commits November 5, 2026 19:37
`spam` is the machine's refusal, and nothing recorded an admin agreeing with
it — so a refused registration stayed `spam` for ever and could not leave the
admin's open-items list. `confirmed_spam` is that agreement: it counts a spam
strike like `spam`, ages out on the same 90-day window, and drops the row out
of `INACTIVE_STATUSES` so the seat stays free.

Settling one is an admin's call on every intake, not a reviewer's on a
proposal, so `reviewMove` answers it ahead of its proposal gate and
`WorkflowButtons` grows an `ungatedStages` map for the stages a slot's every
kind of document shares — gated out, a `spam` registration reached no stage at
all and kept its plain Save button.

Also: the seven role-filtered notification preference rows that replace the
four, with one default resolver every reader shares; a `digestWatermarks`
column the job alone may write; the daily `atlas-snapshots` counts the homes
and the statistics email compare against; and PR #1052's `registration-refusals`
collection, its intake hook and the screening write, without its job, template
or preference row.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
Three homes and one email showed the same work in four vocabularies, so
`src/lib/atlasOverview/` now owns every word a reader sees about an open item,
and the loaders answer for one role at a time rather than for a user — a
manager who runs a class, looks after a region and administers the map does
three jobs on three paces.

`SendDigests` replaces `SendRegistrationDigests` and PR #1052's job: one 07:00
UTC schedule decides Daily, Weekly and Monthly, because three schedules would
send a Weekly manager two emails on a Monday the 1st. Per-role, per-key
watermarks on `Managers.digestWatermarks` keep it exactly-once, clamped to one
period so re-enabling a muted section does not deliver six months at once.
`deliverProposal` keeps its routing and then reads the recipient's own
`new_proposals` pace, so only the moment of delivery moves.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
Each home opened on a list of things rather than a list of problems: the
program home showed every program, the admin home showed a "Needs attention"
row that was everyone else's work, and a region manager had no home at all —
`dashboardChoiceFor` gave them their whole subtree as "Your programs".

All three now open on the same ordered open-items list, built from Payload's
own `Table`, `Pill`, `Button` and `Pagination`, with the filters drawn as the
Tabs field's own tab buttons. Every next step is a link to an edit view that
already exists; no endpoint, action or hook is added for any of them.

`src/lib/atlasOverview/filters.ts` is split out of `status.ts` so a
`'use client'` component can name a filter without pulling the loaders — and
through them `@/lib/env/server` — into an admin browser chunk, which
`client-bundle-safety` caught and which fails on the Railway deploy rather
than in CI.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
Four statements the generator cannot know to write, three of which are the
difference between a deploy and a boot crash-loop:

- job rows naming `sendRegistrationDigests` are deleted before `up` rebuilds
  the two `task_slug` enums without it, and `down` owes the same for the two
  slugs this adds — the rebuild's final cast throws on any surviving row;
- `confirmed_spam` rows go back to `spam` before `down` shrinks the status
  enum, for the same reason;
- preferences are rewritten, not just re-defaulted: the column DEFAULT reaches
  new rows only, so 'Daily Summary' becomes 'Daily', 'Weekly Summary' becomes
  'Weekly', and `regional_summary` is dropped;
- the two `DROP CONSTRAINT` statements the generator emits for FKs its own
  `DROP TABLE … CASCADE` has already taken are removed, as
  `20261019_182311_import_plugin.ts` removed them.

Verified up → down → up against a throwaway Postgres with each of those rows
already present, the migration applied as its own batch. Measured, not
reasoned about: the bare cast was reproduced failing first.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
`atlas-overview.int.spec.ts` reads one loader through all three roles with
`overrideAccess: false`, so a case that passes is one the reader's own access
admits. `digests.int.spec.ts` replaces `registration-digests` for `SendDigests`.

Two defects the specs found, both fixed here:

- **A manager holding two roles lost one role's watermarks.** The run sends
  their emails in a loop over one loaded document, and the second role merged
  into the document's stale column — writing its own marks over the first's, so
  the first role's whole window would have been re-sent. `advanceWatermarks`
  now returns the column and the loop keeps its copy in step.
- **Reopening a refused proposal became admin-only.** The spam branch was
  answering ahead of the reviewer path for every intake; a reviewer's own
  false-positive recovery on a proposal is theirs and stays theirs, and only
  confirming a refusal — and releasing one on an intake nobody reviews — is the
  admin's.

Also restores two files the wholesale checkout from PR #1052's branch reverted:
`ScreenSubmissions.ts` lost #1060's blocked-sender check and `projects.ts`
lost #1068's role rename, because that branch predates both.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
`docs/rules/admin-ui.md`'s dashboard section described two homes and a "Needs
attention" row that is gone. It now says which home each role gets and why the
widest wins, where every word about an open item lives, why a `'use client'`
component must deep-import `atlasOverview/filters`, and where a tile's change
line comes from — a stage count from the daily snapshot, a sign-up count from
two dated queries, and neither as "+0" when nothing can say.

Also: `src/AGENTS.md` for the new lib folder and why `managerRoles` is shared;
`docs/rules/email.md` for `DigestEmail`, the four new `EmailLayout` exports and
the preview script; `tests/COVERAGE.md` for both new specs.

One spec changed with it: a new-event proposal's delivery now defers at a
digest pace, so `atlas-submission-routing` asserts both arms — routing is
settled before the pace is read, because escalating a muted manager's proposal
to somebody else is not what muting asks for.

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

Two acceptance criteria that only a query-backed read and a refused field
satisfy, each written against the way it would otherwise fail quietly.

A join carries at most its own limit, so a home reading "which events" off
`req.user.managedEvents` shows a manager with thirteen programs ten of them
and calls that their list. The case creates thirteen and asserts both the
count and the page.

A manager who could rewind their own watermarks would re-send themselves every
open item the window covers. Payload strips a field its `access.update`
refuses rather than erroring, so the PATCH succeeds and the assertion is the
unchanged column, not a 403.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
…ng the map

Three things the review pass found, each a defect this branch introduced.

**A button only an admin may press was offered to every manager.** The spam
buttons were declared `ungatedStages`, which outranked the `onlyWhen` gate
unconditionally — so a region manager opening a refused *contact* row addressed
to them (which `managerSubmissionScope` admits) saw "Confirm spam" and "Not
spam", both of which `reviewMove` answers with "Only an admin can settle a spam
refusal." It also left `REVIEW_STAGES.spam` permanently shadowed, so the Reopen
a reviewer is entitled to was unreachable and read as live coupling.

`onlyWhen` + `stages` + `ungatedStages` are replaced by one ordered `rules`
list, first match wins, whose `when` can name a form field **or** the viewer's
admin type. A slot serving several kinds of document decides over (kind, viewer,
stage), and precedence between those is what a reader most needs to see; it also
gives the privileged-move gate one spelling on both sides of the wire.
`spamActionFor` now takes `reviewable` rather than the intake, so the
reviewability rule is read once instead of twice with opposite polarity.

**The region table was read three or four times per page.** Every loader in
`atlasOverview` is its own entry point, and each opened with a full scan of a
table holding a node per country, region, area, city and venue, with a
breadcrumbs join — `memoizeOnRequest` collapses that to one, and the open
proposals read with it. `managersInSubtree` walked the whole node table per
emitted row; it is one accumulating pass now, the same shape as
`rollUpRegionMetrics`. The regions overview read every event on the atlas
whatever the scope, and `loadRefusals` had no bound at all on a table that keeps
90 days of refused sign-ups.

`subtreeOf` no longer wraps `resolveOwnedRegionIds`, which already returns the
subtree, and `toNode` calls `breadcrumbAncestorIds` instead of re-inlining it
without its dedupe. `RegionNode.parentId` and the refusal path's fabricated
empty dataset are gone; `AtlasRegionData` is a union, so a refusal carries
nothing to render by mistake.

**The one claim that was simply false:** `filters.ts` said `status.ts` reaches
`@/lib/env/server` through `eventDetails`. Walking the real graph with the
bundle-safety spec's own resolver, `status.ts` reaches six files and no
server-only module; the barrel reaches sixty-seven and is the whole hazard. The
docblock, `docs/rules/admin-ui.md` and the barrel now say that instead, and the
barrel carries only the names a consumer takes off it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
The rest of the review pass. Nothing here changes what a reader sees, with one
exception noted below.

**Facts that were written twice.** The refused-sign-up count had its window in
two constants, its query in two places and its sentence in two more — one of
which hard-coded the 7 the other read from a constant, so moving the window
would have left the home and the email disagreeing in words while agreeing in
data. It is one `refusedAtTheForm` now, returning the finished line. `due.ts`
takes its three paces from `SUMMARY_FREQUENCIES` rather than restating them, so
a fourth cadence added to a preference row is a type error here instead of a
manager silently never mailed. `changeLabel` lives beside the window it
measures. Both new collections take `adminOnlyAccess` from the module whose
stated job is owning that predicate, where one had spelled the body out by hand.
The two query-side overdue stage sets are one constant — and the status table's
Overdue is deliberately *not* merged into it, because that one also carries
`reminded`: a reminded listing is still healthy and still nobody else's to join,
so the difference is the point and the comment says so.

**Dead ends.** `stageRank` and the nine `rank:` entries feeding it lost their
only caller when the old manager home went, and the docstring still described
that home's ordering. `OpenItemsResult.open` was never read. `RegionNode.parentId`
was only ever written. Four exports had no importer. `methodRequired` tested a
blank-pace state the flattened preferences cannot produce. `OpenItemsList` now
derives its own `open`, where three views computed the same expression and each
carried an arm that cannot fire.

`buildDigest` implements the "a failing section is counted and skipped" rule
once instead of three times. `failed` is what rides out in the task output, so a
fourth section catching an error without counting it would report the job green
while the email was short a section.

**The exception: a lone `SectionTabs` rendered nothing.** The component refused
fewer than two tabs, so the program home's Open-items tab — and with it the
count, or the tick that stands in for zero — was never drawn, which the ticket
asks for explicitly. A single tab renders now.

Not done, and deliberately: `status.ts`'s ten status literals each spell `rank`,
`filter` and `counts` inline, and those three are functions of the key (bar
`overdue`'s two ranks). Collapsing them into one table beside the keys is a real
simplification and `open-item-status.spec.ts` pins every value, so it is safe —
but it rewrites the most-read part of the feature, and it is better reviewed on
its own than inside this diff.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
`adminOnly.ts` exports a field-level lock and a condition but had no
collection-level `Access`, so a collection declaring its own admin-only block
spelled `isAdminManager`'s body by hand — the shape #630 records as having
silently refused a role that should have been admitted.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
`getAtlasRegionData` answers a union now, so every read of the home's data
was an error under `typecheck:tests` — which `pnpm typecheck` does not cover,
since the root tsconfig excludes `tests`. The lean gate caught it.

The narrowing lives in the describe block's `load` helper rather than at each
read; the refusal keeps its own case, which calls the loader directly and
asserts the whole shape.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXTrJHBHrgoxUxPjKL
A collection in no project reads as *shared* for visibility
(`docs/rules/access.md`), so every manager saw a sidebar entry whose `access`
can only answer 403 on open — the kind of decorative control the access layer
avoids elsewhere.

⚠ The function form, not `true`: `hidden: true` unregisters the routes too, and
the admin home's own View link points at this collection, so `true` would 404
the one reader it exists for. `payload-jobs` is the precedent.

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

railway-app Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

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

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Nov 7, 2026 at 8:06 pm UTC
1 service not affected by this PR
  • mailpit

@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.

1 question for the reviewer, one per thread.

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


Generated by Claude Code

Comment thread src/lib/atlasOverview/regions.ts Resolved
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 5, 2026
@sydevs-bot

sydevs-bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
CI fix 1

recent dispatches
  • 19:53Z fix-ci · attempt 1 · session · done
  • 19:53Z fix-ci · attempt 1 · session
  • 19:41Z address-review · attempt 1 · session · done
  • 19:41Z address-review · attempt 1 · session
  • 19:32Z review-pr · 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 5, 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

#1070 names nearly every file here by path, so this 113-file diff is the ticket's size, not the PR's. The contract holds: confirmed_spam is additive and no endpoint moves. What a second reading costs is shape: three copies of one region-tree rollup remain, two surfaces of one page disagree about what a "program" is, and the preference vocabulary is bare string end to end, which is what lets a key be restated twice more and a wrong cadence fail silently. On your own question: digestWatermarks as bare json is what #1070 specified, so leave it.

Findings

  • should-fix — statistics.ts:218: Total programs counts finished events; the Programs column beside it does not.
  • should-fix — due.ts:29: a docblock promising a type error that cannot happen; a new cadence would mail nobody.
  • should-fix — regions.ts:78: the third copy of one tree rollup.
  • consider — snapshots.ts:9: a file for one line written elsewhere already.
  • consider — filters.ts:8: one hazard explained at length three times.

What was checked

Read whole on the branch: all ten atlasOverview/ modules, all four Digests/ modules, WorkflowButtons/stages.ts, the migration, and the statuses.ts / active.ts / access/ diffs.

Ladder, named: rollUpRegionCounts and buildRegionTree (sidebarModel.ts:234,263) against the new walkers; NOTIFICATION_TYPES against DIGEST_KEYS.

Clean: the program scope suppresses its snapshot comparison rather than mismatching it (statistics.ts:210); advance is pushed inside each section, so a throw re-sends; scopeRegionIds cannot widen past resolveOwnedRegionIds; down releases confirmed_spam before both enum rebuilds. One gap: up destroys regional_summary, down does not restore it.

Preview /admin and ?region=1 answer 200; unseeded, so read as code.

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


Generated by Claude Code

Comment thread src/lib/atlasOverview/statistics.ts Resolved
Comment thread src/jobs/Digests/due.ts Resolved
Comment thread src/lib/atlasOverview/regions.ts Resolved
Comment thread src/lib/atlasOverview/snapshots.ts Resolved
Comment thread src/lib/atlasOverview/filters.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 5, 2026
`up` subtracted `regional_summary` outright, so a rollback left the key
missing and a manager who had muted regional summaries came back on the
default. The two rows offer the same ['Monthly', 'Never'] pair, so the value
carries into `statistics` — the row #1070 gave that content to — and `down`
puts it back under its old key.

Measuring the round trip against a throwaway Postgres also showed `down`
writing `"event_registration": null` on every manager without that row, and
planting `regional_summary` on one who never had it: `jsonb_build_object` on
an absent key writes a literal null. Both branches are conditional now, and
`jsonb_strip_nulls` wraps the statement as it already wrapped `up`'s.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXqfxsuuwdsr1T23Qz
Total programs counted every event in scope, finished listings included,
while the Programs column beside it counted only the ones that are not — so
an admin read one total in the tile and a different sum down the Countries
table for the same scope. #1070 defines Programs as the latter.

`isProgramStage` is the one definition now, in `status.ts` beside the rest of
what a reader is told, and the snapshot comparison takes the same subset or a
listing finishing reads as a program disappearing. The sign-up totals still
count every event, as the Sign-ups column does, but the per-event map is
narrowed to programs: both its readers divide by a count of programs, and a
finished listing in it could put "Programs with a sign-up" above the total
above it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXqfxsuuwdsr1T23Qz
`due.ts`'s docblock promised that a cadence added to `SUMMARY_FREQUENCIES`
would be a type error here. It was not: `isDue` took a `string` and answered
`false` for anything it did not name, so a fourth cadence would have left
every manager who picked it unmailed with nothing failing — the exact failure
the comment claimed to prevent. The switch is exhaustive over the union now
and carries no `default`, so adding one fails `tsc` in `isDue` and `periodMs`
both. Measured by adding a fourth.

The preference keys were bare `string` end to end, which is what let
`DIGEST_KEYS` restate seven of them where a typo resolves to `Never` and
sends nothing. `NOTIFICATION_KEYS` is the vocabulary, `NotificationType['key']`
and every reader take it, and a misspelling is TS2820. It is declared rather
than derived — derived, `key` would be `string` again — so a unit case pins it
against the rows in both directions.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXqfxsuuwdsr1T23Qz
The same walk — item into its own region, then up the ancestor chain, gated
on the scope — existed three times: the sidebar's published/total pair, the
overviews' six counters, and the overviews' manager sets. Each differed only
in what it added per item, which is the part that is genuinely each caller's.

`rollUpRegionTree` takes the chain, the scope and an accumulator factory, and
every caller instantiates it. No extra walk: the item set and each chain still
come from the caller. The manager roll-up keeps the one real difference and
now says so — it filters the nodes rather than letting the scope refuse them,
because an out-of-scope region's own managers must not reach an in-scope
ancestor's count.

The new spec pins what the three share and none of them stated, including that
`empty` is a factory: one shared accumulator makes every region report the
whole scope's total, and was watched failing six cases across two specs.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXqfxsuuwdsr1T23Qz
A module whose ten lines were seven of docblock and one of
`toISOString().slice(0, 10)`. Two callers is a reason not to inline it twice,
not a reason for its own file — `statistics.ts` reads the key back, so it is
where the spelling belongs, and the nightly task imports it from there.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXqfxsuuwdsr1T23Qz
The story ran at full length in four places — filters.ts, the barrel, this
rule file and src/AGENTS.md — about 25 lines re-narrating one import chain.
src/AGENTS.md already declares itself its one home, so the three others carry
the rule and a pointer, with the ⚠ markers kept. The measured walk moves to
that home, since it is the evidence a reader deciding whether to deep-import
actually wants.

Also lists the new `regionTree/` folder in the src/ layout.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXqfxsuuwdsr1T23Qz
Ardnived and others added 2 commits November 7, 2026 12:25
Start time, the cadence in as few words as reads, and the city the event
meets in (a venue's city, else its address's), on the dashboard and in
the digest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the Registrations view onto FilterTabs and QueryPager, keeping
#1092's hidden empty filters and accepted-only CSV; FilterTabs renders no
tab row when it is given none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1083 November 7, 2026 19:32 Destroyed
@Ardnived

Ardnived commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@sydevs-bot review

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 7, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 7, 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

Since the first review the branch changed shape twice over, and the handoff did not keep up. The snapshot collection became payload.kv, registration-refusals became a count over spam submissions, and rollUpRegionTree — the shared walker this thread settled on — was deleted. All three read as simplifications. None is declared, and two are described the old way in the body.

The walker needs a decision, not an edit: regions.ts walks the subtree itself again, beside sidebarModel.ts:234, which is what the ruling settled against. Scope is otherwise the ticket's: #1070 names these files by path. The contract holds — confirmed_spam is additive and no endpoint moves.

Findings

  • blocker — regions.ts:106: the shared roll-up this thread approved was deleted after approval.
  • should-fix — statistics.ts:28: the body's Contract, Migration, file tree and flow describe an abandoned design.
  • consider — statistics.ts:270: the Registrations tile always draws a change line; step 6 says none does.

What was checked

Read whole on the branch, against #1070 §3, §5, §6: the seven atlasOverview/ modules, the three Digests/ modules, RecordAtlasSnapshot.ts, StatTiles.tsx, the migration.

Ladder: rollUpRegionCounts / buildRegionTree (sidebarModel.ts:234,263) against regions.ts:99-118; payload_kv is already in 20260606_050852_initial_schema, so no config change was owed.

Clean: the migration round-trips — slug rows deleted and confirmed_spam released before each enum rebuild, both preference branches conditional under jsonb_strip_nulls; 38-day pruning covers the compare plus SNAPSHOT_TOLERANCE_DAYS; countByRegion counts the set the live tiles do.

Anomaly: an anchor on mergeRepeatRegistration.ts was refused — it is main's (#1092), not this PR's. Previews not opened.

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


Generated by Claude Code

Comment thread src/lib/atlasOverview/regions.ts Resolved
Comment thread src/lib/atlasOverview/statistics.ts Resolved
Comment thread src/lib/atlasOverview/statistics.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 7, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Three critic threads answered, no code pushed. The branch was already level with main.

  • The deleted shared walker — rebutted. 19cb9a9 is your own commit, 16 hours after the ruling it rests on, and it states why. Restoring rollUpRegionTree would revert you.
  • The stale body — adopted. Rewritten against the branch: no new collection, no table in Migration, payload.kv and the spam count named, the tree and flow matched, four dismissals now listed as built.
  • The Registrations change line — half adopted. The code is right; Manual verification step 6 was wrong and is rewritten.

⚠ The four Mailpit previews predate 7fd282d c7893e0 5aa84d0 7013079, so they no longer show what a run sends. Regenerating them needs a seeded database.

Test results now attribute the last gate to 5ec6920, with the 22 commits since named.

🤖 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 7, 2026
`EMAIL_STRING_DEFAULTS` spans two groups of the atlas translations global:
`emails`, and the twelve `recurrence_*` keys an email's schedule reads from
`event.recurrence`. The translations seed filled the `emails` group from the
whole table, so every run sent those twelve as additional properties. Each
leaf group declares `additionalProperties: false`, so Payload refused the
write with `The following field is invalid: Emails > Emails` — naming no key,
and naming a group the data was right about.

`EMAILS_GROUP_DEFAULTS` is the subset the group itself declares, and the seed
fills blanks from that. The recurrence copy already reaches `event.recurrence`
from each locale's own seed file, so nothing else changes.

`tests/unit/atlas-translations-schema.spec.ts` now pins that export against
the schema rather than re-spelling the prefix filter. Watched it fail with
the filter removed, then pass with it back.

Fixes: seeds/tests/atlas-translations-import.test.ts and
tests/int/wm-web-translations-seed.int.spec.ts, the two red files on 3a31e39.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVAL2jVJbjdYCDQsZY
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1083 November 7, 2026 20:01 Destroyed
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 7, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 7, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 7, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit fd18755 Nov 7, 2026
21 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-1070-atlas-digest-homes branch November 7, 2026 20:34
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 7, 2026
sydevs-bot added a commit to sydevs/WeMeditateWeb that referenced this pull request Nov 7, 2026
Ardnived added a commit that referenced this pull request Nov 10, 2026
`20261106_094841_clients_one_site.json` was generated before #1083 merged in,
and it is the newest snapshot, so the next `migrate:create` diffed against a
schema without #1083's columns and enums and re-emitted all of them — the
duplicate-DDL crash-loop `src/migrations/AGENTS.md` describes. Every statement
the probe emitted already ships in `20261105_201411_atlas_digests_and_homes`.

This migration has run nowhere (the PR preview was deleted), so its snapshot is
replaced with the probe's, generated on the merged tree, rather than stacking an
empty migration. A second probe writes no files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1083 — d50ab05a Deployed Nov 7, 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(atlas): open-items homes, per-role digests, simpler preferences

3 participants