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(mods): a domain plugin's refusal of another plugin's memory_store no longer claims the write (variant B, review #8)

ruv0bae1e47e7c9
diff --git a/plugins/ruflo-migrations/.claude-plugin/plugin.json b/plugins/ruflo-migrations/.claude-plugin/plugin.json
index b778b12529..b9feb060ba 100644
--- a/plugins/ruflo-migrations/.claude-plugin/plugin.json
+++ b/plugins/ruflo-migrations/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-migrations",
"description": "Schema migration management β€” generate, validate, dry-run, and rollback database migrations. As a mod (ADR-445): a tighten-only guard on its tools, /migrations-mod, and a status file the console shows",
- "version": "0.3.2",
+ "version": "0.3.3",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-migrations/hooks/guard.ts b/plugins/ruflo-migrations/hooks/guard.ts
index 52b4af9d19..7e7b137aba 100644
--- a/plugins/ruflo-migrations/hooks/guard.ts
+++ b/plugins/ruflo-migrations/hooks/guard.ts
@@ -1,10 +1,26 @@
-import { secretsIn, textsOf } from './screen'
+import { hasSecret, secretsIn, textsOf } from './screen'
import type { ModOptions } from './options'
import type { Stats } from './status'
const WRITERS = new Set(['memory_store', 'agentdb_pattern-store', 'agentdb_hierarchical-store', 'agentdb_batch'])
const toolOf = (name: string) => (name.startsWith('mcp__') ? name.slice(name.lastIndexOf('__') + 2) : name)
+/** This plugin's namespaces. A `memory_store` outside them is another plugin's write: still screened, but its refusal must not claim it. */
+const OWN_NS = /^migration/i
+const namespaceOf = (input: unknown): string | undefined => {
+ const top = typeof input === 'object' && input !== null ? (input as Record<string, unknown>) : {}
+ const inner = typeof top.input === 'object' && top.input !== null ? (top.input as Record<string, unknown>) : {}
+ return [top.namespace, inner.namespace].find((n): n is string => typeof n === 'string')
+}
+const foreignStore = (tool: string, input: unknown): boolean => /(?:^|__)memory_store$/.test(tool) && !OWN_NS.test(namespaceOf(input) ?? '')
+/** The refusal for a secret in another plugin's `memory_store`: what was found and which namespace, never an owner and never content. */
+function foreignRefusal(input: unknown): string {
+ const ns = namespaceOf(input)
+ const label = (ns ?? '').replace(/[^\w.:-]/g, '').slice(0, 40)
+ const where = !ns ? 'no namespace' : label && !hasSecret(ns) && !hasSecret(label) ? `namespace "${label}"` : 'a namespace not shown here'
+ return `ruflo-migrations: a secret-shaped value (a key, token or password) was found in a memory write; the call targeted ${where}. Store a reference to where it lives, not the value.`
+}
+
/**
* The reason a call is refused, or undefined when it may go. Migration SQL and connection strings are routinely pasted into memory, so a
* memory write holding a secret or a database URL with an inline password is refused. Names the rule, never echoes the value.
@@ -15,5 +31,6 @@ export function verdict(tool: string, input: unknown, _opts: ModOptions, stats:
const found = textsOf(input).flatMap(secretsIn)
if (found.length === 0) return undefined
stats.lastBlock = found[0]
+ if (foreignStore(tool, input)) return foreignRefusal(input)
return 'ruflo-migrations: this memory write holds what looks like a secret or a database URL with a password. Store the migration name and a reference to where the credential lives, not the value.'
}
diff --git a/plugins/ruflo-migrations/scripts/smoke.sh b/plugins/ruflo-migrations/scripts/smoke.sh
index e8003db1e1..dd61c800dd 100755
--- a/plugins/ruflo-migrations/scripts/smoke.sh
+++ b/plugins/ruflo-migrations/scripts/smoke.sh
@@ -7,9 +7,9 @@ step() { printf "β†’ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
-step "1. plugin.json declares 0.3.2 with new keywords"
+step "1. plugin.json declares 0.3.3 with new keywords"
v=$(grep -E '"version"' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
-if [[ "$v" != "0.3.2" ]]; then bad "expected 0.3.2, got '$v'"; else
+if [[ "$v" != "0.3.3" ]]; then bad "expected 0.3.3, got '$v'"; else
miss=""
for k in mcp dry-run up-down-pairs; do
grep -q "\"$k\"" "$ROOT/.claude-plugin/plugin.json" || miss="$miss $k"
diff --git a/plugins/ruflo-migrations/tests/migrations-mod.test.ts b/plugins/ruflo-migrations/tests/migrations-mod.test.ts
index b28a942e84..ff40147be5 100644
--- a/plugins/ruflo-migrations/tests/migrations-mod.test.ts
+++ b/plugins/ruflo-migrations/tests/migrations-mod.test.ts
@@ -101,3 +101,33 @@ describe('/migrations-mod', () => {
expect((await $.command.run(slash(''))).text).toContain('/migrations-mod scan')
})
})
+
+describe('guard: a write to a namespace this plugin does not own', () => {
+ const put = (namespace: string | undefined, value: string) =>
+ call('mcp__plugin_ruflo-core_ruflo__memory_store', { key: 'k', ...(namespace === undefined ? {} : { namespace }), value })
+
+ test('is refused exactly as before, but the message neither claims the write nor echoes anything', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const own = await outcome($, put('migrations', `token ${KEY}`))
+ expect(own).toContain('ruflo-migrations')
+ expect(own).toContain('this memory write')
+ for (const ns of ['unrelated-notes', undefined, 'x'.repeat(80)]) {
+ const denied = await outcome($, put(ns, `token ${KEY}`))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).toMatch(ns === undefined ? /no namespace/ : new RegExp(`targeted namespace \\\\?"${ns.slice(0, 40)}\\\\?"`))
+ expect(denied).not.toMatch(/this memory write|migration name|database URL/)
+ expect(denied).not.toContain('ghp_')
+ expect(denied).toContain('reference')
+ }
+ expect(await outcome($, put('unrelated-notes', 'prefer small reversible steps'))).toContain('ok')
+ })
+
+ test('a secret-shaped namespace is refused and never repeated', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const denied = await outcome($, put(KEY, 'a plain note'))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).not.toContain('ghp_')
+ })
+})
diff --git a/plugins/ruflo-music/.claude-plugin/plugin.json b/plugins/ruflo-music/.claude-plugin/plugin.json
index ccd963b797..e64a955128 100644
--- a/plugins/ruflo-music/.claude-plugin/plugin.json
+++ b/plugins/ruflo-music/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-music",
"description": "AI music generation via Cognitum Music (cogmusic MCP) β€” compose lyrics/prompts, generate tracks, separate stems, extract MIDI, and master through your own music.cognitum.one account. As a mod (ADR-445): a tighten-only guard on its tools, /music-mod, and a status file the console shows",
- "version": "0.2.2",
+ "version": "0.2.3",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-music/hooks/guard.ts b/plugins/ruflo-music/hooks/guard.ts
index 0434e16aa9..889e2b8928 100644
--- a/plugins/ruflo-music/hooks/guard.ts
+++ b/plugins/ruflo-music/hooks/guard.ts
@@ -1,4 +1,4 @@
-import { secretsIn, textsOf } from './screen'
+import { hasSecret, secretsIn, textsOf } from './screen'
import type { ModOptions } from './options'
import type { Stats } from './status'
@@ -10,6 +10,22 @@ const serverOf = (name: string) => (name.startsWith('mcp__') ? name.slice(5, nam
/** The cogmusic server, however the plugin names it (`cogmusic` or `plugin_ruflo-music_cogmusic`). */
const isCogmusic = (name: string) => serverOf(name).includes('cogmusic') && OWN.has(toolOf(name))
+/** This plugin's namespaces. A `memory_store` outside them is another plugin's write: still screened, but its refusal must not claim it. */
+const OWN_NS = /^music/i
+const namespaceOf = (input: unknown): string | undefined => {
+ const top = typeof input === 'object' && input !== null ? (input as Record<string, unknown>) : {}
+ const inner = typeof top.input === 'object' && top.input !== null ? (top.input as Record<string, unknown>) : {}
+ return [top.namespace, inner.namespace].find((n): n is string => typeof n === 'string')
+}
+const foreignStore = (tool: string, input: unknown): boolean => /(?:^|__)memory_store$/.test(tool) && !OWN_NS.test(namespaceOf(input) ?? '')
+/** The refusal for a secret in another plugin's `memory_store`: what was found and which namespace, never an owner and never content. */
+function foreignRefusal(input: unknown): string {
+ const ns = namespaceOf(input)
+ const label = (ns ?? '').replace(/[^\w.:-]/g, '').slice(0, 40)
+ const where = !ns ? 'no namespace' : label && !hasSecret(ns) && !hasSecret(label) ? `namespace "${label}"` : 'a namespace not shown here'
+ return `ruflo-music: a secret-shaped value (a key, token or password) was found in a memory write; the call targeted ${where}. Store a reference to where it lives, not the value.`
+}
+
/**
* The reason a call is refused, or undefined when it may go. Prompts and lyrics leave the machine for music.cognitum.one, and memory
* writes persist, so neither may carry a key, token or password. Names the rule, never echoes the value.
@@ -24,6 +40,7 @@ export function verdict(tool: string, input: unknown, _opts: ModOptions, stats:
return undefined
}
stats.lastBlock = found[0]
+ if (!sends && foreignStore(tool, input)) return foreignRefusal(input)
return sends
? 'ruflo-music: this prompt or lyrics hold what looks like a secret (a key, token or password); they would be sent to the music service. Remove it and try again.'
: 'ruflo-music: this memory write holds what looks like a secret (a key, token or password). Store a reference to where it lives, not the value.'
diff --git a/plugins/ruflo-music/scripts/smoke.sh b/plugins/ruflo-music/scripts/smoke.sh
index 54ff111c96..69a0850035 100755
--- a/plugins/ruflo-music/scripts/smoke.sh
+++ b/plugins/ruflo-music/scripts/smoke.sh
@@ -7,9 +7,9 @@ step() { printf "β†’ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
-step "1. plugin.json declares 0.2.2 with expected keywords"
+step "1. plugin.json declares 0.2.3 with expected keywords"
v=$(grep -E '"version"' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
-if [[ "$v" != "0.2.2" ]]; then bad "expected 0.2.2, got '$v'"; else
+if [[ "$v" != "0.2.3" ]]; then bad "expected 0.2.3, got '$v'"; else
miss=""
for k in cogmusic cognitum mcp; do
grep -q "\"$k\"" "$ROOT/.claude-plugin/plugin.json" || miss="$miss $k"
diff --git a/plugins/ruflo-music/tests/music-mod.test.ts b/plugins/ruflo-music/tests/music-mod.test.ts
index 26a081a804..6a6a8ddc70 100644
--- a/plugins/ruflo-music/tests/music-mod.test.ts
+++ b/plugins/ruflo-music/tests/music-mod.test.ts
@@ -100,3 +100,33 @@ describe('/music-mod', () => {
expect((await $.command.run(slash(''))).text).toContain('/music-mod scan')
})
})
+
+describe('guard: a write to a namespace this plugin does not own', () => {
+ const put = (namespace: string | undefined, value: string) =>
+ call('mcp__plugin_ruflo-core_ruflo__memory_store', { key: 'k', ...(namespace === undefined ? {} : { namespace }), value })
+
+ test('is refused exactly as before, but the message neither claims the write nor echoes anything', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const own = await outcome($, put('music-briefs', `token ${KEY}`))
+ expect(own).toContain('ruflo-music')
+ expect(own).toContain('this memory write')
+ for (const ns of ['unrelated-notes', undefined, 'x'.repeat(80)]) {
+ const denied = await outcome($, put(ns, `token ${KEY}`))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).toMatch(ns === undefined ? /no namespace/ : new RegExp(`targeted namespace \\\\?"${ns.slice(0, 40)}\\\\?"`))
+ expect(denied).not.toMatch(/this memory write|this prompt|music service/)
+ expect(denied).not.toContain('ghp_')
+ expect(denied).toContain('reference')
+ }
+ expect(await outcome($, put('unrelated-notes', 'prefer small reversible steps'))).toContain('ok')
+ })
+
+ test('a secret-shaped namespace is refused and never repeated', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const denied = await outcome($, put(KEY, 'a plain note'))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).not.toContain('ghp_')
+ })
+})
diff --git a/plugins/ruflo-neural-trader/.claude-plugin/plugin.json b/plugins/ruflo-neural-trader/.claude-plugin/plugin.json
index 5a4895928c..e342b78d04 100644
--- a/plugins/ruflo-neural-trader/.claude-plugin/plugin.json
+++ b/plugins/ruflo-neural-trader/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-neural-trader",
"description": "Neural trading via npx neural-trader β€” self-learning strategies, Rust/NAPI backtesting, 112+ MCP tools, swarm coordination, and portfolio optimization. As a mod (ADR-445): a tighten-only guard on its tools, /trader-mod, and a status file the console shows",
- "version": "0.3.3",
+ "version": "0.3.4",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-neural-trader/hooks/guard.ts b/plugins/ruflo-neural-trader/hooks/guard.ts
index 11cf66365e..15a528065b 100644
--- a/plugins/ruflo-neural-trader/hooks/guard.ts
+++ b/plugins/ruflo-neural-trader/hooks/guard.ts
@@ -1,4 +1,4 @@
-import { secretsIn, textsOf } from './screen'
+import { hasSecret, secretsIn, textsOf } from './screen'
import type { ModOptions } from './options'
import type { Stats } from './status'
@@ -18,6 +18,22 @@ function confirmed(input: unknown): boolean {
return [top, inner].some(o => o.confirm === true || o.confirmed === true || o.paper === true || o.dryRun === true || o.dry_run === true)
}
+/** This plugin's namespaces. A `memory_store` outside them is another plugin's write: still screened, but its refusal must not claim it. */
+const OWN_NS = /^(?:trading|neural-trader|trader)/i
+const namespaceOf = (input: unknown): string | undefined => {
+ const top = typeof input === 'object' && input !== null ? (input as Record<string, unknown>) : {}
+ const inner = typeof top.input === 'object' && top.input !== null ? (top.input as Record<string, unknown>) : {}
+ return [top.namespace, inner.namespace].find((n): n is string => typeof n === 'string')
+}
+const foreignStore = (tool: string, input: unknown): boolean => /(?:^|__)memory_store$/.test(tool) && !OWN_NS.test(namespaceOf(input) ?? '')
+/** The refusal for a secret in another plugin's `memory_store`: what was found and which namespace, never an owner and never content. */
+function foreignRefusal(input: unknown): string {
+ const ns = namespaceOf(input)
+ const label = (ns ?? '').replace(/[^\w.:-]/g, '').slice(0, 40)
+ const where = !ns ? 'no namespace' : label && !hasSecret(ns) && !hasSecret(label) ? `namespace "${label}"` : 'a namespace not shown here'
+ return `ruflo-neural-trader: a secret-shaped value (a key, token or password) was found in a memory write; the call targeted ${where}. Store a reference to where it lives, not the value.`
+}
+
/**
* The reason a call is refused, or undefined when it may go. Two rules: a memory write or trader call holding a secret is refused
* (broker keys must not be stored or echoed), and a live order call without an explicit `confirm: true` (or `paper`/`dryRun`) is refused.
@@ -30,6 +46,7 @@ export function verdict(tool: string, input: unknown, opts: ModOptions, stats: S
const found = textsOf(input).flatMap(secretsIn)
if (found.length > 0) {
stats.lastBlock = found[0]
+ if (!trader && foreignStore(tool, input)) return foreignRefusal(input)
return 'ruflo-neural-trader: this call holds what looks like a secret (a broker key, token or password). Keep credentials in the environment and pass a reference, not the value.'
}
if (opts.liveGuard && trader && ORDER.test(toolOf(tool)) && !confirmed(input)) {
diff --git a/plugins/ruflo-neural-trader/scripts/smoke.sh b/plugins/ruflo-neural-trader/scripts/smoke.sh
index 3c5949d01d..e5fb1fbf2f 100755
--- a/plugins/ruflo-neural-trader/scripts/smoke.sh
+++ b/plugins/ruflo-neural-trader/scripts/smoke.sh
@@ -7,9 +7,9 @@ step() { printf "β†’ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
-step "1. plugin.json declares 0.3.3 with new keywords"
+step "1. plugin.json declares 0.3.4 with new keywords"
v=$(grep -E '"version"' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
-if [[ "$v" != "0.3.3" ]]; then bad "expected 0.3.3, got '$v'"; else
+if [[ "$v" != "0.3.4" ]]; then bad "expected 0.3.4, got '$v'"; else
miss=""
for k in neural-trader-runtime walk-forward monte-carlo; do
grep -q "\"$k\"" "$ROOT/.claude-plugin/plugin.json" || miss="$miss $k"
diff --git a/plugins/ruflo-neural-trader/tests/trader-mod.test.ts b/plugins/ruflo-neural-trader/tests/trader-mod.test.ts
index 9a3004e5b5..de36a848b9 100644
--- a/plugins/ruflo-neural-trader/tests/trader-mod.test.ts
+++ b/plugins/ruflo-neural-trader/tests/trader-mod.test.ts
@@ -128,3 +128,33 @@ describe('/trader-mod', () => {
expect((await $.command.run(slash(''))).text).toContain('/trader-mod scan')
})
})
+
+describe('guard: a write to a namespace this plugin does not own', () => {
+ const put = (namespace: string | undefined, value: string) =>
+ call('mcp__plugin_ruflo-core_ruflo__memory_store', { key: 'k', ...(namespace === undefined ? {} : { namespace }), value })
+
+ test('is refused exactly as before, but the message neither claims the write nor echoes anything', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const own = await outcome($, put('trading-signals', `token ${KEY}`))
+ expect(own).toContain('ruflo-neural-trader')
+ expect(own).toContain('this call holds')
+ for (const ns of ['unrelated-notes', undefined, 'x'.repeat(80)]) {
+ const denied = await outcome($, put(ns, `token ${KEY}`))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).toMatch(ns === undefined ? /no namespace/ : new RegExp(`targeted namespace \\\\?"${ns.slice(0, 40)}\\\\?"`))
+ expect(denied).not.toMatch(/this call|broker key|credentials/)
+ expect(denied).not.toContain('ghp_')
+ expect(denied).toContain('reference')
+ }
+ expect(await outcome($, put('unrelated-notes', 'prefer small reversible steps'))).toContain('ok')
+ })
+
+ test('a secret-shaped namespace is refused and never repeated', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const denied = await outcome($, put(KEY, 'a plain note'))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).not.toContain('ghp_')
+ })
+})
diff --git a/plugins/ruflo-observability/.claude-plugin/plugin.json b/plugins/ruflo-observability/.claude-plugin/plugin.json
index 05a468f7dd..dbfa83e547 100644
--- a/plugins/ruflo-observability/.claude-plugin/plugin.json
+++ b/plugins/ruflo-observability/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-observability",
"description": "Structured logging, distributed tracing, and metrics β€” correlate agent swarm activity with application telemetry. As a mod (ADR-445): a tighten-only guard on its tools, /observe-mod, and a status file the console shows",
- "version": "0.3.2",
+ "version": "0.3.3",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-observability/hooks/guard.ts b/plugins/ruflo-observability/hooks/guard.ts
index 23e3f8f7a3..728fd80a9f 100644
--- a/plugins/ruflo-observability/hooks/guard.ts
+++ b/plugins/ruflo-observability/hooks/guard.ts
@@ -1,10 +1,26 @@
-import { secretsIn, textsOf } from './screen'
+import { hasSecret, secretsIn, textsOf } from './screen'
import type { ModOptions } from './options'
import type { Stats } from './status'
const WRITERS = new Set(['memory_store', 'agentdb_pattern-store', 'agentdb_hierarchical-store', 'agentdb_batch'])
const toolOf = (name: string) => (name.startsWith('mcp__') ? name.slice(name.lastIndexOf('__') + 2) : name)
+/** This plugin's namespaces. A `memory_store` outside them is another plugin's write: still screened, but its refusal must not claim it. */
+const OWN_NS = /^observab/i
+const namespaceOf = (input: unknown): string | undefined => {
+ const top = typeof input === 'object' && input !== null ? (input as Record<string, unknown>) : {}
+ const inner = typeof top.input === 'object' && top.input !== null ? (top.input as Record<string, unknown>) : {}
+ return [top.namespace, inner.namespace].find((n): n is string => typeof n === 'string')
+}
+const foreignStore = (tool: string, input: unknown): boolean => /(?:^|__)memory_store$/.test(tool) && !OWN_NS.test(namespaceOf(input) ?? '')
+/** The refusal for a secret in another plugin's `memory_store`: what was found and which namespace, never an owner and never content. */
+function foreignRefusal(input: unknown): string {
+ const ns = namespaceOf(input)
+ const label = (ns ?? '').replace(/[^\w.:-]/g, '').slice(0, 40)
+ const where = !ns ? 'no namespace' : label && !hasSecret(ns) && !hasSecret(label) ? `namespace "${label}"` : 'a namespace not shown here'
+ return `ruflo-observability: a secret-shaped value (a key, token or password) was found in a memory write; the call targeted ${where}. Store a reference to where it lives, not the value.`
+}
+
/**
* The reason a call is refused, or undefined when it may go. Spans, logs and metric labels are stored as memory and outlive the run, so a
* write holding a secret, a US SSN or a payment card number is refused. Names the rule, never echoes the value.
@@ -15,5 +31,6 @@ export function verdict(tool: string, input: unknown, _opts: ModOptions, stats:
const found = textsOf(input).flatMap(secretsIn)
if (found.length === 0) return undefined
stats.lastBlock = found[0]
+ if (foreignStore(tool, input)) return foreignRefusal(input)
return 'ruflo-observability: this telemetry write holds what looks like a secret or personal data (a key, token, SSN or card number). Redact it from the span, log or label first.'
}
diff --git a/plugins/ruflo-observability/scripts/smoke.sh b/plugins/ruflo-observability/scripts/smoke.sh
index c2f10eb273..e3cfcdfc0d 100755
--- a/plugins/ruflo-observability/scripts/smoke.sh
+++ b/plugins/ruflo-observability/scripts/smoke.sh
@@ -7,9 +7,9 @@ step() { printf "β†’ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
-step "1. plugin.json declares 0.3.2 with new keywords"
+step "1. plugin.json declares 0.3.3 with new keywords"
v=$(grep -E '"version"' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
-if [[ "$v" != "0.3.2" ]]; then bad "expected 0.3.2, got '$v'"; else
+if [[ "$v" != "0.3.3" ]]; then bad "expected 0.3.3, got '$v'"; else
miss=""
for k in mcp distributed-tracing anomaly-detection; do
grep -q "\"$k\"" "$ROOT/.claude-plugin/plugin.json" || miss="$miss $k"
diff --git a/plugins/ruflo-observability/tests/observe-mod.test.ts b/plugins/ruflo-observability/tests/observe-mod.test.ts
index 9a3444bc2c..be365827af 100644
--- a/plugins/ruflo-observability/tests/observe-mod.test.ts
+++ b/plugins/ruflo-observability/tests/observe-mod.test.ts
@@ -98,3 +98,33 @@ describe('/observe-mod', () => {
expect((await $.command.run(slash(''))).text).toContain('/observe-mod scan')
})
})
+
+describe('guard: a write to a namespace this plugin does not own', () => {
+ const put = (namespace: string | undefined, value: string) =>
+ call('mcp__plugin_ruflo-core_ruflo__memory_store', { key: 'k', ...(namespace === undefined ? {} : { namespace }), value })
+
+ test('is refused exactly as before, but the message neither claims the write nor echoes anything', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const own = await outcome($, put('observability-traces', `token ${KEY}`))
+ expect(own).toContain('ruflo-observability')
+ expect(own).toContain('this telemetry write')
+ for (const ns of ['unrelated-notes', undefined, 'x'.repeat(80)]) {
+ const denied = await outcome($, put(ns, `token ${KEY}`))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).toMatch(ns === undefined ? /no namespace/ : new RegExp(`targeted namespace \\\\?"${ns.slice(0, 40)}\\\\?"`))
+ expect(denied).not.toMatch(/this telemetry write|span, log or label|telemetry/)
+ expect(denied).not.toContain('ghp_')
+ expect(denied).toContain('reference')
+ }
+ expect(await outcome($, put('unrelated-notes', 'prefer small reversible steps'))).toContain('ok')
+ })
+
+ test('a secret-shaped namespace is refused and never repeated', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const denied = await outcome($, put(KEY, 'a plain note'))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).not.toContain('ghp_')
+ })
+})
diff --git a/plugins/ruflo-ruvector/.claude-plugin/plugin.json b/plugins/ruflo-ruvector/.claude-plugin/plugin.json
index e9d26ee073..4a04701aad 100644
--- a/plugins/ruflo-ruvector/.claude-plugin/plugin.json
+++ b/plugins/ruflo-ruvector/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-ruvector",
"description": "Self-learning vector database via npx [email protected] β€” HNSW, adaptive LoRA embeddings, code-graph clustering, hooks routing, brain/SONA, 103 MCP tools. As a mod (ADR-445): a write guard that keeps secrets out of the vector store and shared brain, /ruvector-mod, and a status file the console shows",
- "version": "0.3.3",
+ "version": "0.3.4",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-ruvector/hooks/guard.ts b/plugins/ruflo-ruvector/hooks/guard.ts
index ca414e3623..d278bd5243 100644
--- a/plugins/ruflo-ruvector/hooks/guard.ts
+++ b/plugins/ruflo-ruvector/hooks/guard.ts
@@ -3,10 +3,28 @@ import { isWriter } from './tools'
import { textsOf } from './screen'
export { textsOf }
+/** This plugin's namespaces. A `memory_store` outside them is another plugin's write: still screened, but its refusal must not claim it. */
+const OWN_NS = /^(?:vector|hyperbolic|ruvector)/i
+const namespaceOf = (input: unknown): string | undefined => {
+ const top = typeof input === 'object' && input !== null ? (input as Record<string, unknown>) : {}
+ const inner = typeof top.input === 'object' && top.input !== null ? (top.input as Record<string, unknown>) : {}
+ return [top.namespace, inner.namespace].find((n): n is string => typeof n === 'string')
+}
+const foreignStore = (tool: string, input: unknown): boolean => /(?:^|__)memory_store$/.test(tool) && !OWN_NS.test(namespaceOf(input) ?? '')
+/** The refusal for a secret in another plugin's `memory_store`: what was found and which namespace, never an owner and never content. */
+function foreignRefusal(input: unknown): string {
+ const ns = namespaceOf(input)
+ const label = (ns ?? '').replace(/[^\w.:-]/g, '').slice(0, 40)
+ const where = !ns ? 'no namespace' : label && !hasSecret(ns) && !hasSecret(label) ? `namespace "${label}"` : 'a namespace not shown here'
+ return `ruflo-ruvector: a secret-shaped value (a key, token or password) was found in a memory write; the call targeted ${where}. Store a reference to where it lives, not the value.`
+}
+
/** The reason a call is refused, or undefined when it may go. Never names or echoes the secret. */
export function verdict(tool: string, input: unknown): string | undefined {
if (!isWriter(tool)) return undefined
return textsOf(input).some(hasSecret)
- ? 'ruflo-ruvector: this call holds what looks like a secret (a key, token or password). Keep secrets out of the vector store and the shared brain; store a reference instead.'
+ ? foreignStore(tool, input)
+ ? foreignRefusal(input)
+ : 'ruflo-ruvector: this call holds what looks like a secret (a key, token or password). Keep secrets out of the vector store and the shared brain; store a reference instead.'
: undefined
}
diff --git a/plugins/ruflo-ruvector/tests/ruvector.test.ts b/plugins/ruflo-ruvector/tests/ruvector.test.ts
index eb10402a26..fa1990ca1f 100644
--- a/plugins/ruflo-ruvector/tests/ruvector.test.ts
+++ b/plugins/ruflo-ruvector/tests/ruvector.test.ts
@@ -98,3 +98,34 @@ describe('/ruvector-mod', () => {
expect((await $.command.run(slash(''))).text).toContain('/ruvector-mod status')
})
})
+
+describe('guard: a write to a namespace this plugin does not own', () => {
+ const STORE = 'mcp__plugin_ruflo-core_ruflo__memory_store'
+ const put = (namespace: string | undefined, value: string) => ({ tool: STORE, key: 'k', ...(namespace === undefined ? {} : { namespace }), value }) as never
+ const text = async ($: { tool: { call: (e: never) => Promise<unknown> } }, e: never) => JSON.stringify(await attempt($.tool.call(e)))
+
+ test('is refused exactly as before, but the message neither claims the write nor echoes anything', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const own = await text($, put('vector-patterns', `token ${SECRET}`))
+ expect(own).toContain('ruflo-ruvector')
+ expect(own).toContain('this call holds')
+ for (const ns of ['unrelated-notes', undefined, 'x'.repeat(80)]) {
+ const denied = await text($, put(ns, `token ${SECRET}`))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).toMatch(ns === undefined ? /no namespace/ : new RegExp(`targeted namespace \\\\?"${ns.slice(0, 40)}\\\\?"`))
+ expect(denied).not.toMatch(/this call holds|vector store|shared brain/)
+ expect(denied).not.toContain('ghp_')
+ expect(denied).toContain('reference')
+ }
+ expect(await text($, put('unrelated-notes', 'a plain note about indexing'))).toContain('done')
+ })
+
+ test('a secret-shaped namespace is refused and never repeated', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const denied = await text($, put(SECRET, 'a plain note'))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).not.toContain('ghp_')
+ })
+})
diff --git a/plugins/ruflo-rvf/.claude-plugin/plugin.json b/plugins/ruflo-rvf/.claude-plugin/plugin.json
index 7d7c20ee28..e072b4f4b5 100644
--- a/plugins/ruflo-rvf/.claude-plugin/plugin.json
+++ b/plugins/ruflo-rvf/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-rvf",
"description": "RVF format for portable agent memory, session persistence, and cross-platform transfer. As a mod (ADR-445): a write guard that keeps secrets out of memory, sessions and transfers, /rvf-mod, and a status file the console shows",
- "version": "0.3.4",
+ "version": "0.3.5",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-rvf/hooks/guard.ts b/plugins/ruflo-rvf/hooks/guard.ts
index d3d8d6e764..fda5852355 100644
--- a/plugins/ruflo-rvf/hooks/guard.ts
+++ b/plugins/ruflo-rvf/hooks/guard.ts
@@ -3,10 +3,28 @@ import { isWriter } from './tools'
import { textsOf } from './screen'
export { textsOf }
+/** This plugin's namespaces. A `memory_store` outside them is another plugin's write: still screened, but its refusal must not claim it. */
+const OWN_NS = /^rvf/i
+const namespaceOf = (input: unknown): string | undefined => {
+ const top = typeof input === 'object' && input !== null ? (input as Record<string, unknown>) : {}
+ const inner = typeof top.input === 'object' && top.input !== null ? (top.input as Record<string, unknown>) : {}
+ return [top.namespace, inner.namespace].find((n): n is string => typeof n === 'string')
+}
+const foreignStore = (tool: string, input: unknown): boolean => /(?:^|__)memory_store$/.test(tool) && !OWN_NS.test(namespaceOf(input) ?? '')
+/** The refusal for a secret in another plugin's `memory_store`: what was found and which namespace, never an owner and never content. */
+function foreignRefusal(input: unknown): string {
+ const ns = namespaceOf(input)
+ const label = (ns ?? '').replace(/[^\w.:-]/g, '').slice(0, 40)
+ const where = !ns ? 'no namespace' : label && !hasSecret(ns) && !hasSecret(label) ? `namespace "${label}"` : 'a namespace not shown here'
+ return `ruflo-rvf: a secret-shaped value (a key, token or password) was found in a memory write; the call targeted ${where}. Store a reference to where it lives, not the value.`
+}
+
/** The reason a call is refused, or undefined when it may go. Never names or echoes the secret. */
export function verdict(tool: string, input: unknown): string | undefined {
if (!isWriter(tool)) return undefined
return textsOf(input).some(hasSecret)
- ? 'ruflo-rvf: this call holds what looks like a secret (a key, token or password). Store a reference to where it lives, not the value.'
+ ? foreignStore(tool, input)
+ ? foreignRefusal(input)
+ : 'ruflo-rvf: this call holds what looks like a secret (a key, token or password). Store a reference to where it lives, not the value.'
: undefined
}
diff --git a/plugins/ruflo-rvf/scripts/smoke.sh b/plugins/ruflo-rvf/scripts/smoke.sh
index 116192bd92..41fe955723 100755
--- a/plugins/ruflo-rvf/scripts/smoke.sh
+++ b/plugins/ruflo-rvf/scripts/smoke.sh
@@ -7,9 +7,9 @@ step() { printf "β†’ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
-step "1. plugin.json declares 0.3.4 with new keywords"
+step "1. plugin.json declares 0.3.5 with new keywords"
v=$(grep -E '"version"' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
-if [[ "$v" != "0.3.4" ]]; then bad "expected 0.3.4, got '$v'"; else
+if [[ "$v" != "0.3.5" ]]; then bad "expected 0.3.5, got '$v'"; else
miss=""
for k in mcp cognitive-containers lineage-tracking; do
grep -q "\"$k\"" "$ROOT/.claude-plugin/plugin.json" || miss="$miss $k"
diff --git a/plugins/ruflo-rvf/tests/rvf.test.ts b/plugins/ruflo-rvf/tests/rvf.test.ts
index c75336e246..97e26fb531 100644
--- a/plugins/ruflo-rvf/tests/rvf.test.ts
+++ b/plugins/ruflo-rvf/tests/rvf.test.ts
@@ -110,3 +110,34 @@ describe('/rvf-mod', () => {
expect((await $.command.run(slash(''))).text).toContain('/rvf-mod status')
})
})
+
+describe('guard: a write to a namespace this plugin does not own', () => {
+ const STORE = 'mcp__plugin_ruflo-core_ruflo__memory_store'
+ const put = (namespace: string | undefined, value: string) => ({ tool: STORE, key: 'k', ...(namespace === undefined ? {} : { namespace }), value }) as never
+ const text = async ($: { tool: { call: (e: never) => Promise<unknown> } }, e: never) => JSON.stringify(await attempt($.tool.call(e)))
+
+ test('is refused exactly as before, but the message neither claims the write nor echoes anything', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const own = await text($, put('rvf-sessions', `token ${SECRET}`))
+ expect(own).toContain('ruflo-rvf')
+ expect(own).toContain('this call holds')
+ for (const ns of ['unrelated-notes', undefined, 'x'.repeat(80)]) {
+ const denied = await text($, put(ns, `token ${SECRET}`))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).toMatch(ns === undefined ? /no namespace/ : new RegExp(`targeted namespace \\\\?"${ns.slice(0, 40)}\\\\?"`))
+ expect(denied).not.toMatch(/this call holds|vector store|shared brain/)
+ expect(denied).not.toContain('ghp_')
+ expect(denied).toContain('reference')
+ }
+ expect(await text($, put('unrelated-notes', 'a plain note about indexing'))).toContain('done')
+ })
+
+ test('a secret-shaped namespace is refused and never repeated', async ($, on) => {
+ world(on)
+ await $.session.start(START)
+ const denied = await text($, put(SECRET, 'a plain note'))
+ expect(denied).toContain('secret-shaped value')
+ expect(denied).not.toContain('ghp_')
+ })
+})
diff --git a/scripts/__tests__/guard-label.test.mjs b/scripts/__tests__/guard-label.test.mjs
new file mode 100644
index 0000000000..758b4dde04
--- /dev/null
+++ b/scripts/__tests__/guard-label.test.mjs
@@ -0,0 +1,100 @@
+#!/usr/bin/env node
+/**
+ * Overlapping `memory_store` guards (variant B): every guard keeps refusing a secret in any namespace, but a domain plugin that does not own
+ * the target namespace must not claim the write or name itself its owner, and must never echo content. Plugin tests cannot import across
+ * plugin folders, so the guards are bundled here.
+ *
+ * Run via: node --test scripts/__tests__/guard-label.test.mjs
+ */
+import { test } from 'node:test'
+import assert from 'node:assert/strict'
+import { execFileSync } from 'node:child_process'
+import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { dirname, join, resolve } from 'node:path'
+import { fileURLToPath, pathToFileURL } from 'node:url'
+
+const HERE = dirname(fileURLToPath(import.meta.url))
+const REPO = dirname(dirname(HERE))
+const tmp = mkdtempSync(join(tmpdir(), 'guard-label-test-'))
+process.on('exit', () => rmSync(tmp, { recursive: true, force: true }))
+
+function esbuild() {
+ if (process.env.ESBUILD) return process.env.ESBUILD
+ const roots = [REPO]
+ try { roots.push(dirname(resolve(REPO, execFileSync('git', ['rev-parse', '--git-common-dir'], { cwd: REPO, encoding: 'utf8' }).trim()))) } catch { /* not a git checkout */ }
+ for (const r of roots) { const p = join(r, 'node_modules', '.bin', 'esbuild'); if (existsSync(p)) return p }
+ throw new Error('esbuild not found (set ESBUILD=/path/to/esbuild)')
+}
+
+const WITH_STATS = ['music', 'neural-trader', 'migrations', 'observability']
+const NAMES = ['agentdb', 'rag-memory', ...WITH_STATS, 'rvf', 'ruvector']
+const id = n => n.replace('-', '_')
+const entry = NAMES.map(n => {
+ const g = JSON.stringify(join(REPO, 'plugins', `ruflo-${n}`, 'hooks', 'guard.ts'))
+ return WITH_STATS.includes(n)
+ ? `import { verdict as v_${id(n)} } from ${g}\nimport { newStats as s_${id(n)} } from ${JSON.stringify(join(REPO, 'plugins', `ruflo-${n}`, 'hooks', 'status.ts'))}`
+ : `import { verdict as v_${id(n)} } from ${g}`
+}).join('\n') + `\nexport const guards = {\n${NAMES.map(n =>
+ WITH_STATS.includes(n) ? ` 'ruflo-${n}': (t: string, i: unknown) => v_${id(n)}(t, i, {} as never, s_${id(n)}()),` : ` 'ruflo-${n}': (t: string, i: unknown) => v_${id(n)}(t, i),`
+).join('\n')}\n}\n`
+writeFileSync(join(tmp, 'entry.ts'), entry)
+execFileSync(esbuild(), [join(tmp, 'entry.ts'), '--bundle', '--platform=node', '--format=esm', `--outfile=${join(tmp, 'guards.mjs')}`, '--log-level=error'])
+const { guards } = await import(pathToFileURL(join(tmp, 'guards.mjs')).href)
+
+const SECRET = ['ghp', 'a1B2'.repeat(10)].join('_') // built, never a literal
+const TOOL = 'mcp__plugin_ruflo-core_ruflo__memory_store'
+const write = (namespace, value = SECRET) => ({ key: 'k', ...(namespace === undefined ? {} : { namespace }), value })
+
+const OWNER = {
+ 'ruflo-music': 'music-briefs',
+ 'ruflo-neural-trader': 'trading-risk',
+ 'ruflo-migrations': 'migrations',
+ 'ruflo-observability': 'observability-traces',
+ 'ruflo-rvf': 'rvf-sessions',
+ 'ruflo-ruvector': 'vector-patterns',
+}
+// Wording that claims the write or the owner's domain; the foreign-namespace message must carry none of it.
+const OWNER_WORDING = /this (?:call|prompt|lyrics|memory write|telemetry write)|music service|broker|migration name|database URL|span, log|vector store|shared brain/
+
+for (const name of NAMES.map(n => `ruflo-${n}`)) {
+ test(`${name}: refuses a secret in every namespace shape, and a clean write goes through`, () => {
+ for (const ns of [...Object.values(OWNER), 'unowned-ns', undefined, '']) {
+ for (const input of [write(ns), { input: write(ns) }]) {
+ assert.ok(guards[name](TOOL, input), `${name} let a secret through (ns=${ns})`)
+ assert.equal(guards[name](TOOL, input).includes(SECRET), false)
+ }
+ assert.equal(guards[name](TOOL, write(ns, 'a note about the weekly review')), undefined)
+ }
+ })
+}
+
+for (const [name, ns] of Object.entries(OWNER)) {
+ test(`${name}: own namespace (${ns}) keeps its own wording`, () => {
+ const reason = guards[name](TOOL, write(ns))
+ assert.ok(reason.startsWith(`${name}:`) && !reason.includes('secret-shaped'), reason)
+ })
+
+ test(`${name}: a foreign or missing namespace gets a neutral message naming the target, no owner wording, no content`, () => {
+ for (const other of ['unowned-ns', undefined, ...Object.values(OWNER).filter(o => o !== ns)]) {
+ const reason = guards[name](TOOL, write(other))
+ assert.ok(reason.startsWith(`${name}:`), reason)
+ assert.match(reason, /secret-shaped value/)
+ assert.match(reason, other === undefined ? /no namespace/ : new RegExp(`namespace "${other}"`))
+ assert.doesNotMatch(reason, OWNER_WORDING)
+ assert.match(reason, /reference/)
+ assert.equal(reason.includes(SECRET), false)
+ }
+ })
+
+ test(`${name}: the namespace is cut, stripped, and dropped when secret-shaped`, () => {
+ assert.match(guards[name](TOOL, write('a b\u0000c' + 'z'.repeat(80))), /namespace "abc[z]{37}"/)
+ const leaky = guards[name](TOOL, write(SECRET))
+ assert.ok(leaky && !leaky.includes('ghp_'), leaky)
+ })
+
+ test(`${name}: the other writers keep their existing message`, () => {
+ const reason = guards[name]('mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store', write('unowned-ns'))
+ if (reason !== undefined) assert.doesNotMatch(reason, /secret-shaped value/)
+ })
+}