🌊 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(ruflo-mods): trust gate judges a glob or a negation by what it selects (#3801)
ruv93b6870a1d6b
diff --git a/plugins/ruflo-mods/hooks/trust.ts b/plugins/ruflo-mods/hooks/trust.tsindex 0812f40270..83e56d639f 100644--- a/plugins/ruflo-mods/hooks/trust.ts+++ b/plugins/ruflo-mods/hooks/trust.ts@@ -49,6 +49,23 @@ const RISKY_EVENTS: Record<string, string> = {'agent.spawn': 'can rewrite or answer every agent spawn',}+/**+ * The risky events a registered pattern reaches. The scan reports patterns as+ * written, so a glob (`tool.*`) or a negation (`!tool.describe`: every event+ * but one) must be judged by what it selects, not by how it is spelled.+ */+const escapeRe = (text: string) => text.replace(/[.+?^$()|[\]{}\\]/g, '\\$&')++function riskyEventsOf(pattern: string): string[] {+ if (Object.hasOwn(RISKY_EVENTS, pattern)) return [pattern]+ if (pattern.startsWith('!')) return ['*']+ // A settings hook by name, or a glob of them, can answer any of them.+ if (pattern.startsWith('classic.')) return ['classic.*']+ if (!pattern.includes('*')) return []+ const glob = new RegExp(`^${pattern.split('*').map(escapeRe).join('.*')}$`)+ return Object.keys(RISKY_EVENTS).filter(name => name !== '*' && name !== 'classic.*' && glob.test(name))+}+const isStrings = (v: unknown): v is readonly string[] => Array.isArray(v) && v.every(s => typeof s === 'string')/** What a module's scan says it could do that matters, as readable reasons. */@@ -56,8 +73,8 @@ export function riskOf(scan: ModuleScan): string[] {const calls = isStrings(scan.uses?.calls) ? scan.uses.calls : []const events = isStrings(scan.uses?.events) ? scan.uses.events : []return [- ...calls.filter(c => c in RISKY_CALLS).map(c => `${c} (${RISKY_CALLS[c]})`),- ...events.filter(ev => ev in RISKY_EVENTS).map(ev => `on ${ev} (${RISKY_EVENTS[ev]})`),+ ...calls.filter(c => Object.hasOwn(RISKY_CALLS, c)).map(c => `${c} (${RISKY_CALLS[c]})`),+ ...events.flatMap(ev => riskyEventsOf(ev).map(name => `on ${ev === name ? ev : `${ev} → ${name}`} (${RISKY_EVENTS[name]})`)),]}diff --git a/plugins/ruflo-mods/tests/trust.test.ts b/plugins/ruflo-mods/tests/trust.test.tsindex 698e992216..ae21ea5cf9 100644--- a/plugins/ruflo-mods/tests/trust.test.ts+++ b/plugins/ruflo-mods/tests/trust.test.ts@@ -109,14 +109,6 @@ const mcpCaller: Plugin = {})},}-/** 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',@@ -130,8 +122,8 @@ 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\)/],+ [promptSteer, /on prompt\.submit \(can add to or rewrite every prompt you send\)/],+ [spawnSteer, /on agent\.spawn \(can rewrite or answer every agent spawn\)/],] as const) {test(`refuse-risky refuses ${plugin.name}`, { plugins: [plugin], options: { modTrust: 'refuse-risky' } }, async ($, on) => {world(on)@@ -144,3 +136,29 @@ describe('trust: every call and hook that reaches outside the session is risky',})}})++describe('trust: a glob or a negation is judged by what it selects (#3801)', () => {+ // The engine reads `on` calls statically: each pattern is a literal at its call site.+ const toolGlob: Plugin = { name: 'tool-glob', tier: 'user', register: on => { on('tool.*', ($, e, next) => next(e)) } }+ const allButOne: Plugin = { name: 'all-but-one', tier: 'user', register: on => { on('!tool.describe', ($, e, next) => next(e)) } }+ const promptGlob: Plugin = { name: 'prompt-glob', tier: 'user', register: on => { on('prompt.*', ($, e, next) => next(e)) } }+ const agentGlob: Plugin = { name: 'agent-glob', tier: 'user', register: on => { on('agent.*', ($, e, next) => next(e)) } }+ const clockGlob: Plugin = { name: 'clock-glob', tier: 'user', register: on => { on('clock.*', ($, e, next) => next(e)) } }+ for (const [plugin, why] of [+ [toolGlob, /on tool\.\* → tool\.check \(can answer tool permission verdicts\)/],+ [allButOne, /on !tool\.describe → \* \(sees every event\)/],+ [promptGlob, /on prompt\.\* → prompt\.submit/],+ [agentGlob, /on agent\.\* → agent\.spawn/],+ ] 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('a glob that selects nothing risky still loads', { plugins: [clockGlob], options: { modTrust: 'refuse-risky' } }, async ($, on) => {+ const w = world(on)+ await $.session.start(START)+ expect(w.logs.join('\n')).not.toContain('REFUSED')+ })+})