Skip to content

chore(hooks): fast fmt+lint pre-commit gates; full validation moves to CI - #428

Closed
codeaholicguy wants to merge 1 commit into
mainfrom
chore/hooks-skip-metadata-only
Closed

codeaholicguy wants to merge 1 commit into
mainfrom
chore/hooks-skip-metadata-only

Conversation

@codeaholicguy

@codeaholicguy codeaholicguy commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

The husky pre-commit hook ran fmt:check + lint + test (nx run-many across all 8 projects, ~80s) for every commit. Per review direction, this replaces the heavy local gates with fast ones and relies on CI for full validation:

Retained in pre-commit (every commit, ~3s total):

  • npm run fmt:check — repo-wide oxfmt check + cargo fmt --check (~1-3s)
  • npx oxlint packages/*/src --ignore-pattern "**/ui/**" — lightweight lint over the same src trees npm run lint covers, minus clippy (~0.6s, warnings only)

Removed from pre-commit (now CI-only):

  • npm run lint (full nx lint incl. cargo clippy -D warnings)
  • npm run test (nx run-many test, all 8 projects)
  • npm run build was never in the hook; unchanged

CI coverage confirmed — .github/workflows/ci.yml runs on pull_request → main: fmt:check, lint, build, Rust toolchain + devkitd build, test, plus a separate Rust job (fmt + clippy + test). .github/workflows/e2e.yml adds the e2e matrix on PRs.

Evidence — hook behavior, real commits (isolated worktree)

Commit Staged Hook ran Time Result
docs-only (docs/hook-test-docs.md) docs fmt:check + oxlint 2.9s committed, stat verified
code (packages/cli/src/util/text.ts) code fmt:check + oxlint 3.5s committed, stat verified

Both commits contain exactly the staged file — no empty-commit corruption, because the test suite no longer runs inside the hook.

CI / branch-protection status (read-only inspection)

  • ci.yml + e2e.yml trigger on every PR to main — full fmt/lint/build/test/e2e coverage exists.
  • However, enforcement is NOT verified: main has no branch protection (API 404), and the single ruleset main (id 12999697) is enforcement: disabled and contains only deletion + non_fast_forward rules — no required status checks. CI will run and report on PRs, but nothing technically blocks merging a red PR. Flagging per instructions; no repo settings were modified. If merge-gating is desired, a ruleset with required checks (Test (Node 20), Rust (fmt + clippy), E2E jobs) needs to be enabled — that requires owner action.

Validation

  • sh -n .husky/pre-commit — clean
  • npm run fmt:check — pass
  • npm run lint — pass (8 projects; same warnings as before, pre-existing)
  • npm run test — pass earlier on this branch base (8 projects; hook change does not touch tested code)
  • npx oxlint packages/*/src --ignore-pattern "**/ui/**" — 0.56s, rc=0, warnings only; src/ui/** exclusions match memory-dashboard's lint script
  • Post-commit git show --stat verified on branch commit and both hook test commits; git ls-tree -r count identical to origin/main (1638)

Notes / risks

  • GIT_ leakage remains an unresolved finding* (not fixed here): the pre-commit hook exports GIT_DIR/GIT_INDEX_FILE; test-spawned git commands can inherit them and mutate the real index (observed producing empty commits). Moving tests out of the hook removes the exposure for commits, but the leak still exists for any other git-hook context that runs tests — recommended follow-up: scrub GIT_* in vitest.setup.ts.
  • pi-session-tracker has no src/ dir and no lint target; the packages/*/src glob simply skips it, matching nx lint coverage exactly (7 JS projects + rust clippy, the latter CI-only now).
  • Commits made with HUSKY=0 after manual gate runs, per the corruption finding above.
  • lefthook.yml in the main checkout is an unmodified upstream example; the active hook is husky (.husky/pre-commit).

Generated with Devin

Replace the full fmt:check + lint + test pre-commit suite with fast
pre-commit formatting (oxfmt check) and lightweight lint (oxlint over
packages/*/src, ~1s). The nx lint/test/build gates move to CI, which
already runs fmt:check, lint, build, and test on every pull request
(.github/workflows/ci.yml) plus the e2e matrix (e2e.yml).

This removes the ~80s per-commit cost and, more importantly, keeps the
known test-suite git-index corruption (GIT_DIR/GIT_INDEX_FILE leaking
into test-spawned git commands) out of the commit path entirely —
the exposure window shrinks to zero for local commits.

Note: committed with HUSKY=0; the new hook itself was exercised
directly (sh -n, manual run) and fmt:check + npm run lint were run
manually and are green.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@codeaholicguy
codeaholicguy force-pushed the chore/hooks-skip-metadata-only branch from 7628aab to 5ee3cb5 Compare November 9, 2026 18:12
@codeaholicguy codeaholicguy changed the title chore(hooks): skip full gates for metadata/docs-only commits chore(hooks): fast fmt+lint pre-commit gates; full validation moves to CI Nov 9, 2026
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