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(console): memory health review - honest section subtitle, shorter consolidate note, tests that kill 5 surviving mutants

ruv7772cd379aeb
diff --git a/plugins/ruflo-console/hooks/views/memory-health.ts b/plugins/ruflo-console/hooks/views/memory-health.ts
index 2ee064644f..d733195e51 100644
--- a/plugins/ruflo-console/hooks/views/memory-health.ts
+++ b/plugins/ruflo-console/hooks/views/memory-health.ts
@@ -85,7 +85,7 @@ function consolidateRows(ctx: Ctx): RenderElement[] {
return [
row(ctx, [
button(ctx, 'mem-health-consolidate', 'â–¸ consolidate', press, { primary: true }),
- text(ctx, ' AgentDB consolidate: merges and promotes across tiers; asks first. It does not delete the keys listed above, delete those one by one (DELETE).', { dimColor: true }),
+ text(ctx, ' asks first · merges across tiers, never deletes these keys (DELETE does)', { dimColor: true }),
]),
...(lab.origin === 'health' ? confirmHere(ctx, 'mem:agentdb') : []),
]
diff --git a/plugins/ruflo-console/hooks/views/memory-lab.ts b/plugins/ruflo-console/hooks/views/memory-lab.ts
index 547b94cde8..1b282a8aeb 100644
--- a/plugins/ruflo-console/hooks/views/memory-lab.ts
+++ b/plugins/ruflo-console/hooks/views/memory-lab.ts
@@ -143,7 +143,7 @@ function resultRows(ctx: Ctx): RenderElement[] {
*/
export function memoryLabRows(ctx: Ctx): RenderElement[] {
const lead = Math.max(15, Math.min(18, ctx.columns - 40))
- const rows: RenderElement[] = [...section(ctx, 'mem-g-health', 'Memory health', 'duplicates, stale, never recalled · read-only', [...healthRows(ctx), ...areaPanel(ctx, 'health')], true), ...searchRows(ctx), ...areaPanel(ctx, 'search'), ...entryRows(ctx), ...areaPanel(ctx, 'entry')]
+ const rows: RenderElement[] = [...section(ctx, 'mem-g-health', 'Memory health', 'duplicates, stale, never recalled · analysis reads no values; consolidate asks first', [...healthRows(ctx), ...areaPanel(ctx, 'health')], true), ...searchRows(ctx), ...areaPanel(ctx, 'search'), ...entryRows(ctx), ...areaPanel(ctx, 'entry')]
rows.push(rule(ctx, 'Lab text', 'the input for the rows below that take text'))
rows.push(field(ctx, 'text', 'text', 'a query or pattern · a node id · a | b to compare · source relation target', 'keep', value => ctx.act.memory.draft('text', value)))
diff --git a/plugins/ruflo-console/tests/memory-health.spec.ts b/plugins/ruflo-console/tests/memory-health.spec.ts
index d76f4e93a5..e814377aa7 100644
--- a/plugins/ruflo-console/tests/memory-health.spec.ts
+++ b/plugins/ruflo-console/tests/memory-health.spec.ts
@@ -39,6 +39,28 @@ describe('memory health analysis', () => {
expect(report.clusterCount).toBe(0)
})
+ it('does not cluster unlike keys that merely share a size, and a same-key different-size pair is near, not exact', () => {
+ const unlike = analyseHealth({ listed: 2, entries: [e('a', 'payment-gateway-config', 100, 1, 1), e('a', 'user-avatar-cache', 100, 1, 2)] }, NOW)
+ const resized = analyseHealth({ listed: 2, entries: [e('a', 'api/auth', 100, 1, 1), e('b', 'api-auth', 500, 1, 2)] }, NOW)
+
+ expect(unlike.clusterCount).toBe(0)
+ expect(resized.clusters[0]).toMatchObject({ kind: 'near', size: 2 })
+ })
+
+ it('the same namespace and key listed twice is not a duplicate of itself', () => {
+ expect(analyseHealth({ listed: 2, entries: [e('a', 'same-key', 10, 1, 1), e('a', 'same-key', 10, 1, 2)] }, NOW).clusterCount).toBe(0)
+ })
+
+ it('the pair budget drops the OLDEST entries: a duplicate among the oldest is not found, one among the newest is', () => {
+ const filler = Array.from({ length: 30 }, (_, index) => e('f', `filler-${index}-zz${index}`, 10 + index * 7, 1, 10 + index))
+ const newest = [e('n', 'fresh-dup-key', 999, 1, 0), e('m', 'fresh-dup-key', 999, 1, 0.5)]
+ const oldest = [e('o', 'ancient-dup-key', 777, 1, 400), e('p', 'ancient-dup-key', 777, 1, 401)]
+ const report = analyseHealth({ listed: 34, entries: [...oldest, ...filler, ...newest] }, NOW, { pairCap: 120 })
+
+ expect(report.isTruncated).toBe(true)
+ expect(report.clusters.flatMap(cluster => cluster.members.map(member => member.key))).toEqual(['fresh-dup-key', 'fresh-dup-key'])
+ })
+
it('stale means never recalled and not updated for the window; a recalled or undated entry is never stale', () => {
const undated: HealthEntry = { namespace: 'a', key: 'undated', size: 1, accessCount: 0 }
const report = analyseHealth({ listed: 4, entries: [e('a', 'old-unread', 1, 0, 90), e('a', 'old-read', 1, 3, 90), e('a', 'new-unread', 1, 0, 2), undated] }, NOW)
@@ -94,6 +116,14 @@ describe('the health probe reader', () => {
expect(memoryHealthProbe.parse('not json')).toBeNull()
})
+ it('reads at most HEALTH_CAP rows even if the CLI ignores --limit', () => {
+ const rows = Array.from({ length: HEALTH_CAP + 50 }, (_, index) => ({ key: `k${index}`, namespace: 'n', size: 1, accessCount: 0 }))
+ const sample = memoryHealthProbe.parse(JSON.stringify(rows))
+
+ expect(sample?.entries).toHaveLength(HEALTH_CAP)
+ expect(sample?.listed).toBe(HEALTH_CAP)
+ })
+
it('asks for exactly the cap, read-only, through the fixed memory list argv', () => {
expect(memoryHealthProbe.args).toEqual(['memory', 'list', '--format', 'json', '--limit', String(HEALTH_CAP)])
})