🌊 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): read-only Research section on the Missions page (ADR-438)
ruv8a50535d6b82
diff --git a/plugins/ruflo-console/hooks/controller.ts b/plugins/ruflo-console/hooks/controller.tsindex 9b9b3c3cc8..fe30c86610 100644--- a/plugins/ruflo-console/hooks/controller.ts+++ b/plugins/ruflo-console/hooks/controller.ts@@ -5,7 +5,7 @@*/import { actionsOf } from './bindings'import type { Catalog } from './data/catalog'-import { PROBES, probeArgv, type ProbeResult } from './data/cli'+import { PROBES, probeArgv, probeReady, type ProbeResult } from './data/cli'import { X_PROBES } from './data/xruv'import { diffEvents, record } from './data/events'import { plain } from './data/parse'@@ -207,7 +207,7 @@ export function createController(state: State, host: Host): Controller {lastAttempt.set(probe.id, Date.now())try {- const result = await host.run(probeArgv(probe, state.options.cli), probe.timeoutMs)+ const result = await host.run(probeArgv(probe, state.options.cli, state), probe.timeoutMs)const value = result.exitCode === 0 ? (probe.parse(result.stdout) as unknown) : nullstate.probes.set(@@ -235,7 +235,7 @@ export function createController(state: State, host: Host): Controller {entry =>(isVisible() || force) &&entry.views.includes(state.view) &&- (!entry.isNetwork || state.options.federationNetwork) &&+ (!entry.isNetwork || state.options.federationNetwork) && probeReady(entry, state) &&(force || (state.probes.get(entry.id)?.isRunning !== true && now - (lastAttempt.get(entry.id) ?? 0) >= entry.everyMs)),)diff --git a/plugins/ruflo-console/hooks/data/cli.ts b/plugins/ruflo-console/hooks/data/cli.tsindex a32724bb89..c06c00e3a3 100644--- a/plugins/ruflo-console/hooks/data/cli.ts+++ b/plugins/ruflo-console/hooks/data/cli.ts@@ -5,8 +5,9 @@* fetches a manifest from GitHub).*/import { idOf, msOf, numberOf, plain, recordOf, stringOf, valuesOf } from './parse'+import { researchProbe } from './research'-import { CLI_PREFIXES, type CliChoice, type ViewId } from '../state'+import { CLI_PREFIXES, type CliChoice, type State, type ViewId } from '../state'export type { ViewId }@@ -15,6 +16,8 @@ export type Probe<T> = {args: readonly string[]/** A local executable for a capability check, or an offline-only ruflo read. */argv?: readonly string[]+ /** An argv that depends on what is installed; null while it cannot be built, and the probe then does not run. */+ argvOf?: (state: State) => readonly string[] | nullisOffline?: boolean/** The views that draw it: a probe runs only while one of them is in front (the overview's run with the bar too). */views: readonly ViewId[]@@ -49,7 +52,10 @@ const objectOf = (stdout: string) => recordOf(jsonAfter(stdout))const exec = (tool: string, params: Record<string, unknown>) => ['mcp', 'exec', '-t', tool, '-p', JSON.stringify(params)] as const/** Offline probes never let the download-enabled CLI choice reach the registry. */-export const probeArgv = (probe: Pick<Probe<unknown>, 'args' | 'argv' | 'isOffline'>, cli: CliChoice): readonly string[] => probe.argv ?? [...CLI_PREFIXES[probe.isOffline && cli === 'npx' ? 'npx-offline' : cli], ...probe.args]+export const probeArgv = (probe: Pick<Probe<unknown>, 'args' | 'argv' | 'argvOf' | 'isOffline'>, cli: CliChoice, state?: State): readonly string[] => (state === undefined ? undefined : probe.argvOf?.(state)) ?? probe.argv ?? [...CLI_PREFIXES[probe.isOffline && cli === 'npx' ? 'npx-offline' : cli], ...probe.args]++/** A probe with an install-dependent argv runs only while that argv can be built; every other probe is always ready. */+export const probeReady = (probe: Pick<Probe<unknown>, 'argvOf'>, state: State): boolean => probe.argvOf === undefined || probe.argvOf(state) !== null/** Help only: older Claude builds must not get a guessed configuration command. */export const budgetConfigProbe: Probe<boolean> = {@@ -469,7 +475,7 @@ export const registryProbe: Probe<Registry> = {},}-export const PROBES = [versionProbe, memoryProbe, namespacesProbe, scoreProbe, flywheelProbe, auditProbe, intelligenceProbe, peersProbe, channelsProbe, rosterProbe, registryProbe, budgetConfigProbe, modelStatsProbe] as const+export const PROBES = [versionProbe, memoryProbe, namespacesProbe, scoreProbe, flywheelProbe, auditProbe, intelligenceProbe, peersProbe, channelsProbe, rosterProbe, registryProbe, budgetConfigProbe, modelStatsProbe, researchProbe] as constexport type ProbeId = (typeof PROBES)[number]['id']diff --git a/plugins/ruflo-console/hooks/data/facts.ts b/plugins/ruflo-console/hooks/data/facts.tsindex dae9e8e470..d6bd0a48cb 100644--- a/plugins/ruflo-console/hooks/data/facts.ts+++ b/plugins/ruflo-console/hooks/data/facts.ts@@ -156,7 +156,7 @@ export function parseHelpers(text: string | null): { version: string; files: strreturn { version: stringOf(manifest.version, 20) ?? 'unknown', files, isSigned: typeof value.signature === 'string' && value.signature.length > 20, ...(algorithm !== undefined && { algorithm }) }}-export type Installed = { id: string; name: string; marketplace: string; version: string; scope: string; updatedMs?: number }+export type Installed = { id: string; name: string; marketplace: string; version: string; scope: string; updatedMs?: number; installPath?: string }/** `~/.claude/plugins/installed_plugins.json` (version 2): every installed plugin, `name@marketplace`. */export function parseInstalled(text: string | null): Installed[] | null {@@ -178,8 +178,9 @@ export function parseInstalled(text: string | null): Installed[] | null {}const updatedMs = msOf(entry.lastUpdated)+ const installPath = typeof entry.installPath === 'string' && entry.installPath.length <= 300 ? entry.installPath : undefined- return [{ id: `${name}@${marketplace}`, name, marketplace, version: stringOf(entry.version, 30) ?? '?', scope: stringOf(entry.scope, 12) ?? '?', ...(updatedMs !== undefined && { updatedMs }) }]+ return [{ id: `${name}@${marketplace}`, name, marketplace, version: stringOf(entry.version, 30) ?? '?', scope: stringOf(entry.scope, 12) ?? '?', ...(updatedMs !== undefined && { updatedMs }), ...(installPath !== undefined && { installPath }) }]})}diff --git a/plugins/ruflo-console/hooks/data/research.ts b/plugins/ruflo-console/hooks/data/research.tsnew file mode 100644index 0000000000..fe85684c30--- /dev/null+++ b/plugins/ruflo-console/hooks/data/research.ts@@ -0,0 +1,107 @@+/**+ * The Missions page's Research section (ADR-438). The mod cannot read memory itself, so it asks the ruflo-goals plugin's+ * `research-list.mjs` (installed under Claude Code's plugin cache) for the newest research records as one local JSON+ * document. Local only: nothing here reaches the network, and the script path comes from `installed_plugins.json`,+ * validated, never from typed text. Read-only: the section stores and starts nothing.+ */+import type { Probe } from './cli'+import { jsonObject, msOf, numberOf, recordOf, stringOf } from './parse'++import type { State } from '../state'++export const GOALS_PLUGIN = 'ruflo-goals@ruflo'+/** The first release with `research-list.mjs`: an older install has no script to run. */+export const RESEARCH_FROM = [0, 3, 0] as const++export type Grade = 'High' | 'Medium' | 'Low'+export type ResearchRecord = {+ question: string+ status: 'done' | 'truncated' | 'failed' | 'unknown'+ depth: string+ findings: number+ grades: Record<Grade, number>+ /** USD, or null when the run did not know: never invented. */+ spentUsd: number | null+ capUsd: number | null+ atMs: number | null+ isScreened: boolean+}++const STATUSES: readonly string[] = ['done', 'truncated', 'failed']+const MAX_RECORDS = 8+const MAX_FINDINGS = 500++/** An absolute POSIX path of a plugin's install directory: no `..`, no control characters, no shell-looking text. */+export const safeInstallPath = (value: unknown): string | undefined => {+ const path = typeof value === 'string' ? value : ''++ return /^\/[A-Za-z0-9._@+/ -]{1,300}$/.test(path) && !path.split('/').includes('..') ? path : undefined+}++const countGrades = (findings: readonly unknown[]): Record<Grade, number> => {+ const grades: Record<Grade, number> = { High: 0, Medium: 0, Low: 0 }++ for (const item of findings) {+ const grade = recordOf(item)?.grade++ if (grade === 'High' || grade === 'Medium' || grade === 'Low') grades[grade] += 1+ }++ return grades+}++/** What `research-list.mjs --limit N` prints: `{ version: 1, records: [...] }`, newest first. Null for anything else. */+export function parseResearch(stdout: string): ResearchRecord[] | null {+ const value = jsonObject(stdout)++ if (value === null || value.version !== 1 || !Array.isArray(value.records)) return null++ const records = value.records.slice(0, MAX_RECORDS).flatMap((item): ResearchRecord[] => {+ const record = recordOf(item)+ const question = stringOf(record?.question, 120)++ if (record === null || question === undefined) return []++ const findings = (Array.isArray(record.findings) ? record.findings : []).slice(0, MAX_FINDINGS)+ const spent = numberOf(record.spentUsd)+ const cap = numberOf(record.capUsd)+ const status = typeof record.status === 'string' && STATUSES.includes(record.status) ? (record.status as ResearchRecord['status']) : 'unknown'++ return [{+ question, status, depth: stringOf(record.depth, 12) ?? 'n/a', findings: findings.length, grades: countGrades(findings),+ spentUsd: spent !== undefined && spent >= 0 ? spent : null, capUsd: cap !== undefined && cap >= 0 ? cap : null,+ atMs: msOf(record.at) ?? null, isScreened: record.screened === true,+ }]+ })++ return records.sort((a, b) => (b.atMs ?? 0) - (a.atMs ?? 0))+}++const atLeast = (version: string, from: readonly number[]): boolean => {+ const parts = /^(\d+)\.(\d+)\.(\d+)/.exec(version)?.slice(1).map(Number) ?? []++ for (let i = 0; i < 3; i++) if ((parts[i] ?? 0) !== from[i]) return (parts[i] ?? 0) > (from[i] ?? 0)++ return parts.length === 3+}++/** Whether ruflo-goals is absent, too old to list research, or ready (with the script's directory). */+export function goalsOf(state: Pick<State, 'snapshot'>): { kind: 'absent' } | { kind: 'old'; version: string } | { kind: 'ready'; root: string } {+ const entry = state.snapshot?.plugins.installed?.find(plugin => plugin.id === GOALS_PLUGIN)+ const root = safeInstallPath(entry?.installPath)++ if (entry === undefined || root === undefined) return { kind: 'absent' }++ return atLeast(entry.version, RESEARCH_FROM) ? { kind: 'ready', root } : { kind: 'old', version: entry.version }+}++/** Where the plugin's list script is, or null when it is absent or too old (the probe then does not run). */+export function researchArgv(state: Pick<State, 'snapshot'>): readonly string[] | null {+ const goals = goalsOf(state)++ return goals.kind === 'ready' ? ['node', `${goals.root}/scripts/research-list.mjs`, '--limit', '8'] : null+}++export const researchProbe: Probe<ResearchRecord[]> = {+ id: 'research', args: [], argvOf: researchArgv, views: ['missions'], everyMs: 300_000, timeoutMs: 30_000, parse: parseResearch,+}diff --git a/plugins/ruflo-console/hooks/views/missions.ts b/plugins/ruflo-console/hooks/views/missions.tsindex c52a8e7eb0..67f41773a9 100644--- a/plugins/ruflo-console/hooks/views/missions.ts+++ b/plugins/ruflo-console/hooks/views/missions.ts@@ -3,6 +3,7 @@ import type { RenderElement } from 'claude-code'import { money, type Mission } from '../data/missions'import { attentionCount, clampCursor, freshnessOf, isLive, listLayout, spinAt } from '../mission-list'import { ago, kv, rule, text, THEME, type Ctx } from './common'+import { researchRows } from './research-section'const STATE_COLOR: Record<string, string> = { running: THEME.warn, verifying: THEME.warn, completed: THEME.ok, failed: THEME.bad, blocked: THEME.bad, paused: THEME.info, queued: THEME.info }@@ -43,6 +44,7 @@ function missionRows(ctx: Ctx, mission: Mission, isFirst: boolean): RenderElemenexport function observationRows(ctx: Ctx): RenderElement[] {const observation = ctx.state.snapshot?.missions ?? nullconst rows: RenderElement[] = [rule(ctx, 'Mission record', observation === null ? 'no observation' : `${observation.missions.length}${observation.isTruncated ? '+' : ''} · observed ${ago(observation.observedAtMs, ctx.nowMs)}`)]+ rows.push(...researchRows(ctx))if (observation === null) {rows.push(text(ctx, ' No mission record yet (ADR-406): create one from a goal in Plan.', { color: THEME.warn }))diff --git a/plugins/ruflo-console/hooks/views/research-section.ts b/plugins/ruflo-console/hooks/views/research-section.tsnew file mode 100644index 0000000000..1051887c5c--- /dev/null+++ b/plugins/ruflo-console/hooks/views/research-section.ts@@ -0,0 +1,45 @@+import type { RenderElement } from 'claude-code'++import { GOALS_PLUGIN, RESEARCH_FROM, goalsOf, type ResearchRecord } from '../data/research'+import { ago, button, clip, live, row, rule, sourceLine, text, THEME, type Ctx } from './common'++const STATUS_COLOR: Record<string, string> = { done: THEME.ok, truncated: THEME.warn, failed: THEME.bad }+const SHOWN = 5++/** Spend as the record states it: `n/a` when the run did not know, never a guess. */+export const spendText = (usd: number | null): string => (usd === null ? 'n/a' : `$${usd < 0.1 ? usd.toFixed(3) : usd.toFixed(2)}`)++const recordRows = (ctx: Ctx, record: ResearchRecord): RenderElement[] => [+ text(ctx, ` ${clip(record.question, Math.min(56, ctx.columns - 4))}`, { bold: true }),+ text(ctx, ` ${record.status} · ${record.findings} ${record.findings === 1 ? 'finding' : 'findings'} · ${ago(record.atMs, ctx.nowMs)}${record.isScreened ? '' : ' · unscreened'}`, STATUS_COLOR[record.status] === undefined ? { dimColor: true } : { color: STATUS_COLOR[record.status] as string }),+ text(ctx, ` High ${record.grades.High} · Medium ${record.grades.Medium} · Low ${record.grades.Low} · spend ${spendText(record.spentUsd)}`, { dimColor: true }),+]++/** The newest research records (ADR-438), read-only: from the ruflo-goals plugin's local list script, only while Missions is in front. */+export function researchRows(ctx: Ctx): RenderElement[] {+ const { state } = ctx+ const result = state.probes.get('research')+ const records = live<ResearchRecord[]>(result)+ const rows = [rule(ctx, 'Research', records === null ? 'deep-researcher records' : `newest ${Math.min(SHOWN, records.length)} · local`)]+ const goals = goalsOf(state)++ if (goals.kind !== 'ready') {+ const name = GOALS_PLUGIN.split('@')[0]++ rows.push(text(ctx, ` n/a — ${goals.kind === 'old' ? `${name} ${goals.version}; needs ${RESEARCH_FROM.join('.')} or newer` : `${name} is not installed`}`, { dimColor: true }))+ rows.push(row(ctx, [button(ctx, 'research-install-goals', goals.kind === 'old' ? 'Plugins: update it' : `Plugin Catalog: ${name}`, () => ctx.act.view(goals.kind === 'old' ? 'plugins' : 'market'))]))++ return rows+ }++ const source = sourceLine(result, ctx.nowMs, 'research')++ rows.push(text(ctx, ` ${records === null ? source.text : `records: ${GOALS_PLUGIN.split('@')[0]}, ${ago(result?.okAtMs, ctx.nowMs)}`}`, { dimColor: true, ...(source.color !== undefined && { color: source.color }) }))+ if (records === null) return rows++ if (records.length === 0) rows.push(text(ctx, ' No research records yet.', { dimColor: true }))+ for (const record of records.slice(0, SHOWN)) rows.push(...recordRows(ctx, record))+ rows.push(text(ctx, ' Read-only. Nothing is started here.', { dimColor: true }))++ return rows+}diff --git a/plugins/ruflo-console/tests/research.spec.ts b/plugins/ruflo-console/tests/research.spec.tsnew file mode 100644index 0000000000..c7748d7b36--- /dev/null+++ b/plugins/ruflo-console/tests/research.spec.ts@@ -0,0 +1,151 @@+import { describe, expect, it } from 'vitest'++import { probeArgv, probeReady, PROBES } from '../hooks/data/cli'+import { parseInstalled } from '../hooks/data/facts'+import { goalsOf, parseResearch, researchArgv, researchProbe, safeInstallPath } from '../hooks/data/research'+import { mcOf } from '../hooks/mission-control'+import { newState, type State } from '../hooks/state'+import type { Actions } from '../hooks/views/common'+import { viewText } from '../hooks/views/pane'+import { spendText } from '../hooks/views/research-section'++const finding = (grade: string) => ({ claim: 'c', grade, sources: ['https://example.test/a'] })+const LIST = JSON.stringify({+ version: 1,+ records: [+ { version: 1, question: 'older question', depth: 'quick', capUsd: 1, spentUsd: 0.2, status: 'truncated', at: '2026-10-03T10:00:00Z', findings: [finding('Low')], screened: true },+ { version: 1, question: 'How do raft leaders fail over?', depth: 'standard', capUsd: 2, spentUsd: null, status: 'done', at: '2026-10-04T09:00:00Z', findings: [finding('High'), finding('High'), finding('Medium'), finding('bogus')], screened: true },+ { question: 'no screening', status: 'weird', at: '2026-10-01T00:00:00Z', findings: [] },+ { question: '', status: 'done' },+ 'junk',+ ],+})++const installed = (path: string, version = '0.3.0'): State => {+ const state = newState({})++ state.snapshot = { plugins: { installed: [{ id: 'ruflo-goals@ruflo', name: 'ruflo-goals', marketplace: 'ruflo', version, scope: 'user', installPath: path }] } } as unknown as State['snapshot']++ return state+}+const shown = (state: State) => {+ mcOf(state).tab = 'record'++ return viewText({ state, nowMs: Date.parse('2026-10-04T12:00:00Z'), columns: 100, act: {} as Actions }, 'missions')+}+const result = (state: State, value: unknown, error: string | null = null, errorAtMs: number | null = null) => state.probes.set('research', { value, okAtMs: Date.parse('2026-10-04T11:58:00Z'), error, errorAtMs, isRunning: false })++describe('the research list parser', () => {+ it('reads records newest first, counting findings and the three grades, and keeps unknown spend as null', () => {+ const records = parseResearch(LIST)++ expect(records?.map(record => record.question)).toEqual(['How do raft leaders fail over?', 'older question', 'no screening'])+ expect(records?.[0]).toMatchObject({ status: 'done', findings: 4, grades: { High: 2, Medium: 1, Low: 0 }, spentUsd: null, capUsd: 2, isScreened: true })+ expect(records?.[1]).toMatchObject({ status: 'truncated', spentUsd: 0.2 })+ expect(records?.[2]).toMatchObject({ status: 'unknown', isScreened: false, findings: 0 })+ })++ it('is null for anything that is not version 1, and strips control text and bad numbers', () => {+ for (const bad of ['', 'nope', '[]', '{"records":[]}', '{"version":2,"records":[]}', '{"version":1}']) expect(parseResearch(bad)).toBeNull()+ expect(parseResearch(JSON.stringify({ version: 1, records: [{ question: 'q\u001b[31mx', spentUsd: -3, status: 'done' }] }))?.[0]).toMatchObject({ spentUsd: null })+ expect(parseResearch(JSON.stringify({ version: 1, records: [{ question: 'q\u001b[31mx', status: 'done' }] }))?.[0]?.question).not.toContain('\u001b')+ })++ it('caps the records it keeps', () => {+ const many = Array.from({ length: 50 }, (_, i) => ({ question: `q${i}`, status: 'done' }))++ expect(parseResearch(JSON.stringify({ version: 1, records: many }))).toHaveLength(8)+ })+})++describe('the research probe', () => {+ it('takes the script path only from a validated install path', () => {+ expect(safeInstallPath('/home/u/.claude/plugins/cache/ruflo/ruflo-goals/0.3.0')).toBeDefined()+ for (const bad of ['relative', '/a/../etc', '/x; rm', '/x$(id)', '/x`id`', '', undefined, 42, `/${'a'.repeat(400)}`]) expect(safeInstallPath(bad)).toBeUndefined()+ })++ it('builds a fixed argv, and none when absent, old or hostile', () => {+ expect(researchArgv(installed('/p/ruflo-goals/0.3.0'))).toEqual(['node', '/p/ruflo-goals/0.3.0/scripts/research-list.mjs', '--limit', '8'])+ expect(researchArgv(newState({}))).toBeNull()+ expect(researchArgv(installed('/p/$(id)'))).toBeNull()+ expect(researchArgv(installed('/p/x', '0.2.9'))).toBeNull()+ expect(probeArgv(researchProbe, 'npx', installed('/p/ruflo-goals/0.3.0'))[1]).toBe('/p/ruflo-goals/0.3.0/scripts/research-list.mjs')+ expect(researchProbe.views).toEqual(['missions'])+ expect(researchProbe.everyMs).toBeGreaterThanOrEqual(300_000)+ expect(PROBES).toContain(researchProbe)+ })++ it('is ready only while ruflo-goals is new enough, and every other probe always is', () => {+ expect(probeReady(researchProbe, newState({}))).toBe(false)+ expect(probeReady(researchProbe, installed('/p/x', '0.2.9'))).toBe(false)+ expect(probeReady(researchProbe, installed('/p/x', '0.3.0'))).toBe(true)+ expect(probeReady(researchProbe, installed('/p/x', '1.0.0'))).toBe(true)+ expect(goalsOf(installed('/p/x', 'unknown'))).toEqual({ kind: 'old', version: 'unknown' })+ for (const probe of PROBES.filter(entry => entry !== researchProbe)) expect(probeReady(probe, newState({}))).toBe(true)+ })++ it('reads installPath from installed_plugins.json only when it is a short string', () => {+ const file = (installPath: unknown) => JSON.stringify({ version: 2, plugins: { 'ruflo-goals@ruflo': [{ scope: 'user', version: '0.3.0', installPath }] } })++ expect(parseInstalled(file('/p/x'))?.[0]?.installPath).toBe('/p/x')+ expect(parseInstalled(file(7))?.[0]?.installPath).toBeUndefined()+ })+})++describe('the Research section on the Missions page', () => {+ it('says ruflo-goals is missing, with a way to get it', () => {+ const text = shown(newState({}))++ expect(text).toContain('Research')+ expect(text).toContain('ruflo-goals is not installed')+ expect(text).toContain('Plugin Catalog: ruflo-goals')+ })++ it('says an older ruflo-goals needs updating and lists nothing', () => {+ const text = shown(installed('/p/x', '0.2.9'))++ expect(text).toContain('ruflo-goals 0.2.9; needs 0.3.0 or newer')+ expect(text).toContain('Plugins: update it')+ })++ it('lists question, status, findings, grade counts and spend, with n/a for unknown spend', () => {+ const state = installed('/p/ruflo-goals/0.3.0')++ result(state, parseResearch(LIST))+ const text = shown(state)++ expect(text).toContain('How do raft leaders fail over?')+ expect(text).toContain('done · 4 findings')+ expect(text).toContain('High 2 · Medium 1 · Low 0 · spend n/a')+ expect(text).toContain('truncated · 1 finding ·')+ expect(text).toContain('spend $0.20')+ expect(text).toContain('unscreened')+ expect(text).toContain('Read-only')+ expect(text.indexOf('How do raft')).toBeLessThan(text.indexOf('older question'))+ })++ it('says so when there are no records, and keeps every line short enough for the host', () => {+ const state = installed('/p/ruflo-goals/0.3.0')++ result(state, [])+ expect(shown(state)).toContain('No research records yet.')+ result(state, parseResearch(JSON.stringify({ version: 1, records: [{ question: 'x'.repeat(200), status: 'done' }] })))+ for (const line of shown(state).split('\n').filter(l => /Read-only|records:/.test(l))) expect(line.trim().length).toBeLessThanOrEqual(50)+ })++ it('does not show stale records as live', () => {+ const state = installed('/p/ruflo-goals/0.3.0')++ result(state, parseResearch(LIST), 'exit 1: boom', Date.parse('2026-10-04T11:59:00Z'))+ const text = shown(state)++ expect(text).not.toContain('raft leaders')+ expect(text).toContain('boom')+ })++ it('formats spend without inventing it', () => {+ expect(spendText(null)).toBe('n/a')+ expect(spendText(0)).toBe('$0.000')+ expect(spendText(1.234)).toBe('$1.23')+ })+})