Max Owners + CODEOWNERS Collector
Enforce Max Owners using data collected by CODEOWNERS Collector. Automatically check repository and ownership standards on every PR.
How CODEOWNERS Collector Powers This Guardrail
The CODEOWNERS Collector gathers metadata from your vcs systems. This data flows into Lunar's Component JSON, where the Max Owners guardrail evaluates it against your standards.
When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.
Quick Start Configuration
Add both the collector and policy to your lunar-config.yml to enable this guardrail.
# Step 1: Enable the CODEOWNERS Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/codeowners@v1.0.0
# with: ...
# Step 2: Enable the CODEOWNERS Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/codeowners@v1.0.0
include: [max-owners]
# with: ...
What CODEOWNERS Collector Collects
This collector gathers the following data that the Max Owners guardrail evaluates.
codeowners
Scans the repository for a CODEOWNERS file in standard locations
(CODEOWNERS, .github/CODEOWNERS, docs/CODEOWNERS) and parses
its contents. Extracts ownership rules, validates syntax, classifies
owners as teams vs individuals, and detects catch-all rules. Writes
structured data to .ownership.codeowners.
Example Data Flow
Here's an example of the data that CODEOWNERS Collector writes to the Component JSON, which Max Owners then evaluates.
{
"ownership": {
"codeowners": {
"exists": true,
"valid": true,
"path": ".github/CODEOWNERS",
"errors": [],
"owners": ["@acme/backend-team", "@acme/platform-team", "@jdoe"],
"team_owners": ["@acme/backend-team", "@acme/platform-team"],
"individual_owners": ["@jdoe"],
"rules": [
{
"pattern": "*",
"owners": ["@acme/platform-team"],
"owner_count": 1,
"line": 3
},
{
"pattern": "/src/backend/",
"owners": ["@acme/backend-team", "@jdoe"],
"owner_count": 2,
"line": 6
}
]
}
}
}
Configuration Options
CODEOWNERS Collector Inputs
| Input | Required | Default | Description |
|---|---|---|---|
paths |
Optional |
CODEOWNERS,.github/CODEOWNERS,docs/CODEOWNERS
|
Comma-separated list of CODEOWNERS file paths to check (first match wins) |
CODEOWNERS Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
min_owners_per_rule |
Optional |
2
|
Minimum number of owners required per CODEOWNERS rule (for min-owners check) |
max_owners_per_rule |
Optional |
10
|
Maximum number of owners allowed per CODEOWNERS rule (for max-owners check) |
Ready to Automate Your Standards?
See how Lunar can turn your engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.