Skip to content

Commit 0a60c86

Browse files
feat: add 10 AI-powered GitHub Actions workflows (#294)
Add AI agent workflows for the governance toolkit: PR Quality: - ai-code-review.yml — Deep review for policy/trust/sandbox code - ai-security-scan.yml — Security analysis (OWASP Agentic Top 10) - ai-test-generator.yml — Test coverage advisor for 8 packages - ai-breaking-change-detector.yml — Public API compatibility check - ai-docs-sync.yml — Documentation freshness check Scheduled: - ai-repo-health.yml — Weekly OSS health dashboard - ai-owasp-compliance.yml — Weekly OWASP Agentic Top 10 audit Release: - ai-release-notes.yml — Monorepo-aware changelog by package Community: - ai-contributor-guide.yml — First-time contributor helper - ai-spec-drafter.yml — Engineering spec from issues All workflows use GitHub Models API (gpt-4o) via GITHUB_TOKEN with models:read permission. Action SHAs are pinned per OSS security best practices. PR-triggered AI jobs are non-blocking. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8708b9b commit 0a60c86

File tree

11 files changed

+1417
-0
lines changed

11 files changed

+1417
-0
lines changed

.github/actions/ai-agent-runner/action.yml

Lines changed: 413 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# AI-powered breaking change detector for the agent-governance-toolkit.
2+
# Critical for published PyPI packages — detects removed/renamed public APIs,
3+
# changed function signatures, modified exports in __init__.py, and changed
4+
# exception types. Posts findings as a PR comment with severity ratings.
5+
name: AI Breaking Change Detector
6+
7+
on:
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
branches: [main]
11+
paths:
12+
- "packages/*/src/**"
13+
14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
models: read
18+
19+
jobs:
20+
detect-breaking-changes:
21+
name: API Compatibility Check
22+
runs-on: ubuntu-latest
23+
if: >-
24+
github.event.pull_request.draft == false &&
25+
github.actor != 'dependabot[bot]' &&
26+
github.event.pull_request.head.repo.full_name == github.repository
27+
continue-on-error: true
28+
steps:
29+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Run breaking change analysis
34+
uses: ./.github/actions/ai-agent-runner
35+
with:
36+
agent-type: breaking-change-detector
37+
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
model: gpt-4o
39+
fallback-model: gpt-4o-mini
40+
max-tokens: "4000"
41+
context-mode: pr-diff
42+
output-mode: pr-comment
43+
custom-instructions: |
44+
You are an API compatibility analyzer for microsoft/agent-governance-toolkit.
45+
These packages are published to PyPI — breaking changes affect downstream users.
46+
47+
Analyze the diff for:
48+
1. **🔴 Removed/renamed** public functions, classes, or methods
49+
2. **🔴 Changed function signatures** — removed params, changed types, new required params
50+
3. **🔴 Removed/changed exports** in `__init__.py` files
51+
4. **🔴 Changed exception types** — different exceptions raised
52+
5. **🟡 Changed default values** — may alter existing behavior
53+
6. **🟡 Changed return types** — may break callers
54+
7. **🔵 New public API** — not breaking, but should be documented
55+
56+
Classification:
57+
- 🔴 **BREAKING** — will break existing code
58+
- 🟡 **POTENTIALLY BREAKING** — may break depending on usage
59+
- 🔵 **ADDITIVE** — new API, not breaking
60+
61+
If NO breaking changes found, say so clearly with ✅.
62+
63+
Format:
64+
## 🔍 API Compatibility Report
65+
66+
### Summary
67+
(brief overall assessment)
68+
69+
### Findings
70+
| Severity | Package | Change | Impact |
71+
|----------|---------|--------|--------|
72+
| 🔴 | agent-os | `PolicyEngine.evaluate()` removed `strict` param | Callers using `strict=True` will fail |
73+
74+
### Migration Guide
75+
(if breaking changes found, suggest migration steps)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# AI-powered deep code review for the agent-governance-toolkit.
2+
# Analyzes PR diffs for security issues, policy engine correctness,
3+
# trust/identity flaws, sandbox escape vectors, and API compatibility.
4+
# Uses GitHub Models API (gpt-4o) via the ai-agent-runner composite action.
5+
name: AI Code Review
6+
7+
on:
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
branches: [main]
11+
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
models: read
16+
17+
jobs:
18+
ai-review:
19+
name: Deep AI Code Review
20+
runs-on: ubuntu-latest
21+
# Skip bots, draft PRs, and fork PRs (security: don't run on untrusted code)
22+
if: >-
23+
github.event.pull_request.draft == false &&
24+
github.actor != 'dependabot[bot]' &&
25+
github.actor != 'github-actions[bot]' &&
26+
github.event.pull_request.head.repo.full_name == github.repository
27+
continue-on-error: true
28+
steps:
29+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Run AI code review
34+
id: review
35+
uses: ./.github/actions/ai-agent-runner
36+
with:
37+
agent-type: code-reviewer
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
model: gpt-4o
40+
fallback-model: gpt-4o-mini
41+
max-tokens: "4000"
42+
context-mode: pr-diff
43+
output-mode: pr-review
44+
custom-instructions: |
45+
You are reviewing the microsoft/agent-governance-toolkit — a security-focused Python library.
46+
47+
Stack: Python 3.9-3.12, monorepo with 8 packages under packages/, pytest, ruff.
48+
49+
Focus areas:
50+
- Policy engine correctness (false negatives = security bypass)
51+
- Trust/identity: cryptographic operations, credential handling, SPIFFE/SVID
52+
- Sandbox escape vectors
53+
- Thread safety in concurrent agent execution
54+
- OWASP Agentic Top 10 compliance
55+
- Type safety and Pydantic model validation
56+
- Backward compatibility (public API changes)
57+
58+
Provide actionable feedback. Flag security issues as 🔴 CRITICAL.
59+
Flag potential breaking changes as 🟡 WARNING.
60+
Suggest improvements as 💡 SUGGESTION.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# AI-powered contributor helper for the agent-governance-toolkit.
2+
# Welcomes first-time contributors with helpful, personalized context:
3+
# - For issues: analyzes the issue and suggests relevant packages/code areas
4+
# - For PRs: provides a friendly first-PR review with extra guidance
5+
# Builds OSS community by making the contribution experience welcoming.
6+
name: AI Contributor Guide
7+
8+
on:
9+
issues:
10+
types: [opened]
11+
pull_request_target:
12+
types: [opened]
13+
14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
issues: write
18+
models: read
19+
20+
jobs:
21+
guide-issue:
22+
name: Guide First-Time Issue Author
23+
runs-on: ubuntu-latest
24+
# Only trigger for first-time contributors (never seen before or first contribution)
25+
if: >-
26+
github.event_name == 'issues' &&
27+
(github.event.issue.author_association == 'NONE' ||
28+
github.event.issue.author_association == 'FIRST_TIME_CONTRIBUTOR')
29+
continue-on-error: true
30+
steps:
31+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32+
33+
- name: Guide contributor on issue
34+
uses: ./.github/actions/ai-agent-runner
35+
with:
36+
agent-type: contributor-guide
37+
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
model: gpt-4o
39+
fallback-model: gpt-4o-mini
40+
max-tokens: "4000"
41+
context-mode: issue
42+
output-mode: issue-comment
43+
custom-instructions: |
44+
You are a friendly OSS community helper for microsoft/agent-governance-toolkit.
45+
A first-time contributor has opened an issue. Welcome them warmly!
46+
47+
Your response should:
48+
1. **Welcome** them to the project
49+
2. **Analyze** their issue and suggest which package(s) might be relevant:
50+
- agent-os: Core policy engine, agent lifecycle
51+
- agent-mesh: Agent discovery, routing, trust mesh
52+
- agent-hypervisor: Execution sandboxing, resource isolation
53+
- agent-sre: Reliability, chaos testing, SLOs
54+
- agent-compliance: Compliance frameworks, audit logging
55+
- agent-marketplace: Agent registry
56+
- agent-lightning: High-performance inference
57+
- agent-runtime: Runtime execution environment
58+
3. **Point to relevant code** — suggest specific directories to look at
59+
4. **Link to resources**:
60+
- [CONTRIBUTING.md](../blob/main/CONTRIBUTING.md)
61+
- [QUICKSTART.md](../blob/main/QUICKSTART.md)
62+
- [Code of Conduct](../blob/main/CODE_OF_CONDUCT.md)
63+
5. **Offer next steps** — what they can do to help resolve this
64+
65+
Be encouraging and specific. Avoid generic boilerplate.
66+
67+
guide-pr:
68+
name: Guide First-Time PR Author
69+
runs-on: ubuntu-latest
70+
# Only trigger for first-time contributors on PRs
71+
# Uses pull_request_target for security (runs on base branch context)
72+
if: >-
73+
github.event_name == 'pull_request_target' &&
74+
(github.event.pull_request.author_association == 'NONE' ||
75+
github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR')
76+
continue-on-error: true
77+
steps:
78+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
79+
80+
- name: Guide PR author
81+
uses: ./.github/actions/ai-agent-runner
82+
with:
83+
agent-type: contributor-guide
84+
github-token: ${{ secrets.GITHUB_TOKEN }}
85+
model: gpt-4o
86+
fallback-model: gpt-4o-mini
87+
max-tokens: "4000"
88+
context-mode: pr-diff
89+
output-mode: pr-comment
90+
custom-instructions: |
91+
You are a friendly OSS community helper for microsoft/agent-governance-toolkit.
92+
A first-time contributor has opened a pull request. Welcome them!
93+
94+
Your response should:
95+
1. **Welcome** them and thank them for contributing
96+
2. **Review their PR** with extra kindness — explain WHY things should be
97+
different, not just what to change
98+
3. **Highlight what they did well** before suggesting improvements
99+
4. **Explain project conventions**:
100+
- We use ruff for linting (select E,F,W)
101+
- Tests go in packages/{name}/tests/
102+
- We follow conventional commits (feat:, fix:, docs:, etc.)
103+
- Security-sensitive code gets extra scrutiny
104+
5. **Link to resources**:
105+
- [CONTRIBUTING.md](../blob/main/CONTRIBUTING.md)
106+
- [QUICKSTART.md](../blob/main/QUICKSTART.md)
107+
6. **Explain next steps** — what happens in the review process
108+
109+
Be warm, specific, and constructive. First impressions matter for OSS!

.github/workflows/ai-docs-sync.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# AI-powered documentation freshness check for agent-governance-toolkit.
2+
# When a PR touches package source code, verifies that corresponding
3+
# documentation is updated — flags missing docstrings, stale READMEs,
4+
# and changed behavior without CHANGELOG entries.
5+
name: AI Docs Sync Check
6+
7+
on:
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
branches: [main]
11+
paths:
12+
- "packages/*/src/**"
13+
14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
models: read
18+
19+
jobs:
20+
docs-freshness:
21+
name: Documentation Freshness Check
22+
runs-on: ubuntu-latest
23+
if: >-
24+
github.event.pull_request.draft == false &&
25+
github.actor != 'dependabot[bot]' &&
26+
github.event.pull_request.head.repo.full_name == github.repository
27+
continue-on-error: true
28+
steps:
29+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Check documentation freshness
34+
uses: ./.github/actions/ai-agent-runner
35+
with:
36+
agent-type: docs-sync-checker
37+
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
model: gpt-4o
39+
fallback-model: gpt-4o-mini
40+
max-tokens: "4000"
41+
context-mode: pr-diff
42+
output-mode: pr-comment
43+
custom-instructions: |
44+
You are a documentation freshness checker for microsoft/agent-governance-toolkit.
45+
46+
Analyze the PR diff and check:
47+
1. **New public APIs without docstrings** — all public functions, classes, and
48+
methods should have docstrings explaining purpose, parameters, return values,
49+
and exceptions
50+
2. **README sections out of date** — if behavior changes, does the package README
51+
reflect it?
52+
3. **CHANGELOG missing entries** — behavioral changes should have a CHANGELOG.md entry
53+
4. **Example code outdated** — if API signatures change, examples/ should be updated
54+
5. **Type hints** — new public APIs should have complete type annotations
55+
56+
Monorepo structure:
57+
- packages/{name}/src/ — source code
58+
- packages/{name}/README.md — package documentation
59+
- packages/{name}/tests/ — test files
60+
- docs/ — project-level documentation
61+
- CHANGELOG.md — project changelog
62+
63+
Format:
64+
## 📝 Documentation Sync Report
65+
66+
### Issues Found
67+
- ❌ `function_name()` in `package/module.py` — missing docstring
68+
- ⚠️ `package/README.md` — section X may need update for new behavior
69+
- ⚠️ CHANGELOG.md — no entry for this change
70+
71+
### Suggestions
72+
- 💡 Add docstring for `function_name(param1: str, param2: int) -> bool`
73+
- 💡 Update README section "Configuration" to mention new option
74+
75+
If everything looks good, say ✅ Documentation is in sync.

0 commit comments

Comments
 (0)