🌊 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
security(ruflo-console): a shell command is a 'full'-level action, class detection no longer a weak denylist; ANSI/OSC/hidden-text stripping; ADR-450 threat model (0.33.3)
ruv7725b867fd7f
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.jsonindex 8b708b7f4d..3b9ec8722a 100644--- a/plugins/ruflo-console/.claude-plugin/plugin.json+++ b/plugins/ruflo-console/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "ruflo-console","description": "ruflo's cockpit inside Claude Code and the one /ruflo command for every ruflo mod (function hooks, early access). Views: overview with health alerts, swarm topology graph, claims flow with TTL rings, federation map, plugin health matrix, learning curve and pipeline, MetaHarness radar and audit trend, memory, cost gauge, agent timeline, approvals queue, event stream, a main menu, an x.ruv.io federation board, an AI terminal (codex, claude or both in remembered sessions, streamed), Skills (npx skills), a Hive-Mind view, a MetaHarness lab, agent drill-down; a command palette for confirm-gated actions through the ruflo CLI; a band above the prompt. Reads ruflo's files and the CLI's local JSON; anything not measured reads n/a. The one network call it makes by itself is a daily read of the published plugin.json at github.com/ruvnet/ruflo to offer an update (Settings → Updates: ask, auto, or off); it installs only through Claude Code's own claude plugin update, and never a new major version without asking.",- "version": "0.33.2",+ "version": "0.33.3","author": {"name": "ruvnet","url": "https://github.com/ruvnet"diff --git a/plugins/ruflo-console/hooks/data/agentdb-mod.ts b/plugins/ruflo-console/hooks/data/agentdb-mod.tsindex 2ffb08cce7..f3e0d85029 100644--- a/plugins/ruflo-console/hooks/data/agentdb-mod.ts+++ b/plugins/ruflo-console/hooks/data/agentdb-mod.ts@@ -1,4 +1,4 @@-import { jsonObject, recordOf } from './parse'+import { jsonObject, plain, recordOf } from './parse'/** What the ruflo-agentdb mod last wrote to `.claude-flow/agentdb-mod/status.json` (ADR-445): its settings, counters and the last items it attached. */export type AgentdbMod = {@@ -29,14 +29,14 @@ export function parseAgentdbMod(text: string | null): AgentdbMod | null {const recent = (Array.isArray(value.recent) ? value.recent : []).slice(-5).flatMap(item => {const r = recordOf(item)- return r !== null && typeof r.snippet === 'string' ? [{ source: typeof r.source === 'string' ? r.source.slice(0, 24) : '?', score: typeof r.score === 'number' ? r.score : null, snippet: r.snippet.slice(0, 120) }] : []+ return r !== null && typeof r.snippet === 'string' ? [{ source: typeof r.source === 'string' ? plain(r.source, 24) : '?', score: typeof r.score === 'number' && Number.isFinite(r.score) ? r.score : null, snippet: plain(r.snippet, 120) }] : []})return {recall: value.recall === true,guard: value.guard === true,- source: typeof value.source === 'string' ? value.source.slice(0, 16) : 'auto',- tool: typeof value.lastTool === 'string' ? value.lastTool.slice(0, 24) : null,+ source: typeof value.source === 'string' ? plain(value.source, 16) : 'auto',+ tool: typeof value.lastTool === 'string' ? plain(value.lastTool, 24) : null,updatedMs: whole(value.updatedMs),attached: whole(value.attached),skipped: whole(value.skipped),diff --git a/plugins/ruflo-console/hooks/data/parse.ts b/plugins/ruflo-console/hooks/data/parse.tsindex f324bdf30a..799a40b305 100644--- a/plugins/ruflo-console/hooks/data/parse.ts+++ b/plugins/ruflo-console/hooks/data/parse.ts@@ -13,14 +13,20 @@ export const MAX_RECORDS = 1_000const ID = /^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/-/** Plain printable text of at most `max` characters: no control or bidi-override characters reach the terminal. */+// Whole escape sequences go first (the CLI colours its output; a hostile file may carry a hyperlink or a title): stripping only the ESC byte+// would leave `[1m` or `]8;;https://…` in the text. Written as \u escapes so no invisible character sits in this source.+const ESCAPES = new RegExp('\\u001b\\][^\\u0007\\u001b]*(?:\\u0007|\\u001b\\\\)|\\u009d[^\\u0007\\u009c]*[\\u0007\\u009c]|(?:\\u001b\\[|\\u009b)[0-9;?]*[ -/]*[@-~]', 'g')+// Controls, DEL, C1, soft hyphen, combining grapheme joiner, Arabic letter mark, zero-width and bidi characters, invisible operators,+// variation selectors, Hangul fillers and BOM: nothing a person could read, all of them fit for hiding or reordering text.+const HIDDEN = new RegExp('[\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u034f\\u061c\\u115f\\u1160\\u17b4\\u17b5\\u180b-\\u180f\\u200b-\\u200f\\u202a-\\u202e\\u2060-\\u2064\\u2066-\\u2069\\u3164\\ufe00-\\ufe0d\\ufeff\\uffa0]|[\\u{e0000}-\\u{e0fff}]', 'gu')++/** Plain printable text of at most `max` characters: no escape sequence, control, hidden or bidi-override character reaches the terminal. */export function plain(value: unknown, max = 200): string {if (typeof value !== 'string') {return ''}- // Whole ANSI sequences first (the CLI colours its output): stripping only the ESC byte left `[1m` in log lines.- const cleaned = value.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, '').replace(/[\u0000-\u001f\u007f-\u009f---]/g, ' ').replace(/\s+/g, ' ').trim()+ const cleaned = value.replace(ESCAPES, '').replace(HIDDEN, ' ').replace(/\s+/g, ' ').trim()return cleaned.length <= max ? cleaned : `${cleaned.slice(0, Math.max(0, max - 1))}…`}diff --git a/plugins/ruflo-console/hooks/model-tools.ts b/plugins/ruflo-console/hooks/model-tools.tsindex 00efdd3229..8324a8e6b2 100644--- a/plugins/ruflo-console/hooks/model-tools.ts+++ b/plugins/ruflo-console/hooks/model-tools.ts@@ -45,17 +45,28 @@ export const TOOL_SPECS: readonly Spec[] = [{ name: 'console_run', needs: 'read', description: 'Run a palette entry by its id (as listed by console_state), with optional text. Read-only entries run at once. Others run only if the person allowed this level, and wait for their Yes unless they chose auto-confirm; the result says which. Example: id "mission-goal", text "add a dark mode toggle".', inputSchema: { type: 'object', properties: { id: { type: 'string' }, text: { type: 'string' } }, required: ['id'] } },]+/**+ * The words that put an action in a class (ADR-450). They are read from the console's own label, command and notes. Only the console's own+ * prose (`note`, `shows`) is cleaned of what an action does NOT do; the label and the command (which carry typed text) are read as they are,+ * so typed text can only add words, never cancel one. Matching is by stem, so "deleting", "removal" and "deletes" count. Anything it does not+ * name stays 'write': the list is a floor, not a proof.+ */+const DELETE = /\b(delet|remov|kill|terminat|destr[ou]y|shut ?down|stop|reset|rollback|cancel|wip(e|ing)|purg|prun|uninstall|force|clean ?up|migrat|drop|eras|unlink|truncat|revok|discard|flush|evict|unregister|nuke|abort|shell command|runs a shell|runs your (test|code)|terminal_execute|rm -)/+const SPEND = /\$\$|billed|costs? money|may cost|model turn|starts a (claude|codex)|spends (money|tokens|credits)|\bpaid\b|may call models|calls the anthropic api|with your (anthropic |api )?key|api key|openrouter|real (model|judge)/+const NETWORK = /\b(network|publish|deploy|push|install|download|fetch|registry|github|npm|gcloud|upload|update|clone|join|federat|reaches|curl|https?:|ssh|webhook|slack|ipfs|pi\.ruv\.io|x\.ruv\.io|relay|peer|broadcast|sends?|sync)/+/** Which class an action is, from its label, command and notes; anything unclear counts as the most dangerous class. */export function classOf(pending: Pick<Pending, 'label' | 'args' | 'note' | 'shows' | 'expect'>): ActionClass {// The console's own notes say what an action does NOT do too ("spends nothing", "not a charge", "runs no agent"): those must not count.- const text = `${pending.label} ${pending.args.join(' ')} ${pending.note ?? ''} ${pending.shows ?? ''}`+ const prose = `${pending.note ?? ''} ${pending.shows ?? ''}`.toLowerCase().replace(/\b(spends|costs|charges|bills|runs|starts|takes)\s+(nothing|no\b[^.;,]{0,30})/g, ' ').replace(/\b(no|not|never|without)\s+(a\s+|an\s+)?(spend\w*|billed|charge\w*|cost\w*|model turn|ai turn|agent|credits?)\b/g, ' ')+ const text = `${pending.label} ${pending.args.join(' ')}`.toLowerCase() + ' \u00a6 ' + prose- if (/\b(delete|remove|kill|terminate|destroy|shutdown|shut down|stop|reset|rollback|cancel|wipe|purge|prune|uninstall|force|clean ?up|migrate|drop)\b/.test(text)) return 'delete'- if (/\$\$|billed|costs money|model turn|starts a (claude|codex)|spends (money|tokens|credits)|\bpaid\b/.test(text)) return 'spend'- if (/\b(network|publish|deploy|push|install|download|fetch|registry|github|npm|gcloud|upload|update|clone|join|federat)/.test(text)) return 'network'+ if (DELETE.test(text)) return 'delete'+ if (SPEND.test(text)) return 'spend'+ if (NETWORK.test(text)) return 'network'return 'write'}diff --git a/plugins/ruflo-console/hooks/version.ts b/plugins/ruflo-console/hooks/version.tsindex 1afc8e79d8..28e42e1172 100644--- a/plugins/ruflo-console/hooks/version.ts+++ b/plugins/ruflo-console/hooks/version.ts@@ -2,4 +2,4 @@* The console's version, shown on the header so a person can tell which build is running. Kept equal to the plugin's manifest* (`.claude-plugin/plugin.json`); tests/version.spec.ts fails if the two drift.*/-export const CONSOLE_VERSION = '0.33.2'+export const CONSOLE_VERSION = '0.33.3'diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.shindex 19f0c09c3b..9a99a8142b 100755--- a/plugins/ruflo-console/scripts/smoke.sh+++ b/plugins/ruflo-console/scripts/smoke.sh@@ -11,9 +11,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 ruflo-console 0.33.2"+step "1. plugin.json declares ruflo-console 0.33.3"grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \- && grep -q '"version": "0.33.2"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"+ && grep -q '"version": "0.33.3"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"step "2. hooks.json names exactly one module and no classic hook commands"grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \diff --git a/plugins/ruflo-console/tests/threat-model.spec.ts b/plugins/ruflo-console/tests/threat-model.spec.tsnew file mode 100644index 0000000000..6f9270b3f3--- /dev/null+++ b/plugins/ruflo-console/tests/threat-model.spec.ts@@ -0,0 +1,248 @@+/**+ * ADR-450, the mod system's threat model: the attempts that were run against the console, kept as regressions.+ * npx vitest run plugins/ruflo-console/tests/threat-model.spec.ts+ * Every case here failed (or measured a gap) before the matching fix; the ones that held are kept so they keep holding.+ */+import { describe, expect, it } from 'vitest'++import type { ReaderFs } from '../hooks/data/files'+import { parseAgentdbMod } from '../hooks/data/agentdb-mod'+import { parseModStatus, readMods } from '../hooks/data/mods'+import { plain } from '../hooks/data/parse'+import { roomFeed } from '../hooks/data/room'+import { allows, classOf, type ActionClass } from '../hooks/model-tools'+import { paletteEntries } from '../hooks/palette'+import { newState } from '../hooks/state'++const make = (label: string, note?: string, args: string[] = []) => ({ label, args, expect: '', ...(note !== undefined && { note }) })+const RANK: Record<ActionClass, number> = { read: 0, write: 1, network: 2, spend: 3, delete: 3 }++describe('T1 classOf: words that name what an action does', () => {+ const corpus: [ActionClass, string, string?][] = [+ ['delete', 'erase the memory namespace'], ['delete', 'unlink the lock files'], ['delete', 'truncate the log'], ['delete', 'revoke the claim'],+ ['delete', 'discard the session'], ['delete', 'flush the store'], ['delete', 'evict entries'], ['delete', 'unregister the agent'], ['delete', 'nuke the swarm'],+ ['delete', 'abort the run'], ['delete', 'deleting old sessions'], ['delete', 'removal of the key'], ['delete', 'deletes the file'], ['delete', 'rm -rf the cache'],+ ['delete', 'run the command in a ruflo terminal', 'RUNS A SHELL COMMAND in this project, as you'], ['delete', 'evolve', 'runs your tests in a sandbox'],+ ['network', 'send a message to the peer'], ['network', 'curl the endpoint'], ['network', 'sync with the relay'], ['network', 'broadcast to the hive'],+ ['network', 'edge status', 'reaches the edge-net genesis node'], ['network', 'open https://example.test'], ['network', 'invite a peer'], ['network', 'post to slack'],+ ['spend', 'workers dispatch', 'MAY COST MONEY: the worker may call models'], ['spend', 'list sessions', 'calls the Anthropic API with your key'],+ ['spend', 'ask openrouter'], ['spend', 'judge', 'uses a real model judge'],+ ]++ it('puts every case at or above the class it needs (measured: 52 of 60 earlier probes were under-classified)', () => {+ const under = corpus.filter(([want, label, note]) => RANK[classOf(make(label, note))] < RANK[want])++ expect(under).toEqual([])+ })++ it('a note that says what an action does NOT do still does not count', () => {+ expect(classOf(make('create the mission', 'spends nothing; no model turn; not billed'))).toBe('write')+ expect(classOf(make('save', 'does not delete anything'))).toBe('delete') // fails safe: the negation is not trusted for delete words+ })++ it('typed text cannot cancel a note: a payload ending in "not" or "no" in front of the note\'s "model turn"', () => {+ for (const text of ['do the thing but not', 'please, without', 'refactor, no', 'x spends no']) {+ expect(classOf(make('run', 'A model turn', ['mission', text])), text).toBe('spend')+ }+ })++ it('typed text cannot shred a note either: a one-letter payload leaves every fixed entry in its class', () => {+ const term = classOf(paletteSpec('dt-term-exec'))++ expect(term).toBe('delete')+ for (const text of ['e', 'a', 'sh', 'ell', 'bill']) {+ expect(classOf({ ...paletteSpec('dt-term-exec'), args: [...paletteSpec('dt-term-exec').args, text] }), text).toBe('delete')+ expect(classOf(make('hand task', 'Starts a Claude Code turn (billed)', ['x', text])), text).toBe('spend')+ }+ })++ it('typed text can only add words: "delete" in a payload over-classifies, which fails safe', () => {+ expect(classOf(make('store note', undefined, ['--value', 'delete everything']))).toBe('delete')+ })++ it('on the real palette: nothing that says it reaches out, costs money or runs a shell is a plain write', () => {+ const state = newState({})+ const bad: string[] = []+ const seen = new Set<string>()++ for (const entry of paletteEntries(state, Date.now())) {+ const spec = entry.run.kind === 'spec' ? entry.run.spec : entry.run.kind === 'text' ? entry.run.make('probe text') : null++ if (spec === null || spec === undefined || spec.isReadOnly === true) continue++ const kind = classOf(spec)+ const note = `${spec.note ?? ''}`.toLowerCase()++ seen.add(entry.id)+ if (/\bcosts? money|may cost|billed cloud|shell command/.test(note) && !allows('full', kind)) bad.push(`${entry.id}:${kind}`)+ if (/shell command/.test(note) && kind !== 'delete') bad.push(`${entry.id}:shell:${kind}`)+ if (/\breaches\b/.test(note) && kind === 'write') bad.push(`${entry.id}:reaches:${kind}`)+ if (/may cost money|may call models|costs money/.test(note) && kind !== 'spend') bad.push(`${entry.id}:money:${kind}`)+ }++ expect(seen.has('dt-term-exec')).toBe(true)+ expect(classOf(paletteSpec('dt-term-exec'))).toBe('delete')+ expect(bad).toEqual([])+ })+})++/** The spec a palette entry builds for `probe text`. */+function paletteSpec(id: string) {+ const entry = paletteEntries(newState({}), Date.now()).find(candidate => candidate.id === id)++ if (entry === undefined) throw new Error(`no entry ${id}`)++ const spec = entry.run.kind === 'spec' ? entry.run.spec : entry.run.kind === 'text' ? entry.run.make('git status') : null++ if (spec === null || spec === undefined) throw new Error(`no spec for ${id}`)++ return spec+}++describe('T4 console_run text and console_set values reach a command', () => {+ it('lands in exactly one argv element for every text entry: no shell, no splitting into flags', () => {+ const state = newState({})+ const payloads = ['--evil-flag value', '$(touch pwn) `id` ; reboot | cat &', '", "x": "y', '-p {"a":1}', 'a\nb\0c']+ let cases = 0++ for (const entry of paletteEntries(state, Date.now())) {+ if (entry.run.kind !== 'text') continue++ for (const payload of payloads) {+ const spec = entry.run.make(payload)++ if (spec === null || spec === undefined) continue++ cases += 1+ const args = [...(spec.argv ?? []), ...spec.args]++ expect(args.some(arg => arg === '--evil-flag' || arg === '$(touch'), `${entry.id} split ${payload}`).toBe(false)+ expect(args.filter(arg => arg.includes('reboot')).length <= 2, `${entry.id} copied ${payload} more than twice`).toBe(true)+ }+ }++ expect(cases).toBeGreaterThan(50)+ })+})++describe('T3 text that reaches the screen', () => {+ const hostile = [+ '\u001b[31mred\u001b[0m', '\u001b]8;;https://evil.test\u0007click\u001b]8;;\u0007', '\u001b]8;;https://evil.test\u001b\\click\u001b]8;;\u001b\\', '\u009d0;title\u0007x',+ 'aevil', 'ab', 'zerowidth', 'softhyphen', 'tag\u{e0041}\u{e0042}chars', 'vs︀︁', 'a\u0000b\u0007c\u001bd', '\u009b31mx', 'line sep ',+ ]+ // eslint-disable-next-line no-control-regex+ const FORBIDDEN = /[\u0000-\u001f\u007f-\u009f----]|[\u{e0000}-\u{e0fff}]/u++ it('plain() leaves no escape, control, bidi, hidden or tag character, and no OSC payload', () => {+ for (const text of hostile) {+ const out = plain(text, 200)++ expect(FORBIDDEN.test(out), JSON.stringify(text)).toBe(false)+ expect(out, JSON.stringify(text)).not.toMatch(/\]8;;|0;title|\[31m|\[0m/)+ }++ expect(plain('a'.repeat(100_000), 40).length).toBe(40)+ expect(plain('\u001b]8;;'.repeat(50_000), 40).length).toBeLessThanOrEqual(40)+ })++ it('plain() on a megabyte of hostile text finishes quickly (no catastrophic pattern)', () => {+ const started = Date.now()++ plain(hostile.join('').repeat(40_000), 200)+ plain('\u001b]' + 'x'.repeat(1_000_000), 200)+ plain('\u001b[' + ';'.repeat(1_000_000), 200)+ expect(Date.now() - started).toBeLessThan(2_000)+ })++ it('the Room feed draws events, Claude calls and what was said through it', () => {+ const [text] = hostile+ const feed = roomFeed({+ events: [{ atMs: 1, kind: 'claims', text: `${hostile[1]} ${'x'.repeat(5_000)}` }],+ log: [{ atMs: 2, tool: 'console_run', summary: hostile[0] ?? '', outcome: 'ok', detail: hostile[4] ?? '' }],+ said: [{ atMs: 3, id: 'room-say-task' as never, text: text ?? '', label: hostile[2] ?? null }],+ pending: null,+ outcome: null,+ source: 'all',+ query: '',+ untilMs: null,+ })++ expect(feed.length).toBeGreaterThanOrEqual(3)++ for (const item of feed) {+ expect(FORBIDDEN.test(`${item.who}${item.text}`), item.id).toBe(false)+ expect(item.text.length).toBeLessThanOrEqual(240)+ }+ })++ it('what the agentdb mod wrote (a snippet, a source, a tool) is cleaned when it is read', () => {+ const file = JSON.stringify({ version: 1, recall: true, guard: true, source: `${hostile[1]}src`, lastTool: hostile[0], recent: [{ source: hostile[4], score: 1e999, snippet: `${hostile[1]} ${hostile[3]} ${hostile[8]}` }] })+ const mod = parseAgentdbMod(file)++ expect(mod).not.toBeNull()++ const shown = JSON.stringify([mod?.source, mod?.tool, ...(mod?.recent ?? []).flatMap(item => [item.source, item.snippet])])++ expect(FORBIDDEN.test(JSON.parse(shown).join(''))).toBe(false)+ expect(shown).not.toMatch(/\]8;;|0;title|\[31m/)+ expect(mod?.recent[0]?.score).toBeNull()+ })+})++describe('T2 a hostile .claude-flow/*-mod/status.json', () => {+ const polluted = [+ '{"version":1,"__proto__":{"polluted":"yes"},"constructor":{"prototype":{"polluted":"yes"}},"calls":3}',+ '{"__proto__":{"version":1},"calls":3}',+ '{"version":1,"calls":1e999,"blocked":-5,"updatedMs":"9","startedMs":[1],"guard":"yes"}',+ '{"version":"1","calls":3}', '{"version":1.0000001,"calls":3}', '[]', '1', 'null', '"x"', '{"version":1,"calls":{"__proto__":1}}',+ `{"version":1,"calls":${'9'.repeat(400)},"blocked":${'9'.repeat(400)}}`,+ '{"a":'.repeat(3_000) + '1' + '}'.repeat(3_000),+ '[' .repeat(3_000) + ']'.repeat(3_000),+ '{"version":1,"name":"\u001b]8;;https://evil.test\u0007x","calls":2}',+ ]++ it('never throws, never pollutes Object.prototype, and only a version-1 object yields a row of plain numbers', () => {+ for (const text of polluted) {+ const row = parseModStatus('evil-mod', text)++ expect(({} as Record<string, unknown>).polluted, text.slice(0, 40)).toBeUndefined()+ expect((Object.prototype as Record<string, unknown>).version).toBeUndefined()++ if (row !== null) {+ expect(row.name).toBe('evil')+ for (const value of [row.calls, row.updatedMs, row.startedMs]) expect(value === null || (Number.isFinite(value) && value >= 0)).toBe(true)+ expect(Number.isFinite(row.blocked) && row.blocked >= 0).toBe(true)+ }+ }+ })++ it('the folder scan refuses odd names, caps files and bytes, and one bad file hides no other', async () => {+ const files: Record<string, string> = {+ 'good-mod': '{"version":1,"calls":4,"blocked":1,"guard":true,"updatedMs":5}',+ 'big-mod': `{"version":1,"pad":"${'x'.repeat(9_000)}"}`,+ 'bad-mod': '{not json',+ }+ const names = [...Object.keys(files), '../escape-mod', 'UPPER-mod', 'a b-mod', '-lead-mod', `${'long'.repeat(20)}-mod`, 'plain-dir', '__proto__-mod']+ const reads: string[] = []+ const fs: ReaderFs = {+ list: async () => names.map(name => ({ name, kind: 'directory' })),+ stat: async path => {+ const text = files[path.split('/').at(-2) ?? '']++ if (text === undefined) throw new Error('ENOENT')++ return { mtimeMs: 1, size: text.length }+ },+ read: async path => {+ reads.push(path)++ return files[path.split('/').at(-2) ?? ''] ?? ''+ },+ }+ const facts = await readMods(fs, new Map(), '/proj')++ expect(facts.rows.map(row => row.name)).toEqual(['good'])+ expect(facts.refused).toBe(2)+ expect(reads.every(path => /^\/proj\/\.claude-flow\/(good|big|bad)-mod\/status\.json$/.test(path)), reads.join()).toBe(true)+ })+})diff --git a/v3/docs/adr/ADR-450-mod-system-threat-model.md b/v3/docs/adr/ADR-450-mod-system-threat-model.mdnew file mode 100644index 0000000000..ef6c8fff42--- /dev/null+++ b/v3/docs/adr/ADR-450-mod-system-threat-model.md@@ -0,0 +1,216 @@+# ADR 450: Threat model of the mod system (console control, guards, recall, status files)++Status: Proposed++> **Integration note (loop, 2026-10-05).** The worker's commit also changed `ruflo-agentdb/hooks/screen.ts` (wider hidden set + NFKC fold, T3/T5) and `guard.ts` (scan keys, T7) with `ruflo-agentdb/tests/threat.test.ts`. Those files were rebased onto the canonical shared screen (#3711/#3715/guard-hardening) and are **not** in this change; where the ADR says an agentdb fix exists, read it as 'pending in the follow-up'. The guard-hardening branch's shared `textsOf` already scans keys and the soft-hyphen/bidi-isolate/Mongolian set. This change ships the console fixes (T1 truthful classes incl. `dt-term-exec` -> `full`, T3 whole-sequence ANSI/OSC stripping and the wider hidden set in `plain()`, sanitised agentdb status text) and the model-tool spec `threat-model.spec.ts`.++Date: 2026 10 05++Builds on: ADR-404 (ruflo as a mod, trust gate), ADR-444 (Claude controls the console), ADR-445 (AgentDB as a mod), ADR-446 (39 plugin mods), ADR-447, ADR-448 (the Room)++## 1. Why++Mods run with Claude Code's own access. ADR-444 then let the model itself drive the console (`console_state | console_open | console_set | console_run`) and, with `modelConfirm: auto`, confirm its own actions. Text from files, peers, memory and the model flows into prompts and onto the screen. This ADR lists what can be attacked, what stops each attack today (with the line that does it), what was actually attempted for this review, what was fixed, and what is left as a recommendation.++Method: every claim below that says "measured" or "held" was run as a test (`plugins/ruflo-console/tests/threat-model.spec.ts`, `plugins/ruflo-agentdb/tests/threat.test.ts`); each fix has a case that failed on the old code and passes on the new. A claim marked **unverified** was read from code, not run.++## 2. Assets++| Asset | Where |+|---|---|+| The person's files, shell and credentials (everything Claude Code can touch) | the host |+| The decision "Claude may act" (control level, confirm mode, per-turn cap) | `settings.ai.modelControl / modelConfirm`, `model-tools.ts:29` |+| Tighten-only verdicts and the secret screens | `ruflo-mods/hooks/guard/*`, the 39 `guard.ts` / `screen.ts` |+| Memory that is recalled into later prompts | AgentDB, `ruflo-agentdb/hooks/recall.ts` |+| The project's policy projection | `.claude-flow/policy/claude-code.json` |+| The person's identity on the federation and the shared brain | `x-publish`, `vec-brain-transfer`, `broadcast` palette entries |+| What the person believes the mods are doing | status files, the Mods section, the Room |++## 3. Actors++A. **Malicious repo content**: files, `.claude/settings.json`, `.claude-flow/*` committed to a repo the person opens.+B. **Poisoned memory**: text an earlier session, a peer or an import stored in AgentDB.+C. **Hostile peer**: a federation / x.ruv.io / Room message.+D. **Prompt-injected Claude**: the model, steered by A, B or C, calling console tools.+E. **Malicious or compromised plugin / mod**: a hooks module the person installed or the model wrote.+F. **Local unprivileged process** that can write under the project's `.claude-flow/`.++## 4. Trust boundaries++1. Model to console (`tool.call` for the four `console_*` tools): the model is untrusted; the level and the class of the action decide.+2. Disk to console (`readMods`, `readSnapshot`): every file is untrusted bytes.+3. Memory to prompt (`frame()` in `recall.ts`): retrieved text is data, framed as such.+4. Tool input to guard (`textsOf` + `scan`): the guard sees what the model sends to a tool.+5. Plugin to host (`plugin.register` trust gate): a mod runs with the host's access once admitted.+6. Console to screen and to the model (`plain()`, `stateJson`): text leaves through these two doors.++## 5. Threats++Status: **fixed** (this change), **held** (attempted, no break), **open** (recommendation). Class names are `read < write < network < spend = delete`; the level needed is `read, write, manage, full, full`.++### T1. classOf under-classification (required item 1)++- Attack: the model runs a palette entry whose label or note names a destructive, networked or billed action in words the classifier does not know, or types text that cancels a note.+- Mitigation before: `classOf`, an English denylist over label + argv + note (`model-tools.ts:49` old). Unknown words fall to `write`.+- Measured, old code: on 60 hand-written adversarial labels/notes (synonyms such as erase, unlink, truncate, revoke, flush, evict; inflections deleting/removal/deletes; network words curl, ssh, webhook, sync, post, broadcast; billed words openrouter, "may cost money", "calls the Anthropic API with your key") **52 were under-classified**. On the 288 real palette entries: readonly 128, write 105, network 40, delete 13, spend 2. Real misses: `dt-term-exec` ("RUNS A SHELL COMMAND in this project, as you") was a plain **write**: at level `write` with `auto`, Claude could run any shell command through the console, outside Claude Code's permission prompts. `vec-workers-dispatch` ("MAY COST MONEY") was `network`, not `spend`. `dt-ma-list` ("calls the Anthropic API with your key") and every "reaches pi.ruv.io / the edge-net genesis node" entry were `write`.+- Measured, text attack: the argv carries the model's own `text`, and the note follows it. A text ending in "not", "no" or "without" turns the note "A model turn" into "not A model turn", which the negation filter strips: **spend read as write** for `do the thing but not`, `please, without`, `refactor, no`.+- Fix: stems instead of whole words (`delet`, `remov`, `eras`, `unlink`, `truncat`, `revok`, `flush`, `evict`, `unregister`, `nuke`, `abort`), shell/exec phrases to `delete`, `reaches|curl|https:|ssh|webhook|slack|ipfs|relay|peer|broadcast|send|sync` to `network`, `may cost|may call models|api key|openrouter|real model` to `spend`; and the negation filter now runs on the console's own prose (`note`, `shows`) only; the label and the argv, which carry typed text, are read as they are, so typed text can add words but never cancel one. (A first version cut the typed text out of the haystack instead. A review showed that a one-letter `text` such as `e` then shredded `RUNS A SHELL COMMAND` in the fixed note and dropped `dt-term-exec` back to `write`; that version was replaced before it was committed, and the `e` case is a regression test.) After: readonly 128, write 93, network 45, delete 17, spend 5 (288 entries); the 28-case corpus and the real-palette invariants pass.+- Residual: typed text can only raise a class: a payload with the word "delete" in it makes `store` need `full` (fails safe, noisy). A denylist is a floor. A new entry whose note uses none of the words is a `write`. Notes also say what they do NOT do, so a negated word still counts as present for delete words (fails safe, over-classifies). False positives that now need `full`: `perf-bottleneck` and `perf-optimize` ("writes and removes a 4 KB probe file"), `auto-daemon-start` and `auto-ap-enable` (their notes say how to stop them), so a `write`-level Claude can no longer start the daemon or enable autopilot.+- Recommended control: replace prose classification with a declared `class` on each `ActionSpec` (devtools already has `cost: 'writes' | ...`); keep `classOf` only as a lower bound (`max(declared, inferred)`) and fail a build test when a non-readonly spec has no declared class.+- Test: `threat-model.spec.ts` T1 (5 cases).++### T2. Hostile `.claude-flow/*-mod/status.json` (required item 2)++- Attack: F or A writes a huge, deeply nested, prototype-polluting, ANSI/bidi, version-spoofed status file.+- Mitigation: folder name must match `^[a-z0-9][a-z0-9-]{0,40}-mod$`, at most 60 folders, 8192 bytes per file (`data/mods.ts:5-11`), `version === 1` only, every field coerced to a finite non-negative integer or a boolean (`data/mods.ts:27-37`); no free text from the file is rendered, the mod name comes from the folder.+- Attempted: 14 payloads: `__proto__` / `constructor.prototype` keys, `{"__proto__":{"version":1}}`, 1e999, 400-digit numbers, negative and string numbers, 3000-deep object and array nesting, an OSC 8 string in a field, non-object roots; plus a folder scan with `../escape-mod`, upper case, spaces, a 123-character name, `__proto__-mod`, an oversize file and a corrupt file.+- Result: **held**. No throw, `Object.prototype` untouched, rows hold only finite numbers, odd names never read, one bad file hides no other (refused counted).+- Residual: (a) the numbers and the `guard: true` flag are unauthenticated: F can make the console show "guard on" for a mod whose guard is off (T11). (b) A symlink or FIFO named `status.json` is stat'd and read through the engine's `fs.read`; whether it follows links or blocks on a FIFO is engine behaviour. **Unverified.**+- Recommended control: `lstat` and refuse non-regular files if the host exposes it; sign status files (T11).+- Test: `threat-model.spec.ts` T2 (2 cases).++### T3. Attacker text on screen: ANSI, OSC 8, bidi, zero-width, long lines (required item 3)++- Attack: C, B or A put escape sequences, hyperlinks, bidi overrides or invisible characters in text the console draws (Room, events, results, agentdb snippets) or hands to the model (`console_state`).+- Mitigation: `plain()` (`data/parse.ts`) is the single door: Room (`data/room.ts:57-65`), `stateJson` (`model-tools.ts`), outcomes.+- Measured, old code: `plain` stripped CSI and C0/C1/bidi/200b-200f only. Left in: OSC payloads (`ESC ] 8 ; ; https://… BEL` lost its ESC and BEL but kept `]8;;https://…` as text), soft hyphen, U+2060-2064 invisible operators, U+FEFF, U+061C, variation selectors, Hangul fillers, Unicode tag characters (U+E0000-E0FFF, "ASCII smuggling"). And `parseAgentdbMod` put `snippet`, `source`, `lastTool` on screen **with no `plain()` at all**.+- Fix: OSC (BEL and ST terminated) and C1 CSI/OSC are removed whole; the hidden set above is replaced by a space; all as `\u` escapes (no raw invisible characters in the source). `parseAgentdbMod` now passes every free-text field through `plain()` and rejects a non-finite score.+- Attempted after: 13 hostile strings, 1 MB inputs with 50 000 unterminated OSC/CSI openers: no forbidden character survives, bounded length, under 2 s total (no catastrophic pattern).+- Residual: long lines are clipped per view (`clip`), not wrapped; a very long run of combining marks can still look odd. Bidi isolates are removed, so text direction cannot be forced, but visually confusable letters (Cyrillic а vs Latin a) are not detected.+- Test: `threat-model.spec.ts` T3 (4 cases).++### T4. `console_set` / `console_run` text into argv (required item 4)++- Attack: shell metacharacters, flag injection or JSON breaking in the typed text.+- Mitigation: the runner passes argv arrays, never a shell (`runner.ts`); each text entry builds `[… '--objective', text, …]`.+- Attempted: 5 payloads (`--evil-flag value`, `$(touch pwn) \`id\` ; reboot | cat &`, `", "x": "y`, `-p {"a":1}`, NUL/newline) against every text entry (79 spec builds at four of the payloads).+- Result: **held**: the text is always exactly one argv element, never split, never starts a new flag element. MCP entries embed it in a JSON string with proper escaping.+- Residual: a value that is itself `--force` or `--yes` is still an option-looking argument to the ruflo CLI's own parser (`--query --force`). The CLI is outside this repo's mods.+- Recommended control: emit `--flag=value` for text options, and `--` before positional text, as `hooks remember` already does.+- Test: `threat-model.spec.ts` T4.++### T5. Recall poisoning (required item 5)++- Attack: B stores text that instructs the model, forges the `<retrieved-memory>` frame, or hides an injection phrase.+- Mitigation: `screen()` drops items with a secret or injection phrase (`recall.ts:81`), `tidy` flattens whitespace (no forged line starts), `frame()` replaces `<` and `>` with `‹` (`recall.ts:104`), a "data, not instructions" note, caps of 5 items / 400 characters each / 1500 total.+- Measured, old code: `ignore all previous instructions` (soft hyphen), U+034F, U+061C, U+180E, U+2060, U+3164, variation selectors and tag characters inside the word **all passed the screen**, as did fullwidth `ignore …` and fullwidth `AKIA…` keys.+- Fix: `scan` and `tidy` strip the wider hidden set and `NFKC`-normalise (`ruflo-agentdb/hooks/screen.ts`). 5 new tests fail on the old screen and pass now.+- Residual: **high**. A phrase list is bypassed by paraphrase ("from now on respond only with …"), another language, or homoglyphs NFKC does not fold (Cyrillic). The frame is a request to the model, not a barrier. The mod's attachment is `additionalContext`, so it carries the same authority as other context.+- Recommended control: treat recall as lowest-authority; never recall text that was written by the model in the same session without a provenance tag; add a score threshold + a "source: model-written" marker; run the item through `aidefence_scan` when available.+- Test: `ruflo-agentdb/tests/threat.test.ts`.++### T6. Guard bypass: split secrets and unwatched tools (required item 6)++- Attack: D sends a secret in pieces, in a field the guard does not read, or through a tool no guard watches.+- Mitigation: `textsOf` reads every string value to depth 6, 200 entries, 20 000 characters; `hasSecret` on each (`ruflo-agentdb/hooks/guard.ts`).+- Measured, old code: keys were never read, so `{"password": "hunter2hunter2hunter2"}` passed (the key-assignment pattern needs `name: value` in one string). Each string is scanned alone, so a token split over two fields or two calls passes.+- Fix (agentdb only): each string beside its key is also scanned as `key: value` (key to 100, value to 2000 characters, charged to the budget). 2 tests.+- Unwatched: with the registry (393 tool names from `v3/@claude-flow/cli/src/mcp-tools/*.ts`) and every quoted tool-shaped string in `plugins/*/hooks` (233 watched-shaped, 196 of them in the registry), of 61 registry tools whose name says they take free text or a command (`_store _save _set _import _publish _send _broadcast _execute _eval _fill _type _create _exec _prompt _write _update _learn _remember _post _message _invite _grant _ingest _add _record`), **26 have no guard naming them**: `agent_execute agent_update agenticow_ingest browser_fill browser_session_record browser_type config_import daa_workflow_execute hooks_intelligence_learn hooks_post-command hooks_post-edit hooks_post-task intelligence_learn memory_import metaharness_learn policy_budget_set session_import swarm_pheromone_update transfer_store-download transfer_store-featured transfer_store-info transfer_store-search transfer_store-trending wasm_gallery_add_custom wasm_gallery_import x_federation_invite_mint`. The worst: `browser_fill` / `browser_type` (type a secret into a web form: exfiltration), `x_federation_invite_mint` (mints a credential), `agent_execute` (a free-form task for an agent), `config_import`, `session_import`, `memory_import` (bulk write that skips the store guards). The count is an upper bound on coverage: a name appearing in a guard file counts as watched.+- Residual: **medium**; the guards are stateless, so split-across-calls cannot be caught per call.+- Recommended control: one shared `textsOf`/`screen` (today 37 plugin files define their own `textsOf`, so a fix must be repeated); have `check-guard-tool-names.mjs` print the unwatched secret-bearing list and fail on a shrinking allowlist; add `browser_fill`, `browser_type`, `x_federation_invite_mint`, `config_import`, `memory_import`, `session_import` to the first guards; a bounded per-session window of the last N written strings for split secrets.+- Test: `ruflo-agentdb/tests/threat.test.ts`; the list above is reproduced by the 20-line script in section 8.++### T7. Cross-mod injection (required item 7)++- Attack: one mod's status/command output reaches another mod's prompt context or the model.+- Mitigation: the model reads the console through `stateJson`: every line goes through `plain(…,160)`, the screen is capped at 3500 characters, and the reply states that screen text is data. Status files carry no free text onto a page except the agentdb mod's `recent` items, now cleaned (T3). A mod's `/…-mod` command answers without the model.+- Result: **held** for the console path; **open** for any mod that forwards another mod's output as `additionalContext`: none found, but nothing forbids it.+- Residual: low; recall is the only mod that attaches text to prompts.+- Recommended control: a conformance test that no `additionalContext` source reads `.claude-flow/*-mod/` files.++### T8. Autopilot default: the worst action at `write` / `manage` with `confirm=auto` (required item 8)++- Setup: `modelControl` defaults to `off` (`settings.ts:49`); `modelConfirm` defaults to `auto` (`settings.ts:286`), so raising the level also removes the person's Yes. Cap: 40 calls per turn, reset at every `turn.start` (`register.ts:343`).+- At `write` (after T1): file and store writes: `auto-cfg-set` (rewrites `.claude-flow/config.json`), `auto-ses-save`, `task` / `mission` / `auto-task-new` (text that later agents act on), `store`, `mem-pattern-store`, `nn-pattern-store`, `vec-hooks-remember` (plant memory that is recalled in later sessions: T15), `daemon`, `init`, worker dispatch, `mem-export` (overwrites `.claude-flow/memory-export.json`). No shell, no network, no billed model (these now need more).+- At `manage`: everything networked: `x-publish` and `x-bbs-publish` (publish text as the person's own key), `vec-brain-transfer` / `sync-push` (publish to pi.ruv.io under the person's identity), `broadcast`, `federation-join`, `marketplace` and `plugin-install` (install code that runs with Claude Code's access), `dt-update-all` (download and write `node_modules`). **This is the worst reachable level in practice: read a secret with any file tool, then publish it with `x-publish`.** Nothing in the console reads the published text for secrets.+- Is the per-turn cap enough? No. It bounds one turn; a `/loop` or any long task gets 40 per turn without limit, and the cap says nothing about class (40 `x-publish` calls fit).+- Recommended control: (1) `auto` must not apply to `network` and above: those always ask, whatever `modelConfirm` says; (2) run the `text` of every publishing/broadcast entry through the secret screen (`aidefence_has_pii` / the 9 patterns) and refuse; (3) a session-total budget of non-read actions per class (for example 5 network, 0 spend without ask); (4) `plugin-install`, `marketplace`, anything that writes settings or hooks becomes `full`; (5) default `modelConfirm` to `ask`.+- Test: not added (needs a product decision); T1 now makes the classes truthful, which is what any of these controls rests on.++### T9. Malicious or compromised plugin or mod++- Attack: E ships a mod with `process.run`, `http.fetch`, `fs.write` or a `tool.call` hook.+- Mitigation: the trust gate names the risky calls and events and, only when the person opts in (`refuse-risky`), refuses them (`ruflo-mods/hooks/trust.ts:1-40`). It reads the host's scan, not the module's claims.+- Residual: **high by design**. It cannot judge modules admitted before it, nor prepend/append/builtin modules; the default is observe, not refuse. A mod the model writes mid-session is exactly the case the gate exists for, and it is off unless chosen.+- Recommended control: default `refuse-risky` for user-tier modules written during a session; list admitted-before-gate modules in the Mods section.++### T10. Policy projection file written by A or F++- Attack: a committed `.claude-flow/policy/claude-code.json` with `mode: "legacy"` or an empty rules list.+- Mitigation: the file can only tighten (`stricter`, `guard/index.ts:44-86`); the engine's own verdict always stands; a bad file fails closed by one step (`.catch`, `guard/index.ts:78`).+- Result: it cannot loosen the engine. It can switch ruflo's own added rules off (legacy / observe), and A controls it. **Residual: medium**: the person believes the policy is enforcing.+- Recommended control: read the projection only from user scope, or require a signature from `ruflo-config-signing-key`; show mode in the band when it is not `enforce`.++### T11. Status-file spoof++- Attack: F writes `{"version":1,"guard":true,"blocked":0,"updatedMs":<now>}` for a mod that is not running.+- Mitigation: none; staleness (6 h) is the only check. Residual: **low-medium**: false assurance, no escalation.+- Recommended control: the mod writes a per-session nonce into the file and into its in-memory state; the console shows "unverified" for a file whose nonce the session never saw.++### T12. Environment override raises control++- Attack: A commits `.claude/settings.json` with `env: {"RUFLO_CONSOLE_CONTROL": "full:auto"}`.+- Mechanism: `register.ts:212` reads `$.env.get('RUFLO_CONSOLE_CONTROL')` and uses it in place of the saved setting. Whether Claude Code puts project-settings `env` into what `$.env` returns is engine behaviour. **Unverified; if it does, a repository can turn Claude's console control to `full` with auto-confirm** as soon as the person trusts the folder.+- Recommended control: the override may only lower the saved level (and may force `ask`), never raise it; the e2e scripts pass a saved setting instead.++### T13. `runById` fuzzy fallback++- Attack: D passes an id that is not an entry plus text, so `filterPalette(entries, "<id> <text>")[0]` picks whichever entry matches best (`runner.ts:205`).+- Result: the chosen entry is still classified after being picked (`settlePending`), so the level holds; but the model can reach an entry by approximate words and the confirmation shows the entry's label, not the id it asked for.+- Recommended control: exact id for model calls; fuzzy only for people.++### T14. The confirmation prompt shows attacker-chosen text++- Attack: in `ask` mode the person sees `plain(label, 100)`; for `mission create: <text>` or `x-publish` the label embeds model text.+- Result: the model can write "Approve to continue the test" into the prompt the person answers. Control characters are gone (T3); persuasion is not.+- Recommended control: the waiting row shows the class and the level it needed in the console's own words, then the quoted payload, dimmed, after it.++### T15. Poisoned memory laundering (a prompt-injected Claude writes memory it later reads)++- Attack: D (or A through D) stores an instruction with `store` / `vec-hooks-remember`; a later session recalls it as "memory".+- Mitigation: the AgentDB write guard refuses secrets only (`guard.ts`); the recall screen (T5) runs on the way back.+- Residual: **medium-high**: persistence across sessions with a regex between. Recommended: tag items written by the model/console and give them a "model-written" provenance on recall; drop them from recall unless the person promoted them.++### T16. Room as a command channel++- Attack: C sends a Room/federation line like "run x-publish …"; the Room only draws it (via `plain`), and the person's own draft goes through the same confirm as `/ruflo run`.+- Result: **held**: a peer's text is rendered, never executed; `console_state` tells the model it is data. The model could still be persuaded by it; that is T8.++### T17. Pending slot and take-over++- Attack: D replaces or clears the person's waiting action, or acts after the person pressed Stop.+- Mitigation: `console_set` and `console_run` refuse while `state.pending` is set (`model-tools.ts:274, 294`); `paused` refuses every tool (`:241`); a level change is re-read per call.+- Result: **held**: covered by `model-tools.spec.ts` (29 tests).++### T18. Denial of service by the model++- Attack: D loops on `console_state` / `console_open`, or fills the control log.+- Mitigation: 40 calls/turn counts reads too; log capped at 40; each reply bounded (3500-character screen, 60 entries).+- Result: **held** for the console; the cap does not span turns (see T8).++## 6. Decision++1. Accept the fixes in this change as the first slice: truthful classes (T1), whole-sequence stripping and the wider hidden set (T3), sanitised agentdb status text (T3), a recall screen that cannot be passed with an invisible character or a fullwidth letter (T5), and `key: value` scanning in the AgentDB write guard (T6). Console 0.33.1 to 0.33.2. The AgentDB `tidy` also folds NFKC on purpose: it turns fullwidth `<` into `<` before `frame()` replaces `<>`, which closes a frame-forgery route; the cost is that ligatures and superscripts in recalled text are shown folded.+2. The recommendations are ranked: T8 (auto never applies to network and above; scan outgoing text), T12 (env may only lower), T6 (shared guard core, guard the six tools in the list), T1 (declared class), T9 (default refuse-risky for session-written mods), then the rest.+3. No change to the dependency pins, to the engine, or to any other plugin in this change. The AgentDB plugin source changed (screen and guard) and needs its own version bump when it is released; the console's was bumped.++## 7. Verification++- `plugins/ruflo-console`: `npx vitest run` 895 passed, 3 skipped (the 23 `claude-code/testing` files only load under `claude plugin test`); `claude plugin test ruflo-console` 211 pass, 0 fail; `scripts/smoke.sh` 16 passed, 0 failed; `claude plugin validate` passed.+- `plugins/ruflo-agentdb`: `claude plugin test` 31 pass, 0 fail (5 of them new and failing on the old sources); `scripts/smoke.sh` 19 passed, 0 failed.+- New regression tests: `threat-model.spec.ts` 12 cases (6 fail on the old sources: the corpus, the text attack, JSON-escaped copies, the real-palette invariants, `plain`, the agentdb status text).+- Driven through the model's own tools (`console-drive.sh`, level `write`), twice, with `text` "echo hello" and with the one-letter `text` "e" (the shredding attempt): both answered `Refused: "run the command in a ruflo terminal" is a delete action and control is set to "write" (it needs "full"). … Nothing ran.` Before this change the same entry classed as `write` and, with `auto`, would have run.++## 8. Reproducing the unwatched-tool list++```js+// node --input-type=module, from the repo root+import { readFileSync, readdirSync, existsSync } from 'node:fs'+import { join } from 'node:path'+import { extractCandidates, extractRegistryNames } from './scripts/check-guard-tool-names.mjs'+const reg = new Set(), watched = new Set()+for (const f of readdirSync('v3/@claude-flow/cli/src/mcp-tools')) if (f.endsWith('.ts')) for (const n of extractRegistryNames(readFileSync(join('v3/@claude-flow/cli/src/mcp-tools', f), 'utf8'))) reg.add(n)+for (const p of readdirSync('plugins')) { const h = join('plugins', p, 'hooks'); if (!existsSync(h)) continue; for (const f of readdirSync(h, { recursive: true })) if (String(f).endsWith('.ts')) for (const n of extractCandidates(readFileSync(join(h, String(f)), 'utf8'))) watched.add(n) }+const bearing = [...reg].filter(n => /(_store|_save|_set|_import|_publish|_send|_broadcast|_execute|_eval|_fill|_type|_create|_exec$|_prompt|_tool$|_write|_update|_learn|_remember|_post|_message|_invite|_grant|_ingest|_add|_record)/.test(n))+console.log(bearing.filter(n => !watched.has(n)).sort().join(' '))+```