Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion catalog/snippets/pre-commit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions docs/pre-commit-hooks-rollout.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 13 additions & 2 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_<script>.py` per script, driving the canonical implementations against input they must reject. The reader modules `pr_review.py` imports are tested through `test_pr_review.py`. A gate nobody has watched fail is a gate nobody knows works. Where a case covers a table, it reads the live table rather than restating it. Each such case also asserts a floor on what a healthy run reaches. That is because a check whose scan matches nothing reports zero findings and reads exactly like a pass.
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`, `enable_hooks.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_<script>.py` per script, driving the canonical implementations against input they must reject. The reader modules `pr_review.py` imports are tested through `test_pr_review.py`. A gate nobody has watched fail is a gate nobody knows works. Where a case covers a table, it reads the live table rather than restating it. Each such case also asserts a floor on what a healthy run reaches. That is because a check whose scan matches nothing reports zero findings and reads exactly like a pass.

```sh
python3 tests/test_prose_lint.py
Expand Down Expand Up @@ -544,6 +544,17 @@ A title must be a safe relative path, judged the same way on every platform. An

No official page states the `op` behaviors the tool relies on, so `selftest` measures them. On `op` 2.42.0 it measured the byte-exact document round-trip, the item list's `updated_at` field, and an archived item leaving the listing. It also sets the `sync` fields with `op item edit` and reads them back with `op item get`. Then it sets them again and checks that `op document edit` keeps them. No run against a live `op` has measured that field shape yet. The PowerShell signin form, a desktop-app sign-in, several accounts, and Windows stay unmeasured. A shape other than the one measured fails loudly rather than being guessed at. Exit `0` is success, `1` a refusal the caller can act on, and `2` the command not having run to an answer. `selftest` also exits `1` where a measured behavior differs from the one assumed, and `2` where it could not delete its scratch vault. `--dry-run` prints the plan and each `op` write it would send, and sends none of them.

## `enable_hooks.py`

Enables a clone's Git hook framework, once per clone, with one Python script for Linux, macOS, and Windows. A hook setting lives in the clone's own `.git/`, which its worktrees share, so nothing committed and no GitHub setting can turn it on. A downstream repository reaches the script through its root `hub_fetch_run.py` copy, run from the clone.

```sh
python3 hub_fetch_run.py scripts/enable_hooks.py
python3 scripts/enable_hooks.py
```

It reads the framework from the clone's top level. `.husky/` with a .NET tool manifest declaring Husky.Net runs `dotnet tool restore`, then `dotnet husky install`. `.husky/` without one sets `core.hooksPath` to `.husky`. `.pre-commit-config.yaml` runs `pre-commit install`, which needs `uv tool install pre-commit` once per host first. A clone holding both, or neither, is refused. It prints the framework it found and a `changed` or `unchanged` line. A clone already enabled is left as it is, so an unchanged run writes nothing. A `core.hooksPath` naming another directory is never replaced. Nor is a `pre-commit` hook the framework did not write, since installing over it would move it aside and chain to it. A linked worktree is refused before its files are read, since its Git config is the base clone's. So is its hooks directory where no `core.hooksPath` is set. A worktree's own Husky.Net runtime is prepared per `repo-worktree` "Preparing Git Hooks" instead. So the script runs in the maintainer's own checkouts, an agent's standalone clone, and the base clone `repo-worktree` creates worktrees from. It exits `0` when enabled or already enabled, `1` on a refusal or a failed step, and `2` on an unknown argument.

<!-- Internal -->

[agent-safety-install]: ../host-setup/agent-safety/claude/install.py
Expand Down
Loading
Loading