* Add Discord role sync with role-centric architecture This refactors the access management to use a role-centric model where each role explicitly defines which platforms it exists on (GitHub, Discord, Google). Key changes: - Add Discord role sync via Pulumi Dynamic Provider - Replace groups.ts with roleIds.ts + roles.ts for type-safe role definitions - Use ROLE_IDS constants to prevent typos in memberOf references - Each role has platform-specific config (github/discord/google keys) - Discord-only roles (e.g., administrators) and GitHub-only roles (e.g., typescript-sdk-auth) are now explicitly modeled - Add PR preview workflow to show Pulumi changes before merge - Add test-config.ts for config structure validation - Fix typo: docs-maintaners -> docs-maintainers Discord roles will match existing server roles: - administrators, lead maintainers, core maintainers - sdk maintainers, working groups, interest groups - etc. Requires new GitHub secrets: - DISCORD_BOT_TOKEN - DISCORD_GUILD_ID * Fix GitHub team ordering and make Discord integration optional - Add topological sort for GitHub teams to ensure parent teams are created before child teams, fixing the registry-wg parentTeamId issue - Make Discord integration optional by using config.get() instead of config.require(), allowing CI preview to succeed without Discord secrets - Add sortRolesByGitHubDependency() utility function in config/utils.ts Claude-Generated-By: Claude Code (cli/claude-opus-4-5=20%) Claude-Steers: 2 Claude-Permission-Prompts: 1 Claude-Escapes: 0 * Reconcile Discord roles for listed users Replace per-role-membership approach with per-user role sync that: - Adds missing roles users should have - Removes managed roles users shouldn't have - Only touches roles defined in config (won't affect admin roles, etc.) Users not in config remain untouched. Claude-Generated-By: Claude Code (cli/claude-opus-4-5=100%) Claude-Steers: 4 Claude-Permission-Prompts: 1 Claude-Escapes: 0 * Fix descriptions to match existing resources * Cache Pulumi plugins and fix GITHUB_TOKEN for pulumi install * Remove accidentally committed state backup * Use github.token for pulumi install * Fix formatting Fix deploy: add pulumi login before config set Fix deploy: set PULUMI_CONFIG_PASSPHRASE_FILE for config commands Import existing docs-maintainers team (remove after deploy) Remove docs-maintainers import workaround Add docs-maintainers cleanup to state cleanup Add pulumi refresh before up to sync state with reality Rename Discord roles to add (synced) suffix Cleanup Makefile and add lead-maintainers GitHub team
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import type { RoleId } from './roleIds';
|
|
import type { Role } from './roles';
|
|
|
|
/**
|
|
* A member of the MCP organization.
|
|
* Members are assigned to roles via memberOf, and the role definitions
|
|
* determine which platforms (GitHub, Discord, Google) they get access to.
|
|
*/
|
|
export interface Member {
|
|
/** GitHub username */
|
|
github?: string;
|
|
/** Email address (for Google Workspace) */
|
|
email?: string;
|
|
/** Discord user ID (snowflake) */
|
|
discord?: string;
|
|
/** Roles this member belongs to */
|
|
memberOf: readonly RoleId[];
|
|
}
|
|
|
|
/**
|
|
* Sort roles by GitHub parent dependency (topological sort).
|
|
* Ensures parent teams are created before child teams.
|
|
*
|
|
* This is necessary because when creating GitHub teams, we need the parent
|
|
* team's ID. If we process roles in arbitrary order, a child team might be
|
|
* processed before its parent, resulting in undefined parentTeamId.
|
|
*/
|
|
export function sortRolesByGitHubDependency(
|
|
roles: readonly Role[],
|
|
roleLookup: Map<RoleId, Role>
|
|
): Role[] {
|
|
const result: Role[] = [];
|
|
const visited = new Set<RoleId>();
|
|
|
|
function visit(role: Role): void {
|
|
if (visited.has(role.id)) return;
|
|
|
|
// Only process roles with GitHub config
|
|
if (!role.github) {
|
|
visited.add(role.id);
|
|
return;
|
|
}
|
|
|
|
// Visit parent first if it exists and has GitHub config
|
|
if (role.github.parent) {
|
|
const parentRole = roleLookup.get(role.github.parent);
|
|
if (parentRole) {
|
|
visit(parentRole);
|
|
}
|
|
}
|
|
|
|
visited.add(role.id);
|
|
result.push(role);
|
|
}
|
|
|
|
for (const role of roles) {
|
|
visit(role);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// Re-export for convenience
|
|
export { ROLE_IDS, type RoleId } from './roleIds';
|
|
export {
|
|
ROLES,
|
|
type Role,
|
|
type GitHubConfig,
|
|
type DiscordConfig,
|
|
type GoogleConfig,
|
|
} from './roles';
|