🌊 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(memory): dedup the RFE1 warning per dbPath, not per process (#2889 follow-up)
Nicholas Ruest81064e8cb2ea
diff --git a/v3/@claude-flow/cli/__tests__/graph-edge-writer-rfe1-guard-2889.test.ts b/v3/@claude-flow/cli/__tests__/graph-edge-writer-rfe1-guard-2889.test.tsindex 6918b06f11..f0865dd8d5 100644--- a/v3/@claude-flow/cli/__tests__/graph-edge-writer-rfe1-guard-2889.test.ts+++ b/v3/@claude-flow/cli/__tests__/graph-edge-writer-rfe1-guard-2889.test.ts@@ -68,7 +68,7 @@ afterEach(async () => {});describe('#2889 graph-edge-writer RFE1 encryption guard', () => {- it.skipIf(!native)('a genuinely RFE1-encrypted file returns null without attempting the native open, and warns once per process', async () => {+ it.skipIf(!native)('a genuinely RFE1-encrypted file returns null without attempting the native open, and warns once per dbPath (deduped across repeat calls on the same path)', async () => {const { encryptBuffer } = await import('../src/encryption/vault.js');const key = randomBytes(32);const blob = encryptBuffer(Buffer.from('irrelevant plaintext payload'), key);@@ -133,6 +133,28 @@ describe('#2889 graph-edge-writer RFE1 encryption guard', () => {gw._resetBridgeDb();});+ it.skipIf(!native)('warns separately for TWO distinct encrypted dbPaths in the same process — dedup must be keyed by path, not a single global flag', async () => {+ const { encryptBuffer } = await import('../src/encryption/vault.js');+ const key = randomBytes(32);++ const pathA = join(root, 'a.db');+ const pathB = join(root, 'b.db');+ writeFileSync(pathA, encryptBuffer(Buffer.from('payload-a'), key));+ writeFileSync(pathB, encryptBuffer(Buffer.from('payload-b'), key));++ const { gw } = await freshGraphWriterWithSpy();+ const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});++ expect(await gw.getBridgeDb(pathA)).toBeNull();+ expect(await gw.getBridgeDb(pathB)).toBeNull();+ // Repeat pathA — must NOT produce a second warning for the same path.+ expect(await gw.getBridgeDb(pathA)).toBeNull();++ const warningsFor = (p: string) => errSpy.mock.calls.filter((call) => String(call[0]).includes(p));+ expect(warningsFor(pathA)).toHaveLength(1);+ expect(warningsFor(pathB)).toHaveLength(1);+ });+it.skipIf(!native)('isBridgeDbEncryptedAtRest distinguishes the encrypted case from plaintext/corrupt/missing', async () => {const { encryptBuffer } = await import('../src/encryption/vault.js');const key = randomBytes(32);diff --git a/v3/@claude-flow/cli/src/memory/graph-edge-writer.ts b/v3/@claude-flow/cli/src/memory/graph-edge-writer.tsindex 27564710c7..d5a3bd7c82 100644--- a/v3/@claude-flow/cli/src/memory/graph-edge-writer.ts+++ b/v3/@claude-flow/cli/src/memory/graph-edge-writer.ts@@ -53,7 +53,9 @@ import { isEncryptedBlob } from '../encryption/vault.js';//// Fix: sniff the header bytes (never buffer the whole file — memory.db can// be multi-GB) before attempting the native open. If it's RFE1-encrypted,-// skip the native open (it would only throw) and warn once per process.+// skip the native open (it would only throw) and warn once per distinct+// dbPath (not once per process — a process can legitimately touch more+// than one encrypted store via a custom `dbPath` argument)./** Read just the first `len` bytes of a file without loading the whole file* into memory. Mirrors the pattern in commands/doctor.ts's readHeaderBytes@@ -85,11 +87,17 @@ function isRfe1EncryptedAtRest(filePath: string): boolean {}}-let _warnedRfe1Encrypted = false;+// Keyed by resolved path (not a single process-wide boolean) — a process+// that touches more than one RFE1-encrypted dbPath (a custom `dbPath` passed+// to insertGraphEdge/queryEdgesBySource/countGraphEdges, or any multi-store+// scenario) must still get the warning for EACH distinct path, not just the+// first one it happens to see.+const _warnedRfe1EncryptedPaths = new Set<string>();function warnRfe1EncryptedOnce(dbPath: string): void {- if (_warnedRfe1Encrypted) return;- _warnedRfe1Encrypted = true;+ const resolved = path.resolve(dbPath);+ if (_warnedRfe1EncryptedPaths.has(resolved)) return;+ _warnedRfe1EncryptedPaths.add(resolved);// eslint-disable-next-line no-consoleconsole.error(`[graph-edge-writer] ${dbPath} is encrypted at rest (CLAUDE_FLOW_ENCRYPT_AT_REST). ` +@@ -112,9 +120,9 @@ export function isBridgeDbEncryptedAtRest(customDbPath?: string): boolean {return fs.existsSync(dbPath) && isRfe1EncryptedAtRest(dbPath);}-/** Test-only: clear the once-per-process warning flag. */+/** Test-only: clear the once-per-path warning dedup set. */export function _resetRfe1WarningFlag(): void {- _warnedRfe1Encrypted = false;+ _warnedRfe1EncryptedPaths.clear();}// ============================================================================