Skip to content

fix(run): uncommitted hook changes go unwarned — phases run the committed .claude/hooks/, but the #1354 check only covers skills #1456

Closed

Description

@admarble

Epic: graph-2026-10-freeze-b Tier: mechanical Execution: sequant_run

Problem

Phase agents run in worktrees created from HEAD, so they run the committed .claude/hooks/, not the copies on disk in the main checkout. #1354 added a warning for this case, but only for .claude/skills/: src/lib/skills-commit-state.ts lists tracked-but-modified files under SKILLS_DIR_PATH alone. A sequant sync or update that rewrites pre-tool.sh or post-tool.sh and is never committed leaves every later phase running the old hooks, with no warning anywhere.

Field evidence: ad-motion commit e48f63e (2026-10-07): "pre-tool.sh and post-tool.sh were left uncommitted at 2.18.0 by the 2026-09-27 sync, so phase worktrees ran the older committed hooks." Ten days of phases ran pre-2.18.0 guard logic with no signal.

ADR-0012 doesn't remove this. Its skills-only plugin view carries no hooks, so hooks remain committed project files.

Proposal

Extend the commit-state check to .claude/hooks/ and keep one shared warning. The same callers (run-orchestrator.ts:1240, doctor.ts, sync.ts) print it, so no caller logic changes.

Acceptance Criteria

  • AC-1: The commit-state check reports tracked files with uncommitted changes under .claude/hooks/ as well as .claude/skills/, and the shared warning names which directory each file is in. Evidence: unit tests in a temp git repo covering a modified tracked hook (warns, names .claude/hooks/), a modified tracked skill (unchanged behaviour), and both clean (no warning), mutation-verified by removing the hooks path from the check
  • AC-2: sequant run, doctor and sync print the hooks warning through their existing call sites, with no new call site added. Evidence: grep -n 'getSkillsCommitState\|formatSkillsCommitWarning' src/commands/doctor.ts src/commands/sync.ts src/lib/workflow/run-orchestrator.ts shows the same three call sites as before, and one existing caller test asserts the hooks line (doctor's or run-orchestrator's, not sync's: sync.ts and its tests are fix(sync): a --only skills install warns 'N file(s) differ' forever, and the suggested sync --force overwrites the repo's constitution #1409's scope in this graph)
  • AC-3: Untracked hook files produce no warning (as for skills, where fix(doctor/run): doctor and run --dry-run report success when nothing would work #1257's doctor check owns untracked files). Evidence: a unit test with an untracked file under .claude/hooks/ showing no warning

May touch

src/lib/skills-commit-state.ts (rename the module or export only if needed; if so, keep the old names as re-exports), its tests, and one caller test (doctor or run-orchestrator; not sync, which is #1409's), CHANGELOG.md.

Prior fixes / producers

Non-Goals

  • No edit to .claude/skills/, templates/skills/ or plugin/, so the change is freeze-safe.
  • No auto-commit and no blocking. The check stays a warning.

Activity

  1. added
    bug
    graph-2026-10-freeze-b
    on Oct 16, 2026
  2. added a commit that references this issue on Oct 16, 2026
  3. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Runner context (graph-2026-10-freeze-b, wave 2)

    Wave 1 merged on 2026-10-16. main is at 9f1fb3f and includes #1440, #1396, #1305, #1325, #1405 and #1409. These notes are for both the exec phase and the qa phase:

    • Don't run npm test (the full suite) in exec or qa. Each phase stops after 30 minutes with no progress, and these phases run the published sequant 2.19.0, which has no affected-tests mode. Run the test files you change or name with npx vitest run <file>. CI runs the full suite on the PR.
    • ADR number: ADR-0014 and ADR-0015 are taken. If this issue writes an ADR, use ADR-0017. Each wave-2 issue has its own number, so parallel runs can't collide.
    • Mutation markers: the published 2.19.0 parser still cuts a marker at the first closing brace (fix(qa): a SEQUANT_MUTATION marker whose text contains "}" parses to nothing — renderMutationMarker and the parser do not round-trip #1305 is fixed on main but not released). Keep braces out of the mutation and failedTest text.
    • Plugin freeze: change nothing under plugin/, .claude/skills/ or templates/skills/.
    • PR fix(#1409): update records a full install in the manifest #1477 (open, another session) edits src/commands/update.ts and sync.install-scope.integration.test.ts. Leave both alone. As the issue says, the caller test is doctor's or run-orchestrator's, not sync's.
  4. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (3 ACs, 3 directories)

    AC Quality Check

    All three ACs are single-line with an Evidence: clause. Notes:

    • AC-1 and AC-3 name tests that do not exist yet, so they fail on main today. Not vacuous.
    • AC-2's grep is vacuous on its own: it matches the same three call sites before and after the change. The caller-test half is the real gate. Keep it, and read the grep as a "no new call site" guard.
    • AC-2 does not say which directory the caller test's hooks line must name. Tighten to: the line contains .claude/hooks/.

    Scope Assessment

    Non-Goals: present (no edits to skills/templates/plugin; no auto-commit or blocking).

    Metric Value Status
    Feature count 1 ✅
    AC items 3 ✅
    Directory spread 3 (src/lib, src/commands, src/lib/workflow) ✅

    Verdict: ✅ SCOPE_OK

    Acceptance Criteria

    AC-1: Check covers .claude/hooks/, warning names the directory

    Verification: Integration Test (temp git repo, extends src/lib/skills-commit-state.integration.test.ts)
    Scenario: Given a committed hook modified on disk → When getSkillsCommitState + formatSkillsCommitWarning run → Then the warning names .claude/hooks/. Skill-only, hook-only and both-clean cases are covered too.
    Assumptions: git status --porcelain paths are repo-root-relative, so the directory can be derived from the path prefix.

    AC-2: Existing call sites print it, no new call site

    Verification: Unit Test (doctor.test.ts) plus the grep
    Scenario: Given getSkillsCommitState mocked to return a .claude/hooks/pre-tool.sh entry → When doctorCommand runs → Then output contains .claude/hooks/.

    AC-3: Untracked hooks stay silent

    Verification: Integration Test
    Scenario: Given an untracked file under .claude/hooks/ → When the state is read → Then modified is [] and the warning is null. --untracked-files=no already guarantees this.

    Implementation Plan

    Phase 1: Producer (src/lib/skills-commit-state.ts)

    1. Add HOOKS_DIR_PATH = ".claude/hooks". Pass both pathspecs to git status (-- .claude/skills .claude/hooks). Keep modified: string[] of full repo-relative paths, so the SkillsCommitState shape and the doctor.test.ts mock stay valid and no caller changes.
    2. In formatSkillsCommitWarning, group modified by directory prefix.
      • Skills-only input must produce the exact current string. doctor.test.ts:397 asserts 2 tracked files under .claude/skills/ have uncommitted changes and committed skills (2.15.1).
      • With hooks, emit one clause per directory, e.g. 1 tracked file under .claude/hooks/ has uncommitted changes. Use a hooks-specific tail: phases will use the committed hooks. Commit instruction: Commit .claude/hooks/ before running. Keep the .sequant-manifest.json hint skills-only.
    3. Do not rename the module or exports. The three callers keep importing the same names, so the "keep old names as re-exports" clause is not needed.

    Phase 2: Tests

    1. Extend the integration test with AC-1 (hook modified; skill modified, unchanged text; both clean) and AC-3 (untracked hook).
    2. Add one hooks-line case in doctor.test.ts next to the fix(run): skills freshness is read from the working tree, but phases use committed skills — an uncommitted sync names the wrong version and silently runs old skills #1354 case (AC-2).
    3. Add a CHANGELOG.md entry.
    4. Mutation-verify: drop HOOKS_DIR_PATH from the pathspec and confirm the hook-modified case fails. Record it in the PR body as Mutation-verified: AC-1 — <mutation>; src/lib/skills-commit-state.integration.test.ts > ... failed; restored. Keep braces out of the marker text (published 2.19.0 parser cuts at the first }). Commit before mutating.

    Design Review

    1. Where does this belong? In the existing producer, skills-commit-state.ts. All three consumers format through it.
    2. Simplest approach? Add a second pathspec and group by prefix. Rejected: a separate hooks module with a fourth call site, which AC-2 forbids and which risks the three warnings drifting.
    3. Pattern and re-patch count? Pattern: fix(run): skills freshness is read from the working tree, but phases use committed skills — an uncommitted sync names the wrong version and silently runs old skills #1354's committed-vs-disk check. git log -S SKILLS_DIR_PATH shows only fix(#1354): warn when tracked skills have uncommitted changes — phases use the committed ones #1385 for the real code, so this is the first extension, not a recurrence. feat(doctor): report each phase skill's source; narrow the committed-skills guards (ADR-0012 follow-up 3) #1399 will narrow the same function; whichever lands second rebases.
    4. Reviewer challenge: "Why not also check .claude/settings*.json or .sequant/?" Out of scope; the issue names hooks only.
    5. Producers and consumers (whole-repo grep): one producer, skills-commit-state.ts. Consumers: run-orchestrator.ts:1239, doctor.ts:788, sync.ts:901, plus the tests. sync.ts is untouched (fix(sync): a --only skills install warns 'N file(s) differ' forever, and the suggested sync --force overwrites the repo's constitution #1409/fix(#1409): update records a full install in the manifest #1477 scope).

    Feature Quality Planning

    Notable gaps. The call sites are gated by skills conditions, so the hooks warning can be silently skipped.

    • run-orchestrator.ts:1238 only checks when skillsPreflightActive && useWorktreeIsolation. If skillsPreflightActive is false while hooks are modified, no warning prints. Check what sets it during exec. If it can be false in a real project, the issue's "no caller logic changes" claim is wrong.
    • doctor.ts:788 sits in the else of the untracked-skills branch, and the check is named "Skills Committed" with pass text "Core skills are committed". With untracked skills present, or the skills directory absent, a modified hook is never reported. When hooks are the only modification, the label still reads as a skills check.
    • sync.ts goes through the same function, so the hooks line appears there without edits.

    Derived ACs

    Source Derived AC Priority
    Caller gating AC-4: with only a hook modified (skills clean), doctor warns and the run pre-flight prints the warning. Evidence: doctor test with modified holding only a hooks path (no skills entry), plus the same case in the run-orchestrator gate. High

    Open Questions

    1. Are the caller gates acceptable as they are? Recommendation: add AC-4 and, if skillsPreflightActive can be false, allow the hooks warning through that gate with a minimal caller change. Impact if wrong: the field-evidence case (ad-motion) stays unwarned. This contradicts "no caller logic changes", but not AC-2's "no new call site".
    2. Doctor check name and pass text. Recommendation: keep "Skills Committed" to avoid breaking tests; when the warning names hooks, it is self-describing. Impact: cosmetic.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Small mechanical fix in one module. Tests are declared in the AC Evidence, so testgen adds nothing. Constraints from the runner context: do not run the full npm test (use npx vitest run <file>), and leave plugin/, .claude/skills/, templates/skills/, src/commands/update.ts and sync.install-scope.integration.test.ts untouched.

    Label Review

    Current: bug, graph-2026-10-freeze-b
    Recommended: bug, graph-2026-10-freeze-b, planned
    Quality Loop: Won't auto-enable.

  5. added
    planned
    on Oct 16, 2026
  6. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 4/4 met

    Gaps:

    • AC-1 gate test lacks a recorded mutation marker (QA ran it: removing HOOKS_DIR_PATH fails 2 tests)
    • Doctor never reports modified tracked hooks when any core skill is untracked
    • Module header comment not updated for hooks coverage
    • Doctor gate hides hook drift. doctor.ts:776-785 only calls getSkillsCommitState in the else branch of the untracked-core-skills check. If any core skill is untracked, a modified tracked hook is never reported. The spec raised this in Open Question 1, and the diff does not change it. It is non-blocking because it only happens in a half-set-up checkout, and fix(doctor/run): doctor and run --dry-run report success when nothing would work #1257's warning fires there.
    • Stale module header. The doc comment at skills-commit-state.ts:1-17 still says the module covers only "tracked files under .claude/skills/". This is cosmetic.

    Suggestions:

    • The skills || state.modified.length fallback keeps paths outside both directories (as used by older mocks) counted as skills. It works, but it is implicit; a one-line comment would make it clear.
  7. added a commit that references this issue on Oct 16, 2026
  8. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Follow-up ledger (runner, wave 2): spec OQ-1 / QA risk gap "doctor never reports modified tracked hooks when any core skill is untracked" is dropped for this issue.

    Reason: doctor.ts:776-800 runs the commit-state check only in the else branch of #1257's untracked-core-skills check. When a core skill is untracked, doctor already warns that phase worktrees won't see the skills and that .claude/skills/ has to be committed before any sequant run. That's a setup gap that stops the run anyway. Once it's fixed, the next doctor reports the hooks. The run pre-flight (run-orchestrator.ts:1238) has no such branch and warns whenever a Claude driver resolves skills, which covers the field case (ad-motion). Changing doctor's gate would be a caller-logic change this issue's scope ruled out. If the owner wants both warnings at once, that's a new issue.

  9. added a commit that references this issue on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggraph-2026-10-freeze-bplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions