evals: prevent silent overwrites in results writer artifacts#131
Merged
Conversation
Two silent data-loss gaps in the per-case markdown artifacts:
- Distinct case names sanitized with re.sub(r'[^\w\-]', '_', name) could
collide ('a/b' and 'a:b' both -> 'a_b.md'), the second silently
overwriting the first. Track the stems used in each run dir and append a
numeric suffix on collision so every case keeps its own file.
- Run directories are timestamped to the second with mkdir(exist_ok=True),
so two runs of the same suite within one second (or two racing processes)
merged their case files. Create with exist_ok=False and bump a numeric
suffix until mkdir wins; mkdir is atomic, so this is safe across processes.
Closes #119
renaudcepre
added a commit
that referenced
this pull request
Jun 25, 2026
Two silent data-loss gaps in the per-case markdown artifacts:
- Distinct case names sanitized with re.sub(r'[^\w\-]', '_', name) could
collide ('a/b' and 'a:b' both -> 'a_b.md'), the second silently
overwriting the first. Track the stems used in each run dir and append a
numeric suffix on collision so every case keeps its own file.
- Run directories are timestamped to the second with mkdir(exist_ok=True),
so two runs of the same suite within one second (or two racing processes)
merged their case files. Create with exist_ok=False and bump a numeric
suffix until mkdir wins; mkdir is atomic, so this is safe across processes.
Closes #119
Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #119. Two silent data-loss gaps in the per-case markdown artifacts (
results_writer.py).1. Case-name collisions
Names were sanitized with
re.sub(r"[^\w\-]", "_", name), soa/banda:bboth becamea_b.md— the second silently overwriting the first. The writer now tracks the stems used in each run dir and appends a numeric suffix on collision (a_b.md,a_b-2.md), so every case keeps its own file. (Also falls back tocasewhen a name sanitizes to empty.)2. Same-second / racing run directories
Run dirs are timestamped to the second with
mkdir(exist_ok=True), so two runs of the same suite within one second — or two racing processes — merged their case files into one directory._make_run_dirnow creates withexist_ok=Falseand bumps a numeric suffix untilmkdirwins.mkdiris atomic, so this is also safe across concurrent processes.Tests
New
tests/evals/test_results_writer.py(kept separate to avoid growing the already-largetest_e2e.py, cf. #98):case.md;Full suite: 1246 passed,
ruffclean,mypy --strictclean.Generated by Claude Code