Repository navigation
Remove hook mode from chunk validate and agent hooks from chunk init - #888
Merged
Merged
Conversation
schurchleycci
force-pushed
the
factory/chunk-validate-hooks-afe65fc1
branch
from
October 30, 2026 16:46
f7b4b09 to
5c7a34b
Compare
`chunk validate` switched into a hook mode whenever stdin held JSON with a `session_id`. In that mode it skipped clean trees, served cached results, exited 0 silently with no config, walked up to find `.chunk/config.json`, exited 2 and gave up after `stopHookMaxAttempts`, and printed `systemMessage` JSON in place of the commands' output. So the same command behaved differently depending on what was on stdin. Now it always runs the commands the way a terminal run does, and exits 1 on failure. The daemon stops forwarding `HookCodex`/`HookEvent` in the same commit as the flag removal. Otherwise an up-to-date daemon would pass flags the new `validate` rejects. Old clients that still send the fields are harmless, because the decoder ignores unknown fields. Kept on purpose, because they may later serve every run: the result cache in `internal/validate`, `internal/filecache`, `gitutil.Fingerprint`, and the daemon's `AllowAsync`/risk/background code, which the CLI no longer offers except via `--async`. The cmd-level cache glue is deleted rather than kept behind `//nolint:unused`, so that dead code does not look live. `eventlog.OpHook` stays although nothing writes it, because existing event logs hold `"op":"hook"` entries.
Without hook mode, the agent hooks `chunk init` wrote to `.claude/settings.json` and `.codex/hooks.json` misbehave. A failing validate exits 1, which Claude Code treats as non-blocking, so the commit gate no longer blocks commits. The Codex PreToolUse entry has no `if` filter, so it would run full validation before every Bash call. Init no longer writes either file. That also drops the `Bash(chunk:*)` permission they carried. That is accepted, because the permission only existed so the hooks could run. Agent files already in users' repos are left as they are; their entries now run plain `chunk validate`. `.git/hooks/pre-commit` stays. It runs plain `chunk validate`, a non-zero exit blocks the commit, and it is the remaining commit guard. With nothing left to control, `chunk hook`, `CHUNK_HOOKS_DISABLED` and `stopHookMaxAttempts` go. Configs that still set `stopHookMaxAttempts` keep loading, because the loader allows unknown fields. `chunk factory bootstrap` used a missing `.claude/settings.json` as the sign that init had not run. It now looks for the `chunk-sidecar` skill that init installs.
schurchleycci
force-pushed
the
factory/chunk-validate-hooks-afe65fc1
branch
from
October 30, 2026 17:03
5c7a34b to
64e5499
Compare
circleci-factory-bot
approved these changes
Oct 30, 2026
circleci-factory-bot
left a comment
There was a problem hiding this comment.
PASS 🟢 impact-matches-intent ✨
SKIP ⚪ 8 skipped check(s): api-auth-and-design, agents-md-respect, author-membership, documentation, git-hygiene, go-best-practices, reduces-risk, server-compat
Details: https://github.com/CircleCI-Public/factory-bot-unredacted-reviews/issues/158
🤖 factory-bot · codeowner mode · reviewed @ 2026-10-30T17:03:56Z · re-request a review to re-run
[trace:c4364ad] [bot 5b70866] [config 6f549d7] [target 64e5499]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
chunk validateacted differently whenever stdin held a hook payload. It skipped clean trees, served cached results, exited 2 to block an agent and printedsystemMessageJSON. Now it just runs the validation commands, whatever is on stdin.Changes
chunk validatealways behaves like a terminal run. The daemon stops forwarding the hook fields in the same commit that removes the hidden hook flags.chunk initno longer writes.claude/settings.jsonor.codex/hooks.json, because those entries misbehave without hook mode..git/hooks/pre-commitstays.chunk hook,CHUNK_HOOKS_DISABLED,stopHookMaxAttemptsanddocs/HOOKS.md.The result cache and the daemon's background-run code are kept, so they can later be wired into every run.
Compatibility
chunk validate.stopHookMaxAttemptskeep loading. Old clients sendinghook_codex/hook_eventto a new daemon are ignored harmlessly.Bash(chunk:*)permission.🤖 Generated with Claude Code