Skip to content

fix(access): narrow managers' contact details to the reader's region - #1045

Closed
sydevs-bot wants to merge 21 commits into
mainfrom
claude/fix-908-manager-field-locks
Closed

sydevs-bot wants to merge 21 commits into
mainfrom
claude/fix-908-manager-field-locks

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #908. Closes #1047. Folds in #1054, by the maintainer's decision to ship both as one PR.

Summary

Before launch, any atlas-manager could read every other manager's email and phone or messaging handles in two places. This PR narrows both to the same rule:

Region managers should be able to see the email addresses of managers on sub-regions and events within their region. They need to be able to contact these users. (Ardnived, 2026-10-30)

  • managers collection (fix(access): atlas-managers read every manager's contact details #908): another manager's row shows name only. email and contactDetails also show when that manager is assigned to an event or a sub-region inside the reader's region, co-managers included. Admins and self-reads are unchanged.
  • Activity logs (fix(access): an event's activity log leaks a manager's contact details #1047): reminder and delivery entries in Events.activityLog and user-submissions.activityLog show their address only to an admin, the address's owner, or a manager whose region holds the event. Everyone else still sees that a reminder or delivery happened, to whom, and when.
  • Both use the same region test that atlas-manager event writes already pass (isEventInScope / eventScopeWhere).

Accepted gap (Ardnived, 2026-10-30): a region manager can assign any manager to an event in their region, read that person's details, and unassign them again. It leaves an invitation email behind and is recorded in docs/rules/access.md. It is still far narrower than main, where every atlas-manager reads every manager.


Part 1 — the managers collection (#908)

Summary

  • Every field on managers now carries a read lock, so an atlas-manager reading another manager gets name. The exception is a manager assigned inside the reader's own region, where email and contactDetails come back as well (see "Region widening" below).
  • stripLockedFieldsOnSelfRead stands down off the caller's own row — without that, the locks would have silently halved every event's re-verification window.
  • Joined: UserSubmissions.previewEvent carried a colleague's whole manager row past those locks, through a copy rather than a relationship.

Change outline

Contract — what an atlas-manager reads off another manager

atlas-manager holds a collection-wide managers: read because a picker exists to list other managers, so the Where cannot be self-scoped (#821). The narrowing is field by field instead.

 GET /api/managers            as an atlas-manager
   id, name, createdAt, updatedAt, collection
-  email, type, roles, language, currentProject
-  contactDetails[]           # phone numbers, messaging handles
-  notificationPreferences    # cadence per notification kind
-  lastRegistrationDigestSentAt
-  legacyId, legacyData       # the imported Atlas row, verbatim
-  magicLinkIssuedAt          # the outstanding sign-in link's timestamp
-  pendingInvitation          # the regions/events/pages just granted
-  invitationDueAt
-  _verified
+  contactDetails: []         # ⚠ denied array → [], never absent
+  sessions: []

…except on a manager assigned inside the reader's owned region subtree, where two fields come back:

 GET /api/managers            as a region manager, on a manager assigned inside their region
   id, name, createdAt, updatedAt, collection, sessions: []
+  email
+  contactDetails[]
-  everything else above, unchanged

Region widening

"Region managers should be able to see the email addresses of managers on sub-regions and events within their region. They need to be able to contact these users." (Ardnived, 2026-10-30)

The maintainer chose to widen this to the region. email and contactDetails now carry regionContactFieldAccess in place of selfOrAdminFieldAccess. It admits self and admins exactly as before. It also admits a manager reading another manager's row when that row is assigned inside the reader's owned subtree:

  • as the manager of an event that passes eventScopeWhere, the list form of isEventInScope (Part 2). This is the test atlas-manager event writes already use.
  • as one of the managers of a region in the subtree. The subtree includes its roots, so co-managers of one region read each other's. They already share that region's write scope over every event in it, and the decision's purpose, contacting one another, applies to them too.

It reaches downward only: a sub-region manager reads the region manager above them by name alone. Every other field stays exactly as before for everyone. That covers type, roles, notificationPreferences, language, the legacy row, the login plugin's columns, _verified, and the joins.

 regionContactFieldAccess({ doc, id, req })        src/collections/Managers/access.ts
   selfOrAdminFieldAccess                → allow   # unchanged
   not an active manager                 → deny    # no user, a client, inactive
+  no doc                                → deny    # where / sort / distinct / /api/access
+  row ∈ resolveContactableManagerIds    → allow   # src/plugins/access/regionSubtreeAccess.ts
   else                                  → deny
  • Cost. It is one set per reader per request, never one query per row. That is resolveOwnedRegionIds (memoized, and shared with every other access decision on req) plus one events query (select: { manager }) and one regions query (select: { managers }). It costs nothing more for admins or self, and nothing beyond the owned-region lookup for a reader who owns no region. A list of N managers costs the same as a list of one, and an int case spies payload.find to assert it.
  • No row in hand stays denied. Field access during where / sort / distinct validation and /api/access carries no doc, so the lock answers self-or-admin there. ?where[email][like], ?where[contactDetails.identifier][like], an or of them, events?where[manager.email][like], sort=email and distinct?field=email are all still refused for a region manager. This mirrors how fix(access): narrow activity-log contact addresses to the region that owns the event #1054's logField lock answers the same question.
  • Read paths checked:
    • REST list and single reads, select.
    • Population through Events.manager and Regions.managers. The answer depends on the manager, not on the path that carried them.
    • The admin document drawer (docAccessOperation).
    • UserSubmissions projections: these stay select: { name: true } under overrideAccess, so they show no email.
    • The list view's columns are decided without a doc, so they still show name alone. The email appears in the drawer.

Flow — a lock is attached at three different layers, because the fields arrive at three different times

 Managers.ts  declares fields                     src/collections/Managers/Managers.ts
+  lockManagerFieldReads([…])                     src/collections/Managers/access.ts
+    recurse tabs / row / collapsible             # containers that flatten away
+    leave ui, unnamed, MANAGER_PUBLIC_FIELDS     # = { name }, admin.useAsTitle
+    MANAGER_REGION_CONTACT_FIELDS → regionContactFieldAccess   # email, contactDetails
+    else access = { ...own, read: own.read ?? selfOrAdminFieldAccess }
+  email, _verified declared bare, TOP LEVEL      # mergeBaseFields needs a merge target
+    each restates its own i18n label             # sanitizeFields would shadow it
 loginPlugin folds, APPENDING three columns       src/plugins/login/
+  magicLinkIssuedAt, pendingInvitation, invitationDueAt carry their own read lock
 accessPlugin folds                               # collection + field access as before
 sanitizeCollection merges the auth base fields   # email, _verified land on our locks
   sessions arrives with Payload's own self-only read

Behaviour — selfOrAdminFieldAccess, and why it reads the row id twice

 selfOrAdminFieldAccess({ doc, id, req })         src/plugins/access/adminOnly.ts
   admin manager                     → allow
   not an active manager             → deny      # allowlist: a third auth collection arrives denied
-  String(user.id) === String(id)
+  isOwnRow(user.id, id ?? doc.id)
+    # afterRead passes id: doc.id
+    # getEntityPermissions passes NO id, only the fetched row as doc — and the
+    # admin renders nothing for a field it has no read permission on, so
+    # reading `id` alone emptied the holder's own Contact tab
   neither present (a create, /api/access) → deny

Behaviour — the strip hook, which the locks would otherwise have turned on

 stripLockedFieldsOnSelfRead(doc, req)            src/plugins/access/stripLockedFieldsOnSelfRead.ts
   req.user.collection !== collection.slug → return doc
+  not the caller's OWN row                → return doc
   for each field carrying a read lock
+    name not in doc                       → skip  # 18 locks vs a 2-column select
     re-evaluate the lock, delete on deny

Required with the locks, not optional. syncVerificationOnSave loads an event's manager with overrideAccess: true, req while a different manager saves the event, and managerCadence reads notificationPreferences off that row. Stripped, nextCheckAt fell back to DEFAULT_VERIFICATION_PERIOD_DAYS and moved from 30 days to 90, silently.

Joined — the copy a field lock never reaches

A field lock governs a read that checks access. These two projections resolve the assigned manager with overrideAccess: true on purpose, so the diff can name them instead of printing Manager: 496 — and previewEvent's own lock admits every manager.

 loadManager(req, managerId)                      src/collections/UserSubmissions/hooks/computeReviewFields.ts
   findByID managers, depth 0, overrideAccess: true
+    select: { name: true }                       # → { id, name, collection }
-  email, contactDetails[], notificationPreferences, legacyData, magicLinkIssuedAt …
 → resolveManager → mergeProposal({ manager })
     previewEvent    read: user.collection !== 'clients'   # i.e. every manager
     proposedChanges reads record.title ?? record.name     # the only consumer

Preview

Railway builds this PR at a host keyed on its number. A fresh preview carries one manager — its own provisioned admin — so these open as an admin, which is the "reads every field, as today" half.

Data: not seeded. previewUrl.seed is unset for this repo, and the narrowing itself needs a second manager plus an atlas-manager session, which a preview has no way to provision. tests/int/managers-access.int.spec.ts covers that half instead — including the admin-panel field permissions, through docAccessOperation.

Test results

Region widening, re-run with Part 2 merged in:

  • Lean gate (check.sh): ✓ lint, format, typecheck, typecheck:tests, unit lane (234 files / 2984 tests)
  • Targeted specs, one at a time: managers-access (30), event-verification (49), user-submissions-review-lifecycle (38)
  • New int cases cover a region manager reading:
    • an event manager in the subtree, a sub-region manager, and a co-manager: email and contactDetails visible, every other key absent;
    • a manager outside the region, and the region manager above (upward): name only.
    • They also cover an atlas-manager outside the region (name only), select of every locked field, depth-1 population, the drawer's permissions, the refused where / sort / distinct probes, and a one-events-query spy.
  • I watched all seven widening cases fail before the change. Then I mutation-checked the hidden ones:
    • widening the field set to more fields reddens 6 cases;
    • answering doc-less checks from the subtree reddens the probe case;
    • dropping the subtree filter reddens the outside and upward cases;
    • dropping the memo reddens the spy, with 12 events queries in place of 1.
  • The unit sweep now evaluates both readers against a seeded per-request set:
    • outside the region, nothing is readable;
    • inside the region, exactly ['contactDetails', 'email'], written out rather than read off the set;
    • with no row in hand, nothing is readable.

Original #908 run:

  • Lean gate: ✓ lint, format, typecheck, typecheck:tests, unit lane (234 files / 2964 tests)
  • Targeted specs: 243 passed — managers-access (19), event-verification (37), manager-magic-link, manager-passwordless, manager-invite, manager-signin-page (67), clients-access, role-based-access, atlas-manager, user-submissions-access (121)
  • For the joined fix: 113 passed — user-submissions-review-lifecycle (38), user-submissions-create (41), screen-submissions (20), atlas-submission-routing (14)
  • Build: N/A — Railway builds the preview
  • Every new assertion was reintroduced against the real defect, watched to fail, then restored. Two of them changed shape because of what that showed: see Detail.

Manual verification

  1. Sign in to the preview as an atlas-manager (not an admin), against a database holding a second manager.
  2. Open an event and the Manager picker — it still lists managers by name.
  3. Open /api/managers?limit=5 in the same browser — no email on any row but your own and those of managers assigned inside a region you manage; elsewhere contactDetails and sessions come back [].
  4. Open your own manager document — the Contact tab still renders your notification preferences and contact methods.
  5. Open a proposal with a manager assigned — the diff's Manager line still reads a name, and previewEvent carries { id, name, collection } for them.

Notes for reviewer

The ticket specified seven edits; this is those, plus one fix and one test the review passes found, plus the joined projection fix. Worth your eye:

  • The joined fix is the same exposure one collection away. previewEvent and proposedChanges resolve the assigned manager with overrideAccess: true, which skips every lock this PR adds, and previewEvent is readable by any manager — so an atlas-manager opening a proposal read the assigned manager's email, contact methods, notification preferences and verbatim legacy row. It joins by root cause rather than by size: a reviewer judging whether fix(access): atlas-managers read every manager's contact details #908 is closed needs both halves. The spec asserts the projected shape exactly, so a column added to Managers cannot ride along later. The rule it establishes in docs/rules/access.md is bounded in both directions: a row copied into a surface owes a select, and a row a gate interrogates must never get one — four managers reads here are correct because they are unselected, and narrowing any of them fails open.

  • _verified's label. Declaring a base auth field bare to carry a lock made sanitizeFields label it from the field name, and the merge lets ours win — so the list view showed a column headed _verified, in every locale. Both redeclarations now restate the i18n function. Clients.apiKey has the same shape and the same hazard.

  • Two sweeps, because neither sees the other's config. The unit sweep reads the config a plugin sees, which is the only place loginPlugin's appended columns exist; the integration sweep reads the booted one, where the auth base fields live. Both evaluate each lock rather than counting one: read: defaultAccess on the base _verified is a function and wide open, and so is read: () => true — the counting form passed both.

  • src/plugins/login/ now imports a manager-shaped predicate. Only managers is served there today; a second collection's holder would be denied their own value rather than shown somebody else's, which is fail-closed.

  • An atlas-manager's Managers list loses three of its four defaultColumns. Payload drops a column the caller cannot read (filterFieldsWithPermissions, fed permissions.collections.managers.fields), so the list shows name alone rather than three blank columns. No change needed.

  • ⚠ Open for your decision: an assignment the reader made counts. Events.manager and Regions.managers don't limit their picks, because the picker lists every manager by name, which is what the grant is for. So a region manager can do this: set anyone as an event's manager inside their subtree (a draft is enough), or add them to a region there. From the next request on, they read that person's email and contact methods, and they can revert the assignment afterwards. The only trace is the invitation queued to the person assigned. The adversarial review found this, and it is not closed here. Each way of closing it is a choice for you:

    It is recorded in docs/rules/access.md. On main today, every atlas-manager reads every manager's email, so this is a residual inside the widening, not a regression against main.

Dismissed, with reasons:

  • Move the locker into accessPlugin with a slug-keyed registry (it runs last, so it would reach the three appended columns by construction and delete three hand-locks). Not taken, and the premise is narrower than it looks: accessPlugin.ts:142 gates its field walk on isTranslatableCollection(slug), and managers is not one, so there is no existing walk to hook into — only a second field pass to add to the highest-blast-radius module in the repo, for one collection. email and _verified merge at sanitize, after every plugin, so two of the five locks stay in Managers.ts either way. The unit sweep is what holds the other three.
  • Push the lock into legacyMigrationFields() — the factory serves five collections, and a manager-shaped lock is wrong on events/regions, so it needs a per-collection argument. Same call.
  • A 'reference' permission level — read narrowed to admin.useAsTitle — would make this narrowing automatic for the next restricted collection a picker points at, and retire the raw-id cost docs/rules/access.md records for web-translator. Field locks are what it would be built from, so this PR is a prerequisite rather than a detour.
  • An existence oracle via ?where[email][equals]= — not real. validateSearchParams rejects a where on a field whose read permission is false (The following path cannot be queried), and the admin UI only offers filters on readable fields. Our own three where: { email } lookups all pass overrideAccess: true, so none is affected.
  • Promoting the plugin-fold helper to tests/utils/, a named constant for the three machine columns, and dropping the explicit id === undefined clause from the hook's guard — all low value; the last reads better spelled out in a security guard.
Detail

No migration. email and _verified already existed as merged base fields; declaring them changes no column. db:migrations:create --skip-empty wrote nothing, and generate:types left payload-types.ts unchanged — a lock strips the value at runtime, not the shape from the generated type. The joined fix changes no column either: select narrows a read.

Two assertions changed shape after watching them fail. The sanitized sweep first asked whether a field carried a read function, and passed with _verified undeclared, because Payload's base read: defaultAccess is a function. It now evaluates each lock as an atlas-manager reading someone else's row, and the unit sweep follows. The docAccessOperation case was added only once the doc.id fallback turned out to be what the admin panel depends on — getEntityPermissions calls populateFieldPermissions with no id at all.

A latent coupling, recorded in Managers/access.ts. Assigning access stands applyFieldAccessForTranslatableCollections down, because that pass acts only if (!field.access). Moot while no role grants translate on managers; the day one does, that pass would silently cover none of these fields.

createdAt / updatedAt are not in MANAGER_PUBLIC_FIELDS. Payload appends them outside fields, so the locker never reaches them; the integration sweep names them separately rather than pretending the allowlist governs them.

How the joined fix was found, and why it is not a follow-up ticket. The branch-level /security-review surfaced it while re-tracing #822. It is docs/rules/access.md's own "restricting a collection does not reach a copy of it" rule, one step further out than the two events fields that paragraph already names — so the rule gained the overrideAccess case rather than a new ticket gaining a sibling. proposedChanges reads only record.title ?? record.name, and manager is absent from Events/endpoints/responseTypes.ts, so the preview widget never read it: select: { name: true } loses nothing either consumer renders.

A third site in the same class is #1047, not this PR. Events.activityLog stores the email address or messaging handle each verification reminder went to, and logField's lock admits every manager — so an atlas-manager reads it off any atlas event. It is not joined because closing it needs a decision (which surface narrows) and the fix lands in a field factory two collections share, where this one is a select in one projection.

Rejected shapes, from the ticket. A single collection afterRead projecting the document down to the public fields would delete most of this — but a field read lock is also what the admin panel reads, so the locks hide those inputs where a projection hook would leave the picker's drawer rendering empty Email and Contact Methods boxes. hidden: true on the three machine columns would strip them from the holder and admins too, and the redeem route would then need showHiddenFields.

Region widening review: an adversarial pass by a fresh agent over git diff origin/claude/fix-1047-log-addresses...HEAD. It turned up:

  • the self-assignment gap above, which is left open for your decision;
  • a transaction comment on the loader that claimed too much, now corrected;
  • two probes that could not fail: the unit doc-less case now keeps the row id, and the sort probe now matches cannot be queried. Both were re-mutation-checked.

It found these sound: the doc-less denial on every path, population, the drawer, fail-closed for no user, clients, inactive managers and malformed ids, and the per-request memo. List-view columns staying name-only and the booleans-only POST /api/managers/access/:id answer were noted, not changed.

Review passes run: /simplify (4 agents: reuse, simplification, efficiency, altitude), /code-review high, /security-review — the last because the diff touches src/plugins/access/, src/collections/Managers/ and now src/collections/UserSubmissions/hooks/. It ran twice: once over the whole branch, reporting nothing at its confidence bar, having traced that #822 stays closed (refresh and me both reach applyUserReadAccess on the caller's own row), that ?where[email] is refused by validateSearchParams because the policy it reads is built with no data, and that type and roles keep update: adminOnlyFieldAccess in the sanitized config; then again over the joined fix alone, which cleared it and surfaced #1047. comment-lint.mjs: no banned comment added.

Closes #908

https://claude.ai/code/session_01Mg9rjXvF3BZLtY4djvmoQY


Part 2 — activity-log addresses (#1047)

Summary

  • An activity-log entry that records a contact address now shows that address only to a reader with business with the event: an admin, the address's owner, or a manager whose region subtree holds the event (or who manages it). Everyone else still sees that the reminder or delivery happened, to whom, and when.
  • Both logs that hold addresses opt in: Events.activityLog reminders (destination, cells.delivery) and user-submissions.activityLog deliveries (cells.sentTo).
  • Four paths that skip an afterRead projection are closed with it: where/sort filtering, write-back of a redacted log, duplicate, and previewEvent's override read.

The decision this implements, from the maintainer, Ardnived (2026-10-30), overriding the ticket's options A/B/C:

Region managers should be able to see the email addresses of managers on sub-regions and events within their region. They need to be able to contact these users.

Change outline

Contract — what a manager reads off a log entry

 GET /api/events/:id   as an atlas-manager outside the event's region subtree
   activityLog[]: { kind: 'reminder', at, stage, level, role, region, channel,
                    manager: { id, name },
                    cells: { activity, who } }
-                   destination: '[email protected]'
-                   cells.delivery: { label: 'email', text: '[email protected]' }
   activityLog[]: { kind: 'verification', …, cells: { delivery: 'Saved' } }   # untouched — a method, not an address

 GET /api/user-submissions/:id   as the same manager, a proposal from elsewhere
   activityLog[]: { type: 'delivery', at, ok, cells: { activity: 'Delivered' } }
-                   cells.sentTo: '[email protected]'

Deleted, not blanked, which is the projection a denied field lock makes. LogTable renders an empty cell, and the row's JSON drawer shows no address.

Behaviour — who sees an address

 regionScopedAddressVisibility(locate)                 src/plugins/access/logAddressVisibility.ts
   admin                                     → every address
   not an active manager                     → none          # allowlist: no user, inactive, a third auth collection
+  the entry is their own                    → that entry    # by the entry's manager.id; by email only where it names nobody
+  isEventInScope(ownedRegionIds, user, ev)  → every address # region ∈ owned subtree, or ev.manager == user
   else                                      → own entries only

 isEventInScope                                         src/plugins/access/regionSubtreeAccess.ts
+  extracted from scopeRegionSubtreeWrite's single-event branch — one predicate for
+  "may write this event" and "may read its contacts", over the existing resolveOwnedRegionIds

Where each document is placed:

  • An event: its own region/manager, loaded with select when the read omitted them (eventAddressScope).
  • A user-submission: the target event for an update proposal; the routing region for a new-event proposal, using submissionRoutingRegionId, the chain deliverProposal mails up (UserSubmissions/logAddressScope.ts).

Flow — the opt-in, per collection

 logField({ …, addresses?: { types, keys, visibility } })     src/fields/logField.ts
   no `addresses`                         → exactly as before; every log keeps today's default
+  afterRead     redact, unless overrideAccess === true        # the read the field lock also exempts
+  read lock     no row in hand (`doc` undefined) → admin only # a query, a distinct read, /api/access
+  beforeChange  restore any entry that is exactly a stored one minus its addresses
+  beforeDuplicate → []

 Events.activityLog           types: ['reminder'], keys: ['destination', 'cells.delivery']
 user-submissions.activityLog types: ['delivery'], keys: ['cells.sentTo']

Joined — the copy an override read carried

 loadTargetEvent(req, id)                               src/collections/UserSubmissions/hooks/computeReviewFields.ts
   findByID events, overrideAccess: true
+    select: { activityLog: false }
 → previewEvent   # read by every manager, so the target event's whole log rode along

Preview

Railway builds this PR at a host keyed on its number. A fresh preview carries one admin and no events, so it shows the "admin sees everything" half only.

  • The preview's Events list (/admin/collections/events) is unchanged for an admin.

Data: not seeded. The narrowing needs an event with reminder entries in two regions, plus an atlas-manager session in each; a preview has no way to provision either. The integration specs cover that half instead.

Test results

  • Lean gate: ✓ lint, format, typecheck, typecheck:tests, unit lane (233 files / 2973 tests)
  • Targeted specs, 116 passed:
    • event-verification (48, 12 new)
    • user-submissions-access (19, 11 new)
    • managers-access (12)
    • user-submissions-review-lifecycle (37)
  • Unit: log-field (15, 6 new)
  • Build: N/A. Railway builds the preview.
  • Every new case was run against the unfixed code. With src/ reverted, 5 event cases and 4 submission cases fail: the outsider reads (full, select-narrowed, REST, depth-1 populated), the own-address-only case, the previewEvent copy, and the filter refusal. The visible-to cases cannot fail against old code, so each was mutation-checked against the fix instead:
    • scope branch disabled → the region-manager and event-manager cases fail;
    • restore hook disabled → both write-back cases fail;
    • doc-less lock and duplicate hook disabled → the filter and duplicate cases fail.

Manual verification

  1. On a database with two regions, sign in as an atlas-manager who manages neither region of a reminded event.
  2. Open that event's Verification tab: every row still shows Event and Who, and Delivery is empty on reminder rows only. Click a row: the JSON has channel and no destination.
  3. Sign in as the manager of the event's country. The same tab shows every address.
  4. As the outsider, open /api/events?where[activityLog.destination][like]=a. It answers 400, The following path cannot be queried.
  5. As the outsider, reject a proposal from another region. Then, as an admin, the proposal's delivery entry still shows Sent to.

Notes for reviewer

Event's own manager → sees the escalated region managers' addresses. I went this way because the reminder escalates about their event to those region managers. "They need to be able to contact these users" reads in both directions on that chain, and region managers already receive the event manager's contact card in the escalation email. It also makes visibility exactly isEventInScope, the predicate that already decides who may write the event. One test of "has business with this event" now serves both. The alternative (event manager sees only their own address) would need a second, narrower predicate that nothing else uses.

This overrides #1047's criterion "user-submissions.activityLog renders exactly as it does today." The ticket read that log as carrying no contact detail, citing the review entries, which store a managerId only. DeliverSubmissions also writes cells.sentTo, and on a proposal that is the address the review mail went to — so that log narrows too, and an outsider's Sent to cell on a proposal is now empty.

This closes the exposure only together with #1045. On main today, every narrowed entry still carries manager.id, and an atlas-manager can read GET /api/managers/<id> for that row's email and contactDetails (#908). #1045 closes that. The two branches merge cleanly (git merge-tree against claude/fix-908-manager-field-locks): this PR adds no code to stripLockedFieldsOnSelfRead or adminOnly.ts, and its docs edits sit outside #1045's hunks. Once both land, a region manager reads a sub-region manager's address in the log but not off their managers row. That is the maintainer's rule applied to the log only. Widening managers to match is a separate decision.

where on the JSON column: a manager could filter by its contents. Before this, as an outsider, where[activityLog.destination][equals] and [like] both matched. like is a substring match, so an address could be read out a prefix at a time. The whole-column [activityLog][like] hit a raw SQL error instead.

The fix lives in the lock, not in a hook. Payload builds the field policies for query validation with no document (getEntityPermissions, fetchData: false), so a narrowed log answers that question for admins only. Payload's own validator then refuses every path shape, including the three the adversarial review found my first beforeOperation guard missed:

  • an uppercase OR/AND;
  • a path through a join (regions.events, managers.managedEvents, users.submissions);
  • a relationship hop (user-submissions?where[event.activityLog…]).

sort and findDistinct are refused the same way. Every read of a row passes doc; the admin edit view's docAccessOperation passes the fetched row. A case pins that the Verification tab still renders for a non-admin.

The write-back was a real data-loss bug, not a hypothetical. An outsider can update proposals (managerSubmissionScope covers every proposal). The admin form posts back the redacted log it rendered, and applyReview appends to the redacted doc its own update's afterRead left. Either path erased sentTo from storage. restoreLogAddresses puts back only an entry that is exactly a stored entry minus its addresses, so a writer gets nothing that was not already stored. Events have no equivalent exposure: their updaters are exactly the readers isEventInScope admits. The hook covers them anyway.

Adversarial review (fresh subagent, handed the diff only). Its findings, and how each was handled:

  • Fixed:
    • Query-guard bypasses (uppercase OR/AND, joins, relationship hops). Replaced the guard with the doc-less lock above.
    • duplicate copying the source's whole log into a draft the caller re-homes to their own region. Added beforeDuplicate: [() => []]. The case uses an unmanaged event, which syncVerificationOnSave leaves alone, so only the hook empties it.
    • Verification entries' cells.delivery ('Saved', 'Email link') were being stripped. Added types, so only reminder and delivery entries narrow.
    • Own-address by handle let a manager add a guessed handle to their own contactDetails and confirm whose it was. "Own" now uses the entry's manager.id, and email only where an entry names nobody.
    • N+1 event loads on a submissions list (now memoized per request), and trash: true on the routing load.
    • A dead data.parent versions branch: Payload hands the hook the version snapshot itself. Removed.
    • The tests that could not fail: covered by the mutation runs above. The API-client submission case now says plainly that it guards the collection restriction, not the narrowing.
  • Kept, with reasons:
    • resolveOwnedRegionIds(req) joining a write's transaction inside afterRead. The same memoized call already runs inside every atlas-manager write's access check, and it only reads. The two gate loads that are new here take no req.
    • Versions decide from the snapshot's own region/manager. readVersions is already update-scoped, so this cannot leak. A select-narrowed version read falls back to own-only.
    • A subscribe delivery's sentTo is '<provider> list <id>' — a mailing list, not a person — and types does not reach it, since DeliverSubmissions logs every intake's outcome as the one delivery type. No carve-out, because managerSubmissionScope gives no non-admin a subscribe or registration row at all (accessConfigs.ts:92, pinned at user-submissions-access.int.spec.ts:211), and an admin sees every address. Widening that scope would need one here.
  • Not fixed (low):
    • A transport error message that names the recipient lands in cells.activity of a failed delivery.
    • Reminder entries written before this PR for a manager with an empty name stored the address as the name. Names are required, and ExpireEvents no longer falls back to the address.
Detail

Every read path checked:

  • REST and local find/findByID, as each reader
  • select[activityLog]=true: no region/manager on the row, so the decision loads them with a two-column select
  • depth population and joins: the field hook runs per populated document with the reader's access
  • versions, as above
  • the admin edit view, which uses getDocumentData with overrideAccess: false, and its field permissions
  • LogTable and VerificationStageField, which read form state only
  • previewEvent/proposedChanges, now selecting the log out
  • where/sort/joins/relationship hops/findDistinct, all refused
  • bulk update by where, refused
  • duplicate, emptied
  • dashboards, the Atlas sidebar, ImportResultsField, SEO/sitemap and geojson: all select without activityLog, or are client-only
  • the verify page: a server component that never sends the log
  • GraphQL is disabled, and REST /distinct is not routed in Payload 3.90.2

Jobs keep the address. ExpireEvents, DeliverSubmissions, ScreenSubmissions and SendSessionReminders read at the local API's default overrideAccess: true, where the hook stands down. The update operation reads originalDoc the same way, which is what the restore compares against.

No migration, no type change. custom, hooks and access change no column; payload-types.ts is unchanged.

Review passes run: the adversarial subagent above, over the whole diff. /simplify, /code-review and /security-review were not run separately.

Closes #1047

🤖 Generated with Claude Code

… admin

#821 gave `atlas-manager` a collection-wide `managers: read` so the
`Events.manager` and `Regions.managers` pickers could list other managers.
Nothing narrowed it, so every atlas-manager read every manager's whole
record — contact details, notification preferences, the verbatim legacy
import row, and the sign-in/invitation machine columns.

`lockManagerFieldReads` gives every named field on the collection a `read`
lock bar `name`, which is all a picker renders. It merges rather than
replaces, so `sessions` keeps Payload's own self-only rule, and it recurses
into the containers that flatten away — `legacyMigrationFields()` is a
top-level `collapsible` carrying `legacyData`.

`email` and `_verified` are now declared at the top level so
`mergeBaseFields` has something to merge the lock onto. The three columns
`loginPlugin` appends after the locker runs carry their own lock.

`selfOrAdminFieldAccess` resolves the row from `id` and then `doc.id`:
`getEntityPermissions` calls `populateFieldPermissions` with no `id`, only
the fetched row, so reading `id` alone would hide every locked input on a
manager's own edit view.

`stripLockedFieldsOnSelfRead` now stands down off the caller's own row.
It re-ran the locks on any row of the collection, which would strip
`notificationPreferences` from the manager `syncVerificationOnSave` loads
with `overrideAccess: true` while a different manager saves the event —
moving `nextCheckAt` from 30 days to 90, silently.

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

A unit sweep enumerates the folded collection with Payload's own
`flattenAllFields` and fails on any field outside `MANAGER_PUBLIC_FIELDS`
with no `read` lock — so a column added to `Managers`, or injected into it
by `loginPlugin`, cannot arrive readable unnoticed. Its own cases cover
`selfOrAdminFieldAccess`, including the `doc.id` spelling the admin
panel's permissions check hands it.

`managers-access.int.spec.ts` reads an atlas-manager's answer back through
`overrideAccess: false`: another manager's row carries the title and the
timestamps and nothing else, the machine columns stay gone when asked for
by name, and an admin still reads every field — which is also what proves
the fixture is not simply empty.

`event-verification.int.spec.ts` covers the cadence the strip hook used to
take: a colleague's save keeps the event manager's 30-day window rather
than the 90-day fallback. `access-self-read-field-locks.spec.ts` gains the
two stand-down cases.

Each assertion was watched to fail against the real defect and restored.
PERF.md's pinned unit-lane counts follow the new spec.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXvF3BZLtY4djvmoQY
The acceptance criterion that a manager's own Contact tab still renders
turns on `docAccessOperation`'s field permissions, not on the read path:
`getEntityPermissions` calls `populateFieldPermissions` with no `id`, only
the fetched row. This case reads those permissions directly, so the
`doc.id` fallback in `selfOrAdminFieldAccess` is pinned where the panel
decides rather than left to a manual check.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXvF3BZLtY4djvmoQY
…s my row"

Per the /simplify and reuse passes:

`readLockOf` is now exported and is what both the hook and the unit sweep ask.
The sweep asserted against a re-typed copy of the same test, so a lock in a
shape only one of them recognised would have passed the sweep and still
leaked.

`isOwnRow` holds the id coercion once. This branch had added two copies of it,
and the rule it encodes — coerce both sides, an unidentifiable row is never
your own — is the part worth reviewing once rather than twice.

Also: the strip hook skips a field the read never selected, since `managers`
now carries 18 locks against reads that select two columns; `WithAccess` and
its cast are gone, because the union is already narrowed where it was used;
and the locker's docblock no longer credits the merge with keeping
`sessions` self-only — Payload merges that field in at sanitize, after the
locker has run, so it survives by never being reached.

Corrected two claims rather than only shortening them, and recorded the
latent coupling with `applyFieldAccessForTranslatableCollections`, whose
`!field.access` guard these locks would stand down if `managers` ever took a
`translate` grant.

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

`sanitizeFields` fills a label in from the field name before
`mergeBaseFields` runs, and the merge lets ours win — so declaring
`_verified` bare to carry a read lock put a column headed `_verified` in the
Managers list view, in every locale, and hardcoded `email`'s label to
English. Each now restates the i18n function it was shadowing.

The sanitized sweep that would have caught it goes in the integration lane,
where the config is the booted one: the unit sweep reads the config a plugin
sees, which is the only place `loginPlugin`'s appended columns exist and
never holds the auth columns Payload merges in at sanitize.

That sweep EVALUATES each lock rather than counting it. "Carries a read
function" is not the property: the base `_verified` ships
`read: defaultAccess`, which is `Boolean(user)` — a function, and wide open —
so the first version of this sweep passed with the field readable by every
atlas-manager.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXvF3BZLtY4djvmoQY
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1045 October 28, 2026 16:22 Destroyed
@railway-app

railway-app Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

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

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

@sydevs-bot

sydevs-bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 19:21Z resolve-conflicts · attempt 1 · session · done
  • 19:21Z resolve-conflicts · attempt 1 · session
  • 23:24Z resolve-conflicts · attempt 1 · session · done
  • 23:24Z resolve-conflicts · attempt 1 · session
  • 21:46Z resolve-conflicts · attempt 1 · session · done

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

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 28, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Oct 28, 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 #908's seven edits and nothing else, and the behaviour reads right: the locks narrow what the picker's grant hands over, the strip hook's own-row stand-down is required rather than tidy-up, and the integration sweep evaluates each lock instead of counting it.

The shape is the question. Five locked fields sit outside the locker this diff builds — three hand-locked in src/plugins/login/, two redeclared bare in Managers.ts. accessPlugin is last for exactly that reason and already walks every collection's fields keyed by slug, so those three are avoidable by construction. The body sends that to a follow-up; it reads like this PR's own work.

One thing to look at: an atlas-manager opening the Managers list now has three of four defaultColumns unreadable (Managers.ts:45). Whether Payload drops such a column or renders it blank is unchecked here.

Findings

  • should-fix — the locker belongs in accessPlugin: src/collections/Managers/access.ts:50
  • should-fix — the unit sweep counts a read function instead of evaluating it, so an open lock passes: tests/unit/manager-field-locks.spec.ts:70
  • consider — isOwnRow re-exported with no consumer: src/plugins/access/index.ts:45

What was checked

  • Read whole: every touched module under src/plugins/{access,login}/ and src/collections/Managers/, plus accessPlugin.ts, fieldAccess.ts, all three specs.
  • Plugin order: loginPlugin, then accessPlugin last (payload.config.ts:369,373).
  • general:email and authentication:verified both resolve in @payloadcms/[email protected], so the label fix holds.
  • managers is absent from TRANSLATABLE_COLLECTIONS (roles.ts:61), so that coupling stays latent.
  • An inactive manager never holds a session (isEligible), so isManager denying their own row costs nothing.

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


Generated by Claude Code

Comment thread src/collections/Managers/access.ts Resolved
Comment thread tests/unit/manager-field-locks.spec.ts Resolved
Comment thread src/plugins/access/index.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 Oct 28, 2026
Both callers reach it through `./adminOnly`; nothing imports it from the
barrel. The barrel is also the import no client module may take
(`src/AGENTS.md`), so a re-export there is a path nobody should use.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXrQ7SFJMZaA6D8fJp
"Carries a read function" is not the property the sweep claims to hold:
`read: () => true` is one, so a field could arrive readable and still pass.
It now evaluates each lock as a non-admin manager reading another row, the
same question the sanitized sweep asks. Watched to fail against a field
declared `read: () => true`, which the counting form passed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXrQ7SFJMZaA6D8fJp
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1045 October 28, 2026 17:09 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Three critic threads settled. Pushed d9a5923.

Your open question on defaultColumns: Payload drops a column the caller cannot read (filterFieldsWithPermissions), so an atlas-manager's Managers list shows name alone, not three blank columns.

Lean gate ✓ 234 files / 2964 tests · managers-access 19 ✓ · /security-review nothing at its bar · comment-lint clean.

Routed elsewhere: UserSubmissions.previewEvent stores the whole assigned manager row, which atlas-manager reads — #908's exposure one collection over.

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


Generated by Claude Code

…ections

`previewEvent` and `proposedChanges` resolve the assigned manager with
`overrideAccess: true`, so every field lock #908 adds to `managers` is
skipped — and `previewEvent`'s own lock admits any manager. An
`atlas-manager` opening a proposal therefore read the assigned manager's
email, contact methods, notification preferences and verbatim legacy import
row: the exposure this branch closes, reached through a copy rather than a
relationship.

`proposedChanges` renders `record.title ?? record.name`, and `manager` is
absent from the published Events response types, so the preview widget never
read it either. `select: { name: true }` loses nothing a consumer renders.

The spec asserts the projected shape exactly rather than naming the columns
to miss, so a column added to `Managers` cannot ride along later. Watched to
fail with the `select` removed: email, contactDetails and
notificationPreferences all came back.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXrQ7SFJMZaA6D8fJp
The rule the previous commit added reads as "select everywhere", and four
`managers` reads are correct because they are unselected: two refuse a
deactivated manager on `type`, two read `notificationPreferences`. Narrowing
any of them fails open.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXrQ7SFJMZaA6D8fJp
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Joined to this PR, pushed 986f7c3.

  • UserSubmissions.previewEvent carried the whole assigned manager row past every lock this PR adds: overrideAccess: true skips field access, and that field's own lock admits any manager. 8ed9474 selects name alone, and the spec pins the projected shape exactly. Watched to fail with the select removed.
  • 986f7c3 bounds the new docs/rules/access.md rule in the other direction: four managers reads are correct because they are unselected (two refuse a deactivated manager on type, two read notificationPreferences), so narrowing one fails open.
  • fix(access): an event's activity log leaks a manager's contact details #1047 is a third site: Events.activityLog stores the address each reminder went to, and logField's lock admits every manager. Filed rather than joined — it needs a decision on which surface narrows, in a factory two collections share.

Lean gate ✓ 234 / 2964 · submissions lane 113 ✓ · /security-review on the delta clear, and it found #1047 · comment-lint clean. 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 Oct 28, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Oct 28, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 28, 2026 17:52
@sydevs-bot
sydevs-bot requested a review from Ardnived October 28, 2026 17:52
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 3, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 3, 2026
Conflicts were the unit lane's pinned file and test counts, in
docs/rules/testing-reqs.md, tests/AGENTS.md and tests/PERF.md. Both sides
grew the lane, so neither count described the merged tree. Measured it
instead: 236 files, 3057 tests. AGENTS.md carried a stale 235 that did not
conflict, which perf-figures-pinned.spec.ts would have failed on.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW5XqXE3nTge4zUMgD
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1045 November 3, 2026 21:57 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged origin/main in. Three conflicts, all one figure: the unit lane's pinned file and test counts, in docs/rules/testing-reqs.md, tests/AGENTS.md and tests/PERF.md.

Neither side was right to keep. Both branches added specs, so this branch's 235 / 3009 and main's 235 / 3036 both describe a tree that no longer exists. I measured the merged lane instead and wrote 236 / 3057 to all three.

AGENTS.md also carried a stale 235 files that did not conflict. tests/unit/perf-figures-pinned.spec.ts checks every consumer against PERF.md, so leaving it would have failed the lane.

No code hunks conflicted. Nothing here is a judgement call for you.

  • Lean gate: ✓ lint, format, typecheck, typecheck:tests, unit lane (236 files / 3057 tests)
  • managers-access int spec: 30 passed

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

Events.ts: both sides added an import to the same block — this branch's
eventAddressScope and main's isAdminManager. Both are used, so both stay.

The other three were the unit lane's pinned counts again, in
docs/rules/testing-reqs.md, tests/AGENTS.md and tests/PERF.md. Both sides
grew the lane, so neither count described the merged tree. Measured it:
237 files, 3071 tests. testing-reqs.md states the pair twice and only one
site conflicted, and AGENTS.md's file count did not conflict at all —
perf-figures-pinned.spec.ts reads all three, so all three are updated.

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

Copy link
Copy Markdown
Contributor Author

Merged main in.

Events.ts was two imports landing in one block — eventAddressScope here, isAdminManager from #1073. Both are used, so both stay.

The three doc conflicts were the unit lane's pinned counts. Both sides grew the lane, so neither number described the merged tree; measured, it is 237 files / 3071 tests. Two sites needed the same edit without conflicting: docs/rules/testing-reqs.md states the pair twice, and AGENTS.md's file count sat on main's side alone. perf-figures-pinned.spec.ts reads every consumer, so all four are updated together.

Gate green — lint, format, typecheck, typecheck:tests, unit lane 237/3071. event-verification and events int specs: 61 passed.

🤖 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 4, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 4, 2026
@Ardnived
Ardnived force-pushed the claude/fix-908-manager-field-locks branch from 339f283 to b0fe2a4 Compare November 5, 2026 04:39
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1045 November 5, 2026 04:39 Destroyed
@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 moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 5, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

#1074 narrowed managerSubmissionScope: it no longer covers every proposal, so Part 2's outsider (a region manager listed elsewhere) gets NotFound on a proposal from another region. Six user-submissions-access log-address cases fail there, both write-back cases included — their premise was that an outsider can update any proposal.

The rest is resolved and green: regionSubtreeAccess keeps main's re-home guard and answers from this branch's isEventInScope. managers-access (32) and event-verification (50) pass. Nothing is pushed.

  • 1. What should Part 2 assert now the row scope hides the outsider?
    • A — Re-aim at the reachable gap (recommended): a reader whose subtree holds the proposal's routingRegion but not the target event's region. The scope admits them; the address lock denies them. Read, not run.
    • B — Drop the six cases: record that managerSubmissionScope now covers submissions, and assert the narrowing on events alone.

🤖 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 5, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 5, 2026
@Ardnived

Copy link
Copy Markdown
Contributor

Superseded by #1105, which keeps this PR's Part 1 (the self-or-admin field locks) and replaces the region widening and the activity-log address projection with one gated contacts table on Regions and Events, plus a region-scoped read on Events.activityLog.

@Ardnived Ardnived closed this Nov 10, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 10, 2026
Ardnived added a commit that referenced this pull request Nov 11, 2026
…#1047) (#1105)

* fix(access): lock every Managers field read to the row's holder or an admin

Ports the first half of #1045 (commits 1f5c3fb..4e71879) onto main, without
its region widening or its activity-log address projection.

`atlas-region-manager` holds a collection-wide `managers: read` so the
`Events.manager` and `Regions.managers` pickers can list other managers
(#821). Nothing narrowed it, so every region manager read every manager's
email, contact methods, notification preferences and imported legacy row.

- `lockManagerFieldReads` gives every field but `name` a self-or-admin `read`
  lock. `email` and `_verified` are redeclared at the top level so the lock
  has a base field to merge onto, keeping Payload's i18n labels.
- `loginPlugin`'s three machine columns carry the same lock.
- `stripLockedFieldsOnSelfRead` stands down off the caller's own row, so an
  internal `overrideAccess` read of a colleague keeps its fields.
- `UserSubmissions.previewEvent` selects only the assigned manager's name.

Refs #908

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

* feat(managers): record when a manager last signed in

Nothing recorded it: `sessions` loses its row on sign-out and prunes expired
ones, and `updatedAt` moves on every write, the digest job's included. The
manager contacts table needs it to tell an active colleague from one who
never accepted.

- `loginPlugin` appends `lastLoginAt`, read-only and `update: () => false`,
  with its own self-or-admin read lock like the other appended columns.
- `createSession`, the one place a session is minted, stamps it in the same
  write as the session row.
- The migration adds the column and fills it from `legacyData.lastLoginAt`,
  which the Atlas import kept for 448 of 516 managers. A hand edit, asked for
  on this PR, on the #1087 precedent: a projection of the same row.
- The Atlas import maps it from now on, keeping the later of the stored and
  the legacy date, so an `--update` never rewinds a real sign-in.

Refs #908

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

* feat(atlas): show a region's and an event's managers to the managers above

With every field but `name` locked on another manager's row, a region
manager had no way to reach the people their region names. The details come
back the way an event's registrants do: through a surface that checks its own
gate and then reads past the locks, rather than a field lock widened per
reader.

- `mayReadManagerContacts` is the gate: an admin, the event's own manager, or
  an active manager whose owned subtree holds the region. That is a region's
  co-managers and the managers of every region above it, downward only.
- `managerContactsField` puts one shared table under `Regions.managers` and
  `Events.manager`: Payload's condensed `Table` with the name, a `mailto:`
  email and the last sign-in. It reads the stored row by id, never the form
  data, and for an event the published row.
- `Events.activityLog` reads behind the same gate (`eventContactsFieldAccess`,
  through a new `read` option on `logField`), since its reminder entries
  record where each one went. With no row in hand it answers for admins only.
- `previewEvent` loads its target without the log: a proposal reaches the
  managers of the region it proposes, who need not be the event's.
- Region-manager reminders already carry the event manager's email. A case
  now pins it against the new locks.

Refs #908, #1047

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

* fix(seeds): keep firstDomain's doc block on firstDomain

`laterDate` landed between the block and the function it documents, so a
reader got the legacy-domain explanation above a date comparison.

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

* fix(admin): declare the contacts row type beside its loader

`import type` is erased, so the client table taking the row type from
`data.ts` pulls no server module into the browser bundle — the shape
`EventRegistrations` already has, where `RegistrationRow` is declared in its
own `data.ts`.

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

* refactor(atlas): render the manager contacts table under the field description

The table is now the `Description` of `Regions.managers` and `Events.manager`
rather than a `ui` field of its own: it renders the field's own description,
then the table, as `PermissionsTable` sits under `Managers.roles`. Both fields
also declare an empty `afterInput`, because Payload otherwise renders a
`Description` once and keeps it through a save, and the table would go on
listing the managers the page loaded with.

The last sign-in is one line, `2026/11/10 - 3 weeks ago`, in three states:
normal, red past six months, and a muted "Never".

Refs #908

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

* fix(admin): spell the contacts table's sign-in day with formatShortDate

The table's own helper gave `2026/11/10`, under a reason — one unambiguous
spelling in every locale — that the module's existing `formatShortDate` already
satisfies. It also spells a UTC day, returns `''` for an unparseable value, and
is what the Registrations table beside this one shows a date with, so both
tables now read the same.

The spec spells the expected day out rather than calling the formatter, so the
day the table shows stays pinned against it.

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

* fix(admin): take the contacts component's props from Payload's own types

`path` arrives through `renderField`'s `clientProps`, which Payload types as
`FieldPaths`, so `Pick<FieldPaths, 'path'>` says what `{ path?: string }` was
restating — and it is always set, so the `''` fallback is gone with it.

`admin.description` needed no structural cast either, only a narrower field
type: `ServerComponentProps['field']` is the whole `Field` union, whose `row`
and `tabs` members omit `description`, while both registrations are on a
relationship picker.

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

* fix(admin): put the contacts table in Payload's afterInput slot

`RelationshipInput` renders `AfterInput` and then the `Description` slot, so
the table reaches the same place from the slot Payload already provides for it
— and a `beforeInput`/`afterInput` key is what `renderField` tests to re-render
a field's components on every form-state request, so the save-follows behaviour
now comes from the registration itself rather than from an empty array beside a
`Description` override.

That override existed only to put the table below the description. Paying for
it were four pieces: re-rendering `FieldDescription` by hand, the `path` prop
it needs, the `RelationshipField` narrowing for `admin.description`, and the
empty-array trap with a ⚠ on each field and in the component. The table now
sits above the description instead.

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

* docs(access): cut what the field-lock JSDoc already carries

Three ⚠ blocks restated, near-verbatim, the JSDoc on `selfOrAdminFieldAccess`
and `stripLockedFieldsOnSelfRead` — and this file loads whenever either is
edited, so every reader paid for both copies.

Each keeps its rule, its #NNN breadcrumb and the one line a reader cannot
re-derive, and hands the mechanism back to the JSDoc beside the code that
implements it.

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

* fix(admin): drop the contacts table's unreachable name fallback

`Managers.name` is `required: true`, so `name || email` never took its second
arm — and had it ever fired, the Name column would have printed an email.

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

* chore(migrations): snapshot resync after the seventh main merge

main's 20261110_234836_clients_label_title snapshot was generated on main,
so it knows nothing of the last_login_at column this branch adds — and its
timestamp is the higher of the two. migrate:create diffed against it and
re-emitted ALTER TABLE "managers" ADD COLUMN "last_login_at", which
20261110_220603_manager_last_login already ships. Replaying one statement
aborts the boot migration (#566).

So the generated file keeps only its .json snapshot, taken on the merged
tree, which carries both sides and heals the chain. A probe run afterwards
writes no files.

CI cannot see any of this: push: !isProduction syncs the schema with Drizzle
push and never replays the chain. Only a Railway boot does.

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

* fix(clients): read the audit's service name from label, not name

#1108 split the clients `name` field into `label` and `title`, and #1106
landed afterwards still reading `name`. Each was green on its own branch,
so main carries a tsc failure neither PR could see: `name` is not a key of
Client.

The audit is operator-facing, so it takes `label`, the internal name, not
`title`, which is the name registrants see.

This is main's break, not this branch's, and it reddens this PR's gate and
CI all the same.

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

* refactor(access): trim the manager contact locks to what they need

The new comments were 44% of the PR's added source; cut to the why, keeping
every warning. The unit sweep over the Managers field locks repeated the
integration sweep, which reads the booted config and so already sees the
login plugin's columns and the base auth fields: the integration spec now
carries the non-vacuity check, and the unit spec keeps the
`selfOrAdminFieldAccess` cases. `stripLockedFieldsOnSelfRead` drops its
unselected-field skip, a shortcut that saved nothing once the hook ran on
the caller's own row alone. `MANAGER_PUBLIC_FIELDS` is no longer exported.

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

* fix(admin): put the contacts table back under the field description

f0f14eb moved the table into `afterInput`, which `Relationship/Input`
renders above the description. Under the description is where the owner
asked for it, as `roles` sits on Managers, so both fields register the
component as their `Description` again, with the empty `afterInput` that
re-renders it after a save. The component's docblock now says why the slot
is `Description`, so the next review can see the placement was chosen.

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

---------

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

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1045 — b0fe2a48 Deployed Nov 5, 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.

fix(access): an event's activity log leaks a manager's contact details fix(access): atlas-managers read every manager's contact details

3 participants