docs(agents, tests): ask what a new check protects and how a test fails (#5417)

## What this PR does

Adds two asks to the contribution rules, for people and for agents: show
that a new test can fail, and say what a new repository-wide check
protects.

A test merged in #5349 that read chart sources from a Go package, pinned
hand-typed expected values, and guarded declarations that no code read
yet. Review checked that it passed and that the author's claims were
true. Nobody asked what requirement it enforced, and I approved it.
#4508, which ships a chart variant the test did not expect, went red on
it without being wrong.

The template asks what requirement on the system's behaviour a check
protects and who consumes the checked artifact. The contribution guides
ask for failure evidence: revert a behaviour change, or mutate the
behaviour a test pins. A rule that has no existing requirement needs
agreement in an issue or an accepted design proposal before the check's
PR. A test plan alone does not justify the check.

Nothing here is machine-checked. Rules about where a contract should be
enforced (schema against Go test) and about where expected values come
from are left out on purpose: they need a discussion first.

### New checks

None. This PR adds prose rules and no check that can fail a change.

### Screenshots

Not a UI change.

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.

IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:

1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [x] [cozystack/community](https://github.com/cozystack/community) -
follow-up: cozystack/community#139 (an issue: `contributors/README.md`
restates how to fill the template in, and should change once this
merges)

### Release note

<!--  Write a release note:
- Explain what has changed internally and for users.
- Start with the same `type(scope):` prefix as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->

```release-note
NONE
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Documentation**
* Added guidance for showing that changed tests detect the behavior they
cover, including what to report when tests cannot be run locally.
* Clarified how to document checks that may affect other changes,
including the requirement they protect and the code that uses their
results.
* Added a “New checks” section to the pull request template, with
instructions to describe applicable checks or write “None.”
* Updated review and commit guidance, and linked to detailed conventions
for tests and checks.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Aleksei Sviridkin authored and GitHub committed 2026-12-03 14:58:45 +03:00
commit 39c452c260
5 files changed
+38 -5

No files matched your search

+9 -1
View File
@@ -7,7 +7,7 @@
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer, a `fix` included. What counts as breaking: https://github.com/cozystack/cozystack/blob/main/docs/agents/contributing.md#what-counts-as-breaking
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft.
- Don't hesitate to ask for opinion and review in the community chats, even if it's still a draft.
- Fixes merged to `main` reach the release lines the backport batch runs for automatically, so do not open backport PRs by hand: https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md
-->
@@ -17,6 +17,14 @@
<!-- Uncomment the next line when this PR adds or changes a downstream patch: https://github.com/cozystack/cozystack/blob/main/CONTRIBUTING.md#patches-to-other-projects-code -->
<!-- Upstream: link to the upstream pull request, or to the issue or thread where the change was raised -->
### New checks
<!-- Fill in when this PR adds or tightens anything that can fail somebody else's change: a test that reads files outside its own package or chart, a lint, a validator, a schema restriction, a CI gate. One entry per check; write "None" below this comment otherwise. A section left empty counts as not filled in.
- Protects: the requirement of the system's behaviour the check guards, with a link (a spec clause, a runtime contract, a documented decision, an issue). "This is how the tree looks today" is not a requirement, and neither is a test plan, a design proposal's Testing section included. A rule with no such source is agreed in an issue or an accepted design proposal before this PR; link it.
- Consumer: the code that reads the artifact being checked. If nothing reads it yet, say so, and link where the rule was agreed before this PR.
-->
### Screenshots
<!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating
+1
View File
@@ -89,6 +89,7 @@ These hold for every task, whichever document the routes above point at.
- **Go Code**: Controller-runtime patterns, kubebuilder style
- **Git Commits**: Conventional Commits (`type(scope): description`) with `--signoff`; an agent-assisted commit adds one `Assisted-by: LLM` trailer
- **Comments and commit bodies**: WHY, not a narration of WHAT; see [Review Blockers](./docs/agents/contributing.md#review-blockers-messages-trailers-comments) in contributing.md
- **Tests and checks**: a new or changed test is seen to fail without its change, or under a mutation of the behaviour it pins; if an e2e failure cannot be observed locally or in CI, the commit body says so and why, for the reviewer to decide. A check that can fail somebody else's change names the requirement it protects and the code that consumes what it checks; a rule no spec or contract states, or one over an artifact nothing reads yet, is agreed in an issue or an accepted design proposal before the PR that adds the check; see [New Tests and Checks](./docs/agents/contributing.md#new-tests-and-checks)
- **Prose**: One continuous line per paragraph — see [Prose Formatting](#prose-formatting)
### What NOT to Do
+10
View File
@@ -63,3 +63,13 @@ When raising issues, please specify the following:
- A scenario where the issue occurred (with details on how to reproduce it)
- Errors and log messages that are displayed by the involved software
- Any other detail that might be useful
## Tests and checks in a pull request
Two things reviewers will ask about, so it saves a round to answer them up front.
**Show that a new test can fail.** Before you commit a test that covers a change in behaviour, run it without that change: revert the fix or break the line the test is about. A test that pins behaviour which is not changing, such as a `FIXME(#N)` test for a known bug or a test written before a refactor, has nothing to revert; mutate the behaviour it pins instead. Write what you did and the failure message as one line in the commit message. Please do not add a separate failing commit for this. Pull requests are merged with a merge commit, not squashed, so every commit lands on `main` and has to pass on its own. If the test is an e2e test you cannot run locally, take the failure from a CI run of a temporary commit that you drop before asking for review, or say in the commit message that you could not observe it and why.
**Say what a new check protects.** A test that reads files outside its own package or chart, a lint, a validator, a schema restriction or a CI gate can fail somebody else's change, so it becomes a rule for the whole repository once it merges. In the "New checks" section of the pull request template, name the requirement of the system's behaviour it protects, with a link to where it is stated, and the code that reads the artifact it checks. A test plan, including the Testing section of a design proposal, is not such a requirement. If the only source is a test plan or how the tree looks today, or nothing reads that artifact yet, agree the rule first in an issue or an accepted design proposal, before you open the pull request that adds the check. Approving that pull request is not the discussion.
The full conventions, written for AI agents and equally valid for people, are in [`docs/agents/contributing.md`](docs/agents/contributing.md#new-tests-and-checks).
+17 -3
View File
@@ -11,6 +11,8 @@ Project-side conventions for commits, branches, and pull requests in Cozystack.
- [ ] PR body includes description and release note
- [ ] Ran `make generate` in every package whose `values.yaml`, `values.schema.json`, `Chart.yaml`, or `README.md` was touched, and committed the regenerated files
- [ ] If the change implements a design proposal, the PR stays draft until the proposal is merged in cozystack/community ([CONTRIBUTING.md](../../CONTRIBUTING.md#where-do-i-file))
- [ ] Every new or changed test was seen to fail without the change it covers, or under a mutation of the behaviour it pins, and the commit body says how; if an e2e failure could not be observed locally or in CI, the commit body says so and why, for the reviewer to decide (see [New Tests and Checks](#new-tests-and-checks))
- [ ] Filled in "New checks" in the PR template for anything that can fail somebody else's change, or wrote "None"
- [ ] Walked the [Downstream Repositories](#downstream-repositories) trigger map against the diff, and linked a follow-up (a PR, or an issue when the PR is out of scope) in every repository the change reaches
- [ ] Every downstream patch the PR adds or changes links its upstream counterpart, or the PR says why there is none (see [Patches to other projects' code](../../CONTRIBUTING.md#patches-to-other-projects-code))
@@ -66,7 +68,7 @@ git commit --signoff --message "type(scope): brief description"
Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer. What counts as breaking is defined in [What counts as breaking](#what-counts-as-breaking).
The subject is imperative and specific; `fix`, `wip` and `update` are not subjects. The body, when there is one, explains why the change is made and only that: the diff already shows what changed and how. Write for a reader who has only `git log`, so no review-iteration or planning vocabulary (`address review comments`, `pass 2`, `batch 1`, `as discussed`) and no bare issue or ticket number in place of the explanation.
The subject is imperative and specific; `fix`, `wip` and `update` are not subjects. The body, when there is one, explains why the change is made and only that: the diff already shows what changed and how. The one exception is a line on how the change was tested, which the diff cannot show (see [New Tests and Checks](#new-tests-and-checks)). Write for a reader who has only `git log`, so no review-iteration or planning vocabulary (`address review comments`, `pass 2`, `batch 1`, `as discussed`) and no bare issue or ticket number in place of the explanation.
**Examples:**
@@ -176,7 +178,7 @@ git push --force origin my-feature
## Pull Request Body
Fill in the template at [`.github/PULL_REQUEST_TEMPLATE.md`](../../.github/PULL_REQUEST_TEMPLATE.md). It includes the required `release-note` block and the [Downstream Repositories](#downstream-repositories) checklist.
Fill in the template at [`.github/PULL_REQUEST_TEMPLATE.md`](../../.github/PULL_REQUEST_TEMPLATE.md). It includes the required `release-note` block, the "New checks" section, which takes an entry per check or "None" (see [New Tests and Checks](#new-tests-and-checks)), and the [Downstream Repositories](#downstream-repositories) checklist.
Link the issues the PR addresses in its body. Use `Closes #N` when it fully resolves an issue, or `Closes owner/repository#N` for another repository; link partial work without a closing keyword. A closing keyword in a commit can close the issue on merge into the default branch, but does not create the PR's linked-issue entry. Put the reference in the PR body even when the commit already carries it.
@@ -321,10 +323,22 @@ The rest of the organisation's repositories do not restate anything this one own
The release process keeps a **separate** list of repositories, in [`changelog.md`](./changelog.md), checked for tags cut during a release window. That list exists to assemble release notes; this one exists to catch code coupling. They overlap but are not interchangeable, and neither replaces the other.
## New Tests and Checks
A test proves something only if it can fail. Before committing a test that covers a change in behaviour, see it fail without that change: revert the fix, or break the one line the test is about, and run it. A test that pins behaviour which is not changing has no change to revert: a `FIXME(#N)` test pinning a known bug (rule 5 of [Test first, failure path first](./overview.md#test-first-failure-path-first)), or a test written before a refactor to hold what the refactor must keep. Such a test shows it can fail by mutating the behaviour it pins. Either way, put the result in the commit body as one line, with what was reverted or mutated and the failure message. This is the line on how the change was tested that [What Goes in the Commit](#what-goes-in-the-commit-what-goes-in-the-pr-body) asks for, and the one place where the body says how. A test that stays green under that revert or mutation checks nothing and blocks the PR.
An e2e test that cannot run locally gets the same evidence from CI: push a temporary commit that reverts the change or mutates the pinned behaviour, take the failure message from that run, and drop the commit before asking for review. When even that is not possible, the commit body says the failure was not observed and why, and the reviewer decides whether that is enough.
Do not add a separate failing commit for this. Pull requests into `main` are merged with a merge commit (squash and rebase merges are switched off in the repository settings), so every commit of the branch lands on `main` as it is, and each one has to build and pass on its own for `git bisect` to stay usable. The evidence goes into the message, not into the history.
A check that can fail somebody else's change needs more than that: a test that reads files outside its own package or chart, a lint, a validator, a schema restriction, a CI gate. Such a check becomes a rule for the whole repository the moment it merges. In the "New checks" section of the PR template, name the requirement of the system's behaviour it protects, with a link to where that requirement is stated, and the code that consumes the artifact it checks. A test plan is not such a requirement, the Testing section of a design proposal included: it says how the work was meant to be verified, not what the system must do.
A check whose only source is a test plan or how the tree looks today, or one over an artifact nothing reads yet, is a proposal for a new rule. Agree that rule first, in an issue or in an accepted design proposal in [cozystack/community](https://github.com/cozystack/community), before opening the PR that adds the check. A design proposal is accepted when its PR is merged, as defined by the [proposal approval process](https://github.com/cozystack/community/blob/main/design-proposals/README.md#approval-process). Approving the PR that adds the check is not the discussion: an ordinary code-owner approval does not say that the rule was weighed. When review finds such a check asked for by a proposal's test plan, the proposal is amended with a [decision record](https://github.com/cozystack/community/blob/main/design-proposals/README.md#decision-records) under it, and the check is not added just because the plan asked for it.
## Review Expectations
- A bug-fix PR should include a behavioural regression test, not just a single field assertion — prove the bug can no longer recur.
- Keep the PR description aligned with the template: `## What this PR does` plus the `release-note` block.
- Keep the PR description aligned with the template: fill in every section that applies, from `## What this PR does` to the `release-note` block.
- Before posting a claim about a set ("all callers", "the only user", "never happens"), grep for the counterexample, or state the mechanism instead.
- Disagreement carries a mechanism: a code path, a number, a spec clause, a failing test. Time spent and urgency are not arguments.
- Answer the point directly and explain why it is accepted or declined. Read brief feedback literally rather than inferring tone, and avoid unnecessary notifications. Follow the [prose guidance](../../AGENTS.md#working-principles).
+1 -1
View File
@@ -120,7 +120,7 @@ The test for a marker is whether every sub-object a user can write is a complete
These rules apply to changes with testable behavior. Documentation-only edits and unmodified upstream updates need the relevant checks, not an artificial failing test. First-party adaptations made during a dependency bump remain covered by these rules.
1. Write the test before changing the implementation and watch it fail for the intended reason, not on a typo or a missing fixture. Then make it green, then refactor under it.
1. Write the test before changing the implementation and watch it fail for the intended reason, not on a typo or a missing fixture. Then make it green, then refactor under it. [New Tests and Checks](./contributing.md#new-tests-and-checks) says how to record the failure in the commit body and how a test that pins unchanged behaviour shows it can fail.
2. Cover relevant failure paths before the happy path: empty or null values, invalid input, a number where a string is expected, a missing resource, a timeout or an API error. Assert the resulting message, exit status and post-failure state required by the operation's contract.
3. Fix regressions in the implementation. Do not skip, weaken or delete a test, or silence a linter, merely to get a green run. When the intended contract changes, update or replace the obsolete assertions and retain coverage of applicable failure cases.
4. A stub needs a failing test for the intended behavior during development. Finish that behavior and make the test pass before merge; do not make the test accept an unintended not-implemented result just to get green CI.