🌊 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
feat(ruflo-console): security sentries and a send-findings-to-Claude button (ADR 427)
ruv9acb1c865505
diff --git a/plugins/ruflo-console/hooks/loops.ts b/plugins/ruflo-console/hooks/loops.tsindex c48f17900f..edcabe42df 100644--- a/plugins/ruflo-console/hooks/loops.ts+++ b/plugins/ruflo-console/hooks/loops.ts@@ -25,6 +25,11 @@ export type LoopPreset = {task: string/** Why this one costs: what each tick does. */cost: string+ /**+ * A security sentry, offered on the Security page: `watch` finds and reports and edits nothing; `fix` also fixes the top finding,+ * in a new worktree branch. The guard (read-only, never push) leads the task, so a cut at the length limit cannot remove it.+ */+ sentry?: 'watch' | 'fix'}export const INTERVALS = ['self-paced', '1m', '5m', '10m', '30m', '1h', '4h', '1d'] as const@@ -50,6 +55,13 @@ export const PRESETS: readonly LoopPreset[] = [{ id: 'hive-vote', tier: 'exotic', title: 'Hive consensus loop', about: 'each tick: the hive proposes, votes and records the decision', interval: '30m', task: 'Use the hive-mind: propose the next most valuable improvement to this project, have the workers vote, and record the decision with its tally in memory.', cost: 'a longer turn per tick: several agents' },{ id: 'horizon', tier: 'exotic', title: 'Long-horizon tracker', about: 'checkpoint a long objective across sessions, detect drift', interval: '1h', task: '/ruflo-goals:horizon-track', cost: 'a turn per tick; writes memory checkpoints' },{ id: 'ultralearn', tier: 'exotic', title: 'Ultralearn', about: 'deep knowledge acquisition into memory and patterns', interval: 'self-paced', task: '/ruflo-loop-workers:ruflo-loop ultralearn', cost: 'long turns; the worker schedules itself' },+ // Security sentries (the Security page lists these): five that find and report, one that also fixes in an isolated branch.+ { id: 'sentry-live', tier: 'practical', sentry: 'watch', title: 'Sentry: live, on change', about: 'scan as files change and report only new findings', interval: 'self-paced', task: 'Read-only. Use the Monitor tool to watch this repo: poll `git status --porcelain` every 20 s and emit a line only when it changes. On each event run `npx ruflo security scan --depth quick --type code --output json` and report only findings that are new since the last event. Edit nothing.', cost: 'a turn only when files change (events, not polling turns); edits nothing' },+ { id: 'sentry-quick', tier: 'practical', sentry: 'watch', title: 'Sentry: quick scan', about: 'a quick code scan, new findings only', interval: '30m', task: 'Read-only. Run `npx ruflo security scan --depth quick --type code --output json`. Report only findings that are new since the last tick, by severity and file, and say nothing if there are none. Edit nothing.', cost: 'a short turn per tick; edits nothing; writes the scan report' },+ { id: 'sentry-secrets', tier: 'practical', sentry: 'watch', title: 'Sentry: secrets and PII', about: 'secrets, PII and injection text in the tree and recent commits', interval: '4h', task: 'Read-only. Run `npx ruflo security secrets`, then check the last 20 commits and the working tree for secrets, PII or prompt-injection text. Report file and type only, and never print a value. Edit nothing.', cost: 'a short turn per tick; edits nothing; values are never shown' },+ { id: 'sentry-nightly', tier: 'steady', sentry: 'watch', title: 'Sentry: nightly deep scan', about: 'a deep scan and STRIDE threats, grouped by root cause', interval: '1d', task: 'Read-only. Run `npx ruflo security scan --depth deep --type code --output json` and `npx ruflo security threats`. Group the findings by root cause, rank them by risk, and say what changed since yesterday. Edit nothing.', cost: 'one longer turn a day; edits nothing; writes the scan report' },+ { id: 'sentry-deps', tier: 'steady', sentry: 'watch', title: 'Sentry: dependencies', about: 'known CVEs in the dependency tree, with the fixing version', interval: '1d', task: 'Read-only. Run `npx ruflo security cve --list`. For each vulnerable dependency give the fixed version and what an upgrade could break. Propose the upgrades; change no file and open no pull request.', cost: 'one turn a day; reaches npm (npm audit); edits nothing' },+ { id: 'sentry-fix', tier: 'steady', sentry: 'fix', title: 'Sentry: find and fix', about: 'fix the top real finding in its own branch, never push', interval: '1h', task: 'Never push or merge, never edit this checkout. Run `npx ruflo security scan --depth quick --type code --output json`. Take the highest-severity real finding (skip false positives), make a git worktree on branch sentry/<date>-<id>, fix it with the smallest change, run the tests, commit there, and report the branch and diff.', cost: 'a turn per tick; edits files only in a new worktree branch and commits there; never pushes (the guard is the instruction, not a sandbox)' },{ id: 'self-heal', tier: 'exotic', title: 'Self-heal the swarm', about: 'find stuck agents and claims, release, re-route', interval: '10m', task: 'Check the swarm: find agents or claims that have made no progress for 10 minutes, release or hand them off, and say what you changed.', cost: 'a turn per tick; writes through confirmed commands' },]@@ -69,7 +81,8 @@ export function loopsOf(state: State): LoopCfg {}const SLASH = /^\/([a-z0-9-]+:[A-Za-z0-9._-]+)(?: [A-Za-z0-9 ._:,=-]{0,120})?$/-const MAX_TASK = 400+/** A task longer than this is cut, so every preset must fit: the spec fails on one that does not. */+export const MAX_TASK = 400const MAX_LOOP = 600/** The stop condition as a clause for the loop's prompt, or why it is not understood. Empty is "no stop condition". */diff --git a/plugins/ruflo-console/hooks/views/secure.ts b/plugins/ruflo-console/hooks/views/secure.tsindex 18f97f25bd..461d8b6bea 100644--- a/plugins/ruflo-console/hooks/views/secure.ts+++ b/plugins/ruflo-console/hooks/views/secure.ts@@ -54,6 +54,22 @@ export function sendResultRow(ctx: Ctx, key: string): RenderElement {)}+/** The triage question: the page text carries only the counts (and is capped), so it sends Claude to the report the scan wrote. */+export const FINDINGS_QUESTION =+ 'Triage these security findings. Read the newest report in .claude/security-scans/ yourself (the counts here are only a summary), group the findings by root cause, separate real defects from false positives, and propose a fix for each real one with the exact change. Do not edit any file until I approve.'++/** Under the findings meter: hands the findings to the main Claude session to triage (the ADR 411 bridge: quoted data, secrets removed, asks first). */+export function sendFindingsRow(ctx: Ctx): RenderElement {+ return row(+ ctx,+ [+ button(ctx, 'findings-send', '✦ send findings to Claude', () => ctx.act.ask.ask(FINDINGS_QUESTION), { primary: true }),+ text(ctx, ' the counts go as quoted data; Claude reads the report itself and edits nothing until you approve', { dimColor: true }),+ ],+ 'findings-send-row',+ )+}+/** A verb the CLI does not have, said as such rather than invented. */export const naRow = (ctx: Ctx, name: string, why: string): RenderElement => text(ctx, ` n/a ${name.padEnd(14, '.')} ${why}`, { dimColor: true })@@ -234,9 +250,10 @@ export function secureView(ctx: Ctx): RenderElement {'sec-findings','Findings',findings === null ? 'none measured yet' : `${SEVERITIES.map(level => `${findings.counts[level]} ${level}`).join(' · ')} · ${ago(findings.atMs, nowMs)}`,- meterRows(ctx),+ findings === null ? meterRows(ctx) : [...meterRows(ctx), sendFindingsRow(ctx)],true,),+ ...sentryRows(ctx),// Open: the text field lives here, and the checks below it read what is typed; folded, the field would be out of reach....section(ctx, 'sec-check', 'Check text', memo.draft === '' ? 'type or paste text, then run a check' : `${memo.draft.length} characters ready`, pasteRows(ctx), true),...section(ctx, 'sec-scan', 'Scan & inspect', scanBusy ? `${spinAt(nowMs)} ${running?.label ?? 'scanning'}` : 'scans are local; npm audit is the network', scanRows, scanBusy),diff --git a/plugins/ruflo-console/hooks/views/sentries.ts b/plugins/ruflo-console/hooks/views/sentries.tsnew file mode 100644index 0000000000..49fb1fdb91--- /dev/null+++ b/plugins/ruflo-console/hooks/views/sentries.ts@@ -0,0 +1,53 @@+import type { RenderElement } from 'claude-code'++import { PRESETS } from '../loops'+import { button, clip, row, section, text, THEME, type Ctx } from './common'++/** When a sentry runs, in words: on change (an event watch), or every interval. */+const whenOf = (interval: string): string => (interval === 'self-paced' ? 'on change' : `every ${interval}`)++/**+ * Security sentries: the loop manager's security presets, one row each. A `watch` sentry finds and reports and edits nothing; the+ * `fix` sentry also fixes the top real finding, in a new worktree branch, and never pushes. Start picks the preset and calls the+ * loop launcher, which shows the exact /loop text and asks first (each tick is a billed Claude turn). The loops run in the main+ * Claude session, so what a sentry finds arrives in the conversation where it can be acted on.+ */+export function sentryRows(ctx: Ctx): RenderElement[] {+ const m = ctx.act.loops+ const sentries = PRESETS.filter(preset => preset.sentry !== undefined)+ const lead = Math.max(16, Math.min(26, ctx.columns - 52))+ const rows: RenderElement[] = sentries.map(preset =>+ row(+ ctx,+ [+ ctx.kit.Text({ bold: true, color: preset.sentry === 'fix' ? THEME.warn : THEME.ok, children: preset.sentry === 'fix' ? ' fix ' : ' watch ' }),+ ctx.kit.Text({ bold: true, color: THEME.head, children: ` ${preset.title.replace('Sentry: ', '')} `.padEnd(lead, '.') }),+ ctx.kit.Text({ color: THEME.info, wrap: 'truncate-end', children: clip(` ${whenOf(preset.interval)} · ${preset.about}`, Math.max(8, ctx.columns - lead - 26)) }),+ ctx.kit.Button({+ key: `sentry-start-${preset.id}`,+ label: ' ▶ start ',+ variant: 'primary',+ onPress: () => {+ m.pick(preset.id)+ m.launch()+ },+ }),+ ],+ `sentry-${preset.id}`,+ ),+ )++ rows.push(+ row(+ ctx,+ [+ button(ctx, 'sentry-manage', '☰ list / stop my sentries', () => m.manage()),+ text(ctx, ' asks Claude to list the scheduled loops and stop the ones you name', { dimColor: true }),+ ],+ 'sentry-manage-row',+ ),+ )+ rows.push(text(ctx, ' watch: reads and reports, edits nothing · fix: edits only in a new branch and never pushes · each tick is a billed turn; it asks first', { dimColor: true }))++ return section(ctx, 'sec-sentries', 'Sentries', `${sentries.filter(entry => entry.sentry === 'watch').length} watch · ${sentries.filter(entry => entry.sentry === 'fix').length} find and fix · real time, or on a schedule`, rows, true)+}diff --git a/plugins/ruflo-console/tests/sentries.spec.ts b/plugins/ruflo-console/tests/sentries.spec.tsnew file mode 100644index 0000000000..bb9bb0d479--- /dev/null+++ b/plugins/ruflo-console/tests/sentries.spec.ts@@ -0,0 +1,73 @@+/**+ * The security sentries: loop presets the Security page offers. They must fit the loop's length limit (a longer task is cut, and the cut+ * would take the guard at its end), the watch ones must read only, the fix one must stay in its own branch and never push, and every+ * command in them must be one the registries really run, so a sentry cannot loop on a verb the CLI does not have. Run with+ * npx vitest run plugins/ruflo-console/tests/sentries.spec.ts+ */+import { describe, expect, it } from 'vitest'++import { INTERVALS, loopInput, MAX_TASK, PRESETS } from '../hooks/loops'+import { SECURE } from '../hooks/secure'++const sentries = PRESETS.filter(preset => preset.sentry !== undefined)+const watch = sentries.filter(preset => preset.sentry === 'watch')+const fix = sentries.filter(preset => preset.sentry === 'fix')+const commandsIn = (task: string): string[] => [...task.matchAll(/`npx ruflo ([^`]+)`/g)].map(match => match[1] as string)+const registered = new Set(SECURE.map(entry => entry.args.join(' ')))++describe('security sentries', () => {+ it('offers several that find and report, and one that also fixes', () => {+ expect(watch.length).toBeGreaterThanOrEqual(5)+ expect(fix.map(preset => preset.id)).toEqual(['sentry-fix'])+ })++ it('covers real time and several schedules, each a valid loop interval', () => {+ for (const preset of sentries) expect((INTERVALS as readonly string[]).includes(preset.interval), preset.id).toBe(true)++ expect(sentries.some(preset => preset.interval === 'self-paced')).toBe(true)+ expect(new Set(sentries.map(preset => preset.interval)).size).toBeGreaterThanOrEqual(4)+ })++ it('fits the task limit whole, so the guard is never cut, and builds a /loop with the whole task', () => {+ for (const preset of sentries) {+ expect(preset.task.length, preset.id).toBeLessThanOrEqual(MAX_TASK)++ const built = loopInput({ tier: preset.tier, preset: preset.id, interval: preset.interval, task: preset.task, stop: '' }, [])++ expect(built, preset.id).toMatchObject({ ok: true })+ expect((built as { text: string }).text, preset.id).toContain(preset.task)+ }+ })++ it('has the guard first: a watch sentry reads only and edits nothing, the fix sentry never pushes or edits the checkout', () => {+ for (const preset of watch) {+ expect(preset.task.startsWith('Read-only.'), preset.id).toBe(true)+ expect(/Edit nothing\.$|open no pull request\.$/.test(preset.task), preset.id).toBe(true)+ expect(preset.cost, preset.id).toContain('edits nothing')+ }++ const [only] = fix++ expect(only?.task.startsWith('Never push or merge, never edit this checkout.')).toBe(true)+ expect(only?.task).toContain('git worktree')+ expect(only?.task).toContain('sentry/')+ expect(only?.cost).toContain('never pushes')+ expect(only?.cost).toContain('not a sandbox')+ })++ it('names only commands the registries run, with their own flags, so a sentry cannot loop on a verb the CLI lacks', () => {+ for (const preset of sentries) {+ const commands = commandsIn(preset.task)++ expect(commands.length, preset.id).toBeGreaterThan(0)++ for (const command of commands) expect(registered.has(command) || [...registered].some(args => args === command), `${preset.id}: ${command}`).toBe(true)+ }+ })++ it('never asks to print a secret value', () => {+ const secrets = PRESETS.find(preset => preset.id === 'sentry-secrets')++ expect(secrets?.task).toContain('never print a value')+ })+})diff --git a/v3/docs/adr/ADR-427-console-security-sentries.md b/v3/docs/adr/ADR-427-console-security-sentries.mdnew file mode 100644index 0000000000..20a0208338--- /dev/null+++ b/v3/docs/adr/ADR-427-console-security-sentries.md@@ -0,0 +1,56 @@+# ADR 427: Security sentries: scheduled and real-time finders, and one that fixes in its own branch++Status: Accepted (ships in ruflo-console 0.26.0)++Date: 2026 10 03++Decision owner: Ruflo maintainers++Scope: `plugins/ruflo-console`: `hooks/loops.ts` (six presets, `sentry`, `MAX_TASK`), `hooks/views/sentries.ts` (new), `hooks/views/secure.ts` (`sendFindingsRow`, `FINDINGS_QUESTION`), `tests/sentries.spec.ts` (new).++Extends: ADR 414 (the loop manager), ADR 411 (the Claude UI bridge), ADR 426 (the self-check and visible runs).++## 1. Context++The Security page ran scans on a press and showed counts, and that was the end of it. A page showing "235 high" gave no way to hand those findings to the session that could triage them, and nothing watched the tree between presses. The loop manager (ADR 414) already starts a recurring `/loop` in the main Claude session from a preset, with the exact text shown and a confirm first, so the console needs no scheduler of its own.++## 2. Decision++### 2.1 Findings go to Claude+Under the findings meter, `✦ send findings to Claude` calls the ADR 411 bridge (quoted data, secrets removed, asks first). The page text carries only the severity counts and is capped at 4,000 characters, so the question tells Claude to read the newest report in `.claude/security-scans/` itself, group the findings by root cause, separate real defects from false positives, propose a fix for each real one, and edit nothing until the person approves.++### 2.2 Six sentries, as loop presets+A `sentry` field on a loop preset marks it; the Security page lists those as a **Sentries** section, and the Automation page's loop manager lists them with the rest. Start picks the preset and calls the loop launcher, so the person sees the exact `/loop` text and the cost before anything runs.++| Sentry | When | Does |+|---|---|---|+| live, on change | self-paced, with the Monitor tool | watches `git status` and scans on a change; reports new findings; edits nothing |+| quick scan | every 30 min | a quick code scan; new findings only |+| secrets and PII | every 4 h | `security secrets`, the last 20 commits and the tree; file and type only, never a value |+| nightly deep scan | every day | a deep scan and STRIDE threats, grouped by root cause, with what changed |+| dependencies | every day | `security cve --list`; the fixing version and what an upgrade could break; no file changed, no pull request |+| **find and fix** | every hour | the top real finding, fixed in a new `git worktree` branch `sentry/<date>-<id>`, tests run, committed there |++### 2.3 What "fix" is allowed to do+The fix sentry never pushes or merges and never edits the current checkout. Its confirm note says it edits files only in a new worktree branch and commits there, and that **the guard is the instruction, not a sandbox**: the loop runs in the main session under the person's own permission mode, so the console does not enforce it, and the text says so rather than implying otherwise. The five that only find begin `Read-only.` and end `Edit nothing.` (or `open no pull request.`).++### 2.4 Guard first, within the limit+The loop launcher cuts a task at 400 characters. A guard at the end would be the first thing lost, so each task leads with its guard, and `MAX_TASK` is exported so the spec fails on any sentry that would be cut.++### 2.5 Real time is events, not polling turns+"Real time" is a Monitor on `git status` with a turn only when files change, not a billed turn every minute. A tick every minute would be near real time at the price of a turn per tick; the cost line on the confirm row says which one a sentry is.++## 3. Alternatives considered++- **A scheduler in the console.** Rejected: ADR 414 already schedules, shows the exact text and asks. A second one would disagree with it.+- **A sentry that fixes in the working tree.** Rejected: an unattended edit of the checkout the person is using. The isolated branch costs one worktree and a `git branch -D`.+- **Durable schedules (survive the session).** Not here: `/loop` expires after seven days and lives in the session. The `ruflo-loop-workers` audit worker and `ruflo-schedule` (a cron) are the durable options and are in the loop manager already.+- **A fixed push to a pull request.** Rejected for the same reason as pushing: a person reviews the branch first.++## 4. What this does not prove++The sentry text is a prompt. The spec proves it fits, leads with its guard, and names only commands the registries run with their own flags; it cannot prove that Claude follows it, that the Monitor tool is available in the session that starts it, or that a worktree fix passes its tests. None of that has been run live. The first live check should start the quick sentry, let it tick once, and read what it reports; the fix sentry should be tried on a throwaway branch before it is left running.++## 5. Tests++`tests/sentries.spec.ts` (6): at least five watch sentries and exactly one fix; real time plus at least four distinct cadences, each a valid loop interval; every task fits `MAX_TASK` and builds a `/loop` containing the whole task; the guard is first (`Read-only.`, or `Never push or merge, never edit this checkout.` with a worktree and a `sentry/` branch) and the cost line says `edits nothing` or `never pushes` and `not a sandbox`; every `npx ruflo ...` command in a sentry is one a registry runs, with its own flags (checked by changing a flag and watching it fail, then restoring it); the secrets sentry says it never prints a value.