Skip to content

fix(hook): report real injection count in remote deployments (#42)#46

Merged
scbrown merged 1 commit into
mainfrom
fix/bo-42-hook-injection-count
Jul 14, 2026
Merged

fix(hook): report real injection count in remote deployments (#42)#46
scbrown merged 1 commit into
mainfrom
fix/bo-42-hook-injection-count

Conversation

@scbrown

@scbrown scbrown commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #42. hook status reported Injection count: 0 even when injection was firing regularly — a client-side telemetry bug with two independent root causes, both with turnkey fixes.

Bug A — remote inject path never advanced the counter

The hook command sets BOBBIN_SERVER, so injection always goes through inject_context_remote(). On success it emitted metrics and stored the injection server-side but never called save_hook_state, so hook_state.json (injection_count, last_injection_time) was never advanced. Only the local path incremented it — and that path is never taken in remote deployments, freezing the client counter at its last local value.

Fix: after a successful remote injection, load / increment / save hook_state, mirroring the local path.

Bug B — hook status resolved a different root than the inject path

run_status used args.path verbatim as the bobbin root. From a sub-directory it read a non-existent hook_state.json and defaulted to 0, while injection recorded to the true root — so the reported count depended on CWD.

Fix: resolve the root by walking up to the first ancestor with .bobbin/config.toml (the resolver the inject path already uses). Stray config-less .bobbin/ dirs are walked past.

Test

  • New test_find_bobbin_root_skips_stray_bobbin_dir covers the Bug B stray-dir scenario.

🤖 Generated with Claude Code

`hook status` reported `Injection count: 0` even when injection was firing,
because of two independent client-side telemetry bugs:

Bug A — the remote inject path (taken whenever BOBBIN_SERVER is set) emitted
metrics and stored the injection server-side but never advanced hook_state.json.
Only the local path incremented the counter, so the client-side count froze at
its last local value. Fix: after a successful remote injection, load / increment
/ save hook_state, mirroring the local path.

Bug B — `hook status` used `args.path` verbatim as the bobbin root, so from a
sub-directory it read a non-existent hook_state.json and defaulted to 0, while
injection recorded to the true root. Fix: resolve the root by walking up to the
first ancestor with `.bobbin/config.toml`, the same resolver the inject path
uses. Stray `.bobbin/` dirs (config-less) are walked past.

Adds a regression test for the resolver's stray-dir behavior.

Fixes #42

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VsuPDxSUjMYqHvQyPvSAPW
@scbrown
scbrown merged commit be0efb3 into main Jul 14, 2026
1 check passed
@scbrown
scbrown deleted the fix/bo-42-hook-injection-count branch July 14, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant