ECC/tests/hooks
Vishnu Pradeep b27551897d
fix(hooks): wrap SessionStart summary with stale-replay guard (#1536)
The SessionStart hook injects the most recent *-session.tmp as
additionalContext labelled only with 'Previous session summary:'.
After a /compact boundary, the model frequently re-executes stale
slash-skill invocations it finds inside that summary, re-running
ARGUMENTS-bearing skills (e.g. /fw-task-new, /fw-raise-pr) with the
last ARGUMENTS they saw.

Observed on claude-opus-4-7 with ECC v1.9.0 on a firmware project:
after compaction resume, the model spontaneously re-enters the prior
skill with stale ARGUMENTS, duplicating GitHub issues, Notion tasks,
and branches for work that is already merged.

ECC cannot fix Claude Code's skill-state replay across compactions,
but it can stop amplifying it. Wrap the injected summary in an
explicit HISTORICAL REFERENCE ONLY preamble with a STALE-BY-DEFAULT
contract and delimit the block with BEGIN/END markers so the model
treats everything inside as frozen reference material.

Tests: update the two hooks.test.js cases that asserted on the old
'Previous session summary' literal to assert on the new guard
preamble, the STALE-BY-DEFAULT contract, and both delimiters. 219/219
tests pass locally.

Tracked at: #1534
2026-04-21 18:02:19 -04:00
..
auto-tmux-dev.test.js feat: add C++ language support and hook tests (#539) 2026-03-16 14:31:49 -07:00
bash-hook-dispatcher.test.js fix: consolidate bash hooks without fork storms 2026-04-14 21:23:57 -07:00
block-no-verify.test.js fix: address PR review comments on block-no-verify hook 2026-04-12 20:29:01 -05:00
check-hook-enabled.test.js feat: add C++ language support and hook tests (#539) 2026-03-16 14:31:49 -07:00
config-protection.test.js fix: finish blocker lane hook and install regressions 2026-03-25 04:00:50 -04:00
cost-tracker.test.js feat: sync ecc2 cost tracker metrics 2026-04-09 06:22:20 -07:00
design-quality-check.test.js feat: add web frontend rules and design quality hook 2026-04-02 17:33:17 -07:00
detect-project-worktree.test.js fix(tests): resolve Windows CI test failures (#701) 2026-03-20 03:37:21 -07:00
doc-file-warning.test.js refactor: address reviewer feedback 2026-03-29 10:09:02 +08:00
evaluate-session.test.js fix: remove unused execFileSync import (no-unused-vars ESLint) 2026-02-18 07:15:53 +05:30
gateguard-fact-force.test.js fix: harden urgent install and gateguard patch 2026-04-14 19:44:08 -07:00
governance-capture.test.js fix: resolve blocker PR validation regressions 2026-03-25 01:34:29 -04:00
hook-flags.test.js feat: add C++ language support and hook tests (#539) 2026-03-16 14:31:49 -07:00
hooks.test.js fix(hooks): wrap SessionStart summary with stale-replay guard (#1536) 2026-04-21 18:02:19 -04:00
mcp-health-check.test.js test: wait for http mcp fixtures to accept connections 2026-04-12 23:38:46 -07:00
observe-subdirectory-detection.test.js fix(clv2): resolve cwd to git root before project detection 2026-03-30 04:46:31 -04:00
observer-memory.test.js fix: harden windows observer prompt handling 2026-04-06 14:05:38 -07:00
post-bash-hooks.test.js feat: add C++ language support and hook tests (#539) 2026-03-16 14:31:49 -07:00
pre-bash-commit-quality.test.js fix(hooks): make pre-commit quality checks enforce staged state 2026-03-29 00:07:18 -04:00
pre-bash-dev-server-block.test.js feat: add C++ language support and hook tests (#539) 2026-03-16 14:31:49 -07:00
pre-bash-reminders.test.js feat: add C++ language support and hook tests (#539) 2026-03-16 14:31:49 -07:00
quality-gate.test.js feat: add C++ language support and hook tests (#539) 2026-03-16 14:31:49 -07:00
session-activity-tracker.test.js fix: detach ecc2 background session runners (#1387) 2026-04-12 22:29:05 -07:00
stop-format-typecheck.test.js perf(hooks): batch format+typecheck at Stop instead of per Edit (#746) 2026-03-31 14:12:12 -07:00
suggest-compact.test.js test: isolate suggest-compact counter fixtures 2026-03-25 03:51:15 -04:00