Skip to content

Extract torrust-clock to a standalone repository #1879

Closed

Description

@josecelano

Goal

Move the torrust-clock crate out of the torrust-tracker workspace into its own standalone repository so that it can be maintained, versioned, and published independently of the tracker.

Background

The torrust-clock package provides a mockable time abstraction for deterministic testing. It contains no tracker-specific logic, making it a general-purpose utility reusable by any Rust project (e.g., torrust-index already contains a local copy of equivalent clock code). Keeping it inside the tracker workspace couples its release cycle to the tracker's and limits its visibility to potential consumers.

After the preceding subissues are complete (torrust-tracker-clock renamed to torrust-clock and DurationSinceUnixEpoch moved from torrust-tracker-primitives to torrust-clock), the crate has zero workspace-path dependencies — all its runtime deps (chrono, tracing) are published crates. Extraction is therefore unblocked.

Prerequisites:

  1. Clock rename subissue (Rename torrust-tracker-clock to torrust-clock #1821) must be complete — in particular T8 (publish torrust-clock on crates.io).
  2. DurationSinceUnixEpoch move subissue (Move DurationSinceUnixEpoch from torrust-tracker-primitives to torrust-tracker-clock #1790) must be complete — in particular T4 (torrust-tracker-primitives dep removed from packages/clock/Cargo.toml).

This issue is a subissue of EPIC #1669 (Overhaul: Packages).

Scope

In Scope

  • Create a new standalone repository torrust/torrust-clock in the Torrust GitHub organization.
  • Move packages/clock/ to the new repository, preserving git history (using git filter-repo).
  • Verify the standalone repository builds and tests pass independently.
  • Set up CI in the new repository (mirror the relevant CI workflows from the tracker repo).
  • Update all 13 workspace consumers (root Cargo.toml + 12 packages) to reference torrust-clock as a crates.io version dependency instead of a path dependency.
  • Remove packages/clock from the workspace members list in root Cargo.toml.
  • Delete the packages/clock/ directory from the tracker repository.
  • Update prose references in packages/AGENTS.md, AGENTS.md, and docs/packages.md (move torrust-clock to the "Extracted" section).

Out of Scope

  • Changes to the crate's API or behaviour.
  • Yanking the old crates.io name torrust-tracker-clock (that is handled by the rename subissue T11, after torrust-index migration).

Workspace consumers to migrate

The following 13 files must have their torrust-clock dep changed from a path dep to a crates.io version dep:

  • Cargo.toml (root — workspace dep registration)
  • packages/axum-health-check-api-server/Cargo.toml
  • packages/axum-http-server/Cargo.toml
  • packages/axum-rest-api-server/Cargo.toml
  • packages/http-protocol/Cargo.toml
  • packages/http-tracker-core/Cargo.toml
  • packages/metrics/Cargo.toml
  • packages/primitives/Cargo.toml
  • packages/swarm-coordination-registry/Cargo.toml
  • packages/tracker-core/Cargo.toml
  • packages/torrent-repository-benchmarking/Cargo.toml
  • packages/udp-server/Cargo.toml
  • packages/udp-tracker-core/Cargo.toml

Implementation Plan

ID Task Notes / Expected Output
T1 Verify clock rename completion state (T8 of rename spec: torrust-clock published on crates.io) packages/clock/Cargo.toml has name = "torrust-clock"
T2 Verify DurationSinceUnixEpoch move completion state (T4 of move spec) packages/clock/Cargo.toml does not list torrust-tracker-primitives
T3 Create standalone repository torrust/torrust-clock Empty repo with license and basic README
T4 Move packages/clock/ to the new repository, preserving git history (git filter-repo) New repo contains full history for packages/clock/
T5 Verify standalone repository: cargo build and cargo test pass with no path deps Clean build in the new repo; Cargo.toml has only external (non-path) deps
T6 Set up CI in the new repository Copy/adapt relevant GitHub Actions workflows; CI passes
T7 Update all 13 workspace consumers (see list above): path dep → crates.io version dep torrust-clock = "X.Y.Z" (or workspace dep) in each Cargo.toml
T8 Remove packages/clock entry from workspace members in root Cargo.toml packages/clock absent from [workspace] members list
T9 Delete packages/clock/ directory from the tracker repository Directory removed; git status shows deletions
T10 Update packages/AGENTS.md, AGENTS.md, docs/packages.md torrust-clock moved to an "Extracted packages" section
T11 Run cargo build --workspace and cargo test --workspace Clean build and all tests pass
T12 Run linter all Exit code 0
T13 Update EPIC #1669 tables Package inventory and desired state tables updated; subissue row set to DONE

Acceptance Criteria

  • A standalone repository torrust/torrust-clock exists on GitHub.
  • The repository contains the full git history for packages/clock/.
  • CI in the new repository passes.
  • No Cargo.toml in the tracker workspace references torrust-clock with a path dep.
  • packages/clock is absent from the [workspace] members list in root Cargo.toml.
  • The packages/clock/ directory no longer exists in the tracker repository.
  • cargo build --workspace in the tracker repository succeeds with zero errors.
  • cargo test --workspace in the tracker repository passes with zero failures.
  • linter all exits with code 0.
  • packages/AGENTS.md, AGENTS.md, and docs/packages.md reflect the extraction.

Related to #1669

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions