Skip to content

fix(gate): gate-hygiene trio — dedupe Stop hook, fix blanked-gate preflight, cheap test_affected default (#129) - #155

Merged
robercano-ghbot merged 2 commits into
mainfrom
feat/issue-129-gate-hygiene
Jul 17, 2026
Merged

fix(gate): gate-hygiene trio — dedupe Stop hook, fix blanked-gate preflight, cheap test_affected default (#129)#155
robercano-ghbot merged 2 commits into
mainfrom
feat/issue-129-gate-hygiene

Conversation

@robercano-ghbot

Copy link
Copy Markdown
Collaborator

Fixes three related gate-hygiene defects in the harness (.claude) module. Closes #129.

1. Consumer repos no longer double-fire the Stop-hook gate

The plugin's hooks/hooks.json and a consumer's vendored .claude/settings.json can both register the same Stop (gate.sh test_affected), PostToolUse (lint) and PreToolUse (guard-git-add) hooks, so a plugin-enabled consumer that also merged those hooks into settings.json paid every gate twice per turn. settings.json is the intended steady-state owner (post-#128 scaffold vendors the runtime harness), so the setup skill now states an explicit single-owner rule and adds a hand-off checklist item to disable the plugin (drop enabledPlugins/extraKnownMarketplaces) once settings.json owns the hooks; the CLAUDE.md template carries a matching caveat. reCode's own .claude/settings.json hooks are untouched — reCode is not plugin-installed on itself, so that registration is its only/correct one.

2. Blanked gates no longer fail on an out-of-sync node_modules

In gate.sh, the pnpm-lock.yaml freshness preflight ran BEFORE the "empty gate => skip" branch, so a deliberately blanked gate ("test_affected": "", the documented "not configured" marker) could still exit 1 whenever node_modules was momentarily behind the lockfile. The preflight now runs only after $cmd is resolved non-empty (i.e. only for gates that actually execute); the freshness logic, stderr message and exit code for configured gates are unchanged.

3. test_affected scaffold default steers cheap, not full-suite

The setup skill previously advised defaulting test_affected to the full test command, making the after-every-turn Stop hook unaffordable. Step-3 guidance now steers toward a changed-scope filter (full command only as a confirmed-fast fallback, else empty), and the template gates.json carries a hint pointing at the per-stack table in docs/GETTING_STARTED.md.

Tests

Added .claude/scripts/gate.test.sh — an offline, auto-discovered regression fixture (13 checks) proving a blanked gate skips (exit 0) even with a stale/absent node_modules/.pnpm/lock.yaml, a configured gate still aborts (exit 1) with the exact message on a lock mismatch, and a configured gate runs on a fresh/absent lock. Verified to fail against the pre-fix ordering.

Gates

build, lint, test (checks.sh + smoke-fanout + all *.test.sh, incl. the new fixture) all green via GATES_FILE=.claude/self/gates.json.

Review

correctness (opus) APPROVE; tests (sonnet) APPROVE on re-review after the regression fixture was added.

🤖 Generated with Claude Code

robercano and others added 2 commits July 17, 2026 09:32
…r, test_affected default (issue #129)

Three related gate-hygiene defects:
- SKILL.md/templates/CLAUDE.md now spell out the single-owner rule for the
  Stop/PostToolUse/PreToolUse hooks: once /orchestrator:setup wires them into a
  consumer's own .claude/settings.json (post-#128 vendoring), the orchestrator
  plugin must be disabled for everyday sessions or every gate double-fires each
  turn; the hand-off checklist now makes dropping enabledPlugins/
  extraKnownMarketplaces an explicit step.
- gate.sh's pnpm-lock freshness preflight now runs after the empty-gate skip,
  so a deliberately blanked gate ("" = not configured) stays a true no-op
  instead of failing the Stop hook when node_modules is momentarily stale.
- SKILL.md's test_affected interview guidance and the gates.json template now
  steer towards a cheap changed-scope filter instead of defaulting straight to
  the full test suite, which is unaffordable as a per-turn Stop hook.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…reflight (#129)

gate.sh was the most-invoked harness script with no dedicated *.test.sh
fixture. Add gate.test.sh (mirrors the sibling offline/mock-root pattern)
covering: (1) a blanked/unconfigured gate key skips cleanly even with a
stale/absent node_modules/.pnpm/lock.yaml — the #129 regression, verified
to fail against the pre-fix preflight-before-skip ordering; (2) a
configured gate + stale lock aborts with the exact stderr message and
never runs the command; (3) a configured gate + fresh lock (or no
pnpm-lock.yaml) actually runs the command.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@robercano-ghbot

Copy link
Copy Markdown
Collaborator Author

fix(gate): gate-hygiene trio — dedupe Stop hook, fix blanked-gate preflight, cheap test_affected default (#129) (not yet reviewed)

@robercano-ghbot
robercano-ghbot merged commit cfb201b into main Jul 17, 2026
9 checks passed
@robercano-ghbot
robercano-ghbot deleted the feat/issue-129-gate-hygiene branch July 17, 2026 07:58
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.

Gate hygiene: Stop-hook gate runs twice in consumer repos; lock-preflight defeats blanked gates; test_affected = full suite on every Stop

2 participants