Skip to content

feat(#1603): one hook channel per checkout — doctor fails when repo hooks and a sequant plugin are both active; init/update skip the hooks group when the plugin is enabled - #1618

Merged
admarble merged 2 commits into
mainfrom
feature/1603-feat-doctor-init-one-hook-channel-per-checkout-doc
Oct 28, 2026

Conversation

@admarble

@admarble admarble commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#1603 is implemented and pushed on feature/1603-feat-doctor-init-one-hook-channel-per-checkout-doc (commit 9c6e3c1). This is an orchestrated run, so I opened no PR; the orchestrator opens it.

  • One detector. src/lib/hook-channels.ts (detectHookChannels) is the only new reader of installed_plugins.json; nothing in src read it before. It merges enabledPlugins in the order user, then project, then local, so a local false turns off a user true. It resolves each plugin's install path, preferring this checkout's local or project entry over the user entry, and counts a plugin only if its hooks/hooks.json registers pre-tool.sh. It never matches on the plugin name. A missing or malformed file counts as "no channel" and never throws.
  • doctor. The new Hook channels check fails when both channels are active, names both files, and gives both fixes. When the manifest has "hooks": "plugin", the Hooks and Settings checks pass instead of warning.
  • init. When a plugin ships the hooks, init writes no .claude/hooks/ and no .claude/settings.json, records "hooks": "plugin" in the manifest, and prints one line before the confirmation prompt. --agent opencode and --agent codex still get the repo hooks, because their wrappers run .claude/hooks/pre-tool.sh.
  • update and sync. Both drop .claude/hooks/** and .claude/settings.json from everything they compute or write when the manifest has the field. For sync that covers the drift scan, the version-current report, the dry run, the apply preview and copyTemplates.
  • Docs. docs/features/plugin-distribution.md states the one-channel rule and names the check, and the "Hooks … via sequant init" row no longer implies both channels. There is a CHANGELOG entry and ADR-0022 (a manifest field rather than an install group, because update refuses any partial groups scope).

Where this differs from the founding doc

  • D-1.2 says update skips the hooks when the plugin is enabled. Here update reads "hooks": "plugin" from the manifest instead of detecting the plugin again, so a checkout keeps what init chose even on a machine without the plugin (ADR-0022, Option C).
  • sync is outside "May touch". I changed it anyway (derived AC-6): without it, the next sequant sync would put the hooks back and undo AC-2.
  • §3's warn case (neither channel present while the manifest expects hooks) is not implemented, because no AC covers it.
  • I also changed writer-state-matrix.test.ts to unset CLAUDE_CONFIG_DIR. The detector reads that variable, as Claude Code does, and the test would otherwise stop being independent of the machine.

AC verification

AC Status Evidence
AC-1 ✅ npx vitest run src/commands/doctor.test.ts -t "Hook channels" → 8 passed, 0 failed (both active → fail naming both paths; repo only; plugin only; plugin with no hooks/hooks.json; local false override; local-scope entry; malformed registry; manifest-plugin Hooks/Settings pass)
AC-2 ✅ npx vitest run src/commands/init.test.ts -t "plugin channel" → 3 passed, plus templates.test.ts "skipHooks leaves out only .claude/hooks and .claude/settings.json" on a real filesystem
AC-3 ✅ npx vitest run src/commands/update.test.ts -t "hooks: plugin" → 3 passed
AC-4 ✅ grep -c 'Hook channels' docs/features/plugin-distribution.md → 1
AC-5 ✅ Skill-directory diff grep → 0
AC-6 (derived) ✅ npx vitest run src/commands/sync.test.ts -t "hooks: plugin" → 3 passed
AC-7 (derived) ✅ "passes without throwing when the plugin registry is malformed" (doctor.test.ts)

Mutation-verified: AC-1 — deleted the fail branch in checkHookChannels; src/commands/doctor.test.ts > 1603 AC-1: Hook channels > fails when repo hooks and a hook-shipping plugin are both active, naming both paths failed (and the local-scope case); restored.
Mutation-verified: AC-2 — deleted the skipHooks sprea

Fixes #1603

QA verdict: AC_MET_BUT_NOT_A_PLUS — acceptance criteria met, but not A+. The run broke to this PR for review rather than entering the quality loop; see the QA review comment for improvement notes.

Follow-ups

  • init on a checkout that already has repo hooks, with a hook-shipping plugin enabled, left both channels active without a message — fixed in 50561b2: init still skips the hooks group and prints one line naming both channels and the doctor check (test names both active channels…, mutation-verified below).

Runner verification (graph-run, 2026-10-26)

Executed in the worktree at 9c6e3c1, then again at 50561b2:

  • AC-1 npx vitest run src/commands/doctor.test.ts -t "Hook channels" → 8 passed (≥ 4 required).
  • AC-2 npx vitest run src/commands/init.test.ts -t "plugin channel" → 3 passed, now 4 with the re-init notice test.
  • AC-3 npx vitest run src/commands/update.test.ts -t "hooks: plugin" → 3 passed.
  • AC-6 (derived) npx vitest run src/commands/sync.test.ts -t "hooks: plugin" → 3 passed.
  • AC-4 grep -c 'Hook channels' docs/features/plugin-distribution.md → 1. AC-5 skill-dir diff count → 0.
  • npx tsc --noEmit, eslint --max-warnings 0 and npm run lint:health clean after the fix commit (unusedExports back at the 339 baseline; initCommand stays under 200 lines).

Fix commit 50561b2 beyond the agent's work: the QA follow-up above (one-line notice on re-init) and PluginHookChannel made file-local (it turned health-advisory red: 339 → 340). Mutation-verified: follow-up — deleted the warnBothHookChannels call in initCommand; src/commands/init.test.ts > 1603 AC-2: plugin channel > names both active channels when .claude/hooks already exists and a plugin ships the hooks failed; restored.

The SEQUANT_QA_VERDICT on the issue names commit 9c6e3c1; the runner fix is the only commit after it. Merge order: this PR lands before #1620, which carries ADR-0023 to this PR's ADR-0022.


🤖 Generated by sequant run

…ck, init/update/sync honour "hooks": "plugin"

Shared detector src/lib/hook-channels.ts resolves enabled plugins through installed_plugins.json and counts one as a channel only when its hooks/hooks.json registers pre-tool.sh. ADR-0022 records the manifest field.

Entire-Checkpoint: cc8249b073c0
… carries the repo hooks; PluginHookChannel file-local

Resolves the QA follow-up: with a hook-shipping plugin enabled and .claude/hooks already present, init still skips the hooks group and now prints one line saying both channels are active and that doctor's Hook channels check fails until the repo copy goes. Mutation-verified test. PluginHookChannel is unexported so lint:health returns to the baseline.

Entire-Checkpoint: 8c9796038eb1
admarble added a commit that referenced this pull request Oct 27, 2026
…e-local exports unexported, ADR renumbered to 0023 behind #1603

QA fix_now items from the #1604 verdict: a runner that throws after the patch is captured now restores by patch and names the patch path (new test); defaultVitestRunner, renderMutation and VitestRunResult are file-local so lint:health returns to the baseline. The ADR moves from 0022 to 0023 because #1603's PR #1618 ships ADR-0022 and lands first.

Entire-Checkpoint: 776551c51856
@admarble
admarble merged commit ec15551 into main Oct 28, 2026
11 of 12 checks passed
@admarble
admarble deleted the feature/1603-feat-doctor-init-one-hook-channel-per-checkout-doc branch October 28, 2026 06:34
admarble added a commit that referenced this pull request Oct 28, 2026
…ication refuses a dirty tree, requires a real failing run, restores by patch, and is the only producer of SEQUANT_MUTATION markers (#1620)

* feat(#1604): sequant mutation begin | check | render — mutation verification refuses a dirty tree, requires a real failing run, restores by patch, and produces the SEQUANT_MUTATION markers

begin records HEAD on a clean tree; check resolves one test with vitest list, captures the mutation with git add -A + git diff --cached --binary, requires the named test to fail under it and pass after git apply -R --index, and appends the record to .sequant/mutations/<N>.json; render prints markers through renderMutationMarker. Under sequant run, openOrUpdatePR reads the record file and buildAutomatedPRBody appends its markers, deduped against exec's. renderMutationMarker escapes backticks. ADR-0022, docs/reference/mutation-verification.md.

Entire-Checkpoint: 8b53a986ce4a

* docs(#1604): renderMutationMarker comment names the \u0060 escape

Entire-Checkpoint: 9681f39698b6

* test(#1604): AC-5 round-trip test name carries no brace or comment delimiter

Entire-Checkpoint: c7585144cbf8

* fix(#1604): check restores the tree when the runner throws, three file-local exports unexported, ADR renumbered to 0023 behind #1603

QA fix_now items from the #1604 verdict: a runner that throws after the patch is captured now restores by patch and names the patch path (new test); defaultVitestRunner, renderMutation and VitestRunResult are file-local so lint:health returns to the baseline. The ADR moves from 0022 to 0023 because #1603's PR #1618 ships ADR-0022 and lands first.

Entire-Checkpoint: 776551c51856
admarble added a commit that referenced this pull request Oct 28, 2026
…, #1620), D-4.2 ADR numbers assigned at merge, next W0b #1605 (#1623)

Entire-Checkpoint: 0d581f61c4e9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant