Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(ruflo-console): the Learning pulse charts mean one thing each and line up (0.33.22)

ruv84b7be3b342a
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.json
index 23c7ee1464..00aec7528b 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.20",
+ "version": "0.33.22",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-console/hooks/version.ts b/plugins/ruflo-console/hooks/version.ts
index a2b7983d6b..f40cd4e40e 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.20'
+export const CONSOLE_VERSION = '0.33.22'
diff --git a/plugins/ruflo-console/hooks/views/learning-pulse.ts b/plugins/ruflo-console/hooks/views/learning-pulse.ts
index 08875996ef..ff9d04eaaa 100644
--- a/plugins/ruflo-console/hooks/views/learning-pulse.ts
+++ b/plugins/ruflo-console/hooks/views/learning-pulse.ts
@@ -1,18 +1,18 @@
import type { RenderElement } from 'claude-code'
-import { gauge, sparkline } from '../memory-lines'
-import { section, count, row, text, THEME, type Ctx } from './common'
+import { gauge } from '../memory-lines'
+import { section, count, row, THEME, type Ctx } from './common'
import { stagesOf } from './frames'
+import { note, subhead } from './subhead'
import { spinAt } from '../spinner'
/** One step of the animation every 160 ms; nothing moves while the pane is hidden (the frame loop stops). */
const beat = (ctx: Ctx, ms: number): number => Math.floor(ctx.nowMs / ms)
/**
- * The learning pulse, folded in its own section: text charts that move while the pane is open. A marker travels the pipeline
- * (RETRIEVE β†’ JUDGE β†’ DISTILL β†’ CONSOLIDATE), the router's model mix is a bar chart with a highlight that sweeps along each bar, and
- * the success rate is a sparkline with a scanning cursor. While a learning action runs the marker quickens and the active stage
- * shows the spinner, so activity reads at a glance. They draw what was measured and nothing else: no data, no chart.
+ * The learning pulse, folded in its own section: a marker travels the pipeline (RETRIEVE β†’ JUDGE β†’ DISTILL β†’ CONSOLIDATE), quickening while a
+ * learning action runs. Below it, three labelled groups of bars that line up: the router's model mix (each model's share of all routed tasks),
+ * the last routed outcomes (one cell each), and the store's sizes (relative to the largest). They draw what was measured and nothing else: no data, no chart.
*/
export function pulseRows(ctx: Ctx): RenderElement[] {
const { state } = ctx
@@ -21,6 +21,7 @@ export function pulseRows(ctx: Ctx): RenderElement[] {
const stages = stagesOf(state)
const at = beat(ctx, running ? 250 : 700) % Math.max(1, stages.length)
+ rows.push(subhead(ctx, 'Pipeline', running ? 'learning now' : 'the marker shows the active stage'))
rows.push(
row(
ctx,
@@ -32,34 +33,39 @@ export function pulseRows(ctx: Ctx): RenderElement[] {
),
)
+ const columns = ctx.columns
+ const width = Math.max(12, Math.min(32, columns - 46))
+ /** One chart row: a fixed label column, a bar of one fixed width, the number right-aligned, then a dim extra. Every group lines up. */
+ const chart = (label: string, bar: string, value: string, color: string, extra = ''): RenderElement =>
+ row(ctx, [
+ ctx.kit.Text({ dimColor: true, children: ` ${label.slice(0, 14).padEnd(14)} ` }),
+ ctx.kit.Text({ color, children: bar }),
+ ctx.kit.Text({ bold: true, children: ` ${value.padStart(6)}` }),
+ ...(extra === '' ? [] : [ctx.kit.Text({ dimColor: true, children: ` ${extra}` })]),
+ ])
+
const router = state.snapshot?.router ?? null
const mix = router?.distribution.filter(entry => entry.count > 0) ?? []
+ const total = mix.reduce((sum, entry) => sum + entry.count, 0)
- if (mix.length > 0) {
- const top = Math.max(...mix.map(entry => entry.count))
- const width = Math.max(8, Math.min(32, ctx.columns - 36))
- const sweep = beat(ctx, 160)
-
- for (const entry of mix.slice(0, 6)) {
- const bar = gauge(entry.count, top, width).split('')
- const filled = bar.filter(cell => cell === 'β–ˆ').length
+ rows.push(subhead(ctx, 'Model mix', mix.length > 0 ? `share of ${count(total)} routed task${total === 1 ? '' : 's'}` : 'n/a'))
- if (filled > 1) bar[sweep % filled] = 'β–“'
- rows.push(text(ctx, ` ${entry.model.slice(0, 14).padEnd(14)} ${bar.join('')} ${count(entry.count)}`, { color: THEME.ok }))
- }
- } else rows.push(text(ctx, ' model mix: n/a β€” no .swarm/model-router-state.json', { dimColor: true }))
+ if (mix.length > 0) {
+ // Each bar is that model's share of ALL routed tasks, so the bars add up to the whole: scaling to the busiest model would draw it full whatever its share.
+ for (const entry of mix.slice(0, 6)) rows.push(chart(entry.model, gauge(entry.count, total, width), count(entry.count), THEME.ok, `${Math.round((entry.count / total) * 100)}%`))
+ if (mix.length > 6) rows.push(note(ctx, `+ ${mix.length - 6} more model${mix.length - 6 === 1 ? '' : 's'}`))
+ } else rows.push(note(ctx, 'no .swarm/model-router-state.json: nothing routed yet'))
const points = state.snapshot?.outcomes?.points ?? []
+ const window = points.slice(-24)
+ const passed = window.filter(point => point.ok).length
- if (points.length > 1) {
- // Running success rate over the last 24 outcomes, as eight-level bars; the cursor sweeps left to right.
- const window = points.slice(-24)
- const rates = window.map((_, i) => Math.round((window.slice(0, i + 1).filter(point => point.ok).length / (i + 1)) * 8))
- const bars = sparkline(rates.map(rate => rate + 1)).split('')
+ rows.push(subhead(ctx, 'Outcomes', window.length > 1 ? `${passed} of the last ${window.length} succeeded Β· ${Math.round((passed / window.length) * 100)}%` : 'n/a'))
- bars[beat(ctx, 200) % bars.length] = '┃'
- rows.push(text(ctx, ` success ${bars.join('')} ${window.filter(point => point.ok).length}/${window.length} of the last ${window.length}`, { color: THEME.ok }))
- } else rows.push(text(ctx, ' success rate: n/a β€” fewer than two routed outcomes', { dimColor: true }))
+ if (window.length > 1) {
+ // One cell per routed outcome, oldest first: a full cell passed, a short one failed. The chart is the data, with no cursor drawn over it.
+ rows.push(chart('last outcomes', window.map(point => (point.ok ? 'β–‡' : 'β–‚')).join(''), `${passed}/${window.length}`, passed === window.length ? THEME.ok : THEME.warn))
+ } else rows.push(note(ctx, 'fewer than two routed outcomes so far'))
const neural = state.snapshot?.neural ?? null
@@ -67,10 +73,11 @@ export function pulseRows(ctx: Ctx): RenderElement[] {
const sizes = { trajectories: neural.trajectories ?? 0, patterns: neural.patterns ?? 0, signals: neural.signals ?? 0 }
const top = Math.max(1, sizes.trajectories, sizes.patterns, sizes.signals)
- for (const [name, value] of Object.entries(sizes)) rows.push(text(ctx, ` ${name.padEnd(14)} ${gauge(value, top, 24)} ${count(value)}`, { color: THEME.info }))
+ rows.push(subhead(ctx, 'Store', 'bars are relative to the largest'))
+ for (const [name, value] of Object.entries(sizes)) rows.push(chart(name, gauge(value, top, width), count(value), THEME.info))
}
const live = state.lab.running?.id.startsWith('nn-') === true
- return section(ctx, 'learn-pulse', 'Learning pulse', live ? `${spinAt(ctx.nowMs)} learning now Β· the marker quickens` : 'live: the marker moves, the data is what ruflo measured', rows, true)
+ return section(ctx, 'learn-pulse', 'Learning pulse', live ? `${spinAt(ctx.nowMs)} learning now Β· the marker quickens` : 'live: the pipeline marker moves; the bars are what ruflo measured', rows, true)
}
diff --git a/plugins/ruflo-console/hooks/views/subhead.ts b/plugins/ruflo-console/hooks/views/subhead.ts
new file mode 100644
index 0000000000..ade5dec963
--- /dev/null
+++ b/plugins/ruflo-console/hooks/views/subhead.ts
@@ -0,0 +1,16 @@
+/** Small layout pieces for views that group their rows into labelled blocks: a heading rule and a wrapped, dim explanation. */
+import type { RenderElement } from 'claude-code'
+
+import { row, THEME, type Ctx } from './common'
+
+/** A sub-heading inside a card: the title, a rule, and what the block summarises at the right, so each block reads on its own. */
+export function subhead(ctx: Ctx, title: string, right = ''): RenderElement {
+ const head = ` ${title} `
+ const tail = right === '' ? '' : ` ${right} `
+ const fill = Math.max(2, ctx.columns - 12 - head.length - tail.length)
+
+ return row(ctx, [ctx.kit.Text({ bold: true, color: THEME.head, children: head }), ctx.kit.Text({ dimColor: true, children: '─'.repeat(fill) }), ...(tail === '' ? [] : [ctx.kit.Text({ dimColor: true, children: tail })])])
+}
+
+/** An explanation under a block: dim, wrapped (never clipped), indented one column. */
+export const note = (ctx: Ctx, words: string): RenderElement => ctx.kit.Text({ dimColor: true, wrap: 'wrap', children: ` ${words}` })
diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.sh
index 4940f0d5ba..f846edbf9d 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.20"
+step "1. plugin.json declares ruflo-console 0.33.22"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
- && grep -q '"version": "0.33.20"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
+ && grep -q '"version": "0.33.22"' "$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/learning-pulse.spec.ts b/plugins/ruflo-console/tests/learning-pulse.spec.ts
new file mode 100644
index 0000000000..181dcc9f04
--- /dev/null
+++ b/plugins/ruflo-console/tests/learning-pulse.spec.ts
@@ -0,0 +1,86 @@
+/** The Learning pulse's charts: every group lines up, each bar means one thing, and nothing is drawn over the data. */
+import { describe, expect, it } from 'vitest'
+
+import { newState } from '../hooks/state'
+import type { Ctx } from '../hooks/views/common'
+import { pulseRows } from '../hooks/views/learning-pulse'
+
+type El = { kind: string; props: Record<string, unknown> }
+const make = (kind: string) => (props: Record<string, unknown>): El => ({ kind, props })
+const kit = { Box: make('Box'), Text: make('Text'), Button: make('Button'), Input: make('Input') }
+const act = new Proxy({}, { get: () => () => undefined }) as unknown as Ctx['act']
+const flat = (node: unknown): El[] => {
+ if (Array.isArray(node)) return node.flatMap(flat)
+ if (typeof node !== 'object' || node === null) return []
+ const el = node as El
+ const children = el.props.children
+
+ return [el, ...(Array.isArray(children) ? children.flatMap(flat) : flat(children))]
+}
+/** Each drawn row as one string: its Text pieces joined in order. */
+const linesOf = (nodes: unknown): string[] =>
+ flat(nodes)
+ .filter(el => el.kind === 'Box' && el.props.flexDirection === 'row')
+ .map(box => flat(box.props.children).filter(el => el.kind === 'Text').map(el => String(el.props.children)).join(''))
+
+function draw(snapshot: Record<string, unknown>, columns = 120): string[] {
+ const state = newState({ boot: false })
+
+ state.snapshot = snapshot as never
+
+ return linesOf(pulseRows({ kit, state, act, columns, nowMs: 5_000, pictures: new Map() } as unknown as Ctx))
+}
+
+const SNAP = {
+ router: { distribution: [{ model: 'sonnet', count: 6 }, { model: 'opus', count: 5 }] },
+ outcomes: { points: Array.from({ length: 9 }, () => ({ ok: true })) },
+ neural: { trajectories: 32_253, patterns: 32_236, signals: 20_200 },
+}
+
+describe('the learning pulse', () => {
+ it('groups its charts under headings that say what each measures', () => {
+ const lines = draw(SNAP)
+
+ expect(lines.some(line => /Pipeline ─+/.test(line))).toBe(true)
+ expect(lines.some(line => /Model mix ─+ share of 11 routed tasks/.test(line))).toBe(true)
+ expect(lines.some(line => /Outcomes ─+ 9 of the last 9 succeeded Β· 100%/.test(line))).toBe(true)
+ expect(lines.some(line => /Store ─+ bars are relative to the largest/.test(line))).toBe(true)
+ })
+
+ it('draws the model mix as each model\'s share of all routed tasks, so no bar is full unless it is the whole', () => {
+ const lines = draw(SNAP)
+ const sonnet = lines.find(line => line.includes('sonnet')) ?? ''
+ const opus = lines.find(line => line.includes('opus')) ?? ''
+ const filled = (line: string): number => (line.match(/β–ˆ/g) ?? []).length
+
+ expect(sonnet).toMatch(/55%/)
+ expect(opus).toMatch(/45%/)
+ expect(filled(sonnet)).toBeGreaterThan(filled(opus))
+ expect(filled(sonnet) + (sonnet.match(/β–‘/g) ?? []).length).toBe(filled(opus) + (opus.match(/β–‘/g) ?? []).length)
+ expect(filled(sonnet)).toBeLessThan(sonnet.match(/[β–ˆβ–‘]/g)?.length ?? 0)
+ // A lone model is the whole: full.
+ expect(draw({ ...SNAP, router: { distribution: [{ model: 'haiku', count: 4 }] } }).find(line => line.includes('haiku'))).toMatch(/β–ˆ{10,}(?!β–‘)/)
+ })
+
+ it('keeps every bar the same width, in a fixed label column, with nothing drawn over the data', () => {
+ const lines = draw(SNAP)
+ const bars = lines.filter(line => /[β–ˆβ–‘]{8,}/.test(line)).map(line => (/[β–ˆβ–‘β–‡β–‚]+/.exec(line.replace(/^[^β–ˆβ–‘β–‡β–‚]*/, ''))?.[0] ?? ''))
+ const rows = lines.filter(line => /sonnet|opus|trajectories|patterns|signals/.test(line))
+
+ expect(new Set(rows.map(line => line.slice(0, 16))).size).toBe(rows.length)
+ expect(rows.every(line => /^ \S+ *\s{1,}/.test(line))).toBe(true)
+ expect(new Set(bars.map(bar => bar.length)).size).toBe(1)
+ for (const line of lines) expect(line).not.toMatch(/[▓┃]/)
+ })
+
+ it('draws one cell per recent outcome (a short cell for a failure) and says plainly when there is no data', () => {
+ const mixed = draw({ ...SNAP, outcomes: { points: [{ ok: true }, { ok: false }, { ok: true }] } })
+
+ expect(mixed.find(line => line.includes('last outcomes'))).toMatch(/β–‡β–‚β–‡ +2\/3/)
+ expect(mixed.some(line => /2 of the last 3 succeeded Β· 67%/.test(line))).toBe(true)
+
+ const empty = draw({ router: { distribution: [] }, outcomes: { points: [] } })
+
+ expect(empty.join('\n')).not.toMatch(/[β–ˆβ–‘β–‡β–‚]/)
+ })
+})