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

merge: reconcile import write results with current namespace validation

Rudy Celeklib1eb593a1499
diff --cc v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts
index 467338dc37,bf84b60167..59442dd071
--- a/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts
@@@ -1611,26 -1626,35 +1626,43 @@@ export const memoryTools: MCPTool[] =
const entries = Array.isArray(doc.entries) ? doc.entries : [];
const nsOverride = input.namespace ? String(input.namespace) : undefined;
if (nsOverride) { const v = validateIdentifier(nsOverride, 'namespace'); if (!v.valid) throw new Error(v.error); }
+ // #3570: validate every entry's namespace up front so a bad file writes nothing.
+ if (!nsOverride) {
+ for (const e of entries) {
+ if (e && typeof e.key === 'string' && e.namespace !== undefined) {
+ const v = validateIdentifier(String(e.namespace), 'namespace');
+ if (!v.valid) throw new Error(v.error);
+ }
+ }
+ }
+ // #3570 follow-up: keys get the same up-front, all-or-nothing check.
+ for (const e of entries) {
+ if (e && typeof e.key === 'string') {
+ const keyError = memoryKeyError(e.key);
+ if (keyError) throw new Error(`${keyError}: ${JSON.stringify(e.key)}`);
+ }
+ }
- let imported = 0; let skipped = 0;
+ let imported = 0; let skipped = 0; let failed = 0;
+ const errors: string[] = [];
for (const e of entries) {
if (!e || typeof e.key !== 'string') { skipped++; continue; }
const value = typeof e.value === 'string' ? e.value : JSON.stringify(e.value ?? null);
try {
const result = await storeEntry({ key: e.key, value, namespace: nsOverride ?? e.namespace ?? 'default', upsert: input.merge !== false, dbPath });
- if (result.success) { imported++; if (result.embedding) vectors++; }
- else skipped++;
- } catch { skipped++; }
+ if (!result.success) throw new Error(result.error || 'Memory write was rejected');
+ imported++;
++ if (result.embedding) vectors++;
+ } catch (error) {
+ failed++;
+ if (errors.length < 10) errors.push(`${e.key}: ${error instanceof Error ? error.message : String(error)}`);
+ }
}
return {
+ success: failed === 0,
+ error: failed > 0 ? `${failed} memory write(s) failed: ${errors.join('; ')}` : undefined,
+ failed,
inputPath,
- imported: { entries: imported, vectors: 0, patterns: 0 },
+ imported: { entries: imported, vectors, patterns: 0 },
skipped,
duration: Date.now() - t0,
};