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(memory): normalize numeric timestamps in store statistics

Rudy Celekli71e584424522
diff --git a/v3/@claude-flow/cli/__tests__/memory-stats-selected-store.test.ts b/v3/@claude-flow/cli/__tests__/memory-stats-selected-store.test.ts
index 77ed2d2fd1..c713f6a957 100644
--- a/v3/@claude-flow/cli/__tests__/memory-stats-selected-store.test.ts
+++ b/v3/@claude-flow/cli/__tests__/memory-stats-selected-store.test.ts
@@ -119,4 +119,24 @@ describe('stats describes the selected store', () => {
expect(mocks.list).not.toHaveBeenCalled();
});
+ it.each([
+ [1767225600000, 1772323200000],
+ ['1767225600000', '1772323200000'],
+ ['2026-01-01T00:00:00Z', 1772323200000],
+ ])('normalizes mixed stored timestamp formats %j / %j', async (first, last) => {
+ mocks.list.mockResolvedValue({ success: true, total: 2, entries: [
+ { ...entries[0], createdAt: last }, { ...entries[1], createdAt: first },
+ ] });
+ const result = await stats.handler({ dbPath: selected }) as any;
+ expect(result.oldestEntry).toBe('2026-01-01T00:00:00.000Z');
+ expect(result.newestEntry).toBe('2026-03-01T00:00:00.000Z');
+ });
+
+ it('accepts epoch zero and ignores invalid or out-of-range timestamps', async () => {
+ mocks.list.mockResolvedValue({ success: true, total: 5, entries: [0, '0', 'bad date', 1e20, undefined].map(createdAt => ({ ...entries[0], createdAt })) });
+ const result = await stats.handler({ dbPath: selected }) as any;
+ expect(result.oldestEntry).toBe('1970-01-01T00:00:00.000Z');
+ expect(result.newestEntry).toBe('1970-01-01T00:00:00.000Z');
+ });
+
});
diff --git a/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts
index 73681052dd..c6a0378e8c 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts
@@ -913,7 +913,7 @@ export const memoryTools: MCPTool[] = [
// `initialized: false` from this tool alone. The probe is still read
// below, for the version and feature labels it is the only source of,
// but it no longer gets to overrule a working store.
- let listing: ListPage<{ namespace: string; hasEmbedding: boolean; createdAt?: string }>;
+ let listing: ListPage<{ namespace: string; hasEmbedding: boolean; createdAt?: string | number }>;
try {
listing = await collectAllEntries(listEntries, dbPath);
} catch (error) {
@@ -936,7 +936,15 @@ export const memoryTools: MCPTool[] = [
for (const entry of listing.entries) {
namespaces[entry.namespace] = (namespaces[entry.namespace] || 0) + 1;
if (entry.hasEmbedding) withEmbeddings++;
- const created = Date.parse(entry.createdAt ?? '');
+ // AgentDB returns INTEGER epoch milliseconds; legacy sql.js rows
+ // may expose ISO strings or numeric strings from SQLite TEXT affinity.
+ const rawCreated = entry.createdAt;
+ const millis = typeof rawCreated === 'number'
+ ? rawCreated
+ : typeof rawCreated === 'string' && /^-?\d+$/.test(rawCreated)
+ ? Number(rawCreated)
+ : Date.parse(rawCreated ?? '');
+ const created = new Date(millis).getTime();
if (Number.isFinite(created)) {
oldest = Math.min(oldest, created);
newest = Math.max(newest, created);