Skip to content

AI-native design editor. Open-source Figma alternative.

ci: keep AI disclosure out of co-author credits

Danila Poyarkov2eef5610d8c1
diff --git a/.claude/settings.json b/.claude/settings.json
new file mode 100644
index 000000000..b7f9b0a62
--- /dev/null
+++ b/.claude/settings.json
@@ -0,0 +1,7 @@
+{
+ "attribution": {
+ "commit": "",
+ "pr": "",
+ "sessionUrl": false
+ }
+}
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 5439dcb8d..9b4f2309b 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -14,7 +14,7 @@ Before opening a PR, read `CONTRIBUTING.md` and `AGENTS.md`. PRs should explain
### AI assistance
-<!-- If an LLM materially helped create or modify this PR, list the model names. Otherwise write “None”. No prompts or transcripts are required. -->
+<!-- If an LLM materially helped create or modify this PR, list the model names. Otherwise write “None”. This is disclosure, not co-authorship; omit tool promotional signatures and session links. No prompts or transcripts are required. -->
Models: None
diff --git a/AGENTS.md b/AGENTS.md
index cbda5cc28..db2aa7648 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -105,6 +105,8 @@ For user-facing work, add one present-tense outcome under the single appropriate
Use Conventional Commits (`feat`, `fix`, `refactor`, `perf`, `docs`, `test`, `build`, `ci`, `chore`) for regular work. Keep subjects short, imperative, and narrowly scoped; explain rationale in the body. Preserve product casing such as DOM/CSS, HTML, JSX, Tailwind, Kiwi, `.fig`, MCP, CLI, AI, ACP, and i18n. Release commits use `Release vX.Y.Z`.
+Keep AI assistance in the PR's AI assistance section, not commit authorship or `Co-authored-by` trailers. Do not append tool-generated promotional signatures or session links. Preserve human co-author credits and required third-party notices. Follow the vendor-neutral attribution policy in `CONTRIBUTING.md`; the existing commitlint gate checks known AI co-author identities without rewriting base history.
+
PR titles use Conventional Commits because GitHub uses them as merge subjects. The separate **PR title** workflow validates titles, including title edits, without rerunning the full CI suite. Preserve the conventional subject when merging via CLI/API; if setting it explicitly with `gh pr merge --subject`, use the validated PR title. Give branch-update merges explicit subjects such as `chore: merge master into <branch>`. Commitlint's default merge exceptions are not a naming convention. Do not rewrite published history solely to normalize messages.
## CLI
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 584e98be7..f239a2c6d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -111,6 +111,14 @@ See [`AGENTS.md`](./AGENTS.md) for the full architecture reference, code convent
Follow the commit-message conventions in [`AGENTS.md`](./AGENTS.md). Update `CHANGELOG.md` for user-facing changes.
+### Attribution
+
+AI-assisted contributions are welcome. Credit human collaborators in commit authorship and `Co-authored-by` trailers; don't add AI assistants as co-authors or append tool-generated promotional signatures. Record AI assistance in the PR's existing AI assistance section instead. Preserve human attribution and required third-party notices.
+
+The committed `.claude/settings.json` disables Claude Code's automatic commit/PR attribution and session links. Other tools should follow the same policy. This does not prohibit AI use, ordinary discussion of tools, or legitimate maintenance-bot workflows.
+
+The Commit messages check flags known AI co-author identities in newly introduced commits, including merge and release commits. If it flags an automatically added trailer, remove only that trailer using the amendment guidance below; keep human credits and the PR disclosure. Unknown identities and promotional prose remain subject to normal review. Existing base-branch history is not rewritten.
+
### Commit messages
The **Commit messages** CI job checks every commit introduced by a PR, including docs-only PRs. It does not lint existing base-branch history or GitHub's synthetic merge commit. The aggregate CI result requires this job to pass.
@@ -119,7 +127,7 @@ Use `type(optional-scope): short description`, for example `fix(MCP): preserve c
PR titles follow the same convention because GitHub uses them as merge subjects. The separate **PR title** workflow checks new and updated PRs, including title edits, without rerunning the full CI suite. Title validation disables commitlint's default merge/revert exceptions. Release titles and commits retain the exact `Release vX.Y.Z` convention.
-Commit-range validation retains commitlint's default merge/revert exceptions, but they are not a naming convention. Preserve the validated PR title when merging via CLI/API, and use explicit conventional subjects for branch updates, for example `chore: merge master into my-branch`. Do not rewrite published history solely to normalize messages. These checks validate structure, not whether a description is meaningful or the type is appropriate.
+Commit-range validation retains commitlint's default merge/revert exceptions, but they are not a naming convention. Preserve the validated PR title when merging via CLI/API, and use explicit conventional subjects for branch updates, for example `chore: merge master into my-branch`. Do not rewrite published history solely to normalize messages. These checks validate structure and known AI co-author identities, not whether a description is meaningful or the type is appropriate.
```sh
bun run check:commits --last
diff --git a/bun.lock b/bun.lock
index 383bea82e..d0c50e58f 100644
--- a/bun.lock
+++ b/bun.lock
@@ -91,6 +91,7 @@
"@arethetypeswrong/cli": "0.18.4",
"@commitlint/cli": "^21.2.2",
"@commitlint/config-conventional": "^21.2.2",
+ "@commitlint/is-ignored": "^21.2.2",
"@commitlint/types": "^21.2.0",
"@feature-sliced/steiger-plugin": "^0.5.8",
"@figma/plugin-typings": "^1.134.0",
diff --git a/commitlint.config.ts b/commitlint.config.ts
index 88eaa4c14..2b7751b6e 100644
--- a/commitlint.config.ts
+++ b/commitlint.config.ts
@@ -1,10 +1,15 @@
+import isIgnored from '@commitlint/is-ignored'
import type { UserConfig } from '@commitlint/types'
+import { hasAICoauthor, noAICoauthors } from './tools/ci/src/commit-attribution'
+
export default {
extends: ['@commitlint/config-conventional'],
- // PR titles must not bypass validation through Git's generated-message exceptions.
- defaultIgnores: process.env.COMMITLINT_PR_TITLE !== '1',
+ // Apply attribution policy before allowing generated-message or release exceptions.
+ defaultIgnores: false,
+ plugins: [{ rules: { 'no-ai-coauthors': noAICoauthors } }],
rules: {
+ 'no-ai-coauthors': [2, 'always'],
'type-enum': [
2,
'always',
@@ -16,6 +21,11 @@ export default {
'body-max-line-length': [0],
'footer-max-line-length': [0]
},
- ignores: [(message) => /^Release v\d+\.\d+\.\d+$/.test(message.split('\n')[0] ?? '')],
+ ignores: [
+ (message) =>
+ !hasAICoauthor(message) &&
+ (/^Release v\d+\.\d+\.\d+$/.test(message.split('\n')[0] ?? '') ||
+ (process.env.COMMITLINT_PR_TITLE !== '1' && isIgnored(message)))
+ ],
helpUrl: 'https://github.com/open-pencil/open-pencil/blob/master/CONTRIBUTING.md#commit-messages'
} satisfies UserConfig
diff --git a/package.json b/package.json
index d532c19e1..9a32ad18b 100644
--- a/package.json
+++ b/package.json
@@ -164,6 +164,7 @@
"@arethetypeswrong/cli": "0.18.4",
"@commitlint/cli": "^21.2.2",
"@commitlint/config-conventional": "^21.2.2",
+ "@commitlint/is-ignored": "^21.2.2",
"@commitlint/types": "^21.2.0",
"@feature-sliced/steiger-plugin": "^0.5.8",
"@figma/plugin-typings": "^1.134.0",
diff --git a/tools/ci/src/commit-attribution.ts b/tools/ci/src/commit-attribution.ts
new file mode 100644
index 000000000..c137847bd
--- /dev/null
+++ b/tools/ci/src/commit-attribution.ts
@@ -0,0 +1,33 @@
+import { execFileSync } from 'node:child_process'
+
+import type { SyncRule } from '@commitlint/types'
+
+// Match tool identities, not people's names or entire vendor domains.
+const AI_COAUTHOR_EMAILS = new Set([
+])
+const AI_GITHUB_EMAIL =
+ /^(?:\d+\+)?(?:claude|copilot|codex|cursoragent|gemini-code-assist|chatgpt-codex-connector)\[bot\]@users\.noreply\.github\.com$/i
+
+export function hasAICoauthor(message: string): boolean {
+ // Git distinguishes real trailers from quoted examples and ordinary body text.
+ const trailers = execFileSync('git', ['interpret-trailers', '--parse'], {
+ input: message,
+ encoding: 'utf8'
+ })
+ return trailers.split('\n').some((line) => {
+ const email = /^co-authored-by:\s*.*<([^<>]+)>\s*$/i.exec(line)?.[1]?.trim().toLowerCase()
+ return email !== undefined && (AI_COAUTHOR_EMAILS.has(email) || AI_GITHUB_EMAIL.test(email))
+ })
+}
+
+export const noAICoauthors: SyncRule = (parsed) => [
+ !hasAICoauthor(parsed.raw),
+ 'AI-assisted contributions are welcome. Remove AI-assistant Co-authored-by trailers and keep disclosure in the PR’s AI assistance section. Preserve human co-author credits.'
+]
diff --git a/tools/ci/tests/commit-messages.test.ts b/tools/ci/tests/commit-messages.test.ts
index 6261af0cd..b33df173c 100644
--- a/tools/ci/tests/commit-messages.test.ts
+++ b/tools/ci/tests/commit-messages.test.ts
@@ -3,6 +3,8 @@ import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
+import { hasAICoauthor } from '#ci/commit-attribution'
+
const root = resolve(import.meta.dir, '../../..')
async function lint(message: string, args: string[] = [], prTitle = false) {
@@ -34,6 +36,54 @@ test.each([
expect(result.code).toBe(0)
})
+test.each([
+ 'fix: document Claude Code and OpenAI integration',
+ 'fix: preserve credits\n\nCo-authored-by: Claude Martin <[email protected]>',
+ 'fix: preserve credits\n\nCo-authored-by: Claude <[email protected]>',
+ 'fix: preserve credits\n\nCo-authored-by: Codex <[email protected]>',
+ 'fix: preserve credits\n\nCo-authored-by: Human Contributor <[email protected]>',
+ 'build: update packages\n\nCo-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>'
+])('preserves ordinary mentions, human credits, and maintenance bots: %s', async (message) => {
+ expect((await lint(message)).code).toBe(0)
+})
+
+test.each([
+ 'Claude Sonnet 5 <[email protected]>',
+ 'Codex <[email protected]>',
+ 'Cursor <[email protected]>',
+ 'Gemini CLI <[email protected]>',
+ 'Copilot <[email protected]>',
+ 'Claude <123+claude[bot]@users.noreply.github.com>'
+])('recognizes known assistant identities: %s', (identity) => {
+ expect(hasAICoauthor(`fix: update\n\nCo-authored-by: ${identity}`)).toBe(true)
+})
+
+test('parses real trailers without treating fenced examples as authorship', () => {
+ expect(
+ hasAICoauthor(
+ 'docs: explain policy\n\n```text\nCo-authored-by: Claude <[email protected]>\n```'
+ )
+ ).toBe(false)
+ expect(
+ hasAICoauthor(
+ 'fix: update\n\nCo-authored-by: Human <[email protected]>\ncO-aUtHoReD-bY: Claude <[email protected]>'
+ )
+ ).toBe(true)
+})
+
+test.each([
+ 'fix: update',
+ 'Merge pull request #1 from contributor/fix',
+ 'Revert "fix: update"',
+ 'Release v0.14.0'
+])('attribution cannot bypass lint through an ignored subject: %s', async (subject) => {
+ const result = await lint(`${subject}\n\nCo-authored-by: Claude <[email protected]>`)
+ expect(result.code).not.toBe(0)
+ expect(result.output).toContain('no-ai-coauthors')
+ expect(result.output).toContain('AI-assisted contributions are welcome')
+ expect(result.output).toContain('Preserve human co-author credits')
+})
+
test.each([
['Fixed stuff', 'type-empty'],
['feature: add tools', 'type-enum'],
@@ -85,7 +135,12 @@ test('checks the full PR range while excluding existing base history', async ()
await git('config', 'user.email', '[email protected]')
await git('config', 'commit.gpgsign', 'false')
await git('config', 'core.hooksPath', join(directory, 'no-hooks'))
- await git('commit', '--allow-empty', '-m', 'Legacy base message')
+ await git(
+ 'commit',
+ '--allow-empty',
+ '-m',
+ 'Legacy base message\n\nCo-authored-by: Claude <[email protected]>'
+ )
const base = await git('rev-parse', 'HEAD')
await git('commit', '--allow-empty', '-m', 'docs: explain setup')
const args = [
@@ -99,11 +154,18 @@ test('checks the full PR range while excluding existing base history', async ()
'HEAD'
]
expect((await lint('', args)).code).toBe(0)
+ await git(
+ 'commit',
+ '--allow-empty',
+ '-m',
+ 'fix: update\n\nCo-authored-by: Claude <[email protected]>'
+ )
await git('commit', '--allow-empty', '-m', 'Bad intermediate commit')
await git('commit', '--allow-empty', '-m', 'fix: valid final commit')
const result = await lint('', args)
expect(result.code).not.toBe(0)
expect(result.output).toContain('Bad intermediate commit')
+ expect(result.output).toContain('no-ai-coauthors')
expect(result.output).not.toContain('Legacy base message')
} finally {
await rm(directory, { recursive: true, force: true })