Skip to content

feat(ci): Static Analysis runs the commit hygiene hooks #4779

Done

Description

@dan-petty

Problem or Motivation

The 10 hygiene hooks run only at a local commit or at a commit of a runner step. No CI job runs them: no workflow under .github/workflows runs pre-commit.

Proposed Solution & Architectural Design

Mark trailing-whitespace, end-of-file-fixer, mixed-line-ending, check-yaml, detect-private-key, check-merge-conflict, check-toml, check-json and ruff-format with stages: [pre-commit, manual].

Keep these hooks out of the manual stage:

  • ruff-check: the lint row runs it in CI. Its --fix deleted an unused import with no message in a test.
  • check-added-large-files: with --all-files it checks only added files, so it checks nothing. With --enforce-all, CHANGELOG.md (862 KB) and uv.lock (761 KB) fail.

Add a devops ci row hooks that runs uv run pre-commit run --all-files --hook-stage manual --show-diff-on-failure. Static Analysis runs it with the other rows. Its limit comes from #4775.

Add ~/.cache/pre-commit to the tooling cache paths of .github/actions/setup-toolchain. #4727 also changes these paths.

The help text says that the row fixes files in a local run.

Fix the one file on main in the same pull request.

Target Subsystem

SDLC, Git & PR Governance (.pre-commit-config.yaml, src/devops_cli/commands/ci.py, .github/actions/setup-toolchain).

Existing Tool Considered

The pre-commit manual stage runs the same hooks in CI with no second definition. Rejected: pre-commit.ci and autofix.ci (a second service and a bot that pushes). Cost (estimate): about 100,000 tokens and 2 hours to build, near 0 to keep.

Acceptance Criteria

  • Static Analysis shows the row and passes on main.
  • In a test repository, a file with no final newline makes the row fail and show the diff.
  • The Static Analysis job takes at most 10 s more with a warm cache (4.4-5.5 s measured for the run).
  • The manual stage does not change a file that has an unused import.

Dependencies

#4776. Related: #4727.

Source: #4771

Alternatives check of 2026-11-24: in-use.
The repository already uses this tool.
Tool: pre-commit/pre-commit (https://github.com/pre-commit/pre-commit), MIT, last activity 2026-11-09, maintained.
Reason: Searches surfaced no better dedicated CI hook runner; pre-commit's manual stage runs the existing hooks in CI, but the project still needs its hooks row, workflow wiring, cache path and hook exclusions.

Covers:

  • Runs the configured hooks with --hook-stage manual
  • Uses the existing .pre-commit-config.yaml with no second definition
  • Checks all tracked files and can show diffs on failure

Lacks:

  • No devops ci hooks row or Static Analysis wiring
  • No ~/.cache/pre-commit toolchain cache path
  • No exclusion of ruff-check or check-added-large-files

Proposed design

Problem statement

No CI job runs the commit hygiene hooks. One tracked file on main ends with two newlines. About one agent push a week uses --no-verify, and cloud agent sessions install no hooks. This change runs the nine hygiene hooks in Static Analysis through the pre-commit manual stage, adds the devops ci hooks row, caches the hook environments, and fixes the bad file.

Acceptance criteria

Requirement: Manual stage runs the nine hygiene hooks

The hooks trailing-whitespace, end-of-file-fixer, mixed-line-ending, check-yaml, detect-private-key, check-merge-conflict, check-toml, check-json and ruff-format SHALL run in the manual stage as well as the pre-commit stage.

Scenario: Manual stage names the nine hooks

  • WHEN uv run pre-commit run --all-files --hook-stage manual runs on main.
  • THEN The command exits 0 and its output names each of the nine hooks.

Requirement: Unsafe hooks stay out of the manual stage

The manual stage MUST NOT run ruff-check or check-added-large-files.

Scenario: Manual stage names neither unsafe hook

  • WHEN uv run pre-commit run --all-files --hook-stage manual runs on main.
  • THEN The command exits 0 and its output names neither ruff-check nor check-added-large-files.

Requirement: The hooks row is registered

The hooks row SHALL be a row of devops ci: it SHALL appear in get_check_specs() and in CONST_CI_CHECK_ROW_NAMES.

Scenario: The row tuple matches the registry

  • WHEN A test imports CHECK_ROW_NAMES and get_check_specs from src/devops_cli/commands/ci.py.
  • THEN hooks is in CHECK_ROW_NAMES, get_check_spec("hooks") returns the row, and the tuple equals the registry order.

Requirement: Hooks row command

The hooks row of devops ci SHALL run uv run pre-commit run --all-files --hook-stage manual --show-diff-on-failure.

Scenario: The check registry holds the hooks command

  • WHEN A test imports get_check_spec from src/devops_cli/commands/ci.py and reads the command of the hooks row.
  • THEN The command is uv run pre-commit run --all-files --hook-stage manual --show-diff-on-failure.

Requirement: Static Analysis runs the hooks row

The Static Analysis job of .github/workflows/ci.yml SHALL run the hooks row with its other rows.

Scenario: Static Analysis log shows the hooks row

  • WHEN The Static Analysis job runs on the pull request.
  • THEN The job log shows the hooks row and the job passes.

Requirement: The tooling cache restores the pre-commit environments

The Static Analysis job SHALL set PRE_COMMIT_HOME to .data/cache/pre-commit and the tooling cache of .github/actions/setup-toolchain SHALL restore and save that path, so that a warm cache keeps the hooks row within 10 s.

Scenario: Second Static Analysis run reuses the pre-commit cache

  • WHEN The Static Analysis job runs a second time with the tooling cache of the first run.
  • THEN The setup-toolchain step reports a tooling cache hit for .data/cache/pre-commit and the hooks row finishes in at most 10 s.

Requirement: Help text states local fixes

The help text of the hooks row SHALL say that a local run fixes files.

Scenario: Hooks help text

  • WHEN uv run devops ci hooks --help runs.
  • THEN The output states that a local run fixes files.

Requirement: The hooks row passes on main

uv run devops ci hooks SHALL pass on main and change no file.

Scenario: Hooks row on main

  • WHEN uv run devops ci hooks runs on main.
  • THEN The command exits 0 and changes no file.

Requirement: Every tracked file ends with one newline

Every tracked file on main SHALL end with exactly one final newline.

Scenario: End-of-file fixer passes on main

  • WHEN uv run pre-commit run end-of-file-fixer --all-files --hook-stage manual runs on main.
  • THEN The hook exits 0 and changes no file.

Requirement: A missing final newline fails with the diff

The hooks row SHALL fail and print the diff of a tracked file that has no final newline.

Scenario: File with no final newline

  • WHEN A scratch repository holds a tracked file with no final newline and uv run devops ci hooks runs there.
  • THEN The row exits non-zero and prints the diff of the file.

Requirement: An unused import stays unchanged

The manual stage MUST NOT change a file that has an unused import.

Scenario: File with an unused import

  • WHEN A scratch repository holds a Python file with an unused import and uv run devops ci hooks runs there.
  • THEN The row exits 0 and the file content is unchanged.

Existing Tool Considered

pre-commit/pre-commit (https://github.com/pre-commit/pre-commit), MIT, last activity 2026-11-09, maintained. The alternatives check of 2026-11-24 records the verdict in-use, and its block names what the tool lacks. The change builds no hook runner and no second hook definition.

Key questions

  • Which pre-commit stage should run the hygiene hooks in CI?: Use the manual stage. pre-commit run --all-files --hook-stage manual runs the existing hooks and needs no second hook definition. default_stages is [pre-commit], so a hook runs in manual only when it names that stage, and the installed git hook types are pre-commit and pre-push, so a local commit keeps its behavior. (best practice) [sources: .pre-commit-config.yaml:2, .pre-commit-config.yaml:3, .pre-commit-config.yaml:22-43]
    • Chosen: manual stage. It runs the same hooks on demand and keeps one hook definition for local commits and CI.
    • Rejected: pre-commit stage only. No CI job makes a commit, so the hooks still do not run in Static Analysis.
    • Rejected: second hook set for CI. It duplicates the hook list and lets the local and CI checks drift.
  • Should ruff-check run in the manual stage?: No. The lint row runs ruff-check in CI, and the hook's entry is uv run --no-sync ruff check --config pyproject.toml --fix, so the manual stage would change files. Its --fix deletes an unused import with no message. (best practice) [sources: .pre-commit-config.yaml:69-74, src/devops_cli/commands/ci.py:908-925]
    • Chosen: exclude ruff-check. The lint row covers it, and the manual stage then changes no file.
    • Rejected: include ruff-check. Its --fix changes files and can delete an import with no message.
  • Should check-added-large-files run in the manual stage?: No. With --all-files it checks only added files and finds nothing. With --enforce-all it fails on CHANGELOG.md (862 KB) and uv.lock (761 KB). (best practice) [sources: .pre-commit-config.yaml:34-37, CHANGELOG.md, uv.lock]
    • Chosen: exclude check-added-large-files. The manual all-files run either checks nothing or fails on tracked large files.
    • Rejected: include it with --all-files. It checks only added files, so it checks nothing in this run.
    • Rejected: include it with --enforce-all. It fails on CHANGELOG.md and uv.lock.
  • Which CI job should run the hooks row?: Static Analysis. It is the aggregate required check that runs the devops ci gate, its step uv run devops ci --check --no-cache --skip test,outdated,actionlint runs every other row, and the row adds no test suite. (best practice) [sources: .github/workflows/ci.yml:49-50, .github/workflows/ci.yml:115-117, docs/adr/0043-required-checks-and-main-ruleset-gate-merges.md:42]
    • Chosen: Static Analysis. The row is a static check and the job already runs the other static rows.
    • Rejected: Tests & Coverage. The row runs no test and would lengthen the test job.
    • Rejected: a new workflow job. A new job adds runner time and a required-check change for no extra coverage.
  • Where should the pre-commit cache live for the CI toolchain?: Use PRE_COMMIT_HOME=.data/cache/pre-commit: set it in the Static Analysis job and add that path to the tooling cache paths of .github/actions/setup-toolchain, next to .mypy_cache and .ruff_cache. The project already keeps the hook environments under the data cache directory for the implement job, whose hook_environment() returns PRE_COMMIT_HOME=<data cache>/pre-commit; .data/cache is the default data.cache_dir; and the tooling cache restores repo-relative directories. The Static Analysis job is the only job that uses the default path list, so the new path is restored and saved there. The same job already runs pre-commit through the hadolint row, so its hook environments fill that cache. (best practice) [sources: src/devops_cli/roadmap/implement/implement_hooks.py:69-71, src/devops_cli/roadmap/implement/implement_hooks.py:139-142, openspec/specs/roadmap-implement-job/repair/spec.md:9, docs/CONFIGURATION.md:292, .github/actions/setup-toolchain/action.yml:13-20, .github/workflows/ci.yml:67-70, src/devops_cli/commands/ci.py:1036-1042]
    • Chosen: PRE_COMMIT_HOME=.data/cache/pre-commit, restored by the tooling cache. It follows the project's record for the hook environments, uses the repo-relative paths that the tooling cache restores, and is the same path in the implement job and CI.
    • Rejected: ~/.cache/pre-commit, pre-commit's default. It needs no setting, but the tooling cache has restored no home-directory path and the project records the data cache directory for the hook environments.
    • Rejected: No cache. Each Static Analysis run would install the hook environments again and add avoidable time.
  • What should the help of the hooks row say?: Say that a local run fixes files. _row_command gives every generated row the help Run the {name} check., which is false for this row: the manual stage runs the hooks with their default fix behavior. Give the hooks row its own help text, as a hand-written command like lint or a per-row help in _row_command. (best practice) [sources: src/devops_cli/commands/ci.py:3148-3149, src/devops_cli/commands/ci.py:3153-3161, src/devops_cli/lang/en/help.py:1122]
    • Chosen: state that a local run fixes files. The manual stage runs the hooks with their default fix behavior, so the help must not call the row a check-only run.
    • Rejected: keep the generated Run the hooks check. help. That is false for a local run and hides the file changes.
  • Where must a new devops ci row be named?: In get_check_specs() of src/devops_cli/commands/ci.py and in CONST_CI_CHECK_ROW_NAMES of src/devops_cli/config/constants.py. CHECK_ROW_NAMES reads the constant, a test keeps that tuple equal to the registry order, --only and --skip validate against it, and _register_row_commands registers a subcommand for each name. [sources: src/devops_cli/commands/ci.py:132, src/devops_cli/commands/ci.py:1726-1731, src/devops_cli/commands/ci.py:3153-3161, src/devops_cli/config/constants.py:6202-6231, tests/commands/test_ci_row_commands.py:96-99]
  • Does the Static Analysis job already run pre-commit?: Yes. Its gate skips only test, outdated and actionlint, so it runs the hadolint row, which runs uv run pre-commit run hadolint --all-files. The job therefore already installs pre-commit and its hook environments. [sources: .github/workflows/ci.yml:115-117, src/devops_cli/commands/ci.py:1036-1042]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4776

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/ci
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/ci. The (ci) scope of the title gives the scope.
    • Priority: P2-Medium. Adds CI coverage for hygiene hooks but does not block release or fix a broken flow.
    • Value: Medium. Catches formatting and hygiene issues in CI that local hooks miss.
    • Effort: Low. Candidate estimates about 2 hours to build with near-zero maintenance.
    • Related: feat(ci): fast execution caching when unchanged & pre-commit file change tracking integration #256, which asks for a different change. Both touch pre-commit integration and cache paths, but 256 builds a caching engine while this adds a new hooks row to Static Analysis.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. dan-petty commented on Nov 14, 2026

    @dan-petty
    OwnerAuthor

    Blocked on #4776: the issue declares that dependency, and #4776 (faster commit hooks and more fast pre-push checks) is still open on 2026-11-14. The item also adds a manual hook stage, a devops ci hooks row, the Static Analysis row, a tooling-cache path and the one-file fix, which the issue itself estimates at 2 hours and 100,000 tokens, above effort/low. Return after #4776 merges; then build it as one PR against the settled hook list.

  6. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found the pre-commit framework, which the project already uses (.pre-commit-config.yaml), and its documentation confirms the manual stage that no git hook triggers and that is run on demand with pre-commit run --hook-stage manual in CI. That is exactly the solution the issue proposes, so the need is fully covered and the tool is already named in the issue.

    The repository already uses this tool.

    Tool: pre-commit/pre-commit (https://github.com/pre-commit/pre-commit)

    • License: MIT
    • Last activity: 2026-11-09
    • Maintained: yes

    Covers:

    • Runs the existing hooks in CI on demand with pre-commit run --all-files --hook-stage manual, with no second hook definition
    • The manual stage is a special stage no git hook triggers, so the same .pre-commit-config.yaml serves both local commits and the CI run
    • --all-files checks every tracked file, so a bad file on main is caught
    • --show-diff-on-failure surfaces the diff of a file the hooks would change

    Lacks:

    • It ships no CI job itself: the project must still add the hooks row to the devops ci command and the Static Analysis job
    • It does not provide the tooling cache path for ~/.cache/pre-commit; that is .github/actions/setup-toolchain work
    • It is not a hosted service or bot that pushes fixes (that is pre-commit.ci / autofix.ci, which the issue rejected)

    Tools considered:

    Searches run:

    • pre-commit run --hook-stage manual in CI, results: 5
    • pre-commit.ci autofix.ci pre-commit CI service, results: 5
    • pre-commit framework stages manual hook stage documentation, results: 5
    • pre-commit.ci continuous integration service, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  7. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at e5dfddb while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  8. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  9. added
    status/ready
    and removed
    status/new
    on Nov 29, 2026
  10. 21 remaining items

  11. added
    status/in-progress
    on Nov 30, 2026
  12. devops-cli-service commented on Nov 30, 2026

    @devops-cli-service
    Contributor

    Owner question: The step "group 2" stopped with a plan defect: the plan does not hold. Amend the plan or split the item?

    Options

    1. Amend the plan: A person amends the plan and runs the item again.
    2. Split the item: A person splits the item and plans each part again.

    Recommendation: Amend the plan: the step follows the plan, so a step that cannot follow it names a defect of the plan.

    Evidence

  13. devops-cli-service commented on Nov 30, 2026

    @devops-cli-service
    Contributor

    Stopped at group 2.

    Failure class: plan_defect.
    Action taken: none.
    Action left: wait: wait for a person.

    Step Status Attempts Tokens in/out Last failing command
    group 1 done 1 4345463/16044 pytest on base: tests/commands/test_ci_row_commands.py
    group 2 stopped 1 3023195/18112 -

    Reason:

    The plan request was refused: An amendment cannot change the criteria section.. Defect: Task 2.1 forbids a `stages` line on `check-added-large-files`, but that hook runs in the `manual` stage because its own manifest in pre-commit-hooks v6.0.0 names `manual`. `default_stages` cannot keep it out, so the requirement `Unsafe hooks stay out of the manual stage` fails with the task as written.. Evidence: pre-commit 4.7.0 `pre_commit/repository.py:124` reads `if not ret['stages']: ret['stages'] = root_config['default_stages']`, so the stages of a hook's own manifest win. The cached manifest `~/.cache/pre-commit/repo53h2_ty8/.pre-commit-hooks.yaml:1-6` holds `-   id: check-added-large-files` with `stages: [pre-commit, pre-push, manual]`. With `stages: [pre-commit, manual]` added to the nine hooks and no line on `check-added-large-files`, `uv run devops ci --check --only hooks` exited 0 and printed `check for added large files..............................................Passed`; the nine hooks passed, `ruff-check` did not run, and no tracked file needed a repair. At HEAD the same command names only `trim trailing whitespace`, `fix end of files` and `check for added large files`. The same manifest names `manual` for `end-of-file-fixer` (`:137-143`) and `trailing-whitespace` (`:205-211`), so the premise line that names `.pre-commit-config.yaml:28` and says the hook runs in the `pre-commit` stage only today is false.
    

    Last message of the agent (a claim that no check verified): Group 2 is not verified and no group-2 work is in place: the tree is clean and the plan needs the amendment below. Group 1 stays verified. Commands, each on its own, with its exit status: - git status --short — no output, so the checkout holds no uncommitted change. - uv run devops ci test tests/commands/test_ci_row_commands.py tests/roadmap/test_roadmap_runner_tools.py — 50 passed, exit 0. - uv run devops ci --check --only hooks — exit 0, but its output names only trim trailing whitespace, fix end of files and check for added large files: six of the nine hooks do not run in the manual stage at HEAD, and check-added-large-files does run there. With the nine stages: [pre-commit, manual] lines added, the nine hooks ran and check-added-large-files still ran, which the task forbids me to fix. - git status --short after the run — no output, so the run changed no file. The blocker: pre-commit gives the stages of a hook's own manifest priority over default_stages (pre_commit/repository.py:124), and check-added-large-files in pre-commit-hooks v6.0.0 names stages: [pre-commit, pre-push, manual]. Only a stages line in our config keeps it out of the manual stage, and task 2.1 forbids that line. ```plan-request { "kind": "task", "group": 2, "defect": "Task 2.1 forbids a stages line on `check-added-large-files`, but that hook runs in the `manual` stage because its own manifest in pre-commit-hooks v6.0.0 names `manual`. `default_stages` cannot keep it out, s

    The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item allow it.

  14. added
    status/blocked
    and removed
    status/in-progress
    owner/service
    on Nov 30, 2026
  15. added
    status/in-review
    and removed
    status/blocked
    on Dec 1, 2026
  16. removed
    status/in-review
    on Dec 1, 2026
  17. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Live since 2026-12-01 16:30 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/cisource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions