Skip to content

Commit 2dba07a

Browse files
Fix run_id collision in CI: increase suffix from 4 to 8 hex chars
The 4 hex char suffix (65536 possibilities) caused a collision when generating 100 IDs within the same second on fast CI runners. Increased to 8 hex chars (4 billion possibilities). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2aaa87f commit 2dba07a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

soup_cli/experiment/tracker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def _get_db_path() -> Path:
8080

8181

8282
def generate_run_id() -> str:
83-
"""Generate a unique, sortable run ID: run_YYYYMMDD_HHMMSS_xxxx."""
83+
"""Generate a unique, sortable run ID: run_YYYYMMDD_HHMMSS_xxxxxxxx."""
8484
ts = datetime.now().strftime("%Y%m%d_%H%M%S")
85-
suffix = secrets.token_hex(2)
85+
suffix = secrets.token_hex(4)
8686
return f"run_{ts}_{suffix}"
8787

8888

tests/test_tracker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def test_generate_run_id():
1818
"""Run IDs should be unique and match expected format."""
1919
rid = generate_run_id()
2020
assert rid.startswith("run_")
21-
# run_ (4) + YYYYMMDD (8) + _ (1) + HHMMSS (6) + _ (1) + xxxx (4) = 24
22-
assert len(rid) == 24
23-
# Uniqueness
21+
# run_ (4) + YYYYMMDD (8) + _ (1) + HHMMSS (6) + _ (1) + xxxxxxxx (8) = 28
22+
assert len(rid) == 28
23+
# Uniqueness (8 hex chars = 4 billion possibilities, no collisions in 100)
2424
ids = {generate_run_id() for _ in range(100)}
2525
assert len(ids) == 100
2626

0 commit comments

Comments
 (0)