Skip to content
This repository was archived by the owner on Jul 2, 2026. It is now read-only.

Commit e67b204

Browse files
committed
feat(alef-docs-fresh): support custom alef command via hook args
Repos that build an extension-aware alef binary (e.g. spikard's spikard-alef, which registers an HTTP-domain IR extension) must verify with that binary; the generic alef on PATH computes a different inputs-hash and reports every generated file as stale. The hook now invokes a command supplied via args with 'verify --exit-code' appended, falling back to alef on PATH when no args are given so existing consumers are unaffected.
1 parent be5b69b commit e67b204

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.3.0] - 2026-06-20
11+
12+
### Added
13+
14+
- `alef-docs-fresh`: support a custom alef command via hook `args`. Repos that
15+
build an extension-aware alef binary (e.g. spikard's `spikard-alef`, which
16+
registers an HTTP-domain IR extension) must verify with that binary — the
17+
generic `alef` on PATH computes a different inputs-hash and reports every
18+
generated file as stale. Pass the override as args (e.g.
19+
`args: ["cargo", "run", "--quiet", "--release", "-p", "spikard-alef", "--"]`);
20+
`verify --exit-code` is appended. With no args the hook still uses `alef` on
21+
PATH, so existing consumers are unaffected.
22+
1023
## [2.2.0] - 2026-06-18
1124

1225
### Fixed

hooks/alef-docs-fresh/run.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@
22
# alef-docs-fresh — Verify that Alef-generated documentation is fresh.
33
# Runs `alef verify --exit-code` to check that generated content is up-to-date
44
# against the IR. If alef.toml is absent, exits 0 (no-op for non-polyglot repos).
5+
#
6+
# Repos that build a custom alef binary with extensions must verify with THAT
7+
# binary, not the generic `alef` on PATH — otherwise the inputs-hash differs and
8+
# every generated file is reported stale. Supply the override command as hook
9+
# args; `verify --exit-code` is appended to it. Example (.pre-commit-config.yaml):
10+
#
11+
# - id: alef-docs-fresh
12+
# args: ["cargo", "run", "--quiet", "--release", "-p", "spikard-alef", "--"]
13+
#
14+
# With no args, the hook falls back to the `alef` binary on PATH.
515
set -euo pipefail
616

717
# Quick check: if no alef.toml exists, skip silently.
818
if [[ ! -f alef.toml ]]; then
919
exit 0
1020
fi
1121

22+
# A custom alef command supplied via hook args takes precedence over the `alef`
23+
# binary on PATH (e.g. an extension-aware build such as spikard's spikard-alef).
24+
if [[ "$#" -gt 0 ]]; then
25+
exec "$@" verify --exit-code
26+
fi
27+
1228
if ! command -v alef >/dev/null 2>&1; then
1329
printf 'kreuzberg-pre-commit-hooks: skipping alef-docs-fresh — `alef` not found on PATH.\n' >&2
1430
printf ' install alef: https://github.com/kreuzberg-dev/alef\n' >&2

tests/test_alef_docs_fresh.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,30 @@ def test_hook_skips_when_alef_missing(tmp_path: Path) -> None:
2525
"""
2626
result = run_hook(HOOK, path_override=empty_path(tmp_path), cwd=tmp_path)
2727
assert result.returncode == 0
28+
29+
30+
def test_hook_uses_custom_command_from_args(tmp_path: Path) -> None:
31+
"""A custom alef command passed via args is invoked with `verify --exit-code`.
32+
33+
Repos with an extension-aware build (e.g. spikard's spikard-alef) must verify
34+
with that binary. The override is used even when no `alef` is on PATH.
35+
"""
36+
(tmp_path / "alef.toml").write_text("[workspace]\n")
37+
marker = tmp_path / "invoked-with"
38+
stub = tmp_path / "fake-alef"
39+
stub.write_text(f'#!/usr/bin/env bash\nprintf "%s" "$*" > "{marker}"\nexit 0\n')
40+
stub.chmod(0o755)
41+
42+
result = run_hook(HOOK, str(stub), cwd=tmp_path)
43+
44+
assert result.returncode == 0
45+
assert marker.read_text() == "verify --exit-code"
46+
47+
48+
def test_hook_propagates_custom_command_failure(tmp_path: Path) -> None:
49+
"""A non-zero exit from the custom alef command must fail the hook."""
50+
(tmp_path / "alef.toml").write_text("[workspace]\n")
51+
52+
result = run_hook(HOOK, "false", cwd=tmp_path)
53+
54+
assert result.returncode != 0

0 commit comments

Comments
 (0)