Repository navigation
fix(hooks): keep the pre-commit-gate lint cache on the root fs - #263
Conversation
The pre-commit-gate hook's golangci-lint run forced GOCACHE into a tempfile.TemporaryDirectory under /tmp and left Go's $WORK at the default /tmp. On hosts where /tmp is a small tmpfs (or a sandbox caps /tmp writes), the lint build exceeds the quota and the gate fails environmentally — a clean tree cannot commit. This redirects the lint temp dirs to a per-user root-fs cache (~/.cache/charly-gate-lint/) and sets GOTMPDIR/TMPDIR so Go's build work and golangci-lint's own temp files follow. Also create the TMPDIR/GOTMPDIR subdirs before running golangci-lint: golangci-lint v2 locks at $TMPDIR/golangci-lint.lock, and a missing TMPDIR makes the lock open fail with ENOENT, which golangci-lint reports as "parallel golangci-lint is running" — a false positive that blocks every commit on hosts where the dir does not pre-exist. Assisted-by: Claude Code deepseek-v4-flash:cloud (analysed on a live system)
pr-validator — CHANGES REQUESTED ❌Change class: hook/workflow (dev-tooling gate — Head SHA validated: The change itself is technically sound — I independently verified it (details below). But the PR FAILS on three checklist items: the body does not follow the mandatory PR template, the change ships no test coverage for its new behavior, and no CHANGELOG entry is staged. Per the rulebook, a single failed item blocks the merge. Checklist
What I independently verified (the change works)
Secondary observation (not blocking on its own)
Comments considered: none — the PR carries no comments. Cross-PR interactions considered:
Decision: FAIL — not merged. The author must:
Assisted-by: Claude Code deepseek-v4-flash:cloud (analysed on a live system) |
…-open cache-root creation The pre-commit-gate hook golangci-lint run forced GOCACHE into a tempfile.TemporaryDirectory under /tmp and left Go $WORK at the default /tmp. On hosts where /tmp is a small tmpfs (or a sandbox caps its writes), the lint build exceeds the quota and the gate fails environmentally — a clean tree cannot commit. This redirects the lint temp dirs to a per-user root-fs cache (~/.cache/charly-gate-lint/) and sets GOTMPDIR/TMPDIR so Go build work and golangci-lint temp files follow. - lint_staged_go creates ~/.cache/charly-gate-lint/ and runs each module golangci-lint inside a TemporaryDirectory rooted there, with GOCACHE/GOLANGCI_LINT_CACHE/GOTMPDIR/TMPDIR set to subdirs it creates first (golangci-lint v2 locks at $TMPDIR/golangci-lint.lock — a missing TMPDIR makes the lock open fail with ENOENT, reported as "parallel golangci-lint is running"). - The cache-root creation is fail-open: a HOME that cannot be written falls back to the system temp dir (the pre-fix behavior) rather than blocking the commit. - gate_test.py gains a red/green pair: with HOME redirected to a temp dir, a lint-clean Go commit passes the gate AND ~/.cache/charly-gate-lint/ is created under the redirected HOME (the pre-fix hook never created it). 37 cases, 0 failures. Assisted-by: Claude Code deepseek-v4-flash:cloud (analysed on a live system)
The previous commit fixed the generated .claude/hooks/pre-commit-gate.sh and gate_test.py by hand. Both are GENERATED from the candy's hook entities by `charly marketplace generate` — a regeneration would have reverted the fix (verified: the first regenerate after the hand-edit dropped the new gate_test.py cache-redirect case). This lands the same change in the source of truth, candy/charly-hooks/charly.yml: - the pre-commit-gate hook entity's content now creates ~/.cache/charly-gate-lint/ (fail-open on an unwritable HOME), roots the lint TemporaryDirectory there, and sets GOCACHE/GOLANGCI_LINT_CACHE/ GOTMPDIR/TMPDIR to subdirs it creates first (golangci-lint v2 locks at $TMPDIR/golangci-lint.lock — a missing TMPDIR is its ENOENT "parallel golangci-lint is running" false positive); - the gate_test.py AUX entity gains the red/green pair proving the lint cache lands under a redirected HOME. `charly marketplace generate` is now a no-op on this tree (the emitted .claude/hooks/* are byte-identical to the committed files), so the fix survives regeneration. Assisted-by: Claude Code deepseek-v4-flash:cloud (analysed on a live system)
pr-validator — APPROVED ✅Change class: hook/workflow (dev-tooling gate — Head SHA validated: Fresh independent evaluation — I re-derived every claim from the diff, the repo, and my own re-runs; none of the author's assertions were taken on trust. Checklist
Comments considered
Cross-PR interactions considered
DecisionPASS — the change is in full compliance. The hook fix is root-cause-driven, the red/green test pair proves the new coverage fails without the change, the source-of-truth candy is byte-identical to the committed hooks, and the CHANGELOG is staged. Proceeding to merge-time CalVer finalization, squash-merge, and tag. Assisted-by: Claude Code deepseek-v4-flash:cloud (analysed on a live system) |
Assisted-by: Claude Code deepseek-v4-flash:cloud (analysed on a live system)
Change class
Code/config (the pre-commit-gate hook + its behavioral test suite).
What
The pre-commit-gate hook's golangci-lint run forced
GOCACHEinto atempfile.TemporaryDirectoryunder/tmpand left Go's$WORKat the default/tmp. On hosts where/tmpis a small tmpfs (or a sandbox caps its writes), the lint build exceeds the quota and the gate fails environmentally — a clean tree cannot commit. This redirects the lint temp dirs to a per-user root-fs cache (~/.cache/charly-gate-lint/) and setsGOTMPDIR/TMPDIRso Go's build work and golangci-lint's own temp files follow..claude/hooks/pre-commit-gate.sh:lint_staged_gocreates~/.cache/charly-gate-lint/and runs each module's golangci-lint inside aTemporaryDirectoryrooted there, withGOCACHE/GOLANGCI_LINT_CACHE/GOTMPDIR/TMPDIRset to subdirs it creates first. The subdir creation is load-bearing: golangci-lint v2 locks at$TMPDIR/golangci-lint.lock, and a missing TMPDIR makes the lock open fail with ENOENT, which golangci-lint reports as "parallel golangci-lint is running" — a false positive that blocks every commit on hosts where the dir does not pre-exist. The cache-root creation is fail-open: a HOME that cannot be written falls back to the system temp dir (the pre-fix behavior) rather than blocking the commit..claude/hooks/gate_test.py: a red/green pair proving the lint cache lands on the root fs — withHOMEredirected to a temp dir, a lint-clean Go commit passes the gate AND~/.cache/charly-gate-lint/is created under the redirected HOME (the pre-fix hook never created it). 37 cases, 0 failures.candy/charly-hooks/charly.yml(the source of truth): both hook entities — thepre-commit-gate:content and thegate_test.pyAUX entity — carry the same fix..claude/hooks/*are GENERATED from these entities bycharly marketplace generate; a regeneration after a hand-edit-only fix would have reverted it (verified: the first regenerate dropped the new gate_test.py case). With the candy updated,charly marketplace generateis a no-op on this tree — the emitted files are byte-identical to the committed ones, so the fix survives regeneration.CHANGELOG/2026.225.0000.md: the cutover entry (placeholder CalVer, finalized by the pr-validator at merge).How R10-tested
The hook is a deterministic command-mechanics gate; the change-class gate is the behavioral test suite that drives the actual hook script against fixture repos. Run from the worktree with a root-fs
TMPDIR(the test's temp HOME must not sit on the capped/tmp):python3 .claude/hooks/gate_test.py:Red arm (the new cache-redirect case against the pre-fix hook — the assertion that
~/.cache/charly-gate-lint/is created under the redirected HOME fails, proving the test would fail without the change):Live: the spec follow-up commit (opencharly/spec#26) passed through the fixed hook with golangci-lint running clean on the staged Go module.
Attribution tier
analysed on a live system— the changed runtime path (the hook's lint-temp-dir redirect) ran live: the full behavioral gate suite passed with pasted output above, and the red/green pair proves the new coverage fails without the change. The complete fresh-rebuild R10 (a disposable bed) does not apply to a hook change — the hook is exercised by the gate suite itself.Harness rulebook compliance
/charly-internals:go-quality(the pre-commit-gate hook paragraph + the golangci-lint lock finding) before editing the hook.GOCACHE/$WORKonto the capped/tmp; the fix redirects them to the root fs. The "parallel golangci-lint is running" false positive was RCA'd to golangci-lint v2's$TMPDIR/golangci-lint.lockENOENT lock-open error.feat/hook-gate-lint), no force-push, no direct push tomain; PR-only landing.Assisted-by: Claude Code deepseek-v4-flash:cloud (analysed on a live system)