Skip to content

refactor(primitives): move TrackerPolicy, TORRENT_PEERS_LIMIT, and PrivateMode from configuration to primitives#1865

Merged
josecelano merged 3 commits into
torrust:developfrom
josecelano:1859-1669-move-tracker-policy-and-private-mode-to-primitives
Jun 2, 2026
Merged

refactor(primitives): move TrackerPolicy, TORRENT_PEERS_LIMIT, and PrivateMode from configuration to primitives#1865
josecelano merged 3 commits into
torrust:developfrom
josecelano:1859-1669-move-tracker-policy-and-private-mode-to-primitives

Conversation

@josecelano
Copy link
Copy Markdown
Member

Summary

Closes #1859. Sub-task of #1669.

Moves three types out of torrust-tracker-configuration and into torrust-tracker-primitives:

  • TrackerPolicy struct
  • TORRENT_PEERS_LIMIT constant
  • PrivateMode struct

This breaks the dependency that swarm-coordination-registry and torrent-repository-benchmarking had on the configuration crate purely for these domain types.

Changes

New files

  • packages/primitives/src/policy.rs — defines TrackerPolicy and TORRENT_PEERS_LIMIT
  • packages/primitives/src/mode.rs — defines PrivateMode

Modified files

  • packages/primitives/src/lib.rs — exports new modules
  • packages/configuration/src/lib.rs — removes TrackerPolicy and TORRENT_PEERS_LIMIT
  • packages/configuration/src/v2_0_0/core.rs — removes PrivateMode, updates imports
  • packages/tracker-core/src/announce_handler.rs — updates imports
  • packages/tracker-core/src/torrent/repository/in_memory.rs — updates imports
  • packages/tracker-core/src/authentication/mod.rs — updates imports
  • packages/tracker-core/src/authentication/service.rs — updates imports
  • packages/swarm-coordination-registry/src/swarm/coordinator.rs — updates imports
  • packages/swarm-coordination-registry/src/swarm/registry.rs — updates imports
  • packages/swarm-coordination-registry/Cargo.toml — removes torrust-tracker-configuration dependency
  • packages/torrent-repository-benchmarking/Cargo.toml — removes torrust-tracker-configuration dependency
  • All torrent-repository-benchmarking/src/ and tests/ files — updates imports

Follow-up

Issue #1864 tracks a follow-up decision on whether TORRENT_PEERS_LIMIT should become a runtime config option rather than a compile-time constant.

Testing

  • cargo test --workspace ✅ all pass
  • cargo clippy --workspace -- -D warnings ✅ no warnings
  • linter all ✅ pass
  • cargo machete ✅ pass

…ivateMode from configuration to primitives

Moves three domain primitive types from `torrust-tracker-configuration`
into `torrust-tracker-primitives` where they semantically belong.

- Add `packages/primitives/src/policy.rs` with `TrackerPolicy` struct and
  `TORRENT_PEERS_LIMIT` constant
- Add `packages/primitives/src/mode.rs` with `PrivateMode` struct
- Export new modules from `torrust-tracker-primitives` lib
- Remove types from `torrust-tracker-configuration`
- Update all import sites in `tracker-core`, `swarm-coordination-registry`,
  and `torrent-repository-benchmarking`
- Remove `torrust-tracker-configuration` dependency from
  `swarm-coordination-registry` and `torrent-repository-benchmarking`

Closes torrust#1859
Copilot AI review requested due to automatic review settings June 2, 2026 06:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Moves tracker domain policy/mode primitives out of torrust-tracker-configuration and into torrust-tracker-primitives to reduce coupling across workspace crates (notably removing configuration as a dependency for swarm-coordination-registry and torrent-repository-benchmarking).

Changes:

  • Added policy and mode modules to torrust-tracker-primitives and re-exported TrackerPolicy, TORRENT_PEERS_LIMIT, and PrivateMode.
  • Updated import sites across tracker-core, swarm-coordination-registry, and torrent-repository-benchmarking to use torrust-tracker-primitives.
  • Removed the now-unneeded torrust-tracker-configuration dependencies from downstream crates and updated issue specs/docs.

Reviewed changes

Copilot reviewed 34 out of 35 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/primitives/src/policy.rs New home for TrackerPolicy and TORRENT_PEERS_LIMIT in primitives.
packages/primitives/src/mode.rs New home for PrivateMode in primitives.
packages/primitives/src/lib.rs Exports new primitives modules and re-exports moved types/const.
packages/configuration/src/lib.rs Removes TrackerPolicy and TORRENT_PEERS_LIMIT from configuration crate.
packages/configuration/src/v2_0_0/core.rs Switches Core to use PrivateMode/TrackerPolicy from primitives and removes local PrivateMode.
packages/tracker-core/src/announce_handler.rs Updates imports for TORRENT_PEERS_LIMIT to primitives.
packages/tracker-core/src/torrent/repository/in_memory.rs Updates imports for TrackerPolicy/TORRENT_PEERS_LIMIT to primitives.
packages/tracker-core/src/authentication/mod.rs Updates PrivateMode import to primitives in tests.
packages/tracker-core/src/authentication/service.rs Updates PrivateMode import to primitives in tests.
packages/swarm-coordination-registry/src/swarm/coordinator.rs Updates TrackerPolicy import to primitives.
packages/swarm-coordination-registry/src/swarm/registry.rs Updates TrackerPolicy/TORRENT_PEERS_LIMIT imports to primitives (including tests).
packages/swarm-coordination-registry/Cargo.toml Removes direct dependency on torrust-tracker-configuration.
packages/torrent-repository-benchmarking/Cargo.toml Removes direct dependency on torrust-tracker-configuration.
packages/torrent-repository-benchmarking/tests/repository/mod.rs Updates TrackerPolicy import to primitives for tests.
packages/torrent-repository-benchmarking/tests/entry/mod.rs Updates TrackerPolicy/TORRENT_PEERS_LIMIT imports to primitives for tests.
packages/torrent-repository-benchmarking/tests/common/torrent.rs Updates TrackerPolicy import to primitives in shared test helpers.
packages/torrent-repository-benchmarking/tests/common/repo.rs Updates TrackerPolicy import to primitives in shared test helpers.
packages/torrent-repository-benchmarking/src/repository/skip_map_mutex_std.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_tokio.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_std.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/repository/rw_lock_std.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_tokio.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_std.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/repository/mod.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/repository/dash_map_mutex_std.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/entry/single.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/entry/rw_lock_parking_lot.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/entry/mutex_tokio.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/entry/mutex_std.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/entry/mutex_parking_lot.rs Updates TrackerPolicy import to primitives.
packages/torrent-repository-benchmarking/src/entry/mod.rs Updates TrackerPolicy import to primitives.
docs/issues/open/1864-1669-review-torrent-peers-limit/ISSUE.md Adds follow-up spec for deciding whether TORRENT_PEERS_LIMIT should remain a constant.
docs/issues/closed/1859-1669-move-tracker-policy-and-private-mode-to-primitives/ISSUE.md Marks issue spec as closed and checks acceptance criteria.
Cargo.lock Removes torrust-tracker-configuration deps where no longer required.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +14
/// When true, if the keys is not permanent the expiration date will be
/// ignored. The key will be accepted even if it has expired.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 68.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.79%. Comparing base (3d4bf1f) to head (736a535).

Files with missing lines Patch % Lines
packages/primitives/src/mode.rs 0.00% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1865      +/-   ##
===========================================
- Coverage    77.80%   77.79%   -0.01%     
===========================================
  Files          380      382       +2     
  Lines        28648    28648              
  Branches     28648    28648              
===========================================
- Hits         22290    22288       -2     
+ Misses        6052     6051       -1     
- Partials       306      309       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@josecelano josecelano self-assigned this Jun 2, 2026
- Fix doc link in axum-http-server/src/lib.rs: TORRENT_PEERS_LIMIT now
  lives in torrust_tracker_primitives (was torrust_tracker_configuration)
- Fix spelling: 'localised' -> 'localized' in issue torrust#1864 spec
- Mark FU-1 completed in DECISIONS.md DEC-07 (done in torrust#1859, PR torrust#1865)
- Update EPIC.md footnote: 'will be moved' -> 'were moved'
@josecelano
Copy link
Copy Markdown
Member Author

ACK 736a535

@josecelano josecelano merged commit 0e672e6 into torrust:develop Jun 2, 2026
28 of 30 checks passed
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.

Move TrackerPolicy, TORRENT_PEERS_LIMIT, and PrivateMode from torrust-tracker-configuration to torrust-tracker-primitives

2 participants