Skip to content

fix(hook): persist selected config in commit-message hooks - #417

Merged
stackbilt-admin merged 6 commits into
mainfrom
fix/issue-341-hook-config
Nov 2, 2026
Merged

stackbilt-admin merged 6 commits into
mainfrom
fix/issue-341-hook-config

Conversation

@stackbilt-admin

@stackbilt-admin stackbilt-admin commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Installed commit-message hooks always read .charter/config.json, even when CI uses validate --config <dir>. Persist the config selection supplied to hook install --commit-msg --config <dir> so the real hook enforces that policy rather than a different default policy.

Relative selections are resolved from the installation directory and recorded relative to Git's worktree root; absolute selections remain absolute. The shell quotes the path as data and passes it to Node after --, including spaces, apostrophes, shell substitutions, and leading dashes. No user-supplied path is interpolated into JavaScript. Reinstallation updates the selection deterministically, managed legacy hooks upgrade, and unmanaged hooks remain untouched unless the existing force option is supplied.

The default config path, trailer-policy semantics, missing-config/no-Node warning-and-skip behavior, and #400's printed Claude event are retained. A missing or malformed selected file names that path in the diagnostic and never falls back to .charter/config.json. The docs explain the missing-file behavior. HIGH-risk local classification remains the separate #342 decision.

Closes #341.

This branch includes reviewed PR #412 (1e9d82be6f4291c8ecec82c52a1f5522c2509a92) as a prerequisite because both issues change hook.ts. The issue-only comparison is against that commit; the PR targets main so required CI runs. Preserve prerequisite ancestry when merging after explicit approval.

Validation in an isolated worktree, Windows Node 24.19.0 / pnpm 9.15.9:

  • Frozen dependency installation, pnpm run build, and pnpm run typecheck: pass.
  • pnpm exec vitest run packages/cli/src/__tests__/hook-config.test.ts packages/cli/src/__tests__/hook.test.ts packages/cli/src/__tests__/hook-claude-local.test.ts packages/cli/src/__tests__/hook-pm.test.ts: 141/141 pass. Twelve new real-Git tests cover strict/disabled custom policy vs opposing default, valid/missing/malformed selections, absolute and subdirectory-relative paths, shell-sensitive and leading-dash paths, reinstall/default restore, legacy upgrades, unmanaged preservation/force, and actual CLI global --config plumbing.
  • pnpm run docs:check: pass (optional docs-sync config absent; papers-lint passed).
  • Existing LF line endings preserved in source/docs; new test file uses LF.
  • Initial full pnpm run test: 1,951 passed, five failed, including one new real-Git fixture exceeding its 5-second timeout under concurrent load. Twelve external-process tests now use a bounded 30-second timeout consistent with existing hook tests; assertions are unchanged. Focused rerun: 141/141 pass. Final full suite: 1,952 passed and only the four known Windows baseline failures (1,956 total). Log: .cache/issue-341-full-tests-final.log.

Main CI currently fails its dependency audit. PR #413 contains the separately approved major-version Zod migration plus #404's compatible repairs and passes Linux CI; this PR does not suppress or weaken any gate. No merge, tag/main push, publication, deployment, production-data change, repository setting change, or remote branch deletion performed.

Confirmed review finding corrected

Normalize only the native platform separator when serializing the selected config path. Literal backslashes in POSIX directory names remain data; Windows path separators are still normalized for the shell. Two real-hook POSIX regression cases cover relative and absolute selections and reinstall stability.

  • Build/typecheck: pass. Focused Windows suites: 141 pass, two POSIX-only cases skipped.
  • Final Windows full run after this fix: 1,952 passed, four known baseline failures, two POSIX cases skipped (1,958 total). Log: .cache/issue-341-posix-fix-full-tests.log. The earlier 1,956-test result preceded these two added cases.
  • Linux contract checks against the compiled fix passed for relative and absolute literal-backslash paths: selected config exists and its spelling is retained, untrailered commits reject with exit1, valid trailers commit successfully, and reinstall is byte-stable and still strict. Script: .cache/issue-341-posix-config-check.cjs. The reviewer original reproduction also now rejects the untrailered commit.
  • No source assertions or policy rules were weakened. This normal append commit requires exact-head independent re-review before merge. No merge or release action is authorized.

@stackbilt-admin
stackbilt-admin marked this pull request as ready for review November 2, 2026 19:25
@stackbilt-admin
stackbilt-admin merged commit 77424c5 into main Nov 2, 2026
7 checks passed
@stackbilt-admin
stackbilt-admin deleted the fix/issue-341-hook-config branch November 27, 2026 23:55
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.

hook: commit-msg gate always reads .charter/config.json, ignoring validate --config

2 participants