The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix: also fix hook_event_name env-var bug found by pre-merge review; sanitize session_id
Clovis3f8b31dcb8af
diff --git a/scripts/hooks/session-activity-tracker.js b/scripts/hooks/session-activity-tracker.jsindex f6edc39f5..c73003b29 100644--- a/scripts/hooks/session-activity-tracker.js+++ b/scripts/hooks/session-activity-tracker.js@@ -11,6 +11,7 @@const crypto = require('crypto');const path = require('path');const { spawnSync } = require('child_process');+const { sanitizeSessionId } = require('../lib/session-bridge');const {appendFile,getClaudeDir,@@ -561,7 +562,12 @@ function summarizeOutput(toolOutput) {}function buildActivityRow(input, env = process.env) {- const hookEvent = String(env.CLAUDE_HOOK_EVENT_NAME || '').trim();+ // Same env-var-reliance bug as the session id below: Claude Code doesn't+ // set CLAUDE_HOOK_EVENT_NAME for hook subprocesses either. Real hook stdin+ // payloads carry hook_event_name as a JSON field -- prefer that.+ const hookEvent = String(+ input?.hook_event_name || env.CLAUDE_HOOK_EVENT_NAME || ''+ ).trim();if (hookEvent && hookEvent !== 'PostToolUse') {return null;}@@ -570,10 +576,14 @@ function buildActivityRow(input, env = process.env) {// Claude Code does not set CLAUDE_SESSION_ID as an environment variable for// hook subprocesses -- the session id is only available in the hook's own// stdin JSON payload. Prefer that; keep the env vars as a fallback for any- // caller that does set them.- const sessionId = String(- input?.session_id || env.ECC_SESSION_ID || env.CLAUDE_SESSION_ID || ''- ).trim();+ // caller that does set them. Sanitized the same way as the sibling hooks+ // (cost-tracker.js, ecc-context-monitor.js, ecc-metrics-bridge.js,+ // gateguard-fact-force.js) that already use this exact fallback order.+ const sessionId =+ sanitizeSessionId(input?.session_id) ||+ sanitizeSessionId(env.ECC_SESSION_ID) ||+ sanitizeSessionId(env.CLAUDE_SESSION_ID) ||+ '';if (!toolName || !sessionId) {return null;}