Repository navigation
Description
Epic: #731 · Foundation: #237 · Design agreed with Chipper in #census on 2026-10-17. This issue is the single design to review before any code.
Goal
Replace the hard-coded Admin / SuperAdmin checks with configurable, server-enforced permissions. Any role can be given any set of permissions from an Admin page, with no code change. Day one behaves exactly like today.
Model
A user may do something if any of their roles has a grant that matches all of:
| Part | Values |
|---|---|
| Permission | page/table × view / add / update / delete, plus named extras (cancel, reschedule, check-in, overrides…), from the catalog in #731 |
| Relationship to the person/shift acted on | self · on my shift · in my department · everyone |
| Subject filter (optional) | holds role(s) X · signed up for position(s) Y · excluding role(s) Z |
| When | any · a named window (event-level or shift-level) |
| Where | any · on-playa · off-playa |
Hard rules that no grant can override:
- Nobody sees or edits their own review.
- Lead-on-lead reviews are denied unless a grant says otherwise.
- At least one Admin always keeps the permissions page (lockout guard).
Department = the existing op_shift_category.department (DataEntry, OutReach, Sampling, SetupStrike, Special, Tech, Training). No new table.
Data (new tables, following the #620 SCD2 direction, no actor columns)
op_role_grant: role_id, permission, relationship, subject_role_ids, subject_position_ids, exclude_role_ids, window_key, place. One row = one grant. Several rows on the same role are OR'd together.op_time_window: key, anchor (shift_start · shift_end · anop_datesdate), minutes_before, minutes_after. Seeded with today's constants:shift_future(until start − 1h)shift_during(start − 1h → end + 2h)walkup_checkin(start ± 30 min)shift_past
op_role_auto_grant: role_id, trigger (position_assigned·training_complete· …), trigger_ref_id, lasts (shift·event_year·until_removed). This replaces the hard-coded training → role writes.- Position sign-up rule:
op_position_type.signup_mode(open · role · assign_only), plusop_position_role(position_type_id, role_id) so a position can accept a set of roles. Today's singlerole_idmigrates into it. - Pseudo-roles become rows in
op_roles(role_src='system'): Guest off-playa, Guest on-playa, Authenticated Volunteer. - Permission catalog lives in code, not a table: a permission only means something once code checks it.
Enforcement
can(session | null, permission, { subjectShiftboardId?, timePositionId?, shiftTimesId? })inlib/authz.ts. It loads the user's roles and grants once per request, then answers yes/no.- Every API route wraps with
withPermission("shift_types:update")(or callscan()for object-level checks). This replaceswithSuperAdmin,withWriteGuard,isAdminandisOwnerOrAdmin. - The client receives the evaluated permission list with the session and hides UI from it. The client is never the lock.
- Read-only mode and the existing check-in window logic keep working: they become a window and an override instead of special cases.
Setup page (Admin by default)
/roles/[roleId]/permissions shows one grid per role: rows = permissions, columns = scope / when / where. New roles start empty (baseline only). It also holds the role's auto-grant rules. Assignment of people to roles stays where it is today.
Day-one seed (reproduces today)
| Role | Seeded grants |
|---|---|
| Guest off-playa | home, filtered shift list (#800), contact, training |
| Guest on-playa | + walk-up check-in in walkup_checkin |
| Authenticated Volunteer | own profile/account/schedule, sign up / remove self, shift list |
| Shift Lead | as today (gates lead positions, profile display) |
| Admin (absorbs SuperAdmin) | today's Admin + SuperAdmin powers |
| New, empty until configured: Volunteer Coordinator; area leads (Gate Sampling, Airport Sampling, Setup, Strike, Data Entry, Lab Host, Art Tour; reusing the existing Census Gate/Airport Sampling Lead and Census Data Entry Lead roles); Census Lab Host; IT Tech (Chipper: "sort of an administrator", to be configured) | — |
| Core Crew, Staff, qualifications, flags, training completions | no grants (still usable as subject filters / sign-up roles) |
Rollout (off-season, never hot-swapped mid-event)
- Close the gap now: add the missing server-side guards on the dates and shift setup routes (Security: admin/super-admin config API endpoints have no server-side authorization #535 follow-up).
- Add the tables +
can()with seed data. Nothing calls it yet. - Move routes onto
withPermissionone group at a time, with a test asserting the same allow/deny as before for each. - Ship the setup page (read-only first, then editable).
- Add VC / area-lead / Lab Host grants, auto-grant rules and sign-up modes, configured by Chipper on the page.
- Later: move flags, training and camp membership out of
op_roles(exclude_from_recruitment flag (absorbs #608) #614, Roadmap: replace boolean add/remove/update/delete flags with timestamps + an SCD change log #620).
Open (all are settings, none block the build)
- How long an auto-granted area lead role lasts (shift / event year / until removed)
- Roster: separate "names only" view level? Personal info as its own permission?
- Reviews: their own window, separate from check-in (Shift leads can't enter review comments on tablets — review UI is Admin-only + window-gated (root cause of Sep 2 Data Entry report) #749)?
🤖 Generated with Claude Code
Activity
mbhewitt commentedon Oct 17, 2026
Admin goes away as a catch-all (Chipper, 2026-10-17)
This replaces "trim Admin to the core group". The 21 people who are Admin but not SuperAdmin keep the abilities they actually use through their functional roles, not through Admin. Live data on those 21:
Plan:
Check before step 2: each of the 20 should actually need what Shift Lead / Lab Host get. A short list for Chipper to eyeball, sent privately (not posted here, it's names).
mbhewitt commentedon Oct 17, 2026
Decisions (Mew, 2026-10-17)
No area lead roles. Lead positions stay gated by the generic Shift Lead role, as today. The old Census Sampling / Construction / OutReach / Data Entry / Training Lead roles are not revived.
Lead powers come from the position, not a role. A grant can be attached to a position as well as a role. Being assigned to Gate Sampling Lead on a shift gives that position's grants for that shift. Example: the Gate Sampling Lead position grants view/check-in/reviews for the samplers and traffic tamers on that shift. This replaces the auto-granted area roles, so there's no role to grant or expire.
Admin → removed from the 21 current non-super Admins. SuperAdmin → becomes Admin (the 9).
Capability roles for system changes: small roles that each carry one slice of setup. Examples:
The 21 ex-Admins who need something get the specific capability role(s).
Design changes
op_role_grantbecomesop_grantwith a holder of eitherrole_idorposition_type_id. Position grants are always scoped to the shift the person holds that position on.op_role_auto_grantfor lead positions. It's still useful for training → role.🤖 Generated with Claude Code
mbhewitt commentedon Oct 17, 2026
Org chart (Mew, 2026-10-17): "we need an org chart… i think peers did something like this"
What peers has (
origin/peers-main,client/src/lib/authz.ts): a hard-coded leadership rank, Admin 3 > Coordinator 2 > Shift Lead 1 > everyone 0. A volunteer's rank is the highest role they hold. You can manage anyone below you, and same rank too for passcode resets (2026-08-30). It's used for kiosk passcode reset and lead read access to a subordinate's page. There is no org chart page.Proposal for Census: make it data-driven. A tree of roles and positions (e.g. Admin → Volunteer Coordinator → Shift Lead → Lab Host / Sampler; Gate Sampling Lead → Gate Sampler / Traffic Tamer), one parent per node. "Below me" comes from the tree, and the scope rules use it: reviews (below only, never peer or self), notes, passcode reset. It can also render as a visible page.
Open (Mew): permissions only, or also a visible "who to ask" chart with names? Should positions be nodes, given that lead powers now come from positions?
mbhewitt commentedon Oct 17, 2026
Org chart: derive it, don't maintain it (proposal, 2026-10-17)
Mew: "i am not sure how to set it up so that it is flexible and self organizing."
Build the chart from data that already exists, so it reorganizes itself as leads are assigned and people sign up:
op_position_type.leadalready flags lead positions. On a shift, people on lead positions sit above the people on that shift's other positions.op_shift_category.departmentputs every shift, and therefore every lead, under a department.2026 check (distinct people, from live signups):
Special has no leads, so its people roll up to that department's VC or to Admin.
The scope rules ("below me" for reviews and notes, passcode reset) read the same derived chart. Next step if wanted: a read-only org chart page rendered from live data.
mbhewitt commentedon Oct 18, 2026
Revision from Chipper's feedback (2026-10-17): the org chart doesn't drive permissions
What changes
can().op_shift_category.departmentof the lead's position. No VC assignment needed, so Special (no VC) works the same way.op_role_grantgets a nullableposition_type_idbesiderole_id, with exactly one of them set. "Holds position X" means signed up for X in the current event year (or in the shift's window, if the grant has one).position_assignedtrigger inop_role_auto_grant. That table is left with only training → role.Open
🤖 Generated with Claude Code
mbhewitt commentedon Oct 18, 2026
Lead access timing (Chipper, 2026-10-17)
Shift Leads keep the Shift Lead role year-round. That status is still useful for off-playa work. Their extra access (department volunteer info and similar) is switched on by date context, not by removing the role and adding it back.
event_access, anchored onop_dates: from N days before the event to M days after.🤖 Generated with Claude Code
mbhewitt commentedon Oct 18, 2026
Top role: rename, don't merge (Chipper, 2026-10-17)
This replaces "SuperAdmin merges into Admin" and the "trim Admin first" warning.
🤖 Generated with Claude Code
mbhewitt commentedon Oct 18, 2026
Privileges come from roles, never from sign-ups (Chipper, 2026-10-17)
This replaces the earlier "Shift Lead sees the department of the lead position they hold" and "grants can attach to a position".
op_position_auto_role). Example: assigned to Gate Sampling Lead → gets Census Gate Sampling Lead. The role carries the privileges. The sign-up itself never does.Implemented in #806.
🤖 Generated with Claude Code
mbhewitt commentedon Oct 18, 2026
Leads: position-based access (Mew, 2026-10-18)
grantee_typenow includesposition, with a unit test and 4 cases run against a scratch MySQL database (lead sees own department · another department → no · removed from lead shift → no · plain volunteer → no).🤖 Generated with Claude Code
mbhewitt commentedon Oct 18, 2026
Chipper 2026-10-18, requirements for the grants admin UI and design:
mbhewitt commentedon Oct 18, 2026
Mew's proposed role hierarchy (2026-10-18):
Revised #806 trim: keep the
positiongrantee and theshiftrelationship (needed for Lead). Drop thedepartmentrelationship (VC department scoping is a 'might') and date-anchored windows.Open questions to Mew (my suggestion in brackets):
mbhewitt commentedon Oct 18, 2026
Chipper (2026-10-18): leads must be able to find volunteers not on their shift, so they can add walk-ups. On-playa today, the add dialog already lists every volunteer for a shift in progress.
Proposed split:
volunteers:find: name-only search (playa/world name, no contact info).mbhewitt commentedon Oct 18, 2026
Mew (2026-10-18): only VCs (and up) get full volunteer details. Shift leads need 'a lot of latitude to make the shift reality'.
Updated Lead model (scope = the shift they're leading, during the lead window):
Still open: who owns SAPs, and the lead window (suggested: 1h before start → 24h after end).
mbhewitt commentedon Oct 18, 2026
Contact data actually held in
op_volunteerson prod (2026-10-18):Chipper's point: a lead who can add anyone to their shift could then see that person's details, so hiding them from leads is mostly a speed bump. Mew to decide: either leads see email and location for people on their shift, or those fields stay VC-only.
mbhewitt commentedon Oct 18, 2026
Mew (2026-10-18): preserve on-playa tablet flexibility. Facts from the current code (
pages/api/shifts/[timeId]/volunteers/index.ts):anyone / on_playa / walkup_checkin.Open question for Mew: widen signed-out tablet abilities during the shift window (add walk-ups, comments)? That would be grant rows only, but the route's device-cookie gate must be kept as a prerequisite.
mbhewitt commentedon Oct 18, 2026
Correction to my previous comment (Mew caught it). For a signed-in non-admin on playa (on-playa build, or a provisioned tablet):
shiftVolunteerRemove→isOwnerOrAdmin; it's self only, everywhere.The #806 seed already matches the server.
mbhewitt commentedon Oct 30, 2026
Multi-event requirement (Chipper, 2026-10-30), from Love Burn + Fern Burn conversations (see #530)
Other events would need separation between departments: people should be able to see only certain departments, not the whole event.
How this fits the current design here:
Chipper: "Separation between departments is a big one. With the ability to only see certain departments. I think we get that through the new roles permissions configuration."
mbhewitt commentedon Nov 13, 2026
Review visibility requirements, from #census on 2026-11-13 (no review content here):
So we need two things: a scoped permission to view reviews (who reviewed, about whom, by leadership level), and a rule for which surfaces reviews are allowed to appear in (app vs. Discord).
mbhewitt commentedon Nov 13, 2026
Mew (2026-11-13): #census is primarily a development channel and may include people who aren't authorized to see reviews. Reviews should be viewed through the app, not Discord. So the app's review views need to cover the leadership-fit scouting use case (above), gated by the review-view permission.
mbhewitt commentedon Nov 27, 2026
Mew (2026-11-27, #851 conflict 7): needs more discussion. Open question: does a new Leadership role replace today's Admin (#731 Part C), or does SuperAdmin become App Admin with Admin unchanged on day one (#804)? Don't build either part until this is settled.
mbhewitt commentedon Nov 27, 2026
Folding in #595 (Mew 2026-11-27, #851 conflict 13: superseded by the roles discussion). Carried over from #595: (1) who can grant Admin; (2) for actions the server already blocks for Admins (role-definition create/edit/delete), should the Roles screen hide those buttons or show them disabled?
mbhewitt commentedon Nov 27, 2026
Folding in #596 (Mew 2026-11-27, #851: roll into the roles discussion). Its open sub-decisions: A) Settings hidden on-playa plus an off-playa tester role; B) remove shift-lead/lab-host power to edit shift times or a position's role; C) disable-idle-logout for super-admins only; D) allow hiding Admin/Super admin on the account page; E) time-scope admins' forced roster changes (event-time only, past-looking). Details on #596.
mbhewitt commentedon Nov 27, 2026
Folding in #237 (Roles and permissions foundation, January 2026; Mew 2026-11-27, #851). Its scope (configurable permissions instead of hardcoded ones: who can check in, role-restricted signup, roster visibility, PII access) is this ticket's scope.
mbhewitt commentedon Nov 27, 2026
Mew (2026-11-27, #851): the permissions meeting (Mew, Chipper, Rescue) still needs to happen. I'll add a written proposal to the permissions framing doc first, so the meeting can react to it.
mbhewitt commentedon Nov 27, 2026
Folding in #128 (Mew 2026-11-27, #851): admins can be added to shifts and look like regular volunteers. Should they be hidden or marked? Include this in the permissions discussion.
mbhewitt commentedon Nov 27, 2026
Proposal for the permissions meeting is posted as a Drive comment on the framing doc (2026-11-27). Summary: App Admin = today's SuperAdmin; Volunteer Coordinator replaces Admin, after a one-by-one review; no separate Leadership role; drop Scheduler and Volunteer Assistant for now. Leads see name and camp, not email, and review during the lead window. Past notes are VC-only. Volunteers can self-drop until the shift starts. Screens hide what the server forbids. #596 E vs "always": keep always, and log the change. Recommendations only; the meeting decides.
mbhewitt commentedon Nov 27, 2026
Folding in #597 (Mew 2026-11-27):
op_roles.displaycontrols both whether a role shows on account pages and whether it's offered in the position setup picker. The permissions design should split these.mbhewitt commentedon Nov 27, 2026
Folding in #444 (Mew 2026-11-27): the configurable signup-rules engine (warn / block / Discord ping / checklist + custom copy). Today's rules live in
components/api/shiftAddRules.ts.