feat(clock): move DurationSinceUnixEpoch to torrust-tracker-clock (#1790)#1791
Conversation
…Epoch to torrust-tracker-clock)
…rrust#1790) Move the `DurationSinceUnixEpoch` type alias from `torrust-tracker-primitives` into `torrust-tracker-clock`, where it semantically belongs as it measures time relative to the Unix epoch — a clock-domain concept. Changes: - `torrust-tracker-clock`: add `pub type DurationSinceUnixEpoch = std::time::Duration` - `torrust-tracker-clock/Cargo.toml`: remove `torrust-tracker-primitives` dependency - `torrust-tracker-primitives/src/lib.rs`: replace type definition with `#[deprecated] pub use torrust_tracker_clock::DurationSinceUnixEpoch` for backward compatibility - `torrust-tracker-primitives/src/peer.rs`: import `DurationSinceUnixEpoch` directly from `torrust_tracker_clock` to avoid triggering the deprecation warning internally - `torrust-tracker-metrics/Cargo.toml`: replace `torrust-tracker-primitives` dep with `torrust-tracker-clock` - All workspace consumers (77 files): update import path from `torrust_tracker_primitives::DurationSinceUnixEpoch` to `torrust_tracker_clock::DurationSinceUnixEpoch` - Issue spec and EPIC updated Resolves torrust#1790.
…ptance criteria checked
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Moves the DurationSinceUnixEpoch type alias from torrust-tracker-primitives to torrust-tracker-clock, so torrust-tracker-clock no longer depends on torrust-tracker-primitives. A deprecated re-export is kept in torrust-tracker-primitives for backward compatibility, and all workspace consumers are updated to import from the new location.
Changes:
- Define
DurationSinceUnixEpochintorrust-tracker-clockand drop its dep ontorrust-tracker-primitives. - Add a deprecated re-export in
torrust-tracker-primitives(which now depends ontorrust-tracker-clock) and updatepeer.rsto import directly. - Update ~77 workspace files (and
torrust-tracker-metricsCargo.toml) to import the type fromtorrust_tracker_clock.
Reviewed changes
Copilot reviewed 90 out of 91 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/clock/src/lib.rs | Adds pub type DurationSinceUnixEpoch |
| packages/clock/Cargo.toml | Removes torrust-tracker-primitives dep |
| packages/clock/src/{clock,conv,clock/working,clock/stopped}/...rs | Switch imports to local definition |
| packages/primitives/src/lib.rs | Adds deprecated re-export from clock |
| packages/primitives/Cargo.toml | Adds torrust-tracker-clock dep |
| packages/primitives/src/peer.rs | Imports directly from clock to bypass deprecation |
| packages/metrics/Cargo.toml | Swaps primitives → clock dep |
| packages/metrics/src/**.rs | Import path updates |
| packages/{tracker-core,udp-tracker-core,udp-tracker-server,http-tracker-core,swarm-coordination-registry,torrent-repository-benchmarking,axum-rest-tracker-api-server}/...rs | Import path updates |
| docs/issues/open/1790-...md | New issue spec documenting the move |
| docs/issues/drafts/1669-02-...md | Old draft spec deleted |
| docs/issues/open/1669-overhaul-packages/EPIC.md | Marks SI-02 DONE and updates extraction table |
Comments suppressed due to low confidence (3)
packages/primitives/src/lib.rs:1
- Issue #1790 is this very PR's issue (the move itself), and its acceptance criteria mark it DONE without removing the re-export. The "Out of Scope" section of the spec explicitly defers removal to "a separate cleanup subissue." The deprecation note should point to a new (future) cleanup issue, or at minimum say "to be tracked in a follow-up subissue of #1669"; otherwise consumers chasing the link will find a closed/done issue with no actionable removal plan.
packages/primitives/src/lib.rs:1 - The
sincevalue"3.0.0-develop"is not a valid semver release identifier —sinceis intended to be the version in which the item became deprecated. Using a pre-release/develop marker here is misleading once the crate is published. Consider using the next planned crates.io version (e.g., the upcoming3.x.yrelease) instead.
packages/primitives/src/lib.rs:1 - Because this is a
pub usere-export marked#[deprecated], any downstream crate that still usestorrust_tracker_primitives::DurationSinceUnixEpochwill start getting adeprecatedwarning. If the workspace (or any downstream consumer) compiles with-D deprecated/#![deny(deprecated)], this will break their build. Consider documenting this consequence in the PR description / changelog, or gating the warning behind a feature flag during the transition period.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| --- | ||
| doc-type: issue | ||
| issue-type: task | ||
| status: draft |
| **Circular dep constraint**: `torrust-tracker-primitives` must **not** re-export the type | ||
| from `torrust-tracker-clock`. That would introduce a new `torrust-tracker-primitives` → | ||
| `torrust-tracker-clock` dependency edge. Instead, `torrust-tracker-primitives` retains its | ||
| own independent `pub type DurationSinceUnixEpoch = Duration` definition. Once all workspace | ||
| consumers have been migrated to `torrust_tracker_clock::DurationSinceUnixEpoch`, the copy | ||
| in `torrust-tracker-primitives` can be deprecated and removed in a future cleanup. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1791 +/- ##
===========================================
+ Coverage 77.67% 77.72% +0.05%
===========================================
Files 378 378
Lines 28599 28599
Branches 28599 28599
===========================================
+ Hits 22213 22229 +16
+ Misses 6074 6060 -14
+ Partials 312 310 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Fix spec status: draft -> open - Rewrite obsolete 'Circular dep constraint' paragraph to describe the actual implementation (primitives -> clock dep, deprecated re-export) - Fix deprecation note reference: torrust#1790 -> EPIC torrust#1669 (the correct place to track removal as a future cleanup subissue)
|
ACK a6bd710 |
Summary
Move the
DurationSinceUnixEpochtype alias fromtorrust-tracker-primitivesintotorrust-tracker-clock, where it semantically belongs.Closes #1790.
Motivation
DurationSinceUnixEpochis a trivial alias forstd::time::Durationwith no tracker-specific logic. It lives intorrust-tracker-primitivesonly by historical accident. The primary user istorrust-tracker-clock(theClocktrait and conversion helpers), which had to carry atorrust-tracker-primitivesdependency solely for this type. Moving it:torrust-tracker-primitivesdep fromtorrust-tracker-clock, making it dependency-lightertorrust-tracker-clockfor future extraction to a standalone repository (SI-09, SI-13 in EPIC Overhaul: packages #1669)Changes
packages/clock/src/lib.rs— addpub type DurationSinceUnixEpoch = std::time::Durationpackages/clock/Cargo.toml— removetorrust-tracker-primitivesdependencypackages/primitives/src/lib.rs— replace the type definition with#[deprecated] pub use torrust_tracker_clock::DurationSinceUnixEpoch(backward-compatible re-export; deprecated to guide consumers to the new path)packages/primitives/src/peer.rs— importDurationSinceUnixEpochdirectly fromtorrust_tracker_clock(bypasses the deprecated re-export to keep the build clean under-D deprecated)packages/metrics/Cargo.toml— replacetorrust-tracker-primitivesdep withtorrust-tracker-clock.rsfiles — update import path fromtorrust_tracker_primitives::DurationSinceUnixEpochtotorrust_tracker_clock::DurationSinceUnixEpochVerification
cargo build --workspace— clean (zero errors, zero warnings)cargo test --doc --workspace— all passcargo test --tests --benches --examples --workspace --all-targets --all-features— all passlinter all— all linters pass (markdown, yaml, toml, cspell, clippy, rustfmt, shellcheck)cargo machete— no unused dependencies