Skip to content

fix(workspace): ship the commit-msg hooks to flake-generated consumers - #1439

Merged
c-vigo merged 4 commits into
devfrom
bugfix/1434-consumer-commit-msg-hooks
Aug 12, 2026
Merged

c-vigo merged 4 commits into
devfrom
bugfix/1434-consumer-commit-msg-hooks

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #1434. A direnv consumer on flake-generated hooks (the #1167 default) had no local commit-message or agent-identity enforcement at all.

validate-commit-msg, prepare-commit-msg-strip-trailers and check-agent-identity were defined scaffold = true with no consumer fragment, so mkProjectShell's generated config omitted all three. The scaffolded .githooks/commit-msg shim then ran prek run --hook-stage commit-msg against an empty stage and exited 0 — the exact false guarantee #1019 was filed to remove ("every scaffolded repo shipped a COMMIT_MESSAGE_STANDARD.md it could not enforce"), and git commit --author="Claude <...>" passed locally too.

Pre-existing since #883/#1167, not a regression; CI (validate-commit-range, check-pr-agent-fingerprints) was the only line of defense for these consumers.

Type of Change

  • fix -- Bug fix
  • test -- Adding or updating tests
  • docs -- Documentation only

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

Route chosen: consumer fragments with Nix store-path entries, not "append the portable definition verbatim". The portable yaml entries are uv run <tool>, which resolves against the consumer's project venv — and a consumer venv has no vig-utils (many consumers have no pyproject.toml at all). Every other tool-naming consumer fragment (nixfmt, statix, deadnix, just-fmt, gitleaks, pymarkdown) already resolves ${pkgs.<tool>}/bin/…, so the hook version follows the devkit pin the consumer bumps with nix flake update vigos. git-hooks.nix supports commit-msg/prepare-commit-msg in its stages set, so "stage-gated" was never the blocker — the header's "not generatable" claim was stale and is corrected.

  • nix/vig-utils.nix (new) -- the vig-utils package lifted verbatim out of flake.nix's overlay, so hook fragments build it from an un-overlaid pkgs. pkgs.vig-utils existed only via overlays.default, which would have made the generation surface fail eval on a plain pkgs. Follows the existing nix/pymarkdown.nix precedent — one definition, no new overlay requirement.
  • nix/hooks.nix -- consumer fragments for the three hooks; defaultCommitTypes + refsOptionalTypesFor + validateCommitMsgArgs helpers, with the committed YAML render now deriving its argv from the same helper (one literal, not two); consumer render takes a knob attrset ({ workflow, branchTypes, commitTypes, refsPolicy }) instead of four positional nullables.
  • flake.nix -- mkProjectShell gains commitTypes ? null / refsPolicy ? null with eval-time asserts mirroring the scaffold guards (per-entry [a-z][a-z0-9]*, non-empty list; three-value enum).
  • assets/workspace/flake.nix -- reads DEVKIT_COMMIT_TYPES / DEVKIT_REFS_POLICY from .vig-os, each forwarded behind a builtins.functionArgs vigos.lib.mkProjectShell ? <arg> probe so a floating vigos input predating the argument still evaluates (Scaffolded flake breaks on fresh install while devkit main predates the workflow argument #1249 pattern). New vigOsList helper now that the comma-list parse has two callers.
  • docs/MIGRATION.md, assets/workspace/.vig-os, CHANGELOG.md (+ hook-synced mirror).

Knob-resolution consistency (the issue's hard requirement). The flake path resolves exactly as render_commit_types / render_refs_policy (assets/init-workspace.sh) and resolve-toolchain do: same default 11-type list, same trim/drop-empty parse, same charset allowlist, optional mirroring the resolved list (the #1431 composition, not a hardcoded stock copy), required using the none sentinel. Divergence is now structurally impossible on the Nix side, since validateCommitMsgArgs renders both the committed YAML and the consumer config.

Changelog Entry

### Fixed

- **Flake-generated hooks now carry the commit-message and agent-identity guards** ([#1434](https://github.com/vig-os/devkit/issues/1434))

(Full entry with sub-bullets is in CHANGELOG.md under ## Unreleased -> ### Fixed.)

Testing

  • Tests pass locally
  • Manual testing performed (describe below)

Manual Testing Details

Live behavioral proof against a real generated config symlinked into a scratch repo, not just render assertions:

check before after
prek run --hook-stage commit-msg on totally-invalid message… exit 0, no hooks exit 1 -- First line must match 'type(scope): short description'
valid fix(hooks): … + Refs: -- exit 0
check-agent-identity with GIT_AUTHOR_NAME=Claude absent exit 1 -- matches blocklisted AI agent identity: 'claude'
commitTypes=[feat,fix,chore,record] refsPolicy=optional -> record(registry): … no Refs -- exit 0
same config -> perf(x): … -- exit 1 -- Allowed types: chore, feat, fix, record

The "before" row is grounded: the pre-fix generated config's hook list contained none of the three.

  • uv run pytest tests/test_flake_hooks.py -> 59 passed, exit 0 (baseline 45; RED run: 1 failed, 29 errors -- function 'mkProjectShell' called with unexpected argument 'commitTypes').
  • Targeted regression set (test_flake_hooks, test_flake_devshell, test_workflow_model, test_vig_os_manifest, test_ci_runner, test_scaffold_drift) -> 176 passed, 1 skipped, exit 0.
  • prek run --all-files -> exit 0, fully green (re-run after merging dev).
  • nix flake check --accept-flake-config . on a clean tree -> exit 0, all checks passed!.
  • Custom-knob render verified directly: --types feat,fix,chore,record --refs-optional-types feat,fix,chore,record, i.e. optional mirrors the resolved list, matching render_refs_policy's RESOLVED_COMMIT_TYPES branch.

Note: tests/test_image.py::TestFileStructure::test_manifest_files fails locally, and fails identically on a clean dev without this branch — it checksums the working-tree CHANGELOG.md against a locally cached devcontainer image. Stale-image noise, unrelated to this change; CI rebuilds the image.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Invariants held. Drift gate: .pre-commit-config.yaml (both copies) is absent from the diff entirely — the argv refactor renders byte-identically. Zero-hooks parity: TestZeroHooksParity passes with an identical drvPath; the three hooks exist only on the consumer surface, inert without a hooks/hooksExcludes opt-in. Default-render stability: new test_default_args_match_the_scaffolded_render asserts consumer argv == scaffold argv == the stock six-element list.

Adoption is a behavior change worth calling out in the release notes — a consumer whose history contains non-conformant messages will start seeing local rejections on its next nix flake update vigos. Existing direnv consumers get nothing until they hand-port the .vig-os reader into their scaffold-once flake.nix (the same one-time port as #1224/#1432, now documented in MIGRATION.md); until then the hooks ship with stock defaults, still strictly better than no hooks.

Deliberately not done. No check (sandbox) fragments — the Nix sandbox has no git repo and no commit to inspect, and check-agent-identity short-circuits under CI=true; those would be dead weight. check-agent-identity does now run under a direnv consumer's prek run --all-files lint job, but returns 0 immediately when CI/GITHUB_ACTIONS is set, so consumer CI is unaffected (container-mode consumers have shipped it since #1031).

Suggested follow-up: check-expirations's consumer fragment still uses uv run check-expirations — the exact venv-resolution weakness this issue is about, and now the odd one out among the vig-utils consumer fragments. Should move to the same store-path form.

Closes #1434

Refs: #1434

@c-vigo
c-vigo merged commit 20e5660 into dev Aug 12, 2026
14 checks passed
@c-vigo
c-vigo deleted the bugfix/1434-consumer-commit-msg-hooks branch August 12, 2026 07:55
c-vigo added a commit that referenced this pull request Aug 12, 2026
The #1443 entry (c427dee) replaced the "Flake-generated hooks now carry
the commit-message and agent-identity guards" title bullet instead of
inserting above it, so #1434's three sub-bullets hung off #1444 and #1434
had no entry of its own — the release notes would have reported a
consumer-facing change to local commit-message and agent-identity
enforcement as part of an unrelated smoke-dispatch branch-naming fix.

Restore the title line verbatim as merged in #1439, in its original slot
ahead of #1414; the sub-bullets are byte-identical to that render and
need no re-indentation. The hook-synced .devcontainer mirror follows.

Documentation-only change to a data file, so RED-GREEN TDD does not
apply. No test is added: the defect is a sub-bullet attached to the wrong
parent, not an orphan, so a structural "every sub-bullet has a titled
parent" assertion passes both before and after the fix and cannot express
it.

Refs: #1453
c-vigo added a commit that referenced this pull request Aug 12, 2026
## Description

Fixes #1453. **Targets `release/1.8.0`** — the train is cut and
`1.8.0-rc1` is tagged; this must land before the notes are finalized,
after which the `[1.8.0]` section is released and immutable.

The #1434 entry had lost its bold title bullet, so its three sub-bullets
hung off the #1444 entry. As it stood, the 1.8.0 release notes would
have presented a user-visible fix to local commit-message and
agent-identity enforcement as part of an unrelated smoke-dispatch
branch-naming fix, and #1434 would have had no entry at all.

## Type of Change

- [x] `docs` -- Documentation only

### Modifiers

- [ ] Breaking change (`!`) -- This change breaks backward compatibility

## Changes Made

A **single added line**. No re-indentation was needed — the orphaned
sub-bullets were already at the correct 2-space depth:

```diff
     (devkit-smoke-test#354) but every deploy overlays the template back over
     it, re-arming the regression for the next train. Dots now map to dashes
     in the template SSoT, matching the live listener
+- **Flake-generated hooks now carry the commit-message and agent-identity guards** ([#1434](#1434))
   - A direnv consumer on flake-generated hooks had **no local commit-message
     or agent-identity enforcement at all**: `validate-commit-msg`,
```

`### Fixed` now reads #1447, #1443, #1444, #1434, #1414, #1403, #1396,
and #1444 keeps only its own sub-bullet.

**The title is recovered, not invented.** `git show
20e5660:CHANGELOG.md` (the PR #1439 merge) carries this exact line, and
#1439's body proposes it verbatim under "Changelog Entry". The restored
20-line region diffs byte-identical against the original, and the entry
lands back in its original slot ahead of #1414.

**Root cause — this corrects the guess in the issue.** It was *not* the
changelog freeze. `046ca547` only moved headings (14 insertions / 4
deletions). The culprit is **`c427dee8`** (#1443), whose diff shows `--
**Flake-generated hooks…**`: it *replaced* the #1434 title line instead
of inserting above it. `d0f276cd` (#1444) then inserted below that,
inheriting the orphans.

## Changelog Entry

No changelog entry needed — this **is** a changelog repair. Adding a
"fixed the changelog" bullet to the section it repairs would be noise in
the released notes.

## Testing

- [x] Tests pass locally
- [x] Manual testing performed (describe below)

### Manual Testing Details

- `prek run --all-files` -> exit 0, fully green, including `pymarkdown`
on both the root file and the synced mirror — which is the real risk
here, since it validates list nesting. Re-run clean after
`sync-manifest` mirrored the file.
- `uv run pytest tests/ -q` -> 780 passed, 20 skipped, 1 failed. The
single failure is the known
`tests/test_image.py::TestFileStructure::test_manifest_files`,
**proved** pre-existing rather than assumed: stashing to a fully
pristine tree reproduces it, and the stale image's *destination* hash is
identical across both runs (`0b4f7b0ff94c…`) while only the source hash
moves. CI rebuilds the image.
- Re-verified after merging `release/1.8.0` in: `prek run --all-files`
exit 0, the restored entry intact, #1448's entry present.
- The mirror `assets/workspace/.devcontainer/CHANGELOG.md` was written
by the hook, never hand-edited; its diff is the same single line.

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have updated the documentation accordingly
- [x] I have updated `CHANGELOG.md` (this PR *is* the changelog change)
- [x] My changes generate no new warnings or errors
- [x] I have added tests that prove my fix is effective or that my
feature works -- see below
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published

## Additional Notes

**No test was added, deliberately.** The defect is not an orphaned
sub-bullet — the three sub-bullets had a perfectly valid parent (#1444).
A "every sub-bullet has a titled parent entry" assertion passes
identically before and after this fix, so it cannot express the bug. The
only detecting heuristic would be "a sub-bullet cites an issue other
than its parent's", which this changelog violates constantly by design
(#1447's sub-bullet cites #1434; #1443's cites #1344/#1348/#1423). It
would be almost entirely false positives. This is a semantic authorship
error, not a structural one — which is also why `pymarkdown` passes it.
TDD does not apply; the commit body says so explicitly rather than
skipping it silently.

Nothing below `## [1.8.0]` was touched. Every top-level bullet in the
1.8.0 section was checked against the canonical shape post-fix; all 19
conform. One suspected second instance was chased and cleared: the #1403
entry's sub-bullets about smoke deploys preserving `CHANGELOG.md` look
misparented, but `git show 64b524a` proves all three were authored
together as facets of the same sync-conflict fix.

Two cosmetic inconsistencies remain, both pre-existing and deliberately
out of scope: stray blank lines between three entries in `### Changed`
(#1411, #1409, #1405) where every other section is contiguous, and
trailing periods on four sub-bullets (#1403's three, #1396's one) where
the rest of the section is period-free.

**Worth flagging for the train:** this defect class — a hand-inserted
entry silently consuming the line beneath it — survived a PR review and
the freeze, and surfaced only by eye during #1447 review. Since the
section becomes immutable at cut, one last read of the rendered notes
before finalize is cheap insurance.

Closes #1453

Refs: #1453
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