From 95b5bf0c94ecd7a0e088c8323919c50778f68ccc Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 22 Nov 2026 08:39:01 +0000 Subject: [PATCH] docs(contributing): split the contributor docs into CONTRIBUTING.md and docs/contributing/ CONTRIBUTING.md becomes a short entry point: the two positions and an index. The rules move to one file per trigger in docs/contributing/ (setup, making a change, AI assistance, code style, reviewing), each written as the rule, its reason and how it is held. GLOSSARY.md gains Driver, Unattended agent and Agent account. CLAUDE.md's bot-branch note now points to the new rule against pushing to someone else's branch. Closes #189 Assisted-by: Claude Code:claude-opus-5-5 --- CLAUDE.md | 3 +- CONTRIBUTING.md | 92 +++++-------------- GLOSSARY.md | 14 +++ docs/contributing/ai-assistance.md | 55 ++++++++++++ docs/contributing/code-style.md | 57 ++++++++++++ docs/contributing/making-a-change.md | 126 +++++++++++++++++++++++++++ docs/contributing/reviewing.md | 39 +++++++++ docs/contributing/setup.md | 51 +++++++++++ 8 files changed, 364 insertions(+), 73 deletions(-) create mode 100644 docs/contributing/ai-assistance.md create mode 100644 docs/contributing/code-style.md create mode 100644 docs/contributing/making-a-change.md create mode 100644 docs/contributing/reviewing.md create mode 100644 docs/contributing/setup.md diff --git a/CLAUDE.md b/CLAUDE.md index d5da2b4..8aa0106 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -172,7 +172,6 @@ runners, and no credential from anywhere else is used here. Never reuse another role-visible change needs a changelog fragment and a new `galaxy.yml` version; only the operator tags. - **Denied image namespace:** `check_image_versions.py pins` fails when anything under `.gitea/workflows` mentions the image namespace this repository's CI must not use (the string is in the script). -- **Hand edits on a bot branch:** a commit pushed by hand to a `renovate/` branch makes Renovate stop - rebasing it, so merge that pull request by hand. +- **Bot branches:** never push to a `renovate/` branch (or anyone else's); see `docs/contributing/making-a-change.md`. - **The runner has a single slot:** the Renovate job (up to 30 minutes) delays Lint, Build and Molecule. - **Open item:** do not enable automerge for bot PRs until a live run has shown that they get Lint and Build. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ff524b..dad9374 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,78 +1,28 @@ # Contributing -- Open a pull request against `main`. The forge does not allow self-registration, so only - accounts the maintainer has created can open pull requests or issues for now. Fork - pull requests are not a supported path: a fork controls its own workflow file. Workflows on fork pull requests get - no secrets and a read-only token. To discuss a contribution, write to the address in - `SECURITY.md`. -- This repository stands alone: nothing public here (a tracked file, issue or pull request - text or comment, release note or job output) refers to another repository of the maintainer's, its - documents, hosts, network or namespaces, or states host sizing. When you bring content in - from another repository, search the incoming diff for such mentions before committing, - rewrite comments so they stand alone, and say in the pull request what you searched for. -- Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) - (`feat:`, `fix:`, `docs:`, `ci:` ...). CI checks every commit. -- Every user-visible change needs a changelog fragment in `changelogs/fragments/` - (antsibull-changelog format, a YAML file with a section such as - `minor_changes:` or `bugfixes:`). Pure CI or docs changes use `trivial:`. -- Role variables carry the role name as a prefix (`_`). -- Third-party material needs an SPDX header, a `REUSE.toml` annotation (it - overrides file headers) and an entry in `NOTICE`. -- Set up the tooling once per clone with `scripts/dev-setup.sh`: it creates a virtualenv with - the pinned tools (`requirements-dev.lock`, the hashed lock of `requirements-dev.txt`), installs the pinned collections the roles call - (`requirements.yml`, into `.ansible/collections`, so local lint resolves the versions CI does) - and installs git hooks that find the tools (the `ansible-lint` hook, `scripts/ansible-lint.sh`, uses those - collections, also from a bare `pre-commit run`). Then - `pre-commit run --all-files` before pushing. A `git push` runs `ansible-test sanity` on HEAD - (`scripts/ansible-test-sanity.sh`, the Build job's check; the first run builds virtualenvs and - takes minutes), so a finding only that test reports stops the push, not the Build check. -- Never commit credentials, tokens or key material. -- Releases are cut by the maintainer: bump `version` in `galaxy.yml`, add a - `release_summary:` fragment, run `antsibull-changelog release` in a release PR - (commit the generated `CHANGELOG.rst` and `changelogs/.plugin-cache.yaml`), then - push an annotated `vX.Y.Z` tag. +Who can contribute and how, then where the rules for each step live. -## Dependency and image updates +## Positions -- A pin in `requirements-dev.txt` is changed together with its lock: Renovate does both (pip-compile manager); - by hand, run `scripts/lock-requirements.sh` (`--upgrade` moves transitive packages too; needs PyPI and - Python 3.13) and commit `requirements-dev.lock` in the same pull request. Installs use - `pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`: pip refuses an unhashed - package and any disagreement between the two files. Hook repositories in `.pre-commit-config.yaml` are - pinned by commit SHA with the release in a `# frozen: vX.Y.Z` comment; find the SHA with - `git ls-remote "refs/tags/" "refs/tags/^{}"` (the `^{}` line, when there is one). -- `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `.pre-commit-config.yaml` and `images/**` are inputs of the CI and - molecule images. A pull request that changes one needs a higher `version:` for that image in - `.gitea/workflows/image.yml` (`python3 scripts/bump_image_versions.py` makes the edit; the - `Check image versions were bumped` step enforces it). After the merge, `image.yml` builds the - image on `main`, and a second pull request moves the `image:@sha256:` pins in - `lint.yml`, `build.yml` and `molecule.yml` to the printed digest. That second pull request - touches no `image.yml` trigger path, so it rebuilds nothing. -- These files are in `galaxy.yml` `build_ignore`: such bumps do not change the Collection or its - version. A change consumers can see needs a changelog fragment, and only the maintainer - bumps the version and tags. -- `renovate.json` configures dependency bumps (minor and patch automerge, majors by hand). Renovate - runs for this repository in `.gitea/workflows/renovate.yml` (daily cron on the Collection's own - runner, as a Kamino-only bot user (repository secret `RENOVATE_BOT_TOKEN`); no credential from anywhere else is used). To dry-run after changing the - config: Actions > Renovate > Run workflow with `dry_run=true`, then read the debug log (the job fails on a failed clone or an ERROR problem). The dry run - proves reads (and runs the post-upgrade task); whether the bot can push and open a pull - request, and whether such pull requests start the PR workflows, only the first live run shows - (open item, see CLAUDE.md). Pull requests from `renovate/` branches must pass - `scripts/check_bot_pr_diff.py`, which only allows version, tag, digest and pin lines. -- Workflows must not mention `git.rkdr.net/defame1297/` (an image namespace this repository's - CI must not use); the `Check image pins` step fails if they do. +There are two positions, held per repository ([GLOSSARY.md](GLOSSARY.md)): -## Maintainer setup +- **Trusted contributor**: the maintainer has given you write access to this repository, and with it + the secrets that write access exposes. You push a branch here and open a pull request against `main`. +- **Outsider**: anyone without write access. You contribute through issues, using a form in + [.gitea/ISSUE_TEMPLATE/](.gitea/ISSUE_TEMPLATE/), not pull requests. What happens to a fork or AGit + pull request is in [reviewing.md](docs/contributing/reviewing.md). -Settings the workflows cannot enforce and the repository needs before it accepts -outside contributions: +Accounts on this forge are created by the maintainer; there is no self-registration. Report a +vulnerability as [SECURITY.md](SECURITY.md) says, never in an issue. -- Protect the `v*` tags so only maintainers can create them. A tag run uses the - workflow files of the tagged commit and may receive organisation secrets. -- Protect `main`: pull request required, with the `Lint` and `Build` checks. Molecule has no path filter - on pull requests (the job always starts and chooses its scenarios itself), so it can be made a required - check as well; that is the operator's decision. -- The image workflow (`.gitea/workflows/image.yml`) pushes with the organisation secrets - `PACKAGE_PUSH_USER` and `PACKAGE_PUSH_TOKEN` (a bot user with write access to the - organisation's packages and a token with only the `write:package` scope). Keep - those the only credentials stored at organisation level. +## Contributor docs + +- [setup.md](docs/contributing/setup.md): setting up a clone and an agent tool. +- [making-a-change.md](docs/contributing/making-a-change.md): branches, commits, fragments, templates, + third-party material, content from other repositories, dependency and image updates. +- [ai-assistance.md](docs/contributing/ai-assistance.md): working with an agent, disclosure, agent accounts. +- [code-style.md](docs/contributing/code-style.md): code style outside roles. +- [reviewing.md](docs/contributing/reviewing.md): closing a fork pull request, merging someone else's, + running an unmerged branch locally. + +Rules for roles are in [roles/AGENTS.md](roles/AGENTS.md). diff --git a/GLOSSARY.md b/GLOSSARY.md index 6e19cf9..4e2db1c 100644 --- a/GLOSSARY.md +++ b/GLOSSARY.md @@ -29,3 +29,17 @@ _Avoid_: Collaborator, member **Outsider**: Anyone without write access to this repository, who contributes through issues rather than pull requests. _Avoid_: External contributor, stranger, friend, guest + +### Agents + +**Driver**: +The person who starts an agent session and answers for what it produces. +_Avoid_: User, owner + +**Unattended agent**: +An agent running with no driver live in the session, such as a scheduled one. +_Avoid_: Bot, autonomous agent, AFK agent + +**Agent account**: +A Gitea account used only by agents, with exactly one accountable person. +_Avoid_: Bot account, service account diff --git a/docs/contributing/ai-assistance.md b/docs/contributing/ai-assistance.md new file mode 100644 index 0000000..b09e636 --- /dev/null +++ b/docs/contributing/ai-assistance.md @@ -0,0 +1,55 @@ +# AI assistance + +Read this before working on this repository with an agent, committing agent-written content, or +setting up an agent account. + +These rules are our own, credited to the +[Ansible community AI policy](https://docs.ansible.com/projects/ansible/13/community/ai_policy.html); +they do not adopt it by reference. Every rule gives its reason and how it is held: by a control (a +named hook or check), by review, or aspirational (checked by nothing and nobody). Links between the +contributor docs are held by review until an offline link check exists. Terms such as *driver*, +*unattended agent* and *agent account* are defined in [GLOSSARY.md](../../GLOSSARY.md). + +## Authorship and disclosure + +- **The author of record of a pull request is the person who opened it, or the person accountable for + the account that opened it. They answer for every line: they understand it and have run the checks + it touches. An agent is a tool, never an author.** No driver line is needed in the pull request. + *Reason:* review only works if someone can explain the change. + *Held by:* review. +- **Every pull request, issue, comment and review reply an agent writes in a session with someone + live in it has a human driver who started that session and answers for it.** + *Reason:* what an agent posts needs a person who answers for it, as much as what it commits. + *Held by:* review. +- **Every commit that contains agent-written content carries `Assisted-by: [:]` (tool + required, model optional), for example `Assisted-by: Claude Code:claude-opus-5-5`. A pull request + written with an agent carries the same line in its description.** There is no "substantial use" + threshold. + *Reason:* AI assistance is disclosed, and in an agent-first repository a threshold cannot be applied + consistently. + *Held by:* review. +- **Never add `Co-Authored-By:` for an agent, `Claude-Session:` or any other session link, or any other + AI trailer.** Agent tools often add these by default: set yours to write `Assisted-by:` instead. + History is not rewritten. + *Reason:* a co-author trailer makes the tool an author, and a session link is private and points + outside this repository. + *Held by:* review until the commit-msg hook that refuses these trailers lands (issue #272); then + control. + +## What agents may do + +- **An unattended agent acts from the agent account. It may code, push, open pull requests and + issues, comment and review; it may not approve or merge.** + *Reason:* unattended work still has to reach review, and the prompt-injection risk this carries is + accepted while every account is created by the maintainer (the Accepted risks in + [SECURITY.md](../../SECURITY.md)). + *Held by:* aspirational. +- **No agent approves or merges a pull request, driven or unattended.** + *Reason:* approval by a code owner is the gate, and an agent that approves passes its own gate. + *Held by:* control for agent accounts (they are outside the merge and approvals allowlists of the + branch protection); review for an agent acting with a contributor's own token. +- **Every agent account has exactly one accountable person, named in its Gitea profile.** + *Reason:* everything an agent account does needs one person who answers for it. + *Held by:* aspirational. +- Which issues an unattended agent may act on, and how it treats issue text, is in + [docs/agents/issue-tracker.md](../agents/issue-tracker.md). diff --git a/docs/contributing/code-style.md b/docs/contributing/code-style.md new file mode 100644 index 0000000..36fa84b --- /dev/null +++ b/docs/contributing/code-style.md @@ -0,0 +1,57 @@ +# Code style + +Read this before writing or changing a script, a workflow, a hook, a comment or a guidance document. +Rules for roles are in [roles/AGENTS.md](../../roles/AGENTS.md). + +Every rule gives its reason and how it is held: by a control (a named hook or check), by review, or +aspirational (checked by nothing and nobody). Links between the contributor docs are held by review +until an offline link check exists. The rules bind new and changed lines from the day they land; +existing content is brought in line by separate issues. + +## Rules + +1. **Existing tool first.** Use an Ansible module, a lint rule or a tool's own setting before a + script. A pull request that adds or grows a script says what it ruled out. + *Counter-example:* a custom checker for comment or file length. No standard tool measures them for + YAML or shell, so those limits are held by review (below) rather than by a script of our own. + *Does not forbid:* a script where no tool does the job, such as the scenario selector. + *Reason:* every script here is code someone has to review and maintain. + *Held by:* review. +2. **One job per file, readable in one sitting.** + *Counter-example:* `scripts/check_image_versions.py` holds two checks, `pins` and `bump`, in over 800 + lines. + *Does not forbid:* helpers in the file that serve its one job, or a long file that is still one job; + do not split a file only for its length. + *Reason:* a reviewer has to hold the whole file in mind to judge a change to it. + *Held by:* control in part: `ruff` (complexity and function size at its defaults) and `shellcheck` + hooks; review for the rest. +3. **A comment gives the reason, in a line or two.** + *Counter-example:* the header of `scripts/dev-setup.sh`, over twenty lines that mostly restate what + the code does. + *Does not forbid:* a usage line, or a reason that takes three lines because it is subtle. + *Reason:* the code says what it does; only the reason is missing from it. + *Held by:* review. +4. **Write for the next reader, not the record.** No incident history, change narration or session + notes in code, comments or agent context; they go in the commit message or an ADR. + *Counter-example:* "ci 0.2.26 failed to push" in agent context, a past incident where the reason + (Cloudflare rejects request bodies over 100 MB) is all a reader needs. + *Does not forbid:* stating the fact that justifies a rule. + *Reason:* history in context ages into noise that every later reader pays for. + *Held by:* review. +5. **Change only what the task needs.** Unrelated cleanup is a separate pull request. + *Counter-example:* reformatting a role while fixing a typo in another. + *Does not forbid:* fixing a line you had to touch anyway. + *Reason:* a small diff is one a reviewer can read in full. + *Held by:* review. + +## Limits and exceptions + +- **Soft limits: a comment block over 5 lines, a script or workflow over 200 lines, a guidance document + over 200 lines.** Above one, the pull request says why; nothing fails. + *Reason:* the numbers prompt a question in review without forcing a split that makes things worse. + *Held by:* review. This file is the only home of these numbers; a number a tool holds lives in that + tool's committed config, never in an environment variable. +- **An exception is explicit and local: an inline suppression with its reason, or one sentence in the + pull request. Never a global exclude.** + *Reason:* a reviewer can judge an exception only where it is visible. + *Held by:* review. diff --git a/docs/contributing/making-a-change.md b/docs/contributing/making-a-change.md new file mode 100644 index 0000000..ea1fcea --- /dev/null +++ b/docs/contributing/making-a-change.md @@ -0,0 +1,126 @@ +# Making a change + +Read this before starting a branch, committing, filing an issue or opening a pull request. + +Every rule below gives its reason and how it is held: by a control (a named hook or check), by +review, or aspirational (checked by nothing and nobody). Links between the contributor docs are +held by review until an offline link check exists. Rules for roles are in +[roles/AGENTS.md](../../roles/AGENTS.md); rules for working with an agent, including commit +trailers, are in [ai-assistance.md](ai-assistance.md). + +## Branches and pull requests + +- **Work on a branch of your own and open a pull request against `main`; never push to `main`.** + *Reason:* every change reaches `main` through the Lint and Build checks and a reviewer. + *Held by:* control: branch protection on `main`. +- **Do not push to someone else's branch or to a bot's branch; put your change in a pull request of + your own.** Updating a branch from `main` with Gitea's update button is allowed. + *Reason:* a push changes a head its author already reviewed or scheduled to merge, and a hand-made + commit on a `renovate/` branch makes Renovate stop rebasing it. + *Held by:* aspirational. +- **File an issue or open a pull request with the headings of the matching template in `.gitea/`, + also when you file through the API, `tea` or an MCP server.** + *Reason:* those routes skip the templates, and an agent's built-in body leaves out what review needs. + *Held by:* review. +- **A pull request says under *Verified* what you ran (commands, linked CI runs) and under *Not + verified* what you did not.** + *Reason:* a reviewer can only judge a change by what was actually checked. + *Held by:* review. + +## Commits + +- **Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/)** (`feat:`, + `fix:`, `docs:`, `ci:` ...). + *Reason:* the type tells a reviewer and the changelog what kind of change it is. + *Held by:* control: the `conventional-pre-commit` commit-msg hook, and the Lint check on every commit + of a pull request. +- **Never commit credentials, tokens or key material.** + *Reason:* a pushed secret has leaked, whatever later commits do. + *Held by:* control: the `gitleaks` hook, and the Lint check's scan of a pull request's commits. + +## Changelog, versions and dependencies + +- **A change a consumer can see needs a changelog fragment in `changelogs/fragments/`**: an + antsibull-changelog YAML file with one section. A pure CI or docs change needs none, or a `trivial:` + one. Pick the section by the release it calls for: + - major: `breaking_changes`, `removed_features`; + - minor: `minor_changes`, `deprecated_features`; + - patch: `bugfixes`, `security_fixes`, `known_issues`; + - never `major_changes` (its title reads like a major release; use `breaking_changes` or + `minor_changes`). + + *Reason:* the changelog is built from the fragments, and the next version follows from their sections. + *Held by:* control for the format (the `antsibull-changelog-lint` hook); review for whether one is + needed and which section. +- **Write a fragment, never the version.** The maintainer sets `version` in `galaxy.yml` and tags + the release. + *Reason:* the version follows from all fragments since the last release, not from one change. + *Held by:* review (`galaxy.yml` is under `CODEOWNERS`). +- **A new Collection dependency states its reason in the pull request and has a version floor.** + *Reason:* every consumer has to install it, and without a floor an old version nobody tested + satisfies it. + *Held by:* review (`galaxy.yml` is under `CODEOWNERS`). + +## Third-party material + +- **Third-party material carries an SPDX header, a `REUSE.toml` annotation (which overrides file + headers) and an entry in `NOTICE`.** + *Reason:* the Collection is GPL-licensed and REUSE-compliant, so each file's licence and origin must + be recorded. + *Held by:* review, prompted by the pull request template's checkbox; the `reuse-lint` hook catches + a file with no licence at all. + +## Content from other repositories + +- **No tracked file, issue or pull request text or comment, release note or job output refers to + another repository of the maintainer's, its documents, hosts, network or namespaces, or states host + sizing.** This instruction has no expiry. + *Reason:* this repository is public and stands alone; a reader without an account must not learn + the private environment from it. + *Held by:* aspirational (no check is cheap for issue text or job logs). +- **When you bring content in from another repository, search the incoming diff before committing** + for mentions of the source repository, its documents, hostnames, addresses, account namespaces and + sibling paths; rewrite comments so they stand alone; say in the pull request what you searched for. + *Reason:* copied comments and paths are where private references slip in. + *Held by:* review. + +## Dependency and image updates + +Interim section: it moves to `images/AGENTS.md` and `scripts/AGENTS.md`. + +- **A pin in `requirements-dev.txt` changes together with its lock `requirements-dev.lock`.** Renovate + does both; by hand, run `scripts/lock-requirements.sh` (`--upgrade` also moves transitive packages; + it needs PyPI and the Python of `.python-version`) and commit the lock in the same pull request. + *Reason:* installs use `pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`, + which refuses an unhashed package and any disagreement between the two files. + *Held by:* control: the Lint and Build checks install that way when a pin file changes. +- **Hook repositories in `.pre-commit-config.yaml` are pinned by commit SHA, with the release in a + `# frozen: vX.Y.Z` comment.** Find the SHA with + `git ls-remote "refs/tags/" "refs/tags/^{}"` (the `^{}` line, when there is one). + *Reason:* a tag can be moved; a commit SHA cannot. + *Held by:* review (`.pre-commit-config.yaml` is under `CODEOWNERS`). +- **A pull request that changes an image input (`requirements-dev.txt`, `requirements-dev.lock`, + `requirements.yml`, `.pre-commit-config.yaml`, `images/**`) raises that image's `version:` in + `.gitea/workflows/image.yml`** (`python3 scripts/bump_image_versions.py` makes the edit). + *Reason:* a published image version is never rebuilt, so a changed input needs a new version. + *Held by:* control: the Lint check's `Check image versions were bumped` step. +- **After the merge builds the image on `main`, a second pull request moves the + `image:@sha256:` pins in `lint.yml`, `build.yml` and `molecule.yml` to the printed + digest.** It touches no `image.yml` trigger path, so it rebuilds nothing. + *Reason:* consumers run exactly the digest a reviewer saw. + *Held by:* review; Renovate opens these pull requests for the repository's own images. +- These tooling files are in `galaxy.yml` `build_ignore`, so their bumps change neither the + Collection nor its version. +- **A pull request from a `renovate/` branch changes only version, tag, digest and pin lines.** + *Reason:* the bot's pull requests automerge, so they must not be able to change anything else. + *Held by:* control: `scripts/check_bot_pr_diff.py` in the Lint check, run from `main`'s copy. +- **Workflows never mention the image namespace this repository's CI must not use** (the string is in + `scripts/check_image_versions.py`). + *Reason:* this repository's images are built and pulled only under its own organisation's namespace. + *Held by:* control: the Lint check's `Check image pins` step. +- `renovate.json` configures the bumps (minor and patch automerge, majors by hand). Renovate runs in + `.gitea/workflows/renovate.yml` (daily cron on this repository's runner, as a bot user of this + repository only). Test a config change before the merge with `renovate --platform=local` (the version + in `renovate.yml`), which reads your checkout; a dry run in Actions (Run workflow with `dry_run=true`) + reads `renovate.json` from `main` and proves reads only. Open item: no live run has yet shown that + the bot can push and open a pull request, and that its pull requests get the Lint and Build checks. diff --git a/docs/contributing/reviewing.md b/docs/contributing/reviewing.md new file mode 100644 index 0000000..4fec5d6 --- /dev/null +++ b/docs/contributing/reviewing.md @@ -0,0 +1,39 @@ +# Reviewing + +Read this before closing a fork pull request, merging someone else's pull request, or running an +unmerged branch you did not write. + +Every rule gives its reason and how it is held: by a control (a named hook or check), by review, or +aspirational (checked by nothing and nobody). Links between the contributor docs are held by review +until an offline link check exists. The positions are defined in [GLOSSARY.md](../../GLOSSARY.md). + +## Fork pull requests + +- **A fork or AGit pull request (one pushed to `refs/for/` counts as a fork pull request) + always comes from an outsider. A human closes it without approving its runs and points to an issue; + no agent or automation closes it. Never approve a fork run, and never merge a fork pull request.** + *Reason:* a fork controls its own workflow files, so an approved run executes the outsider's code on + this repository's runner, and a person, not an agent or automation, should tell the outsider where to go instead. + *Held by:* aspirational. +- **A trusted contributor may carry the change into a pull request of their own after reading every + line; they are then its author of record.** + *Reason:* the change then reaches `main` through the ordinary path, with a person who answers for it. + *Held by:* review. + +## Running a branch you did not write + +- **Review an unmerged branch you did not write before running its changes locally**, in particular + scripts, `.pre-commit-config.yaml`, `.claude/` and every `AGENTS.md`. Review it in the web diff, or in + a clone where no agent runs. + *Reason:* hooks and scripts run with your rights, and a branch's agent settings, hooks, skills and + instruction files take effect as soon as you open it with an agent. + *Held by:* review. + +## Merging + +- **Schedule a merge only on your own pull request, on a branch nobody else pushes to. Merge a pull + request you reviewed (the agent account's, the release pull request) with the merge button, at the + head you read.** + *Reason:* a scheduled merge merges whatever head the branch has when the checks pass, and a push + does not cancel it. + *Held by:* aspirational. diff --git a/docs/contributing/setup.md b/docs/contributing/setup.md new file mode 100644 index 0000000..bbd92c8 --- /dev/null +++ b/docs/contributing/setup.md @@ -0,0 +1,51 @@ +# Setup + +Read this before setting up a clone, or an agent tool, to work on this repository. + +Every rule below gives its reason and how it is held: by a control (a named hook or check), by +review, or aspirational (checked by nothing and nobody). Links between the contributor docs are +held by review until an offline link check exists. + +## The clone + +- **Run `scripts/dev-setup.sh` once per clone, and again after a change to `requirements-dev.txt`, its + lock `requirements-dev.lock`, `requirements.yml` or the hook types.** It creates `.venv` with the + pinned tools on the Python named in `.python-version`, installs the collections of `requirements.yml` + into `.ansible/collections`, and installs the git hooks (pre-commit, commit-msg, pre-push) with the + virtualenv first on their `PATH`. + *Reason:* several hooks run their tools by name (`language: system`), so they fail without that + virtualenv, and local lint must resolve the collection versions CI does. + *Held by:* aspirational (a hook run without the virtualenv fails, which shows the step was skipped). +- **Run `pre-commit run --all-files` before pushing.** + *Reason:* a finding then stops you before the push instead of failing CI after it. + *Held by:* control: the Lint check runs the same hooks on every pull request. +- **Let `git push` run `ansible-test sanity` on HEAD** (`scripts/ansible-test-sanity.sh`, the Build + check's sanity test); its first run builds virtualenvs and takes minutes. + *Reason:* a finding only that test reports stops the push instead of the Build check. + *Held by:* control: the pre-push hook, and the Build check. + +## Agent tools + +Until the root `CLAUDE.md` is replaced by `AGENTS.md` (issue #185), the repository itself breaks the +second rule below, and the startup check does not pass. + +- **Use Claude Code 2.1.281 or later.** + *Reason:* older versions read no `AGENTS.md`, or only `CLAUDE.md` in some sessions, so the agent + works without this repository's guidance. + *Held by:* aspirational. +- **Keep personal notes in `~/.claude/CLAUDE.md`. Never create `CLAUDE.local.md` or a `CLAUDE.md` in + the clone, and keep no `CLAUDE.md` in any directory above the clone.** + *Reason:* Claude Code reads a `CLAUDE.md` it finds there instead of the `AGENTS.md` files, so the + agent loses this repository's guidance. + *Held by:* review for a committed file, until a hook refuses one (issue #244); aspirational for + files outside the repository. +- **Confirm that Claude Code's startup line reads `no CLAUDE.md found; AGENTS.md loaded: ...`.** + *Reason:* it is the one visible sign that the agent loaded the guidance. + *Held by:* aspirational. +- **The tracked `.claude/settings.json` never holds `permissions.allow`; `deny` and `ask` rules are + allowed. Your own allowlist and personal guards go in `.claude/settings.local.json`, which is never + committed.** (`.gitignore` lists it once issue #196 lands; until then, leave it out of your commits.) + *Reason:* a branch's settings take effect for whoever opens it with an agent, so an `allow` rule + pushed on an unmerged branch lets that branch's commands run without a prompt before anyone has + reviewed it, while a `deny` or `ask` rule can only add prompts. + *Held by:* review (`.claude/` is under `CODEOWNERS`).