diff --git a/catalog/snippets/pre-commit/README.md b/catalog/snippets/pre-commit/README.md index b89df18d0..ee110896c 100644 --- a/catalog/snippets/pre-commit/README.md +++ b/catalog/snippets/pre-commit/README.md @@ -40,7 +40,7 @@ rather than silently skipping the gate. The unresolved-commit fallback reads the prose gate and its data from `main` twice. When the two reads differ, it refuses to run a mixed pair, and a re-run is the remedy. -Install and enable with `uv tool install pre-commit` once, then `pre-commit install`. +Install with `uv tool install pre-commit` once per host. Enable it once per clone with `python3 hub_fetch_run.py scripts/enable_hooks.py`, which runs `pre-commit install` in that clone. `pre-commit` itself is never added as a project dependency. The lint-only profile has no project environment to add it to, and `uv tool install` gives a persistent command independent diff --git a/docs/pre-commit-hooks-rollout.md b/docs/pre-commit-hooks-rollout.md index baac45f79..613fa2383 100644 --- a/docs/pre-commit-hooks-rollout.md +++ b/docs/pre-commit-hooks-rollout.md @@ -34,9 +34,14 @@ vendored or pinned. ## Per-Repo Conversion Copy and adapt the applicable catalog snippet, and copy `catalog/snippets/hub_fetch_run.py` into the repo root. -Enable it (`git config core.hooksPath .husky`, or `uv tool install pre-commit` once then -`pre-commit install`). For the Husky.Net snippet specifically, also run `dotnet tool restore` -then `dotnet husky install`, which generates `.husky/_/husky.sh`, the file the hook sources. +Enable it once per clone with `python3 hub_fetch_run.py scripts/enable_hooks.py`, run in that clone. +The script detects the framework, enables it, and reports what it found and what it changed. +For the Husky.Net snippet it runs `dotnet tool restore` then `dotnet husky install`, which generates `.husky/_/husky.sh`, the file the hook sources. +The `pre-commit` framework needs `uv tool install pre-commit` once per host first. +The script refuses a linked worktree, whose Git config is its base clone's, as is its hooks directory where no `core.hooksPath` is set. +A conversion worked in a linked worktree therefore enables nothing there. +The hook is enabled from the base clone instead, once that clone holds the converted files. +A worktree's own Husky.Net runtime is prepared per `repo-worktree` "Preparing Git Hooks". Confirm the doc gates run clean against the repo's current tree. Open the PR through the repo's normal branching model. A repo whose corpus does not yet pass its language formatter clean ships the doc-gate half first. diff --git a/scripts/README.md b/scripts/README.md index b1b04e056..9c29ebe1b 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. Every library a script declares inline is pinned to one exact version, and so is each package one of those requires. An open bound once let an upstream release change the prose gate with no change here. `tests/requirements.txt` pins the same versions, and `PinTests` in `tests/test_backlog_metrics.py` holds every pin equal. `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`, `skills_install.py`, and `secrets_sync.py` below are the exceptions. A generator, two recorders, an installer, the handoff chain, the two settings writers, and the secrets sync 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` and `prune` alone write. +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. Every library a script declares inline is pinned to one exact version, and so is each package one of those requires. An open bound once let an upstream release change the prose gate with no change here. `tests/requirements.txt` pins the same versions, and `PinTests` in `tests/test_backlog_metrics.py` holds every pin equal. `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`, `skills_install.py`, `secrets_sync.py`, and `enable_hooks.py` below are the exceptions. A generator, two recorders, an installer, the handoff chain, the two settings writers, the secrets sync, and the hook enabler 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` and `prune` alone write. -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: `agent_policy.py`, `backlog_metrics.py`, `build_dist.py`, `canonical_review.py`, `carry.py`, `central_config.py`, `handoff.py`, `local_review.py`, `pr_cleanup.py`, `pr_review.py`, `pr_review_copilot.py`, `secrets_sync.py`, `skills_install.py`. `gh_graphql.py` is a library with no command line. It is the GraphQL transport and cursor walker that `agent_policy.py`, `backlog_metrics.py`, `central_config.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`, `pr_review_hold.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, the hosted-review registration grace, and the digest rendered from them. `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`. `pr_review_promotion.py` reads a promotion's commits back to the pull requests that landed them, for the coverage reading a green Dependabot bump earns. `pr_cleanup_rest.py` is a library with no command line too, holding the REST reads `pr_cleanup.py` makes, a promotion's shape among them. `run_deadline.py` is a library with no command line as well. It runs a captured child under a deadline that holds on Windows, where `subprocess.run` waits out a grandchild holding the pipes. `host_gate.py`, `local_review.py`, `pr_cleanup.py`, `pr_review.py`, and `skills_install.py` import it, and `test_skills_install.py` tests it. `docker_lint.py` keeps its own runs, since a carrying repository fetches it with only its pin manifest beside it. 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_