Replace custom build tool clock with mockable Clock (#194)#195
Conversation
Replace the bespoke build-tool clock trait with `mockable::Clock` so production code uses the shared dependency-injection abstraction and tests use `mockable::MockClock` for deterministic duration assertions. Add `mockable` to the manifest with the clock support needed by production code and the mock support needed by the wrapper test.
WalkthroughBuildSoftwareTool removes its custom Clock trait and SystemClock implementation. The struct no longer stores an injected clock; instead, ChangesClock Abstraction Removal
Possibly related issues
Possibly related PRs
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 6 warnings)
✅ Passed checks (13 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideReplaces the custom clock abstraction in the build tool wrapper with the shared mockable::Clock/DefaultClock implementation and updates tests and dependencies to support deterministic, mockable timing. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Ensure that this is validated against the current version of the codegraph. If further refinement to address this finding would be deleterious, please supply a clear explanatory one to two paragraph markdown message I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced. src/tools/builder/core/wrapper_tests.rs Comment on file //! Tests for the build software native-tool wrapper.
use std::sync::{Arc, Mutex};
use std::sync::{❌ New issue: Code Duplication |
This comment was marked as resolved.
This comment was marked as resolved.
Share the execute-and-assert body for analyzer and builder failure tests so the cases keep one assertion path.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35ffcf94e6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .utc() | ||
| .signed_duration_since(start) | ||
| .to_std() | ||
| .unwrap_or_default(), |
There was a problem hiding this comment.
Use monotonic clock for tool duration measurement
This now computes duration from wall-clock UTC timestamps, so if the host clock steps backwards (e.g., NTP/VM time sync) during execution, signed_duration_since(start) becomes negative and to_std().unwrap_or_default() silently reports 0ms. That regresses from the previous monotonic Instant behaviour and can skew tool timing data consumed by metrics and estimators. Please measure elapsed time with a monotonic source (or at least avoid silently collapsing negative deltas to zero).
Useful? React with 👍 / 👎.
Measure `BuildSoftwareTool` execution duration with `Instant` so host wall-clock adjustments cannot collapse elapsed time to zero. Remove the now-unused `mockable` dependency because its clock abstraction only exposes wall-clock time and cannot provide the required monotonic source.
Summary
This branch replaces the bespoke
BuildSoftwareToolclock abstraction withmockable::Clock, so the build tool wrapper follows the shared dependencyinjection pattern for deterministic time tests.
Closes #194.
Review walkthrough
mockable::ClockandDefaultClockreplacing the local trait andSystemClockimplementation.MockClocksnapshot assertion.mockabledependency wiring.Validation
cargo test execute_success_output_matches_snapshot: passed.cargo clippy --workspace: passed.cargo nextest run --workspace --features test-helpers --profile default: passed, 4110 passed, 8 skipped.make all: passed.git diff --check: passed.coderabbit review --agent: attempted after implementation, after local gates, and after commit; CodeRabbit returned recoverable usage rate-limit errors each time.Summary by Sourcery
Replace the build tool’s custom clock abstraction with the shared mockable clock implementation for deterministic timing behavior.
Enhancements:
Build:
Tests: