Skip to content

ci(lefthook): run each hygiene hook once in standards - #1137

Merged
kyle-sexton merged 2 commits into
mainfrom
ci/lefthook-hooks-once
Nov 25, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
ci/lefthook-hooks-once

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

No linked issue: owner decision Q298 (L3) (melodic-software/architecture docs/owner-decisions.md L426) authorizes this directly.

Summary

In this repository, five hygiene tools ran twice on every commit. The root lefthook.yml extended components/lefthook-base/lefthook.yml, lefthook-shellcheck, lefthook-python and lefthook-typescript, and it also listed the claude-code-plugins aggregate remote. The duplicate pairs were:

  • typos and spelling-remote-lint;
  • markdownlint and markdown-format-remote-lint;
  • shellcheck and bash-format-remote-lint;
  • ruff-lint/ruff-format and python-format-remote-*;
  • biome and javascript-format-remote-*.

The ccp jobs read the same root configs (_typos.toml, .markdownlint-cli2.jsonc, .shellcheckrc, ruff.toml, biome.jsonc). Q298 asks for each hook to run once. Now every hygiene tool runs once, from a remote.

Fix

  • lefthook.yml:
    • drops all four extends entries;
    • lists this repository's own remote (components/lefthook-base/lefthook-remote.yml at main) for standards-gitleaks and standards-editorconfig. It is a remote, not an extends, because the remote's scripts act only from the fetched copy under info/lefthook-remotes/. A local extends would run them from .lefthook/pre-commit/, where they exit 0 (lefthook-base README, "Remote form");
    • carries the strict settings the base fragment supplied, as that README prescribes for a remote consumer: min_version: "2.0.5", assert_lefthook_installed: true, glob_matcher: doublestar and pre-commit.parallel: true;
    • keeps the fixture exclude and the psscriptanalyzer and dotnet-format source-slice lanes unchanged.
  • The component fragments stay. The contract tests still compose them in temporary consumers: lefthook-base.test.sh, lefthook-merge-skip.test.sh, lefthook-shellcheck.test.sh, lefthook-typescript.test.sh and dotnet-format-staged.test.mjs.
  • docs/conventions/ecosystems/{bash,markdown,python,typescript}.yaml: the comments name the claude-code-plugins hook that runs each tool locally, in place of the dropped lane.
  • pr-require-checks.yml:
    • the lefthook validate step is renamed "Validate the root hook config", because the fragments are no longer merged into the root;
    • a new step, "Validate each lefthook component fragment", runs components/lefthook-base/lefthook-fragments-validate.test.sh. That test extends each components/lefthook-*/lefthook.yml alone from a scratch consumer and runs lefthook validate, so the root no longer has to load the fragments for CI to check them.

Verification

  • lefthook dump --format json, after lefthook install fetched both remotes: every pre-commit job and command name appears once. A group_by over the names finds no duplicates.
    • standards-gitleaks and standards-editorconfig appear once each.
    • None of typos, markdownlint, shellcheck, ruff-*, biome, gitleaks or editorconfig appears as a local command.
    • The settings dump as min_version 2.0.5, assert_lefthook_installed true, glob_matcher doublestar, parallel true.
  • This commit's own pre-commit run executed each job once, including standards-gitleaks ("no leaks found") and standards-editorconfig. The hook took 0.60 s.
  • lefthook-fragments-validate.test.sh: 9 assertions pass. Planting an unknown key (commands: renamed) in the real components/lefthook-python/lefthook.yml fails [4], and restoring the file makes it pass.
  • lefthook validate: All good.
  • harness/shell/run-tests.sh on lefthook-base, lefthook-remote, lefthook-merge-skip, lefthook-shellcheck and lefthook-typescript: 5 passed. node --test components/lefthook-dotnet/dotnet-format-staged.test.mjs: 12 passed.

Known overlap I left in place: the psscriptanalyzer lane and ccp's powershell-format-remote-lint both run PSScriptAnalyzer with PSScriptAnalyzerSettings.psd1. The lane stays as a repo-specific adapter that dogfoods components/lefthook-powershell/psscriptanalyzer-staged.ps1. Removing it would make PSScriptAnalyzer run once too.

Related

🤖 Generated with Claude Code

The root lefthook.yml extended the lefthook-base, lefthook-shellcheck,
lefthook-python and lefthook-typescript fragments and also listed the
claude-code-plugins aggregate remote, so typos, markdownlint, ShellCheck,
Ruff and Biome ran twice per commit. Drop the four extends, list this
repository's own remote for Gitleaks and EditorConfig-checker, and carry
the strict settings in the root file. The psscriptanalyzer and
dotnet-format source-slice lanes stay.

Owner decision Q298 (L3).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T06:50:21.890455Z e9af4bd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

claude-security-review reviewed 2e0e983d7e0277d57012cc9871f9c34e2c8d5364: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review (incremental, blocking only): no security issues found

This review covers only what changed since e9af4bd0e01fb882f7ff74bead3180c850506d82. I read every hunk of both files in scope. Because this lane already reviewed an earlier head of this pull request, it reports CRITICAL and IMPORTANT findings only.

  • .github/workflows/pr-require-checks.yml: The change adds one step, "Validate each lefthook component fragment", to the test-lefthook job (L384-L386). That step runs a test script that is already in the repository.
    • Trigger: the workflow runs on pull_request, not pull_request_target.
    • Permissions: the job grants only contents: read and pull-requests: read (L327-L329).
    • Inputs: the step's if: and run: contain no github context expression and no secrets.
    • Merge holds: the change only adds a check. It does not touch the ci-status hold steps.
  • components/lefthook-base/lefthook-fragments-validate.test.sh (new file): for each components/lefthook-*/lefthook.yml, the script copies the fragment into a scratch repo it creates under mktemp -d and runs lefthook validate there. A trap removes the scratch directory on exit.
    • Every path it uses comes from this repository's own tree or from the temp directory.
    • Every variable is quoted. The script runs no eval and makes no network call.
    • It reads no credentials.

No trust control changes: the trusted-trigger check, the lane token, the kill switch, the token broker and the merge holds are all unchanged. The diff has no plugin manifest, nothing that could bill, and no path for untrusted text to reach a lane that holds credentials. The PR description contains no instructions aimed at this lane.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on e9af4bd0e01fb882f7ff74bead3180c850506d82; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment thread lefthook.yml Resolved
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

claude-review reviewed 2e0e983d7e0277d57012cc9871f9c34e2c8d5364: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Code review, PR #1137 (incremental: e9af4bd → 2e0e983)

The prior-findings file says blocking only: yes, so this review reports blocking findings only.

This push fixes the earlier blocking finding. That finding was that the Python fragment components/lefthook-python/lefthook.yml lost its only CI check once the root extends was dropped.

  • New test. components/lefthook-base/lefthook-fragments-validate.test.sh loops over every components/lefthook-*/lefthook.yml. For each one it builds a scratch consumer that extends only that fragment and runs lefthook validate there.
    • The loop covers all six fragments today: base, dotnet, powershell, python, shellcheck and typescript.
    • It also checks that the number it validated equals the number find reports, so a fragment the glob misses fails the test.
  • Self-check. At L53-57 the test renames commands: to xcommandsx: in a copy of the Python fragment and expects lefthook validate to fail. It first checks that the planted key really is in the copy, so the check cannot pass because the sed matched nothing. components/lefthook-python/lefthook.yml:16 does carry commands:.
  • New CI step. pr-require-checks.yml:384-386 runs the new test under the same lefthook filter as the steps around it. That filter includes components/lefthook-*/** (L346), so an edit to any fragment triggers the step.
    • If lefthook is missing, the test calls skip_suite and exits 0. In CI that cannot hide a failure: the step before it (lefthook validate, L383) would already fail without lefthook.

I found no new blocking findings in the incremental change.

Not verified by me. These are the author's claims, unchecked because this lane has no shell and ran nothing:

  • the 9 assertions pass;
  • planting an unknown key in the real Python fragment fails case [4];
  • lefthook's schema rejects an unknown key under pre-commit.

Loosened checks would be marked: fail. This is the default, because the prompt gave no loosened_check_verdict: or loosened_check_patterns: line; patterns: 0. The prompt also gave no loosened_check_decision_record: line, so I did not check the citation requirement.

Verifier dropped 0 of 0 candidates.

The root lefthook.yml no longer extends the component fragments, so the
root `lefthook validate` step stopped loading them. A new test extends
each components/lefthook-*/lefthook.yml alone from a scratch consumer and
runs `lefthook validate`, with a self-check that a misspelled key fails.
CI runs it in the lefthook job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton merged commit 9436624 into main Nov 25, 2026
67 of 68 checks passed
@kyle-sexton
kyle-sexton deleted the ci/lefthook-hooks-once branch November 25, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant