Skip to content

fix(install): prune once per event — second hook on a shared event was silently dropped - #1

Open
Tespera wants to merge 1 commit into
cozytab:mainfrom
Tespera:pr-a-installer-fix
Open

fix(install): prune once per event — second hook on a shared event was silently dropped#1
Tespera wants to merge 1 commit into
cozytab:mainfrom
Tespera:pr-a-installer-fix

Conversation

@Tespera

@Tespera Tespera commented Jul 16, 2026

Copy link
Copy Markdown

The bug

install.sh prunes fable-mode's old entries inside the per-spec append loop:

for event, matcher, fname in SPECS:
    entries = prune(hooks.get(event, []))   # <- re-reads the event list every iteration
    ...
    hooks[event] = entries

prune() drops any group referencing one of our script names. So when two specs share an event, processing the second spec re-prunes the event list and silently removes the group just added for the first. Today every spec has a unique event, so the bug is latent — but the moment a second hook is registered on the same event (e.g. another PostToolUse/Bash guard), the earlier one vanishes from settings.json with no error, and --uninstall/re-install idempotency masks it.

I hit this for real while prototyping an additional PostToolUse hook: the fail-streak registration silently disappeared after install.

The fix

Prune once per event before the append loop, then append all specs. Behavior for the current 4-hook setup is byte-identical (verified: tests/test_install.py all green, fresh/idempotent/merge/re-point/uninstall paths unchanged); the installer just stops eating its own registrations when specs ever share an event.

No behavior change for users; this is groundwork that makes the installer safe to extend.

🤖 Generated with Claude Code

…ling groups on a shared event

With two hooks registered on the same event (e.g. two PostToolUse/Bash
entries), processing the second spec re-pruned the event list and silently
dropped the group just added for the first. Latent with a single spec per
event; bites as soon as a second one exists.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant