Skip to content

SI-5: Deprecate rest-api-core and remove from workspace - #1957

Merged
josecelano merged 8 commits into
torrust:developfrom
josecelano:1943-si-5-deprecate-rest-api-core
Jun 29, 2026
Merged

josecelano merged 8 commits into
torrust:developfrom
josecelano:1943-si-5-deprecate-rest-api-core

Conversation

@josecelano

Copy link
Copy Markdown
Member

SI-5: Deprecate rest-api-core and remove from workspace

Closes #1943

Summary

After SI-4 migrated the stats context to the contract-first architecture, the rest-api-core package became an empty shell with a single consumer (axum-rest-api-server). This PR:

  1. Moves TrackerHttpApiCoreContainer (DI container) into rest-api-runtime-adapter
  2. Removes the entire packages/rest-api-core/ directory
  3. Updates all import paths across the workspace
  4. Removes workspace dependency and deny.toml wrapper rules
  5. Removes the crate from the deployment publish workflow
  6. Updates all documentation references (AGENTS.md, docs/packages.md)

Changes

Code Changes

  • Moved TrackerHttpApiCoreContainer from rest-api-core to rest-api-runtime-adapter/src/container.rs
  • Updated 7 import paths across axum-rest-api-server and src/ to use rest_api_runtime_adapter::container
  • Added tokio dependency to rest-api-runtime-adapter/Cargo.toml (needed for the container)
  • Removed rest-api-core dependency from axum-rest-api-server/Cargo.toml and root Cargo.toml
  • Deleted entire packages/rest-api-core/ directory (~1100 lines removed)
  • Updated deny.toml — removed rest-api-core from 3 wrapper rules
  • Updated .github/workflows/deployment.yaml — removed cargo publish step

Documentation Changes

  • Converted issue spec to folder format (ISSUE.md)
  • Updated AGENTS.md, packages/AGENTS.md, docs/packages.md
  • Added new use-rest-api skill under .github/skills/usage/
  • Added manual verification evidence to the issue spec

Verification

  • Workspace builds cleanly (cargo check --workspace)
  • Pre-commit checks pass
  • Pre-push checks pass (full test suite incl. workspace-coupling)
  • Manual verification: all API endpoints working correctly (stats, metrics, announce)

Copilot AI review requested due to automatic review settings June 29, 2026 15:19
@josecelano
josecelano requested a review from a team as a code owner June 29, 2026 15:19
@josecelano josecelano self-assigned this Jun 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the now-redundant torrust-tracker-rest-api-core crate from the workspace after the contract-first REST API migration, relocating the remaining DI container wiring into rest-api-runtime-adapter and updating workspace references, publishing workflow, and documentation accordingly.

Changes:

  • Moved TrackerHttpApiCoreContainer into torrust-tracker-rest-api-runtime-adapter and re-exported it from the crate.
  • Updated import paths and Cargo dependencies across the tracker binary and axum-rest-api-server; removed rest-api-core from the workspace, deny wrapper rules, and deployment publishing.
  • Updated documentation/issue specs and added a new use-rest-api skill with skill-link markers.

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/container.rs Switches container import to torrust-tracker-rest-api-runtime-adapter.
src/bootstrap/jobs/tracker_apis.rs Updates REST API container imports (including test module).
share/default/config/tracker.development.sqlite3.toml Adds skill-link: use-rest-api marker for REST API usage workflow.
packages/rest-api-runtime-adapter/src/lib.rs Exposes the new container module publicly.
packages/rest-api-runtime-adapter/src/container.rs New home for TrackerHttpApiCoreContainer wiring.
packages/rest-api-runtime-adapter/Cargo.toml Adds torrust-tracker-configuration and tokio (sync) for container wiring.
packages/rest-api-core/src/statistics/services.rs Deleted as part of removing rest-api-core.
packages/rest-api-core/src/statistics/mod.rs Deleted as part of removing rest-api-core.
packages/rest-api-core/src/statistics/metrics.rs Deleted as part of removing rest-api-core.
packages/rest-api-core/src/lib.rs Deleted as part of removing rest-api-core.
packages/rest-api-core/README.md Deleted as part of removing rest-api-core.
packages/rest-api-core/LICENSE Deleted as part of removing rest-api-core.
packages/rest-api-core/Cargo.toml Deleted as part of removing rest-api-core.
packages/axum-rest-api-server/src/v1/routes.rs Switches REST API container import to runtime-adapter.
packages/axum-rest-api-server/src/v1/middlewares/auth.rs Adds skill-link: use-rest-api marker in rustdoc header.
packages/axum-rest-api-server/src/testing/environment.rs Switches REST API container import to runtime-adapter.
packages/axum-rest-api-server/src/server.rs Switches REST API container import to runtime-adapter (incl. tests).
packages/axum-rest-api-server/src/routes.rs Switches REST API container import to runtime-adapter.
packages/axum-rest-api-server/Cargo.toml Drops dependency on torrust-tracker-rest-api-core.
packages/AGENTS.md Updates architecture docs to remove rest-api-core references.
docs/packages.md Removes rest-api-core references and documents SI-5 removal.
docs/issues/open/1943-1938-si-5-deprecate-rest-api-core/ISSUE.md New folder-based issue spec with manual verification evidence.
docs/issues/open/1943-1938-si-5-deprecate-rest-api-core.md Removes the old single-file issue spec (replaced by folder format).
docs/issues/open/1938-rest-api-contract-first-migration/EPIC.md Updates SI-5 link to point to the folder-based issue spec.
deny.toml Removes rest-api-core from wrapper rules.
Cargo.toml Removes workspace dependency on torrust-tracker-rest-api-core; adds runtime-adapter entry.
Cargo.lock Removes torrust-tracker-rest-api-core package; updates dependencies accordingly.
AGENTS.md Updates package catalog entry from rest-api-core to rest-api-runtime-adapter.
.github/workflows/deployment.yaml Removes cargo publish -p torrust-tracker-rest-api-core step.
.github/skills/usage/use-rest-api/SKILL.md Adds a new skill describing how to use/verify the REST API.

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

Comment thread packages/AGENTS.md Resolved
Comment thread AGENTS.md Resolved
- Fix AGENTS.md: change rest-api-runtime-adapter layer from 'client tools' to 'runtime adapter'
- Fix packages/AGENTS.md: add Runtime Adapter layer to diagram, update description
- Fix ISSUE.md: update status to 'completed', last-updated-utc, check prerequisites and verification
- Fix use-rest-api SKILL.md: add Skill Links section
@josecelano

Copy link
Copy Markdown
Member Author

ACK 5dda558

@josecelano
josecelano merged commit ec8336b into torrust:develop Jun 29, 2026
15 of 16 checks passed

@da2ce7 da2ce7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a post-merge review of the change from #1957 as it stands at e170b9620 on the default branch.

What still runs: the pull request moved TrackerHttpApiCoreContainer out of the removed rest-api-core crate into rest-api-runtime-adapter. It now lives at packages/rest-api-runtime-adapter/src/v1/container.rs (moved into the v1 module by ca1c8ab) and is the type every REST API route receives. Live from the change are the struct with its two constructors, the tokio dependency added for it (packages/rest-api-runtime-adapter/Cargo.toml:32), the udp-server wrapper comment at deny.toml:57 and the two use-rest-api skill-link markers. The application builds the container in AppContainer::tracker_http_api_container (src/container.rs:177); initialize and initialize_from are called only from test code.

[Minor] The ban_service field has no reader. packages/rest-api-runtime-adapter/src/v1/container.rs:40 declares pub ban_service: Arc<RwLock<BanService>>, filled at packages/rest-api-runtime-adapter/src/v1/container.rs:121 and src/container.rs:187, but nothing in axum-rest-api-server, rest-api-application or rest-api-runtime-adapter reads it. Its last consumer was get_labeled_metrics in the rest-api-core statistics module that this change deleted, and that function already discarded the value into _udp_banned_ips_total; the banned-IP count the API reports comes from the UDP server statistics repository (packages/rest-api-runtime-adapter/src/v1/adapters/stats.rs:112). The tokio dependency at packages/rest-api-runtime-adapter/Cargo.toml:32 and the import at packages/rest-api-runtime-adapter/src/v1/container.rs:10 exist only to name this field's type. The published crate therefore carries a dependency for no consumer and gives every holder of the container a write handle to the lock the UDP tracker's ban service runs under (reset_bans and increase_counter take &mut self), against the packages/AGENTS.md guidance to avoid direct tokio::sync coupling between packages. Smallest fix: delete the field and its two initialisers, the RwLock and BanService imports, and the tokio line from the crate manifest.

[Nit] The module documentation at packages/rest-api-runtime-adapter/src/v1/container.rs:1 (lines 1 to 7) records history instead of behaviour. Lines 6 and 7 say the module "was moved here as part of SI-5", which in the published crate's documentation names a crate that no longer exists. Lines 3 and 4 say the module wires the tracker components the Axum server uses, but the running application composes the container from its own shared services at src/container.rs:177, while initialize (packages/rest-api-runtime-adapter/src/v1/container.rs:51) builds a separate swarm registry, a tracker core with its own database connection and a separate UDP server container, so an API built through it sees none of a running tracker's state. Smallest fix: replace lines 6 and 7 with a sentence saying that initialize builds an isolated set of components for tests and standalone use and that the application builds the container from the services it already runs.

[Nit] The marker at packages/axum-rest-api-server/src/v1/middlewares/auth.rs:11 is an inner doc line directly followed by the paragraph "Using the Authorization header:", so the rendered documentation of the module reads "skill-link: use-rest-api Using the Authorization header:" as one sentence. Smallest fix: write the marker as a plain // skill-link: use-rest-api comment, the other form docs/skills/semantic-skill-link-convention.md allows for Rust files.

Checked and found sound: nothing at 5a8e78861 referenced the deleted rest-api-core statistics module, so its removal dropped no live code path; every other container field is read by the v1 routes or the API job; deny.toml:57 matches its wrappers list and adds no edge, because the runtime adapter already depended on udp-server for its statistics adapter; the sync feature is all the moved type needs from tokio; the marker at share/default/config/tracker.development.sqlite3.toml:2 and the one in the middleware both resolve to the repository's use-rest-api skill, which lists both files; the lock file agrees with the manifests; and the crate publish list this change edited has since been replaced by a separate package release workflow.

This branch was previously deployed

1 inactive deployment
coverage — 5dda558d Deployed Jun 29, 2026 by josecelano via Generate Coverage Report #1514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SI-5: Deprecate rest-api-core and remove from workspace

3 participants