Files
adminandClaude Opus 5 d923c075af Grant a module to a person, and let a unit stay a shortcut
Atrium becomes the writer of `dredd.module_permission` -- the one table
that decides who may use which module, and with what role. No row is no
access; `user` may use; `moderator` may administer; a platform
administrator needs no row anywhere.

The administration pane grants and revokes per module, with a role, and
`module_assignment` survives only as the record of WHY somebody holds a
row: naming a unit is still how you grant a whole department at once, but
it now writes the per-user rows, so the three modules read exactly one
table and never have to reach into this schema to find out who may enter.

The shortcut re-materialises on every change that can alter who is in a
unit -- an assignment added or removed, availability changed, a module
created, an access request approved, a unit grant given or taken away, a
unit deleted, an account created, and every deploy through the seed. That
is possible without a background job for one reason: the hub is the only
writer of membership AND of permissions, so every input is a request this
app served. Freezing it instead would have been a regression -- unit
membership already resolved live -- and re-resolving on read would mean a
GET that writes, in three deployments that hold SELECT and nothing else.

Two rules keep the set-difference safe. Naming somebody on a roster pins
a direct assignment for them, so an unrelated change to that module
cannot sweep them away later -- a silent, delayed revocation. And a
deactivated account takes no part in either direction, so switching
somebody off and on again does not strip every module they moderated.

Two gaps found by running it rather than reading it:

- Existing modules have no permission rows, and nothing in the trigger
  list creates them -- so the first deploy of this would have let nobody
  into anything, including modules marked available to everyone. The seed
  now sweeps every module, which makes it a backstop as well as a
  backfill since it writes only differences.
- A table created by the new revision carries no runtime grants: 0003
  granted ON ALL TABLES at the time it ran. Invisible until the day the
  deployment joins a platform and every roster read is a permission
  error. The new revision re-runs the grants, as 0003's own docstring
  says every later revision adding a table must.

The HTTP route keeps its name. `/admin/modules/<slug>/moderators` is
quoted in three other repositories and scanned by a test in one of them;
renaming it to match the table would be tidiness bought with four repos
and a broken suite.

Requires dredd-core v0.11.0.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-01 11:53:04 +02:00
..
2026-09-14 20:04:48 +02:00