diff --git a/includes/commit-check.toml b/includes/commit-check.toml deleted file mode 100644 index 8649562..0000000 --- a/includes/commit-check.toml +++ /dev/null @@ -1,10 +0,0 @@ -[commit] -conventional_commits = false -subject_max_length = 72 -subject_min_length = 1 -# Reject LLM session URL trailers -message_pattern = '(?ims)(?!.*^[\w-]+-session:\s)' -ai_attribution = "disclose" -ai_disclosure_trailers = ["Assisted-by"] -# Assisted-by: values must not be email addresses or URLs -ai_disclosure_pattern = '^(?!.*(@|://)).*\S' diff --git a/includes/commit-check.toml.jinja b/includes/commit-check.toml.jinja new file mode 100644 index 0000000..37f0195 --- /dev/null +++ b/includes/commit-check.toml.jinja @@ -0,0 +1,15 @@ +[commit] +conventional_commits = false +subject_max_length = 72 +subject_min_length = 1 +# Reject LLM session URL trailers and promotional "Generated with" lines +message_pattern = '(?ims)(?!.*^(?:[\w-]+-session:\s|\W*generated (?:with|by) \S))' +{%- if llm_contribution_policy == "not-accepted" %} +ai_attribution = "forbid" +{%- else %} +ai_attribution = "disclose" +ai_disclosure_trailers = ["Assisted-by"] +# Assisted-by: values must not be email addresses or URLs +ai_disclosure_pattern = '^(?!.*(@|://)).*\S' +{%- endif %} +{#- vim: set ft=toml: #} diff --git a/template/{% if enable_commit_check and project_visibility == 'private' %}commit-check.toml{% endif %}.jinja b/template/{% if enable_commit_check and project_visibility == 'private' %}commit-check.toml{% endif %}.jinja index 8727aaa..94b7fb3 100644 --- a/template/{% if enable_commit_check and project_visibility == 'private' %}commit-check.toml{% endif %}.jinja +++ b/template/{% if enable_commit_check and project_visibility == 'private' %}commit-check.toml{% endif %}.jinja @@ -1 +1 @@ -{%- include pathjoin("includes", "commit-check.toml") -%} +{%- include pathjoin("includes", "commit-check.toml.jinja") -%} diff --git a/template/{% if project_visibility == 'public' %}.github{% endif %}/{% if enable_commit_check %}commit-check.toml{% endif %}.jinja b/template/{% if project_visibility == 'public' %}.github{% endif %}/{% if enable_commit_check %}commit-check.toml{% endif %}.jinja index 8727aaa..94b7fb3 100644 --- a/template/{% if project_visibility == 'public' %}.github{% endif %}/{% if enable_commit_check %}commit-check.toml{% endif %}.jinja +++ b/template/{% if project_visibility == 'public' %}.github{% endif %}/{% if enable_commit_check %}commit-check.toml{% endif %}.jinja @@ -1 +1 @@ -{%- include pathjoin("includes", "commit-check.toml") -%} +{%- include pathjoin("includes", "commit-check.toml.jinja") -%} diff --git a/template/{% if project_visibility == 'public' %}CONTRIBUTING.md{% endif %}.jinja b/template/{% if project_visibility == 'public' %}CONTRIBUTING.md{% endif %}.jinja index 454a8fc..3b21275 100644 --- a/template/{% if project_visibility == 'public' %}CONTRIBUTING.md{% endif %}.jinja +++ b/template/{% if project_visibility == 'public' %}CONTRIBUTING.md{% endif %}.jinja @@ -44,16 +44,24 @@ LLM-generated code or text, and be able to explain it on request. {%- elif llm_contribution_policy == "accepted-with-disclosure" -%} You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. +Contributions must be submitted by a person, not autonomously by a bot or +LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. +Do not include LLM session URLs, or promotional lines such as +"Generated with [...]." {%- elif llm_contribution_policy == "not-accepted" -%} You may use LLM tools to help you understand code, run commands, or plan your work. However, code and text you submit must be authored by you, not generated by an LLM. + +Commits with LLM attribution are rejected. This includes `Assisted-by:` or +`Co-authored-by:` trailers, LLM session URLs, and promotional lines such as +"Generated with [...]". {%- endif %} {%- if not enable_docs %} diff --git a/tests/template/__snapshots__/test_commit_check.ambr b/tests/template/__snapshots__/test_commit_check.ambr new file mode 100644 index 0000000..8ae409a --- /dev/null +++ b/tests/template/__snapshots__/test_commit_check.ambr @@ -0,0 +1,55 @@ +# serializer version: 1 +# name: test_commit_check_config[private-commit-check.toml-accepted-with-disclosure] + ''' + [commit] + conventional_commits = false + subject_max_length = 72 + subject_min_length = 1 + # Reject LLM session URL trailers and promotional "Generated with" lines + message_pattern = '(?ims)(?!.*^(?:[\w-]+-session:\s|\W*generated (?:with|by) \S))' + ai_attribution = "disclose" + ai_disclosure_trailers = ["Assisted-by"] + # Assisted-by: values must not be email addresses or URLs + ai_disclosure_pattern = '^(?!.*(@|://)).*\S' + + ''' +# --- +# name: test_commit_check_config[private-commit-check.toml-not-accepted] + ''' + [commit] + conventional_commits = false + subject_max_length = 72 + subject_min_length = 1 + # Reject LLM session URL trailers and promotional "Generated with" lines + message_pattern = '(?ims)(?!.*^(?:[\w-]+-session:\s|\W*generated (?:with|by) \S))' + ai_attribution = "forbid" + + ''' +# --- +# name: test_commit_check_config[public-.github/commit-check.toml-accepted-with-disclosure] + ''' + [commit] + conventional_commits = false + subject_max_length = 72 + subject_min_length = 1 + # Reject LLM session URL trailers and promotional "Generated with" lines + message_pattern = '(?ims)(?!.*^(?:[\w-]+-session:\s|\W*generated (?:with|by) \S))' + ai_attribution = "disclose" + ai_disclosure_trailers = ["Assisted-by"] + # Assisted-by: values must not be email addresses or URLs + ai_disclosure_pattern = '^(?!.*(@|://)).*\S' + + ''' +# --- +# name: test_commit_check_config[public-.github/commit-check.toml-not-accepted] + ''' + [commit] + conventional_commits = false + subject_max_length = 72 + subject_min_length = 1 + # Reject LLM session URL trailers and promotional "Generated with" lines + message_pattern = '(?ims)(?!.*^(?:[\w-]+-session:\s|\W*generated (?:with|by) \S))' + ai_attribution = "forbid" + + ''' +# --- diff --git a/tests/template/__snapshots__/test_contributing.ambr b/tests/template/__snapshots__/test_contributing.ambr index 7de0ed3..9a1e724 100644 --- a/tests/template/__snapshots__/test_contributing.ambr +++ b/tests/template/__snapshots__/test_contributing.ambr @@ -183,12 +183,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -221,12 +225,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ## Development documentation @@ -350,6 +358,10 @@ work. However, code and text you submit must be authored by you, not generated by an LLM. + Commits with LLM attribution are rejected. This includes `Assisted-by:` or + `Co-authored-by:` trailers, LLM session URLs, and promotional lines such as + "Generated with [...]". + ''' # --- # name: test_contributing_features[not-accepted-no_docs] @@ -383,6 +395,10 @@ work. However, code and text you submit must be authored by you, not generated by an LLM. + Commits with LLM attribution are rejected. This includes `Assisted-by:` or + `Co-authored-by:` trailers, LLM session URLs, and promotional lines such as + "Generated with [...]". + ## Development documentation ### Prerequisites @@ -503,12 +519,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -543,12 +563,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -583,12 +607,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -623,12 +651,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -663,12 +695,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -703,12 +739,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -743,12 +783,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -783,12 +827,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -823,12 +871,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -863,12 +915,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -903,12 +959,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -943,12 +1003,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- @@ -983,12 +1047,16 @@ A contributor is always the author of their contributions. You must read, review, and understand everything you submit, including LLM-generated code or text, and be able to explain it on request. + Contributions must be submitted by a person, not autonomously by a bot or + LLM agent. If a commit contains code or text largely generated by an LLM, add an `Assisted-by: :` trailer to its message. This can be done automatically with `git commit --trailer="Assisted-by: :"`. Do not use `Co-authored-by:` for LLM attribution. LLMs are tools, not authors. + Do not include LLM session URLs, or promotional lines such as + "Generated with [...]." ''' # --- diff --git a/tests/template/test_commit_check.py b/tests/template/test_commit_check.py index 81ca51d..d5b0ed3 100644 --- a/tests/template/test_commit_check.py +++ b/tests/template/test_commit_check.py @@ -4,13 +4,16 @@ import pytest -from tests.utils import template - if TYPE_CHECKING: from collections.abc import Callable from pathlib import Path + from syrupy.assertion import SnapshotAssertion + +@pytest.mark.parametrize( + "llm_contribution_policy", ["accepted-with-disclosure", "not-accepted"] +) @pytest.mark.parametrize( ("project_visibility", "config_path"), [ @@ -20,10 +23,13 @@ ) def test_commit_check_config( render_template: Callable[..., Path], + snapshot: SnapshotAssertion, project_visibility: str, config_path: str, + llm_contribution_policy: str, ) -> None: - rendered = render_template(project_visibility=project_visibility) - assert (rendered / config_path).read_text() == ( - template.dir / "includes" / "commit-check.toml" - ).read_text() + rendered = render_template( + project_visibility=project_visibility, + llm_contribution_policy=llm_contribution_policy, + ) + assert (rendered / config_path).read_text() == snapshot