Skip to content

fix: register the SessionStart hook so the tracing reminder fires - #17

Merged
winjer merged 2 commits into
mainfrom
fix/register-sessionstart-hook
Jul 21, 2026
Merged

fix: register the SessionStart hook so the tracing reminder fires#17
winjer merged 2 commits into
mainfrom
fix/register-sessionstart-hook

Conversation

@winjer

@winjer winjer commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

The --on-start reminder code existed in cli.rs, but code-trace setup only ever registered the Stop hook — never the SessionStart hook. So Claude Code never invoked --on-start on real installs, and the tracing ENABLED / PAUSED warning never appeared. The test harness hand-wired both hooks, which masked the gap.

Fix: add register_session_start_hook (mirrors register_stop_hook — idempotent, self-healing, preserves unrelated hooks) and compose it in setup run(). The reminder must fire for every session-start source, so the canonical hook is registered under an empty match-all matcher in its own group. Confirmed against the Claude Code hooks docs that plain stdout from a SessionStart hook is injected into Claude's context, so the existing println! is correct.

Harness hardening: the harness now registers hooks via the real installer (code-trace setup --register-hook) instead of hand-written JSON, so scenario (c) genuinely validates the installer's wiring — this bug would have been caught. Also added an optional NPMRC_FILE BuildKit secret so the image build works behind a private npm registry (no-op with direct registry access, e.g. CI).

Verified: cargo test + clippy clean; the container harness passes all 5 scenarios end-to-end, including the reminder scenario now driven by the real installer.

Re-running the installer on an existing install repairs it: the SessionStart hook is added additively, preserving the existing Stop hook and other settings.

winjer and others added 2 commits July 21, 2026 09:37
The --on-start reminder code existed in cli.rs but setup only ever
registered the Stop hook, so Claude Code never invoked --on-start on real
installs and the 'tracing ENABLED/PAUSED' warning never appeared. The
test harness hand-wired both hooks, which masked the gap.

Add register_session_start_hook (mirrors register_stop_hook: idempotent,
self-healing, preserves unrelated hooks) and compose it in setup run().
The reminder must fire for every session-start source, so the canonical
hook is registered under an empty match-all matcher in its own group.

Verified contract: plain stdout from a SessionStart hook is injected into
Claude's context (Claude Code hooks docs).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Previously the harness hand-wrote settings.json with both hooks, which
masked the missing SessionStart registration in setup. Register hooks
through 'code-trace setup --register-hook' instead, so scenario c (the
tracing reminder) genuinely validates the installer's wiring.

Also make the image build work behind a private npm registry via an
optional NPMRC_FILE BuildKit secret (no-op with direct registry access,
e.g. CI); documented in harness/README.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@winjer
winjer marked this pull request as ready for review July 21, 2026 09:19
@winjer
winjer merged commit 8c3212f into main Jul 21, 2026
2 checks passed
@winjer
winjer deleted the fix/register-sessionstart-hook branch July 21, 2026 09:21
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