Repository navigation
Description
Bug Description
When Spec Kit writes the shared event dispatcher .specify/events.py, it does not check who owns the file or whether it was modified. install_integration_events always rewrites it from the template (src/specify_cli/events/__init__.py, dispatcher step "1. Generate events.py dispatcher script").
Removal checks both. _cleanup_shared_dispatcher deletes the file only when the departing integration's manifest records it and no other installed integration references it. It preserves a modified dispatcher with a warning unless --force is given, and preserves an unowned one even with --force (design/integration.md, event cleanup). The shared scripts and templates use the same guard when they are refreshed (shared_infra.py, refresh_managed): a file whose hash no longer matches the manifest is kept with a warning, and --force overwrites it.
So a modified dispatcher survives an uninstall, but is silently overwritten by every write path that reaches install_integration_events without the upgrade command's own check_modified() guard. For example, the event refresh after specify extension add or remove overwrites it.
Found during review of #5616, where the finding was deferred. That PR installs a built-in session_start handler for Copilot, so this write path now runs on every Copilot init and upgrade (review comment: #5616 (comment)).
Steps to Reproduce
Run on main at f2010547, Linux:
specify init . --integration claude --script sh --ignore-agent-tools- Give Claude any event handler, for example with
.specify/integration-events.yml(integrations.claude.events.session_start.command: speckit.plan), then runspecify integration upgrade claude..specify/events.pyis created and recorded inclaude.manifest.json. - Append
# user customizationto.specify/events.py. specify integration upgrade clauderefuses, saying the file was modified (protected by upgrade'scheck_modified()).- Remove the override, and add a local extension that declares
events: {session_start: {command: speckit.evt.hello}}withspecify extension add --dev <path>. grep "user customization" .specify/events.py: no match. The file was regenerated without any warning.
Expected Behavior
Writes use the same ownership rules as removal and as shared infra refresh:
- An unchanged, Spec Kit-owned dispatcher is regenerated silently.
- A modified or unowned dispatcher is preserved with a warning that names the remedy, and is overwritten only with
--force.
Because the dispatcher and the native hook commands are generated together, a preserved stale dispatcher needs clear reporting. Hooks written by a newer Spec Kit may pass arguments that an older dispatcher does not understand.
Actual Behavior
install_integration_events overwrites .specify/events.py unconditionally on init, install, upgrade (after the integration's own manifest check), and on the event refresh after extension add or remove.
Specify CLI Version
1.4.6.dev0 (main at f2010547)
AI Agent
Not agent-specific; reproduced with Claude Code (claude) and GitHub Copilot (copilot) integrations.
Operating System
Linux
Python Version
3.14
Additional Context
Pre-existing on main, independent of #5533 and #5616. Write-side ownership affects the event lifecycle of every event-capable integration, so it is tracked separately rather than fixed in #5616.
AI Disclosure
Filed on behalf of @markuswondrak by the pi coding agent (provider github-copilot, model claude-opus-5.5, reasoning effort xhigh, interactive and human-supervised). The agent read the code, reproduced the behavior on main with the steps above, and wrote this issue at @markuswondrak's request.


Activity