Difficulty: Expert
Type: feature
Background
The README lists "Constitutional rule engine" and "Complex moderation workflows / appeals / reinstatement" as separate deferred areas, distinct from the existing simple packages/policy-engine rule types (PUBLIC, MEMBERS_ONLY, ADMINS_ONLY, CONTRIBUTORS_OR_ADMINS).
Problem
Communities have no way to define higher-level, versioned governance rules (a "constitution") that constrain what lower-level policies or role/permission changes are even allowed to do (e.g., "suspensions always require two-admin approval" or "no role can be granted ADMINS_ONLY access without a documented reason"), nor a structured moderation workflow (suspend → appeal → reinstate) with auditable state transitions.
Expected outcome
A packages/constitution-engine (or similarly scoped) module lets each community define versioned governance constraints that validate proposed policy/role/permission changes before they're applied, plus a moderation-action state machine (active → suspended → appealed → reinstated/upheld) with every transition recorded as an auditable event.
Suggested implementation
- Design a small declarative rule format for constitutional constraints (e.g., JSON rules referencing action type, required approvals, cool-down periods) stored per community with versioning (so changing a community's constitution doesn't retroactively invalidate past decisions).
- Add a validation hook that runs before mutating admin actions (role/permission changes, suspensions) checking against the active constitution version; reject non-compliant actions with a clear reason.
- Design a moderation state machine (
active → suspended → appealed → reinstated / upheld) as an explicit Prisma-backed model with allowed transitions enforced in code (not just convention), each transition emitting an outbox event.
- Add an appeals endpoint allowing a suspended member to submit an appeal, and an admin endpoint to resolve it (reinstate or uphold), both requiring the multi-approval pattern if the constitution mandates it.
- Write thorough tests: invalid transitions rejected, constitutional constraint enforcement (e.g., two-admin approval requirement), and versioning (an old decision remains valid under the constitution version active at the time it was made).
- Document the design, including tradeoffs and the intentionally-simple v1 rule format, in
docs/.
Acceptance criteria
Likely affected files/directories
packages/ (new constitution-engine package)
packages/policy-engine/
apps/access-api/prisma/schema.prisma
apps/access-api/src/routes/
docs/
Difficulty: Expert
Type: feature
Background
The README lists "Constitutional rule engine" and "Complex moderation workflows / appeals / reinstatement" as separate deferred areas, distinct from the existing simple
packages/policy-enginerule types (PUBLIC,MEMBERS_ONLY,ADMINS_ONLY,CONTRIBUTORS_OR_ADMINS).Problem
Communities have no way to define higher-level, versioned governance rules (a "constitution") that constrain what lower-level policies or role/permission changes are even allowed to do (e.g., "suspensions always require two-admin approval" or "no role can be granted
ADMINS_ONLYaccess without a documented reason"), nor a structured moderation workflow (suspend → appeal → reinstate) with auditable state transitions.Expected outcome
A
packages/constitution-engine(or similarly scoped) module lets each community define versioned governance constraints that validate proposed policy/role/permission changes before they're applied, plus a moderation-action state machine (active → suspended → appealed → reinstated/upheld) with every transition recorded as an auditable event.Suggested implementation
active → suspended → appealed → reinstated/upheld) as an explicit Prisma-backed model with allowed transitions enforced in code (not just convention), each transition emitting an outbox event.docs/.Acceptance criteria
docs/Likely affected files/directories
packages/(new constitution-engine package)packages/policy-engine/apps/access-api/prisma/schema.prismaapps/access-api/src/routes/docs/