Skip to content

feat(builtins): add hk_validate builtin to fail on config warnings - #1862

Merged
jdx merged 1 commit into
mainfrom
feat/builtins-hk-validate
Nov 18, 2026
Merged

jdx merged 1 commit into
mainfrom
feat/builtins-hk-validate

Conversation

@jdx

@jdx jdx commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Requested in discussion #1861: there was no builtin for running hk validate --deny-warnings, so users wrote the step themselves.

The new hk_validate builtin runs it whenever hk.pkl or .config/hk.pkl changes:

hooks {
  ["pre-commit"] {
    steps { ["hk_validate"] = Builtins.hk_validate }
  }
}

The step passes for a clean config and fails on warnings, such as a step with no command. The command is declared read, matching hk validate, so it runs under --safe.

Validation: a new bats file covers both outcomes and passes locally. I did not run the full suite. The builtin has no pkl-level tests, like hk_test, since the bats file covers it.

AI-assisted β€” Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable.

πŸ€– Generated with Claude Code


Note

Low Risk
Small additive builtin and tests; no changes to core validation or auth paths.

Overview
Adds a new hk_validate builtin so hooks can enforce a warning-free hk.pkl without hand-rolling a step.

The builtin is Special Purpose, watches hk.pkl and .config/hk.pkl, and runs hk validate --deny-warnings with a read effect (aligned with hk validate / safe mode). It is registered in the docs showreel builtins list and covered by bats tests for both a clean config and a config that triggers warnings (e.g. a step with no command).

Reviewed by Cursor Bugbot for commit 91399af. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Documentation
    • Updated the built-in command list to include hk_validate.
  • Tests
    • Added coverage for successful validation of a clean configuration and warnings for configurations with a nocmd step. Also verified that hk check fails when validation warnings are denied.

Runs hk validate --deny-warnings on hk.pkl so config warnings fail the check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
AI-Assisted: Tool: Claude Code; model: unavailable; version: 2.1.325
Entire-Checkpoint: 01M7KG6NVWRAE9XYN0R16DSQPJ
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change β†’

No actionable comments were generated in the recent review.

Walkthrough

The builtin list now includes hk_validate. Bats tests cover hk check with a clean configuration and a configuration that produces a warning.

Changes: hk_validate Listing and Tests

Layer / File(s) Summary
Builtin listing and validation tests
docs/.vitepress/theme/showreel/kit/builtins-list.ts, test/hk_validate_builtin.bats
The builtin list includes hk_validate. Tests check that hk check succeeds with a clean configuration and fails with deny-warnings when the configuration produces a warning. They also check that hk validate output contains warning.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: greptile-apps

Merge Risk: Minimal Β· up to 91399

This adds the hk_validate builtin to the documentation list and adds tests for the clean and warning cases. The risk is minimal and it is ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(builtins): add hk_validate builtin to fail on config warnings" matches the main change. The raw summary shows a new hk_validate entry in the builtins list and a bats test file that che…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(builtins): add hk_validate builtin to fail on config warnings" matches the main change. The raw summary shows a new hk_validate entry in the builtins list and a bats test file that checks a clean config passes and a config with a nocmd step fails under deny-warnings. The PR objectives say the builtin runs hk validate --deny-warnings when hk.pkl changes, so warnings fail the check. The title is specific and concise, and it names the builtin and its purpose. The Pkl builtin file is excluded from review, but the title does not depend on it.

  • Autofix Β· Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: jdx/hk
  • Branch: feat/builtins-hk-validate
  • File: .coderabbit.yaml
  • Commit: 91399af
  • Layers: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 204f55ff-2eea-4b0b-9cf1-163f4eae2913
Commits

Reviewing files that changed from the base of the PR and between 79b1c97 and 91399af.

Files ignored due to path filters: 1

  • pkl/builtins/hk_validate.pkl is excluded by !**/*.pkl
Files selected for processing: 2

  • docs/.vitepress/theme/showreel/kit/builtins-list.ts
  • test/hk_validate_builtin.bats

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 Β· The reviewable changes appear safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The reviewable changes appear safe to merge.

Summary

Adds hk_validate to the showreel’s builtin list and adds tests for clean configs and configs with warnings.

  • Hooks can now fail when hk config validation finds warnings.

Reviews (3) Β· Last reviewed commit: "feat(builtins): add hk_validate builtin" Β· Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Instruction counts

benchmark trend instructions Ξ” wall (min) Ξ”
builtins β–ƒβ–‚β–‚β–‚β–‚β–‚β–β–‚β–‚β–‚β–‚β–‚β–ƒβ–ƒβ–…β–ˆ 1,981,754 β†’ 1,990,988 +0.47% 3.15 β†’ 3.08ms -2.12%
check β€” β€” β€” 19.95 β†’ 19.00ms -4.78%
config-cold β–β–β–β–β–β–β–β–‚β–‚β–‚β–‚β–‚β–‚β–‚β–ˆβ–ˆ 72,334,205 β†’ 72,237,385 -0.13% 22.60 β†’ 21.64ms -4.24%
stash β–‚β–‚β–‚β–β–β–β–ƒβ–ƒβ–ƒβ–ƒβ–ƒβ–ƒβ–ƒβ–ƒβ–ƒβ–ˆ 60,933,600 β†’ 61,566,973 +1.04% ⚠️ 286.88 β†’ 297.80ms +3.81%
usage β–β–†β–‡β–‡β–‡β–‡β–†β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–ˆβ–„ 4,435,786 β†’ 4,408,587 -0.61% 5.06 β†’ 5.02ms -0.69%
validate β€” β€” β€” 14.29 β†’ 14.26ms -0.20%

1 benchmark(s) above the 1% gate: stash +1.04%

Only instruction counts gate. Wall clock is shown for context β€” on identical hardware it moves 4-20% run to run.

Measured by tak β€” instruction-counted CLI benchmarks, stored in this repository's git notes.

91399af8b436 vs baef3672d1e9 Β· measured on the runner, not pushed to the history.

@jdx
jdx merged commit 98dea41 into main Nov 18, 2026
33 of 34 checks passed
@jdx
jdx deleted the feat/builtins-hk-validate branch November 18, 2026 00:42
@jdx jdx mentioned this pull request Nov 18, 2026
jdx added a commit that referenced this pull request Nov 23, 2026
### πŸš€ Features

- **(builtins)** add hk_validate builtin to fail on config warnings by
[@jdx](https://github.com/jdx) in
[#1862](#1862)
- **(builtins)** report ox_lint findings as diagnostics by
[@jdx](https://github.com/jdx) in
[#1871](#1871)
- **(builtins)** add bun_fmt formatter by [@jdx](https://github.com/jdx)
in [#1870](#1870)
- **(builtins)** add scan = "staged" option to betterleaks by
[@jdx](https://github.com/jdx) in
[#1878](#1878)
- **(builtins)** scan every pushed commit for secrets with scan =
"commits" by [@jdx](https://github.com/jdx) in
[#1880](#1880)
- **(step)** add recheck_after_fix to rerun checks a later fix changed
by [@jdx](https://github.com/jdx) in
[#1891](#1891)

### πŸ› Bug Fixes

- **(builtins)** keep empty files empty when fixing with tofu, terraform
and other stdin formatters by [@jdx](https://github.com/jdx) in
[#1874](#1874)
- **(install)** let steps call mise from the global --mise launcher by
[@jdx](https://github.com/jdx) in
[#1875](#1875)
- **(install)** start the per-repo --mise launcher without mise on PATH
by [@jdx](https://github.com/jdx) in
[#1883](#1883)
- **(stash)** stop a nested hk from waiting on the stash lock during
stash recovery by [@jdx](https://github.com/jdx) in
[#1852](#1852)
- **(stash)** stop a stash restore from starting a nested hk through
post-checkout by [@jdx](https://github.com/jdx) in
[#1869](#1869)
- **(stash)** keep intent-to-add files out of the commit with stash =
"none" by [@jdx](https://github.com/jdx) in
[#1884](#1884)
- **(step)** stop adding GIT_WORK_TREE to steps without a dir by
[@jdx](https://github.com/jdx) in
[#1889](#1889)

### πŸ›‘οΈ Security

- **(deps)** update mise tools by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1854](#1854)
- **(deps)** update dependency jouet to v0.0.4 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1859](#1859)

### πŸ” Other Changes

- **(deps)** update url to 2.5.9 by [@jdx](https://github.com/jdx) in
[#1893](#1893)
- **(entire)** remove trail runners by [@jdx](https://github.com/jdx) in
[8cfa90f](8cfa90f)
- remove the pull_request_target workflows by
[@jdx](https://github.com/jdx) in
[#1876](#1876)

### πŸ“¦οΈ Dependency Updates

- update github actions by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1853](#1853)
- lock file maintenance by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1856](#1856)
- update dependency jsdom to v31 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1855](#1855)
- lock file maintenance by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1860](#1860)
- ignore unmaintained chrono advisories in cargo-deny by
[@jdx](https://github.com/jdx) in
[#1868](#1868)
- update rust crate pklr to v6.0.4 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1858](#1858)
- update mise tools by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1895](#1895)
- update github actions by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1894](#1894)
- lock file maintenance by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1896](#1896)
- lock file maintenance by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1899](#1899)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Release-metadata and documentation URL updates only; runtime behavior
changes are documented in the changelog but not introduced in this diff.
> 
> **Overview**
> Cuts **hk v2.14.0** by bumping the crate and CLI version from `2.13.0`
to `2.14.0` in `Cargo.toml`, `Cargo.lock`, `hk.usage.kdl`, and generated
CLI docs, and aligning every docs/example `package://` import with the
new release URL.
> 
> Adds a **2.14.0** section to `CHANGELOG.md` that records what ships in
this tag: new builtins (`hk_validate`, `bun_fmt`, betterleaks `scan =
"staged"` / `"commits"`, ox_lint diagnostics), **`recheck_after_fix`**,
stash/mise/install/step env fixes, dependency and CI housekeeping
(including removing trail runners and `pull_request_target` workflows).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c86fddc. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: mise-en-dev <123107610+mise-en-dev@users.noreply.github.com>
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