Skip to content

Move AnnouncePolicy from torrust-tracker-configuration to torrust-tracker-primitives #1795

Closed

Description

@josecelano

Goal

Move the AnnouncePolicy struct from torrust-tracker-configuration into torrust-tracker-primitives, reversing an inverted dependency where a primitives package depends on a configuration package. After the move, torrust-tracker-configuration depends on torrust-tracker-primitives for AnnouncePolicy, which is the natural direction.

Background

AnnouncePolicy (min/max announce intervals) is a domain concept — it describes the peer communication policy for the BitTorrent announce cycle. Domain concepts belong in primitives, not in configuration, which should be concerned only with config-file parsing and environment variable wiring.

The coupling analysis (F-03) found that torrust-tracker-primitives imports torrust_tracker_configuration::AnnouncePolicy — meaning a primitives package depends on a configuration package. This is an inverted dependency: primitives should sit at the bottom of the dependency graph, with configuration depending on it, not the reverse.

Moving AnnouncePolicy to primitives fixes the inversion:

  • Before: primitives → configuration (for AnnouncePolicy)
  • After: configuration → primitives (for AnnouncePolicy, among other types)

Both packages are published to crates.io. Removing AnnouncePolicy from torrust-tracker-configuration is a semver breaking change for that crate; it will require a major version bump when published. Within this workspace, at version 3.0.0-develop, the change is expected and planned.

This is subissue SI-04 of EPIC #1669 (Overhaul: Packages).

Scope

In Scope

  • Move the AnnouncePolicy struct (and any directly associated types or impl blocks) from packages/configuration/src/ to packages/primitives/src/announce.rs.
  • Remove torrust-tracker-configuration as a dependency of torrust-tracker-primitives; torrust-tracker-primitives must not depend on torrust-tracker-configuration.
  • Update packages/configuration to import AnnouncePolicy from torrust-tracker-primitives; keep a #[deprecated] re-export in configuration for external consumers.
  • Update all other workspace files that import AnnouncePolicy from torrust_tracker_configuration to import it from torrust_tracker_primitives.
  • Remove torrust-tracker-configuration from packages/http-protocol/Cargo.toml (only usage was AnnouncePolicy in test code).
  • Verify the workspace builds and all tests pass.

Out of Scope

  • Any rename of AnnouncePolicy or changes to its fields.
  • Publishing a new crates.io version; the semver bump is handled in the release cycle.
  • Extracting torrust-tracker-primitives to a standalone repository (a later subissue).

Implementation Plan

ID Task
T1 Locate all definition and usage sites of AnnouncePolicy across the workspace
T2 Move AnnouncePolicy definition to packages/primitives/src/announce.rs
T3 Remove AnnouncePolicy from packages/configuration/src/; add deprecated re-export pointing to torrust_tracker_primitives
T4 Add torrust-tracker-primitives as a dep of packages/configuration/Cargo.toml
T5 Remove torrust-tracker-configuration dep from packages/primitives/Cargo.toml
T6 Update all workspace files that import AnnouncePolicy from torrust_tracker_configuration to use torrust_tracker_primitives
T7 Remove torrust-tracker-configuration from packages/http-protocol/Cargo.toml
T8 Run cargo build --workspace and cargo test --workspace
T9 Run linter all and cargo machete

Acceptance Criteria

  • packages/primitives/src/announce.rs defines AnnouncePolicy and exports it publicly.
  • packages/primitives/Cargo.toml does not list torrust-tracker-configuration as a dependency.
  • packages/configuration/src/ no longer defines AnnouncePolicy; it re-exports from torrust-tracker-primitives with a deprecation notice.
  • No workspace file imports AnnouncePolicy from torrust_tracker_configuration directly (all use torrust_tracker_primitives).
  • cargo build --workspace succeeds with zero errors.
  • cargo test --workspace passes with zero failures.
  • linter all exits with code 0.
  • cargo machete reports no unused dependencies.

Part of EPIC #1669.

Activity

  1. self-assigned this
    on May 19, 2026
  2. added 4 commits that reference this issue on May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions