-
-
Notifications
You must be signed in to change notification settings - Fork 387
docs: add AI usage policy for contributors #2111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9dc703b
docs: add AI usage policy for contributors
derberg 674ff01
Update AI-POLICY.md
derberg 83c8321
Update pull-request-template.md
derberg b5f3e66
Update AI-assisted contribution disclosure requirements
derberg 4e54703
Merge branch 'master' into aipolicy
Adi-204 94d4a00
Merge branch 'master' into aipolicy
Adi-204 0f3b960
Merge branch 'master' into aipolicy
derberg ec773ea
Update CODEOWNERS
derberg b521ec3
Merge branch 'master' into aipolicy
derberg 79e8fc6
Merge branch 'master' into aipolicy
derberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Purpose of this workflow is to enforce the AI Usage Policy (AI-POLICY.md): | ||
| # every pull request must declare whether it was AI-assisted, either by providing | ||
| # a non-empty `Generated-by:` line or by checking the "No AI assistance" box. | ||
| # This verifies that a declaration is PRESENT - it cannot verify its truthfulness. | ||
| # | ||
| # Why pull_request_target instead of pull_request: the check must be able to post a | ||
| # comment on pull requests opened from forks, and the plain `pull_request` event only | ||
| # grants a read-only token for forks. | ||
| # | ||
| # Security: this is hardened against the classic PR-body script-injection vector. | ||
| # - No `${{ }}` expression interpolation: the body is read at runtime as a JS value | ||
| # via context.payload.pull_request.body, never substituted into code. | ||
| # - The body is treated purely as data (regex/string ops); never eval'd, shelled, | ||
| # or passed to a `run:` step. | ||
| # - pull_request_target is safe because there is NO checkout - PR code is never | ||
| # fetched or executed, so the write-scoped token is never exposed to it. | ||
| # - The failure comment is static text and does not echo back the PR body. | ||
| # - Token is scoped to `pull-requests: write` only. | ||
| name: Verify AI disclosure | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: | ||
| - opened | ||
| - edited | ||
| - reopened | ||
| - synchronize | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| verify-ai-disclosure: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check PR body for AI-assistance disclosure | ||
| uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 | ||
| with: | ||
| script: | | ||
| const MARKER = '<!-- ai-disclosure-check -->'; | ||
| const policyUrl = 'https://github.com/asyncapi/generator/blob/master/AI-POLICY.md'; | ||
| const body = context.payload.pull_request.body || ''; | ||
| // Strip HTML comments so example text inside <!-- --> doesn't count as a real declaration. | ||
| const stripped = body.replace(/<!--[\s\S]*?-->/g, ''); | ||
|
|
||
| const noAiChecked = /- \[x\]\s*No AI assistance/i.test(stripped); | ||
|
|
||
| // Match only horizontal whitespace after the colon so an empty | ||
| // `Generated-by:` line does not swallow the following line as its value. | ||
| const values = [...stripped.matchAll(/Generated-by:[ \t]*([^\n]*)/gi)] | ||
| .map(m => m[1].replace(/`/g, '').trim()) | ||
| .filter(v => v.length > 0); | ||
| const generatedByValue = values[0] || ''; | ||
| const hasGeneratedBy = values.length > 0; | ||
|
|
||
| const { owner, repo } = context.repo; | ||
| const issue_number = context.payload.pull_request.number; | ||
|
|
||
| // Find a previous comment from this check so we update/remove it instead of spamming. | ||
| const comments = await github.paginate(github.rest.issues.listComments, { | ||
| owner, repo, issue_number, per_page: 100, | ||
| }); | ||
| const existing = comments.find(c => (c.body || '').includes(MARKER)); | ||
|
|
||
| if (noAiChecked || hasGeneratedBy) { | ||
| core.info( | ||
| hasGeneratedBy | ||
| ? `AI assistance disclosed: Generated-by: ${generatedByValue}` | ||
| : 'Declared: no AI assistance used.' | ||
| ); | ||
| // PR is now compliant - clean up any earlier failure comment. | ||
| if (existing) { | ||
| await github.rest.issues.deleteComment({ owner, repo, comment_id: existing.id }); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| const message = [ | ||
| MARKER, | ||
| '### ⚠️ Missing AI-assistance disclosure', | ||
| '', | ||
| `Per our [AI Usage Policy](${policyUrl}), every pull request must declare whether generative AI assisted in creating it. Please **edit this PR description** to do one of the following:`, | ||
| '', | ||
| '- If AI assisted, add a line naming the tool and version, for example:', | ||
| ' ```', | ||
| ' Generated-by: Claude Code 1.x', | ||
| ' ```', | ||
| '- If no AI was used, check the **"No AI assistance was used"** box in the PR template.', | ||
| '', | ||
| 'This check re-runs whenever you edit the description, and this comment will disappear once a declaration is present. Note that it confirms a declaration *exists* — it does not verify its accuracy; you remain accountable for everything you submit.', | ||
| ].join('\n'); | ||
|
|
||
| if (existing) { | ||
| await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body: message }); | ||
| } else { | ||
| await github.rest.issues.createComment({ owner, repo, issue_number, body: message }); | ||
| } | ||
|
|
||
| core.setFailed(`Missing AI-assistance disclosure. See ${policyUrl}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # AI Usage Policy | ||
|
|
||
| This policy governs the use of generative AI and AI-assisted tooling (LLMs, coding agents, autocomplete assistants, and similar) when contributing to this repository. | ||
|
|
||
| > **AI tools are instruments; humans are the only authors.** | ||
|
|
||
| You may use AI tools to help you contribute. But the moment you open a pull request or an issue, **you** are the author of every line in it. The tool is not a co-maintainer, it is not accountable, and it cannot be cited as an excuse. This policy exists so that AI accelerates good contributions without lowering the bar for quality, security, or trust. | ||
|
|
||
| This is a contributor-facing policy. It is **not** the same as [`AGENTS.md`](AGENTS.md): that file instructs coding agents on *how to write code that fits this repository*, whereas this policy defines *the rules and expectations for humans who use AI to contribute here*. | ||
|
|
||
| ## When this applies | ||
|
|
||
| This policy applies to **any** contribution where a generative AI tool materially assisted in producing the content, including: | ||
|
|
||
| - source code, tests, and configuration, | ||
| - documentation and template content, | ||
| - issue descriptions, and | ||
| - review comments. | ||
|
|
||
| If you only used AI for spell-checking, search, or to understand existing code, disclosure is not required. If AI generated or substantially shaped the content you are submitting, it is. | ||
|
|
||
| ## Your responsibilities as a contributor | ||
|
|
||
| Before you submit AI-assisted work, you must: | ||
|
|
||
| 1. **Review it thoroughly.** Read and understand every part of the contribution. If you do not understand it, do not submit it. | ||
| 2. **Verify quality.** Ensure it meets this project's standards — it builds, tests pass, and it follows the conventions in [`CONTRIBUTING.md`](CONTRIBUTING.md) and [`AGENTS.md`](AGENTS.md). | ||
| 3. **Remove extraneous changes.** Strip out unrelated edits, dead code, speculative abstractions, and noise the tool introduced. Keep the diff focused. | ||
| 4. **Be prepared to explain it.** You must be able to justify any part of the contribution if a maintainer asks. "The AI wrote it" is not an answer. | ||
| 5. **Accept responsibility.** You bear full accountability for the contribution, exactly as if you had written every line by hand. | ||
| 6. **Check licensing.** Confirm that generated material does not reproduce code under incompatible licenses and does not violate this project's [license](LICENSE). | ||
|
|
||
| > Blindly copy-pasting AI output introduces security and stability risks. Maintainers may close such pull requests without review. | ||
|
|
||
| ## Required disclosure | ||
|
|
||
| If a contribution was materially AI-assisted, you **must** disclose it: | ||
|
|
||
| - **Pull requests:** include a `Generated-by:` line in the PR description naming the tool and its version, for example: | ||
|
|
||
| ``` | ||
| Generated-by: Claude Code 1.x | ||
| Generated-by: GitHub Copilot | ||
| ``` | ||
|
|
||
| The pull request template carries a dedicated AI-assistance section — fill in the `Generated-by:` line, or check the "no AI assistance" box if it does not apply. A CI check verifies that one of the two is present; it confirms a declaration exists, it does not and cannot verify its truthfulness. | ||
|
|
||
| - **Issues:** note in the issue body that AI assisted in drafting it. | ||
|
|
||
| Disclosure is a sign of good faith, not an admission of wrongdoing. We welcome AI-assisted contributions that follow this policy. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Maintainers may **close non-compliant pull requests without review**, including undisclosed AI-generated PRs and PRs the contributor cannot explain. | ||
| - **Repeated violations** are treated as a breach of our [Code of Conduct](CODE_OF_CONDUCT.md) and may result in the contributor being blocked. | ||
|
|
||
| If you are unsure whether something falls under this policy, ask a maintainer in the `#generator` channel on [AsyncAPI Slack](https://www.asyncapi.com/slack-invite) before submitting. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.