Skip to content

Conversation

@rkuhn
Copy link
Contributor

@rkuhn rkuhn commented Jun 18, 2025

also return next wakeup in Blocked::Sleeping and add Running::next_wakeup() accessor

Signed-off-by: Roland Kuhn [email protected]

Summary by CodeRabbit

  • New Features
    • Added the ability to advance the simulation clock up to a specified time or until the next scheduled wakeup.
    • Introduced methods to retrieve the next scheduled wakeup time and to run the simulation until either blocked or a given time is reached.
  • Bug Fixes
    • Improved reporting for blocked states by including the next wakeup time.
  • Tests
    • Enhanced tests to verify new clock advancement behaviors with optional time limits.

also return next wakeup in Blocked::Sleeping and add Running::next_wakeup() accessor

Signed-off-by: Roland Kuhn <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

Walkthrough

The simulation’s time management got a slick upgrade: now you can skip the clock to a specified max time, not just the next wakeup. The Blocked::Sleeping variant now carries the next wakeup time, and new methods let you peek at upcoming wakeups or run until a time or block. Tests were updated to groove with these new moves, and tokio got a dev-dep boost for multi-threaded runtime action.

Changes

File(s) Change Summary
crates/pure-stage/Cargo.toml Added tokio as a dev-dependency with multi-threaded runtime features (rt-multi-thread).
crates/pure-stage/src/simulation/blocked.rs Changed Blocked::Sleeping from unit to struct variant holding next_wakeup: Instant; assert_sleeping now returns Instant.
crates/pure-stage/src/simulation/running.rs skip_to_next_wakeup now accepts optional max_time; added next_wakeup and run_until_blocked_or_time. Blocking logic updated to include next wakeup time.
crates/pure-stage/tests/simulation.rs Enhanced clock_manual test to check skip_to_next_wakeup(Some(time)) behaviour and timing; added checks for sleeping state with next wakeup.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test
    participant Sim as SimulationRunning
    participant Blocked as Blocked

    Test->>Sim: skip_to_next_wakeup(Some(time))
    Sim->>Sim: Advance clock to min(next_wakeup, time)
    Sim-->>Test: Return true if wakeup occurred, else false

    Test->>Sim: skip_to_next_wakeup(None)
    Sim->>Sim: Advance clock to next_wakeup
    Sim-->>Test: Return result

    Sim->>Sim: next_wakeup()
    Sim-->>Test: Return Option<Instant>

    Sim->>Sim: run_until_blocked_or_time(time)
    Sim->>Sim: Loop until blocked or time reached

    Sim->>Blocked: block_reason()
    Blocked-->>Sim: Return Sleeping { next_wakeup } or Idle
Loading

Poem

Here’s to the clock that now skips with flair,
Like Link on Epona, it’s swift through the air.
Sleeping no more just a silent state,
It holds next wakeup, it controls its fate.
Tests keep it honest, no bugs in the mix,
Simulation’s tighter—like a well-tuned fix!
⏳🎮🐴


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8cc2f45 and 5d13537.

📒 Files selected for processing (2)
  • crates/pure-stage/src/simulation/running.rs (4 hunks)
  • crates/pure-stage/tests/simulation.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/pure-stage/tests/simulation.rs
  • crates/pure-stage/src/simulation/running.rs
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Examples (ledger-in-nodejs)
  • GitHub Check: Snapshots (preprod, 1, 10.1.4)
  • GitHub Check: Build on ubuntu-24.04 with target aarch64-unknown-linux-musl
  • GitHub Check: Build on macos-latest with target aarch64-apple-darwin
  • GitHub Check: Build on ubuntu-latest with target riscv32im-risc0-zkvm-elf
  • GitHub Check: Build on windows-latest with target x86_64-pc-windows-msvc
  • GitHub Check: Coverage
  • GitHub Check: Build on ubuntu-latest with target x86_64-unknown-linux-gnu
  • GitHub Check: Sanity
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

Attention: Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/pure-stage/src/simulation/running.rs 92.85% 2 Missing ⚠️
Files with missing lines Coverage Δ
crates/pure-stage/src/simulation/blocked.rs 60.60% <100.00%> (ø)
crates/pure-stage/src/simulation/running.rs 84.94% <92.85%> (+0.10%) ⬆️

... and 8 files with indirect coverage changes

🚀 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.

@stevana stevana self-requested a review June 19, 2025 05:56
rkuhn and others added 3 commits June 19, 2025 12:32
Signed-off-by: Roland Kuhn <[email protected]>
Signed-off-by: Roland Kuhn <[email protected]>
@rkuhn rkuhn force-pushed the rk/run_until_blocked_or_time branch from 8cc2f45 to 5d13537 Compare June 19, 2025 10:33
@rkuhn rkuhn merged commit 83e5d16 into main Jun 19, 2025
13 checks passed
@rkuhn rkuhn deleted the rk/run_until_blocked_or_time branch June 19, 2025 11:39
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.

3 participants