Repository navigation
fix(access): narrow managers' contact details to the reader's region - #1045
sydevs-bot wants to merge 21 commits into
Conversation
… 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
|
🚅 Deployed to the SahajCloud-pr-1045 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 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
readfunction instead of evaluating it, so an open lock passes:tests/unit/manager-field-locks.spec.ts:70 - consider —
isOwnRowre-exported with no consumer:src/plugins/access/index.ts:45
What was checked
- Read whole: every touched module under
src/plugins/{access,login}/andsrc/collections/Managers/, plusaccessPlugin.ts,fieldAccess.ts, all three specs. - Plugin order:
loginPlugin, thenaccessPluginlast (payload.config.ts:369,373). general:emailandauthentication:verifiedboth resolve in@payloadcms/[email protected], so the label fix holds.managersis absent fromTRANSLATABLE_COLLECTIONS(roles.ts:61), so that coupling stays latent.- An inactive manager never holds a session (
isEligible), soisManagerdenying their own row costs nothing.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
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
|
Three critic threads settled. Pushed
Your open question on Lean gate ✓ 234 files / 2964 tests · Routed elsewhere: 🤖 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
|
Joined to this PR, pushed
Lean gate ✓ 234 / 2964 · submissions lane 113 ✓ · 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
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
|
Merged Neither side was right to keep. Both branches added specs, so this branch's 235 / 3009 and
No code hunks conflicted. Nothing here is a judgement call for you.
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
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
|
Merged
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: Gate green — lint, format, typecheck, typecheck:tests, unit lane 237/3071. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
339f283 to
b0fe2a4
Compare
|
#1074 narrowed The rest is resolved and green:
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
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 |
…#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]>
Closes #908. Closes #1047. Folds in #1054, by the maintainer's decision to ship both as one PR.
Summary
Before launch, any
atlas-managercould read every other manager's email and phone or messaging handles in two places. This PR narrows both to the same rule:managerscollection (fix(access): atlas-managers read every manager's contact details #908): another manager's row showsnameonly.emailandcontactDetailsalso 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.Events.activityLoganduser-submissions.activityLogshow 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.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 thanmain, where every atlas-manager reads every manager.Part 1 — the
managerscollection (#908)Summary
managersnow carries areadlock, so anatlas-managerreading another manager getsname. The exception is a manager assigned inside the reader's own region, whereemailandcontactDetailscome back as well (see "Region widening" below).stripLockedFieldsOnSelfReadstands down off the caller's own row — without that, the locks would have silently halved every event's re-verification window.UserSubmissions.previewEventcarried a colleague's whole manager row past those locks, through a copy rather than a relationship.Change outline
Contract — what an
atlas-managerreads off another manageratlas-managerholds a collection-widemanagers: readbecause a picker exists to list other managers, so theWherecannot be self-scoped (#821). The narrowing is field by field instead.…except on a manager assigned inside the reader's owned region subtree, where two fields come back:
Region widening
The maintainer chose to widen this to the region.
emailandcontactDetailsnow carryregionContactFieldAccessin place ofselfOrAdminFieldAccess. 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:managerof an event that passeseventScopeWhere, the list form ofisEventInScope(Part 2). This is the test atlas-manager event writes already use.managersof 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 → denyresolveOwnedRegionIds(memoized, and shared with every other access decision onreq) plus oneeventsquery (select: { manager }) and oneregionsquery (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 spiespayload.findto assert it.where/sort/distinctvalidation and/api/accesscarries nodoc, so the lock answers self-or-admin there.?where[email][like],?where[contactDetails.identifier][like], anorof them,events?where[manager.email][like],sort=emailanddistinct?field=emailare 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'slogFieldlock answers the same question.select.Events.managerandRegions.managers. The answer depends on the manager, not on the path that carried them.docAccessOperation).UserSubmissionsprojections: these stayselect: { name: true }underoverrideAccess, so they show no email.namealone. The email appears in the drawer.Flow — a lock is attached at three different layers, because the fields arrive at three different times
Behaviour —
selfOrAdminFieldAccess, and why it reads the row id twiceselfOrAdminFieldAccess({ 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) → denyBehaviour — the strip hook, which the locks would otherwise have turned on
Required with the locks, not optional.
syncVerificationOnSaveloads an event's manager withoverrideAccess: true, reqwhile a different manager saves the event, andmanagerCadencereadsnotificationPreferencesoff that row. Stripped,nextCheckAtfell back toDEFAULT_VERIFICATION_PERIOD_DAYSand 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: trueon purpose, so the diff can name them instead of printingManager: 496— andpreviewEvent's own lock admits every manager.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.
Verifiedcolumn header, not_verifiedGET /api/managers— every field, since the caller is an adminData: not seeded.
previewUrl.seedis unset for this repo, and the narrowing itself needs a second manager plus anatlas-managersession, which a preview has no way to provision.tests/int/managers-access.int.spec.tscovers that half instead — including the admin-panel field permissions, throughdocAccessOperation.Test results
Region widening, re-run with Part 2 merged in:
check.sh): ✓ lint, format, typecheck, typecheck:tests, unit lane (234 files / 2984 tests)managers-access(30),event-verification(49),user-submissions-review-lifecycle(38)emailandcontactDetailsvisible, every other key absent;nameonly.nameonly),selectof every locked field, depth-1 population, the drawer's permissions, the refusedwhere/sort/distinctprobes, and a one-events-query spy.['contactDetails', 'email'], written out rather than read off the set;Original #908 run:
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)user-submissions-review-lifecycle(38),user-submissions-create(41),screen-submissions(20),atlas-submission-routing(14)Manual verification
atlas-manager(not an admin), against a database holding a second manager./api/managers?limit=5in the same browser — noemailon any row but your own and those of managers assigned inside a region you manage; elsewherecontactDetailsandsessionscome back[].previewEventcarries{ 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.
previewEventandproposedChangesresolve the assigned manager withoverrideAccess: true, which skips every lock this PR adds, andpreviewEventis readable by any manager — so anatlas-manageropening 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 toManagerscannot ride along later. The rule it establishes indocs/rules/access.mdis bounded in both directions: a row copied into a surface owes aselect, and a row a gate interrogates must never get one — fourmanagersreads 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 madesanitizeFieldslabel 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.apiKeyhas 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: defaultAccesson the base_verifiedis a function and wide open, and so isread: () => true— the counting form passed both.src/plugins/login/now imports a manager-shaped predicate. Onlymanagersis 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, fedpermissions.collections.managers.fields), so the list showsnamealone rather than three blank columns. No change needed.⚠ Open for your decision: an assignment the reader made counts.
Events.managerandRegions.managersdon'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. Onmaintoday, every atlas-manager reads every manager's email, so this is a residual inside the widening, not a regression againstmain.Dismissed, with reasons:
accessPluginwith 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:142gates its field walk onisTranslatableCollection(slug), andmanagersis 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.emailand_verifiedmerge at sanitize, after every plugin, so two of the five locks stay inManagers.tseither way. The unit sweep is what holds the other three.legacyMigrationFields()— the factory serves five collections, and a manager-shaped lock is wrong onevents/regions, so it needs a per-collection argument. Same call.'reference'permission level — read narrowed toadmin.useAsTitle— would make this narrowing automatic for the next restricted collection a picker points at, and retire the raw-id costdocs/rules/access.mdrecords forweb-translator. Field locks are what it would be built from, so this PR is a prerequisite rather than a detour.?where[email][equals]=— not real.validateSearchParamsrejects awhereon 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 threewhere: { email }lookups all passoverrideAccess: true, so none is affected.tests/utils/, a named constant for the three machine columns, and dropping the explicitid === undefinedclause from the hook's guard — all low value; the last reads better spelled out in a security guard.Detail
No migration.
emailand_verifiedalready existed as merged base fields; declaring them changes no column.db:migrations:create --skip-emptywrote nothing, andgenerate:typesleftpayload-types.tsunchanged — a lock strips the value at runtime, not the shape from the generated type. The joined fix changes no column either:selectnarrows 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
_verifiedundeclared, because Payload's baseread: defaultAccessis a function. It now evaluates each lock as an atlas-manager reading someone else's row, and the unit sweep follows. ThedocAccessOperationcase was added only once thedoc.idfallback turned out to be what the admin panel depends on —getEntityPermissionscallspopulateFieldPermissionswith noidat all.A latent coupling, recorded in
Managers/access.ts. AssigningaccessstandsapplyFieldAccessForTranslatableCollectionsdown, because that pass acts onlyif (!field.access). Moot while no role grantstranslateonmanagers; the day one does, that pass would silently cover none of these fields.createdAt/updatedAtare not inMANAGER_PUBLIC_FIELDS. Payload appends them outsidefields, 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-reviewsurfaced it while re-tracing #822. It isdocs/rules/access.md's own "restricting a collection does not reach a copy of it" rule, one step further out than the twoeventsfields that paragraph already names — so the rule gained theoverrideAccesscase rather than a new ticket gaining a sibling.proposedChangesreads onlyrecord.title ?? record.name, andmanageris absent fromEvents/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.activityLogstores the email address or messaging handle each verification reminder went to, andlogField's lock admits every manager — so anatlas-managerreads 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 aselectin one projection.Rejected shapes, from the ticket. A single collection
afterReadprojecting the document down to the public fields would delete most of this — but a fieldreadlock 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: trueon the three machine columns would strip them from the holder and admins too, and the redeem route would then needshowHiddenFields.Region widening review: an adversarial pass by a fresh agent over
git diff origin/claude/fix-1047-log-addresses...HEAD. It turned up: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-onlyPOST /api/managers/access/:idanswer were noted, not changed.Review passes run:
/simplify(4 agents: reuse, simplification, efficiency, altitude),/code-review high,/security-review— the last because the diff touchessrc/plugins/access/,src/collections/Managers/and nowsrc/collections/UserSubmissions/hooks/. It ran twice: once over the whole branch, reporting nothing at its confidence bar, having traced that #822 stays closed (refreshandmeboth reachapplyUserReadAccesson the caller's own row), that?where[email]is refused byvalidateSearchParamsbecause the policy it reads is built with nodata, and thattypeandroleskeepupdate: adminOnlyFieldAccessin 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
Events.activityLogreminders (destination,cells.delivery) anduser-submissions.activityLogdeliveries (cells.sentTo).afterReadprojection are closed with it:where/sortfiltering, write-back of a redacted log,duplicate, andpreviewEvent's override read.The decision this implements, from the maintainer, Ardnived (2026-10-30), overriding the ticket's options A/B/C:
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.
LogTablerenders an empty cell, and the row's JSON drawer shows no address.Behaviour — who sees an address
Where each document is placed:
region/manager, loaded withselectwhen the read omitted them (eventAddressScope).submissionRoutingRegionId, the chaindeliverProposalmails 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 alongPreview
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.
/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-managersession in each; a preview has no way to provision either. The integration specs cover that half instead.Test results
event-verification(48, 12 new)user-submissions-access(19, 11 new)managers-access(12)user-submissions-review-lifecycle(37)log-field(15, 6 new)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, thepreviewEventcopy, and the filter refusal. The visible-to cases cannot fail against old code, so each was mutation-checked against the fix instead:Manual verification
atlas-managerwho manages neither region of a reminded event.channeland nodestination./api/events?where[activityLog.destination][like]=a. It answers 400,The following path cannot be queried.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.activityLogrenders exactly as it does today." The ticket read that log as carrying no contact detail, citing the review entries, which store amanagerIdonly.DeliverSubmissionsalso writescells.sentTo, and on a proposal that is the address the review mail went to — so that log narrows too, and an outsider'sSent tocell on a proposal is now empty.This closes the exposure only together with #1045. On
maintoday, every narrowed entry still carriesmanager.id, and an atlas-manager can readGET /api/managers/<id>for that row's email andcontactDetails(#908). #1045 closes that. The two branches merge cleanly (git merge-treeagainstclaude/fix-908-manager-field-locks): this PR adds no code tostripLockedFieldsOnSelfReadoradminOnly.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 theirmanagersrow. That is the maintainer's rule applied to the log only. Wideningmanagersto match is a separate decision.whereon the JSON column: a manager could filter by its contents. Before this, as an outsider,where[activityLog.destination][equals]and[like]both matched.likeis 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 firstbeforeOperationguard missed:OR/AND;regions.events,managers.managedEvents,users.submissions);user-submissions?where[event.activityLog…]).sortandfindDistinctare refused the same way. Every read of a row passesdoc; the admin edit view'sdocAccessOperationpasses 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 (
managerSubmissionScopecovers every proposal). The admin form posts back the redacted log it rendered, andapplyReviewappends to the redacteddocits own update's afterRead left. Either path erasedsentTofrom storage.restoreLogAddressesputs 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 readersisEventInScopeadmits. The hook covers them anyway.Adversarial review (fresh subagent, handed the diff only). Its findings, and how each was handled:
OR/AND, joins, relationship hops). Replaced the guard with the doc-less lock above.duplicatecopying the source's whole log into a draft the caller re-homes to their own region. AddedbeforeDuplicate: [() => []]. The case uses an unmanaged event, whichsyncVerificationOnSaveleaves alone, so only the hook empties it.cells.delivery('Saved','Email link') were being stripped. Addedtypes, so only reminder and delivery entries narrow.contactDetailsand confirm whose it was. "Own" now uses the entry'smanager.id, and email only where an entry names nobody.trash: trueon the routing load.data.parentversions branch: Payload hands the hook the version snapshot itself. Removed.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 noreq.readVersionsis already update-scoped, so this cannot leak. Aselect-narrowed version read falls back to own-only.sentTois'<provider> list <id>'— a mailing list, not a person — andtypesdoes not reach it, sinceDeliverSubmissionslogs every intake's outcome as the onedeliverytype. No carve-out, becausemanagerSubmissionScopegives no non-admin a subscribe or registration row at all (accessConfigs.ts:92, pinned atuser-submissions-access.int.spec.ts:211), and an admin sees every address. Widening that scope would need one here.cells.activityof a failed delivery.required, andExpireEventsno longer falls back to the address.Detail
Every read path checked:
find/findByID, as each readerselect[activityLog]=true: noregion/manageron the row, so the decision loads them with a two-columnselectgetDocumentDatawithoverrideAccess: false, and its field permissionsLogTableandVerificationStageField, which read form state onlypreviewEvent/proposedChanges, now selecting the log outwhere/sort/joins/relationship hops/findDistinct, all refusedwhere, refusedduplicate, emptiedImportResultsField, SEO/sitemap and geojson: allselectwithoutactivityLog, or are client-only/distinctis not routed in Payload 3.90.2Jobs keep the address.
ExpireEvents,DeliverSubmissions,ScreenSubmissionsandSendSessionRemindersread at the local API's defaultoverrideAccess: true, where the hook stands down. The update operation readsoriginalDocthe same way, which is what the restore compares against.No migration, no type change.
custom,hooksandaccesschange no column;payload-types.tsis unchanged.Review passes run: the adversarial subagent above, over the whole diff.
/simplify,/code-reviewand/security-reviewwere not run separately.Closes #1047
🤖 Generated with Claude Code