Skip to content

fix: add random suffix to log filenames to prevent collision#94

Open
PolyphonyRequiem wants to merge 1 commit intomicrosoft:mainfrom
PolyphonyRequiem:fix/event-log-filename-collision
Open

fix: add random suffix to log filenames to prevent collision#94
PolyphonyRequiem wants to merge 1 commit intomicrosoft:mainfrom
PolyphonyRequiem:fix/event-log-filename-collision

Conversation

@PolyphonyRequiem
Copy link
Copy Markdown
Member

Problem

When multiple workflow runs start in the same second (common when orchestrating parallel runs), \ ime.strftime('%Y%m%d-%H%M%S')\ produces identical timestamps, causing all runs to write to the same event log file. This corrupts event logs, checkpoint files, and CLI log files by interleaving events from different runs.

Solution

Append a random 8-character hex suffix (via \secrets.token_hex(4)) to filenames across all three affected locations:

  • \EventLogSubscriber\ (\�vent_log.py)
  • \CheckpointManager.save_checkpoint\ (\checkpoint.py)
  • \generate_log_path\ (\cli/run.py)

Before

\
conductor-workflow-20260416-014816.events.jsonl
\\

After

\
conductor-workflow-20260416-014816-a3b7c9f1.events.jsonl
\\

Backward Compatibility

Fully backward compatible — existing tools that glob *.events.jsonl, *.json, or *.log\ continue to work. Filenames remain human-readable with the timestamp prefix; the suffix only prevents collisions.

Testing

  • Added \ est_filenames_unique_for_simultaneous_starts\ — creates 3 subscribers in rapid succession, asserts all paths are unique
  • Added \ est_filename_contains_random_suffix\ — validates the 8-char hex suffix format in filenames

Note

One pre-existing test (\ est_handles_non_serializable_data) fails on Windows due to a path separator assertion (\\\some\\path\ vs /some/path). This is unrelated to this change.

When multiple workflow runs start in the same second (common when
orchestrating parallel runs), time.strftime('%Y%m%d-%H%M%S') produces
identical timestamps, causing all runs to write to the same file.
This corrupts event logs, checkpoint files, and CLI log files by
interleaving events from different runs.

Append a random 8-character hex suffix (via secrets.token_hex(4))
to filenames across all three affected locations:
- EventLogSubscriber (event_log.py)
- CheckpointManager.save_checkpoint (checkpoint.py)
- generate_log_path (cli/run.py)

Filenames change from:
  conductor-workflow-20260416-014816.events.jsonl
to:
  conductor-workflow-20260416-014816-a3b7c9f1.events.jsonl

Backward compatible: existing tools that glob *.events.jsonl,
*.json, or *.log continue to work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@1d6583d). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #94   +/-   ##
=======================================
  Coverage        ?   85.44%           
=======================================
  Files           ?       46           
  Lines           ?     6445           
  Branches        ?        0           
=======================================
  Hits            ?     5507           
  Misses          ?      938           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PolyphonyRequiem
Copy link
Copy Markdown
Member Author

@microsoft-github-policy-service agree company="Microsoft"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants