π 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
fix(ruflo-console): the Router block says why it is empty and does not stretch a flat curve over nine outcomes
ruv878dae104dd2
diff --git a/plugins/ruflo-console/hooks/views/learning.ts b/plugins/ruflo-console/hooks/views/learning.tsindex b44d8032ae..350bbf582c 100644--- a/plugins/ruflo-console/hooks/views/learning.ts+++ b/plugins/ruflo-console/hooks/views/learning.ts@@ -64,6 +64,11 @@ export function learningView(ctx: Ctx): RenderElement {const router = snap?.router ?? nullconst neural = snap?.neural ?? nullconst intel = live<Intelligence>(state.probes.get('intelligence'))+ // The mod owns `route` only where no classic route hook runs it (ADR-404): with `owned` empty it routes nothing and records nothing here.+ const owned = state.ruflo.snapshot?.owned+ const classicOwnsRoute = owned !== undefined && !owned.includes('route')+ const lastOutcomeMs = outcomes?.points[outcomes.points.length - 1]?.atMs+ const staleOutcomes = lastOutcomeMs !== undefined && nowMs - lastOutcomeMs > 24 * 3_600_000const routerRows: RenderElement[] = [kv(ctx,@@ -72,18 +77,24 @@ export function learningView(ctx: Ctx): RenderElement {? `${route.agent} ${pct(route.confidence)} Β· ${route.matched ? 'keyword match' : 'no match, default'} Β· ${route.reason} (a prior, not a calibrated probability)`: state.ruflo.snapshot === null? 'n/a β ruflo-mods not seated, so no in-process route'- : 'n/a β no prompt routed yet this session',+ : classicOwnsRoute+ ? 'n/a β in this project the classic hook-handler owns routing, so ruflo-mods stands down and records no picks (see /ruflo-mods)'+ : 'n/a β no prompt routed yet this session',),kv(ctx,'routed outcomes',outcomes === null || outcomes.total === 0? 'n/a β no routing-outcomes.json'- : `${outcomes.successes}/${outcomes.total} succeeded (${pct(outcomes.successes / outcomes.total)} success rate, N=${outcomes.total}) Β· last ${ago(outcomes.points[outcomes.points.length - 1]?.atMs, nowMs)}`,- outcomes !== null && outcomes.total > 0 ? THEME.info : undefined,+ : `${outcomes.successes}/${outcomes.total} succeeded (${pct(outcomes.successes / outcomes.total)} success rate, N=${outcomes.total}) Β· last ${ago(lastOutcomeMs, nowMs)}${staleOutcomes ? ' Β· nothing recorded since' : ''}`,+ outcomes !== null && outcomes.total > 0 ? (staleOutcomes ? THEME.warn : THEME.info) : undefined,),- picture(ctx, 'curve', `running success rate over ${outcomes?.total ?? 0} outcomes`),- text(ctx, 'running success rate of routed tasks, oldest left (router accuracy over N outcomes); new outcomes draw in', { dimColor: true }),+ // A curve needs a history: with a handful of outcomes it is a flat line stretched across the pane, so show one cell per outcome instead.+ ...((outcomes?.points.length ?? 0) < 12+ ? outcomes === null || outcomes.points.length === 0+ ? []+ : [kv(ctx, 'recent outcomes', `${outcomes.points.map(point => (point.ok ? 'β' : 'β')).join('')} oldest left Β· a full cell passed, a short one failed`, THEME.ok)]+ : [picture(ctx, 'curve', `running success rate over ${outcomes?.total ?? 0} outcomes`), text(ctx, 'running success rate of routed tasks, oldest left (router accuracy over N outcomes); new outcomes draw in', { dimColor: true })]),kv(ctx,'model router',diff --git a/plugins/ruflo-console/tests/learning-router.spec.ts b/plugins/ruflo-console/tests/learning-router.spec.tsnew file mode 100644index 0000000000..5fea85ab53--- /dev/null+++ b/plugins/ruflo-console/tests/learning-router.spec.ts@@ -0,0 +1,61 @@+/** The Learning page's Router block says why it is empty, flags a stale history, and does not stretch a flat curve over a handful of outcomes. */+import { describe, expect, it } from 'vitest'++import { newState } from '../hooks/state'+import type { Ctx } from '../hooks/views/common'+import { learningView } from '../hooks/views/learning'++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))]+}+const NOW = 10 * 86_400_000+const points = (n: number, atMs: number, failAt = -1) => Array.from({ length: n }, (_, i) => ({ ok: i !== failAt, atMs: atMs + i }))++function lines(opts: { owned: readonly string[] | null; n: number; lastMs: number; failAt?: number }): string {+ const state = newState({ boot: false })++ state.snapshot = { outcomes: { total: opts.n, successes: opts.failAt === undefined || opts.failAt < 0 ? opts.n : opts.n - 1, points: points(opts.n, opts.lastMs - opts.n, opts.failAt) }, router: null, neural: null, sona: null } as never+ state.ruflo = { ...state.ruflo, snapshot: opts.owned === null ? null : ({ owned: opts.owned } as never), route: null } as never++ return flat(learningView({ kit, state, act, columns: 130, nowMs: NOW, pictures: new Map() } as unknown as Ctx))+ .filter(el => el.kind === 'Text')+ .map(el => String(el.props.children))+ .join('\n')+}++describe('the Router block', () => {+ it('says why there is no live pick when the classic hook owns routing here', () => {+ const text = lines({ owned: [], n: 9, lastMs: NOW - 8 * 86_400_000 })++ expect(text).toContain('the classic hook-handler owns routing')+ expect(text).toContain('ruflo-mods stands down and records no picks')+ expect(text).not.toContain('no prompt routed yet this session')+ })++ it('keeps the old wording where the mod does own routing, and when the mod is not seated', () => {+ expect(lines({ owned: ['route'], n: 9, lastMs: NOW })).toContain('no prompt routed yet this session')+ expect(lines({ owned: null, n: 9, lastMs: NOW })).toContain('ruflo-mods not seated')+ })++ it('flags an outcome history nothing has been added to for a day', () => {+ expect(lines({ owned: [], n: 9, lastMs: NOW - 8 * 86_400_000 })).toMatch(/last 8d ago Β· nothing recorded since/)+ expect(lines({ owned: [], n: 9, lastMs: NOW - 3_600_000 })).not.toContain('nothing recorded since')+ })++ it('shows a handful of outcomes as one cell each, not a curve, and keeps the curve for a real history', () => {+ const few = lines({ owned: [], n: 9, lastMs: NOW, failAt: 3 })++ expect(few).toContain('βββββββββ')+ expect(few).not.toContain('running success rate of routed tasks')+ expect(lines({ owned: [], n: 30, lastMs: NOW })).toContain('running success rate of routed tasks')+ })+})