chore: add lefthook git hooks and polyglot static analysis toolchain - #480
Open
BillyOutlast wants to merge 1 commit into
Open
chore: add lefthook git hooks and polyglot static analysis toolchain#480BillyOutlast wants to merge 1 commit into
BillyOutlast wants to merge 1 commit into
Conversation
Two enforcement layers: fast local hooks at commit/push, authoritative scans in CI. Nothing in CI depends on a hook having run. - lefthook (root devDep, wired via prepare script): pre-commit formats staged files (prettier + eslint --fix), runs ast-grep structural scan and gitleaks secret scan (<10s); pre-push runs server typecheck, per-crate clippy on changed crates, golangci-lint, knip report - security.yml: gitleaks full-history scan (direct CLI — gitleaks-action requires a paid license for orgs), cargo-audit matrix across all 7 Rust crates with lockfile generation for vendored crates that gitignore it, golangci-lint job for the Go backend (--new-from-rev rollout mode) - semgrep-scheduled.yml: weekly deep scan -> SARIF -> Code Scanning, deliberately not wired into push/PR CI - knip report-only job in server-ci (non-blocking during rollout) - configs: knip.json (workspace-aware), sgconfig.yml + starter rules (no-console-log TS/Vue, no-fmt-println Go), backend/.golangci.yml v2 with gosec, shared root .prettierrc.json, clippy-changed.sh helper - CLAUDE.md documenting what runs when, escape hatches, native binary install paths, and rollout baselines Rollout is deliberately non-disruptive: knip report-only, golangci-lint new-issues-only, ast-grep rules as warnings — each documented in CLAUDE.md with its baseline count for flipping to strict later. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a two-layer quality-gate setup for the polyglot monorepo: fast local hooks at commit/push, authoritative scans in CI. Nothing in CI depends on a hook having run — hooks are early feedback, CI is the authority.
What's included
"prepare": "lefthook install"— hooks self-install onpnpm install, no brew prerequisite. Glob-filtered so irrelevant commands skip entirely (a markdown-only commit pays ~nothing)security.yml— gitleaks full-history scan via direct CLI (gitleaks-actionrequires a paid license for organization repos), cargo-audit matrix across all 7 Rust crates with on-the-fly lockfile generation for vendored crates that gitignore theirs, golangci-lint job for the previously-unlinted Go backendsemgrep-scheduled.yml— weekly deep scan uploaded to Code Scanning; deliberately not in push/PR CI where its runtime would hurtknip.jsonsgconfig.yml+rules/):no-console-log(server TS/Vue),no-fmt-println(Go)backend/.golangci.yml(v2 syntax) with gosec + core linters.prettierrc.json(copied from server/)CLAUDE.mddocumenting what runs when, escape hatches, native binary install paths, and machine-readable output commands for AI agentsRollout philosophy
Deliberately non-disruptive — each gate starts in warn/report mode with a recorded baseline in CLAUDE.md:
--new-from-rev=origin/developnew-issues-onlyseverity: warningEach has a documented flip-to-strict path once triaged. The clippy pre-push hook skips
desktop/src-taurilocally (needs Tauri system libs) but CI covers it.Verification
Negative-tested: a staged fake API key fails pre-commit via gitleaks.