Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

feat(helpers): hand route/post-edit to the ruflo mod via RUFLO_MODS_OWNS (ADR-404)

ruvc3352611992e
diff --git a/.claude/helpers/hook-handler.cjs b/.claude/helpers/hook-handler.cjs
index 401b7594ed..bf6ba5f87a 100755
--- a/.claude/helpers/hook-handler.cjs
+++ b/.claude/helpers/hook-handler.cjs
@@ -286,6 +286,17 @@ async function readStdin() {
});
}
+// ADR-404: the ruflo mod (plugins/ruflo-mods) runs these events in-process
+// inside Claude Code and sets RUFLO_MODS_OWNS on the process, which every hook
+// started after inherits. An event named there is the mod's; returning here
+// keeps it from firing twice. Only side-effect events can be handed over:
+// guards such as pre-bash always run, whatever the variable says.
+const MOD_OWNABLE_EVENTS = new Set(['route', 'post-edit']);
+function ownedByMod(cmd, env = process.env) {
+ if (!MOD_OWNABLE_EVENTS.has(cmd)) return false;
+ return String(env.RUFLO_MODS_OWNS || '').split(',').some((owned) => owned.trim() === cmd);
+}
+
function claimSideEffectEvent(family, stdinData, event) {
if (/^(1|true|yes|on)$/i.test(process.env.RUFLO_DISABLE_HOOK_DEDUP || '')) return true;
try {
@@ -312,6 +323,8 @@ function claimSideEffectEvent(family, stdinData, event) {
}
async function main() {
+ if (ownedByMod(command)) return;
+
// Global safety timeout: hooks must NEVER hang (#1530, #1531)
const safetyTimer = setTimeout(() => {
process.stderr.write("[WARN] Hook handler global timeout (5s), forcing exit\n");
@@ -606,4 +619,4 @@ if (require.main === module) {
// Which sibling helpers loaded (all CommonJS, shipped as .cjs — #3555).
const loadedHelpers = { router: !!router, session: !!session, memory: !!memory, intelligence: !!intelligence };
-module.exports = { runWithTimeout, INTELLIGENCE_TIMEOUT_MS, loadedHelpers };
+module.exports = { runWithTimeout, INTELLIGENCE_TIMEOUT_MS, loadedHelpers, ownedByMod, MOD_OWNABLE_EVENTS };
diff --git a/plugins/ruflo-core/scripts/ruflo-hook.cjs b/plugins/ruflo-core/scripts/ruflo-hook.cjs
index 28c1afc5dc..f1536c5fbb 100644
--- a/plugins/ruflo-core/scripts/ruflo-hook.cjs
+++ b/plugins/ruflo-core/scripts/ruflo-hook.cjs
@@ -406,6 +406,15 @@ function main() {
done();
}
+ // ADR-404: when the ruflo mod records edits in-process it sets
+ // RUFLO_MODS_OWNS on the Claude Code process; this hook then stands down so
+ // an edit is recorded once, as hook-handler.cjs does. Telemetry only: the
+ // PreToolUse permission paths below never consult it.
+ if (subcommand === 'post-edit' &&
+ String(process.env.RUFLO_MODS_OWNS || '').split(',').some((owned) => owned.trim() === 'post-edit')) {
+ done();
+ }
+
const stdinData = readStdinRaw();
const event = parseEventJson(stdinData);
diff --git a/v3/@claude-flow/cli/.claude/helpers/hook-handler.cjs b/v3/@claude-flow/cli/.claude/helpers/hook-handler.cjs
index 401b7594ed..bf6ba5f87a 100755
--- a/v3/@claude-flow/cli/.claude/helpers/hook-handler.cjs
+++ b/v3/@claude-flow/cli/.claude/helpers/hook-handler.cjs
@@ -286,6 +286,17 @@ async function readStdin() {
});
}
+// ADR-404: the ruflo mod (plugins/ruflo-mods) runs these events in-process
+// inside Claude Code and sets RUFLO_MODS_OWNS on the process, which every hook
+// started after inherits. An event named there is the mod's; returning here
+// keeps it from firing twice. Only side-effect events can be handed over:
+// guards such as pre-bash always run, whatever the variable says.
+const MOD_OWNABLE_EVENTS = new Set(['route', 'post-edit']);
+function ownedByMod(cmd, env = process.env) {
+ if (!MOD_OWNABLE_EVENTS.has(cmd)) return false;
+ return String(env.RUFLO_MODS_OWNS || '').split(',').some((owned) => owned.trim() === cmd);
+}
+
function claimSideEffectEvent(family, stdinData, event) {
if (/^(1|true|yes|on)$/i.test(process.env.RUFLO_DISABLE_HOOK_DEDUP || '')) return true;
try {
@@ -312,6 +323,8 @@ function claimSideEffectEvent(family, stdinData, event) {
}
async function main() {
+ if (ownedByMod(command)) return;
+
// Global safety timeout: hooks must NEVER hang (#1530, #1531)
const safetyTimer = setTimeout(() => {
process.stderr.write("[WARN] Hook handler global timeout (5s), forcing exit\n");
@@ -606,4 +619,4 @@ if (require.main === module) {
// Which sibling helpers loaded (all CommonJS, shipped as .cjs — #3555).
const loadedHelpers = { router: !!router, session: !!session, memory: !!memory, intelligence: !!intelligence };
-module.exports = { runWithTimeout, INTELLIGENCE_TIMEOUT_MS, loadedHelpers };
+module.exports = { runWithTimeout, INTELLIGENCE_TIMEOUT_MS, loadedHelpers, ownedByMod, MOD_OWNABLE_EVENTS };