Skip to content

Refactor codeowners config/generation - #10287

Open
mcmire wants to merge 5 commits into
mainfrom
refactor-codeowners
Open

mcmire wants to merge 5 commits into
mainfrom
refactor-codeowners

Conversation

@mcmire

@mcmire mcmire commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Explanation

In a previous commit (4a8e09d) we added a configuration file, codeowners.ts, which was intended to help contributors define codeowners for packages more easily. However, in an effort to preserve existing grouping and sorting within .github/CODEOWNERS as much as possible, we were forced to include explicit generation logic in the configuration file, which made it less maintainable than we'd liked.

This commit changes codeowners.ts so that now all it contains is an exported configuration object, and the aforementioned logic to generate the CODEOWNERS file has been simplified. All packages and teams are now alphabetized, and the order of sections within CODEOWNERS is predetermined. For rare cases where customization is needed, an overrides property within the configuration file is available for use.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Regenerating CODEOWNERS changes rule order and file layout, which can shift GitHub review requests even when team assignments are preserved; verify overrides still win for nested paths like wallet initialization.

Overview
codeowners.ts is now a declarative config (packages + overrides) instead of exporting hand-built sections and inline generation helpers. Package→team mappings and optional initializationPath values are unchanged in intent; generation logic moved into scripts/manage-codeowners/ (assemble.ts, render.ts, generate.ts) with unit tests.

The regenerated .github/CODEOWNERS drops team-grouped sections in favor of a fixed layout: alphabetized Packages blocks (each package gets directory ownership, release files with @MetaMask/core-platform co-ownership, and wallet init paths under the wallet subsection), then an Overrides section (.github/, eth-json-rpc-middleware paths). Owner lists are sorted for consistent output. The CLI prelude is shorter; main.ts calls generateCodeownersFileContent(config).

Reviewed by Cursor Bugbot for commit 6ae3b11. Bugbot is set up for automated code reviews on this repo. Configure here.

@mcmire
mcmire force-pushed the refactor-codeowners branch 3 times, most recently from 8859b8c to 9934c74 Compare September 17, 2026 19:22
In a previous commit we added a configuration file, `codeowners.ts`,
which was intended to help contributors define codeowners for packages
more easily. However, in an effort to preserve existing grouping and
sorting within `.github/CODEOWNERS` as much as possible, we were forced
to include logic in the configuration file, which made it less
maintainable than we'd liked.

This commit changes `codeowners.ts` so that now all it contains is an
exported configuration object, and the aforementioned logic to generate
the CODEOWNERS file has been simplified. All packages and teams are now
alphabetized, and the order of sections within CODEOWNERS is
predetermined. For rare cases where customization is needed, an
`overrides` property within the configuration file is available for use.
@mcmire
mcmire force-pushed the refactor-codeowners branch from 9934c74 to 4a282fc Compare September 17, 2026 19:28
@mcmire
mcmire marked this pull request as ready for review September 17, 2026 19:38
@mcmire
mcmire requested a review from a team as a code owner September 17, 2026 19:38
@mcmire
mcmire deployed to default-branch September 17, 2026 19:38 — with GitHub Actions Active

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4a282fc. Configure here.

Comment thread scripts/manage-codeowners/assemble.ts Outdated
Comment thread codeowners.ts
GitHub resolves CODEOWNERS using the last matching rule, so alphabetized package sections allowed the generic wallet rule to override earlier initialization rules. Emit generated initialization rules at the start of the final Overrides section so their configured owners take precedence, before explicit overrides that must remain last.
Render all Wallet initialization ownership rules directly after the generic wallet package rule. This keeps related rules together while preserving last-match precedence over the wallet ownership rule; explicit overrides remain in the final Overrides section.
Comment thread codeowners.ts
buildRuleForPackage('money-account-controller'),
buildRuleForPackage('snap-account-service'),
],
const config = {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The packages property in this configuration object should be equivalent to PACKAGES from before. overrides is a new property and replaced the custom rules that were spread out between buildFirstSection and buildJointTeamOwnershipSection.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant