Files
ruflo/v3/@claude-flow
rUv 5e634b3965 fix(test): use a UUID, not Date.now(), for mcp-policy-enforcer's per-test audit log path (#3337)
`beforeEach` built each test's "unique" audit-log/policy file path from
`Date.now()` alone (millisecond resolution). Two tests whose beforeEach
hooks fire within the same millisecond — easily happens in a fast
suite — get the identical filename, so one test's audit-log writes leak
into another's line-count assertions.

This is the root cause of an intermittent CI failure: "deny -> expiry ->
allow through the real stdio dispatcher" expects exactly 3 audit-log
lines but sometimes sees 5 — the extra 2 lines come from the preceding
"budget=1" test's two dispatch calls, when both tests' beforeEach hooks
land on the same Date.now() value. Confirmed the mechanism directly:
Date.now() collides trivially in a tight loop (2M iterations, first
try), while crypto.randomUUID() never collides across 200k calls.

Swapped both the audit-log and policy-file paths in this describe block
to use randomUUID() instead. Ran the file 9 times back-to-back post-fix:
31/31 passing every time.


Claude-Session: https://claude.ai/code/session_01SjxUvZnyBdwtx4Y1jKAqt6
2026-09-16 14:45:11 +00:00
..