Skip to content

Implement a deterministic permission inheritance resolver with conflict detection #379

Description

@Lakes41

Difficulty: Expert
Type: Feature
Recommended labels (if available in this repo): roles, access-control, backend, expert

Background

GuildPass communities may eventually support roles that inherit permissions from other roles. Inheritance is useful, but it introduces graph complexity, ambiguity and the possibility of cycles.

This issue introduces a pure role-permission inheritance resolver that can be implemented independently of role persistence, membership services and API routes.

Problem

There is currently no reusable Core primitive for resolving effective permissions across an inheritance graph.

A naive recursive implementation can loop forever on cycles, double-count permissions, or produce inconsistent results when multiple inheritance paths converge.

Expected Outcome

Implement a deterministic resolver that calculates the effective permission set for a role based on its directly assigned permissions and inherited parent roles.

Suggested Implementation

Represent roles with structures similar to:

interface RoleNode {
  id: string;
  permissions: string[];
  inherits: string[];
}

The resolver should:

  • accept a collection of role definitions;
  • resolve effective permissions recursively;
  • deduplicate repeated permissions;
  • detect cyclic inheritance;
  • reject references to unknown parent roles;
  • define deterministic ordering for returned permissions;
  • support multiple inheritance;
  • enforce configurable depth and graph-size limits;
  • expose structured errors for cycles, missing parents and malformed graphs;
  • remain independent of Prisma, Fastify and membership state.

Optional deny semantics may be introduced only if they are explicitly modelled and documented rather than inferred from naming conventions.

Acceptance Criteria

  • Direct permissions resolve correctly.
  • Single-level inheritance resolves correctly.
  • Multi-level inheritance resolves correctly.
  • Multiple inheritance resolves correctly.
  • Duplicate permissions appear only once in the effective result.
  • Cycles are detected deterministically.
  • Missing inherited roles are rejected clearly.
  • Returned permission ordering is deterministic.
  • Depth and graph-size limits are enforced.
  • Unit tests cover diamonds, cycles, missing roles and deep inheritance chains.
  • pnpm typecheck passes.
  • pnpm build passes.
  • pnpm test passes.
  • No role database schema, API route or membership functionality is introduced.

Likely Affected Files/Directories

packages/permission-inheritance/ or equivalent isolated package
unit tests

Independence Requirement

This issue must be independently implementable from the current main branch and must not depend on role persistence or another campaign issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesThird CampaignOfficial FWC26 campaign issue — eligible for campaign scoring and rewardsaccess-controlAccess evaluation, permissions, authorisation rules, and protected resource logicbackendBackend services, application logic, persistence integration, and server-side functionalityexpertExpert difficulty tasks requiring deep expertise and architectural decision-makingrolesBuilt-in and custom roles, role definitions, assignments, and community role management

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions