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(test): use a UUID, not Date.now(), for mcp-policy-enforcer's per-test audit log path (#3337)

rUv5e634b396511
diff --git a/v3/@claude-flow/cli/__tests__/mcp-policy-enforcer.test.ts b/v3/@claude-flow/cli/__tests__/mcp-policy-enforcer.test.ts
index cb031b4774..71829706ba 100644
--- a/v3/@claude-flow/cli/__tests__/mcp-policy-enforcer.test.ts
+++ b/v3/@claude-flow/cli/__tests__/mcp-policy-enforcer.test.ts
@@ -14,6 +14,7 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
+import { randomUUID } from 'crypto';
import {
isPolicyEnforcementEnabled,
loadMcpPolicy,
@@ -290,8 +291,14 @@ describe('MCPServerManager tools/call — policy wiring', () => {
beforeEach(() => {
resetPolicyEnforcerState();
- setAuditLogPathForTesting(path.join(os.tmpdir(), `mcp-audit-integration-${Date.now()}.jsonl`));
- policyPath = path.join(os.tmpdir(), `mcp-policy-integration-${Date.now()}.json`);
+ // A `Date.now()`-only suffix collides when two tests' beforeEach hooks
+ // fire within the same millisecond (easily happens in a fast suite),
+ // pointing them at the identical "unique" file — one test's audit
+ // writes then leak into another's line-count assertions. randomUUID()
+ // guarantees no collision regardless of timing.
+ const runId = randomUUID();
+ setAuditLogPathForTesting(path.join(os.tmpdir(), `mcp-audit-integration-${runId}.jsonl`));
+ policyPath = path.join(os.tmpdir(), `mcp-policy-integration-${runId}.json`);
});
afterEach(() => {
if (ORIGINAL_ENV === undefined) delete process.env.RUFLO_MCP_ENFORCE_POLICY;