Skip to content

Reserve run IDs atomically - #184

Merged
Kubuxu merged 1 commit into
mainfrom
reserve-run-ids-atomically
Aug 26, 2026
Merged

Reserve run IDs atomically#184
Kubuxu merged 1 commit into
mainfrom
reserve-run-ids-atomically

Conversation

@Kubuxu

@Kubuxu Kubuxu commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • atomically reserve each generated run ID by creating its run directory
  • retry when another process has already reserved the same ID
  • propagate reservation failures during startup

Rationale

Random run ID collisions can occur in tests with an estimated probability of 1 in 1,600. Concurrent processes currently have no atomic claim step, so duplicate IDs can cause flaky tests and shared run state. Atomic directory creation removes that race.

This change was split out of #180 so it can be reviewed and merged separately.

Verification

  • cargo test --lib (50 passed)

Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Copilot AI lite review requested due to automatic review settings August 25, 2026 11:49
@Kubuxu
Kubuxu requested review from beck-8 and rvagg as code owners August 25, 2026 11:49
@FilOzzy FilOzzy added this to FOC Aug 25, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Aug 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the reliability of run ID generation by turning it into an atomic “claim” operation: a candidate run ID is only accepted if its corresponding run directory can be created, preventing concurrent processes from sharing the same run ID and run state.

Changes:

  • Update generate_run_id to atomically reserve the run ID via directory creation, retrying on collisions.
  • Add internal helpers for candidate generation and reservation, and adjust tests to validate reservation behavior.
  • Propagate run ID reservation errors to the CLI entrypoint (main) via Result.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/run_id/mod.rs Implements atomic run ID reservation using create_dir and updates tests to validate reserved IDs.
src/main.rs Adapts to the new fallible generate_run_id() API by propagating errors with ?.
Suppressed comments (1)

src/run_id/mod.rs:146

  • This test unconditionally imports std::os::unix::fs::symlink, which will fail to compile on Windows targets. Since create_latest_symlink has Windows support, the test should be gated to Unix (or implemented with platform-specific symlink creation).
    #[test]
    fn test_create_latest_symlink_handles_broken_symlinks() {
        // This test verifies that create_latest_symlink properly handles
        // removing broken symlinks and creating new ones
        use std::os::unix::fs::symlink;

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Kubuxu

Kubuxu commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

CI failed with Execution failed for Deploy Multicall3 Contract: Multicall3 deployment failed checking for flake

@FilOzzy FilOzzy moved this from 📌 Triage to 🔎 Awaiting review in FOC Aug 25, 2026
@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC Aug 26, 2026
@Kubuxu
Kubuxu merged commit a7e8436 into main Aug 26, 2026
7 of 8 checks passed
@Kubuxu
Kubuxu deleted the reserve-run-ids-atomically branch August 26, 2026 10:56
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

5 participants