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

fix(ruflo-mods): trust gate treats process.spawn, mcp.call/connect, session.send, config.set, prompt.submit and agent.spawn as risky; names a reload that gains risk (#3787, #3801)

Dragan Spiridonov72c84437d4fc
diff --git a/plugins/ruflo-mods/hooks/trust.ts b/plugins/ruflo-mods/hooks/trust.ts
index 857f86f738..0812f40270 100644
--- a/plugins/ruflo-mods/hooks/trust.ts
+++ b/plugins/ruflo-mods/hooks/trust.ts
@@ -26,7 +26,12 @@ export type ModuleScan = {
/** Calls that reach outside the session: commands, network, the environment. */
const RISKY_CALLS: Record<string, string> = {
'process.run': 'runs host commands',
+ 'process.spawn': 'runs host commands',
'http.fetch': 'makes network requests',
+ 'mcp.call': 'calls MCP tools (any connected server)',
+ 'mcp.connect': 'connects MCP servers',
+ 'session.send': 'sends messages to other agents',
+ 'config.set': 'changes Claude Code settings',
'env.set': 'changes the environment of later hooks and tools',
'fs.write': 'writes files (settings, hooks, helpers included)',
'agent.spawn': 'starts agents with a prompt of its own',
@@ -92,7 +97,8 @@ export function registerTrust(on: On, policy: TrustPolicy, allow: ReadonlySet<st
on('plugin.register', async ($, e, next) => {
const decision = judge(e, policy, allow)
if (!decision.judged) return next(e)
- const key = `${e.provenance}:${decision.refuse ? 'refused' : 'loaded'}`
+ // Keyed on what the module can do: a reload that gains a risky call or hook is named again.
+ const key = `${e.provenance}:${decision.refuse ? 'refused' : 'loaded'}:${[...decision.risk].sort().join('|')}`
if (!told.has(key)) {
told.add(key)
try {
diff --git a/plugins/ruflo-mods/tests/trust.test.ts b/plugins/ruflo-mods/tests/trust.test.ts
index 515c9d5c17..698e992216 100644
--- a/plugins/ruflo-mods/tests/trust.test.ts
+++ b/plugins/ruflo-mods/tests/trust.test.ts
@@ -86,3 +86,61 @@ describe('trust by provenance', () => {
await expect($.session.start(START)).rejects.toThrow(/allow it by provenance \(auto-allow@/)
})
})
+
+/** Runs a host command through $.process.spawn rather than $.process.run. */
+const spawner: Plugin = {
+ name: 'spawner',
+ tier: 'user',
+ register: on => {
+ on('turn.complete', async ($, e, next) => {
+ for await (const _ of $.process.spawn({ argv: ['true'] })) void _
+ return next(e)
+ })
+ },
+}
+/** Reaches any connected MCP server's tools. */
+const mcpCaller: Plugin = {
+ name: 'mcp-caller',
+ tier: 'user',
+ register: on => {
+ on('turn.complete', async ($, e, next) => {
+ await $.mcp.call('ruflo', 'terminal_execute', {})
+ return next(e)
+ })
+ },
+}
+/** Hooks only prompt.submit: it can steer every prompt (#3787). */
+const promptSteer: Plugin = {
+ name: 'prompt-steer',
+ tier: 'user',
+ register: on => {
+ on('prompt.submit', ($, e, next) => next(e))
+ },
+}
+/** Hooks only agent.spawn: it can rewrite every subagent's task (#3787). */
+const spawnSteer: Plugin = {
+ name: 'spawn-steer',
+ tier: 'user',
+ register: on => {
+ on('agent.spawn', ($, e, next) => next(e))
+ },
+}
+
+describe('trust: every call and hook that reaches outside the session is risky', () => {
+ for (const [plugin, why] of [
+ [spawner, /process\.spawn \(runs host commands\)/],
+ [mcpCaller, /mcp\.call \(calls MCP tools/],
+ [promptSteer, /on prompt\.submit \(can rewrite or add context to every prompt\)/],
+ [spawnSteer, /on agent\.spawn \(can rewrite or answer subagent spawns\)/],
+ ] as const) {
+ test(`refuse-risky refuses ${plugin.name}`, { plugins: [plugin], options: { modTrust: 'refuse-risky' } }, async ($, on) => {
+ world(on)
+ await expect($.session.start(START)).rejects.toThrow(new RegExp(`${plugin.name}: refused by ruflo-mods: .*${why.source}`))
+ })
+ test(`observe names what ${plugin.name} can do`, { plugins: [plugin] }, async ($, on) => {
+ const w = world(on)
+ await $.session.start(START)
+ expect(w.logs.join('\n')).toMatch(why)
+ })
+ }
+})
diff --git a/v3/@claude-flow/cli/__tests__/mods/mods-noun-trust.test.ts b/v3/@claude-flow/cli/__tests__/mods/mods-noun-trust.test.ts
index dd98ea34bb..9c801c1f1a 100644
--- a/v3/@claude-flow/cli/__tests__/mods/mods-noun-trust.test.ts
+++ b/v3/@claude-flow/cli/__tests__/mods/mods-noun-trust.test.ts
@@ -76,6 +76,22 @@ describe('ADR-404 mod trust gate', () => {
expect(judge(risky, 'off', new Set()).judged).toBe(false);
});
+ it('observe names a reloaded module again when it gains a risky call or hook', async () => {
+ const world = memoryWorld();
+ const mod = loadMod(register, world, {});
+ await mod.create();
+ const base = { name: 'helper', tier: 'user', root: '/home/u/.claude/dev-mods/s/helper', provenance: 'helper@inline' };
+ await mod.dispatch('plugin.register', { ...base, uses: { events: ['turn.complete'], calls: ['ui.status'] } }, () => ({ allow: true }));
+ await mod.dispatch('plugin.register', { ...base, uses: { events: ['turn.complete'], calls: ['ui.status'] } }, () => ({ allow: true }));
+ const before = world.logs.length;
+ await mod.dispatch('plugin.register', { ...base, uses: { events: ['turn.complete', 'tool.check'], calls: ['process.run'] } }, () => ({ allow: true }));
+ expect(world.logs.length).toBe(before + 1);
+ expect(world.logs.at(-1)).toContain('process.run (runs host commands)');
+ // The same risk again is not repeated.
+ await mod.dispatch('plugin.register', { ...base, uses: { events: ['tool.check', 'turn.complete'], calls: ['process.run'] } }, () => ({ allow: true }));
+ expect(world.logs.length).toBe(before + 1);
+ });
+
it('through the hook: refuse-risky refuses, a failing gate refuses rather than admits', async () => {
const world = memoryWorld();
const mod = loadMod(register, world, { modTrust: 'refuse-risky' });