Skip to content

Remove hook mode from chunk validate and agent hooks from chunk init - #888

Merged
schurchleycci merged 2 commits into
mainfrom
factory/chunk-validate-hooks-afe65fc1
Oct 30, 2026
Merged

schurchleycci merged 2 commits into
mainfrom
factory/chunk-validate-hooks-afe65fc1

Conversation

@schurchleycci

Copy link
Copy Markdown
Contributor

Motivation

chunk validate acted differently whenever stdin held a hook payload. It skipped clean trees, served cached results, exited 2 to block an agent and printed systemMessage JSON. Now it just runs the validation commands, whatever is on stdin.

Changes

  • chunk validate always behaves like a terminal run. The daemon stops forwarding the hook fields in the same commit that removes the hidden hook flags.
  • chunk init no longer writes .claude/settings.json or .codex/hooks.json, because those entries misbehave without hook mode. .git/hooks/pre-commit stays.
  • Removed: chunk hook, CHUNK_HOOKS_DISABLED, stopHookMaxAttempts and docs/HOOKS.md.

The result cache and the daemon's background-run code are kept, so they can later be wired into every run.

Compatibility

  • Existing agent hook files are left alone. Their entries now run plain chunk validate.
  • Configs that still set stopHookMaxAttempts keep loading. Old clients sending hook_codex/hook_event to a new daemon are ignored harmlessly.
  • Newly initialised repos no longer get the Bash(chunk:*) permission.

🤖 Generated with Claude Code

circleci-factory-bot

This comment was marked as outdated.

circleci-factory-bot

This comment was marked as outdated.

`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
schurchleycci force-pushed the factory/chunk-validate-hooks-afe65fc1 branch from 5c7a34b to 64e5499 Compare October 30, 2026 17:03

@circleci-factory-bot circleci-factory-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

@schurchleycci
schurchleycci marked this pull request as ready for review October 30, 2026 18:42
@schurchleycci
schurchleycci requested review from a team as code owners October 30, 2026 18:42
@schurchleycci
schurchleycci merged commit b2ea3ea into main Oct 30, 2026
7 checks passed
@schurchleycci
schurchleycci deleted the factory/chunk-validate-hooks-afe65fc1 branch October 30, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants