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

security(ruflo-console): auto-confirm never answers network/spend/delete, secret screen on text Claude passes, env override can only lower control (0.33.4; ADR-450 T8, T12)

ruv6b3eefed57cd
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.json
index 3b9ec8722a..b5fd70a74a 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.3",
+ "version": "0.33.4",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-console/hooks/help-topics-more.ts b/plugins/ruflo-console/hooks/help-topics-more.ts
index 3daecf84bd..0700579bc4 100644
--- a/plugins/ruflo-console/hooks/help-topics-more.ts
+++ b/plugins/ruflo-console/hooks/help-topics-more.ts
@@ -56,7 +56,8 @@ export const MORE_TOPICS: readonly HelpTopic[] = [
{ text: 'Choose how far in Settings → Claude control: read (look and open pages), write (also fill fields and run local actions), manage (also network), full (also spend, deploy, delete). It is off until you turn it on.', go: { view: 'settings' }, label: 'Open Settings' },
{ text: 'Choose who says Yes in Settings → Claude control: confirm. auto (the default) lets Claude run unattended inside the level; ask leaves each action waiting for your Yes in the console.' },
{ text: 'With auto, Claude’s own call confirms an action, but only inside the level above: anything higher is still refused and nothing runs. Every auto action is logged on Overview.' },
- { text: 'The level is your real limit: write for local work, manage adds the network, full adds spend, deploy and delete. Use manage or full only when you are watching, or set confirm to ask, because a deploy or a delete then runs without a Yes.' },
+ { text: 'Whatever confirm says, an action that reaches the network, spends or deletes waits for your Yes, and text that looks like a secret is refused.' },
+ { text: 'The level is your real limit: write for local work, manage adds the network, full adds spend, deploy and delete. Network, spend and delete actions wait for your Yes at any level: raising it lets Claude propose them, not run them.' },
{ text: 'Start a new Claude Code session (or /reload-plugins). Claude now has four tools: console_state, console_open, console_set and console_run. Ask in words: "set up a mission to add a dark mode toggle".' },
{ text: 'Watch Overview → Claude control: the level, whether it asks or confirms itself, the count, and each action (done, waiting for you, refused). Take back control stops every tool at once; Give control back resumes.', go: { view: 'overview' }, label: 'Open Overview' },
],
diff --git a/plugins/ruflo-console/hooks/model-tools.ts b/plugins/ruflo-console/hooks/model-tools.ts
index 8324a8e6b2..28bb7936c4 100644
--- a/plugins/ruflo-console/hooks/model-tools.ts
+++ b/plugins/ruflo-console/hooks/model-tools.ts
@@ -14,6 +14,7 @@ import { PROFILES, RIGORS } from './goap'
import { mcOf, setResearch } from './mission-control'
import { RESEARCH_DEPTHS } from './mission-options'
import { filterPalette, paletteEntries } from './palette'
+import { hasSecret } from './screen'
import { settingsOf } from './settings'
import type { ControlEntry, Pending, State, ViewId } from './state'
import { VIEWS } from './state'
@@ -85,6 +86,19 @@ export function parseControlEnv(value: unknown): { level: ControlLevel; confirm:
return found === undefined || (confirm !== 'ask' && confirm !== 'auto') ? null : { level: found, confirm }
}
+/**
+ * The session override can only LOWER what the person saved, never raise it (ADR-450 T12): a project's settings `env` must not be able to hand
+ * Claude `full:auto`. The level is the lower of the two; the confirm is `ask` if either says ask.
+ */
+export function lowerOnly(saved: { level: ControlLevel; confirm: ControlConfirm }, forced: { level: ControlLevel; confirm: ControlConfirm } | null): { level: ControlLevel; confirm: ControlConfirm } {
+ if (forced === null) return saved
+
+ return { level: rank(forced.level) < rank(saved.level) ? forced.level : saved.level, confirm: forced.confirm === 'ask' || saved.confirm === 'ask' ? 'ask' : 'auto' }
+}
+
+/** Classes whose effect leaves the machine, costs money or cannot be undone: they always wait for the person, whatever `modelConfirm` says (ADR-450 T8). */
+export const ALWAYS_ASK: readonly ActionClass[] = ['network', 'spend', 'delete']
+
export type ModelToolDeps = { state: State; control: Controller }
/** How long Claude's call waits for an action that runs on its own. */
@@ -107,6 +121,11 @@ const say = (state: State, tool: string, summary: string, outcome: ControlEntry[
if (state.control.log.length > LOG_MAX) state.control.log.splice(0, state.control.log.length - LOG_MAX)
}
+const SECRET_REFUSAL = 'that text looks like a secret. It was not used and is not shown. Do not pass keys, tokens or passwords to the console.'
+
+/** True when the raw argument or its cleaned form holds a secret (the raw form too, so a token split by a hidden character is refused, not just defused). */
+const leaksSecret = (raw: unknown, cleaned: string): boolean => (typeof raw === 'string' && hasSecret(raw)) || hasSecret(cleaned)
+
const textOf = (value: unknown): string => (typeof value === 'string' ? plain(value, MAX_TEXT).trim() : '')
/** The console's state for the model: bounded, with control characters stripped. */
@@ -187,7 +206,7 @@ async function settlePending(deps: ModelToolDeps, tool: string, id: string, aske
return { status: 'refused', text: `"${plain(pending.label, 80)}" is a ${kind} action and control is set to "${level}" (it needs "${NEEDS[kind]}"). The person can raise it in Settings → Claude control. Nothing ran.` }
}
- if (confirmOf(ai.modelConfirm) === 'ask') {
+ if (confirmOf(ai.modelConfirm) === 'ask' || ALWAYS_ASK.includes(kind)) {
say(state, tool, id, 'waiting', pending.label)
return { status: 'waiting', text: `Waiting for the person to confirm in the console: "${plain(pending.label, 100)}" (${kind}). Expect: ${plain(pending.expect, 160)}. Do not repeat it; call console_state later to see the result.` }
@@ -267,6 +286,8 @@ export async function callTool(name: string, input: Record<string, unknown>, dep
const field = textOf(input.field)
const value = textOf(input.value)
+ if (leaksSecret(input.value, value)) return refuse(`set ${field}`, SECRET_REFUSAL)
+
if (state.pending !== null) return refuse(`set ${field}`, `an action is already waiting for the person ("${plain(state.pending.label, 80)}"). Do not change fields until they answer.`)
const askedAt = Date.now()
@@ -286,6 +307,8 @@ export async function callTool(name: string, input: Record<string, unknown>, dep
const id = textOf(input.id)
const text = textOf(input.text)
+ if (leaksSecret(input.text, text)) return refuse(`run ${id}`, SECRET_REFUSAL)
+
// The person's own waiting action is theirs to answer: never replaced, never cleared.
if (state.pending !== null) return refuse(`run ${id}`, `an action is already waiting for the person ("${plain(state.pending.label, 80)}"). Do not run another until they answer.`)
diff --git a/plugins/ruflo-console/hooks/register.ts b/plugins/ruflo-console/hooks/register.ts
index 0e0e591f0d..4390536466 100644
--- a/plugins/ruflo-console/hooks/register.ts
+++ b/plugins/ruflo-console/hooks/register.ts
@@ -13,7 +13,7 @@ import { BAR_KEY, barView } from './views/bar'
import { setBootChecks } from './boot-checks'
import { buildOf, isOurCheckout, setBuild } from './build'
import { runUpdateCheck } from './update-flow'
-import { announceModelTools, parseControlEnv, serveModelTools } from './model-tools'
+import { announceModelTools, confirmOf, levelOf, lowerOnly, parseControlEnv, serveModelTools } from './model-tools'
import { loadAiPrefs, settingsOf } from './settings'
import { contextSection, onPromptSubmit, onTurnComplete } from './mission-claude'
import { parseMode, RECHECK_EVERY_MS, UPDATES_KEY } from './updates'
@@ -206,12 +206,16 @@ export const register: Register = (on, raw: PluginOptions) => {
await control.refresh()
control.autoOpen()
- // Declare the console tools to the model when control is on: the saved setting, or this session's RUFLO_CONSOLE_CONTROL=<level>:<ask|auto>.
+ // Declare the console tools to the model when control is on: the saved setting, or this session's RUFLO_CONSOLE_CONTROL=<level>:<ask|auto>, which can only lower it.
await loadAiPrefs(state, bound).catch(() => undefined)
const forced = parseControlEnv(await (async () => $.env.get('RUFLO_CONSOLE_CONTROL'))().catch(() => undefined))
- if (forced !== null) Object.assign(settingsOf(state).ai, { modelControl: forced.level, modelConfirm: forced.confirm })
+ // The override may only lower what the person saved (ADR-450 T12): a project's settings env must not raise Claude's control.
+ const ai = settingsOf(state).ai
+ const effective = lowerOnly({ level: levelOf(ai.modelControl), confirm: confirmOf(ai.modelConfirm) }, forced)
+
+ Object.assign(ai, { modelControl: effective.level, modelConfirm: effective.confirm })
await announceModelTools(tool => $.tool.register(tool), state).catch(() => 0)
return next(e)
diff --git a/plugins/ruflo-console/hooks/screen.ts b/plugins/ruflo-console/hooks/screen.ts
new file mode 100644
index 0000000000..428d1ee272
--- /dev/null
+++ b/plugins/ruflo-console/hooks/screen.ts
@@ -0,0 +1,65 @@
+/**
+ * Secret screen for text Claude passes to the console (ADR-450 T8): a value it sets or the text of an entry it runs is checked here before it
+ * can reach a palette entry (a publish, a broadcast, a stored note). The region between the markers is a copy of the shared screen
+ * (origin: plugins/ruflo-agentdb/hooks/screen.ts), regenerated by `node scripts/sync-mod-screen.mjs`; a plugin cannot import another plugin.
+ * Findings are never echoed: the caller says only that the text looks like a secret.
+ */
+
+// BEGIN SHARED SCREEN (generated from plugins/ruflo-agentdb/hooks/screen.ts by scripts/sync-mod-screen.mjs; do not edit in a copy)
+export type Rules = readonly (readonly [string, RegExp])[]
+
+/** The secret shapes every mod screens for. A plugin adds its own after these, outside the markers. */
+export const COMMON_SECRETS: Rules = [
+ ['private key', /-----BEGIN [A-Z ]*PRIVATE KEY-----/],
+ ['aws access key', /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/],
+ ['github token', /\b(?:gh[pousr]_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{40,})\b/],
+ ['slack token', /\bxox[abprs]-[A-Za-z0-9-]{10,}/],
+ ['google api key', /\bAIza[0-9A-Za-z_-]{35}\b/],
+ ['anthropic or openai key', /\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{24,}/],
+ ['jwt', /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/],
+ ['bearer token', /\bBearer\s+[A-Za-z0-9._~+/=-]{24,}/],
+]
+
+export const INJECTION: Rules = [
+ ['override instructions', /\b(?:ignore|disregard|forget|override)\b[^.\n]{0,40}\b(?:previous|prior|above|earlier|all|any|system)\b[^.\n]{0,30}\b(?:instructions?|rules?|prompts?|guidelines?)\b/i],
+ ['role reassignment', /\byou are (?:now|no longer)\b|\bact as (?:an? )?(?:unrestricted|jailbroken)\b/i],
+ ['new instructions', /\b(?:new|updated|real) (?:system )?instructions?\s*:/i],
+ ['fake role tags', /<\/?\s*(?:system|assistant|developer|instructions?)\s*>|^\s*(?:system|assistant)\s*:/im],
+ ['concealment', /\bdo not (?:tell|inform|mention|reveal)[^.\n]{0,30}\b(?:user|human|operator)\b/i],
+ ['exfiltration', /\b(?:exfiltrate|send|post|upload)\b[^.\n]{0,50}\b(?:secrets?|credentials?|tokens?|api keys?|\.env)\b/i],
+ ['shell pipe', /\b(?:curl|wget)\b[^|\n]{0,200}\|\s*(?:sudo\s+)?(?:ba|z)?sh\b/i],
+]
+
+// C0/C1 controls (keeping tab and newline), DEL, zero-width and bidi override characters; built with escapes, never raw.
+const INVISIBLE = new RegExp('[\\u0000-\\u0008\\u000b-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2060-\\u2064\\ufeff]', 'g')
+
+/** Input capped at 20k characters with invisible characters removed, so none can hide a secret or a phrase. */
+export const bare = (text: string) => (text.length > 20_000 ? text.slice(0, 20_000) : text).replace(INVISIBLE, '')
+
+/** Names of the rules that match `text` (already `bare`d). */
+export const names = (rules: Rules, text: string) => rules.filter(([, re]) => re.test(text)).map(([name]) => name)
+
+export type Findings = { readonly secrets: readonly string[]; readonly injection: readonly string[] }
+
+/** Names of every secret shape in `secrets` and every injection phrase found in `text`. Cost is linear in the capped input. */
+export function screenWith(secrets: Rules, text: string): Findings {
+ const bounded = bare(text)
+ return { secrets: names(secrets, bounded), injection: names(INJECTION, bounded) }
+}
+
+export const hasSecretIn = (secrets: Rules, text: string) => names(secrets, bare(text)).length > 0
+
+/** Makes stored text safe to show: no control or bidi characters, whitespace collapsed, at most `max` characters. */
+export function tidy(text: string, max: number): string {
+ const flat = text.replace(INVISIBLE, '').replace(/\s+/g, ' ').trim()
+ return flat.length > max ? `${flat.slice(0, Math.max(0, max - 1))}…` : flat
+}
+// END SHARED SCREEN
+
+const SECRETS: Rules = [
+ ...COMMON_SECRETS,
+ ['key assignment', /\b(?:api[_-]?key|secret|token|passw(?:or)?d|credential)s?["']?\s*[:=]\s*["']?[A-Za-z0-9/+=_.-]{16,}/i],
+]
+
+/** True when `text` holds a secret shape (a token, a key, a private key, `password=...`). */
+export const hasSecret = (text: string): boolean => hasSecretIn(SECRETS, text)
diff --git a/plugins/ruflo-console/hooks/version.ts b/plugins/ruflo-console/hooks/version.ts
index 28e42e1172..de849e9983 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.3'
+export const CONSOLE_VERSION = '0.33.4'
diff --git a/plugins/ruflo-console/hooks/views/settings.ts b/plugins/ruflo-console/hooks/views/settings.ts
index 78770fae7b..03cbfd8eb7 100644
--- a/plugins/ruflo-console/hooks/views/settings.ts
+++ b/plugins/ruflo-console/hooks/views/settings.ts
@@ -161,7 +161,7 @@ function aiItems(ctx: Ctx): Item[] {
one('guidance', 'Mission guidance', 'after a mission goal is entered, claude -p writes detailed guidance by lifecycle stage and suggests ruflo capabilities to bring in (it asks first unless always accept)', ai.guidance ? 'on' : 'off', ['on', 'off'], !ai.guidance, value => ctx.act.settings.ai({ guidance: value === 'on' }), 'mission goal guidance advice suggestions'),
...LOOP_ROWS.map(row => one(row.id, row.title, row.description, row.current(ai), row.options, row.isChanged(ai), value => ctx.act.settings.ai(row.patch(value)), row.extra)),
one('model-control', 'Claude control', 'how far Claude may drive this console with its console_* tools: off, read (look and open pages), write (also fill fields and run local actions), manage (also network), full (also spend, deploy, delete); takes effect in a new session or /reload-plugins', ai.modelControl, ['off', 'read', 'write', 'manage', 'full'], ai.modelControl !== 'off', value => ctx.act.settings.ai({ modelControl: value as typeof ai.modelControl }), 'claude control drive computer use tools autonomy model'),
- one('model-confirm', 'Claude control: confirm', 'auto (the default) lets Claude’s call confirm itself, within the level above, so it runs unattended (every call is logged on Overview); ask leaves each action waiting for your Yes in the console', ai.modelConfirm, ['ask', 'auto'], ai.modelConfirm !== 'auto', value => ctx.act.settings.ai({ modelConfirm: value === 'auto' ? 'auto' : 'ask' }), 'claude control confirm auto ask approve'),
+ one('model-confirm', 'Claude control: confirm', 'auto (the default) lets Claude’s call confirm itself, within the level above, so it runs unattended (every call is logged on Overview), except an action that reaches the network, spends or deletes: that always waits for your Yes; ask leaves each action waiting for your Yes in the console', ai.modelConfirm, ['ask', 'auto'], ai.modelConfirm !== 'auto', value => ctx.act.settings.ai({ modelConfirm: value === 'auto' ? 'auto' : 'ask' }), 'claude control confirm auto ask approve'),
one('ctx-mission', 'Mission context in Claude’s prompt', 'the active mission and task ride in Claude’s system prompt, and change only when the task does (a changed prompt makes Claude re-read the chat)', ai.missionContext ? 'on' : 'off', ['on', 'off'], !ai.missionContext, value => ctx.act.settings.ai({ missionContext: value === 'on' }), 'mission context prompt cache claude'),
one('loop-gates', 'Mission gates', 'your own commands a mission may run to verify a task, one per line; each asks first and shows its exact argv; no shell characters', ai.loopGates, [], ai.loopGates !== '', value => ctx.act.settings.ai({ loopGates: value.slice(0, 800) }), 'gates verify tests smoke evidence'),
one('mission-cap', 'Mission spend cap (USD)', 'auto-run pauses when one mission’s spend reaches this (list-price estimate; empty means no cap)', ai.missionCapUsd, [], ai.missionCapUsd !== '', value => ctx.act.settings.ai({ missionCapUsd: /^\d{1,5}(\.\d{1,2})?$/.test(value.trim()) ? value.trim() : '' }), 'mission cap budget spend cost'),
diff --git a/plugins/ruflo-console/scripts/e2e-control.sh b/plugins/ruflo-console/scripts/e2e-control.sh
index a9d2e93097..81566dc7f2 100755
--- a/plugins/ruflo-console/scripts/e2e-control.sh
+++ b/plugins/ruflo-console/scripts/e2e-control.sh
@@ -7,7 +7,8 @@
# and exits 0, so CI can run it everywhere. Live, it copies ~/.claude/.credentials.json into an isolated CLAUDE_CONFIG_DIR (never the
# real ~/.claude) and shreds it on exit, as e2e.sh does. The project is a throwaway folder; nothing in the repo is written.
#
-# Runs, each a separate Claude session with RUFLO_CONSOLE_CONTROL set as shown:
+# Runs, each a separate Claude session whose SAVED control setting is the one shown (RUFLO_CONSOLE_CONTROL can only lower a saved level, so it
+# cannot turn control on; the script seeds the isolated config's plugin store instead):
# A (unset) control is off: the console's tools do not exist for the model
# B read it can read and open pages; filling a field is refused with the level it needs
# C write:auto it opens Missions, sets a goal (the console plans it) and runs mission-create: Claude's own call confirms it
@@ -42,7 +43,9 @@ TOOLS="mcp__ruflo-console__console_state,mcp__ruflo-console__console_open,mcp__r
# run NAME CONTROL PROMPT: one headless session; the transcript (stream-json) lands in $OUT/NAME.jsonl.
run() {
local name="$1" control="$2" prompt="$3"
- (cd "$PROJECT" && env ${control:+RUFLO_CONSOLE_CONTROL="$control"} CLAUDE_CONFIG_DIR="$CFG" timeout 240 "$CLAUDE" -p --model haiku --max-budget-usd 0.50 \
+ mkdir -p "$CFG/plugins/store"
+ node -e 'const [level, confirm] = (process.argv[1] || "off:auto").split(":"); require("node:fs").writeFileSync(process.argv[2], JSON.stringify({ "ai-prefs": { modelControl: level, modelConfirm: confirm || "auto" } }))' "$control" "$CFG/plugins/store/ruflo-console_inline-b43d4e31bb1a.json"
+ (cd "$PROJECT" && env CLAUDE_CONFIG_DIR="$CFG" timeout 240 "$CLAUDE" -p --model haiku --max-budget-usd 0.50 \
--plugin-dir "$PLUGIN" --allowedTools "$TOOLS" --disallowedTools Bash,Write,Edit,NotebookEdit --output-format stream-json --verbose --debug-file "$OUT/$name.log" "$prompt" </dev/null >"$OUT/$name.jsonl" 2>"$OUT/$name.err")
}
diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.sh
index 9a99a8142b..1c0788bf1f 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.3"
+step "1. plugin.json declares ruflo-console 0.33.4"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
- && grep -q '"version": "0.33.3"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
+ && grep -q '"version": "0.33.4"' "$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/control-guards.spec.ts b/plugins/ruflo-console/tests/control-guards.spec.ts
new file mode 100644
index 0000000000..e05d7fa0b3
--- /dev/null
+++ b/plugins/ruflo-console/tests/control-guards.spec.ts
@@ -0,0 +1,115 @@
+/**
+ * What the console's model tools may never do on their own (ADR-450 T8, T12): auto-confirm a network, spend or delete action, pass text that
+ * looks like a secret, or let an environment variable raise Claude's control above what the person saved.
+ */
+import { describe, expect, it } from 'vitest'
+
+import { allows, callTool, lowerOnly, parseControlEnv } from '../hooks/model-tools'
+import { setup } from './fixtures/control-setup'
+
+describe('what auto-confirm may never answer (ADR-450 T8)', () => {
+ const ENTRIES = { read: 'mission-open', write: 'mission-create', network: 'plugin-install', spend: 'hand-task', delete: 'mission-cancel' } as const
+ const levels = ['read', 'write', 'manage', 'full'] as const
+
+ for (const kind of ['read', 'write', 'network', 'spend', 'delete'] as const) {
+ for (const confirm of ['ask', 'auto'] as const) {
+ for (const level of levels) {
+ const refused = !allows(level, kind)
+ const waits = !refused && kind !== 'read' && (confirm === 'ask' || kind !== 'write')
+
+ it(`${kind} at ${level}:${confirm} is ${refused ? 'refused' : waits ? 'left waiting for the person' : 'run'}`, async () => {
+ const { deps, calls, state } = setup(level, confirm)
+ const answer = await callTool('console_run', { id: ENTRIES[kind] }, deps)
+
+ if (refused) expect(answer).toMatch(/^Refused: .*needs/)
+ else if (waits) expect(answer).toMatch(/^Waiting for the person to confirm/)
+ else expect(answer).toMatch(/^Done/)
+
+ expect(calls.confirm).toBe(!refused && !waits && kind !== 'read' ? 1 : 0)
+ expect(state.pending !== null).toBe(waits)
+ })
+ }
+ }
+ }
+
+ it('never confirms a network, spend or delete action in auto, however many times Claude asks', async () => {
+ const { deps, calls } = setup('full', 'auto')
+
+ for (const id of ['plugin-install', 'hand-task', 'mission-cancel']) {
+ expect(await callTool('console_run', { id }, deps), id).toMatch(/^Waiting for the person to confirm/)
+ deps.state.pending = null
+ }
+ expect(calls.confirm).toBe(0)
+ })
+})
+
+describe('text Claude passes is screened for secrets before it reaches an entry (ADR-450 T8)', () => {
+ const TOKEN = `ghp_${'a1B2c3D4e5'.repeat(4)}`
+ const SECRETS = [TOKEN, 'AKIAABCDEFGHIJKLMNOP', '-----BEGIN OPENSSH PRIVATE KEY-----', 'password=hunter2hunter2hunter2', `sk-ant-${'x'.repeat(30)}`, `xoxb-${'1'.repeat(12)}`]
+
+ for (const secret of SECRETS) {
+ it(`refuses a run whose text holds ${secret.slice(0, 8)}… and runs nothing, never echoing it`, async () => {
+ const { deps, calls, state } = setup('manage', 'auto')
+ const answer = await callTool('console_run', { id: 'mission-create', text: `post this: ${secret}` }, deps)
+
+ expect(answer).toBe('Refused: that text looks like a secret. It was not used and is not shown. Do not pass keys, tokens or passwords to the console.')
+ expect(answer).not.toContain(secret)
+ expect(calls.runs).toEqual([])
+ expect(JSON.stringify(state.control.log)).not.toContain(secret)
+ })
+
+ it(`refuses a set whose value holds ${secret.slice(0, 8)}… and fills nothing`, async () => {
+ const { deps, calls } = setup('write', 'auto')
+ const answer = await callTool('console_set', { field: 'goal', value: `use ${secret}` }, deps)
+
+ expect(answer).toMatch(/^Refused: that text looks like a secret/)
+ expect(answer).not.toContain(secret)
+ expect(calls.goal).toEqual([])
+ })
+ }
+
+ it('hides a secret behind zero-width characters no better', async () => {
+ const { deps, calls } = setup('write', 'auto')
+
+ expect(await callTool('console_run', { id: 'mission-create', text: `gh\u200bp_${'a1B2c3D4e5'.repeat(4)}` }, deps)).toMatch(/^Refused: that text looks like a secret/)
+ expect(calls.runs).toEqual([])
+ })
+
+ it('still runs and sets clean text', async () => {
+ const { deps, calls } = setup('write', 'auto')
+
+ expect(await callTool('console_set', { field: 'goal', value: 'add a dark mode toggle' }, deps)).toMatch(/^Set goal/)
+ expect(await callTool('console_run', { id: 'mission-create', text: 'a normal note about tokens in general' }, deps)).toMatch(/^Done/)
+ expect(calls.goal).toEqual(['add a dark mode toggle'])
+ expect(calls.runs).toEqual(['mission-create'])
+ })
+})
+
+describe('the environment override may only lower control (ADR-450 T12)', () => {
+ const levels = ['off', 'read', 'write', 'manage', 'full'] as const
+ const rank = (level: (typeof levels)[number]) => levels.indexOf(level)
+
+ for (const saved of levels) {
+ for (const forced of levels) {
+ for (const savedConfirm of ['ask', 'auto'] as const) {
+ for (const forcedConfirm of ['ask', 'auto'] as const) {
+ it(`saved ${saved}:${savedConfirm} with env ${forced}:${forcedConfirm}`, () => {
+ const got = lowerOnly({ level: saved, confirm: savedConfirm }, { level: forced, confirm: forcedConfirm })
+
+ expect(rank(got.level)).toBeLessThanOrEqual(rank(saved))
+ expect(rank(got.level)).toBeLessThanOrEqual(rank(forced))
+ expect(got.level).toBe(rank(forced) < rank(saved) ? forced : saved)
+ expect(got.confirm).toBe(savedConfirm === 'ask' || forcedConfirm === 'ask' ? 'ask' : 'auto')
+ })
+ }
+ }
+ }
+ }
+
+ it('leaves the saved setting alone when there is no override, and cannot turn control on from off', () => {
+ expect(lowerOnly({ level: 'write', confirm: 'ask' }, null)).toEqual({ level: 'write', confirm: 'ask' })
+ expect(lowerOnly({ level: 'off', confirm: 'auto' }, parseControlEnv('full:auto'))).toEqual({ level: 'off', confirm: 'auto' })
+ expect(lowerOnly({ level: 'read', confirm: 'ask' }, parseControlEnv('full:auto'))).toEqual({ level: 'read', confirm: 'ask' })
+ })
+})
+
diff --git a/plugins/ruflo-console/tests/fixtures/control-setup.ts b/plugins/ruflo-console/tests/fixtures/control-setup.ts
new file mode 100644
index 0000000000..c81bcee923
--- /dev/null
+++ b/plugins/ruflo-console/tests/fixtures/control-setup.ts
@@ -0,0 +1,53 @@
+/** A fake console controller for the model-tool specs (ADR-444): read-only entries finish at once, the rest wait in `state.pending`. */
+import { settingsOf } from '../../hooks/settings'
+import { newState } from '../../hooks/state'
+import type { ModelToolDeps } from '../../hooks/model-tools'
+import type { Actions } from '../../hooks/views/common'
+
+export type Level = 'off' | 'read' | 'write' | 'manage' | 'full'
+
+/** A controller whose runner behaves like the real one: read-only entries finish at once, the rest wait in `state.pending`. */
+export function setup(level: Level, confirm: 'ask' | 'auto' = 'ask', entries: Record<string, { label: string; readOnly?: boolean; note?: string }> = {}, followUp?: { label: string; note?: string }) {
+ const state = newState({})
+ const calls = { timers: [] as (() => void)[], finishAfter: undefined as Promise<void> | undefined, setView: [] as string[], open: 0, goal: [] as string[], profile: [] as string[], draft: [] as string[][], confirm: 0, cancel: 0, runs: [] as string[] }
+
+ Object.assign(settingsOf(state).ai, { modelControl: level, modelConfirm: confirm })
+
+ const catalog = { 'mission-open': { label: 'open Mission Control', readOnly: true }, 'mission-create': { label: 'create the mission and its tasks' }, 'mission-cancel': { label: 'cancel the mission and its open tasks' }, 'plugin-install': { label: 'install a plugin', note: 'network: clones it from GitHub' }, 'hand-task': { label: 'hand task t1 to Claude', note: 'Starts a Claude Code turn (billed as any turn is)' }, ...entries }
+ const control = {
+ host: { invalidate: () => undefined, after: (_ms: number, fn: () => void) => ({ cancel: () => calls.timers.splice(calls.timers.indexOf(fn), 1), fire: fn, ...(calls.timers.push(fn) && {}) }) },
+ setView: (view: string) => void calls.setView.push(view),
+ open: async () => void (calls.open += 1),
+ actions: { mission: { goal: (text: string) => {
+ calls.goal.push(text)
+ if (followUp !== undefined) state.pending = { label: followUp.label, args: [], expect: 'guidance', askedAtMs: Date.now(), ...(followUp.note !== undefined && { note: followUp.note }) }
+ }, profile: (id: string) => void calls.profile.push(id), rigor: () => undefined }, devtools: { draft: (field: string, text: string) => void calls.draft.push([field, text]) }, costBudgetDraft: () => undefined } as unknown as Actions,
+ runner: {
+ runById: (id: string) => {
+ const entry = catalog[id as keyof typeof catalog] as { label: string; readOnly?: boolean; note?: string } | undefined
+
+ if (entry === undefined) return false
+
+ calls.runs.push(id)
+ if (entry.readOnly === true) state.outcome = { label: entry.label, ok: true, verified: 'n/a', detail: 'done', atMs: Date.now() + 1 }
+ else state.pending = { label: entry.label, args: [], expect: 'the change on disk', askedAtMs: Date.now(), ...(entry.note !== undefined && { note: entry.note }) }
+
+ return true
+ },
+ settled: async () => undefined,
+ finished: async () => (calls.finishAfter === undefined ? undefined : calls.finishAfter),
+ confirm: async () => {
+ calls.confirm += 1
+ state.outcome = { label: state.pending?.label ?? '', ok: true, verified: 'n/a', detail: 'ran', atMs: Date.now() + 1 }
+ state.pending = null
+ },
+ cancel: () => {
+ calls.cancel += 1
+ state.pending = null
+ },
+ },
+ }
+
+ return { state, calls, deps: { state, control } as unknown as ModelToolDeps }
+}
+
diff --git a/plugins/ruflo-console/tests/model-tools.spec.ts b/plugins/ruflo-console/tests/model-tools.spec.ts
index 6ff3ab8c6a..1b091cb93b 100644
--- a/plugins/ruflo-console/tests/model-tools.spec.ts
+++ b/plugins/ruflo-console/tests/model-tools.spec.ts
@@ -11,8 +11,7 @@ import { settingsOf } from '../hooks/settings'
import { newState, type State } from '../hooks/state'
import type { Actions } from '../hooks/views/common'
import { viewText } from '../hooks/views/pane'
-
-type Level = 'off' | 'read' | 'write' | 'manage' | 'full'
+import { setup } from './fixtures/control-setup'
/** A controller whose runner behaves like the real one: read-only entries finish at once, the rest wait in `state.pending`. */
function setup(level: Level, confirm: 'ask' | 'auto' = 'ask', entries: Record<string, { label: string; readOnly?: boolean; note?: string }> = {}, followUp?: { label: string; note?: string }) {
@@ -204,7 +203,7 @@ describe('a field that raises its own follow-up (a goal is planned, then guidanc
expect(state.pending).toBeNull()
})
- it('leaves it waiting for the person in ask mode, and confirms it in auto mode at full', async () => {
+ it('leaves it waiting for the person in ask mode, and in auto mode too: a billed follow-up is never auto-confirmed', async () => {
const ask = setup('full', 'ask', {}, guidance)
expect(await callTool('console_set', { field: 'goal', value: 'g' }, ask.deps)).toMatch(/Waiting for the person to confirm/)
@@ -213,8 +212,9 @@ describe('a field that raises its own follow-up (a goal is planned, then guidanc
const auto = setup('full', 'auto', {}, guidance)
- expect(await callTool('console_set', { field: 'goal', value: 'g' }, auto.deps)).toMatch(/Done: ask claude -p/)
- expect(auto.calls.confirm).toBe(1)
+ expect(await callTool('console_set', { field: 'goal', value: 'g' }, auto.deps)).toMatch(/Waiting for the person to confirm.*\(spend\)/)
+ expect(auto.calls.confirm).toBe(0)
+ expect(auto.state.pending).not.toBeNull()
})
it('does not touch a field while the person has an action waiting', async () => {
@@ -333,11 +333,11 @@ describe('running an entry: ask, auto, and the level', () => {
})
it('lets the same actions through at the level they need', async () => {
- expect(await callTool('console_run', { id: 'plugin-install' }, setup('manage', 'auto').deps)).toMatch(/^Done/)
+ expect(await callTool('console_run', { id: 'plugin-install' }, setup('manage', 'auto').deps)).toMatch(/^Waiting/)
expect(await callTool('console_run', { id: 'plugin-install' }, setup('write', 'auto').deps)).toMatch(/^Refused/)
expect(await callTool('console_run', { id: 'mission-cancel' }, setup('manage', 'auto').deps)).toMatch(/^Refused/)
- expect(await callTool('console_run', { id: 'mission-cancel' }, setup('full', 'auto').deps)).toMatch(/^Done/)
- expect(await callTool('console_run', { id: 'hand-task' }, setup('full', 'auto').deps)).toMatch(/^Done/)
+ expect(await callTool('console_run', { id: 'mission-cancel' }, setup('full', 'auto').deps)).toMatch(/^Waiting/)
+ expect(await callTool('console_run', { id: 'hand-task' }, setup('full', 'auto').deps)).toMatch(/^Waiting/)
})
it('never replaces or answers an action the person already has waiting', async () => {
diff --git a/v3/docs/adr/ADR-444-claude-controls-the-console.md b/v3/docs/adr/ADR-444-claude-controls-the-console.md
index 719d5a69f8..15359a39c9 100644
--- a/v3/docs/adr/ADR-444-claude-controls-the-console.md
+++ b/v3/docs/adr/ADR-444-claude-controls-the-console.md
@@ -57,3 +57,7 @@ and a second setting, **confirm**: `auto` (default since console 0.32: once the
## 6. Amendment: autopilot by default
With `ask` as the default, a person who had turned control on found Claude parked on every write, waiting for a Yes that nothing prompted for. The level is the real limit (it defaults to off, and only the person raises it), so the confirm default is now `auto`; `ask` remains an explicit choice. Claude Code's own permission prompt for the four tools is separate: allow `mcp__ruflo-console__*` in the permissions settings to remove that one too (a mod can only tighten `tool.check`, never loosen it).
+
+## 7. Amendment: auto never answers network, spend or delete (console 0.33.4, ADR-450 T8, T12)
+
+`modelConfirm: auto` no longer applies to every class. An action classed `network`, `spend` or `delete` always waits for the person in the console's confirm row, even in `auto`: Claude's call is answered "Waiting for the person to confirm" and it must not retry. `auto` still runs local `write` actions unattended. Text Claude passes to `console_set` (the value) or `console_run` (the text) is screened with the shared secret screen (`hooks/screen.ts`, a copy kept in step by `scripts/sync-mod-screen.mjs`) before it reaches an entry; a match is refused ("that text looks like a secret") and never echoed. `RUFLO_CONSOLE_CONTROL` may only lower the saved level, or force `ask`; it can no longer raise either, so a project's settings `env` cannot give Claude more control than the person saved. For a recording or a test that needs a level, save it in Settings (or the plugin store) instead of the environment.
diff --git a/v3/docs/adr/ADR-450-mod-system-threat-model.md b/v3/docs/adr/ADR-450-mod-system-threat-model.md
index ef6c8fff42..caedf66a79 100644
--- a/v3/docs/adr/ADR-450-mod-system-threat-model.md
+++ b/v3/docs/adr/ADR-450-mod-system-threat-model.md
@@ -126,6 +126,7 @@ Status: **fixed** (this change), **held** (attempted, no break), **open** (recom
- 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.
+- **Update (console 0.33.4): controls (1) and (2) are implemented.** `settlePending` (`model-tools.ts`) leaves `network`, `spend` and `delete` actions waiting for the person whatever `modelConfirm` is; `console_set` values and `console_run` text are refused when `hooks/screen.ts` (the shared screen) finds a secret, raw or cleaned. Tests: `tests/control-guards.spec.ts` (every class x confirm x level; a secret refused for set and run; clean text still runs). Controls (3) to (5) stay open.
### T9. Malicious or compromised plugin or mod
@@ -152,6 +153,7 @@ Status: **fixed** (this change), **held** (attempted, no break), **open** (recom
- 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.
+- **Update (console 0.33.4): fixed.** `lowerOnly` (`model-tools.ts`), applied in `register.ts`, takes the lower level and `ask` if either side says ask. Tested for every saved x env pair in `tests/control-guards.spec.ts`.
### T13. `runById` fuzzy fallback