feat: add CODEOWNERS integration by carlos-alm · Pull Request #195 · optave/ops-codegraph-tool · GitHub
Skip to content

feat: add CODEOWNERS integration#195

Merged
carlos-alm merged 1 commit into
mainfrom
feat/codeowners
Mar 1, 2026
Merged

feat: add CODEOWNERS integration#195
carlos-alm merged 1 commit into
mainfrom
feat/codeowners

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

  • Add src/owners.js module: CODEOWNERS parser, matcher, and data functions (ownersData, ownersForFiles, owners CLI display)
  • Add codegraph owners [target] CLI command with --owner, --boundary, -f, -k, -T, -j options
  • Add code_owners MCP tool for AI agent access
  • Integrate ownership into diff-impact: shows affected owners and suggested reviewers
  • No new dependencies — CODEOWNERS glob patterns handled by a ~30-line patternToRegex
  • No DB schema changes — ownership derived at query time from CODEOWNERS + node file paths
  • Graceful degradation when no CODEOWNERS file exists

Closes #18

Test plan

  • 21 unit tests for parser, regex, matching, file discovery (tests/unit/owners.test.js)
  • 12 integration tests with temp DB + CODEOWNERS fixture (tests/integration/owners.test.js)
  • MCP tool list test updated (tests/unit/mcp.test.js)
  • Manual: create CODEOWNERS, run codegraph owners, codegraph owners --boundary, codegraph diff-impact --staged

Map graph nodes to CODEOWNERS entries, show ownership coverage,
per-owner breakdown, and cross-owner boundary edges. Integrates
ownership into diff-impact output with affected owners and
suggested reviewers. Exposes code_owners MCP tool.

Impact: 10 functions changed, 12 affected
@claude

claude Bot commented Mar 1, 2026

Copy link
Copy Markdown

@greptile-apps

greptile-apps Bot commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds comprehensive CODEOWNERS integration to codegraph, enabling ownership tracking and reviewer suggestions without external dependencies.

Key Changes:

  • New src/owners.js module with CODEOWNERS parser, glob-to-regex pattern matcher (~30 lines), and ownership query functions
  • CLI command codegraph owners [target] with filters for owner, boundary analysis, file, kind, and test exclusion
  • MCP tool code_owners for AI agent access to ownership data
  • Enhanced diff-impact to show affected owners and suggested reviewers automatically
  • 33 tests (21 unit + 12 integration) covering parser, patterns, queries, filters, and edge cases

Implementation Quality:

  • Zero new dependencies—custom pattern-to-regex handles CODEOWNERS glob semantics (anchored /, wildcards * and **, directory matching, bare filenames)
  • Graceful degradation when CODEOWNERS is missing (returns empty results, doesn't error)
  • Follows existing codegraph patterns (CLI structure, MCP tool schema, query integration)
  • Last-match-wins semantics for overlapping patterns (per CODEOWNERS spec)
  • Cross-owner boundary analysis shows collaboration points between teams

No Issues Found:
The implementation is clean, well-tested, and follows project conventions. Pattern matching logic is correct and handles edge cases properly.

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • Clean implementation with comprehensive test coverage (33 tests), no breaking changes, proper error handling, and graceful degradation. The pattern-to-regex conversion logic is correct, all integrations follow existing patterns, and the feature is fully self-contained with no external dependencies.
  • No files require special attention

Important Files Changed

Filename Overview
src/owners.js New module implementing CODEOWNERS parser with pattern matching, ownership queries, and CLI display. Clean implementation with good separation of concerns.
src/cli.js Adds codegraph owners [target] command with standard options (--owner, --boundary, -f, -k, -T, -j). Follows existing CLI patterns.
src/mcp.js Adds code_owners MCP tool with proper schema definition and handler integration. Consistent with existing tool patterns.
src/queries.js Integrates ownership into diff-impact output, adding affected owners and suggested reviewers. Wrapped in try-catch for graceful degradation.
tests/unit/owners.test.js Comprehensive unit tests covering parser, regex conversion, pattern matching, and file discovery across standard CODEOWNERS locations (21 tests).
tests/integration/owners.test.js Integration tests with temp DB fixture covering ownership queries, filters (--owner, --file, --noTests, --kind, --boundary), and graceful degradation (12 tests).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[CODEOWNERS file] --> B[parseCodeowners]
    B --> C[parseCodeownersContent]
    C --> D[patternToRegex]
    D --> E[Compiled Rules<br/>pattern, owners, regex]
    
    E --> F[ownersData<br/>Full ownership queries]
    E --> G[ownersForFiles<br/>Lightweight helper]
    
    F --> H[CLI: codegraph owners]
    F --> I[MCP: code_owners tool]
    G --> J[diff-impact integration]
    
    K[File paths from DB] --> F
    L[Changed files from git] --> J
    
    J --> M[Affected Owners<br/>Suggested Reviewers]
    F --> N[Coverage Stats<br/>Boundary Analysis<br/>Per-Owner Breakdown]
    
    style A fill:#e1f5ff
    style E fill:#fff4e1
    style M fill:#e8f5e9
    style N fill:#e8f5e9
Loading

Last reviewed commit: 6d1992c

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@carlos-alm carlos-alm merged commit 36c6fdb into main Mar 1, 2026
17 checks passed
@carlos-alm carlos-alm deleted the feat/codeowners branch March 1, 2026 23:47
carlos-alm added a commit that referenced this pull request Mar 2, 2026
Mark backlog items as DONE: streaming/pagination (#207), hybrid
BM25+semantic search (#198), CODEOWNERS (#195), snapshots (#192),
TF-IDF search (subsumed by #198).

Update README: add CODEOWNERS, snapshots, hybrid search, pagination
sections; update MCP tool count to 26/27; add --mode, --ndjson,
--limit, --offset flags; update feature comparison tables with verified
competitor data.
carlos-alm added a commit that referenced this pull request Mar 2, 2026
Mark backlog items as DONE: streaming/pagination (#207), hybrid
BM25+semantic search (#198), CODEOWNERS (#195), snapshots (#192),
TF-IDF search (subsumed by #198).

Update README: add CODEOWNERS, snapshots, hybrid search, pagination
sections; update MCP tool count to 26/27; add --mode, --ndjson,
--limit, --offset flags; update feature comparison tables with verified
competitor data.
carlos-alm added a commit that referenced this pull request Mar 2, 2026
Mark backlog items as DONE: streaming/pagination (#207), hybrid
BM25+semantic search (#198), CODEOWNERS (#195), snapshots (#192),
TF-IDF search (subsumed by #198).

Update README: add CODEOWNERS, snapshots, hybrid search, pagination
sections; update MCP tool count to 26/27; add --mode, --ndjson,
--limit, --offset flags; update feature comparison tables with verified
competitor data.
Zeeeepa pushed a commit to Zeeeepa/codegraph that referenced this pull request Jun 22, 2026
…ave#195)

Map graph nodes to CODEOWNERS entries, show ownership coverage,
per-owner breakdown, and cross-owner boundary edges. Integrates
ownership into diff-impact output with affected owners and
suggested reviewers. Exposes code_owners MCP tool.

Impact: 10 functions changed, 12 affected
Zeeeepa pushed a commit to Zeeeepa/codegraph that referenced this pull request Jun 22, 2026
Mark backlog items as DONE: streaming/pagination (optave#207), hybrid
BM25+semantic search (optave#198), CODEOWNERS (optave#195), snapshots (optave#192),
TF-IDF search (subsumed by optave#198).

Update README: add CODEOWNERS, snapshots, hybrid search, pagination
sections; update MCP tool count to 26/27; add --mode, --ndjson,
--limit, --offset flags; update feature comparison tables with verified
competitor data.
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