diff --git a/docs/pr-reviewer-reference.md b/docs/pr-reviewer-reference.md index ed5ff3b29..1710eeb97 100644 --- a/docs/pr-reviewer-reference.md +++ b/docs/pr-reviewer-reference.md @@ -77,6 +77,7 @@ Each reviewer's behavior is shaped by a committed file rather than accepted as g - **CodeRabbit** is configured in `.coderabbit.yaml`, whose [settings reference][coderabbit-config] names each option. Its automatic review is off, since this repository's review policy has `wait` ask CodeRabbit explicitly instead. The file still lists `develop` as a base, the setting that governs where a repository left on automatic review is reviewed. No pause follows five reviewed commits, since a fleet pull request routinely passes five pushes and the pause reads as a reviewer that stopped. A path instruction for Markdown asks for false, stale, unverifiable, or unfollowable claims only. That is because CI lints style and the local review pass reads canonical prose whole. Sequence diagrams, suggested labels and reviewers, and the in-progress fortune are off. The markdownlint, actionlint, shellcheck, and ruff tools are off, since CI runs the same four and fails the pull request on them. - **Qodo** is configured in `.pr_agent.toml`, whose [configuration reference][qodo-config] names each option. An issues guideline asks for a reproduction with any claimed crash. That guideline came after a claimed `IsADirectoryError` on this repository's build was disproven by running it. A compliance guideline asks for the rule's own sentence and routes a rule against unchanged text to the summary. Informational findings go to the [summary][qodo-verbosity] rather than a thread, since a thread blocks the merge until resolved. Images are off so a finding's title is plain text a matcher can see. Qodo's [review standards][qodo-rules] import from `AGENTS.md`, `CLAUDE.md`, `copilot-instructions.md`, and `SKILL.md` files when changes merge. Each is scoped to its folder at any depth. Only new rules are added, so an edited or deleted rule is changed in its portal instead. This repository sits below Qodo's star gate and gets no automatic Qodo review. - **Which reviewer runs, and when**, is the repository's review policy, the `review` section of `.github/agent-policy.json`, or the hub default `spec/agent-policy.default.json` where it states none. `scripts/README.md` "`pr_review.py`" describes how `wait` applies it. A bot's own automatic trigger is a setting the policy does not read. `repo-config/configure.sh apply --checkout` derives it from the policy rendered from the registry. That covers Copilot's ruleset rule, CodeRabbit, and Qodo. A repository's `.coderabbit.yaml` replaces CodeRabbit's central and UI settings rather than merging with them, unless it sets `inheritance: true`. So the rendered file sets `auto_pause_after_reviewed_commits` to `0` itself, or CodeRabbit's default pause after five reviewed commits applies. `auto` says only that the bot may start on its own. `explicit` assumes it does not, so turn the bot's own trigger off before moving it to `explicit`. Otherwise it reviews twice. For Copilot, `wait` also notes any request already pending when it starts. That includes one an earlier `wait` sent, so the note points at a trigger left on only where no session sent the request. +- **Central settings**: the account-wide `coderabbit` and `pr-agent-settings` repositories turn automatic review off, and only while every fleet repository carries its own file. [Repository Configuration "Central Bot Settings"][repo-config-central] describes the gate. - **GitHub Copilot**: the carried `.github/copilot-instructions.md`, which bootstraps the `fleet-code-review` Skill, is the lever this repository uses. GitHub also documents path-scoped `.github/instructions/*.instructions.md` files, unused here. ## Plan and Repository Scope @@ -96,6 +97,10 @@ Private repositories remain Copilot-only unless a candidate's approved plan, dat [pr-892]: https://github.com/ptr727/ProjectTemplate/pull/892 [stall-issue]: https://github.com/ptr727/ProjectTemplate/issues/1741 + + +[repo-config-central]: repo-config.md#central-bot-settings + [coderabbit-auto-review]: https://docs.coderabbit.ai/configuration/auto-review diff --git a/docs/repo-config.md b/docs/repo-config.md index cdb734d5e..6ade0b18a 100644 --- a/docs/repo-config.md +++ b/docs/repo-config.md @@ -13,6 +13,7 @@ The hub holds all fleet-wide repository configuration: - `labels.json` declares the fleet label set. - `project.json` declares the fleet project every repository is linked to, by owner, number, and title. - `configure.sh` applies or checks those payloads through the GitHub API. +- `central/` holds the READMEs `scripts/central_config.py` writes into the central bot-settings repositories, per "Central Bot Settings" below. Downstream repositories carry no `repo-config/` directory. The registry's `workflowModel` selects the `develop` payload, and its `environments` declares the deployment environments the check mode asserts. Both are read from `registry/repos.json` rather than from a payload here. Commands that operate before registry enrollment pass the model explicitly. @@ -34,6 +35,26 @@ repo-config/configure.sh apply owner/repo release|operational Then validate the result with `repo-config/configure.sh check owner/repo release|operational`, run from the same checkout. The command asserts every applied ruleset, setting, label, security feature, and the fleet project link, plus the deployment environments described below. It exits non-zero on drift (the settings checks are driven by the committed payloads, and the ruleset checks by the payloads composed for the repo). Or import each ruleset by hand from the payloads `configure.sh` composes for the repo. Write them with `uv run --no-project --script scripts/agent_policy.py rulesets --registry registry/repos.json --name --model --out-dir `. Then run `gh api -X POST repos///rulesets --input /.json` for each of `develop` and `main`. `gh ruleset` is read-only, so creation goes through `gh api`. [`repo-config/README.md` "Rulesets"][repo-config-readme-rulesets] says what the composition changes. The required check binds by name and only turns green after the repo's PR workflow runs once. To edit a live ruleset, GET it, change the field, and PUT the whole writable subset back (a partial PUT `422`s). +## Central Bot Settings + +CodeRabbit reads a repository named `coderabbit` under the owner as central configuration, and Qodo reads `pr-agent-settings`. Each holds a README and one config file that turns automatic review off account-wide. A repository carrying its own `.coderabbit.yaml` uses that file instead. A repository carrying its own `.pr_agent.toml` overrides each key that file sets. + +`scripts/central_config.py` writes both repositories from the hub. The READMEs are hand-authored sources under `repo-config/central/`, and the config text is a constant in the script. Each settings repository has a registry entry with `status: "excluded"`, so the fleet audit expects no baseline from it. + +A central file with automatic review off silences the bot on every repository that lacks its own file. So the config file exists only while every live registry repository under the owner carries its own file. Each repository's own file sits on its default branch and sets the same key to a bool. A live repository is any entry that is neither archived nor excluded, and a registry listing none under the owner refuses rather than passing. That key is `reviews.auto_review.enabled` for CodeRabbit and `config.disable_auto_feedback` for Qodo. An earlier central file without this gate silenced CodeRabbit on the repositories that had no file of their own yet. + +- `precondition` prints `ok` or `FAIL` per repository. It exits 0 when the gate holds, 1 when it does not, and 2 when a read could not run. +- `write` puts the README, and the config file only while the gate holds, into a checkout. It removes a config file the gate no longer allows and prints a `withheld` line naming the repositories that lack their own file. It never stages or commits, and `--dry-run` writes nothing. +- `check` reads the settings repository at a ref, `main` by default, and reports drift from what `write` produces. A config file present while the gate fails is drift, and one withheld while the gate fails is not. + +```sh +uv run --no-project --script scripts/central_config.py precondition --repo ptr727/coderabbit --registry registry/repos.json +uv run --no-project --script scripts/central_config.py write --repo ptr727/coderabbit --registry registry/repos.json --checkout +uv run --no-project --script scripts/central_config.py check --repo ptr727/pr-agent-settings --registry registry/repos.json --ref main +``` + +Carrying the result into a settings repository is a pull request there, and it needs the maintainer's go-ahead. `write` reads the gate once, and the file takes effect only when that pull request merges. So run `check` just before the merge and again after it. Run it again whenever a repository joins the registry. + ## Deployment Environments `check` asserts that every environment the registry entry's `environments` declares exists and carries the declared deployment-branch policy, and `apply` writes none. The asymmetry is deliberate. An environment's secrets and variables are credentials that exist nowhere in the hub. So an `apply` could create the environment and set its policy and still leave it unable to publish, while reporting success. Their names are enumerable through the API, and their values in the case of a variable. But no tool here queries those stores. That is a choice about what this script owns rather than a limit the API imposes. The policy is checkable on its own and worth checking, because it decides which refs may deploy at all. On an OIDC publish that is half the gate: a ref the policy excludes mints no token. diff --git a/registry/repos.json b/registry/repos.json index ef87146d2..a119e31da 100644 --- a/registry/repos.json +++ b/registry/repos.json @@ -356,6 +356,18 @@ "url": "https://github.com/ptr727/GoogleTo1Password", "status": "archived", "driftNotes": ["Archived on GitHub. Found missing from the registry by the fleet membership check (ptr727/ProjectTemplate#550). No further conformance work is expected while archived."] + }, + { + "name": "coderabbit", + "url": "https://github.com/ptr727/coderabbit", + "status": "excluded", + "exclusionReason": "CodeRabbit's central configuration for the owner, not a fleet project. Its whole content is written by scripts/central_config.py, which docs/repo-config.md \"Central Bot Settings\" describes, so it owes no fleet baseline." + }, + { + "name": "pr-agent-settings", + "url": "https://github.com/ptr727/pr-agent-settings", + "status": "excluded", + "exclusionReason": "Qodo's central configuration for the owner, not a fleet project. Its whole content is written by scripts/central_config.py, which docs/repo-config.md \"Central Bot Settings\" describes, so it owes no fleet baseline." } ] } diff --git a/repo-config/README.md b/repo-config/README.md index 11fb5320c..401361f48 100644 --- a/repo-config/README.md +++ b/repo-config/README.md @@ -7,6 +7,8 @@ Hub-only repository and branch configuration held as committed files, kept out o - `project.json`: the fleet project every repository is linked to, declared as the project owner, the project number, and the project title. `repo-config/configure.sh apply owner/repo release|operational` resolves the number to a live project and refuses the run when that project's title is not the declared one. It writes the link only when the repository does not already hold it, so a second apply is a read. `check` asserts the link and counts the repository's other project links without judging them, the same way it treats a label the payload never declared. - `configure.sh`: run from a hub checkout at `main`, per [GOVERNANCE.md "Hub-Hosted Tooling"][governance-hub-hosted-tooling]. It resolves every payload path against the hub's `repo-config/` directory. Name the target repository explicitly, since the command defaults to whichever repository the shell is sitting in. `repo-config/configure.sh apply owner/repo release|operational` creates or updates the settings, Dependabot security features, labels, rulesets, and the fleet project link idempotently. With `--checkout ` it also writes the agent policy files into that local checkout. See [Agent Policy][agent-policy]. `repo-config/configure.sh check owner/repo release|operational` is the read-only counterpart and exits non-zero on drift. It is not an exact inverse. It also asserts the agent policy files on the default branch. It asserts that every environment the registry's `environments` declares for the repo exists and carries the declared deployment-branch policy. `apply` writes neither, for the reason [docs/repo-config.md][repo-config-doc] "Deployment Environments" gives. The model defaults to the registry `workflowModel` lookup. Pass it explicitly for a repository outside the registry. Both commands exit early, writing nothing, when the target's registry entry carries `status: "archived"`. GitHub rejects every write to an archived repository, so `apply` could never clear the drift `check` would otherwise report there forever. +- `central/`: the README sources for the owner's central CodeRabbit and Qodo settings repositories, which `scripts/central_config.py` writes. See [docs/repo-config.md][repo-config-doc] "Central Bot Settings". + ## Rulesets Two workflow models share `main.json` but differ on `develop` (registry `workflowModel`, default `release`): diff --git a/repo-config/central/coderabbit/README.md b/repo-config/central/coderabbit/README.md new file mode 100644 index 000000000..42d70251a --- /dev/null +++ b/repo-config/central/coderabbit/README.md @@ -0,0 +1,39 @@ +# coderabbit + +CodeRabbit's organization-wide configuration for the `ptr727` repositories. + +## Purpose + +[CodeRabbit][coderabbit-link] reads a repository named `coderabbit` under an organization or account as that owner's central configuration. A repository that carries no `.coderabbit.yaml` of its own uses the `.coderabbit.yaml` here. A repository that carries one uses its own file instead. + +A fleet repository chooses which reviewers run, on which branches, and when, in its own `.github/agent-policy.json`. That file is rendered from the [ProjectTemplate][projecttemplate-link] registry, together with the repository's `.coderabbit.yaml` and `.pr_agent.toml`. So once present, the default here reaches only a repository the registry renders no files for, such as a new one. It turns automatic review off, so it starts no review nobody asked for. + +## Status + +A central default with automatic review off silences CodeRabbit on every repository that lacks its own file. So `.coderabbit.yaml` is present here only while every fleet repository carries its own `.coderabbit.yaml` on its default branch, setting `reviews.auto_review.enabled`. [`scripts/central_config.py`][central-config-link] `write` adds the file when that holds and removes it when it does not. + +## Where the Rules Live + +This repository holds configuration only. The rules it serves live in ProjectTemplate: + +- [Pull Request Reviewer Reference][reviewer-reference-link] describes each reviewer bot and how its configuration is committed. Its "Review Configuration" section covers the review policy. +- [`spec/agent-policy.schema.json`][agent-policy-schema-link] defines the policy file, and [`spec/agent-policy.default.json`][agent-policy-default-link] is the default a repository inherits where its own file states none. +- [`GOVERNANCE.md`][governance-link] "PR Review Etiquette" governs how a review is requested, triaged, and resolved. +- [Repository Configuration][repo-config-link] describes `repo-config/configure.sh`, which applies each repository's bot settings. + +## Changing the Configuration + +ProjectTemplate writes this repository with [`scripts/central_config.py`][central-config-link]. Make a change there and carry it here by a pull request. Never edit this repository in place. The [settings reference][coderabbit-config-link] names each option. + + +[coderabbit-config-link]: https://docs.coderabbit.ai/reference/configuration +[coderabbit-link]: https://www.coderabbit.ai +[projecttemplate-link]: https://github.com/ptr727/ProjectTemplate + + +[agent-policy-default-link]: https://github.com/ptr727/ProjectTemplate/blob/main/spec/agent-policy.default.json +[agent-policy-schema-link]: https://github.com/ptr727/ProjectTemplate/blob/main/spec/agent-policy.schema.json +[central-config-link]: https://github.com/ptr727/ProjectTemplate/blob/main/scripts/central_config.py +[governance-link]: https://github.com/ptr727/ProjectTemplate/blob/main/GOVERNANCE.md#pr-review-etiquette +[repo-config-link]: https://github.com/ptr727/ProjectTemplate/blob/main/docs/repo-config.md +[reviewer-reference-link]: https://github.com/ptr727/ProjectTemplate/blob/main/docs/pr-reviewer-reference.md diff --git a/repo-config/central/pr-agent-settings/README.md b/repo-config/central/pr-agent-settings/README.md new file mode 100644 index 000000000..c4baa2d4c --- /dev/null +++ b/repo-config/central/pr-agent-settings/README.md @@ -0,0 +1,39 @@ +# pr-agent-settings + +Qodo's organization-wide configuration for the `ptr727` repositories. + +## Purpose + +[Qodo][qodo-link] reads a repository named `pr-agent-settings` under an organization or account as that owner's central configuration. It reads `.pr_agent.toml` from this repository's default branch for every repository under the owner. A repository carrying its own `.pr_agent.toml` on its default branch overrides each key that file sets, and inherits the rest from here. + +A fleet repository chooses which reviewers run, on which branches, and when, in its own `.github/agent-policy.json`. That file is rendered from the [ProjectTemplate][projecttemplate-link] registry, together with the repository's `.coderabbit.yaml` and `.pr_agent.toml`. Every rendered `.pr_agent.toml` sets `config.disable_auto_feedback`. So once present, that key here reaches only a repository the registry renders no files for, such as a new one. It turns automatic feedback off, so it starts no review nobody asked for. + +## Status + +Qodo reads a repository's own file only from its default branch. So a central default with automatic feedback off silences Qodo wherever a repository's own file has not reached that branch. `.pr_agent.toml` is therefore present here only while every fleet repository carries its own `.pr_agent.toml` on its default branch, setting `config.disable_auto_feedback`. [`scripts/central_config.py`][central-config-link] `write` adds the file when that holds and removes it when it does not. + +## Where the Rules Live + +This repository holds configuration only. The rules it serves live in ProjectTemplate: + +- [Pull Request Reviewer Reference][reviewer-reference-link] describes each reviewer bot and how its configuration is committed. Its "Review Configuration" section covers the review policy. +- [`spec/agent-policy.schema.json`][agent-policy-schema-link] defines the policy file, and [`spec/agent-policy.default.json`][agent-policy-default-link] is the default a repository inherits where its own file states none. +- [`GOVERNANCE.md`][governance-link] "PR Review Etiquette" governs how a review is requested, triaged, and resolved. +- [Repository Configuration][repo-config-link] describes `repo-config/configure.sh`, which applies each repository's bot settings. + +## Changing the Configuration + +ProjectTemplate writes this repository with [`scripts/central_config.py`][central-config-link]. Make a change there and carry it here by a pull request. Never edit this repository in place. The [configuration reference][qodo-config-link] names each option. + + +[projecttemplate-link]: https://github.com/ptr727/ProjectTemplate +[qodo-config-link]: https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/ +[qodo-link]: https://www.qodo.ai + + +[agent-policy-default-link]: https://github.com/ptr727/ProjectTemplate/blob/main/spec/agent-policy.default.json +[agent-policy-schema-link]: https://github.com/ptr727/ProjectTemplate/blob/main/spec/agent-policy.schema.json +[central-config-link]: https://github.com/ptr727/ProjectTemplate/blob/main/scripts/central_config.py +[governance-link]: https://github.com/ptr727/ProjectTemplate/blob/main/GOVERNANCE.md#pr-review-etiquette +[repo-config-link]: https://github.com/ptr727/ProjectTemplate/blob/main/docs/repo-config.md +[reviewer-reference-link]: https://github.com/ptr727/ProjectTemplate/blob/main/docs/pr-reviewer-reference.md diff --git a/scripts/README.md b/scripts/README.md index e60dcefaa..7f61de431 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -4,9 +4,9 @@ The fleet's checks and review tooling, run by hand, with the deterministic ones **Hosted here and reached, never carried.** These are not declared in [`spec/files.json`][files], so the audit does not expect a downstream repo to ship them, the same footing as `spec/audit.py`. That is the fleet model rather than an omission: a gate holding no per-repo content has one canonical implementation for the fleet. The prose and repository gate implementations live beside their composite actions under `.github/actions/`. That placement lets reusable workflows reach the implementation at their pinned hub commit through `$/.github/actions/` without checking out the hub. The same-named files in `scripts/` are thin local entry points that call those action-owned implementations. They let maintainers and hooks retain the established commands from a hub checkout without creating a second copy of either gate. A repository that cannot reach the hub reports a local check as not run rather than reconstructing it. That repository does so because a rebuilt gate encodes its author's reading of the rule and agrees with no other repository. -Python only, and standard library only. The exceptions are markdown-it-py, PyYAML, ruamel.yaml, tomlkit, and EditorConfig. `backlog_metrics.py`, `build_dist.py`, `canonical_review.py`, `carry.py`, `pr_review.py`, `pr_review_copilot.py`, and `pr_cleanup.py` declare markdown-it-py in their inline script metadata, and `build_dist.py` declares PyYAML as well. `build_dist.py` and `carry.py` import markdown-it-py only on the path that reads a region. `build_dist.py` imports PyYAML only on the path that measures a skill description. That is because `skills_install.py` and `handoff.py` import them under a plain `python3`. Every check script is read-only and exits non-zero on a finding. `build_dist.py`, `local_review.py`, `canonical_review.py`, `handoff.py`, `agent_policy.py`, and `skills_install.py` below are the exceptions. A generator, two recorders, an installer, the handoff chain, and the agent policy writer all exist to write. `build_dist.py --check` and `skills_install.py --report` are read-only modes for CI and for asking without changing anything. `local_review.py status` and `check` answer without recording anything, but they are not read-only in that same sense. Reading the working tree stages it, which writes inside `.git` and runs any `filter.*.clean` the repository configures. Only the receipt is left untouched. `canonical_review.py` reads files rather than staging them, so its `list`, `status`, `sweep`, and `report` are read-only outright, and `record` alone writes. +Python only, and standard library only. The exceptions are markdown-it-py, PyYAML, ruamel.yaml, tomlkit, and EditorConfig. `backlog_metrics.py`, `build_dist.py`, `canonical_review.py`, `carry.py`, `pr_review.py`, `pr_review_copilot.py`, and `pr_cleanup.py` declare markdown-it-py in their inline script metadata, and `build_dist.py` declares PyYAML as well. `build_dist.py` and `carry.py` import markdown-it-py only on the path that reads a region. `build_dist.py` imports PyYAML only on the path that measures a skill description. That is because `skills_install.py` and `handoff.py` import them under a plain `python3`. Every check script is read-only and exits non-zero on a finding. `build_dist.py`, `local_review.py`, `canonical_review.py`, `handoff.py`, `agent_policy.py`, `central_config.py`, and `skills_install.py` below are the exceptions. A generator, two recorders, an installer, the handoff chain, and the two settings writers all exist to write. `build_dist.py --check` and `skills_install.py --report` are read-only modes for CI and for asking without changing anything. `local_review.py status` and `check` answer without recording anything, but they are not read-only in that same sense. Reading the working tree stages it, which writes inside `.git` and runs any `filter.*.clean` the repository configures. Only the receipt is left untouched. `canonical_review.py` reads files rather than staging them, so its `list`, `status`, `sweep`, and `report` are read-only outright, and `record` alone writes. -The directory separates its kinds by name and by tree. A gate checks and exits non-zero on a finding, and its name carries a `_lint` or `_gate` suffix saying what it gates. The `prose_lint.py` and `repo_gate.py` entry points delegate to the action-owned implementations that gate this tree in CI, and `host_gate.py` gates the machine it runs on. A utility does work rather than gating and carries no suffix: `backlog_metrics.py`, `build_dist.py`, `canonical_review.py`, `handoff.py`, `local_review.py`, `pr_cleanup.py`, `pr_review.py`, `pr_review_copilot.py`, `skills_install.py`. `gh_graphql.py` is a library with no command line, the GraphQL transport and cursor walker that `backlog_metrics.py`, `handoff.py`, `pr_cleanup.py`, and `pr_review.py` import from beside them. `pr_review_checks.py`, `pr_review_check_lines.py`, `pr_review_rounds.py`, and `pr_review_digest.py` are libraries with no command line as well. They are the pure readers `pr_review.py` imports for the head's checks, its review rounds, and the digest rendered from both. `pr_review_policy.py` reads and validates a repository's review policy, and `pr_review_side.py` reads and asks the comment-triggered reviewers, its one write handed in by `pr_review.py`. `pr_review_payload.py` reads the policy's key and each bot's entry off a payload, for the readers that may not load `pr_review_policy.py`. The digest takes its lines about the checks from `pr_review_check_lines.py`. The unit tests live apart at the repository root under [`tests/`][tests], one `test_