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

feat(console): Mods reader shows calls from seen/checked/calls-object and refusal class from lastReason/lastBlocked (console 0.33.10)

ruvd9a226913e1c
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.json
index 3215ed3bd0..77431bb3bd 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.9",
+ "version": "0.33.10",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-console/hooks/data/mods.ts b/plugins/ruflo-console/hooks/data/mods.ts
index a80104120d..b92dbe5608 100644
--- a/plugins/ruflo-console/hooks/data/mods.ts
+++ b/plugins/ruflo-console/hooks/data/mods.ts
@@ -1,5 +1,5 @@
import { readBounded, under, type ReadCache, type ReaderFs } from './files'
-import { jsonObject, plain } from './parse'
+import { jsonObject, plain, recordOf } from './parse'
/** The most mod folders read, and the most bytes of one status file (a larger one is refused, not trimmed). */
export const MODS_MAX_FILES = 60
@@ -15,7 +15,7 @@ export const DENY_CLASSES = ['secret', 'destructive', 'path', 'network', 'policy
export type DenyClass = (typeof DENY_CLASSES)[number]
/**
- * One mod's status file (ADR-446): the counters every mod writes; per-plugin counters are not read here. The last four are optional and only
+ * One mod's status file (ADR-446): the counters every mod writes (calls also from `seen`/`checked`/a `calls` object; lastDenied also from `lastReason`/`lastBlocked`); per-plugin counters are not read here. The last four are optional and only
* present when the file reported them (modVersion, a one-line summary of what it guards, the class of its last refusal, the file's age source).
*/
export type ModRow = { name: string; guard: boolean | null; calls: number | null; blocked: number; updatedMs: number | null; startedMs: number | null; modVersion?: string; summary?: string; lastDenied?: DenyClass; fileMs?: number }
@@ -27,6 +27,34 @@ export const NO_MODS: ModsFacts = { rows: [], refused: 0, truncated: false }
const whole = (v: unknown): number | null => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? Math.floor(v) : null)
+/** Most keys of a `calls` object that are summed, and the ceiling of any summed or widened count (a hostile 1e300 must not become a display value). */
+const CALLS_KEYS_MAX = 64
+const COUNT_CEILING = Number.MAX_SAFE_INTEGER
+
+/**
+ * How many times a mod ran, from whichever of its three shapes the file uses: a number `calls`; a `calls` object (summed over its numeric values,
+ * at most 64 of them); else `seen`, else `checked`. Anything else (array, nested object, NaN, negative, a string) is not a count: null.
+ */
+export function callsOf(value: Record<string, unknown>): number | null {
+ const direct = whole(value.calls)
+
+ if (direct !== null) return Math.min(direct, COUNT_CEILING)
+
+ const table = recordOf(value.calls)
+
+ if (table !== null) {
+ let sum = 0
+
+ for (const entry of Object.values(table).slice(0, CALLS_KEYS_MAX)) sum = Math.min(sum + (whole(entry) ?? 0), COUNT_CEILING)
+
+ return sum
+ }
+
+ const seen = whole(value.seen) ?? whole(value.checked)
+
+ return seen === null ? null : Math.min(seen, COUNT_CEILING)
+}
+
const SUMMARY_MAX = 120
const VERSION = /^[0-9][0-9A-Za-z.+-]{0,15}$/
const CLASS_TESTS: readonly [DenyClass, RegExp][] = [
@@ -53,16 +81,18 @@ export function parseModStatus(name: string, text: string | null, fileMs: number
if (value === null || value.version !== 1) return null
+ const denied = denyClassOf(value.lastDenied) ?? denyClassOf(value.lastReason) ?? denyClassOf(value.lastBlocked)
+
return {
name: name.slice(0, -4),
guard: typeof value.guard === 'boolean' ? value.guard : null,
- calls: whole(value.calls),
+ calls: callsOf(value),
blocked: whole(value.blocked) ?? 0,
updatedMs: whole(value.updatedMs),
startedMs: whole(value.startedMs),
...(modVersionOf(value.modVersion) !== null && { modVersion: modVersionOf(value.modVersion) as string }),
...(plain(value.summary, SUMMARY_MAX) !== '' && { summary: plain(value.summary, SUMMARY_MAX) }),
- ...(denyClassOf(value.lastDenied) !== null && { lastDenied: denyClassOf(value.lastDenied) as DenyClass }),
+ ...(denied !== null && { lastDenied: denied }),
...(fileMs !== null && fileMs >= 0 && { fileMs }),
}
}
diff --git a/plugins/ruflo-console/hooks/version.ts b/plugins/ruflo-console/hooks/version.ts
index dfb91bb3a2..0c8c0d39ef 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.9'
+export const CONSOLE_VERSION = '0.33.10'
diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.sh
index c51c37750a..2592c10ea3 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.9"
+step "1. plugin.json declares ruflo-console 0.33.10"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
- && grep -q '"version": "0.33.9"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
+ && grep -q '"version": "0.33.10"' "$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/mods-section.spec.ts b/plugins/ruflo-console/tests/mods-section.spec.ts
index 07463922b3..83db229823 100644
--- a/plugins/ruflo-console/tests/mods-section.spec.ts
+++ b/plugins/ruflo-console/tests/mods-section.spec.ts
@@ -10,7 +10,7 @@ import { readSnapshot } from '../hooks/data/snapshot'
import type { Actions } from '../hooks/views/common'
import { roomOf } from '../hooks/room'
import { viewText } from '../hooks/views/pane'
-import { denyClassOf, isStale, MODS_MAX_BYTES, MODS_MAX_FILES, MODS_STALE_MS, orderMods, parseModStatus, readMods, type ModRow } from '../hooks/data/mods'
+import { callsOf, denyClassOf, isStale, MODS_MAX_BYTES, MODS_MAX_FILES, MODS_STALE_MS, orderMods, parseModStatus, readMods, type ModRow } from '../hooks/data/mods'
const status = (extra: Record<string, unknown> = {}) => JSON.stringify({ version: 1, updatedMs: 1_000, calls: 5, blocked: 0, startedMs: 500, guard: true, ...extra })
const row = (name: string, blocked: number, updatedMs: number | null): ModRow => ({ name, guard: true, calls: 1, blocked, updatedMs, startedMs: null })
@@ -104,6 +104,59 @@ describe('readMods', () => {
})
})
+describe('wider status shapes (mod-status-files recommendation 1)', () => {
+ const calls = (extra: Record<string, unknown>) => parseModStatus('x-mod', JSON.stringify({ version: 1, ...extra }))?.calls
+
+ it('sums a calls object over its numeric values and ignores the rest', () => {
+ expect(calls({ calls: { route: 3, deny: 2, note: 'x', nested: { a: 9 }, neg: -4, nan: null } })).toBe(5)
+ expect(calls({ calls: {} })).toBe(0)
+ })
+
+ it('reads seen, then checked, when there is no calls; a real calls wins', () => {
+ expect(calls({ seen: 7, checked: 3 })).toBe(7)
+ expect(calls({ checked: 3 })).toBe(3)
+ expect(calls({ calls: 2, seen: 7 })).toBe(2)
+ expect(calls({ calls: 'many', seen: 4 })).toBe(4)
+ expect(calls({ blocked: 1 })).toBeNull()
+ })
+
+ it('is bounded and never throws on hostile shapes', () => {
+ expect(calls({ calls: 1e300 })).toBe(Number.MAX_SAFE_INTEGER)
+ expect(calls({ calls: { a: 1e300, b: 1e300 } })).toBe(Number.MAX_SAFE_INTEGER)
+ expect(calls({ seen: 1e300 })).toBe(Number.MAX_SAFE_INTEGER)
+ expect(calls({ calls: [1, 2, 3] })).toBeNull()
+ expect(calls({ calls: -1 })).toBeNull()
+ expect(calls({ seen: -1, checked: Number.NaN })).toBeNull()
+ expect(calls({ seen: [4], checked: { a: 1 } })).toBeNull()
+ expect(calls({ calls: Object.fromEntries(Array.from({ length: 500 }, (_, i) => [`k${i}`, 1])) })).toBe(64)
+ expect(callsOf(Object.create(null) as Record<string, unknown>)).toBeNull()
+ })
+
+ it('maps lastReason and lastBlocked to the refusal class, lastDenied first', () => {
+ const denied = (extra: Record<string, unknown>) => parseModStatus('x-mod', JSON.stringify({ version: 1, ...extra }))?.lastDenied
+
+ expect(denied({ lastReason: 'reads a .env file' })).toBe('secret')
+ expect(denied({ lastBlocked: 'curl to a host' })).toBe('network')
+ expect(denied({ lastDenied: 'rm -rf', lastReason: 'token' })).toBe('destructive')
+ expect(denied({ lastReason: 42, lastBlocked: ['secret'] })).toBeUndefined()
+ expect(denied({ lastReason: { a: 'secret' } })).toBeUndefined()
+ expect(denied({ lastReason: '', lastBlocked: 'odd thing' })).toBe('other')
+ })
+
+ it('never keeps the raw reason text, and strips control and bidi characters before classing', () => {
+ const parsed = parseModStatus('x-mod', JSON.stringify({ version: 1, lastReason: '\u202esecret\u0007 /home/me/.ssh/id_rsa ' + 'x'.repeat(5000) }))
+
+ expect(parsed?.lastDenied).toBe('secret')
+ expect(JSON.stringify(parsed)).not.toContain('id_rsa')
+ })
+
+ it('shows the three real shapes in one scan', async () => {
+ const mods = await readMods(fakeFs({ 'a-mod': status(), 'b-mod': JSON.stringify({ version: 1, calls: { x: 4, y: 6 }, blocked: 1, updatedMs: 5 }), 'c-mod': JSON.stringify({ version: 1, seen: 9, blocked: 2, lastReason: 'token leak', updatedMs: 6 }) }), new Map(), '/p')
+
+ expect(Object.fromEntries(mods.rows.map(mod => [mod.name, [mod.calls, mod.lastDenied ?? null]]))).toEqual({ a: [5, null], b: [10, null], c: [9, 'secret'] })
+ })
+})
+
describe('the Mods section on the pages', () => {
const act = new Proxy(() => undefined, { get: () => act, apply: () => undefined }) as unknown as Actions
const empty: ReaderFs = { read: () => Promise.reject(new Error('ENOENT')), stat: () => Promise.reject(new Error('ENOENT')), list: () => Promise.reject(new Error('ENOENT')) }