Skip to content

[RFC] doc: modernize the contribution documentation and add an agent baseline - #15054

Draft
RonnyPfannschmidt wants to merge 7 commits into
pytest-dev:mainfrom
RonnyPfannschmidt:doc/contributing-modernization
Draft

RonnyPfannschmidt wants to merge 7 commits into
pytest-dev:mainfrom
RonnyPfannschmidt:doc/contributing-modernization

Conversation

@RonnyPfannschmidt

@RonnyPfannschmidt RonnyPfannschmidt commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

CONTRIBUTING.rst was 648 lines serving four audiences, with setup instructions older than uv.lock, and an AI policy that called disclosure optional. Seven commits, each readable on its own.

Tooling: uv leads (uv sync --group dev, uv run pytest), and the pip path is kept for those without it. tox -e py replaces pinned py312/py313. Adds pre-commit run -a as the CI-equivalent check. Also documents the trap that costs newcomers an afternoon: the suite spawns pytest subprocesses with a scrubbed environment, so a user-site pytest vanishes for them. Drops the two "follow PEP-8 for naming" asides, since ruff decides that.

Split by audience: merge/squash, backporting, stale handling and the close-a-stalled-PR wording are team process, not contributor steps. They move to doc/en/maintenance.rst, together with the plugin-transfer runbook and the test-me-* branch trigger, which was previously documented only in test.yml. "Joining the Development Team" stays put.

Backporting: was written as a choice between an automatic and a manual method. Patchback does it off the label, and the hand cherry-pick is the fallback when it conflicts. "Who does the backporting" is recast to match.

AI policy: requirements and rationale were interleaved across ninety lines. They are now split into "What we require" and "Why this policy exists". The policy is also stricter, as agreed in pytest-dev/meta-core discussion 73 (core team only):

  • Disclosing generated content is mandatory, for maintainers too: a Co-authored-by or Assisted-by trailer naming tool and model, a note in the PR description, and a lead line on generated comments and reviews.
  • Denying AI use or stripping it from authorship gets the account banned. Adding a forgotten disclosure when asked is fine.
  • Blatant bots are banned: self-declared unreviewed output, or PRs sprayed across many repositories within minutes.
  • Maintainers may land their own fix for a bug a closed PR pointed at, under the same duties plus a second maintainer's review.
  • The PR template's disclosure checkbox is required again, and maintenance.rst says to keep the trailers when squashing.

This covers pytest only. A shared policy template for other pytest-dev projects is planned separately. #15446 makes attribution mandatory in the same paragraph; this PR includes that change.

AGENTS.md: the policy lived only where humans read it. This is what the harnesses read: setup, layout and conventions. First comes the rule that unsupervised agents hand their work back, and that a supervised agent pushes, opens or comments only after its human has read the exact text and typed a go for that action. CLAUDE.md points at it, so there is one text, not two that drift.

Deliberately not included: a .claude/settings.json deny-list and a PreToolUse hook. Those have real teeth for one vendor and are easy to add later. The failure mode we actually see is well-meaning people running well-behaved harnesses that were never told anything, and this removes the "nobody told me" case first.

RFC and draft, because the split and the shape of AGENTS.md are what's worth arguing about, ahead of wording.

Docs build clean under -W --keep-going; pre-commit run -a green.

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 17, 2026
@RonnyPfannschmidt
RonnyPfannschmidt force-pushed the doc/contributing-modernization branch from 2a6c510 to d77f78b Compare September 23, 2026 07:00
@RonnyPfannschmidt
RonnyPfannschmidt force-pushed the doc/contributing-modernization branch 2 times, most recently from d4936f3 to 075e996 Compare October 11, 2026 07:26
@RonnyPfannschmidt
RonnyPfannschmidt force-pushed the doc/contributing-modernization branch from 075e996 to a47df4e Compare October 14, 2026 20:28
RonnyPfannschmidt and others added 7 commits November 25, 2026 19:09
The setup instructions predated uv.lock and tox-uv: they installed
pre-commit and tox with `pip install --user`, and pinned tox environments
to interpreter versions (py312, py313) that the envlist has since moved
past.  `uv sync --group dev` was mentioned once, as an alternative to a
hand-rolled venv.

Lead with uv, keep the pip path for people who do not have it, and use
`tox -e py` rather than naming an interpreter.  Document `pre-commit run
-a` as the check CI performs, and that pyright/pylint/pyupgrade are
manual-stage hooks that run nowhere by default.

Drop the two "follow PEP-8 for naming" asides: ruff-format and ruff-check
decide this, and pre-commit applies them.  Point the changelog steps at
changelog/README.rst instead of listing the types a third and fourth
time.

Also record the trap that costs newcomers an afternoon: parts of the
suite launch pytest in subprocesses with a scrubbed environment, so a
pytest that is only visible through the user site-packages vanishes for
those children.

Add a short map of the tree, and link the backwards compatibility and
deprecation policies from the section about implementing features.

Co-Authored-By: Claude Opus 5 (1M context) via Claude Code <noreply@anthropic.com>
CONTRIBUTING.rst served four audiences at once.  Everything from the
merge/squash guidelines down -- backporting, stale issue handling, the
wording for closing a stalled pull request -- is process the team
performs, not steps a contributor takes, and it made up a third of the
document a first-time contributor has to wade through.

Move it to doc/en/maintenance.rst, along with the repository transfer
runbook that sat inside the plugin submission section, and add the
`test-me-*` branch trigger, which was documented only in the workflow
file.

CONTRIBUTING.rst keeps "Joining the Development Team", since that answers
a contributor's question, and hands over to the new guide from there.

Links from CONTRIBUTING.rst use explicit URLs rather than :ref:, because
that file is also rendered by GitHub.

Co-Authored-By: Claude Opus 5 (1M context) via Claude Code <noreply@anthropic.com>
The policy ran ninety lines of interleaved requirement and argument, so
the part a contributor has to comply with could not be quoted without
the part that explains our mood.  Split it: "What we require" carries the
four requirements, "Why this policy exists" carries the reasoning,
including the paragraphs that moved down out of the requirements.

Drop the name of a specific agentic tool from the rationale -- the
problem is the mode of use, and naming a product dates the text.

The pull request template listed `Co-authored-by` trailers as a checklist
item, which reads as a requirement, while the policy calls them optional.
Move it into the note above as the suggestion it is.

Co-Authored-By: Claude Opus 5 (1M context) via Claude Code <noreply@anthropic.com>
The AI policy has so far existed only where a human reads it, which is
not where it is needed: an agent pointed at this repository picks up no
project context at all, invents its own idea of how to run the tests, and
learns nothing about what we do and do not accept.

AGENTS.md is the file the current crop of agent harnesses reads by
convention; CLAUDE.md points at it so there is one text, not two that
drift. It gives an agent the setup that actually works (tags, uv, why a
user-site pytest breaks the subprocess tests), the layout, the
conventions that reviewers would otherwise have to ask for, and -- first,
because it is the part that matters -- the instruction to hand the work
back to a human instead of opening a pull request.

This is prose, and it stops only an agent that reads and honours it. That
is deliberate for now: it removes the "nobody told me" case, which is
most of what we actually see, without putting enforcement machinery in
the repository before we know what it would need to catch.

Co-Authored-By: Claude Opus 5 (1M context) via Claude Code <noreply@anthropic.com>
The section presented an "automatic method" and a "manual method" as two
equally available options, which has not matched practice for a long
time: patchback does the backports off the `backport x.x.x` label, and
the cherry-pick by hand is what happens when it hits a conflict and gives
up.

Say that, and recast "who does the backporting" accordingly -- applying
the label is part of merging, and the question of who does the work only
arises once patchback has failed.

Co-Authored-By: Claude Opus 5 (1M context) via Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) via Claude Code <noreply@anthropic.com>
The policy called attribution optional, which contradicts what the core
team agreed: disclosure is required for everyone, maintainers included,
and hiding it is what gets an account banned.

- CONTRIBUTING.rst: generated code, commits, PR descriptions, comments
  and reviews are disclosed (trailer naming tool and model, a note in the
  PR, a lead line on comments); denying or stripping it ends in a ban,
  forgetting does not; blatant bots are banned; maintainers may land
  replacement fixes for closed PRs under the same duties plus a second
  maintainer's review.
- PR template: the disclosure checkbox is required again.
- AGENTS.md: trailers are required, and a supervised agent takes no
  outward action without a go its human typed for that action.
- maintenance.rst: keep the trailers when squashing.

Co-Authored-By: Claude Opus 5.5 via Claude Code <noreply@anthropic.com>
> **Unsupervised agentic contributions are not accepted**. See our [AI/LLM-Assisted Contributions Policy](https://github.com/pytest-dev/pytest/blob/main/CONTRIBUTING.rst#aillm-assisted-contributions-policy), and [AGENTS.md](https://github.com/pytest-dev/pytest/blob/main/AGENTS.md) if you are configuring an agent to work on pytest.

- [ ] If AI agents were used, they are credited in `Co-authored-by` commit trailers.
- [ ] AI use is disclosed: `Co-authored-by`/`Assisted-by` trailers and a note in this description.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Plz forbid Co-authored-by — these are for the actual authors, not probabilistic machines. The agent vendors just abuse them for self-advertisement because they'd render Claude logo all over GitHub. Make the guardrails do the same.

Comment thread AGENTS.md

```console
$ git fetch --tags https://github.com/pytest-dev/pytest
$ uv sync --group dev

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This shouldn't encourage robots bypass tox. We should do the opposite. They already tend to run incorrectly configured commands by calling the underlying tools. If the contributors want to bypass, they should do so based on some reasoning in specific situations.

Comment thread AGENTS.md
failures have nothing to do with the change under test.

```console
$ uv run pytest testing/test_config.py # a single module

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See above.

In another project, I have a thin proxy entry point layer (https://github.com/ansible/pylibssh/blob/66a52439dfb68adce09920a018f7c1f71bb3072b/CLAUDE.md?plain=1 / https://github.com/ansible/pylibssh/blob/66a52439dfb68adce09920a018f7c1f71bb3072b/AGENTS.md?plain=1), and then dedicated topic instructions like so: https://github.com/ansible/pylibssh/blob/66a52439dfb68adce09920a018f7c1f71bb3072b/.agents-ctx/CONTRIB_WORKFLOW_INFRA_TOOLING.md#workflow--tooling-infrastructure.

The idea is to deter the agents from using infra that's not integrated and is different from the CI. They should use tox just like other components. They still tend to bypass this during troubleshooting in my experience but they still have to do the final self-verification using the correct dev/contrib infra. And these instructions suggest not doing that, which ain't a good idea.

Comment thread AGENTS.md
- **Comments earn their place.** Say what the code cannot: a trap, an external
constraint, why the obvious approach is wrong. Do not restate the line below.
- **Attribute your work.** This is required. If you produced commits, name the
tool and model in a `Co-authored-by` or `Assisted-by` trailer, and say so in the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same: leave Co-authored-by for humans

Comment thread CLAUDE.md
@@ -0,0 +1 @@
See [AGENTS.md](AGENTS.md).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Following Markdown links is nondeterministic. But the @-syntax is unconditional inclusion.

Suggested change
See [AGENTS.md](AGENTS.md).
@AGENTS.md

Comment thread CONTRIBUTING.rst
**Disclose AI use.** If AI tools generated any of your code, commits, pull request
description, comments or reviews, say so, naming the tool and model:

* commits get a ``Co-authored-by`` or ``Assisted-by`` trailer;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same: no co authors among robots

Comment thread CONTRIBUTING.rst
development dependencies from ``uv.lock``::

#. Install tox
$ uv sync --group dev

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This uv injection seems invasive. Why not show using tox where everything is integrated already instead of introducing a yet another tool? Seems out of the scope. If people want, they could have tox-uv, FWIW. But teaching them how to manage their envs probably doesn't belong here. You'll end up copying third party docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants