Skip to content

feat: ownership oracles (externally computed reviewer requirements) - #178

Open
zbedforrest wants to merge 9 commits into
mainfrom
feature/ownership-oracles
Open

feat: ownership oracles (externally computed reviewer requirements)#178
zbedforrest wants to merge 9 commits into
mainfrom
feature/ownership-oracles

Conversation

@zbedforrest

@zbedforrest zbedforrest commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Related PR(s)

#179 builds on this (inline ownership). Supersedes the seam explored in #45.

Summary / Background

Some ownership requirements depend on what changed inside a file, not which file changed (e.g. "telemetry event schema changes need data-platform review"). Path patterns can't express that, so such policies live in advisory bots that comment on PRs but enforce nothing.

This PR adds ownership oracles: an earlier workflow step computes reviewer requirements from the PR's content and hands them to codeowners-plus as a JSON file via the new oracle-files input. The rules are AND-merged into .codeowners-derived ownership through the existing MergeCodeOwners path, so review requesting, approval tracking, smart dismissal, and the status check apply unchanged.

Design properties:

  • Add-only: oracle rules can add requirements but never remove or weaken .codeowners rules, so a tampered oracle file can at worst request extra reviews.
  • Fail-closed: a missing or malformed oracle file (including an invalid glob pattern) fails the check rather than silently dropping reviews.
  • A file matched by an oracle rule counts as owned for unowned-file reporting.

Code Changes

  • pkg/oracle: JSON rule format, Parse/Load with strict validation, RuleSet.ToCodeOwners
  • pkg/codeowners: NewFromFileOwners constructor for computed ownership
  • internal/app: applyOracles merge step; main.go/action.yml: oracle-files input
  • README: "Ownership Oracles" section; coverage badge regenerated
  • Tests: oracle unit tests, app-level merge/error tests (multi-file, unowned interaction, case-insensitive approvals), splitOracleFiles

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces 'Ownership Oracles' (computed ownership) to Codeowners Plus, allowing external tools to feed JSON-based reviewer requirements into the action. The changes include adding the oracle-files input, parsing and merging oracle rules with standard .codeowners requirements, and introducing the pkg/oracle package with accompanying tests. The review feedback focuses on improving robustness in pkg/oracle/oracle.go by validating glob patterns during parsing to fail-closed, and adding nil checks for warningWriter and overlays in Merge to prevent potential panics.

Comment thread pkg/oracle/oracle.go Outdated
Comment thread pkg/oracle/oracle.go
Comment thread pkg/oracle/oracle.go Outdated
@zbedforrest
zbedforrest force-pushed the feature/ownership-oracles branch from ddcf8b6 to 5b75238 Compare July 22, 2026 19:26
@zbedforrest zbedforrest changed the title feature: ownership oracles — computed ownership from external tooling feature: ownership oracles (computed ownership from external tooling) Jul 22, 2026
@zbedforrest
zbedforrest force-pushed the feature/ownership-oracles branch from 5b75238 to dbb86fe Compare July 22, 2026 20:00
@zbedforrest zbedforrest changed the title feature: ownership oracles (computed ownership from external tooling) feat: ownership oracles (externally computed reviewer requirements) Jul 22, 2026
@zbedforrest
zbedforrest force-pushed the feature/ownership-oracles branch from dbb86fe to 980c869 Compare July 22, 2026 20:15
zbedforrest and others added 8 commits July 22, 2026 13:27
- Parse rejects leading-slash patterns, which are valid per doublestar
  but silently never match repo-relative diff paths
- Parse rejects whitespace-only owners, not just empty strings
- MergeCodeOwners no longer treats optional-only reviewers as conferring
  ownership, so an optional oracle rule cannot suppress the unowned-file
  warning (matches .codeowners semantics)
- README: guidance on protecting the oracle generator script from PR
  tampering, and clarified ownership notes
@zbedforrest
zbedforrest marked this pull request as ready for review August 10, 2026 21:21
@github-actions
github-actions Bot requested a review from BakerNet August 10, 2026 21:22
@github-actions

Copy link
Copy Markdown

Codeowners approval required for this PR:

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