Repository navigation
Description
Problem
devops review pr and devops review branch name the review session by the second it starts: datetime.now(UTC).strftime("%Y%m%d-%H%M%S") (src/devops_cli/commands/review.py:661 and :918). Two reviews that start in the same second under one data folder get the same name. The second review runs to its end and then refuses to publish: "Review session was not published: a session of that name already exists". It exits 1 and does not post its comment.
Seen on 2026-11-17 while building #6199: a test that ran devops review pr --post two times in one test failed with this error when the two runs fell in one second. The test now runs the review one time.
Expected behavior
Two reviews that start in the same second get different session names, so each review publishes its session and posts its comment.
Alternatives check of 2026-11-25: covers.
Tool: python-ulid (https://pypi.org/project/python-ulid), MIT, last activity 2026-11-17, maintained.
Reason: The PyPI and GitHub facts show python-ulid generates unique 26-character ULIDs that sort by millisecond start time and decode back to a timestamp, which covers the session-naming need; the issue body already adopts it.
Covers:
- Unique 26-character Crockford base32 ULID on every call
- Lexicographic order follows the millisecond start time
- Recovers the start time with ULID.from_str(name).datetime
- Small pure-Python dependency with no service
Lacks:
- No order for legacy timestamp names; the store sorts itself
- No session publish, duplicate refusal or comment posting
- Does not place the helper; call-site edits remain
Proposed design
Problem statement
devops review pr and devops review branch name a review session by the second it starts. Two reviews that start in the same second under one data folder get one name. The second review runs to its end, refuses to publish, exits 1 and posts no comment. The change names each session with a ULID from python-ulid through one helper. It keeps ReviewSessionStore ordering sessions by start time when a data folder holds old timestamp names and new ULID names.
Acceptance criteria
Requirement: Unique session names
The session-name helper SHALL return a different name on each call.
Scenario: One hundred calls in one process
- WHEN A test calls new_session_name() 100 times in one process.
- THEN The test asserts that the 100 names are 100 distinct strings.
Requirement: ULID session name
Each session name MUST be a 26-character Crockford base32 ULID string.
Scenario: Name pattern
- WHEN A test takes one name from new_session_name().
- THEN The test asserts that the name matches ^[0-7][0-9A-HJKMNP-TV-Z]{25}$.
Requirement: Start-time order
Session names MUST sort in start-time order at the millisecond resolution that the name records.
Scenario: Two names one millisecond apart
- WHEN A test freezes the clock with time_machine.travel at a fixed instant with tick=False, takes one name, shifts the clock one millisecond forward and takes a second name.
- THEN The test asserts that the first name sorts before the second name.
Requirement: Both review commands use the helper
devops review pr and devops review branch MUST both name their session with new_session_name().
Scenario: Each command asks for a name
- WHEN A test replaces devops_cli.commands.review.new_session_name with a fake that returns one known name and runs devops review branch and devops review pr with their fakes.
- THEN The test asserts that each command passes the fake's name as the session_id of its review.
Requirement: Path review gets a unique name
A review pipeline built with no session name MUST take a different default name from new_session_name() on each build.
Scenario: Two builds with no session name
- WHEN A test builds two ReviewPipelineOrchestrator objects with no session_id argument.
- THEN The test asserts that both session_id values match ^[0-7][0-9A-HJKMNP-TV-Z]{25}$ and differ.
Requirement: Two sessions publish in one data folder
Two sessions named by new_session_name() MUST both publish into one data folder.
Scenario: Two publishes
- WHEN A test creates two sessions from two names of the helper and publishes both into one data folder.
- THEN The test asserts that both publishes return their directories and that ReviewSessionStore.sessions() lists two sessions.
Requirement: Duplicate session refusal stays
A publish under the name of a published session MUST still be refused.
Scenario: Forced duplicate name
- WHEN A test publishes two sessions of the same name into one data folder.
- THEN The second publish raises ReviewSessionExistsError with a message that starts Review session <name> was not published: a session of that name already exists.
Requirement: Mixed name formats sort by start time
ReviewSessionStore.sessions() MUST order sessions by their start time when a data folder holds both a timestamp-named session and a ULID-named session.
Scenario: Older timestamp session and newer ULID session
- WHEN A test publishes a session named 20261001-120000 and, with the clock frozen at 2026-11-17, a session named by new_session_name() into one data folder.
- THEN The test asserts that ReviewSessionStore.sessions() lists the ULID session first and that ReviewSessionStore.latest() returns the ULID session.
Requirement: python-ulid is pinned and mapped
The project MUST declare python-ulid at an exact pin in the dependencies of pyproject.toml, map its ulid module in [tool.deptry] package_module_name_map, and record it in uv.lock.
Scenario: Lockfile and dependency check
- WHEN uv run devops ci --check --only lockfile,deps runs.
- THEN The check passes: the lockfile row reports that uv lock --check found the lock current and the deps row reports no missing or unused dependency.
Existing Tool Considered
python-ulid (https://pypi.org/project/python-ulid) has the verdict covers in the alternatives check of 2026-11-18 in the issue body. That check states what the tool covers and lacks. The change keeps the existing review session, publish and comment code for the parts that the tool lacks. It uses ULID.from_str(name).datetime to recover the start time for display. The owner reply on the issue adopts the tool, and the change adds one exact-pinned runtime dependency.
Key questions
- Where does the review code build the session name from the current second?: devops review branch and devops review pr build the name inline with datetime.now(UTC).strftime("%Y%m%d-%H%M%S") at src/devops_cli/commands/review.py:661 and src/devops_cli/commands/review.py:918. ReviewPipelineOrchestrator falls back to the same format at src/devops_cli/ai/review/pipeline.py:2128. src/devops_cli/commands/review.py:2509 uses the same format for a sample-validation run directory, which is not a review session and stays as it is. [sources: src/devops_cli/commands/review.py:661, src/devops_cli/commands/review.py:918, src/devops_cli/ai/review/pipeline.py:2128, src/devops_cli/commands/review.py:2509]
- Should the project adopt python-ulid, which the alternatives check of 2026-11-18 rates covers, or keep the second-resolution timestamp name with a reason?: Adopt python-ulid. The owner reply on the issue adopts the tool, and AGENTS.md rule 3 puts an open, maintained tool before code the project builds. The alternatives check of 2026-11-18 in the issue body gives python-ulid the verdict covers. The change adds one exact-pinned runtime dependency. (best practice) [sources: AGENTS.md:9]
- Chosen: Adopt python-ulid. The owner reply adopts the tool, the alternatives check rates it covers, and AGENTS.md rule 3 puts an open tool first.
- Rejected: Keep %Y%m%d-%H%M%S with a counter. It builds the uniqueness rule by hand at each call site, and two processes can still pick the same suffix.
- Rejected: Use uuid.uuid7(). It gives a 36-character hyphenated name with no ULID decoding helper, and the open library covers the need.
- Where should the one session-name helper live, and does the pipeline default use it?: Add new_session_name() to src/devops_cli/review/session.py beside ReviewSession and ReviewSessionStore. It returns str(ULID()). The two commands import it and call it. ReviewPipelineOrchestrator uses it for the default at src/devops_cli/ai/review/pipeline.py:2128, so one format covers every review session, including devops review path. The docstrings that call a session name a timestamp at src/devops_cli/review/session.py:83 and src/devops_cli/review/session.py:219 change with it. (best practice) [sources: src/devops_cli/review/session.py:72, src/devops_cli/review/session.py:83, src/devops_cli/review/session.py:213, src/devops_cli/review/session.py:219, src/devops_cli/ai/review/pipeline.py:108, src/devops_cli/ai/review/pipeline.py:2128]
- Chosen: new_session_name() in src/devops_cli/review/session.py. The store owns the name, and the pipeline already imports from this module.
- Rejected: A private helper in src/devops_cli/commands/review.py. It keeps the format away from the store and the pipeline default needs a second copy.
- Rejected: Inline str(ULID()) at each of the three sites. Three copies drift and need three tests.
- What refuses a publish under a name that is already published?: ReviewSession.publish() renames the staging directory into the sessions directory and raises ReviewSessionExistsError when the name exists, at src/devops_cli/review/session.py:151. The error builds the message Review session <name> was not published: a session of that name already exists at src/devops_cli/exceptions/ai.py:154. The store test at tests/ai/test_review_session_store.py:197 already checks the refusal. [sources: src/devops_cli/review/session.py:151, src/devops_cli/exceptions/ai.py:145, src/devops_cli/exceptions/ai.py:154, tests/ai/test_review_session_store.py:197]
- How does ReviewSessionStore keep sessions in start-time order when a data folder holds both the old %Y%m%d-%H%M%S names and the new ULID names?: Sort on the start time decoded from each name: ULID.from_str(name).datetime for a ULID, datetime.strptime(name, "%Y%m%d-%H%M%S").replace(tzinfo=UTC) for a legacy name, and last place for a name that is neither. A raw reverse sort of the names puts every legacy 2026... name ahead of every new 01... ULID, so latest() at src/devops_cli/ai/review/runner.py:119 and the dashboard would keep showing an old review as the newest. (best practice) [sources: src/devops_cli/review/session.py:213, src/devops_cli/review/session.py:219, src/devops_cli/review/session.py:242, src/devops_cli/ai/review/runner.py:119, tests/ai/test_review_session_store.py:262]
- Chosen: Sort on the start time decoded from each name. A folder that holds both formats keeps the newest review first and latest() keeps working.
- Rejected: Keep the reverse sort of the raw names. Every legacy name begins with 2 and every current ULID begins with 0, so every legacy session sorts ahead of every new one.
- Rejected: Rename the published timestamp sessions to ULIDs. A published session's name is its identity, and a rename moves history that a reader or a saved name may hold.
- Rejected: Prefix the timestamp and append a ULID. The name is 42 characters and no longer a ULID, which loses the 26-character filename-safe form.
- Does the change need a deptry mapping for python-ulid?: Yes. The package name is python-ulid and the module name is ulid. The change adds "python-ulid" = "ulid" to [tool.deptry] package_module_name_map in pyproject.toml, beside the existing pytrec-eval-terrier mapping, so the deps row accepts the import. [sources: pyproject.toml:364, pyproject.toml:365, src/devops_cli/commands/ci.py:1050]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 17, 2026
Both fix a 1-second timestamp collision, but the candidate targets devops review session names while #4488 targeted devops roadmap eval verify report names.devops-cli-service commentedon Nov 18, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (4)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 19, 2026
Owner question: The alternatives check found that https://pypi.org/project/python-ulid covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 21, 2026
Owner question: See the first point of Open questions in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 22, 2026
Owner question: See the first point of Open questions in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
dan-petty commentedon Nov 24, 2026
Adopt the tool: python-ulid. AGENTS.md rule 3 requires using an open tool before building.
devops-cli-service commentedon Nov 24, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
chore(main): release 0.219.0 (#7177)
devops-cli-service commentedon Nov 25, 2026
Released in v0.219.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.219.0
devops-cli-service commentedon Nov 25, 2026
Live since 2026-11-25 17:09 UTC