Repository navigation
refactor(clock): rename crate torrust-tracker-clock to torrust-clock - #1822
Conversation
… torrust-clock - Move spec from drafts/ to open/ with issue number prefix 1821 - Update spec: issue number, branch, defer crates.io tasks to SI-13 - Update EPIC torrust#1669 SI-09 row with issue torrust#1821 link and open spec path
…ust#1821 Rename the `torrust-tracker-clock` crate to `torrust-clock` as specified in issue torrust#1821 (sub-issue SI-09 of EPIC torrust#1669). - Rename `name` in `packages/clock/Cargo.toml` - Update root workspace dependency key - Update all 12 dependent package `Cargo.toml` files - Replace all `torrust_tracker_clock::` references in Rust source files - Update prose in README, AGENTS.md, docs/release_process.md, skills Crates.io publish/deprecation/yank steps are deferred to SI-13. All CI checks pass: `cargo build --workspace`, `cargo test --workspace`, `linter all`.
There was a problem hiding this comment.
Pull request overview
This PR renames the Rust crate torrust-tracker-clock to torrust-clock across the workspace to reflect that the clock utility is tracker-agnostic and reusable by other Torrust projects (e.g. torrust-index), updating all code and docs accordingly.
Changes:
- Renamed the clock crate in
packages/clock/Cargo.tomland updated workspace/dependentCargo.tomlreferences. - Updated Rust import paths from
torrust_tracker_clock::...totorrust_clock::...across the codebase (including tests). - Updated multiple documentation/spec files and skills to refer to the new crate name.
Reviewed changes
Copilot reviewed 138 out of 139 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/integration.rs |
Update integration test imports to torrust_clock. |
src/lib.rs |
Update crate-level import to torrust_clock. |
src/bootstrap/jobs/activity_metrics_updater.rs |
Update Time import path to torrust_clock. |
src/bootstrap/app.rs |
Call torrust_clock::initialize_static(). |
src/app.rs |
Update Time import path to torrust_clock. |
packages/udp-tracker-server/tests/integration.rs |
Update integration test imports to torrust_clock. |
packages/udp-tracker-server/src/statistics/repository.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/udp-tracker-server/src/statistics/metrics.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/udp-tracker-server/src/statistics/event/listener.rs |
Switch Time import to torrust_clock. |
packages/udp-tracker-server/src/statistics/event/handler/response_sent.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/udp-tracker-server/src/statistics/event/handler/request_received.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/udp-tracker-server/src/statistics/event/handler/request_banned.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/udp-tracker-server/src/statistics/event/handler/request_accepted.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/udp-tracker-server/src/statistics/event/handler/request_aborted.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/udp-tracker-server/src/statistics/event/handler/mod.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/udp-tracker-server/src/statistics/event/handler/error.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/udp-tracker-server/src/server/mod.rs |
Update static initialization to torrust_clock. |
packages/udp-tracker-server/src/lib.rs |
Switch clock imports and test helper types to torrust_clock. |
packages/udp-tracker-server/src/handlers/mod.rs |
Switch Time import to torrust_clock. |
packages/udp-tracker-server/src/environment.rs |
Update static initialization to torrust_clock. |
packages/udp-tracker-server/src/banning/event/listener.rs |
Switch Time import to torrust_clock. |
packages/udp-tracker-server/src/banning/event/handler.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/udp-tracker-server/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/udp-tracker-core/src/statistics/repository.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/udp-tracker-core/src/statistics/metrics.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/udp-tracker-core/src/statistics/event/listener.rs |
Switch Time import to torrust_clock. |
packages/udp-tracker-core/src/statistics/event/handler.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/udp-tracker-core/src/peer_builder.rs |
Switch Time import to torrust_clock. |
packages/udp-tracker-core/src/lib.rs |
Switch clock import to torrust_clock. |
packages/udp-tracker-core/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/tracker-core/tests/common/test_env.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/tests/common/fixtures.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/torrent/services.rs |
Switch DurationSinceUnixEpoch import in tests to torrust_clock. |
packages/tracker-core/src/torrent/repository/in_memory.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/torrent/mod.rs |
Update doc example import to torrust_clock. |
packages/tracker-core/src/torrent/manager.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock (including tests). |
packages/tracker-core/src/test_helpers.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/statistics/repository.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/statistics/persisted/mod.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/statistics/metrics.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/statistics/event/listener.rs |
Switch Time import to torrust_clock. |
packages/tracker-core/src/statistics/event/handler.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/peer_tests.rs |
Switch clock trait/type imports to torrust_clock. |
packages/tracker-core/src/lib.rs |
Switch clock import to torrust_clock. |
packages/tracker-core/src/databases/driver/sqlite/auth_key_store.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/databases/driver/postgres/auth_key_store.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/tracker-core/src/authentication/key/peer_key.rs |
Switch DurationSinceUnixEpoch/conv imports to torrust_clock. |
packages/tracker-core/src/authentication/key/mod.rs |
Switch DurationSinceUnixEpoch/Time imports and doc example to torrust_clock. |
packages/tracker-core/src/authentication/handler.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock (including tests). |
packages/tracker-core/src/announce_handler.rs |
Switch doc example/test imports to torrust_clock. |
packages/tracker-core/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/torrent-repository-benchmarking/tests/repository/mod.rs |
Switch clock imports in tests to torrust_clock. |
packages/torrent-repository-benchmarking/tests/integration.rs |
Update integration test imports to torrust_clock. |
packages/torrent-repository-benchmarking/tests/entry/mod.rs |
Switch clock imports in tests to torrust_clock. |
packages/torrent-repository-benchmarking/tests/common/torrent.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/tests/common/repo.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/repository/skip_map_mutex_std.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_tokio.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_std.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/repository/rw_lock_std.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_tokio.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_std.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/repository/mod.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/repository/dash_map_mutex_std.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/lib.rs |
Switch clock import to torrust_clock. |
packages/torrent-repository-benchmarking/src/entry/single.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/entry/rw_lock_parking_lot.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/entry/peer_list.rs |
Switch DurationSinceUnixEpoch imports to torrust_clock (including tests). |
packages/torrent-repository-benchmarking/src/entry/mutex_tokio.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/entry/mutex_std.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/entry/mutex_parking_lot.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/src/entry/mod.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/torrent-repository-benchmarking/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/torrent-repository-benchmarking/benches/helpers/utils.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/swarm-coordination-registry/src/swarm/registry.rs |
Switch DurationSinceUnixEpoch/conv imports to torrust_clock (including tests). |
packages/swarm-coordination-registry/src/swarm/coordinator.rs |
Switch DurationSinceUnixEpoch imports to torrust_clock (including tests). |
packages/swarm-coordination-registry/src/statistics/repository.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/swarm-coordination-registry/src/statistics/metrics.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/swarm-coordination-registry/src/statistics/event/listener.rs |
Switch Time import to torrust_clock. |
packages/swarm-coordination-registry/src/statistics/event/handler.rs |
Switch DurationSinceUnixEpoch and clock imports to torrust_clock (including tests). |
packages/swarm-coordination-registry/src/statistics/activity_metrics_updater.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock. |
packages/swarm-coordination-registry/src/lib.rs |
Switch clock imports (and tests) to torrust_clock. |
packages/swarm-coordination-registry/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/primitives/src/peer.rs |
Switch DurationSinceUnixEpoch imports/docs to torrust_clock. |
packages/primitives/src/lib.rs |
Update deprecated re-export docs/note to torrust_clock. |
packages/primitives/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/metrics/src/sample.rs |
Switch DurationSinceUnixEpoch imports to torrust_clock (including tests). |
packages/metrics/src/sample_collection.rs |
Switch DurationSinceUnixEpoch imports to torrust_clock (including tests). |
packages/metrics/src/prometheus.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/metrics/src/metric/mod.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/metrics/src/metric/aggregate/sum.rs |
Switch DurationSinceUnixEpoch import in tests to torrust_clock. |
packages/metrics/src/metric/aggregate/avg.rs |
Switch DurationSinceUnixEpoch import in tests to torrust_clock. |
packages/metrics/src/metric_collection/serde.rs |
Switch DurationSinceUnixEpoch import in tests to torrust_clock. |
packages/metrics/src/metric_collection/prometheus.rs |
Switch DurationSinceUnixEpoch imports to torrust_clock (including tests). |
packages/metrics/src/metric_collection/mod.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/metrics/src/metric_collection/kind_collection.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/metrics/src/metric_collection/aggregate/sum.rs |
Switch DurationSinceUnixEpoch import in tests to torrust_clock. |
packages/metrics/src/metric_collection/aggregate/avg.rs |
Switch DurationSinceUnixEpoch import in tests to torrust_clock. |
packages/metrics/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/http-tracker-core/src/statistics/repository.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/http-tracker-core/src/statistics/metrics.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/http-tracker-core/src/statistics/event/listener.rs |
Switch Time import to torrust_clock. |
packages/http-tracker-core/src/statistics/event/handler.rs |
Switch DurationSinceUnixEpoch/Time imports to torrust_clock (including tests). |
packages/http-tracker-core/src/services/scrape.rs |
Switch DurationSinceUnixEpoch import in tests to torrust_clock. |
packages/http-tracker-core/src/lib.rs |
Switch clock imports (and tests) to torrust_clock. |
packages/http-tracker-core/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/http-tracker-core/benches/helpers/util.rs |
Switch DurationSinceUnixEpoch import to torrust_clock. |
packages/http-protocol/src/v1/requests/announce.rs |
Switch Time import to torrust_clock. |
packages/http-protocol/src/lib.rs |
Switch clock import to torrust_clock. |
packages/http-protocol/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/clock/tests/integration.rs |
Update internal test CurrentClock type aliases to torrust_clock. |
packages/clock/tests/clock/mod.rs |
Switch Time import to torrust_clock. |
packages/clock/src/lib.rs |
Update doc comment mention to torrust-clock. |
packages/clock/README.md |
Rename README title/linking to torrust-clock. |
packages/clock/Cargo.toml |
Rename package name and update metadata. |
packages/axum-rest-tracker-api-server/tests/integration.rs |
Update integration test imports to torrust_clock. |
packages/axum-rest-tracker-api-server/src/v1/context/torrent/resources/torrent.rs |
Switch DurationSinceUnixEpoch import in tests to torrust_clock. |
packages/axum-rest-tracker-api-server/src/v1/context/auth_key/resources.rs |
Switch conv/clock imports to torrust_clock (including tests). |
packages/axum-rest-tracker-api-server/src/server.rs |
Update static initialization to torrust_clock. |
packages/axum-rest-tracker-api-server/src/lib.rs |
Switch clock import to torrust_clock. |
packages/axum-rest-tracker-api-server/src/environment.rs |
Update static initialization to torrust_clock. |
packages/axum-rest-tracker-api-server/Cargo.toml |
Rename dependency key to torrust-clock. |
packages/axum-http-tracker-server/tests/integration.rs |
Update integration test imports to torrust_clock. |
packages/axum-http-tracker-server/src/server.rs |
Update static initialization to torrust_clock. |
packages/axum-http-tracker-server/src/environment.rs |
Update static initialization to torrust_clock. |
packages/axum-http-tracker-server/Cargo.toml |
Rename dependency key(s) to torrust-clock. |
packages/axum-health-check-api-server/tests/integration.rs |
Update integration test imports to torrust_clock. |
packages/axum-health-check-api-server/Cargo.toml |
Rename dependency key to torrust-clock. |
docs/release_process.md |
Update published-crates list to torrust-clock. |
docs/issues/open/1821-1669-09-rename-torrust-tracker-clock-to-torrust-clock.md |
Update issue spec metadata/content to reflect rename work. |
docs/issues/open/1669-overhaul-packages/EPIC.md |
Update EPIC inventory/plan tables to include torrust-clock. |
contrib/dev-tools/analysis/workspace-coupling/src/main.rs |
Update observation strings to use torrust-clock naming. |
Cargo.toml |
Rename workspace dependency key to torrust-clock. |
Cargo.lock |
Update lockfile entries for the renamed crate. |
AGENTS.md |
Update package catalog row to the new crate name. |
.github/skills/dev/testing/write-unit-test/SKILL.md |
Update skill examples to torrust_clock. |
.github/skills/dev/git-workflow/release-new-version/SKILL.md |
Update release skill published-crates list to torrust-clock. |
Comments suppressed due to low confidence (1)
docs/issues/open/1821-1669-09-rename-torrust-tracker-clock-to-torrust-clock.md:50
- This paragraph says publishing
torrust-clockis deferred to SI-13, but elsewhere in this PR the docs now treattorrust-clockas a crate that gets published during releases (e.g.docs/release_process.mdand the EPIC inventory marks it as published on crates.io). Please reconcile the documentation: either clarify that only the deprecation/yank oftorrust-tracker-clockis deferred (whiletorrust-clockwill be published on the next release), or update the other docs/EPIC to reflect that publishing is indeed deferred.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- EPIC Package Inventory: mark torrust-clock as unpublished (No) since the new crate name is not yet on crates.io; publishing is deferred to SI-13 - workspace-coupling: replace stale thin-dep bullets with a note that both were resolved (SI-02 and SI-03 respectively)
The VS Code `currentActivePullRequest` and `pullRequestInViewport` tools do not detect fork-based PRs. Since all contributor PRs in this repository are fork-based, clarify that GitHub CLI GraphQL is the primary path for fetching and resolving review threads in both the fetch-review-threads and resolve-review-threads skills.
|
ACK d956c7e |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1822 +/- ##
========================================
Coverage 77.70% 77.70%
========================================
Files 379 379
Lines 28605 28604 -1
Branches 28605 28604 -1
========================================
Hits 22227 22227
- Misses 6066 6072 +6
+ Partials 312 305 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
da2ce7
left a comment
There was a problem hiding this comment.
This is a post-merge review of the change from #1822 as it stands at e170b9620 on the default branch.
What still runs: the clock crate left the workspace in ecbc59d and now resolves from crates.io as torrust-clock 3.0.0, with its checksum pinned in Cargo.lock. What survives of this change is the torrust_clock:: import paths and the CurrentClock aliases in the consumer packages, the deprecation note at packages/primitives/src/lib.rs:49, and the observations text in the workspace-coupling report generator. When this merged, the publish job in .github/workflows/deployment.yaml still ran cargo publish -p torrust-tracker-clock; 33cca9f removed that line, so it is history.
[Minor] An expiring key whose expiry is later than the last instant chrono can represent (year 262143, about 8.2e12 seconds after the epoch) is accepted and stored, and building the reply then panics. The lifetime check at packages/tracker-core/src/authentication/key/mod.rs:111, and at packages/tracker-core/src/authentication/handler.rs:102 for an uploaded key, rejects only a u64 overflow of now plus the lifetime. The SQLite and PostgreSQL stores accept any expiry up to i64::MAX seconds (packages/tracker-core/src/databases/driver/sqlite/auth_key_store.rs:49). After that, peer_key_to_auth_key at packages/rest-api-runtime-adapter/src/v1/adapters/auth_key.rs:88 calls PeerKey::expiry_time, and convert_from_timestamp_to_datetime_utc at packages/tracker-core/src/authentication/key/peer_key.rs:105 unwraps the None that DateTime::from_timestamp returns for such a value. With POST /api/v1/key/10000000000000, or POST /api/v1/keys with {"key": null, "seconds_valid": 10000000000000}, the handler panics and the connection closes without a response. The key is nevertheless already in the database and in memory, so the API reports nothing for a change it made, and a retry on the generate route stores another key. The # Panics note at packages/tracker-core/src/authentication/key/peer_key.rs:96 names only the i64 limit (292.5 billion years), but the limit actually reached is chrono's much smaller one. Smallest fix: in generate_key and in add_peer_key, return DurationOverflow before anything is stored when DateTime::from_timestamp has no value for the computed expiry, and correct the # Panics text.
[Nit] contrib/dev-tools/analysis/workspace-coupling/src/main.rs:363 writes "None — previously known thin dependencies have been resolved:" under the heading "Known thin dependencies (pre-existing)", and lines 364-365 then list two dependencies that both run through torrust-clock. Since ecbc59d that crate has not been a workspace member, so neither listed edge can appear in the report the tool generates, and the section reads as both empty and populated. Smallest fix: drop the two hard-coded rows and keep "None.".
Checked and found sound: every CurrentClock alias selects clock::Working under cfg(not(test)) and clock::Stopped under cfg(test), and every Stopped setter call sits in test code. now_add and now_sub use checked arithmetic, and their callers at packages/tracker-core/src/authentication/key/mod.rs:111, packages/tracker-core/src/authentication/handler.rs:102 and packages/tracker-core/src/torrent/manager.rs:104 turn overflow into DurationOverflow or a zero cutoff instead of a panic. The datetime conversion at packages/swarm-coordination-registry/src/swarm/registry.rs:263 only receives a cutoff at or before now. ser_unix_time_value at packages/primitives/src/peer.rs:153 returns an error instead of truncating. The swarm statistics handler at packages/swarm-coordination-registry/src/statistics/event/handler.rs:3 takes its timestamp from the caller. All 12 dependent manifests named in the description were renamed, and no torrust_tracker_clock path or torrust-tracker-clock dependency key remains outside the issue records and a profiling image.
Closes #1821
Part of EPIC #1669 (SI-09)
Summary
Rename the Cargo crate
torrust-tracker-clocktotorrust-clockto reflect that it is a generic, tracker-independent utility usable in any Rust project (e.g.torrust-index).Changes
packages/clock/Cargo.toml—name = "torrust-clock", updated description and keywordsCargo.toml— workspace dependency key renamed fromtorrust-tracker-clocktotorrust-clockCargo.tomlfiles — dependency key updatedtorrust_tracker_clock::→torrust_clock::(and string literals)packages/clock/README.md,AGENTS.md,docs/release_process.md, skillstorrust-clockmoved totorrust-section, SI-09 marked DONEDeferred
Crates.io publish / deprecation notice / yank and
torrust-indexmigration are deferred to SI-13 (extracttorrust-clockto standalone repo).Verification
cargo build --workspace✓cargo test --workspace✓linter all✓