🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix: distinguish lifecycle events in hook deduplication (#4212)
Wu Shuwen7f5023144b29
diff --git a/plugins/ruflo-core/scripts/background-hooks.test.cjs b/plugins/ruflo-core/scripts/background-hooks.test.cjsindex 038f617464..4bce8fb4cc 100644--- a/plugins/ruflo-core/scripts/background-hooks.test.cjs+++ b/plugins/ruflo-core/scripts/background-hooks.test.cjs@@ -116,3 +116,21 @@ test('session-end is never dropped by the cap', async () => {runShim('session-end', {}, dedupFreeEnv({ ...base, HOOK_SLOW_MS: '100', HOOK_SLOW_OUT: out }), work);assert.ok(await waitFor(out), 'session-end ran although the single slot was busy');});++test('session-end dedup distinguishes lifecycle events within one session (#4206)', async () => {+ const work = tmp('rf-lifecycle-');+ const base = {+ CLAUDE_PROJECT_DIR: work,+ RUFLO_HOOK_DEDUP_DIR: path.join(work, 'dedup'),+ RUFLO_HOOK_TMP_DIR: work,+ HOOK_SLOW_MS: '50',+ };+ const stopOut = path.join(work, 'stop.json');+ const compactOut = path.join(work, 'compact.json');+ const stop = { session_id: 'same-session', hook_event_name: 'Stop' };+ const compact = { session_id: 'same-session', hook_event_name: 'PreCompact' };+ runShim('session-end', stop, dedupFreeEnv({ ...base, RUFLO_DISABLE_HOOK_DEDUP: '', HOOK_SLOW_OUT: stopOut }), work);+ assert.ok(await waitFor(stopOut), 'Stop session-end ran');+ runShim('session-end', compact, dedupFreeEnv({ ...base, RUFLO_DISABLE_HOOK_DEDUP: '', HOOK_SLOW_OUT: compactOut }), work);+ assert.ok(await waitFor(compactOut), 'PreCompact session-end was not suppressed by Stop');+});diff --git a/plugins/ruflo-core/scripts/ruflo-hook.cjs b/plugins/ruflo-core/scripts/ruflo-hook.cjsindex 80cd6953ca..638800cca9 100644--- a/plugins/ruflo-core/scripts/ruflo-hook.cjs+++ b/plugins/ruflo-core/scripts/ruflo-hook.cjs@@ -476,11 +476,12 @@ function parseEventJson(stdinData) {function claimSideEffectEvent(family, stdinData, event) {if (/^(1|true|yes|on)$/i.test(process.env.RUFLO_DISABLE_HOOK_DEDUP || '')) return true;try {- const eventId = event?.tool_use_id || event?.toolUseId ||- event?.session_id || event?.sessionId || event?.hook_event_id;+ const eventId = event?.tool_use_id || event?.toolUseId || event?.hook_event_id ||+ event?.session_id || event?.sessionId;+ const lifecycle = event?.hook_event_name || event?.hookEventName || '';const payloadIdentity = eventId- ? `event:${eventId}`- : `payload:${(stdinData || '').trim()}|bucket:${Math.floor(Date.now() / 2000)}`;+ ? `event:${lifecycle}:${eventId}`+ : `payload:${lifecycle}:${(stdinData || '').trim()}|bucket:${Math.floor(Date.now() / 2000)}`;const projectRoot = process.env.CLAUDE_PROJECT_DIR || process.cwd();const digest = crypto.createHash('sha256').update(`ruflo-hook-dedup-v1\0${path.resolve(projectRoot)}\0${family}\0${payloadIdentity}`)